typedef struct dict_vendor {
char vendorname[40];
int vendorpec;
- int vendorcode;
struct dict_vendor *next;
} DICT_VENDOR;
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
static DICT_VALUE *dictionary_values = NULL;
static DICT_VENDOR *dictionary_vendors = NULL;
-static int vendorno = 1;
static const char *dtypes[] = {
"string",
"integer",
dictionary_attributes = NULL;
dictionary_values = NULL;
dictionary_vendors = NULL;
- vendorno = 1;
memset(base_attributes, 0, sizeof(base_attributes));
}
{
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;
}
strcpy(vval->vendorname, name);
vval->vendorpec = value;
- vval->vendorcode = vendorno++;
/* Insert at front. */
vval->next = dictionary_vendors;
}
/*
- * 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)
{
*/
for (v = dictionary_vendors; v; v = v->next) {
if (DICT_STRCMP(name, v->vendorname) == 0) {
- return v->vendorcode;
+ return v->vendorpec;
}
}