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(const char *val);
+DICT_VALUE *dict_valbyname(int attr, const char *val);
int dict_vendorcode(int);
int dict_vendorpec(int);
int dict_vendorname(const char *name);
/*
* Get a value by its name.
+ * If you pass an actual attr, it will try to match it.
+ * If you just want it to return on the first match,
+ * send it 0 as the attr. I hope this works the way it
+ * seems to. :) --kph
*/
-DICT_VALUE * dict_valbyname(const char *name)
+DICT_VALUE * dict_valbyname(int attr, const char *name)
{
DICT_VALUE *v;
for (v = dictionary_values; v; v = v->next) {
- if (DICT_STRCMP(v->name, name) == 0)
- return v;
+ if ((attr == 0 || v->attr == attr) &&
+ DICT_STRCMP(v->name, name) == 0)
+ return v;
+
}
return NULL;
vp->lvalue = atoi(value);
vp->length = 4;
}
- else if ((dval = dict_valbyname(value)) == NULL) {
- free(vp);
+ /*
+ * Look for the named value for the given
+ * attribute.
+ */
+ else if ((dval = dict_valbyname(da->attr, value)) == NULL) {
+ free(vp);
librad_log("Unknown value %s for attribute %s",
value, vp->name);
return NULL;
* Check to see if it's already defined.
* If so, return the old value.
*/
- old_value = dict_valbyname(name);
- if (old_value) return old_value->value;
-
+ old_value = dict_valbyname(PW_AUTHTYPE, name);
+ if (old_value) return old_value->value;
/* Look for the predefined Auth-Type value */
old_value = dict_valbyattr(PW_AUTHTYPE, 0);
if (!old_value) return 0; /* something WIERD is happening */