fr_io_address_t const *address = track->address;
RADCLIENT const *client;
RADIUS_PACKET *packet = request->packet;
+ fr_cursor_t cursor;
/*
* Set the request dictionary so that we can do
* That MUST be set and checked in the underlying
* transport, via a call to fr_dhcpv6_ok().
*/
- if (fr_dhcpv6_decode(packet, packet->data, packet->data_len, &packet->vps) < 0) {
+ fr_cursor_init(&cursor, &packet->vps);
+ if (fr_dhcpv6_decode(packet, packet->data, packet->data_len, &cursor) < 0) {
RPEDEBUG("Failed decoding packet");
return -1;
}
/** Decode a DHCPv6 packet
*
*/
-ssize_t fr_dhcpv6_decode(TALLOC_CTX *ctx, uint8_t const *packet, size_t packet_len, VALUE_PAIR **vps)
+ssize_t fr_dhcpv6_decode(TALLOC_CTX *ctx, uint8_t const *packet, size_t packet_len, fr_cursor_t *cursor)
{
ssize_t slen;
- fr_cursor_t cursor;
uint8_t const *p, *end;
fr_dhcpv6_decode_ctx_t packet_ctx;
VALUE_PAIR *vp;
- fr_cursor_init(&cursor, vps);
-
/*
* Get the packet type.
*/
vp->vp_uint32 = packet[0];
vp->type = VT_DATA;
- fr_cursor_append(&cursor, vp);
+ fr_cursor_append(cursor, vp);
if ((packet[0] == FR_DHCPV6_RELAY_FORWARD) ||
(packet[0] == FR_DHCPV6_RELAY_REPLY)) {
if (fr_value_box_from_network(vp, &vp->data, vp->da->type, NULL, packet + 1, 1, true) < 0) {
goto fail;
}
- fr_cursor_append(&cursor, vp);
+ fr_cursor_append(cursor, vp);
vp = fr_pair_afrom_da(ctx, attr_relay_link_address);
if (!vp) goto fail;
if (fr_value_box_from_network(vp, &vp->data, vp->da->type, NULL, packet + 2, 16, true) < 0) {
goto fail;
}
- fr_cursor_append(&cursor, vp);
+ fr_cursor_append(cursor, vp);
vp = fr_pair_afrom_da(ctx, attr_relay_peer_address);
if (!vp) goto fail;
goto fail;
}
- fr_cursor_append(&cursor, vp);
+ fr_cursor_append(cursor, vp);
p = packet + 2 + 32;
goto decode_options;
vp = fr_pair_afrom_da(ctx, attr_transaction_id);
if (!vp) {
fail:
- fr_pair_list_free(vps);
+ fr_cursor_head(cursor);
+ fr_cursor_free_list(cursor);
return -1;
}
(void) fr_pair_value_memdup(vp, packet + 1, 3, false);
vp->type = VT_DATA;
- fr_cursor_append(&cursor, vp);
+ fr_cursor_append(cursor, vp);
p = packet + 4;
* he doesn't, all hell breaks loose.
*/
while (p < end) {
- slen = fr_dhcpv6_decode_option(ctx, &cursor, dict_dhcpv6, p, (end - p), &packet_ctx);
+ slen = fr_dhcpv6_decode_option(ctx, cursor, dict_dhcpv6, p, (end - p), &packet_ctx);
if (slen < 0) {
- fr_pair_list_free(vps);
+ fr_cursor_head(cursor);
+ fr_cursor_free_list(cursor);
talloc_free(packet_ctx.tmp_ctx);
return slen;
}
* all kinds of bad things happen.
*/
if (!fr_cond_assert(slen <= (end - p))) {
- fr_pair_list_free(vps);
+ fr_cursor_head(cursor);
+ fr_cursor_free_list(cursor);
talloc_free(packet_ctx.tmp_ctx);
return -1;
}
*/
if (da == attr_relay_message) {
VALUE_PAIR *vp;
+ fr_cursor_t cursor_group;
vp = fr_pair_afrom_da(ctx, attr_relay_message);
if (!vp) return PAIR_DECODE_FATAL_ERROR;
- rcode = fr_dhcpv6_decode(ctx, data + 4, len, &vp->vp_group);
+ fr_cursor_init(&cursor_group, &vp->vp_group);
+ rcode = fr_dhcpv6_decode(ctx, data + 4, len, &cursor_group);
if (rcode < 0) {
talloc_free(vp);
return rcode;
static ssize_t fr_dhcpv6_decode_proto(TALLOC_CTX *ctx, VALUE_PAIR **vps, uint8_t const *data, size_t data_len, UNUSED void *proto_ctx)
{
size_t packet_len = data_len;
+ fr_cursor_t cursor;
// fr_dhcpv6_decode_ctx_t *test_ctx = talloc_get_type_abort(proto_ctx, fr_dhcpv6_decode_ctx_t);
if (!fr_dhcpv6_ok(data, packet_len, 200)) return -1;
*vps = NULL;
+ fr_cursor_init(&cursor, vps);
- return fr_dhcpv6_decode(ctx, data, packet_len, vps);
+ return fr_dhcpv6_decode(ctx, data, packet_len, &cursor);
}