* - 0 on success.
* - -1 on failure.
*/
-static int fr_dict_protocol_add(fr_dict_t *dict)
+static int dict_protocol_add(fr_dict_t *dict)
{
if (!dict->root) return -1; /* Should always have root */
* - 0 on success.
* - -1 on failure (memory allocation error).
*/
-static inline int fr_dict_attr_child_add(fr_dict_attr_t *parent, fr_dict_attr_t *child)
+static inline int dict_attr_child_add(fr_dict_attr_t *parent, fr_dict_attr_t *child)
{
fr_dict_attr_t const * const *bin;
fr_dict_attr_t **this;
* @return the number of bytes written to the buffer.
*/
size_t fr_dict_print_attr_oid(char *out, size_t outlen,
- fr_dict_attr_t const *ancestor, fr_dict_attr_t const *da)
+ fr_dict_attr_t const *ancestor, fr_dict_attr_t const *da)
{
size_t len;
char *p = out, *end = p + outlen;
* - 0 on success.
* - -1 on failure (memory allocation error).
*/
-static fr_dict_attr_t *fr_dict_attr_alloc_name(TALLOC_CTX *ctx, char const *name)
+static fr_dict_attr_t *dict_attr_alloc_name(TALLOC_CTX *ctx, char const *name)
{
fr_dict_attr_t *da;
* - A copy of the input fr_dict_attr_t on success.
* - NULL on failure.
*/
-static fr_dict_attr_t *fr_dict_attr_acopy(TALLOC_CTX *ctx, fr_dict_attr_t const *in)
+static fr_dict_attr_t *dict_attr_acopy(TALLOC_CTX *ctx, fr_dict_attr_t const *in)
{
fr_dict_attr_t *n;
- n = fr_dict_attr_alloc_name(ctx, in->name);
+ n = dict_attr_alloc_name(ctx, in->name);
if (!n) return NULL;
n->attr = in->attr;
* - A new fr_dict_attr_t on success.
* - NULL on failure.
*/
-static fr_dict_attr_t *fr_dict_attr_alloc(TALLOC_CTX *ctx,
- fr_dict_attr_t const *parent,
- char const *name, int attr,
- fr_type_t type, fr_dict_attr_flags_t const *flags)
+static fr_dict_attr_t *dict_attr_alloc(TALLOC_CTX *ctx,
+ fr_dict_attr_t const *parent,
+ char const *name, int attr,
+ fr_type_t type, fr_dict_attr_flags_t const *flags)
{
fr_dict_attr_t *da;
fr_dict_attr_t new = {
return NULL;
}
- da = fr_dict_attr_alloc_name(ctx, buffer);
+ da = dict_attr_alloc_name(ctx, buffer);
} else {
- da = fr_dict_attr_alloc_name(ctx, name);
+ da = dict_attr_alloc_name(ctx, name);
}
new.name = da->name;
* - fr_dict_attr_t on success
* - NULL on failure
*/
-static fr_dict_attr_t *fr_dict_attr_add_by_name(fr_dict_t *dict, fr_dict_attr_t const *parent,
- char const *name, int attr, fr_type_t type, fr_dict_attr_flags_t flags)
+static fr_dict_attr_t *dict_attr_add_by_name(fr_dict_t *dict, fr_dict_attr_t const *parent,
+ char const *name, int attr, fr_type_t type, fr_dict_attr_flags_t flags)
{
size_t namelen;
fr_dict_attr_t *n;
}
}
- n = fr_dict_attr_alloc(dict->pool, parent, name, attr, type, &flags);
+ n = dict_attr_alloc(dict->pool, parent, name, attr, type, &flags);
if (!n) {
fr_strerror_printf("Out of memory");
goto error;
if (n->type == FR_TYPE_COMBO_IP_ADDR) {
fr_dict_attr_t *v4, *v6;
- v4 = fr_dict_attr_acopy(dict->pool, n);
+ v4 = dict_attr_acopy(dict->pool, n);
if (!v4) {
talloc_free(n);
goto error;
}
- v6 = fr_dict_attr_acopy(dict->pool, n);
+ v6 = dict_attr_acopy(dict->pool, n);
if (!v6) {
talloc_free(n);
goto error;
fr_dict_attr_t *n;
fr_dict_attr_t *mutable;
- n = fr_dict_attr_add_by_name(dict, parent, name, attr, type, flags);
+ n = dict_attr_add_by_name(dict, parent, name, attr, type, flags);
if (!n) return -1;
/*
*/
memcpy(&mutable, &parent, sizeof(mutable));
- if (fr_dict_attr_child_add(mutable, n) < 0) return -1;
+ if (dict_attr_child_add(mutable, n) < 0) return -1;
return 0;
}
return -1;
}
- dict->root = fr_dict_attr_alloc_name(dict, name);
+ dict->root = dict_attr_alloc_name(dict, name);
if (!dict->root) return -1;
dict->root->attr = proto_number;
* @return
* - NULL on memory allocation error.
*/
-static fr_dict_t *fr_dict_alloc(TALLOC_CTX *ctx)
+static fr_dict_t *dict_alloc(TALLOC_CTX *ctx)
{
fr_dict_t *dict;
return 0;
}
- dict = fr_dict_alloc(NULL);
+ dict = dict_alloc(NULL);
/*
* Set the root attribute with the protocol name
*/
dict_root_set(dict, argv[0], value);
- if (fr_dict_protocol_add(dict) < 0) return -1;
+ if (dict_protocol_add(dict) < 0) return -1;
return 0;
}
memset(&flags, 0, sizeof(flags));
memcpy(&mutable, &ctx->parent, sizeof(mutable));
- new = fr_dict_attr_alloc(mutable, fr_dict_root(ctx->dict), "Vendor-Specific",
+ new = dict_attr_alloc(mutable, fr_dict_root(ctx->dict), "Vendor-Specific",
FR_VENDOR_SPECIFIC, FR_TYPE_VSA, &flags);
- fr_dict_attr_child_add(mutable, new);
+ dict_attr_child_add(mutable, new);
vsa_da = new;
}
}
}
memcpy(&mutable, &vsa_da, sizeof(mutable));
- new = fr_dict_attr_alloc(mutable, ctx->parent, argv[1], vendor, FR_TYPE_VENDOR, &flags);
- fr_dict_attr_child_add(mutable, new);
+ new = dict_attr_alloc(mutable, ctx->parent, argv[1], vendor, FR_TYPE_VENDOR, &flags);
+ dict_attr_child_add(mutable, new);
vendor_da = new;
}
* - 0 on success.
* - -1 on failure.
*/
-static int fr_dict_global_init(TALLOC_CTX *ctx)
+static int dict_global_init(TALLOC_CTX *ctx)
{
if (protocol_by_name && protocol_by_num) return 0;
static bool defined_cast_types;
fr_dict_t *dict;
- dict = fr_dict_alloc(ctx);
+ dict = dict_alloc(ctx);
if (!dict) return -1;
/*
type_name = talloc_typed_asprintf(dict->pool, "Tmp-Cast-%s", p->name);
- n = fr_dict_attr_alloc(dict->pool, dict->root, type_name,
+ n = dict_attr_alloc(dict->pool, dict->root, type_name,
FR_CAST_BASE + p->number, p->number, &flags);
if (!n) {
error:
/*
* Set up parenting for the attribute.
*/
- if (fr_dict_attr_child_add(dict->root, n) < 0) goto error;
+ if (dict_attr_child_add(dict->root, n) < 0) goto error;
talloc_free(type_name);
}
memcpy(&tmp, &dir, sizeof(tmp));
dict_dir = internal_name ? talloc_asprintf(NULL, "%s%c%s", dir, FR_DIR_SEP, internal_name) : tmp;
- if ((!protocol_by_name || !protocol_by_num) && (fr_dict_global_init(ctx) < 0)) return -1;
+ if ((!protocol_by_name || !protocol_by_num) && (dict_global_init(ctx) < 0)) return -1;
if (!dict) {
- dict = fr_dict_alloc(ctx);
+ dict = dict_alloc(ctx);
if (!dict) {
error:
if (!fr_dict_internal) talloc_free(dict);
type_name = talloc_typed_asprintf(dict->pool, "Tmp-Cast-%s", p->name);
- n = fr_dict_attr_alloc(dict->pool, dict->root, type_name,
+ n = dict_attr_alloc(dict->pool, dict->root, type_name,
FR_CAST_BASE + p->number, p->number, &flags);
if (!n) goto error;
/*
* Set up parenting for the attribute.
*/
- if (fr_dict_attr_child_add(dict->root, n) < 0) goto error;
+ if (dict_attr_child_add(dict->root, n) < 0) goto error;
talloc_free(type_name);
}
dir = talloc_asprintf(proto_dir, "%s%c%s", base_dir, FR_DIR_SEP, proto_dir);
if (!*out) {
- dict = fr_dict_alloc(ctx);
+ dict = dict_alloc(ctx);
if (!dict) {
error:
talloc_free(proto_dir);
parent = da->parent;
}
- n = fr_dict_attr_alloc(ctx, parent, da->name, da->attr, da->type, &da->flags);
+ n = dict_attr_alloc(ctx, parent, da->name, da->attr, da->type, &da->flags);
n->parent = parent;
n->depth = da->depth;
if (fr_dict_vendor_add(dict, old->name, old->attr) < 0) return NULL;
- n = fr_dict_attr_alloc(dict->pool, parent, old->name, old->attr, old->type, &flags);
+ n = dict_attr_alloc(dict->pool, parent, old->name, old->attr, old->type, &flags);
/*
* Setup parenting for the attribute
*/
memcpy(&mutable, &old->parent, sizeof(mutable));
- if (fr_dict_attr_child_add(mutable, n) < 0) return NULL;
+ if (dict_attr_child_add(mutable, n) < 0) return NULL;
return n;
}
* is responsible for converting "Attr-26 = 0x..." to an actual attribute,
* if it so desires.
*/
- return fr_dict_attr_add_by_name(dict, parent, old->name, old->attr, old->type, flags);
+ return dict_attr_add_by_name(dict, parent, old->name, old->attr, old->type, flags);
}
/*
parent = new_parent;
}
- n = fr_dict_attr_alloc(ctx, parent, NULL, attr, FR_TYPE_OCTETS, &flags);
+ n = dict_attr_alloc(ctx, parent, NULL, attr, FR_TYPE_OCTETS, &flags);
/*
* The config files may reference the unknown by name.
case FR_TYPE_EVS:
if (!fr_cond_assert(!parent->flags.is_unknown)) return -1;
- *out = fr_dict_attr_alloc(ctx, parent, NULL, vendor, FR_TYPE_VENDOR, &flags);
+ *out = dict_attr_alloc(ctx, parent, NULL, vendor, FR_TYPE_VENDOR, &flags);
return 0;
* - 0 on success.
* - -1 on failure.
*/
-static int fr_dict_unknown_attr_afrom_num(TALLOC_CTX *ctx, fr_dict_attr_t **out,
- fr_dict_attr_t const *parent, unsigned long num)
+static int dict_unknown_attr_afrom_num(TALLOC_CTX *ctx, fr_dict_attr_t **out,
+ fr_dict_attr_t const *parent, unsigned long num)
{
fr_dict_attr_t *da;
fr_dict_attr_flags_t flags = {
*out = NULL;
- da = fr_dict_attr_alloc(ctx, parent, NULL, num, FR_TYPE_OCTETS, &flags);
+ da = dict_attr_alloc(ctx, parent, NULL, num, FR_TYPE_OCTETS, &flags);
if (!da) return -1;
*out = da;
case FR_TYPE_EXTENDED:
case FR_TYPE_LONG_EXTENDED:
is_root:
- if (fr_dict_unknown_attr_afrom_num(our_ctx, &n, our_parent, num) < 0) {
+ if (dict_unknown_attr_afrom_num(our_ctx, &n, our_parent, num) < 0) {
goto error;
}
* Leaf attribute
*/
case '\0':
- if (fr_dict_unknown_attr_afrom_num(our_ctx, &n, our_parent, num) < 0) goto error;
+ if (dict_unknown_attr_afrom_num(our_ctx, &n, our_parent, num) < 0) goto error;
break;
}
p++;
return NULL;
}
-static void fr_dict_snprint_flags(char *out, size_t outlen, fr_dict_attr_flags_t flags)
+static void dict_snprint_flags(char *out, size_t outlen, fr_dict_attr_flags_t flags)
{
char *p = out, *end = p + outlen;
size_t len;
unsigned int i;
char const *name;
- fr_dict_snprint_flags(buff, sizeof(buff), da->flags);
+ dict_snprint_flags(buff, sizeof(buff), da->flags);
switch (da->type) {
case FR_TYPE_VSA: