Merge branch 'oldradius'
[mech_eap.git] / util_radius.h
index d6ab501..acc2283 100644 (file)
@@ -66,7 +66,14 @@ public:
     bool initFromBuffer(const gss_eap_attr_ctx *ctx,
                         const gss_buffer_t buffer);
 
-    bool getAttribute(unsigned int attribute,
+    bool getAttribute(int attribute,
+                      int *authenticated,
+                      int *complete,
+                      gss_buffer_t value,
+                      gss_buffer_t display_value,
+                      int *more) const;
+    bool getAttribute(int attribute,
+                      int vendor,
                       int *authenticated,
                       int *complete,
                       gss_buffer_t value,
@@ -81,6 +88,14 @@ public:
     static gss_eap_attr_provider *createAttrContext(void);
 
 private:
+    bool initFromGssCred(const gss_cred_id_t cred);
+    static VALUE_PAIR *copyAvps(const VALUE_PAIR *in);
+    const VALUE_PAIR *getAvps(void) const {
+        return m_avps;
+    }
+
+    rc_handle *m_rh;
+    VALUE_PAIR *m_avps;
     bool m_authenticated;
 };
 
@@ -90,42 +105,37 @@ private:
 extern "C" {
 #endif
 
-static inline OM_uint32
+OM_uint32
 addAvpFromBuffer(OM_uint32 *minor,
                  rc_handle *rh,
                  VALUE_PAIR **vp,
                  int type,
-                 gss_buffer_t buffer)
-{
-    if (rc_avpair_add(rh, vp, type, buffer->value, buffer->length, 0) == NULL) {
-        *minor = ENOMEM;
-        return GSS_S_FAILURE;
-    }
-
-    return GSS_S_COMPLETE;
-}
+                 gss_buffer_t buffer);
 
-static inline OM_uint32
+OM_uint32
 getBufferFromAvps(OM_uint32 *minor,
                   VALUE_PAIR *vps,
                   int type,
-                  gss_buffer_t buffer)
-{
-    VALUE_PAIR *vp;
-    gss_buffer_desc tmp = GSS_C_EMPTY_BUFFER;
-
-    vp = rc_avpair_get(vps, type, 0);
-    if (vp != NULL) {
-        tmp.length = vp->lvalue;
-        tmp.value = vp->strvalue;
-    }
-
-    return duplicateBuffer(minor, &tmp, buffer);
-}
+                  gss_buffer_t buffer,
+                  int concat);
 
 OM_uint32 gssEapRadiusAttrProviderInit(OM_uint32 *minor);
 OM_uint32 gssEapRadiusAttrProviderFinalize(OM_uint32 *minor);
 
+OM_uint32
+gssEapRadiusAllocHandle(OM_uint32 *minor,
+                        const gss_cred_id_t cred,
+                        rc_handle **pHandle);
+
+#define RC_CONFIG_FILE      SYSCONFDIR "/radiusclient/radiusclient.conf"
+
+/* RFC 2548 - Microsoft Vendor-specific RADIUS Attributes */
+#define RADIUS_VENDOR_ID_MICROSOFT 311
+
+enum { RADIUS_VENDOR_ATTR_MS_MPPE_SEND_KEY = 16,
+       RADIUS_VENDOR_ATTR_MS_MPPE_RECV_KEY = 17
+};
+
 #ifdef __cplusplus
 }
 #endif