remove util_alloc.c
[mech_eap.orig] / util_attr.h
index 90b0953..6f6c74a 100644 (file)
 #ifndef _UTIL_ATTR_H_
 #define _UTIL_ATTR_H_ 1
 
-#define ATTR_TYPE_RADIUS            0U
-#define ATTR_TYPE_SAML_ASSERTION    1U
-#define ATTR_TYPE_SAML              2U
-#define ATTR_TYPE_LOCAL             3U
-#define ATTR_TYPE_MIN               ATTR_TYPE_RADIUS
-#define ATTR_TYPE_MAX               (ATTR_TYPE_LOCAL + 1U)
-
 #ifdef __cplusplus
 #include <string>
 
@@ -51,6 +44,19 @@ typedef bool
                                const gss_buffer_t attribute,
                                void *data);
 
+#define ATTR_TYPE_RADIUS            0U                  /* RADIUS AVPs */
+#define ATTR_TYPE_SAML_ASSERTION    1U                  /* SAML assertion */
+#define ATTR_TYPE_SAML              2U                  /* SAML attributes */
+#define ATTR_TYPE_LOCAL             3U                  /* Local attributes */
+#define ATTR_TYPE_MIN               ATTR_TYPE_RADIUS
+#define ATTR_TYPE_MAX               ATTR_TYPE_LOCAL
+
+#define ATTR_FLAG_DISABLE_LOCAL     0x00000001
+
+/*
+ * Attribute provider: this represents a source of attributes derived
+ * from the security context.
+ */
 struct gss_eap_attr_provider
 {
 public:
@@ -106,8 +112,8 @@ public:
 
     virtual time_t getExpiryTime(void) const { return 0; }
 
-    static bool init() { return true; }
-    static void finalize() {}
+    static bool init(void) { return true; }
+    static void finalize(void) {}
 
     static gss_eap_attr_provider *createAttrContext(void) { return NULL; }
 
@@ -122,6 +128,10 @@ private:
 
 typedef gss_eap_attr_provider *(*gss_eap_attr_create_provider)(void);
 
+/*
+ * Attribute context: this manages a set of providers for a given
+ * security context.
+ */
 struct gss_eap_attr_ctx
 {
 public:
@@ -196,19 +206,27 @@ public:
     time_t getExpiryTime(void) const;
 
 private:
+    bool providerEnabled(unsigned int type) const;
+    void releaseProvider(unsigned int type);
+
     gss_eap_attr_provider *getPrimaryProvider(void) const;
 
     /* make non-copyable */
     gss_eap_attr_ctx(const gss_eap_attr_ctx&);
     gss_eap_attr_ctx& operator=(const gss_eap_attr_ctx&);
 
-    gss_eap_attr_provider *m_providers[ATTR_TYPE_MAX];
+    uint32_t m_flags;
+    gss_eap_attr_provider *m_providers[ATTR_TYPE_MAX + 1];
 };
 
+#endif /* __cplusplus */
+
 #include "util_radius.h"
 #include "util_saml.h"
 #include "util_shib.h"
 
+#ifdef __cplusplus
+
 #include <string>
 #include <new>
 
@@ -240,6 +258,12 @@ struct gss_eap_attr_ctx;
 extern "C" {
 #endif
 
+/*
+ * C wrappers for attribute context functions. These match their
+ * GSS naming extension equivalents. The caller is required to
+ * obtain the name mutex.
+ */
+
 struct gss_eap_attr_ctx *
 gssEapCreateAttrContext(gss_cred_id_t acceptorCred,
                         gss_ctx_id_t acceptorCtx);
@@ -306,9 +330,6 @@ gssEapReleaseAttrContext(OM_uint32 *minor,
                          gss_name_t name);
 
 OM_uint32
-gssEapAttrProvidersInit(OM_uint32 *minor);
-
-OM_uint32
 gssEapAttrProvidersFinalize(OM_uint32 *minor);
 
 #ifdef __cplusplus