In preparation for removing lvalue.
* DHCP Opcode is request
*/
vp = pairfind(head, 256, DHCP_MAGIC_VENDOR);
- if (vp && vp->lvalue == 3) {
+ if (vp && vp->vp_integer == 3) {
/*
* Vendor is "MSFT 98"
*/
/*
* Reply should be broadcast.
*/
- if (vp) vp->lvalue |= 0x8000;
+ if (vp) vp->vp_integer |= 0x8000;
packet->data[10] |= 0x80;
}
}
char *q;
VALUE_PAIR *vp;
DICT_VENDOR *dv;
+ const DICT_ATTR *da;
/*
* Unknown attributes MUST be of type 'octets'
return NULL;
}
}
+
+ /*
+ * Maybe we're reading an old detail/config file, where
+ * it didn't know about a particular attribute and dumped
+ * it as hex. Now the dictionaries have been updated,
+ * and we know about it. So... convert it to the
+ * appropriate type.
+ *
+ * FIXME: call data2vp_any.
+ */
+ da = dict_attrbyvalue(attr, vendor);
+ if (da) {
+ /*
+ * FIXME: convert hex to the data type.
+ */
+ return NULL;
+ }
/*
* We've now parsed the attribute properly, Let's create
size = strlen(value + 2);
data = vp->vp_octets;
- /*
- * We may be reading something like Attr-5. i.e.
- * who-ever wrote the text didn't understand it, but we
- * do.
- */
- switch (vp->type) {
- default:
- if (size == (vp->length * 2)) break;
- vp->type = PW_TYPE_OCTETS;
- /* FALL-THROUGH */
-
- case PW_TYPE_OCTETS:
- case PW_TYPE_ABINARY:
- vp->length = size >> 1;
- if (vp->length > sizeof(vp->vp_octets)) {
- vp->vp_tlv = malloc(vp->length);
- if (!vp->vp_tlv) {
- fr_strerror_printf("Out of memory");
- free(vp);
- return NULL;
- }
- data = vp->vp_tlv;
- vp->type |= PW_FLAG_LONG;
- }
- break;
-
- case PW_TYPE_STRING:
- vp->length = size >> 1;
- memset(&vp->vp_strvalue, 0, sizeof(vp->vp_strvalue));
- if (vp->length >= sizeof(vp->vp_strvalue)) {
- vp->vp_tlv = malloc(vp->length);
- if (!vp->vp_tlv) {
- fr_strerror_printf("Out of memory");
- free(vp);
- return NULL;
- }
- data = vp->vp_tlv;
- vp->type |= PW_FLAG_LONG;
+ vp->length = size >> 1;
+ if (vp->length > sizeof(vp->vp_octets)) {
+ vp->vp_tlv = malloc(vp->length);
+ if (!vp->vp_tlv) {
+ fr_strerror_printf("Out of memory");
+ free(vp);
+ return NULL;
}
- break;
+ data = vp->vp_tlv;
+ vp->type |= PW_FLAG_LONG;
}
if (fr_hex2bin(value + 2, data, size) != vp->length) {
return NULL;
}
- /*
- * Move contents around based on type. This is
- * to work around the historical use of "lvalue".
- */
- switch (vp->type) {
- case PW_TYPE_DATE:
- case PW_TYPE_IPADDR:
- case PW_TYPE_INTEGER:
- memcpy(&vp->lvalue, vp->vp_octets, sizeof(vp->lvalue));
- vp->vp_strvalue[0] = '\0';
- break;
-
- default:
- break;
- }
-
return vp;
}
tail = &packet->vps;
- vp = paircreate(PW_VQP_PACKET_TYPE, 0, PW_TYPE_OCTETS);
+ vp = paircreate(PW_VQP_PACKET_TYPE, 0, PW_TYPE_INTEGER);
if (!vp) {
fr_strerror_printf("No memory");
return -1;
}
- vp->lvalue = packet->data[1];
+ vp->vp_integer = packet->data[1];
debug_pair(vp);
*tail = vp;
tail = &(vp->next);
- vp = paircreate(PW_VQP_ERROR_CODE, 0, PW_TYPE_OCTETS);
+ vp = paircreate(PW_VQP_ERROR_CODE, 0, PW_TYPE_INTEGER);
if (!vp) {
fr_strerror_printf("No memory");
return -1;
}
- vp->lvalue = packet->data[2];
+ vp->vp_integer = packet->data[2];
debug_pair(vp);
*tail = vp;
tail = &(vp->next);
- vp = paircreate(PW_VQP_SEQUENCE_NUMBER, 0, PW_TYPE_OCTETS);
+ vp = paircreate(PW_VQP_SEQUENCE_NUMBER, 0, PW_TYPE_INTEGER);
if (!vp) {
fr_strerror_printf("No memory");
return -1;
}
- vp->lvalue = packet->id; /* already set by vqp_recv */
+ vp->vp_integer = packet->id; /* already set by vqp_recv */
debug_pair(vp);
*tail = vp;
return -1;
}
- code = vp->lvalue;
+ code = vp->vp_integer;
if ((code < 1) || (code > 4)) {
fr_strerror_printf("Invalid value %d for VQP-Packet-Type", code);
return -1;
if (!vp) {
ptr[2] = 0;
} else {
- ptr[2] = vp->lvalue & 0xff;
+ ptr[2] = vp->vp_integer & 0xff;
return 0;
}
case PW_TYPE_DATE:
case PW_TYPE_SHORT:
case PW_TYPE_BYTE:
- snprintf(out, outlen, "%u", vp->lvalue);
+ snprintf(out, outlen, "%u", vp->vp_integer);
return strlen(out);
case PW_TYPE_SIGNED:
hack.type = cur->dattr->type;
hack.operator = T_OP_EQ;
hack.length = 4;
- hack.lvalue = request->packet->src_ipaddr.ipaddr.ip4addr.s_addr;
+ hack.vp_ipaddr = request->packet->src_ipaddr.ipaddr.ip4addr.s_addr;
vp = &hack;
} else {
RDEBUG2("WARNING: Attribute %s was not found in request, unique ID MAY be inconsistent", cur->dattr->name);
VALUE_PAIR *tmp;
tmp = pairfind(vp, PW_FALL_THROUGH, 0);
- return tmp ? tmp->lvalue : 0;
+ return tmp ? tmp->vp_integer : 0;
}
/*