The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
dict_unknown.c
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program 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
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/** Deal with 'unknown' attributes, creating ephemeral dictionary attributes for them
18 *
19 * @file src/lib/util/dict_unknown.c
20 *
21 * @copyright 2019 The FreeRADIUS server project
22 */
23RCSID("$Id: b3f8fe232c9beaf6d70d889e4e0f6cb2992b10fb $")
24
25#include <freeradius-devel/util/dict_priv.h>
26
28{
29 flags->is_unknown = true;
30
31 if (parent->flags.internal) {
32 fr_strerror_printf("Cannot create 'raw' attribute of data type '%s' which is 'internal'",
34 return -1;
35 }
36
37 if ((parent->type == FR_TYPE_UNION) && (type != FR_TYPE_OCTETS)) {
38 fr_strerror_printf("Cannot create 'raw' attribute of data type '%s' which has parent data type 'union'",
40 return -1;
41 }
42
43 if (parent->depth >= FR_DICT_MAX_TLV_STACK) {
44 fr_strerror_const("Attribute depth is too large");
45 return -1;
46 }
47
48 /*
49 * If we are leveraging an existing attribute, then do some additional checks.
50 */
51 if (da) {
52 if (da->flags.internal) {
53 fr_strerror_printf("Cannot create unknown attribute from internal attribute %s", da->name);
54 return -1;
55 }
56
57 /*
58 * @todo - do we actually care about this?
59 *
60 * If we fix the unknown allocations to always use the raw number as the name, then it
61 * should be fine to change the data types.
62 */
63 if (type != FR_TYPE_OCTETS) {
64 if (da->type != type) {
65 fr_strerror_printf("Cannot allocate unknown attribute (%s) which changes data type from '%s' to '%s'",
66 da->name,
67 fr_type_to_str(da->type),
69 return -1;
70 }
71 }
72 }
73
74 /*
75 * Ensure that raw members of a structure have the correct length.
76 */
77 if (parent->type == FR_TYPE_STRUCT) {
78 if (!da) {
79 fr_strerror_printf("Cannot create 'raw' attribute of data type '%s' which has parent data type 'struct'",
81 return -1;
82 }
83
84 if (fr_type_is_leaf(da->type)) {
85 if (fr_type_is_structural(type)) goto cannot_change_type;
86
87 fr_assert(da->flags.is_known_width);
88
89 flags->is_known_width = true;
90 flags->length = da->flags.length;
91
92 } else if (da->type != type) {
93 cannot_change_type:
94 /*
95 * @todo - why not? So long as the size is the same...
96 */
97 fr_strerror_printf("Cannot create 'raw' attribute in 'struct' which changes data type from '%s' to '%s'",
99 return -1;
100 }
101 }
102
103 return 0;
104}
105
106/** Converts an unknown to a known by adding it to the internal dictionaries.
107 *
108 * Does not free old #fr_dict_attr_t, that is left up to the caller.
109 *
110 * @param[in] dict of protocol context we're operating in.
111 * If NULL the internal dictionary will be used.
112 * @param[in] unknown attribute to add.
113 * @return
114 * - Existing #fr_dict_attr_t if unknown was found in a dictionary.
115 * - A new entry representing unknown.
116 */
118{
119 fr_dict_attr_t const *da;
120 fr_dict_attr_t const *parent;
122
123 if (unlikely(dict->read_only)) {
124 fr_strerror_printf("%s dictionary has been marked as read only", fr_dict_root(dict)->name);
125 return NULL;
126 }
127
128#ifdef STATIC_ANALYZER
129 if (!unknown->name || !unknown->parent) return NULL;
130#endif
131
132 da = fr_dict_attr_by_name(NULL, unknown->parent, unknown->name);
133 if (da) {
134 if (da->attr == unknown->attr) return da;
135
136 fr_strerror_printf("Unknown attribute '%s' conflicts with existing attribute in namespace '%s'",
137 da->name, unknown->parent->name);
138 return da;
139 }
140
141 /*
142 * Define the complete unknown hierarchy
143 */
144 if (unknown->parent && unknown->parent->flags.is_unknown) {
145 parent = fr_dict_attr_unknown_add(dict, unknown->parent);
146 if (!parent) {
147 fr_strerror_printf_push("Failed adding parent \"%s\"", unknown->parent->name);
148 return NULL;
149 }
150 } else {
151 parent = unknown->parent;
152 }
153
154 memcpy(&flags, &unknown->flags, sizeof(flags));
155 flags.is_unknown = 0;
156
157 /*
158 * If this is a vendor, we skip most of the sanity
159 * checks and add it to the vendor hash, and add it
160 * as a child attribute to the Vendor-Specific
161 * container.
162 */
163 if (unknown->type == FR_TYPE_VENDOR) {
165
166 if (dict_vendor_add(dict, unknown->name, unknown->attr) < 0) return NULL;
167
168 n = dict_attr_alloc(dict->pool, parent, unknown->name, unknown->attr, unknown->type,
169 &(dict_attr_args_t){ .flags = &flags });
170 if (unlikely(!n)) return NULL;
171
172 /*
173 * Setup parenting for the attribute
174 */
175 if (dict_attr_child_add(UNCONST(fr_dict_attr_t *, unknown->parent), n) < 0) return NULL;
176
177 return n;
178 }
179
180 /*
181 * Look up the attribute by number. If it doesn't exist,
182 * add it both by name and by number. If it does exist,
183 * add it only by name.
184 */
185 da = fr_dict_attr_child_by_num(parent, unknown->attr);
186 if (da) {
188
189 n = dict_attr_alloc(dict->pool, parent, unknown->name, unknown->attr, unknown->type,
190 &(dict_attr_args_t){ .flags = &flags });
191 if (!n) return NULL;
192
193 /*
194 * Add the unknown by NAME. e.g. if the admin does "Attr-26", we want
195 * to return "Attr-26", and NOT "Vendor-Specific". The rest of the server
196 * is responsible for converting "Attr-26 = 0x..." to an actual attribute,
197 * if it so desires.
198 */
200 talloc_free(n);
201 return NULL;
202 }
203
204 return n;
205 }
206
207 /*
208 * Add the attribute by both name and number.
209 *
210 * Fixme - Copy extensions?
211 */
212 if (fr_dict_attr_add(dict, parent, unknown->name, unknown->attr, unknown->type, &flags) < 0) return NULL;
213
214 /*
215 * For paranoia, return it by name.
216 */
217 return fr_dict_attr_by_name(NULL, parent, unknown->name);
218}
219
220/** Free dynamically allocated (unknown attributes)
221 *
222 * If the da was dynamically allocated it will be freed, else the function
223 * will return without doing anything.
224 *
225 * @param[in] da to free.
226 */
228{
229 if (!da || !*da) return;
230
231 /* Don't free real DAs */
232 if (!(*da)->flags.is_unknown) {
233 return;
234 }
235
237
238 *da = NULL;
239}
240
241/** Allocate an unknown DA.
242 *
243 */
245{
247 fr_dict_attr_t const *parent;
248 fr_dict_attr_flags_t flags = {};
249
250 fr_assert(!da->flags.is_root); /* cannot copy root attributes */
251 fr_assert(da->parent);
252
253 switch (type) {
254 case FR_TYPE_LEAF:
255 case FR_TYPE_GROUP:
256 case FR_TYPE_TLV:
257 case FR_TYPE_VSA:
258 case FR_TYPE_VENDOR:
259 break;
260
261 default:
262 fr_strerror_printf("Invalid data type '%s' for unknown attribute", fr_type_to_str(type));
263 return NULL;
264 }
265
266 switch (da->type) {
267 case FR_TYPE_LEAF:
269 break;
270
271 default:
272 fr_strerror_printf("Cannot create unknown attribute from data type '%s'", fr_type_to_str(da->type));
273 return NULL;
274 }
275
276 if (dict_attr_unknown_init(da->parent, da, type, &flags)) return NULL;
277
278 /*
279 * Set the unknown flags. Note that we don't copy any other flags, as they are all likely to be wrong.
280 */
281 flags.is_raw = 1;
282
283 /*
284 * Allocate an attribute.
285 */
286 n = dict_attr_alloc_null(ctx, da->dict->proto);
287 if (!n) return NULL;
288
289 /*
290 * We want to have parent / child relationships, AND to
291 * copy all unknown parents, AND to free the unknown
292 * parents when this 'da' is freed. We therefore talloc
293 * the parent from the 'da'.
294 */
295 if (da->parent->flags.is_unknown) {
296 parent = fr_dict_attr_unknown_copy(n, da->parent);
297 if (!parent) {
298 error:
299 talloc_free(n);
300 return NULL;
301 }
302
303 } else {
304 parent = da->parent;
305 }
306
307 /*
308 * Initialize the rest of the fields.
309 */
310 if (dict_attr_init(&n, parent, da->name, da->attr, type, &(dict_attr_args_t){ .flags = &flags }) < 0) {
311 goto error;
312 }
313
314 /*
315 * Copy protocol-specific extents, and hope to heck that the protocol encoder knows what it's doing.
316 */
319 goto error;
320 }
321
322 /*
323 * Do NOT copy extents. The name and da_stack extents are already defined. We do NOT copy
324 * existing children, references, keys, enumv, etc. If the unknown attribute is a group, it's
325 * ref is already set to the root, or to a copy of the input DA. If the unknown attribute is a
326 * TLV, then it cannot have known children. If an unknown attribute is a leaf, then it cannot
327 * have known enums.
328 */
329
330 DA_VERIFY(n);
331
332 return n;
333}
334
335/** Copy a known or unknown attribute to produce an unknown attribute with the specified name
336 *
337 * Will copy the complete hierarchy down to the first known attribute.
338 */
340{
341 fr_type_t type = da->type;
342
343 /*
344 * VENDOR, etc. are logical containers, and can have
345 * unknown children, so they're left alone. All other
346 * base types are mangled to OCTETs.
347 *
348 * Note that we can't allocate an unknown STRUCT. If the
349 * structure is malformed, then it's just a sequence of
350 * OCTETS. Similarly, if a GROUP is malformed, then we
351 * have no idea what's inside of it, and we make it OCTETS.
352 */
353 if (!da->flags.is_unknown) switch (type) {
354 case FR_TYPE_VENDOR:
355 fr_assert(da->flags.type_size != 0);
356 break;
357
358 case FR_TYPE_TLV:
359 case FR_TYPE_VSA:
360 break;
361
362 default:
364 break;
365 }
366
367 return fr_dict_attr_unknown_alloc(ctx, da, type);
368}
369
370/** Initialise a fr_dict_attr_t from a number and a data type
371 *
372 * @param[in] ctx to allocate the attribute in.
373 * @param[in] parent of the unknown attribute (may also be unknown).
374 * @param[in] num of the unknown attribute.
375 * @param[in] type data type
376 * @param[in] raw is it raw, i.e. _bad_ value, versus unknown?
377 * @return
378 * - An fr_dict_attr_t on success.
379 * - NULL on failure.
380 */
382{
383 fr_dict_attr_flags_t flags = {
384 .is_raw = raw,
385 };
386 fr_dict_attr_t const *da = NULL;
387
388 if (parent->flags.internal) {
389 fr_strerror_printf("Cannot create 'raw' attribute from internal parent '%s' of data type '%s'",
390 parent->name, fr_type_to_str(parent->type));
391 return NULL;
392 }
393
394 if (((parent->type == FR_TYPE_TLV) || (parent->type == FR_TYPE_VENDOR))) {
395 if ((uint64_t) num >= ((uint64_t) 1 << (8 * parent->flags.type_size))) {
396 fr_strerror_printf("Invalid attribute number '%u' - it must be no more than %u bits in size",
397 num, 8 * parent->flags.type_size);
398 return NULL;
399 }
400 }
401
402 switch (type) {
403 default:
404 fr_strerror_printf("Cannot allocate unknown attribute '%u' - invalid data type '%s'",
405 num, fr_type_to_str(type));
406 return NULL;
407
408 case FR_TYPE_VENDOR:
409 if (parent->type != FR_TYPE_VSA) goto fail;
410
411 if (parent->flags.is_unknown) goto fail;
412 break;
413
414 case FR_TYPE_LEAF:
415 case FR_TYPE_TLV:
416 case FR_TYPE_VSA:
418 fail:
419 fr_strerror_printf("Cannot allocate unknown attribute '%u' data type '%s' with parent %s data type '%s'",
420 num, fr_type_to_str(type),
421 parent->name, fr_type_to_str(parent->type));
422 return NULL;
423 }
424
425 /*
426 * We can convert anything to 'octets'.
427 */
428 if (type == FR_TYPE_OCTETS) break;
429
430 /*
431 * But we shouldn't be able to create a raw attribute which is a _different_ type than an
432 * existing one.
433 */
435 break;
436 }
437
438 if (dict_attr_unknown_init(parent, da, type, &flags)) return NULL;
439
440 return dict_attr_alloc(ctx, parent, NULL, num, type,
441 &(dict_attr_args_t){ .flags = &flags });
442}
443
444/** Create a fr_dict_attr_t from an ASCII attribute and value
445 *
446 * Where the attribute name is in the form:
447 * - %d
448 * - %d.%d.%d...
449 *
450 * @note If vendor != 0, an unknown vendor (may) also be created, parented by
451 * the correct VSA attribute. This is accessible via vp->parent,
452 * and will be use the unknown da as its talloc parent.
453 *
454 * @param[in] ctx to alloc new attribute in.
455 * @param[out] out Where to write the head of the chain unknown
456 * dictionary attributes.
457 * @param[in] parent Attribute to use as the root for resolving OIDs in.
458 * Usually the root of a protocol dictionary.
459 * @param[in] in OID string to parse
460 * @param[in] type data type of the unknown attribute
461 * @return
462 * - The number of bytes parsed on success.
463 * - <= 0 on failure. Negative offset indicates parse error position.
464 */
466 fr_dict_attr_t const **out,
467 fr_dict_attr_t const *parent,
469{
470 fr_sbuff_t our_in = FR_SBUFF(in);
471 fr_dict_attr_t const *our_parent = parent;
472 fr_dict_attr_t *n = NULL;
473 fr_dict_attr_flags_t flags = { .is_raw = true, };
474
475 *out = NULL;
476
477 /*
478 * Allocate the final attribute first, so that any
479 * unknown parents can be freed when this da is freed.
480 *
481 * See fr_dict_attr_unknown_afrom_da() for more details.
482 *
483 * Note also that we copy the input name, even if it is
484 * not normalized.
485 *
486 * While the name of this attribute is "Attr-#.#.#", one
487 * or more of the leading components may, in fact, be
488 * known.
489 */
490 n = dict_attr_alloc_null(ctx, parent->dict->proto);
491
492 /*
493 * Loop until there's no more component separators.
494 */
495 for (;;) {
496 uint32_t num;
498
499 fr_sbuff_out(&sberr, &num, &our_in);
500 switch (sberr) {
502 switch (our_parent->type) {
503 /*
504 * If the parent is a VSA, this component
505 * must specify a vendor.
506 */
507 case FR_TYPE_VSA:
508 {
509 fr_dict_attr_t *ni;
510
511 if (fr_sbuff_next_if_char(&our_in, '.')) {
512 ni = fr_dict_attr_unknown_vendor_afrom_num(n, our_parent, num);
513 if (!ni) {
514 error:
515 talloc_free(n);
516 FR_SBUFF_ERROR_RETURN(&our_in);
517 }
518 our_parent = ni;
519 continue;
520 }
521 if (dict_attr_init(&n, our_parent, NULL, num, FR_TYPE_VENDOR,
522 &(dict_attr_args_t){ .flags = &flags }) < 0) goto error;
523 }
524 break;
525
526 /*
527 * If it's structural, this component must
528 * specify a TLV.
529 */
531 {
532 fr_dict_attr_t *ni;
533
534 if (fr_sbuff_next_if_char(&our_in, '.')) {
535 ni = fr_dict_attr_unknown_typed_afrom_num(n, our_parent, num, FR_TYPE_TLV);
536 if (!ni) goto error;
537 our_parent = ni;
538 continue;
539 }
540 }
542
543 default:
544 /*
545 * Leaf type with more components
546 * is an error.
547 */
548 if (fr_sbuff_is_char(&our_in, '.')) {
549 fr_strerror_printf("Interior OID component cannot proceed a %s type",
550 fr_type_to_str(our_parent->type));
551 goto error;
552 }
553
554 if (dict_attr_unknown_init(our_parent, NULL, type, &flags)) goto error;
555
556 if (dict_attr_init(&n, our_parent, NULL, num, type,
557 &(dict_attr_args_t){ .flags = &flags }) < 0) goto error;
558 break;
559 }
560 break;
561
562 default:
563 {
564 fr_sbuff_marker_t c_start;
565
566 fr_sbuff_marker(&c_start, &our_in);
568 fr_strerror_printf("Unknown attribute \"%.*s\" for parent \"%s\"",
569 (int)fr_sbuff_behind(&c_start), fr_sbuff_current(&c_start), our_parent->name);
570 goto error;
571 }
572 }
573 break;
574 }
575
576 DA_VERIFY(n);
577
578 *out = n;
579
580 FR_SBUFF_SET_RETURN(in, &our_in);
581}
582
583/** Fixup the parent of an unknown attribute using an equivalent known attribute
584 *
585 * This can be useful where an unknown attribute's ancestors are added to
586 * a dictionary but not the unknown attribute itself.
587 *
588 * @param[in] da to fixup.
589 * @param[in] parent to assign. If NULL, we will attempt to resolve
590 * the parent in the dictionary the current unknown
591 * attribute extends.
592 * @return
593 * - 0 on success.
594 * - -1 on failure.
595 */
597{
598 fr_dict_attr_t const *da_u, *da_k;
599
600 if (parent) {
601 /*
602 * Walk back up the hierarchy until we get to a known
603 * ancestor on the unknown side.
604 */
605 for (da_u = da->parent, da_k = parent;
606 da_k && da_u && da_u->flags.is_unknown;
607 da_u = da_u->parent, da_k = da_k->parent) {
608 if (unlikely(da_u->attr != da_k->attr)) {
609 fr_strerror_printf("Unknown parent number %u does not match "
610 "known parent number %u (%s)",
611 da_u->attr, da_k->attr, da_k->name);
612 return -1;
613 }
614
615 if (unlikely(da_u->depth != da_k->depth)) {
616 fr_strerror_printf("Unknown parent depth %u does not match "
617 "known parent depth %u (%s)",
618 da_u->depth, da_k->depth, da_k->name);
619 return -1;
620 }
621 }
622 if ((da_k == NULL) != (da_u == NULL)) {
623 fr_strerror_printf("Truncated or over-extended hierarchy "
624 "for unknown attribute %u", da->attr);
625 return -1;
626 }
627 } else {
629 if (!parent) {
630 fr_strerror_printf("Failed resolving unknown attribute %u "
631 "in dictionary", da->attr);
632 return -1;
633 }
634 }
635
636 da->parent = fr_dict_attr_unconst(parent);
637
638 return 0;
639}
640
641/** Check to see if we can convert a nested TLV structure to known attributes
642 *
643 * @param[in] dict to search in.
644 * @param[in] da Nested tlv structure to convert.
645 * @return
646 * - NULL if we can't.
647 * - Known attribute if we can.
648 */
650{
651 INTERNAL_IF_NULL(dict, NULL);
652
653 if (!da->flags.is_unknown) return da; /* It's known */
654
655 if (da->parent) {
656 fr_dict_attr_t const *parent;
657
658 parent = fr_dict_attr_unknown_resolve(dict, da->parent);
659 if (!parent) return NULL;
660
661 return fr_dict_attr_child_by_num(parent, da->attr);
662 }
663
664 if (dict->root == da) return dict->root;
665 return NULL;
666}
int n
Definition acutest.h:579
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
Definition build.h:167
#define RCSID(id)
Definition build.h:485
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
Definition build.h:324
#define unlikely(_x)
Definition build.h:383
#define UNUSED
Definition build.h:317
fr_dict_t const * fr_dict_by_da(fr_dict_attr_t const *da)
Attempt to locate the protocol dictionary containing an attribute.
Definition dict_util.c:2901
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:609
bool const fr_dict_attr_allowed_chars[UINT8_MAX+1]
Characters allowed in a single dictionary attribute name.
Definition dict_util.c:64
static fr_dict_attr_t * fr_dict_attr_unknown_copy(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Definition dict.h:589
fr_dict_attr_t const * fr_dict_attr_by_name(fr_dict_attr_err_t *err, fr_dict_attr_t const *parent, char const *attr))
Locate a fr_dict_attr_t by its name.
Definition dict_util.c:3558
fr_dict_attr_t * fr_dict_attr_unconst(fr_dict_attr_t const *da)
Coerce to non-const.
Definition dict_util.c:4935
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
Definition dict_util.c:2695
#define DA_VERIFY(_x)
Definition dict.h:68
unsigned int is_raw
This dictionary attribute was constructed from a known attribute to allow the user to assign octets v...
Definition dict.h:82
uint16_t length
length of the attribute
Definition dict.h:153
@ FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC
Protocol specific extensions.
Definition dict.h:191
unsigned int is_known_width
is treated as if it has a known width for structs
Definition dict.h:94
#define FR_DICT_MAX_TLV_STACK
Maximum TLV stack size.
Definition dict.h:522
int fr_dict_attr_add(fr_dict_t *dict, fr_dict_attr_t const *parent, char const *name, unsigned int attr, fr_type_t type, fr_dict_attr_flags_t const *flags))
Add an attribute to the dictionary.
Definition dict_util.c:2004
static fr_dict_attr_t * fr_dict_attr_unknown_typed_afrom_num(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int num, fr_type_t type)
Definition dict.h:601
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:3623
static fr_slen_t in
Definition dict.h:887
#define FR_DICT_ATTR_MAX_NAME_LEN
Maximum length of a attribute name.
Definition dict.h:502
unsigned int is_unknown
This dictionary attribute is ephemeral and not part of the main dictionary.
Definition dict.h:79
Values of the encryption flags.
static void * fr_dict_attr_ext(fr_dict_attr_t const *da, fr_dict_attr_ext_t ext)
Definition dict_ext.h:134
static void * dict_attr_ext_copy(fr_dict_attr_t **da_out_p, fr_dict_attr_t const *da_in, fr_dict_attr_ext_t ext)
Copy a single attribute extension from one attribute to another.
#define dict_attr_alloc(_ctx, _parent, _name, _attr, _type, _args)
Definition dict_priv.h:255
#define INTERNAL_IF_NULL(_dict, _ret)
Set the internal dictionary if none was provided.
Definition dict_priv.h:45
int dict_attr_add_to_namespace(fr_dict_attr_t const *parent, fr_dict_attr_t *da)
Add an attribute to the name table for an attribute.
Definition dict_util.c:1816
int dict_attr_child_add(fr_dict_attr_t *parent, fr_dict_attr_t *child)
Add a child to a parent.
Definition dict_util.c:1717
int dict_vendor_add(fr_dict_t *dict, char const *name, unsigned int num)
Add a vendor to the dictionary.
Definition dict_util.c:1622
#define dict_attr_init(_da_p, _parent, _name, _attr, _type, _args)
Full initialisation functions.
Definition dict_priv.h:231
fr_dict_attr_t * dict_attr_alloc_null(TALLOC_CTX *ctx, fr_dict_protocol_t const *dict)
Partial initialisation functions.
Definition dict_util.c:1030
Optional arguments for initialising/allocating attributes.
Definition dict_priv.h:191
fr_slen_t fr_dict_attr_unknown_afrom_oid_substr(TALLOC_CTX *ctx, fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *in, fr_type_t type)
Create a fr_dict_attr_t from an ASCII attribute and value.
fr_dict_attr_t * fr_dict_attr_unknown_alloc(TALLOC_CTX *ctx, fr_dict_attr_t const *da, fr_type_t type)
Allocate an unknown DA.
fr_dict_attr_t const * fr_dict_attr_unknown_resolve(fr_dict_t const *dict, fr_dict_attr_t const *da)
Check to see if we can convert a nested TLV structure to known attributes.
fr_dict_attr_t * fr_dict_attr_unknown_typed_afrom_num_raw(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int num, fr_type_t type, bool raw)
Initialise a fr_dict_attr_t from a number and a data type.
int fr_dict_attr_unknown_parent_to_known(fr_dict_attr_t *da, fr_dict_attr_t const *parent)
Fixup the parent of an unknown attribute using an equivalent known attribute.
void fr_dict_attr_unknown_free(fr_dict_attr_t const **da)
Free dynamically allocated (unknown attributes)
fr_dict_attr_t const * fr_dict_attr_unknown_add(fr_dict_t *dict, fr_dict_attr_t const *unknown)
Converts an unknown to a known by adding it to the internal dictionaries.
fr_dict_attr_t * fr_dict_attr_unknown_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Copy a known or unknown attribute to produce an unknown attribute with the specified name.
static int dict_attr_unknown_init(fr_dict_attr_t const *parent, UNUSED fr_dict_attr_t const *da, fr_type_t type, fr_dict_attr_flags_t *flags)
talloc_free(reap)
fr_type_t
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
@ FR_TYPE_VENDOR
Attribute that represents a vendor in the attribute tree.
@ FR_TYPE_VSA
Vendor-Specific, for RADIUS attribute 26.
@ FR_TYPE_OCTETS
Raw octets.
@ FR_TYPE_GROUP
A grouping of other attributes.
unsigned int uint32_t
ssize_t fr_slen_t
fr_sbuff_parse_error_t
@ FR_SBUFF_PARSE_OK
No error.
#define fr_assert(_expr)
Definition rad_assert.h:38
static char const * name
size_t fr_sbuff_adv_past_allowed(fr_sbuff_t *sbuff, size_t len, bool const allowed[static UINT8_MAX+1], fr_sbuff_term_t const *tt)
Wind position past characters in the allowed set.
Definition sbuff.c:1805
bool fr_sbuff_next_if_char(fr_sbuff_t *sbuff, char c)
Return true if the current char matches, and if it does, advance.
Definition sbuff.c:2116
#define fr_sbuff_current(_sbuff_or_marker)
#define fr_sbuff_is_char(_sbuff_or_marker, _c)
#define FR_SBUFF_ERROR_RETURN(_sbuff_or_marker)
#define FR_SBUFF_SET_RETURN(_dst, _src)
#define FR_SBUFF(_sbuff_or_marker)
#define fr_sbuff_out(_err, _out, _in)
#define fr_sbuff_behind(_sbuff_or_marker)
fr_aka_sim_id_type_t type
static int talloc_const_free(void const *ptr)
Free const'd memory.
Definition talloc.h:229
static fr_slen_t parent
Definition pair.h:857
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
Definition strerror.h:64
#define fr_strerror_printf_push(_fmt,...)
Add a message to an existing stack of messages at the tail.
Definition strerror.h:84
#define fr_strerror_const(_msg)
Definition strerror.h:223
#define fr_type_is_structural(_x)
Definition types.h:393
@ FR_TYPE_UNION
A union of limited children.
Definition types.h:82
#define FR_TYPE_STRUCTURAL_EXCEPT_VSA
Definition types.h:315
#define fr_type_is_structural_except_vsa(_x)
Definition types.h:392
#define FR_TYPE_STRUCTURAL
Definition types.h:317
#define fr_type_is_leaf(_x)
Definition types.h:394
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
Definition types.h:455
#define FR_TYPE_LEAF
Definition types.h:318
static size_t char ** out
Definition value.h:1023