The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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  */
23 RCSID("$Id: b4033caa25c18109481e5ad502bfa64a759ff52d $")
24 
25 #include <freeradius-devel/util/dict_priv.h>
26 
27 /** Converts an unknown to a known by adding it to the internal dictionaries.
28  *
29  * Does not free old #fr_dict_attr_t, that is left up to the caller.
30  *
31  * @param[in] dict of protocol context we're operating in.
32  * If NULL the internal dictionary will be used.
33  * @param[in] unknown attribute to add.
34  * @return
35  * - Existing #fr_dict_attr_t if unknown was found in a dictionary.
36  * - A new entry representing unknown.
37  */
39 {
40  fr_dict_attr_t const *da;
41  fr_dict_attr_t const *parent;
43 
44  if (unlikely(dict->read_only)) {
45  fr_strerror_printf("%s dictionary has been marked as read only", fr_dict_root(dict)->name);
46  return NULL;
47  }
48 
49 #ifdef STATIC_ANALYZER
50  if (!unknown->name || !unknown->parent) return NULL;
51 #endif
52 
53  da = fr_dict_attr_by_name(NULL, unknown->parent, unknown->name);
54  if (da) {
55  if (da->attr == unknown->attr) return da;
56 
57  fr_strerror_printf("Unknown attribute '%s' conflicts with existing attribute in namespace '%s'",
58  da->name, unknown->parent->name);
59  return da;
60  }
61 
62  /*
63  * Define the complete unknown hierarchy
64  */
65  if (unknown->parent && unknown->parent->flags.is_unknown) {
66  parent = fr_dict_attr_unknown_add(dict, unknown->parent);
67  if (!parent) {
68  fr_strerror_printf_push("Failed adding parent \"%s\"", unknown->parent->name);
69  return NULL;
70  }
71  } else {
72  parent = unknown->parent;
73  }
74 
75  memcpy(&flags, &unknown->flags, sizeof(flags));
76  flags.is_unknown = 0;
77 
78  /*
79  * If this is a vendor, we skip most of the sanity
80  * checks and add it to the vendor hash, and add it
81  * as a child attribute to the Vendor-Specific
82  * container.
83  */
84  if (unknown->type == FR_TYPE_VENDOR) {
86 
87  if (dict_vendor_add(dict, unknown->name, unknown->attr) < 0) return NULL;
88 
89  n = dict_attr_alloc(dict->pool, parent, unknown->name, unknown->attr, unknown->type,
90  &(dict_attr_args_t){ .flags = &flags });
91  if (unlikely(!n)) return NULL;
92 
93  /*
94  * Setup parenting for the attribute
95  */
96  if (dict_attr_child_add(UNCONST(fr_dict_attr_t *, unknown->parent), n) < 0) return NULL;
97 
98  return n;
99  }
100 
101  /*
102  * Look up the attribute by number. If it doesn't exist,
103  * add it both by name and by number. If it does exist,
104  * add it only by name.
105  */
106  da = fr_dict_attr_child_by_num(parent, unknown->attr);
107  if (da) {
108  fr_dict_attr_t *n;
109 
110  n = dict_attr_alloc(dict->pool, parent, unknown->name, unknown->attr, unknown->type,
111  &(dict_attr_args_t){ .flags = &flags });
112  if (!n) return NULL;
113 
114  /*
115  * Add the unknown by NAME. e.g. if the admin does "Attr-26", we want
116  * to return "Attr-26", and NOT "Vendor-Specific". The rest of the server
117  * is responsible for converting "Attr-26 = 0x..." to an actual attribute,
118  * if it so desires.
119  */
120  if (dict_attr_add_to_namespace(parent, n) < 0) {
121  talloc_free(n);
122  return NULL;
123  }
124 
125  return n;
126  }
127 
128  /*
129  * Add the attribute by both name and number.
130  *
131  * Fixme - Copy extensions?
132  */
133  if (fr_dict_attr_add(dict, parent, unknown->name, unknown->attr, unknown->type, &flags) < 0) return NULL;
134 
135  /*
136  * For paranoia, return it by name.
137  */
138  return fr_dict_attr_by_name(NULL, parent, unknown->name);
139 }
140 
141 /** Free dynamically allocated (unknown attributes)
142  *
143  * If the da was dynamically allocated it will be freed, else the function
144  * will return without doing anything.
145  *
146  * @param[in] da to free.
147  */
149 {
150  if (!da || !*da) return;
151 
152  /* Don't free real DAs */
153  if (!(*da)->flags.is_unknown) {
154  return;
155  }
156 
157  talloc_const_free(*da);
158 
159  *da = NULL;
160 }
161 
162 /** Allocate an unknown DA.
163  *
164  */
165 static fr_dict_attr_t *dict_unknown_alloc(TALLOC_CTX *ctx, fr_dict_attr_t const *da, fr_type_t type)
166 {
167  fr_dict_attr_t *n;
168  fr_dict_attr_t const *parent;
169  fr_dict_attr_flags_t flags = da->flags;
170 
171  fr_assert(!da->flags.is_root); /* cannot copy root attributes */
172 
173  /*
174  * Set the unknown flag, and copy only those other flags
175  * which we know to be correct.
176  */
177  flags.is_unknown = 1;
178  flags.is_raw = 1;
179  flags.array = 0;
180  flags.has_value = 0;
181  if (type != FR_TYPE_VENDOR) {
182  flags.length = 0; /* not fixed length */
183  } else {
184  flags.type_size = da->flags.type_size;
185  flags.length = da->flags.length;
186  }
187  flags.extra = 0;
188 
189  /*
190  * Allocate an attribute.
191  */
192  n = dict_attr_alloc_null(ctx, da->dict->proto);
193  if (!n) return NULL;
194 
195  /*
196  * We want to have parent / child relationships, AND to
197  * copy all unknown parents, AND to free the unknown
198  * parents when this 'da' is freed. We therefore talloc
199  * the parent from the 'da'.
200  */
201  if (da->parent && da->parent->flags.is_unknown) {
202  parent = fr_dict_attr_unknown_copy(n, da->parent);
203  if (!parent) {
204  error:
205  talloc_free(n);
206  return NULL;
207  }
208 
209  } else {
210  parent = da->parent;
211  }
212 
213  /*
214  * Initialize the rest of the fields.
215  */
216  if (dict_attr_init(&n, parent, da->name, da->attr, type, &(dict_attr_args_t){ .flags = &flags }) < 0) {
217  goto error;
218  }
220  DA_VERIFY(n);
221 
222  return n;
223 }
224 
225 /** Copy a known or unknown attribute to produce an unknown attribute with the specified name
226  *
227  * Will copy the complete hierarchy down to the first known attribute.
228  */
230 {
231  fr_type_t type = da->type;
232 
233  /*
234  * VENDOR, etc. are logical containers, and can have
235  * unknown children, so they're left alone. All other
236  * base types are mangled to OCTETs.
237  *
238  * Note that we can't allocate an unknown STRUCT. If the
239  * structure is malformed, then it's just a sequence of
240  * OCTETS. Similarly, if a GROUP is malformed, then we
241  * have no idea what's inside of it, and we make it OCTETS.
242  */
243  switch (type) {
244  case FR_TYPE_VENDOR:
245  fr_assert(da->flags.type_size != 0);
246  break;
247 
248  case FR_TYPE_TLV:
249  case FR_TYPE_VSA:
250  break;
251 
252  default:
254  break;
255  }
256 
257  return dict_unknown_alloc(ctx, da, type);
258 }
259 
260 /** Initialise a fr_dict_attr_t from a number and a data type
261  *
262  * @param[in] ctx to allocate the attribute in.
263  * @param[in] parent of the unknown attribute (may also be unknown).
264  * @param[in] num of the unknown attribute.
265  * @param[in] type data type
266  * @param[in] raw is it raw, i.e. _bad_ value, versus unknown?
267  * @return
268  * - An fr_dict_attr_t on success.
269  * - NULL on failure.
270  */
271 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)
272 {
273  fr_dict_attr_flags_t flags = {
274  .is_unknown = true,
275  .internal = parent->flags.internal,
276  .is_raw = raw,
277  };
278 
279  switch (type) {
280  case FR_TYPE_VENDOR:
281  if (parent->type != FR_TYPE_VSA) goto fail;
282 
283  if (!fr_cond_assert(!parent->flags.is_unknown)) return NULL;
284 
285  /*
286  * These can be reset later if needed. But these
287  * values are most common.
288  */
289  flags.type_size = 1;
290  flags.length = 1;
291  break;
292 
293  case FR_TYPE_NULL:
294  case FR_TYPE_VALUE_BOX:
295  case FR_TYPE_VOID:
296  case FR_TYPE_MAX:
297  fr_strerror_printf("%s: Cannot allocate unknown %s attribute (%u) - invalid data type",
298  __FUNCTION__,
299  fr_type_to_str(type), num);
300  return NULL;
301 
302  default:
303  if (fr_dict_attr_is_key_field(parent)) break;
304 
306  fail:
307  fr_strerror_printf("%s: Cannot allocate unknown %s attribute (%u) with parent type %s",
308  __FUNCTION__,
309  fr_type_to_str(type), num,
310  fr_type_to_str(parent->type));
311  return NULL;
312  }
313 
314  /*
315  * We can convert anything to 'octets'. But we shouldn't be able to create a raw
316  * attribute which is a _different_ type than an existing one.
317  */
318  if (type != FR_TYPE_OCTETS) {
319  fr_dict_attr_t const *child;
320 
321  child = fr_dict_attr_child_by_num(parent, num);
322  if (child && (child->type != type)) {
323  fr_strerror_printf("%s: Cannot allocate unknown attribute (%u) which changes type from %s to %s",
324  __FUNCTION__,
325  num,
326  fr_type_to_str(child->type),
328  return NULL;
329  }
330  }
331 
332  break;
333  }
334 
335  if (parent->depth >= FR_DICT_MAX_TLV_STACK) {
336  fr_strerror_const("Attribute depth is too large");
337  return NULL;
338  }
339 
340  return dict_attr_alloc(ctx, parent, NULL, num, type,
341  &(dict_attr_args_t){ .flags = &flags });
342 }
343 
344 /** Initialise an octets type attribute from a da
345  *
346  * @param[in] ctx to allocate the attribute in.
347  * @param[in] da of the unknown attribute.
348  * @return
349  * - 0 on success.
350  * - -1 on failure.
351  */
353 {
354  return dict_unknown_alloc(ctx, da, FR_TYPE_OCTETS);
355 }
356 
357 /** Create a fr_dict_attr_t from an ASCII attribute and value
358  *
359  * Where the attribute name is in the form:
360  * - %d
361  * - %d.%d.%d...
362  *
363  * @note If vendor != 0, an unknown vendor (may) also be created, parented by
364  * the correct VSA attribute. This is accessible via vp->parent,
365  * and will be use the unknown da as its talloc parent.
366  *
367  * @param[in] ctx to alloc new attribute in.
368  * @param[out] out Where to write the head of the chain unknown
369  * dictionary attributes.
370  * @param[in] parent Attribute to use as the root for resolving OIDs in.
371  * Usually the root of a protocol dictionary.
372  * @param[in] in OID string to parse
373  * @param[in] type data type of the unknown attribute
374  * @return
375  * - The number of bytes parsed on success.
376  * - <= 0 on failure. Negative offset indicates parse error position.
377  */
379  fr_dict_attr_t const **out,
380  fr_dict_attr_t const *parent,
382 {
383  fr_sbuff_t our_in = FR_SBUFF(in);
384  fr_dict_attr_t const *our_parent = parent;
385  fr_dict_attr_t *n = NULL;
386  fr_dict_attr_flags_t flags = {
387  .is_unknown = true,
388  .is_raw = true,
389  .type_size = parent->dict->root->flags.type_size,
390  .length = parent->dict->root->flags.length,
391  };
392 
393  *out = NULL;
394 
395  /*
396  * Allocate the final attribute first, so that any
397  * unknown parents can be freed when this da is freed.
398  *
399  * See fr_dict_attr_unknown_afrom_da() for more details.
400  *
401  * Note also that we copy the input name, even if it is
402  * not normalized.
403  *
404  * While the name of this attribute is "Attr-#.#.#", one
405  * or more of the leading components may, in fact, be
406  * known.
407  */
408  n = dict_attr_alloc_null(ctx, parent->dict->proto);
409 
410  /*
411  * Loop until there's no more component separators.
412  */
413  for (;;) {
414  uint32_t num;
416 
417  fr_sbuff_out(&sberr, &num, &our_in);
418  switch (sberr) {
419  case FR_SBUFF_PARSE_OK:
420  switch (our_parent->type) {
421  /*
422  * If the parent is a VSA, this component
423  * must specify a vendor.
424  */
425  case FR_TYPE_VSA:
426  {
427  fr_dict_attr_t *ni;
428 
429  if (fr_sbuff_next_if_char(&our_in, '.')) {
430  ni = fr_dict_attr_unknown_vendor_afrom_num(n, our_parent, num);
431  if (!ni) {
432  error:
433  talloc_free(n);
434  FR_SBUFF_ERROR_RETURN(&our_in);
435  }
436  our_parent = ni;
437  continue;
438  }
439  if (dict_attr_init(&n, our_parent, NULL, num, FR_TYPE_VENDOR,
440  &(dict_attr_args_t){ .flags = &flags }) < 0) goto error;
441  }
442  break;
443 
444  /*
445  * If it's structural, this component must
446  * specify a TLV.
447  */
449  {
450  fr_dict_attr_t *ni;
451 
452  if (fr_sbuff_next_if_char(&our_in, '.')) {
453  ni = fr_dict_attr_unknown_typed_afrom_num(n, our_parent, num, FR_TYPE_TLV);
454  if (!ni) goto error;
455  our_parent = ni;
456  continue;
457  }
458  }
459  FALL_THROUGH;
460 
461  default:
462  /*
463  * Leaf type with more components
464  * is an error.
465  */
466  if (fr_sbuff_is_char(&our_in, '.')) {
467  fr_strerror_printf("Interior OID component cannot proceed a %s type",
468  fr_type_to_str(our_parent->type));
469  goto error;
470  }
471  if (dict_attr_init(&n, our_parent, NULL, num, type,
472  &(dict_attr_args_t){ .flags = &flags }) < 0) goto error;
473  break;
474  }
475  break;
476 
477  default:
478  {
479  fr_sbuff_marker_t c_start;
480 
481  fr_sbuff_marker(&c_start, &our_in);
483  fr_strerror_printf("Unknown attribute \"%.*s\" for parent \"%s\"",
484  (int)fr_sbuff_behind(&c_start), fr_sbuff_current(&c_start), our_parent->name);
485  goto error;
486  }
487  }
488  break;
489  }
490 
491  DA_VERIFY(n);
492 
493  *out = n;
494 
495  FR_SBUFF_SET_RETURN(in, &our_in);
496 }
497 
498 /** Fixup the parent of an unknown attribute using an equivalent known attribute
499  *
500  * This can be useful where an unknown attribute's ancestors are added to
501  * a dictionary but not the unknown attribute itself.
502  *
503  * @param[in] da to fixup.
504  * @param[in] parent to assign. If NULL, we will attempt to resolve
505  * the parent in the dictionary the current unknown
506  * attribute extends.
507  * @return
508  * - 0 on success.
509  * - -1 on failure.
510  */
512 {
513  fr_dict_attr_t const *da_u, *da_k;
514 
515  if (parent) {
516  /*
517  * Walk back up the hierarchy until we get to a known
518  * ancestor on the unknown side.
519  */
520  for (da_u = da->parent, da_k = parent;
521  da_k && da_u && da_u->flags.is_unknown;
522  da_u = da_u->parent, da_k = da_k->parent) {
523  if (unlikely(da_u->attr != da_k->attr)) {
524  fr_strerror_printf("Unknown parent number %u does not match "
525  "known parent number %u (%s)",
526  da_u->attr, da_k->attr, da_k->name);
527  return -1;
528  }
529 
530  if (unlikely(da_u->depth != da_k->depth)) {
531  fr_strerror_printf("Unknown parent depth %u does not match "
532  "known parent depth %u (%s)",
533  da_u->depth, da_k->depth, da_k->name);
534  return -1;
535  }
536  }
537  if ((da_k == NULL) != (da_u == NULL)) {
538  fr_strerror_printf("Truncated or over-extended hierarchy "
539  "for unknown attribute %u", da->attr);
540  return -1;
541  }
542  } else {
544  if (!parent) {
545  fr_strerror_printf("Failed resolving unknown attribute %u "
546  "in dictionary", da->attr);
547  return -1;
548  }
549  }
550 
551  da->parent = fr_dict_attr_unconst(parent);
552 
553  return 0;
554 }
555 
556 /** Check to see if we can convert a nested TLV structure to known attributes
557  *
558  * @param[in] dict to search in.
559  * @param[in] da Nested tlv structure to convert.
560  * @return
561  * - NULL if we can't.
562  * - Known attribute if we can.
563  */
565 {
566  INTERNAL_IF_NULL(dict, NULL);
567 
568  if (!da->flags.is_unknown) return da; /* It's known */
569 
570  if (da->parent) {
571  fr_dict_attr_t const *parent;
572 
574  if (!parent) return NULL;
575 
576  return fr_dict_attr_child_by_num(parent, da->attr);
577  }
578 
579  if (dict->root == da) return dict->root;
580  return NULL;
581 }
int n
Definition: acutest.h:577
static fr_dict_t * dict
Definition: fuzzer.c:46
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
Definition: build.h:165
#define RCSID(id)
Definition: build.h:481
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
Definition: build.h:320
#define unlikely(_x)
Definition: build.h:379
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
Definition: debug.h:139
static fr_dict_attr_t * fr_dict_attr_unknown_copy(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Definition: dict.h:550
unsigned int has_value
Has a value.
Definition: dict.h:92
fr_dict_attr_t * fr_dict_attr_unconst(fr_dict_attr_t const *da)
Coerce to non-const.
Definition: dict_util.c:4597
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:3263
bool const fr_dict_attr_allowed_chars[UINT8_MAX+1]
Characters that are allowed in dictionary attribute names.
Definition: dict_util.c:51
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:570
unsigned int array
Pack multiples into 1 attr.
Definition: dict.h:88
unsigned int extra
really "subtype is used by dict, not by protocol"
Definition: dict.h:112
#define DA_VERIFY(_x)
Definition: dict.h:66
unsigned int is_raw
This dictionary attribute was constructed from a known attribute to allow the user to assign octets v...
Definition: dict.h:79
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_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:2606
uint8_t type_size
For TLV2 and root attributes.
Definition: dict.h:135
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:562
#define FR_DICT_MAX_TLV_STACK
Maximum TLV stack size.
Definition: dict.h:492
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:1712
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
#define fr_dict_attr_is_key_field(_da)
Definition: dict.h:152
static fr_slen_t in
Definition: dict.h:821
#define FR_DICT_ATTR_MAX_NAME_LEN
Maximum length of a attribute name.
Definition: dict.h:472
uint8_t length
length of the attribute
Definition: dict.h:127
unsigned int is_unknown
This dictionary attribute is ephemeral and not part of the main dictionary.
Definition: dict.h:76
Values of the encryption flags.
Definition: merged_model.c:139
static int dict_attr_ext_copy_all(fr_dict_attr_t **da_out_p, fr_dict_attr_t const *da_in)
Copy all attribute extensions from one attribute to another.
Definition: dict_ext_priv.h:90
#define dict_attr_alloc(_ctx, _parent, _name, _attr, _type, _args)
Definition: dict_priv.h:235
#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:1524
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:1425
int dict_vendor_add(fr_dict_t *dict, char const *name, unsigned int num)
Add a vendor to the dictionary.
Definition: dict_util.c:1309
#define dict_attr_init(_da_p, _parent, _name, _attr, _type, _args)
Full initialisation functions.
Definition: dict_priv.h:211
fr_dict_attr_t * dict_attr_alloc_null(TALLOC_CTX *ctx, fr_dict_protocol_t const *dict)
Partial initialisation functions.
Definition: dict_util.c:917
Optional arguments for initialising/allocating attributes.
Definition: dict_priv.h:171
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.
Definition: dict_unknown.c:378
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.
Definition: dict_unknown.c:271
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.
Definition: dict_unknown.c:229
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.
Definition: dict_unknown.c:511
void fr_dict_attr_unknown_free(fr_dict_attr_t const **da)
Free dynamically allocated (unknown attributes)
Definition: dict_unknown.c:148
fr_dict_attr_t * fr_dict_attr_unknown_raw_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Initialise an octets type attribute from a da.
Definition: dict_unknown.c:352
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.
Definition: dict_unknown.c:564
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.
Definition: dict_unknown.c:38
static fr_dict_attr_t * dict_unknown_alloc(TALLOC_CTX *ctx, fr_dict_attr_t const *da, fr_type_t type)
Allocate an unknown DA.
Definition: dict_unknown.c:165
talloc_free(reap)
fr_type_t
Definition: merged_model.c:80
@ FR_TYPE_TLV
Contains nested attributes.
Definition: merged_model.c:118
@ FR_TYPE_MAX
Number of defined data types.
Definition: merged_model.c:130
@ FR_TYPE_NULL
Invalid (uninitialised) attribute type.
Definition: merged_model.c:81
@ FR_TYPE_VALUE_BOX
A boxed value.
Definition: merged_model.c:125
@ FR_TYPE_VENDOR
Attribute that represents a vendor in the attribute tree.
Definition: merged_model.c:122
@ FR_TYPE_VOID
User data.
Definition: merged_model.c:127
@ FR_TYPE_VSA
Vendor-Specific, for RADIUS attribute 26.
Definition: merged_model.c:121
@ FR_TYPE_OCTETS
Raw octets.
Definition: merged_model.c:84
unsigned int uint32_t
Definition: merged_model.c:33
ssize_t fr_slen_t
Definition: merged_model.c:35
fr_sbuff_parse_error_t
Definition: merged_model.c:45
@ FR_SBUFF_PARSE_OK
No error.
Definition: merged_model.c:46
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:1755
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:2066
#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(_sbuff_or_marker)
#define fr_sbuff_out(_err, _out, _in)
#define fr_sbuff_behind(_sbuff_or_marker)
fr_assert(0)
fr_aka_sim_id_type_t type
static int talloc_const_free(void const *ptr)
Free const'd memory.
Definition: talloc.h:224
static fr_slen_t parent
Definition: pair.h:851
#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
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
Definition: types.h:433
#define FR_TYPE_STRUCTURAL_EXCEPT_VSA
Definition: types.h:294
#define fr_type_is_structural_except_vsa(_x)
Definition: types.h:370
FR_SBUFF_SET_RETURN(sbuff, &our_sbuff)
static size_t char ** out
Definition: value.h:997