use JSON instead of DDF marshalling
[mech_eap.git] / util_radius.h
index 30ac07e..656f1b7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, JANET(UK)
+ * Copyright (c) 2011, JANET(UK)
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * SUCH DAMAGE.
  */
 
+/*
+ * RADIUS attribute provider.
+ */
+
 #ifndef _UTIL_RADIUS_H_
 #define _UTIL_RADIUS_H_ 1
 
@@ -47,10 +51,10 @@ public:
                             const gss_ctx_id_t ctx);
 
     bool getAttributeTypes(gss_eap_attr_enumeration_cb, void *data) const;
-    void setAttribute(int complete,
+    bool setAttribute(int complete,
                       const gss_buffer_t attr,
                       const gss_buffer_t value);
-    void deleteAttribute(const gss_buffer_t value);
+    bool deleteAttribute(const gss_buffer_t attr);
     bool getAttribute(const gss_buffer_t attr,
                       int *authenticated,
                       int *complete,
@@ -62,26 +66,32 @@ public:
     void releaseAnyNameMapping(gss_buffer_t type_id,
                                gss_any_t input) const;
 
-    void exportToBuffer(gss_buffer_t buffer) const;
-    bool initFromBuffer(const gss_eap_attr_ctx *ctx,
-                        const gss_buffer_t buffer);
+    const char *prefix(void) const;
+    const char *name(void) const;
+    bool initWithJsonObject(const gss_eap_attr_ctx *manager,
+                           json_t *obj);
+    json_t *jsonRepresentation(void) const;
 
-    bool getAttribute(int attribute,
+    bool getAttribute(uint32_t attribute,
                       int *authenticated,
                       int *complete,
                       gss_buffer_t value,
                       gss_buffer_t display_value,
                       int *more) const;
-    bool getAttribute(int attribute,
-                      int vendor,
+    bool getAttribute(uint16_t attribute,
+                      uint16_t vendor,
                       int *authenticated,
                       int *complete,
                       gss_buffer_t value,
                       gss_buffer_t display_value,
                       int *more) const;
+    bool setAttribute(int complete,
+                      uint32_t attribute,
+                      const gss_buffer_t value);
+    bool deleteAttribute(uint32_t attribute);
 
-    bool getFragmentedAttribute(int attribute,
-                                int vendor,
+    bool getFragmentedAttribute(uint16_t attribute,
+                                uint16_t vendor,
                                 int *authenticated,
                                 int *complete,
                                 gss_buffer_t value) const;
@@ -96,14 +106,11 @@ 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;
+        return m_vps;
     }
 
-    rc_handle *m_rh;
-    VALUE_PAIR *m_avps;
+    VALUE_PAIR *m_vps;
     bool m_authenticated;
 };
 
@@ -112,46 +119,54 @@ extern "C" {
 #endif
 
 OM_uint32
-addAvpFromBuffer(OM_uint32 *minor,
-                 rc_handle *rh,
-                 VALUE_PAIR **vp,
-                 int type,
-                 int vendor,
-                 gss_buffer_t buffer);
+gssEapRadiusAddAvp(OM_uint32 *minor,
+                   VALUE_PAIR **vp,
+                   uint16_t type,
+                   uint16_t vendor,
+                   const gss_buffer_t buffer);
+
+OM_uint32
+gssEapRadiusGetAvp(OM_uint32 *minor,
+                   VALUE_PAIR *vps,
+                   uint16_t type,
+                   uint16_t vendor,
+                   gss_buffer_t buffer,
+                   int concat);
 
 OM_uint32
-getBufferFromAvps(OM_uint32 *minor,
-                  VALUE_PAIR *vps,
-                  int type,
-                  int vendor,
-                  gss_buffer_t buffer,
-                  int concat);
+gssEapRadiusGetRawAvp(OM_uint32 *minor,
+                      VALUE_PAIR *vps,
+                      uint16_t type,
+                      uint16_t vendor,
+                      VALUE_PAIR **vp);
+OM_uint32
+gssEapRadiusFreeAvps(OM_uint32 *minor,
+                     VALUE_PAIR **vps);
 
 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);
+gssEapRadiusMapError(OM_uint32 *minor,
+                     struct rs_error *err);
 
-#define RC_CONFIG_FILE      SYSCONFDIR "/radiusclient/radiusclient.conf"
+#define RS_CONFIG_FILE      SYSCONFDIR "/radsec.conf"
 
-/* RFC 2548 - Microsoft Vendor-specific RADIUS Attributes */
-#define VENDOR_ID_MICROSOFT 311
+#define VENDORPEC_MS                        311 /* RFC 2548 */
 
-enum { VENDOR_ATTR_MS_MPPE_SEND_KEY = 16,
-       VENDOR_ATTR_MS_MPPE_RECV_KEY = 17
-};
+#define PW_MS_MPPE_SEND_KEY                 16
+#define PW_MS_MPPE_RECV_KEY                 17
 
-#define VENDOR_ID_UKERNA    25622
+#define VENDORPEC_UKERNA                    25622
 
-enum { VENDOR_ATTR_GSS_ACCEPTOR_SERVICE_NAME = 128,
-       VENDOR_ATTR_GSS_ACCEPTOR_HOST_NAME,
-       VENDOR_ATTR_GSS_ACCEPTOR_SERVICE_SPECIFIC,
-       VENDOR_ATTR_GSS_ACCEPTOR_REALM_NAME,
-       VENDOR_ATTR_SAML_AAA_ASSERTION
-};
+#define PW_GSS_ACCEPTOR_SERVICE_NAME        128
+#define PW_GSS_ACCEPTOR_HOST_NAME           129
+#define PW_GSS_ACCEPTOR_SERVICE_SPECIFIC    130
+#define PW_GSS_ACCEPTOR_REALM_NAME          131
+#define PW_SAML_AAA_ASSERTION               132
+
+#define IS_RADIUS_ERROR(code)               ((code) >= ERROR_TABLE_BASE_rse && \
+                                             (code) <= ERROR_TABLE_BASE_rse + RSE_TIMEOUT_IO)
 
 #ifdef __cplusplus
 }