else
a = ip_ntoa(NULL, vp->lvalue);
break;
-#ifdef ASCEND_BINARY
case PW_TYPE_ABINARY:
+#ifdef ASCEND_BINARY
a = buf;
print_abinary(vp, buf, sizeof(buf));
break;
#endif
+ case PW_TYPE_OCTETS:
+ strcpy(buf, "0x");
+ a = buf + 2;
+ for (t = 0; t < vp->length; t++) {
+ sprintf(a, "%02x", vp->strvalue[t]);
+ a += 2;
+ }
+ a = buf;
+ break;
+
default:
a = "UNKNOWN-TYPE";
break;
if (reply->length == 0 && reply->strvalue[0] != 0)
reply->length = strlen(reply->strvalue);
+#ifndef ASCEND_BINARY
+ case PW_TYPE_ABINARY:
+#endif
+ case PW_TYPE_OCTETS:
len = reply->length;
+
if (len >= MAX_STRING_LEN) {
len = MAX_STRING_LEN - 1;
}
DICT_ATTR *da;
DICT_VALUE *dval;
VALUE_PAIR *vp;
- char *p, *s;
+ u_char *p, *s;
if ((da = dict_attrbyname(attribute)) == NULL) {
librad_log("unknown attribute %s", attribute);
switch(da->type) {
case PW_TYPE_STRING:
vp->length = strlen(value);
+ if (vp->length >= MAX_STRING_LEN) {
+ vp->length = MAX_STRING_LEN - 1;
+ }
break;
case PW_TYPE_IPADDR:
/*
}
vp->length = 4;
break;
-#ifdef ASCEND_BINARY
case PW_TYPE_ABINARY:
+#ifdef ASCEND_BINARY
/*
* special case to convert filter to binary
*/
break;
#endif
+ /* raw octets: 0x01020304... */
+ case PW_TYPE_OCTETS:
+ vp->length = 0;
+ if (strncasecmp(value, "0x", 2) == 0) {
+ p = value + 2;
+ s = vp->strvalue;
+ while (*p && vp->length < MAX_STRING_LEN) {
+ unsigned int tmp;
+
+ if (sscanf(p, "%02x", &tmp) != 1) break;
+ p += 2;
+ *(s++) = tmp;
+ vp->length++;
+ }
+ *s = '\0';
+ }
+ break;
+
default:
free(vp);
- librad_log("unknown attribute type");
+ librad_log("unknown attribute type %d", da->type);
return NULL;
}
return vp;