The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
decode.c
Go to the documentation of this file.
1/*
2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
6 *
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: b52d225a31da6f9bb8b11c204a07848fe985f774 $
19 *
20 * @file protocols/dhcpv6/decode.c
21 * @brief Functions to decode DHCP options.
22 *
23 * @author Arran Cudbard-Bell (a.cudbardb@freeradius.org)
24 *
25 * @copyright 2018 The FreeRADIUS server project
26 * @copyright 2018 NetworkRADIUS SARL (legal@networkradius.com)
27 */
28#include <stdint.h>
29#include <stddef.h>
30
31#include <freeradius-devel/io/test_point.h>
32#include <freeradius-devel/util/dns.h>
33#include <freeradius-devel/util/proto.h>
34#include <freeradius-devel/util/struct.h>
35
36#include "dhcpv6.h"
37#include "attrs.h"
38
39static ssize_t decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out,
41 uint8_t const *data, size_t const data_len, void *decode_ctx);
42
45 uint8_t const *data, size_t const data_len, void *decode_ctx)
46{
47 return fr_pair_tlvs_from_network(ctx, out, parent, data, data_len, decode_ctx, decode_option, NULL, true);
48}
49
50static ssize_t decode_value(TALLOC_CTX *ctx, fr_pair_list_t *out,
52 uint8_t const *data, size_t const data_len, void *decode_ctx);
53
54/** Handle arrays of DNS labels for fr_struct_from_network()
55 *
56 */
59 uint8_t const *data, size_t const data_len, void *decode_ctx)
60{
62 return fr_pair_dns_labels_from_network(ctx, out, parent, data, data, data_len, NULL, false);
63 }
64
65 return decode_value(ctx, out, parent, data, data_len, decode_ctx);
66}
67
68
69static ssize_t decode_value(TALLOC_CTX *ctx, fr_pair_list_t *out,
71 uint8_t const *data, size_t const data_len, void *decode_ctx)
72{
73 ssize_t slen;
74 fr_pair_t *vp = NULL;
75 uint8_t prefix_len;
76 fr_dict_attr_t const *ref;
77
78 FR_PROTO_HEX_DUMP(data, data_len, "decode_value");
79
80 switch (parent->type) {
81 /*
82 * Address MAY be shorter than 16 bytes.
83 */
85 if (data_len == 0) {
86 raw:
87 return fr_pair_raw_from_network(ctx, out, parent, data, data_len);
88
89 }
90
91 /*
92 * Structs used fixed length IPv6 addressews.
93 */
94 if (parent->parent->type == FR_TYPE_STRUCT) {
95 if (data_len != (1 + sizeof(vp->vp_ipv6addr))) {
96 goto raw;
97 }
98
100 if (!vp) return PAIR_DECODE_OOM;
101
102 vp->vp_ip.af = AF_INET6;
103 vp->vp_ip.scope_id = 0;
104 vp->vp_ip.prefix = data[0];
105 memcpy(&vp->vp_ipv6addr, data + 1, sizeof(vp->vp_ipv6addr));
106 slen = 1 + sizeof(vp->vp_ipv6addr);
107 break;
108 }
109
110 /*
111 * No address, the prefix length MUST be zero.
112 */
113 if (data_len == 1) {
114 if (data[0] != 0) goto raw;
115
116 vp = fr_pair_afrom_da(ctx, parent);
117 if (!vp) return PAIR_DECODE_OOM;
118
119 vp->vp_ip.af = AF_INET6;
120 slen = 1;
121 break;
122 }
123
124 prefix_len = data[0];
125
126 /*
127 * If we have a /64 prefix but only 7 bytes of
128 * address, that's an error.
129 */
130 slen = fr_bytes_from_bits(prefix_len);
131 if ((size_t) slen > (data_len - 1)) {
132 goto raw;
133 }
134
135 vp = fr_pair_afrom_da(ctx, parent);
136 if (!vp) return PAIR_DECODE_OOM;
137
138 vp->vp_ip.af = AF_INET6;
139 vp->vp_ip.prefix = prefix_len;
140 memcpy(&vp->vp_ipv6addr, data + 1, slen);
141
142 slen++;
143 break;
144
145 /*
146 * A bool is encoded as an empty option if it's
147 * true. A bool is omitted entirely if it's
148 * false.
149 */
150 case FR_TYPE_BOOL:
151 if (data_len != 0) goto raw;
152 vp = fr_pair_afrom_da(ctx, parent);
153 if (!vp) return PAIR_DECODE_OOM;
154 vp->vp_bool = true;
155 slen = 0;
156 break;
157
158 /*
159 * A standard 32bit integer, but unlike normal UNIX timestamps
160 * starts from the 1st of January 2000.
161 *
162 * In the encoder we subtract 30 years to any values, so
163 * here we need to add that to the time here.
164 */
165 case FR_TYPE_DATE:
166 vp = fr_pair_afrom_da(ctx, parent);
167 if (!vp) return PAIR_DECODE_OOM;
168
169 slen = fr_value_box_from_network(vp, &vp->data, vp->vp_type, vp->da,
170 &FR_DBUFF_TMP(data, data_len), data_len, true);
171 if (slen < 0) {
173 goto raw;
174 }
176 break;
177
178 case FR_TYPE_STRUCT:
179 slen = fr_struct_from_network(ctx, out, parent, data, data_len,
181 if (slen < 0) goto raw;
182
183 if (parent->flags.array) return slen;
184 return data_len;
185
186 case FR_TYPE_GROUP:
187 vp = fr_pair_afrom_da(ctx, parent);
188 if (!vp) return PAIR_DECODE_OOM;
189
191 if (ref && (ref->dict != dict_dhcpv6)) {
193
194 proto = fr_dict_protocol(ref->dict);
195 fr_assert(proto != NULL);
196
197 if (!proto->decode) {
198 raw_free:
200 goto raw;
201 }
202
203 slen = proto->decode(vp, &vp->vp_group, data, data_len);
204 if (slen < 0) goto raw_free;
205
206 vp->vp_tainted = true;
207
208 } else {
209 if (!ref) ref = fr_dict_root(dict_dhcpv6);
210
211 /*
212 * Child VPs go into the child group, not in the main parent list. BUT, we start
213 * decoding attributes from the ref, and not from the group parent.
214 */
215 slen = fr_pair_tlvs_from_network(vp, &vp->vp_group, ref, data, data_len, decode_ctx, decode_option, NULL, false);
216 if (slen < 0) goto raw_free;
217 }
218
220 return data_len;
221
223 vp = fr_pair_afrom_da(ctx, parent);
224 if (!vp) return PAIR_DECODE_OOM;
225
226 /*
227 * Limit the IPv6 address to 16 octets, with no scope.
228 */
229 if (data_len < sizeof(vp->vp_ipv6addr)) goto raw;
230
231 slen = fr_value_box_from_network(vp, &vp->data, vp->vp_type, vp->da,
232 &FR_DBUFF_TMP(data, sizeof(vp->vp_ipv6addr)), sizeof(vp->vp_ipv6addr), true);
233 if (slen < 0) goto raw_free;
234 break;
235
236 default:
237 vp = fr_pair_afrom_da(ctx, parent);
238 if (!vp) return PAIR_DECODE_OOM;
239
240 slen = fr_value_box_from_network(vp, &vp->data, vp->vp_type, vp->da,
241 &FR_DBUFF_TMP(data, data_len), data_len, true);
242 if (slen < 0) goto raw_free;
243 break;
244 }
245
246 /*
247 * The input is larger than the decoded value, re-do it as a raw attribute.
248 */
249 if (!parent->flags.array && ((size_t) slen < data_len)) {
251 goto raw;
252 }
253
254 fr_assert(vp != NULL);
255
256 vp->vp_tainted = true;
258
259 if (parent->flags.array) return slen;
260
261 return data_len;
262}
263
264
265static ssize_t decode_vsa(TALLOC_CTX *ctx, fr_pair_list_t *out,
266 fr_dict_attr_t const *parent,
267 uint8_t const *data, size_t const data_len, void *decode_ctx)
268{
269 uint32_t pen;
270 fr_dict_attr_t const *da;
271 fr_pair_t *vp;
272 fr_dhcpv6_decode_ctx_t *packet_ctx = decode_ctx;
273
274 FR_PROTO_HEX_DUMP(data, data_len, "decode_vsa");
275
277 "%s: Internal sanity check failed, attribute \"%s\" is not of type 'vsa'",
278 __FUNCTION__, parent->name)) return PAIR_DECODE_FATAL_ERROR;
279
280 /*
281 * Enterprise code plus at least one option header
282 */
283 if (data_len < 8) return fr_pair_raw_from_network(ctx, out, parent, data, data_len);
284
285 memcpy(&pen, data, sizeof(pen));
286 pen = htonl(pen);
287
288 /*
289 * Verify that the parent (which should be a VSA)
290 * contains a fake attribute representing the vendor.
291 *
292 * If it doesn't then this vendor is unknown, but we know
293 * vendor attributes have a standard format, so we can
294 * decode the data anyway.
295 */
297 if (!da) {
299
301 if (!n) return PAIR_DECODE_OOM;
302 da = n;
303 }
304
305 FR_PROTO_TRACE("decode context %s -> %s", parent->name, da->name);
306
307 vp = fr_pair_find_by_da(out, NULL, da);
308 if (vp) {
309 return fr_pair_tlvs_from_network(vp, &vp->vp_group, da, data + 4, data_len - 4, decode_ctx, decode_option, NULL, false);
310 }
311
312 return fr_pair_tlvs_from_network(ctx, out, da, data + 4, data_len - 4, decode_ctx, decode_option, NULL, true);
313}
314
315static ssize_t decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out,
316 fr_dict_attr_t const *parent,
317 uint8_t const *data, size_t const data_len, void *decode_ctx)
318{
319 unsigned int option;
320 size_t len;
321 ssize_t slen;
322 fr_dict_attr_t const *da;
323 fr_dhcpv6_decode_ctx_t *packet_ctx = decode_ctx;
324
325#ifdef STATIC_ANALYZER
326 if (!packet_ctx || !packet_ctx->tmp_ctx) return PAIR_DECODE_FATAL_ERROR;
327#endif
328
329 /*
330 * Must have at least an option header.
331 */
332 if (data_len < 4) {
333 fr_strerror_printf("%s: Insufficient data", __FUNCTION__);
334 return -(data_len);
335 }
336
337 option = DHCPV6_GET_OPTION_NUM(data);
339 if (len > (data_len - 4)) {
340 fr_strerror_printf("%s: Option overflows input. "
341 "Optional length must be less than %zu bytes, got %zu bytes",
342 __FUNCTION__, data_len - 4, len);
344 }
345
346 da = fr_dict_attr_child_by_num(parent, option);
347 if (!da) {
348 da = fr_dict_attr_unknown_raw_afrom_num(packet_ctx->tmp_ctx, parent, option);
349 if (!da) return PAIR_DECODE_FATAL_ERROR;
350 }
351 FR_PROTO_TRACE("decode context changed %s -> %s",da->parent->name, da->name);
352
353 /*
354 * Relay messages are weird, and contain complete DHCPv6
355 * packets, copied verbatim from the DHCPv6 client.
356 */
357 if (da == attr_relay_message) {
358 fr_pair_t *vp;
359
361 if (!vp) return PAIR_DECODE_FATAL_ERROR;
362
363 slen = fr_dhcpv6_decode(vp, &vp->vp_group, data + 4, len);
364 if (slen < 0) {
366 raw:
367 slen = fr_pair_raw_from_network(ctx, out, da, data + 4, len);
368 if (slen < 0) return slen;
369 return 4 + slen;
370 }
371
373
374 } else if ((da->type == FR_TYPE_STRING) && fr_dhcpv6_flag_any_dns_label(da)) {
375 slen = fr_pair_dns_labels_from_network(ctx, out, da, data + 4, data + 4, len, NULL, true);
376 if (slen < 0) return slen;
377
378 } else if (da->flags.array) {
379 slen = fr_pair_array_from_network(ctx, out, da, data + 4, len, decode_ctx, decode_value);
380
381 } else if (da->type == FR_TYPE_VSA) {
382 bool append = false;
383 fr_pair_t *vp;
384
385 vp = fr_pair_find_by_da(out, NULL, da);
386 if (!vp) {
387 vp = fr_pair_afrom_da(ctx, da);
388 if (!vp) return PAIR_DECODE_FATAL_ERROR;
389
390 append = true;
391 }
392
393 slen = decode_vsa(vp, &vp->vp_group, da, data + 4, len, decode_ctx);
394 if (append) {
395 if (slen < 0) {
396 TALLOC_FREE(vp);
397 } else {
399 }
400 }
401
402 } else if (da->type == FR_TYPE_TLV) {
403 slen = fr_pair_tlvs_from_network(ctx, out, da, data + 4, len, decode_ctx, decode_option, NULL, true);
404
405 } else {
406 slen = decode_value(ctx, out, da, data + 4, len, decode_ctx);
407 }
408
409 if (slen < 0) goto raw;
410
411 return len + 4;
412}
413
414
415/** Create a "normal" fr_pair_t from the given data
416 *
417 * 0 1 2 3
418 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
419 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
420 * | option-code | option-len |
421 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
422 */
424 uint8_t const *data, size_t data_len, void *decode_ctx)
425{
426 FR_PROTO_HEX_DUMP(data, data_len, "fr_dhcpv6_decode_pair");
427
428 /*
429 * The API changes, so we just bounce directly to the
430 * decode_option() function.
431 *
432 * All options including VSAs in DHCPv6 MUST follow the
433 * standard format.
434 */
435 return decode_option(ctx, out, fr_dict_root(dict_dhcpv6), data, data_len, decode_ctx);
436}
437
439 uint8_t const *data, size_t data_len)
440{
441 ssize_t slen;
442 uint8_t const *attr, *end;
443
444 fr_dhcpv6_decode_ctx_t decode_ctx = {};
445
446 fr_assert(dict_dhcpv6 != NULL);
447
448 decode_ctx.tmp_ctx = talloc(ctx, uint8_t);
449
450 attr = data;
451 end = data + data_len;
452
453 while (attr < end) {
454 slen = fr_dhcpv6_decode_option(ctx, out, attr, (end - attr), &decode_ctx);
455 if (slen < 0) {
456 talloc_free(decode_ctx.tmp_ctx);
457 return slen;
458 }
459
460 /*
461 * If slen is larger than the room in the packet,
462 * all kinds of bad things happen.
463 */
464 if (!fr_cond_assert(slen <= (end - attr))) {
465 talloc_free(decode_ctx.tmp_ctx);
466 return -slen - (attr - data);
467 }
468
469 attr += slen;
470 talloc_free_children(decode_ctx.tmp_ctx);
471 }
472
473 talloc_free(decode_ctx.tmp_ctx);
474 return data_len;
475}
476
477static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
478{
479 fr_dhcpv6_decode_ctx_t *test_ctx;
480
481 test_ctx = talloc_zero(ctx, fr_dhcpv6_decode_ctx_t);
482 if (!test_ctx) return -1;
483
484 test_ctx->tmp_ctx = talloc(test_ctx, uint8_t);
485
486 *out = test_ctx;
487
488 return 0;
489}
490
491static ssize_t fr_dhcpv6_decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, UNUSED void *proto_ctx)
492{
493 size_t packet_len = data_len;
494// fr_dhcpv6_decode_ctx_t *test_ctx = talloc_get_type_abort(proto_ctx, fr_dhcpv6_decode_ctx_t);
495
496 if (!fr_dhcpv6_ok(data, packet_len, 200)) return -1;
497
498 return fr_dhcpv6_decode(ctx, out, data, packet_len);
499}
500
501
503 uint8_t const *data, size_t data_len, void *decode_ctx)
504{
506
507 return decode_option(ctx, out, fr_dict_root(dict_dhcpv6), data, data_len, decode_ctx);
508}
509
510/*
511 * Test points
512 */
518
int n
Definition acutest.h:577
#define NDEBUG_UNUSED
Definition build.h:326
#define UNUSED
Definition build.h:315
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
Definition dbuff.h:514
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
Definition debug.h:139
#define fr_cond_assert_msg(_x, _fmt,...)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
Definition debug.h:156
Implementation of the DHCPv6 protocol.
#define DHCPV6_GET_OPTION_NUM(_x)
Definition dhcpv6.h:47
#define DHCPV6_GET_OPTION_LEN(_x)
Definition dhcpv6.h:48
static bool fr_dhcpv6_flag_any_dns_label(fr_dict_attr_t const *da)
Definition dhcpv6.h:152
#define DHCPV6_DATE_OFFSET
Definition dhcpv6.h:124
TALLOC_CTX * tmp_ctx
for temporary things cleaned up during decoding
Definition dhcpv6.h:133
static fr_dict_attr_t * fr_dict_attr_unknown_vendor_afrom_num(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int vendor)
Definition dict.h:573
fr_dict_protocol_t const * fr_dict_protocol(fr_dict_t const *dict)
Return the protocol descriptor for the dictionary.
Definition dict_util.c:4948
static fr_dict_attr_t * fr_dict_attr_unknown_raw_afrom_num(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int attr)
Definition dict.h:580
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
Definition dict_util.c:2400
fr_dict_attr_t const * fr_dict_attr_child_by_num(fr_dict_attr_t const *parent, unsigned int attr)
Check if a child attribute exists in a parent using an attribute number.
Definition dict_util.c:3328
Protocol-specific callbacks in libfreeradius-PROTOCOL.
Definition dict.h:429
static fr_dict_attr_t const * fr_dict_attr_ref(fr_dict_attr_t const *da)
Return the reference associated with a group type attribute.
Definition dict_ext.h:184
#define PAIR_DECODE_OOM
Fatal error - Out of memory.
Definition pair.h:45
#define PAIR_DECODE_FATAL_ERROR
Fatal error - Failed decoding the packet.
Definition pair.h:49
ssize_t fr_pair_tlvs_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx, fr_pair_decode_value_t decode_tlv, fr_pair_tlvs_verify_t verify_tlvs, bool nested)
Decode a list of pairs from the network.
Definition decode.c:148
ssize_t fr_pair_dns_labels_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *start, uint8_t const *data, size_t const data_len, fr_dns_labels_t *lb, bool exact)
Decode a DNS label or a list of DNS labels from the network.
Definition decode.c:237
ssize_t fr_pair_array_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx, fr_pair_decode_value_t decode_value)
Decode an array of values from the network.
Definition decode.c:41
ssize_t fr_pair_raw_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len)
Create a "raw" pair from the network data.
Definition decode.c:79
talloc_free(reap)
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_IPV6_PREFIX
IPv6 Prefix.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
@ FR_TYPE_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_BOOL
A truth value.
@ FR_TYPE_VSA
Vendor-Specific, for RADIUS attribute 26.
@ FR_TYPE_GROUP
A grouping of other attributes.
unsigned int uint32_t
long int ssize_t
unsigned char uint8_t
static unsigned int fr_bytes_from_bits(unsigned int bits)
Convert bits (as in prefix length) to bytes, rounding up.
Definition nbo.h:237
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
Definition pair.c:693
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
Definition pair.c:1345
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
Definition pair.c:283
static fr_dict_t const * dict_dhcpv6
static fr_dict_attr_t const * attr_relay_message
static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
Definition decode.c:102
static ssize_t decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx)
Definition decode.c:433
static ssize_t decode_value_trampoline(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx)
Handle arrays of DNS labels for fr_struct_from_network()
Definition decode.c:70
static ssize_t decode_vsa(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx)
RFC 4243 Vendor Specific Suboptions.
Definition decode.c:349
static ssize_t decode_tlv_trampoline(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx)
Definition decode.c:57
bool fr_dhcpv6_ok(uint8_t const *packet, size_t packet_len, uint32_t max_attributes)
See if the data pointed to by PTR is a valid DHCPv6 packet.
Definition base.c:230
ssize_t fr_dhcpv6_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *packet, size_t packet_len)
Decode a DHCPv6 packet.
Definition base.c:581
ssize_t fr_dhcpv6_decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, void *decode_ctx)
Create a "normal" fr_pair_t from the given data.
Definition decode.c:423
fr_test_point_pair_decode_t dhcpv6_tp_decode_pair
Definition decode.c:514
fr_test_point_proto_decode_t dhcpv6_tp_decode_proto
Definition decode.c:520
ssize_t fr_dhcpv6_decode_foreign(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len)
Definition decode.c:438
static ssize_t fr_dhcpv6_decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, UNUSED void *proto_ctx)
Definition decode.c:491
static ssize_t decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, NDEBUG_UNUSED fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx)
Definition decode.c:502
#define decode_value
Definition decode.c:410
VQP attributes.
#define fr_assert(_expr)
Definition rad_assert.h:38
static char const * proto(int id, int porttype)
Definition radwho.c:85
fr_pair_t * vp
ssize_t fr_struct_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx, fr_pair_decode_value_t decode_value, fr_pair_decode_value_t decode_tlv)
Convert a STRUCT to one or more VPs.
Definition struct.c:33
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
Definition pair.h:69
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Definition test_point.h:85
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Definition test_point.h:67
Entry point for pair decoders.
Definition test_point.h:84
Entry point for protocol decoders.
Definition test_point.h:66
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
Definition time.h:590
#define fr_unix_time_add(_a, _b)
Add a time/time delta together.
Definition time.h:324
static fr_slen_t parent
Definition pair.h:851
#define FR_PROTO_HEX_DUMP(_data, _data_len, _fmt,...)
Definition proto.h:41
#define FR_PROTO_TRACE(_fmt,...)
Definition proto.h:40
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
Definition strerror.h:64
ssize_t fr_value_box_from_network(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv, fr_dbuff_t *dbuff, size_t len, bool tainted)
Decode a fr_value_box_t from serialized binary data.
Definition value.c:1754
static fr_slen_t data
Definition value.h:1265
static size_t char ** out
Definition value.h:997