Removed mapping of vendor Private Enterprise Code to internal code.
authoraland <aland>
Tue, 30 Oct 2001 16:36:48 +0000 (16:36 +0000)
committeraland <aland>
Tue, 30 Oct 2001 16:36:48 +0000 (16:36 +0000)
We now use the vendor PEC directly, which means that we error out
if the vendor PEC is larger than 65535.

Fixing that problem requires major changes to the source, which
can wait until later.

src/include/libradius.h
src/lib/dict.c

index 57637b8..8baf625 100644 (file)
@@ -94,7 +94,6 @@ typedef struct dict_value {
 typedef struct dict_vendor {
        char                    vendorname[40];
        int                     vendorpec;
-       int                     vendorcode;
        struct dict_vendor      *next;
 } DICT_VENDOR;
 
@@ -156,10 +155,15 @@ DICT_ATTR *dict_attrbyvalue(int attr);
 DICT_ATTR      *dict_attrbyname(const char *attr);
 DICT_VALUE     *dict_valbyattr(int attr, int val);
 DICT_VALUE     *dict_valbyname(int attr, const char *val);
-int            dict_vendorcode(int);
-int            dict_vendorpec(int);
 int            dict_vendorname(const char *name);
 
+/*
+ *  Compatibility
+ */
+#define dict_vendorcode
+#define dict_vendorpec
+
+
 #if 1 /* FIXME: compat */
 #define dict_attrget   dict_attrbyvalue
 #define dict_attrfind  dict_attrbyname
index 71ea5c9..5e0e0ba 100644 (file)
@@ -24,7 +24,6 @@ static DICT_ATTR      *dictionary_attributes = NULL;
 static DICT_VALUE      *dictionary_values = NULL;
 static DICT_VENDOR     *dictionary_vendors = NULL;
 
-static int             vendorno = 1;
 static const char *dtypes[] = {
        "string",
        "integer",
@@ -78,7 +77,6 @@ static void dict_free(void)
        dictionary_attributes = NULL;
        dictionary_values = NULL;
        dictionary_vendors = NULL;
-       vendorno = 1;
 
        memset(base_attributes, 0, sizeof(base_attributes));
 }
@@ -90,6 +88,11 @@ int dict_addvendor(const char *name, int value)
 {
        DICT_VENDOR *vval;
 
+       if (value >= (1 << 16)) {
+               librad_log("dict_addvendor: Cannot handle vendor ID larger than 65535");
+               return -1;
+       }
+
        if (strlen(name) > (sizeof(vval->vendorname) -1)) {
                librad_log("dict_addvendor: vendor name too long");
                return -1;
@@ -101,7 +104,6 @@ int dict_addvendor(const char *name, int value)
        }
        strcpy(vval->vendorname, name);
        vval->vendorpec  = value;
-       vval->vendorcode = vendorno++;
 
        /* Insert at front. */
        vval->next = dictionary_vendors;
@@ -642,35 +644,7 @@ DICT_VALUE * dict_valbyname(int attr, const char *name)
 }
 
 /*
- *     Get the PEC (Private Enterprise Code) of the vendor
- *     based on its internal number.
- */
-int dict_vendorpec(int code)
-{
-       DICT_VENDOR     *v;
-
-       for (v = dictionary_vendors; v; v = v->next)
-               if (v->vendorcode == code)
-                       break;
-
-       return v ? v->vendorpec : 0;
-}
-
-/*
- *     Get the internal code of the vendor based on its PEC.
- */
-int dict_vendorcode(int pec)
-{
-       DICT_VENDOR     *v;
-
-       for (v = dictionary_vendors; v; v = v->next)
-               if (v->vendorpec == pec)
-                       break;
-       return v ? v->vendorcode : 0;
-}
-
-/*
- *     Get the vendor code based on the vendor name
+ *     Get the vendor PEC based on the vendor name
  */
 int dict_vendorname(const char *name)
 {
@@ -681,7 +655,7 @@ int dict_vendorname(const char *name)
         */
        for (v = dictionary_vendors; v; v = v->next) {
                if (DICT_STRCMP(name, v->vendorname) == 0) {
-                       return v->vendorcode;
+                       return v->vendorpec;
                }
        }