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: ede1e2a3bc7203207c2638e0d7a9e7489e9802fb $
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 fr_dict_attr_t const *ref;
76
77 FR_PROTO_HEX_DUMP(data, data_len, "decode_value");
78
79 switch (parent->type) {
80 case FR_TYPE_ATTR:
81 /*
82 * Force the length of the data to be two,
83 * otherwise the "from network" call complains.
84 * Because we pass in the enumv as the _parent_
85 * and not the da. The da is marked as "array",
86 * but the parent is not.
87 */
88 if (data_len < 2) goto raw;
89
90 fr_assert(parent->parent->flags.is_root);
91
93 if (!vp) return PAIR_DECODE_OOM;
95
96 slen = fr_value_box_from_network(vp, &vp->data, vp->vp_type, parent->parent,
97 &FR_DBUFF_TMP(data, 2), 2, true);
98 if (slen <= 0) {
99 TALLOC_FREE(vp);
100 goto raw;
101 }
102
103 vp->vp_tainted = true;
105 return 2;
106
107 /*
108 * Address MAY be shorter than 16 bytes.
109 */
111 if (data_len == 0) {
112 raw:
113 return fr_pair_raw_from_network(ctx, out, parent, data, data_len);
114
115 }
116
117 vp = fr_pair_afrom_da(ctx, parent);
118 if (!vp) return PAIR_DECODE_OOM;
120
121 slen = fr_value_box_ipaddr_from_network(&vp->data, parent->type, parent,
122 data[0], data + 1, data_len - 1,
123 (parent->parent->type == FR_TYPE_STRUCT), true);
124 if (slen < 0) goto raw_free;
125
126 slen++; /* account for the prefix */
127 break;
128
129 /*
130 * A bool is encoded as an empty option if it's
131 * true. A bool is omitted entirely if it's
132 * false.
133 */
134 case FR_TYPE_BOOL:
135 if (data_len != 0) goto raw;
136 vp = fr_pair_afrom_da(ctx, parent);
137 if (!vp) return PAIR_DECODE_OOM;
139
140 vp->vp_bool = true;
141 slen = 0;
142 break;
143
144 /*
145 * A standard 32bit integer, but unlike normal UNIX timestamps
146 * starts from the 1st of January 2000.
147 *
148 * In the encoder we subtract 30 years to any values, so
149 * here we need to add that to the time here.
150 */
151 case FR_TYPE_DATE:
152 vp = fr_pair_afrom_da(ctx, parent);
153 if (!vp) return PAIR_DECODE_OOM;
155
156 slen = fr_value_box_from_network(vp, &vp->data, vp->vp_type, vp->da,
157 &FR_DBUFF_TMP(data, data_len), data_len, true);
158 if (slen < 0) {
160 goto raw;
161 }
163 break;
164
165 case FR_TYPE_STRUCT:
166 slen = fr_struct_from_network(ctx, out, parent, data, data_len,
168 if (slen < 0) goto raw;
169
170 if (parent->flags.array) return slen;
171 return data_len;
172
173 case FR_TYPE_GROUP:
174 vp = fr_pair_afrom_da(ctx, parent);
175 if (!vp) return PAIR_DECODE_OOM;
177
179 if (ref && (ref->dict != dict_dhcpv6)) {
180 fr_dict_protocol_t const *proto;
181
182 proto = fr_dict_protocol(ref->dict);
183 fr_assert(proto != NULL);
184
185 if (!proto->decode) {
186 raw_free:
188 goto raw;
189 }
190
191 slen = proto->decode(vp, &vp->vp_group, data, data_len);
192 if (slen < 0) goto raw_free;
193
194 vp->vp_tainted = true;
195
196 } else {
197 if (!ref) ref = fr_dict_root(dict_dhcpv6);
198
199 /*
200 * Child VPs go into the child group, not in the main parent list. BUT, we start
201 * decoding attributes from the ref, and not from the group parent.
202 */
203 slen = fr_pair_tlvs_from_network(vp, &vp->vp_group, ref, data, data_len, decode_ctx, decode_option, NULL, false);
204 if (slen < 0) goto raw_free;
205 }
206
208 return data_len;
209
211 vp = fr_pair_afrom_da(ctx, parent);
212 if (!vp) return PAIR_DECODE_OOM;
214
215 slen = fr_value_box_ipaddr_from_network(&vp->data, parent->type, parent,
216 128, data, data_len,
217 true, true);
218 if (slen < 0) goto raw_free;
219 break;
220
221 default:
222 vp = fr_pair_afrom_da(ctx, parent);
223 if (!vp) return PAIR_DECODE_OOM;
225
226 slen = fr_value_box_from_network(vp, &vp->data, vp->vp_type, vp->da,
227 &FR_DBUFF_TMP(data, data_len), data_len, true);
228 if (slen < 0) goto raw_free;
229 break;
230 }
231
232 /*
233 * The input is larger than the decoded value, re-do it as a raw attribute.
234 */
235 if (!parent->flags.array && ((size_t) slen < data_len)) {
237 goto raw;
238 }
239
240 fr_assert(vp != NULL);
241
242 vp->vp_tainted = true;
244
245 if (parent->flags.array) return slen;
246
247 return data_len;
248}
249
250
251static ssize_t decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out,
252 fr_dict_attr_t const *parent,
253 uint8_t const *data, size_t const data_len, void *decode_ctx)
254{
255 unsigned int option;
256 size_t len;
257 ssize_t slen;
258 fr_dict_attr_t const *da;
259 fr_dhcpv6_decode_ctx_t *packet_ctx = decode_ctx;
260
261#ifdef STATIC_ANALYZER
262 if (!packet_ctx || !packet_ctx->tmp_ctx) return PAIR_DECODE_FATAL_ERROR;
263#endif
264
265 /*
266 * Must have at least an option header.
267 */
268 if (data_len < 4) {
269 fr_strerror_printf("%s: Insufficient data", __FUNCTION__);
270 return -(data_len);
271 }
272
273 option = DHCPV6_GET_OPTION_NUM(data);
275 if (len > (data_len - 4)) {
276 fr_strerror_printf("%s: Option overflows input. "
277 "Optional length must be less than %zu bytes, got %zu bytes",
278 __FUNCTION__, data_len - 4, len);
280 }
281
282 da = fr_dict_attr_child_by_num(parent, option);
283 if (!da) {
284 da = fr_dict_attr_unknown_raw_afrom_num(packet_ctx->tmp_ctx, parent, option);
285 if (!da) return PAIR_DECODE_FATAL_ERROR;
286 }
287 FR_PROTO_TRACE("decode context changed %s -> %s",da->parent->name, da->name);
288
289 /*
290 * Relay messages are weird, and contain complete DHCPv6
291 * packets, copied verbatim from the DHCPv6 client.
292 */
293 if (da == attr_relay_message) {
294 fr_pair_t *vp;
295
297 if (!vp) return PAIR_DECODE_FATAL_ERROR;
299
300 slen = fr_dhcpv6_decode(vp, &vp->vp_group, data + 4, len);
301 if (slen < 0) {
303 raw:
304 slen = fr_pair_raw_from_network(ctx, out, da, data + 4, len);
305 if (slen < 0) return slen;
306 return 4 + slen;
307 }
308
310
311 } else if ((da->type == FR_TYPE_STRING) && fr_dhcpv6_flag_any_dns_label(da)) {
312 slen = fr_pair_dns_labels_from_network(ctx, out, da, data + 4, data + 4, len, NULL, true);
313 if (slen < 0) return slen;
314
315 } else if (da->flags.array) {
316 slen = fr_pair_array_from_network(ctx, out, da, data + 4, len, decode_ctx, decode_value);
317
318 } else if (da->type == FR_TYPE_VSA) {
319 bool append_vsa = false;
320 bool append_vp = false;
321 uint32_t pen;
322 fr_dict_attr_t const *vendor;
323 fr_pair_t *vsa, *vp;
324 fr_pair_list_t list;
325
326 /*
327 * Insufficient room for a 4-octet enterprise
328 * code, plus at least one option header.
329 */
330 if (len < 8) goto raw;
331
332 pen = fr_nbo_to_uint32(data + 4);
333
334 /*
335 * Verify that the VSA contains a vendor.
336 *
337 * If it doesn't then this vendor is unknown, but we know
338 * vendor attributes have a standard format, so we can
339 * decode the data anyway.
340 */
341 vendor = fr_dict_attr_child_by_num(da, pen);
342 if (!vendor) {
344
345 n = fr_dict_attr_unknown_vendor_afrom_num(packet_ctx->tmp_ctx, da, pen);
346 if (!n) return PAIR_DECODE_OOM;
347 vendor = n;
348 }
349
350 vsa = fr_pair_find_by_da(out, NULL, da);
351 if (!vsa) {
352 vsa = fr_pair_afrom_da(ctx, da);
353 if (!vsa) return PAIR_DECODE_FATAL_ERROR;
354 PAIR_ALLOCED(vsa);
355
356 append_vsa = true;
357 }
358
359 vp = NULL;
360 if (!append_vsa) vp = fr_pair_find_by_da(&vsa->vp_group, NULL, vendor);
361
362 if (!vp) {
363 vp = fr_pair_afrom_da(vsa, vendor);
364 if (!vp) return PAIR_DECODE_FATAL_ERROR;
366
367 append_vp = true;
368 }
369
370 fr_pair_list_init(&list);
371 slen = fr_pair_tlvs_from_network(vp, &vp->vp_group, vendor, data + 8, len - 4,
372 decode_ctx, decode_option, NULL, false);
373
374 if (slen < 0) {
375 fr_pair_list_free(&list);
376 if (append_vp) talloc_free(vp);
377 if (append_vsa) talloc_free(vsa);
378 goto raw;
379 }
380
381 /*
382 * The child list contains vendors, and we have to merge the vendors
383 */
384 fr_pair_list_append(&vp->vp_group, &list);
385 if (append_vp) fr_pair_append(&vsa->vp_group, vp);
386 if (append_vsa) fr_pair_append(out, vsa);
387
388 } else if (da->type == FR_TYPE_TLV) {
389 slen = fr_pair_tlvs_from_network(ctx, out, da, data + 4, len, decode_ctx, decode_option, NULL, true);
390
391 } else {
392 slen = decode_value(ctx, out, da, data + 4, len, decode_ctx);
393 }
394
395 if (slen < 0) goto raw;
396
397 return len + 4;
398}
399
400
401/** Create a "normal" fr_pair_t from the given data
402 *
403 * 0 1 2 3
404 * 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
405 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
406 * | option-code | option-len |
407 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
408 */
410 uint8_t const *data, size_t data_len, void *decode_ctx)
411{
412 FR_PROTO_HEX_DUMP(data, data_len, "fr_dhcpv6_decode_pair");
413
414 /*
415 * The API changes, so we just bounce directly to the
416 * decode_option() function.
417 *
418 * All options including VSAs in DHCPv6 MUST follow the
419 * standard format.
420 */
421 return decode_option(ctx, out, fr_dict_root(dict_dhcpv6), data, data_len, decode_ctx);
422}
423
425 uint8_t const *data, size_t data_len)
426{
427 ssize_t slen;
428 uint8_t const *attr, *end;
429
430 fr_dhcpv6_decode_ctx_t decode_ctx = {};
431
432 fr_assert(dict_dhcpv6 != NULL);
433
434 decode_ctx.tmp_ctx = talloc(ctx, uint8_t);
435
436 attr = data;
437 end = data + data_len;
438
439 while (attr < end) {
440 slen = fr_dhcpv6_decode_option(ctx, out, attr, (end - attr), &decode_ctx);
441 if (slen < 0) {
442 talloc_free(decode_ctx.tmp_ctx);
443 return slen;
444 }
445
446 /*
447 * If slen is larger than the room in the packet,
448 * all kinds of bad things happen.
449 */
450 if (!fr_cond_assert(slen <= (end - attr))) {
451 talloc_free(decode_ctx.tmp_ctx);
452 return -slen - (attr - data);
453 }
454
455 attr += slen;
456 talloc_free_children(decode_ctx.tmp_ctx);
457 }
458
459 talloc_free(decode_ctx.tmp_ctx);
460 return data_len;
461}
462
463static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict,
464 UNUSED fr_dict_attr_t const *root_da)
465{
466 fr_dhcpv6_decode_ctx_t *test_ctx;
467
468 test_ctx = talloc_zero(ctx, fr_dhcpv6_decode_ctx_t);
469 if (!test_ctx) return -1;
470
471 test_ctx->tmp_ctx = talloc(test_ctx, uint8_t);
472
473 *out = test_ctx;
474
475 return 0;
476}
477
478static 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)
479{
480 size_t packet_len = data_len;
481// fr_dhcpv6_decode_ctx_t *test_ctx = talloc_get_type_abort(proto_ctx, fr_dhcpv6_decode_ctx_t);
482
483 if (!fr_dhcpv6_ok(data, packet_len, 200)) return -1;
484
485 return fr_dhcpv6_decode(ctx, out, data, packet_len);
486}
487
488
490 uint8_t const *data, size_t data_len, void *decode_ctx)
491{
493
494 return decode_option(ctx, out, fr_dict_root(dict_dhcpv6), data, data_len, decode_ctx);
495}
496
497/*
498 * Test points
499 */
505
int n
Definition acutest.h:577
#define NDEBUG_UNUSED
Definition build.h:347
#define UNUSED
Definition build.h:336
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
Definition dbuff.h:522
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
Definition debug.h:141
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
fr_dict_attr_decode_func_t decode
for decoding attributes.
Definition dict.h:487
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:604
fr_dict_protocol_t const * fr_dict_protocol(fr_dict_t const *dict)
Return the protocol descriptor for the dictionary.
Definition dict_util.c:5252
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:611
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
Definition dict_util.c:2665
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:3593
Protocol-specific callbacks in libfreeradius-PROTOCOL.
Definition dict.h:455
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:148
talloc_free(hp)
#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:156
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:253
ssize_t fr_pair_raw_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *da, uint8_t const *data, size_t data_len)
Create a "raw" pair from malformed network data.
Definition decode.c:86
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
@ 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 uint32_t fr_nbo_to_uint32(uint8_t const data[static sizeof(uint32_t)])
Read an unsigned 32bit integer from wire format (big endian)
Definition nbo.h:167
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:707
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:1352
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:290
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
Definition pair.c:46
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, UNUSED fr_dict_attr_t const *root_da)
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:482
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_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:231
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:590
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:409
fr_test_point_pair_decode_t dhcpv6_tp_decode_pair
Definition decode.c:501
fr_test_point_proto_decode_t dhcpv6_tp_decode_proto
Definition decode.c:507
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:424
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:478
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:489
#define decode_value
Definition decode.c:407
VQP attributes.
#define fr_assert(_expr)
Definition rad_assert.h:37
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:32
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:86
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Definition test_point.h:68
Entry point for pair decoders.
Definition test_point.h:85
Entry point for protocol decoders.
Definition test_point.h:67
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
#define PAIR_ALLOCED(_x)
Definition pair.h:212
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
Appends a list of fr_pair_t from a temporary list to a destination list.
static fr_slen_t parent
Definition pair.h:858
#define FR_PROTO_HEX_DUMP(_data, _data_len, _fmt,...)
Definition proto.h:42
#define FR_PROTO_TRACE(_fmt,...)
Definition proto.h:41
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
Definition strerror.h:64
@ FR_TYPE_ATTR
A contains an attribute reference.
Definition types.h:83
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:1892
ssize_t fr_value_box_ipaddr_from_network(fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv, int prefix_len, uint8_t const *data, size_t data_len, bool fixed, bool tainted)
Decode a fr_value_box_t of type IP address / prefix.
Definition value.c:2296
static fr_slen_t data
Definition value.h:1340
static size_t char ** out
Definition value.h:1030