Permit *known* attributes to be sent as hex via 0x...
authoraland <aland>
Tue, 15 Jan 2008 14:33:38 +0000 (14:33 +0000)
committeraland <aland>
Tue, 15 Jan 2008 14:33:38 +0000 (14:33 +0000)
src/lib/valuepair.c

index d831b00..2c65fb1 100644 (file)
@@ -1174,6 +1174,7 @@ static VALUE_PAIR *pairmake_any(const char *attribute, const char *value,
        const char      *p = attribute;
        char            *q;
        VALUE_PAIR      *vp;
+       DICT_ATTR       *da;
 
        /*
         *      Unknown attributes MUST be of type 'octets'
@@ -1183,6 +1184,12 @@ static VALUE_PAIR *pairmake_any(const char *attribute, const char *value,
                return NULL;
        }
 
+       da = dict_attrbyname(attribute);
+       if (da) {
+               attr = da->attr;
+               goto raw;
+       }
+
        attr = vendor = 0;
 
        /*
@@ -1284,6 +1291,7 @@ static VALUE_PAIR *pairmake_any(const char *attribute, const char *value,
 
        attr |= vendor << 16;
 
+ raw:
        /*
         *      We've now parsed the attribute properly, Let's create
         *      it.  This next stop also looks the attribute up in the
@@ -1396,6 +1404,11 @@ VALUE_PAIR *pairmake(const char *attribute, const char *value, int operator)
                return pairmake_any(attribute, value, operator);
        }
 
+       if ((value[0] == '0') && (value[1] == 'x') &&
+           (da->type != PW_TYPE_OCTETS)) {
+               return pairmake_any(attribute, value, operator);
+       }
+
        if ((vp = pairalloc(da)) == NULL) {
                librad_log("out of memory");
                return NULL;