.allow_foreign = false, /* tests are in the RADIUS dictionary */
};
- fr_map_list_init(&list);
+ fr_dlist_map_init(&list);
/*
* Must be called first, so the handler is called last
*/
cf_log_perr(cs, "map_afrom_cs failed");
return EXIT_FAILURE; /* message already printed */
}
- if (fr_map_list_empty(&list)) {
+ if (fr_dlist_map_empty(&list)) {
cf_log_err(cs, "'update' sections cannot be empty");
return EXIT_FAILURE;
}
printf("%s %s {\n", name1, name2);
}
- while ((map = fr_map_list_next(&list, map))) {
+ while ((map = fr_dlist_map_next(&list, map))) {
map_print(&FR_SBUFF_OUT(buffer + 1, sizeof(buffer) - 1), map);
puts(buffer);
}
*
* Expands to 1 if types are compatible, else 0.
*
- * @param _x pointer to check.
- * @param _t type to check compatibility with.
+ * @param[in] _x pointer to check.
+ * @param[in] _t type to check compatibility with.
*/
#define IS_COMPATIBLE(_x, _t) _Generic(_x, _t:1, default: 0)
+/** Check if a field in a struct is compatible (the C11 way)
+ *
+ * Expands to 1 if types are compatible, else 0.
+ *
+ * @param[in] _s struct to check.
+ * @param[in] _f field in struct.
+ * @param[in] _t type to check compatibility with.
+ */
+#define IS_FIELD_COMPATIBLE(_s, _f, _t) _Generic(((_s *)0)->_f, _t:1, default: 0)
+
/*
* Only use GCC __attribute__ if were building with a GCClike
* compiler.
*/
#ifdef __GNUC__
-# define CC_HINT(...) __attribute__ ((__VA_ARGS__))
+# define CC_HINT(...) __attribute__((__VA_ARGS__))
# define likely(_x) __builtin_expect((_x), 1)
# define unlikely(_x) __builtin_expect((_x), 0)
#else
char const *attr;
char attr_buff[1024 + 1]; /* X.501 says we need to support at least 1024 chars for attr names */
- while ((map = fr_map_list_next(maps, map))) {
+ while ((map = fr_dlist_map_next(maps, map))) {
if (tmpl_expand(&attr, attr_buff, sizeof(attr_buff), request, map->rhs, NULL, NULL) < 0) {
REDEBUG("Expansion of LDAP attribute \"%s\" failed", map->rhs->name);
TALLOC_FREE(ctx);
fr_ldap_result_t result;
char const *name;
- while ((map = fr_map_list_next(expanded->maps, map))) {
+ while ((map = fr_dlist_map_next(expanded->maps, map))) {
int ret;
name = expanded->attrs[total++];
}
MAP_VERIFY(map);
- fr_map_list_insert_tail(out, map);
+ fr_dlist_map_insert_tail(out, map);
return 0;
}
}
map->parent = parent;
- fr_map_list_init(&map->child);
+ fr_dlist_map_init(&map->child);
return map;
}
* caller will have to check for this!
*/
if (is_child && parent) {
- fr_map_list_insert_tail(&parent->child, map);
+ fr_dlist_map_insert_tail(&parent->child, map);
}
if (parent_p) *parent_p = new_parent;
* Free in reverse as successive entries have their
* prececessors as talloc parent contexts
*/
- fr_map_list_talloc_reverse_free(out);
+ fr_dlist_map_talloc_reverse_free(out);
return -1;
}
bool qualifiers = our_lhs_rules.disallow_qualifiers;
fr_map_list_t child_list;
- fr_map_list_init(&child_list);
+ fr_dlist_map_init(&child_list);
subcs = cf_item_to_section(ci);
token = cf_section_name2_quote(subcs);
*/
if (_map_afrom_cs(map, &child_list, map, cf_item_to_section(ci),
&our_lhs_rules, rhs_rules, validate, uctx, max) < 0) {
- fr_map_list_talloc_free(&child_list);
+ fr_dlist_map_talloc_free(&child_list);
talloc_free(map);
goto error;
}
- fr_map_list_move(&map->child, &child_list);
+ fr_dlist_map_move(&map->child, &child_list);
our_lhs_rules.disallow_qualifiers = qualifiers;
MAP_VERIFY(map);
next:
parent_ctx = map;
- fr_map_list_insert_tail(out, map);
+ fr_dlist_map_insert_tail(out, map);
}
return 0;
MEM(n = fr_pair_afrom_da(ctx, tmpl_da(map->lhs)));
n->op = map->op;
- for (child = fr_map_list_next(&map->child, NULL);
+ for (child = fr_dlist_map_next(&map->child, NULL);
child != NULL;
- child = fr_map_list_next(&map->child, child)) {
+ child = fr_dlist_map_next(&map->child, child)) {
fr_pair_list_t list;
/*
* If there's no child and no RHS then the
* map was invalid.
*/
- if (fr_map_list_empty(&map->child) && !fr_cond_assert(map->rhs != NULL)) {
+ if (fr_dlist_map_empty(&map->child) && !fr_cond_assert(map->rhs != NULL)) {
fr_sbuff_terminate(out);
return 0;
}
#include <freeradius-devel/server/cf_util.h>
#include <freeradius-devel/server/tmpl.h>
+#include <freeradius-devel/util/dlist.h>
#ifdef __cplusplus
extern "C" {
['>'] = true, \
['~'] = true
-/** Value pair map list
+FR_DLIST_TYPES(map)
+
+/** Given these are used in so many places, it's more friendly to have a proper type
*
- * Specifically define a type for lists of map_t to aid type checking
*/
-typedef struct {
- fr_dlist_head_t head;
-} fr_map_list_t;
+typedef FR_DLIST_HEAD_TYPE(map) fr_map_list_t;
/** Value pair map
*
* @see tmpl_t
*/
struct vp_map_s {
- tmpl_t *lhs; //!< Typically describes the attribute to add, modify or compare.
- tmpl_t *rhs; //!< Typically describes a literal value or a src attribute
- ///< to copy or compare.
+ tmpl_t *lhs; //!< Typically describes the attribute to add, modify or compare.
+ tmpl_t *rhs; //!< Typically describes a literal value or a src attribute
+ ///< to copy or compare.
- fr_token_t op; //!< The operator that controls insertion of the dst attribute.
- fr_type_t cast; //!< Cast value to this type.
+ fr_token_t op; //!< The operator that controls insertion of the dst attribute.
+ fr_type_t cast; //!< Cast value to this type.
- CONF_ITEM *ci; //!< Config item that the map was created from. Mainly used for
- //!< logging validation errors.
+ CONF_ITEM *ci; //!< Config item that the map was created from. Mainly used for
+ //!< logging validation errors.
- map_t *parent; //! parent map, for nested ones
- fr_map_list_t child; //!< a child map. If it exists, `rhs` MUST be NULL
- fr_dlist_t entry; //!< List entry.
+ map_t *parent; //! parent map, for nested ones
+ fr_map_list_t child; //!< a child map. If it exists, `rhs` MUST be NULL
+ FR_DLIST_ENTRY_TYPE(map) entry; //!< List entry.
};
-FR_DLIST_NEW_TYPE(map_list, fr_map_list_t, head, map_t, entry)
+FR_DLIST_FUNCS(map, map_t, entry)
/** A list modification
*
*/
struct vp_list_mod_s {
- map_t const *map; //!< Original map describing the change to be made.
+ map_t const *map; //!< Original map describing the change to be made.
- fr_map_list_t mod; //!< New map containing the destination (LHS) and
- ///< values (RHS).
- fr_dlist_t entry; //!< Entry into dlist
+ fr_map_list_t mod; //!< New map containing the destination (LHS) and
+ ///< values (RHS).
+ fr_dlist_t entry; //!< Entry into dlist
};
#ifndef WITH_VERIFY_PTR
{
vp_list_mod_t *mod;
mod = talloc_zero(ctx, vp_list_mod_t);
- fr_map_list_init(&mod->mod);
+ fr_dlist_map_init(&mod->mod);
return mod;
}
{
map_t *map;
map = talloc_zero(ctx, map_t);
- fr_map_list_init(&map->child);
+ fr_dlist_map_init(&map->child);
return map;
}
talloc_free(n);
return NULL;
}
- fr_map_list_insert_tail(&n->mod, mod);
+ fr_dlist_map_insert_tail(&n->mod, mod);
return n;
}
talloc_free(n);
return NULL;
}
- fr_map_list_insert_tail(&n->mod, mod);
+ fr_dlist_map_insert_tail(&n->mod, mod);
return n;
}
talloc_free(n);
return NULL;
}
- fr_map_list_insert_tail(&n->mod, mod);
+ fr_dlist_map_insert_tail(&n->mod, mod);
return n;
}
mod->lhs = mutated->lhs;
mod->op = mutated->op;
mod->rhs = mutated->rhs;
- fr_map_list_insert_tail(&n->mod, mod);
+ fr_dlist_map_insert_tail(&n->mod, mod);
goto finish;
}
* before this map is applied.
*/
if (fr_value_box_copy(n_mod->rhs, tmpl_value(n_mod->rhs), &vp->data) < 0) goto error;
- fr_map_list_insert_tail(&n->mod, n_mod);
+ fr_dlist_map_insert_tail(&n->mod, n_mod);
MAP_VERIFY(n_mod);
} while ((vp = fr_pair_list_next(list, vp)));
fr_dcursor_init(&values, &head);
- if (fr_value_box_from_str(fr_map_list_head(&n->mod),
- tmpl_value(fr_map_list_head(&n->mod)->rhs), type,
+ if (fr_value_box_from_str(fr_dlist_map_head(&n->mod),
+ tmpl_value(fr_dlist_map_head(&n->mod)->rhs), type,
tmpl_da(mutated->lhs),
mutated->rhs->name, mutated->rhs->len,
fr_value_unescape_by_quote[(uint8_t)mutated->rhs->quote], false)) {
(void)fr_dcursor_init(&from, rhs_result);
while ((vb = fr_dcursor_remove(&from))) {
if (vb->type != tmpl_da(mutated->lhs)->type) {
- n_vb = fr_value_box_alloc_null(fr_map_list_head(&n->mod)->rhs);
+ n_vb = fr_value_box_alloc_null(fr_dlist_map_head(&n->mod)->rhs);
if (!n_vb) {
fr_dcursor_head(&from);
fr_dcursor_free_list(&from);
vp = fr_dcursor_current(&from);
fr_assert(vp); /* Should have errored out */
do {
- n_vb = fr_value_box_alloc_null(fr_map_list_head(&n->mod)->rhs);
+ n_vb = fr_value_box_alloc_null(fr_dlist_map_head(&n->mod)->rhs);
if (!n_vb) {
attr_error:
fr_dcursor_head(&values);
vb = tmpl_value(mutated->rhs);
- n_vb = fr_value_box_alloc_null(fr_map_list_head(&n->mod)->rhs);
+ n_vb = fr_value_box_alloc_null(fr_dlist_map_head(&n->mod)->rhs);
if (!n_vb) {
data_error:
fr_dcursor_head(&values);
}
mod->op = vp->op;
- fr_map_list_insert_tail(&n->mod, mod);
+ fr_dlist_map_insert_tail(&n->mod, mod);
}
}
* If tmpl_value were a pointer we could
* assign values directly.
*/
- fr_value_box_copy(fr_map_list_head(&n->mod)->rhs, tmpl_value(fr_map_list_head(&n->mod)->rhs), fr_dlist_head(&head));
+ fr_value_box_copy(fr_dlist_map_head(&n->mod)->rhs, tmpl_value(fr_dlist_map_head(&n->mod)->rhs), fr_dlist_head(&head));
/*
* value boxes in tmpls cannot now be the head of a list
*
- *tmpl_value(fr_map_list_head(&n->mod)->rhs)->next = head->next;
+ *tmpl_value(fr_dlist_map_head(&n->mod)->rhs)->next = head->next;
*/
fr_dlist_talloc_free(&head);
{
map_t *mod;
- fr_assert(!fr_map_list_empty(&vlm->mod));
+ fr_assert(!fr_dlist_map_empty(&vlm->mod));
/*
* Fast path...
*/
- mod = fr_map_list_head(&vlm->mod);
- if (fr_map_list_num_elements(&vlm->mod) == 1) {
+ mod = fr_dlist_map_head(&vlm->mod);
+ if (fr_dlist_map_num_elements(&vlm->mod) == 1) {
fr_pair_t *vp;
vp = map_list_mod_to_vp(ctx, mod->lhs, tmpl_value(mod->rhs));
fr_pair_append(list, vp);
*/
for (;
mod;
- mod = fr_map_list_next(&vlm->mod, mod)) {
+ mod = fr_dlist_map_next(&vlm->mod, mod)) {
fr_pair_t *vp;
vp = map_list_mod_to_vp(ctx, mod->lhs, tmpl_value(mod->rhs));
memset(&cc, 0, sizeof(cc));
MAP_VERIFY(map);
- fr_assert(!fr_map_list_empty(&vlm->mod));
+ fr_assert(!fr_dlist_map_empty(&vlm->mod));
/*
* Print debug information for the mods being applied
*/
- while ((mod = fr_map_list_next(&vlm->mod, mod))) {
+ while ((mod = fr_dlist_map_next(&vlm->mod, mod))) {
fr_value_box_t *vb;
MAP_VERIFY(mod);
map_list_mod_debug(request, map, mod, vb->type != FR_TYPE_NULL ? vb : NULL);
}
}
- mod = fr_map_list_head(&vlm->mod); /* Reset */
+ mod = fr_dlist_map_head(&vlm->mod); /* Reset */
/*
* All this has been checked by #map_to_list_mod
}
}
- fr_assert(!fr_map_list_next(&vlm->mod, mod));
+ fr_assert(!fr_dlist_map_next(&vlm->mod, mod));
/*
* Find the destination attribute. We leave with either
* any of these values.
*/
if (tmpl_num(map->lhs) != NUM_ALL) {
- fr_value_box_t *vb = tmpl_value(fr_map_list_head(&vlm->mod)->rhs);
+ fr_value_box_t *vb = tmpl_value(fr_dlist_map_head(&vlm->mod)->rhs);
if (fr_value_box_cmp(vb, &found->data) == 0) {
fr_dcursor_free_item(&list);
* matches any of these values.
*/
do {
- fr_value_box_t *vb = tmpl_value(fr_map_list_head(&vlm->mod)->rhs);
+ fr_value_box_t *vb = tmpl_value(fr_dlist_map_head(&vlm->mod)->rhs);
if (fr_value_box_cmp(vb, &found->data) == 0) {
fr_dcursor_free_item(&list);
RDEBUG4("::: OVERWRITING %s FROM %d TO %d",
to_vp->da->name, i, j);
fr_pair_remove(from, from_vp);
- vp = fr_dlist_replace(&to->order, to_vp, from_vp);
+ vp = fr_dlist_replace(&to->order.head, to_vp, from_vp);
talloc_free(vp);
from_vp = NULL;
edited[j] = true;
RDEBUG4("::: REPLACING %s FROM %d TO %d",
from_vp->da->name, i, j);
fr_pair_remove(from, from_vp);
- vp = fr_dlist_replace(&to->order, to_vp, from_vp);
+ vp = fr_dlist_replace(&to->order.head, to_vp, from_vp);
talloc_free(vp);
from_vp = NULL;
edited[j] = true;
RDEBUG4("::: REPLACING %s FROM %d TO %d",
from_vp->da->name, i, j);
fr_pair_remove(from, from_vp);
- vp = fr_dlist_replace(&to->order, to_vp, from_vp);
+ vp = fr_dlist_replace(&to->order.head, to_vp, from_vp);
talloc_free(vp);
from_vp = NULL;
edited[j] = true;
list_ctx = ns->list_ctx;
ar = ns->ar;
- curr = _tmpl_cursor_eval(&list_head->order, curr, &cc);
+ curr = _tmpl_cursor_eval(&list_head->order.head, curr, &cc);
if (!curr) {
/*
* References extend beyond current
* We MUST be either at a valid entry, OR at EOF.
*/
MEM(t = talloc_zero(ctx, PAIR_LIST));
- fr_map_list_init(&t->check);
- fr_map_list_init(&t->reply);
+ fr_dlist_map_init(&t->check);
+ fr_dlist_map_init(&t->reply);
t->filename = filename;
t->lineno = lineno;
t->order = order++;
do_insert:
fr_assert(!new_map->parent);
- fr_map_list_insert_tail(&t->check, new_map);
+ fr_dlist_map_insert_tail(&t->check, new_map);
/*
* There can be spaces before any comma.
fr_assert(tmpl_list(new_map->lhs) == PAIR_LIST_REPLY);
- if (!new_map->parent) fr_map_list_insert_tail(&t->reply, new_map);
+ if (!new_map->parent) fr_dlist_map_insert_tail(&t->reply, new_map);
(void) fr_sbuff_adv_past_blank(&sbuff, SIZE_MAX, NULL);
/*
* Sanity check sublists.
*/
- if (!fr_map_list_empty(&map->child)) {
+ if (!fr_dlist_map_empty(&map->child)) {
fr_dict_attr_t const *da;
if (!tmpl_is_attr(map->lhs)) {
return false;
}
- return pass2_fixup_map(fr_map_list_head(&map->child), rules, da);
+ return pass2_fixup_map(fr_dlist_map_head(&map->child), rules, da);
}
return true;
RULES_VERIFY(rules);
- while ((map = fr_map_list_next(&gext->map, map))) {
+ while ((map = fr_dlist_map_next(&gext->map, map))) {
/*
* Mostly fixup the map, but maybe leave the RHS
* unresolved.
* the RHS as a reference to a json string, SQL column
* name, etc.
*/
- while ((map = fr_map_list_next(&gext->map, map))) {
+ while ((map = fr_dlist_map_next(&gext->map, map))) {
if (!pass2_fixup_map(map, rules, NULL)) return false;
}
*/
if (!gext->vpt) return true;
- return pass2_fixup_tmpl(fr_map_list_head(&gext->map)->ci, &gext->vpt,
+ return pass2_fixup_tmpl(fr_dlist_map_head(&gext->map)->ci, &gext->vpt,
cf_section_to_item(g->cs), rules->dict_def);
}
g = unlang_generic_to_group(c);
gext = unlang_group_to_map(g);
map = NULL;
- while ((map = fr_map_list_next(&gext->map, map))) {
+ while ((map = fr_dlist_map_next(&gext->map, map))) {
map_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), map);
DEBUG("%.*s%s", depth + 1, unlang_spaces, buffer);
}
edit = unlang_generic_to_edit(c);
map = NULL;
- while ((map = fr_map_list_next(&edit->maps, map))) {
+ while ((map = fr_dlist_map_next(&edit->maps, map))) {
map_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), map);
DEBUG("%.*s%s", depth + 1, unlang_spaces, buffer);
}
/*
* This looks at cs->name2 to determine which list to update
*/
- fr_map_list_init(&gext->map);
+ fr_dlist_map_init(&gext->map);
rcode = map_afrom_cs(gext, &gext->map, cs, &t_rules, &t_rules, unlang_fixup_map, NULL, 256);
if (rcode < 0) return NULL; /* message already printed */
- if (fr_map_list_empty(&gext->map)) {
+ if (fr_dlist_map_empty(&gext->map)) {
cf_log_err(cs, "'map' sections cannot be empty");
goto error;
}
/*
* This looks at cs->name2 to determine which list to update
*/
- fr_map_list_init(&gext->map);
+ fr_dlist_map_init(&gext->map);
rcode = map_afrom_cs(gext, &gext->map, cs, &t_rules, &t_rules, unlang_fixup_update, NULL, 128);
if (rcode < 0) return NULL; /* message already printed */
- if (fr_map_list_empty(&gext->map)) {
+ if (fr_dlist_map_empty(&gext->map)) {
cf_log_err(cs, "'update' sections cannot be empty");
error:
talloc_free(g);
/*
* This looks at cs->name2 to determine which list to update
*/
- fr_map_list_init(&gext->map);
+ fr_dlist_map_init(&gext->map);
rcode = map_afrom_cs(gext, &gext->map, cs, &t_rules, &t_rules, unlang_fixup_filter, NULL, 128);
if (rcode < 0) return NULL; /* message already printed */
- if (fr_map_list_empty(&gext->map)) {
+ if (fr_dlist_map_empty(&gext->map)) {
cf_log_err(cs, "'filter' sections cannot be empty");
return NULL;
}
c->debug_name = c->name;
c->type = UNLANG_TYPE_EDIT;
- fr_map_list_init(&edit->maps);
+ fr_dlist_map_init(&edit->maps);
edit_free = edit;
compile_action_defaults(c, unlang_ctx);
MEM(map = talloc_zero(parent, map_t));
map->op = op;
map->ci = cf_section_to_item(cs);
- fr_map_list_init(&map->child);
+ fr_dlist_map_init(&map->child);
name = cf_section_name1(cs);
*/
// if (unlang_fixup_update(map, NULL) < 0) goto fail;
- fr_map_list_insert_tail(&edit->maps, map);
+ fr_dlist_map_insert_tail(&edit->maps, map);
*prev = c;
return out;
c->debug_name = c->name;
c->type = UNLANG_TYPE_EDIT;
- fr_map_list_init(&edit->maps);
+ fr_dlist_map_init(&edit->maps);
edit_free = edit;
compile_action_defaults(c, unlang_ctx);
/*
* Convert this particular map.
*/
- if (map_afrom_cp(edit, &map, fr_map_list_tail(&edit->maps), cp, &t_rules, &t_rules) < 0) {
+ if (map_afrom_cp(edit, &map, fr_dlist_map_tail(&edit->maps), cp, &t_rules, &t_rules) < 0) {
fail:
talloc_free(edit_free);
return NULL;
*/
if (unlang_fixup_update(map, NULL) < 0) goto fail;
- fr_map_list_insert_tail(&edit->maps, map);
+ fr_dlist_map_insert_tail(&edit->maps, map);
*prev = c;
return out;
return -1;
}
- if (!fr_map_list_empty(&map->child)) {
+ if (!fr_dlist_map_empty(&map->child)) {
REDEBUG("In-place lists not yet implemented");
return -1;
}
*/
for (map = state->map;
map != NULL;
- map = state->map = fr_map_list_next(state->map_head, map)) {
+ map = state->map = fr_dlist_map_next(state->map_head, map)) {
repeatable_set(frame); /* Call us again when done */
switch (state->state) {
* The edit list creates a local pool which should
* generally be large enough for most edits.
*/
- MEM(state->el = fr_edit_list_alloc(state, fr_map_list_num_elements(&edit->maps)));
+ MEM(state->el = fr_edit_list_alloc(state, fr_dlist_map_num_elements(&edit->maps)));
state->map_head = &edit->maps;
- state->map = fr_map_list_head(state->map_head);
+ state->map = fr_dlist_map_head(state->map_head);
fr_pair_list_init(&state->rhs.pair_list);
/*
(sizeof(tmpl_t) * 2) + 128),
g->num_children)); /* 128 is for string buffers */
- fr_dcursor_init(&update_state->maps, fr_map_list_dlist_head(&gext->map));
+ fr_dcursor_init(&update_state->maps, &gext->map.head);
fr_value_box_list_init(&update_state->lhs_result);
fr_value_box_list_init(&update_state->rhs_result);
fr_dlist_init(&update_state->vlm_head, vp_list_mod_t, entry);
}
}
-/*
- * Hang onto your hats. This gets weird.
+/** Expands to the type name used for the entry wrapper structure
+ *
+ * @param[in] _name Prefix we add to type-specific structures.
+ * @return fr_dlist_<name>_entry_t
*/
-#define FR_DLIST_NEW_TYPE(_name, _list_type, _member_head, _entry_type, _member) \
+#define FR_DLIST_ENTRY_TYPE(_name) fr_dlist_ ## _name ## _entry_t
+
+/** Expands to the type name used for the head wrapper structure
+ *
+ * @param[in] _name Prefix we add to type-specific structures.
+ * @return fr_dlist_<name>_head_t
+ */
+#define FR_DLIST_HEAD_TYPE(_name) fr_dlist_ ## _name ## _head_t
+
+/** Define type specific wrapper structs for dlists
+ *
+ * @note This macro should be used inside the header for the area of code
+ * which will use type specific functions.
+ */
+#define FR_DLIST_TYPES(_name) \
+ typedef struct { fr_dlist_t entry; } FR_DLIST_ENTRY_TYPE(_name); \
+ typedef struct { fr_dlist_head_t head; } FR_DLIST_HEAD_TYPE(_name); \
+
+/** Define type specific wrapper functions for dlists
+ *
+ * @note This macro should be used inside the source file that will use
+ * the type specific functions.
+ *
+ * @param[in] _name Prefix we add to type-specific dlist functions.
+ * @param[in] _element_type Type of structure that'll be inserted into the dlist.
+ * @param[in] _element_entry Field in the _element_type that holds the dlist entry information.
+ */
+#define FR_DLIST_FUNCS(_name, _element_type, _element_entry) \
DIAG_OFF(unused-function) \
- static inline fr_dlist_head_t *fr_ ## _name ## _dlist_head(_list_type *list) \
- { return &list->_member_head; } \
-\
- static inline void fr_ ## _name ## _entry_init(_entry_type *entry) \
- { fr_dlist_entry_init(&entry->_member); } \
+ _Static_assert(IS_FIELD_COMPATIBLE(_element_type, _element_entry, FR_DLIST_ENTRY_TYPE(_name)) == 1, "Bad dlist entry field type");\
+ static inline fr_dlist_head_t *fr_dlist_ ## _name ## _list_head(FR_DLIST_HEAD_TYPE(_name) const *list) \
+ { return UNCONST(fr_dlist_head_t *, &list->head); } \
+ static inline void fr_dlist_ ## _name ## _entry_init(_element_type *entry) \
+ { fr_dlist_entry_init(&entry->_element_entry.entry); } \
\
- static inline void fr_ ## _name ## _init(_list_type *list) \
- { _fr_dlist_init(&list->_member_head, offsetof(_entry_type, _member), NULL); } \
+ static inline void fr_dlist_ ## _name ## _init(FR_DLIST_HEAD_TYPE(_name) *list) \
+ { _fr_dlist_init(&list->head, offsetof(_element_type, _element_entry), NULL); } \
\
- static inline void fr_ ## _name ## _talloc_init(_list_type *list) \
- { _fr_dlist_init(&list->_member_head, offsetof(_entry_type, _member), #_entry_type); } \
+ static inline void fr_dlist_ ## _name ## _talloc_init(FR_DLIST_HEAD_TYPE(_name) *list) \
+ { _fr_dlist_init(&list->head, offsetof(_element_type, _element_entry), #_element_type); } \
\
- static inline void fr_ ## _name ## _clear(_list_type *list) \
- { fr_dlist_clear(&list->_member_head); } \
+ static inline void fr_dlist_ ## _name ## _clear(FR_DLIST_HEAD_TYPE(_name) *list) \
+ { fr_dlist_clear(&list->head); } \
\
- static inline bool fr_ ## _name ## _in_list(_list_type *list, _entry_type *ptr) \
- { return fr_dlist_in_list(&list->_member_head, ptr); } \
+ static inline bool fr_dlist_ ## _name ## _in_list(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *ptr) \
+ { return fr_dlist_in_list(&list->head, ptr); } \
\
- static inline int fr_ ## _name ## _insert_head(_list_type *list, _entry_type *ptr) \
- { return fr_dlist_insert_head(&list->_member_head, ptr); } \
+ static inline int fr_dlist_ ## _name ## _insert_head(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *ptr) \
+ { return fr_dlist_insert_head(&list->head, ptr); } \
\
- static inline int fr_ ## _name ## _insert_tail(_list_type *list, _entry_type *ptr) \
- { return fr_dlist_insert_tail(&list->_member_head, ptr); } \
+ static inline int fr_dlist_ ## _name ## _insert_tail(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *ptr) \
+ { return fr_dlist_insert_tail(&list->head, ptr); } \
\
- static inline int fr_ ## _name ## _insert_after(_list_type *list, _entry_type *pos, _entry_type *ptr) \
- { return fr_dlist_insert_after(&list->_member_head, pos, ptr); } \
+ static inline int fr_dlist_ ## _name ## _insert_after(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *pos, _element_type *ptr) \
+ { return fr_dlist_insert_after(&list->head, pos, ptr); } \
\
- static inline int fr_ ## _name ## _insert_before(_list_type *list, _entry_type *pos, _entry_type *ptr) \
- { return fr_dlist_insert_before(&list->_member_head, pos, ptr); } \
+ static inline int fr_dlist_ ## _name ## _insert_before(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *pos, _element_type *ptr) \
+ { return fr_dlist_insert_before(&list->head, pos, ptr); } \
\
- static inline _entry_type *fr_ ## _name ## _head(_list_type const *list) \
- { return fr_dlist_head(&list->_member_head); } \
+ static inline _element_type *fr_dlist_ ## _name ## _head(FR_DLIST_HEAD_TYPE(_name) const *list) \
+ { return fr_dlist_head(&list->head); } \
\
- static inline bool fr_ ## _name ## _empty(_list_type const *list) \
- { return fr_dlist_empty(&list->_member_head); } \
+ static inline bool fr_dlist_ ## _name ## _empty(FR_DLIST_HEAD_TYPE(_name) const *list) \
+ { return fr_dlist_empty(&list->head); } \
\
- static inline bool fr_ ## _name ## _initialised(_list_type const *list) \
- { return fr_dlist_initialised(&list->_member_head); } \
+ static inline bool fr_dlist_ ## _name ## _initialised(FR_DLIST_HEAD_TYPE(_name) const *list) \
+ { return fr_dlist_initialised(&list->head); } \
\
- static inline _entry_type *fr_ ## _name ## _tail(_list_type const *list) \
- { return fr_dlist_tail(&list->_member_head); } \
+ static inline _element_type *fr_dlist_ ## _name ## _tail(FR_DLIST_HEAD_TYPE(_name) const *list) \
+ { return fr_dlist_tail(&list->head); } \
\
- static inline _entry_type *fr_ ## _name ## _next(_list_type const *list, _entry_type const *ptr) \
- { return fr_dlist_next(&list->_member_head, ptr); } \
+ static inline _element_type *fr_dlist_ ## _name ## _next(FR_DLIST_HEAD_TYPE(_name) const *list, _element_type const *ptr) \
+ { return fr_dlist_next(&list->head, ptr); } \
\
- static inline _entry_type *fr_ ## _name ## _prev(_list_type const *list, _entry_type const *ptr) \
- { return fr_dlist_prev(&list->_member_head, ptr); } \
+ static inline _element_type *fr_dlist_ ## _name ## _prev(FR_DLIST_HEAD_TYPE(_name) const *list, _element_type const *ptr) \
+ { return fr_dlist_prev(&list->head, ptr); } \
\
- static inline _entry_type *fr_ ## _name ## _remove(_list_type *list, _entry_type *ptr) \
- { return fr_dlist_remove(&list->_member_head, ptr); } \
+ static inline _element_type *fr_dlist_ ## _name ## _remove(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *ptr) \
+ { return fr_dlist_remove(&list->head, ptr); } \
\
- static inline _entry_type *fr_ ## _name ## _pop_head(_list_type *list) \
- { return fr_dlist_pop_head(&list->_member_head); } \
+ static inline _element_type *fr_dlist_ ## _name ## _pop_head(FR_DLIST_HEAD_TYPE(_name) *list) \
+ { return fr_dlist_pop_head(&list->head); } \
\
- static inline _entry_type *fr_ ## _name ## _pop_tail(_list_type *list) \
- { return fr_dlist_pop_tail(&list->_member_head); } \
+ static inline _element_type *fr_dlist_ ## _name ## _pop_tail(FR_DLIST_HEAD_TYPE(_name) *list) \
+ { return fr_dlist_pop_tail(&list->head); } \
\
- static inline _entry_type *fr_ ## _name ## _replace(_list_type *list, _entry_type *item, _entry_type *ptr) \
- { return fr_dlist_replace(&list->_member_head, item, ptr); } \
+ static inline _element_type *fr_dlist_ ## _name ## _replace(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *item, _element_type *ptr) \
+ { return fr_dlist_replace(&list->head, item, ptr); } \
\
- static inline int fr_ ## _name ## _move(_list_type *dst, _list_type *src) \
- { return fr_dlist_move(&dst->_member_head, &src->_member_head); } \
+ static inline int fr_dlist_ ## _name ## _move(FR_DLIST_HEAD_TYPE(_name) *dst, FR_DLIST_HEAD_TYPE(_name) *src) \
+ { return fr_dlist_move(&dst->head, &src->head); } \
\
- static inline int fr_ ## _name ## _move_head(_list_type *dst, _list_type *src) \
- { return fr_dlist_move_head(&dst->_member_head, &src->_member_head); } \
+ static inline int fr_dlist_ ## _name ## _move_head(FR_DLIST_HEAD_TYPE(_name) *dst, FR_DLIST_HEAD_TYPE(_name) *src) \
+ { return fr_dlist_move_head(&dst->head, &src->head); } \
\
- static inline void fr_ ## _name ## _talloc_free_head(_list_type *list) \
- { fr_dlist_talloc_free_head(&list->_member_head); } \
+ static inline void fr_dlist_ ## _name ## _talloc_free_head(FR_DLIST_HEAD_TYPE(_name) *list) \
+ { fr_dlist_talloc_free_head(&list->head); } \
\
- static inline void fr_ ## _name ## _talloc_free_tail(_list_type *list) \
- { fr_dlist_talloc_free_tail(&list->_member_head); } \
+ static inline void fr_dlist_ ## _name ## _talloc_free_tail(FR_DLIST_HEAD_TYPE(_name) *list) \
+ { fr_dlist_talloc_free_tail(&list->head); } \
\
- static inline void fr_ ## _name ## _talloc_free_item(_list_type *list, _entry_type *ptr) \
- { fr_dlist_talloc_free_item(&list->_member_head, ptr); } \
+ static inline void fr_dlist_ ## _name ## _talloc_free_item(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *ptr) \
+ { fr_dlist_talloc_free_item(&list->head, ptr); } \
\
- static inline void fr_ ## _name ## _talloc_free(_list_type *list) \
- { fr_dlist_talloc_free(&list->_member_head); } \
+ static inline void fr_dlist_ ## _name ## _talloc_free(FR_DLIST_HEAD_TYPE(_name) *list) \
+ { fr_dlist_talloc_free(&list->head); } \
\
- static inline void fr_ ## _name ## _talloc_reverse_free(_list_type *list) \
- { fr_dlist_talloc_reverse_free(&list->_member_head); } \
+ static inline void fr_dlist_ ## _name ## _talloc_reverse_free(FR_DLIST_HEAD_TYPE(_name) *list) \
+ { fr_dlist_talloc_reverse_free(&list->head); } \
\
- static inline unsigned int fr_ ## _name ## _num_elements(_list_type const *list) \
- { return fr_dlist_num_elements(&list->_member_head); } \
+ static inline unsigned int fr_dlist_ ## _name ## _num_elements(FR_DLIST_HEAD_TYPE(_name) const *list) \
+ { return fr_dlist_num_elements(&list->head); } \
\
- static inline void fr_ ## _name ## _sort(_list_type *list, fr_cmp_t cmp) \
- { fr_dlist_sort(&list->_member_head, cmp); } \
+ static inline void fr_dlist_ ## _name ## _sort(FR_DLIST_HEAD_TYPE(_name) *list, fr_cmp_t cmp) \
+ { fr_dlist_sort(&list->head, cmp); } \
DIAG_ON(unused-function)
#include <freeradius-devel/util/proto.h>
#include <freeradius-devel/util/regex.h>
-FR_DLIST_NEW_TYPE(pair_dlist, fr_pair_list_t, order, fr_pair_t, order_entry)
+FR_DLIST_FUNCS(pair, fr_pair_t, order_entry)
/** Initialise a pair list header
*
* in the list and allows us to iterate over
* all of them.
*/
- fr_pair_dlist_talloc_init(list);
+ fr_dlist_pair_talloc_init(&list->order);
}
/** Free a fr_pair_t
*/
static inline CC_HINT(always_inline) void pair_init_null(fr_pair_t *vp)
{
- fr_pair_dlist_entry_init(vp);
+ fr_dlist_pair_entry_init(vp);
/*
* Legacy cruft
*/
vp->op = T_OP_EQ;
- vp->type = VT_DATA;
}
/** Dynamically allocate a new attribute with no #fr_dict_attr_t assigned
if (!n) return NULL;
n->op = vp->op;
- n->type = vp->type;
/*
* Copy the unknown attribute hierarchy
*/
*/
int fr_pair_steal_append(TALLOC_CTX *list_ctx, fr_pair_list_t *list, fr_pair_t *vp)
{
- if (fr_pair_dlist_in_list(list, vp)) {
+ if (fr_dlist_pair_in_list(&list->order, vp)) {
fr_strerror_printf("Pair %pV is a list member, cannot be moved", vp);
return -1;
}
*/
int fr_pair_steal_prepend(TALLOC_CTX *list_ctx, fr_pair_list_t *list, fr_pair_t *vp)
{
- if (fr_pair_dlist_in_list(list, vp)) {
+ if (fr_dlist_pair_in_list(&list->order, vp)) {
fr_strerror_printf("Pair %pV is a list member, cannot be moved", vp);
return -1;
}
*/
void fr_pair_list_free(fr_pair_list_t *list)
{
- fr_pair_dlist_talloc_free(list);
+ fr_dlist_pair_talloc_free(&list->order);
}
/** Is a valuepair list empty
*/
bool fr_pair_list_empty(fr_pair_list_t const *list)
{
- return fr_pair_dlist_empty(list);
+ return fr_dlist_pair_empty(&list->order);
}
/** Mark malformed or unrecognised attributed as unknown
fr_pair_t *vp = NULL;
unsigned int count = 0;
- if (fr_pair_dlist_empty(list)) return 0;
+ if (fr_dlist_pair_empty(&list->order)) return 0;
- while ((vp = fr_pair_dlist_next(list, vp))) if (da == vp->da) count++;
+ while ((vp = fr_dlist_pair_next(&list->order, vp))) if (da == vp->da) count++;
return count;
}
{
fr_pair_t *vp = UNCONST(fr_pair_t *, prev);
- if (fr_pair_dlist_empty(list)) return NULL;
+ if (fr_dlist_pair_empty(&list->order)) return NULL;
PAIR_LIST_VERIFY(list);
- while ((vp = fr_pair_dlist_next(list, vp))) if (da == vp->da) return vp;
+ while ((vp = fr_dlist_pair_next(&list->order, vp))) if (da == vp->da) return vp;
return NULL;
}
{
fr_pair_t *vp = NULL;
- if (fr_pair_dlist_empty(list)) return NULL;
+ if (fr_dlist_pair_empty(&list->order)) return NULL;
PAIR_LIST_VERIFY(list);
fr_dict_attr_t const *da;
/* List head may be NULL if it contains no VPs */
- if (fr_pair_dlist_empty(list)) return NULL;
+ if (fr_dlist_pair_empty(&list->order)) return NULL;
PAIR_LIST_VERIFY(list);
fr_dict_attr_t const *da;
/* List head may be NULL if it contains no VPs */
- if (fr_pair_dlist_empty(list)) return NULL;
+ if (fr_dlist_pair_empty(&list->order)) return NULL;
PAIR_LIST_VERIFY(list);
fr_dcursor_iter_t iter, void const *uctx,
bool is_const)
{
- return _fr_dcursor_init(cursor, &list->order,
+ return _fr_dcursor_init(cursor, fr_dlist_pair_list_head(&list->order),
iter, uctx,
_pair_list_dcursor_insert, _pair_list_dcursor_remove, list, is_const);
}
fr_pair_t *_fr_pair_dcursor_init(fr_dcursor_t *cursor, fr_pair_list_t const *list,
bool is_const)
{
- return _fr_dcursor_init(cursor, &list->order,
+ return _fr_dcursor_init(cursor, fr_dlist_pair_list_head(&list->order),
NULL, NULL,
_pair_list_dcursor_insert, _pair_list_dcursor_remove, list, is_const);
}
fr_pair_list_t const *list, fr_dict_attr_t const *da,
bool is_const)
{
- return _fr_dcursor_init(cursor, &list->order,
+ return _fr_dcursor_init(cursor, fr_dlist_pair_list_head(&list->order),
fr_pair_iter_next_by_da, da,
_pair_list_dcursor_insert, _pair_list_dcursor_remove, list, is_const);
}
fr_pair_list_t const *list, fr_dict_attr_t const *da,
bool is_const)
{
- return _fr_dcursor_init(cursor, &list->order,
+ return _fr_dcursor_init(cursor, fr_dlist_pair_list_head(&list->order),
fr_pair_iter_next_by_ancestor, da,
_pair_list_dcursor_insert, _pair_list_dcursor_remove, list, is_const);
}
*/
fr_pair_t *fr_pair_list_head(fr_pair_list_t const *list)
{
- return fr_pair_dlist_head(list);
+ return fr_dlist_pair_head(&list->order);
}
/** Get the next item in a valuepair list after a specific entry
*/
fr_pair_t *fr_pair_list_next(fr_pair_list_t const *list, fr_pair_t const *item)
{
- return fr_pair_dlist_next(list, item);
+ return fr_dlist_pair_next(&list->order, item);
}
/** Get the previous item in a valuepair list before a specific entry
*/
fr_pair_t *fr_pair_list_prev(fr_pair_list_t const *list, fr_pair_t const *item)
{
- return fr_pair_dlist_prev(list, item);
+ return fr_dlist_pair_prev(&list->order, item);
}
/** Get the tail of a valuepair list
*/
fr_pair_t *fr_pair_list_tail(fr_pair_list_t const *list)
{
- return fr_pair_dlist_tail(list);
+ return fr_dlist_pair_tail(&list->order);
}
/** Add a VP to the start of the list.
{
PAIR_VERIFY(to_add);
- if (fr_pair_dlist_in_list(list, to_add)) {
+ if (fr_dlist_pair_in_list(&list->order, to_add)) {
fr_strerror_printf("Pair %pV already inserted into list", to_add);
return -1;
}
- fr_pair_dlist_insert_head(list, to_add);
+ fr_dlist_pair_insert_head(&list->order, to_add);
return 0;
}
{
PAIR_VERIFY(to_add);
- if (fr_pair_dlist_in_list(list, to_add)) {
+ if (fr_dlist_pair_in_list(&list->order, to_add)) {
fr_strerror_printf("Pair %pV already inserted into list", to_add);
return -1;
}
- fr_pair_dlist_insert_tail(list, to_add);
+ fr_dlist_pair_insert_tail(&list->order, to_add);
return 0;
}
{
PAIR_VERIFY(to_add);
- if (fr_pair_dlist_in_list(list, to_add)) {
+ if (fr_dlist_pair_in_list(&list->order, to_add)) {
fr_strerror_printf("Pair %pV already inserted into list", to_add);
return -1;
}
- if (pos && !fr_pair_dlist_in_list(list, pos)) {
+ if (pos && !fr_dlist_pair_in_list(&list->order, pos)) {
fr_strerror_printf("Pair %pV not in list", pos);
return -1;
}
- fr_pair_dlist_insert_after(list, pos, to_add);
+ fr_dlist_pair_insert_after(&list->order, pos, to_add);
return 0;
}
{
PAIR_VERIFY(to_add);
- if (fr_pair_dlist_in_list(list, to_add)) {
+ if (fr_dlist_pair_in_list(&list->order, to_add)) {
fr_strerror_printf("Pair %pV already inserted into list", to_add);
return -1;
}
- if (pos && !fr_pair_dlist_in_list(list, pos)) {
+ if (pos && !fr_dlist_pair_in_list(&list->order, pos)) {
fr_strerror_printf("Pair %pV not in list", pos);
return -1;
}
- fr_pair_dlist_insert_before(list, pos, to_add);
+ fr_dlist_pair_insert_before(&list->order, pos, to_add);
return 0;
}
{
fr_pair_t *prev;
- prev = fr_pair_dlist_prev(list, vp);
- fr_pair_dlist_remove(list, vp);
+ prev = fr_dlist_pair_prev(&list->order, vp);
+ fr_dlist_pair_remove(&list->order, vp);
return prev;
}
{
fr_pair_t *prev;
- prev = fr_pair_dlist_prev(list, vp);
- fr_pair_dlist_remove(list, vp);
+ prev = fr_dlist_pair_prev(&list->order, vp);
+ fr_dlist_pair_remove(&list->order, vp);
talloc_free(vp);
return prev;
*/
void fr_pair_list_sort(fr_pair_list_t *list, fr_cmp_t cmp)
{
- fr_pair_dlist_sort(list, cmp);
+ fr_dlist_pair_sort(&list->order, cmp);
}
/** Write an error to the library errorbuff detailing the mismatch
{
fr_pair_t *check, *match;
- if (fr_pair_dlist_empty(filter) && fr_pair_dlist_empty(list)) {
- return true;
- }
+ if (fr_dlist_pair_empty(&filter->order) && fr_dlist_pair_empty(&list->order)) return true;
/*
* This allows us to verify the sets of validate and reply are equal
{
fr_pair_t *check, *last_check = NULL, *match = NULL;
- if (fr_pair_dlist_empty(filter) && fr_pair_dlist_empty(list)) {
- return true;
- }
+ if (fr_dlist_pair_empty(&filter->order) && fr_dlist_pair_empty(&list->order)) return true;
/*
* This allows us to verify the sets of validate and reply are equal
break;
case FR_TYPE_STRUCTURAL:
- if (!fr_pair_dlist_empty(&vp->vp_group)) return;
+ if (!fr_dlist_pair_empty(&vp->vp_group.order)) return;
- while ((child = fr_pair_dlist_pop_tail(&vp->vp_group))) {
+ while ((child = fr_dlist_pair_pop_tail(&vp->vp_group.order))) {
fr_pair_value_clear(child);
talloc_free(child);
}
*/
for (; slow; slow = fr_pair_list_next(list, slow)) {
PAIR_VERIFY(slow);
-
parent = talloc_parent(slow);
if (expected && (parent != expected)) goto bad_parent;
}
*/
void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
{
- fr_pair_dlist_move(dst, src);
+ fr_dlist_pair_move(&dst->order, &src->order);
}
/** Move a list of fr_pair_t from a temporary list to the head of a destination list
*/
void fr_pair_list_prepend(fr_pair_list_t *dst, fr_pair_list_t *src)
{
- fr_pair_dlist_move_head(dst, src);
+ fr_dlist_pair_move_head(&dst->order, &src->order);
}
/** Evaluation function for matching if vp matches a given da
*/
size_t fr_pair_list_len(fr_pair_list_t const *list)
{
- return fr_pair_dlist_num_elements(list);
+ return fr_dlist_pair_num_elements(&list->order);
}
/** Parse a list of VPs from a value box.
# define _CONST
#endif
-/** The type of value a fr_pair_t contains
- *
- * This is used to add structure to nested fr_pair_ts and specifies what type of node it is (set, list, data).
- *
- * xlat is another type of data node which must first be expanded before use.
- */
-typedef enum value_type {
- VT_INVALID = 0, //!< fr_pair_t is broken
- VT_SET, //!< fr_pair_t is #fr_value_box_list
- VT_DATA, //!< fr_pair_t has a single value.
-} value_type_t;
-
typedef struct value_pair_s fr_pair_t;
+FR_DLIST_TYPES(pair)
+
typedef struct {
- fr_dlist_head_t order; //!< Maintains the relative order of pairs in a list.
+ FR_DLIST_HEAD_TYPE(pair) order; //!< Maintains the relative order of pairs in a list.
} fr_pair_list_t;
/** Stores an attribute, a value and various bits of other data
///< Note: This should not be modified outside
///< of pair.c except via #fr_pair_reinit_from_da.
- fr_dlist_t _CONST order_entry; //!< Entry to maintain relative order within a list
+ FR_DLIST_ENTRY_TYPE(pair) _CONST order_entry; //!< Entry to maintain relative order within a list
///< of pairs. This ensures pairs within the list
///< are encoded in the same order as they were
///< received or inserted.
fr_token_t op; //!< Operator to use when moving or inserting
//!< valuepair into a list.
char const *xlat; //!< Source string for xlat expansion.
-
- value_type_t type; //!< Type of pointer in value union.
};
};
printf("printf pop rate %" PRIu64 "\n", rate);
/* shared runners are terrible for performance tests */
- if (!getenv("NO_PERFORMANCE_TESTS")) TEST_CHECK(rate > 400000);
+ if (!getenv("NO_PERFORMANCE_TESTS")) TEST_CHECK(rate > 200000);
}
/*
* We apply the rules in the reply items.
*/
- if (!fr_map_list_empty(&entry->check)) {
+ if (!fr_dlist_map_empty(&entry->check)) {
WARN("%s[%d] Check list is not empty for entry \"%s\".\n",
filename, entry->lineno, entry->name);
}
map = NULL;
- while ((map = fr_map_list_next(&entry->reply, map))) {
+ while ((map = fr_dlist_map_next(&entry->reply, map))) {
fr_dict_attr_t const *da;
if (!tmpl_is_attr(map->lhs)) {
fr_pair_list_init(&check_list);
- while ((map = fr_map_list_next(&pl->reply, map))) {
+ while ((map = fr_dlist_map_next(&pl->reply, map))) {
if (map_to_vp(packet, &tmp_list, request, map, NULL) < 0) {
RPWARN("Failed parsing map %s for check item, skipping it", map->lhs->name);
continue;
#endif
rlm_cache_entry_t *c;
- fr_map_list_init(&head);
+ fr_dlist_map_init(&head);
for (s_ret = fr_redis_cluster_state_init(&state, &conn, driver->cluster, request, key, key_len, false);
s_ret == REDIS_RCODE_TRY_AGAIN; /* Continue */
s_ret = fr_redis_cluster_state_next(&state, &conn, driver->cluster, request, status, &reply)) {
#else
c = talloc_zero(NULL, rlm_cache_entry_t);
#endif
- fr_map_list_init(&c->maps);
+ fr_dlist_map_init(&c->maps);
/*
* Convert the key/value pairs back into maps
*/
/*
* Pull out the cache created date
*/
- if (tmpl_da(fr_map_list_head(&head)->lhs) == attr_cache_created) {
+ if (tmpl_da(fr_dlist_map_head(&head)->lhs) == attr_cache_created) {
map_t *map;
- c->created = tmpl_value(fr_map_list_head(&head)->rhs)->vb_date;
+ c->created = tmpl_value(fr_dlist_map_head(&head)->rhs)->vb_date;
- map = fr_map_list_pop_head(&head);
+ map = fr_dlist_map_pop_head(&head);
talloc_free(map);
}
/*
* Pull out the cache expires date
*/
- if (tmpl_da(fr_map_list_head(&head)->lhs) == attr_cache_expires) {
+ if (tmpl_da(fr_dlist_map_head(&head)->lhs) == attr_cache_expires) {
map_t *map;
- c->expires = tmpl_value(fr_map_list_head(&head)->rhs)->vb_date;
+ c->expires = tmpl_value(fr_dlist_map_head(&head)->rhs)->vb_date;
- map = fr_map_list_pop_head(&head);
+ map = fr_dlist_map_pop_head(&head);
talloc_free(map);
}
c->key = talloc_memdup(c, key, key_len);
c->key_len = key_len;
- fr_map_list_move(&c->maps, &head);
+ fr_dlist_map_move(&c->maps, &head);
*out = c;
return CACHE_OK;
fr_value_box_init(&expires_value.data.literal, FR_TYPE_DATE, NULL, true);
tmpl_value(&expires_value)->vb_date = c->expires;
- cnt = fr_map_list_num_elements(&c->maps) + 2;
+ cnt = fr_dlist_map_num_elements(&c->maps) + 2;
/*
* The majority of serialized entries should be under 1k.
}
argv_p += 3;
argv_len_p += 3;
- while ((map = fr_map_list_next(&c->maps, map))) {
+ while ((map = fr_dlist_map_next(&c->maps, map))) {
if (fr_redis_tuple_from_map(pool, argv_p, argv_len_p, map) < 0) {
REDEBUG("Failed encoding map as Redis K/V pair");
talloc_free(pool);
RDEBUG2("Merging cache entry into request");
RINDENT();
- while ((map = fr_map_list_next(&c->maps, map))) {
+ while ((map = fr_dlist_map_next(&c->maps, map))) {
/*
* The only reason that the application of a map entry
* can fail, is if the destination list or request
if (!c) {
RETURN_MODULE_FAIL;
}
- fr_map_list_init(&c->maps);
+ fr_dlist_map_init(&c->maps);
c->key = talloc_memdup(c, key, key_len);
c->key_len = key_len;
* gathering fr_pair_ts to cache.
*/
pool = talloc_pool(NULL, 2048);
- while ((map = fr_map_list_next(&inst->maps, map))) {
+ while ((map = fr_dlist_map_next(&inst->maps, map))) {
fr_pair_list_t to_cache;
fr_pair_list_init(&to_cache);
MEM(c_map = talloc_zero(c, map_t));
c_map->op = map->op;
- fr_map_list_init(&c_map->child);
+ fr_dlist_map_init(&c_map->child);
/*
* Now we turn the fr_pair_ts into maps.
fr_assert(0);
}
MAP_VERIFY(c_map);
- fr_map_list_insert_tail(&c->maps, c_map);
+ fr_dlist_map_insert_tail(&c->maps, c_map);
}
talloc_free_children(pool); /* reset pool state */
}
return XLAT_ACTION_FAIL;
}
- while ((map = fr_map_list_next(&c->maps, map))) {
+ while ((map = fr_dlist_map_next(&c->maps, map))) {
if ((tmpl_da(map->lhs) != tmpl_da(target)) ||
(tmpl_list(map->lhs) != tmpl_list(target))) continue;
.allow_foreign = true /* Because we don't know where we'll be called */
};
- fr_map_list_init(&inst->maps);
+ fr_dlist_map_init(&inst->maps);
if (map_afrom_cs(inst, &inst->maps, update,
&parse_rules, &parse_rules, cache_verify, NULL, MAX_ATTRMAP) < 0) {
return -1;
}
}
- if (fr_map_list_empty(&inst->maps)) {
+ if (fr_dlist_map_empty(&inst->maps)) {
cf_log_err(conf, "Cache config must contain an update section, and "
"that section must not be empty");
return -1;
/*
* It's valid to have an empty cache entry (save allocing the pairs pool)
*/
- if (fr_map_list_empty(&c->maps)) goto finish;
+ if (fr_dlist_map_empty(&c->maps)) goto finish;
value_pool = talloc_pool(ctx, 512);
if (!value_pool) {
return -1;
}
- while ((map = fr_map_list_next(&c->maps, map))) {
+ while ((map = fr_dlist_map_next(&c->maps, map))) {
char *value;
ssize_t slen;
MAP_VERIFY(map);
/* It's not a special attribute, add it to the map list */
- fr_map_list_insert_tail(&c->maps, map);
+ fr_dlist_map_insert_tail(&c->maps, map);
next:
p = q + 1;
uctx.cs = client->cs;
RINDENT();
- while ((map = fr_map_list_next(maps, map))) {
+ while ((map = fr_dlist_map_next(maps, map))) {
char *field = NULL;
if (tmpl_aexpand(request, &field, request, map->rhs, NULL, NULL) < 0) {
vp_list_mod_t *vlm;
fr_dlist_head_t vlm_head;
- fr_map_list_init(&map_head);
+ fr_dlist_map_init(&map_head);
fr_dcursor_init(&maps, &map_head);
/*
return -1;
}
- while ((map = fr_map_list_next(maps, map))) {
+ while ((map = fr_dlist_map_next(maps, map))) {
/*
* This function doesn't change the map, so it's OK.
*/
};
char buffer[8192];
- fr_map_list_init(&inst->map);
+ fr_dlist_map_init(&inst->map);
/*
* "update" without "key" is invalid, as we can't run the
* module.
redo:
RINDENT();
- while ((map = fr_map_list_next(maps, map))) {
+ while ((map = fr_dlist_map_next(maps, map))) {
int field;
char *field_name;
ssize_t slen;
fr_value_box_t *key;
- if (fr_map_list_empty(&inst->map) || !inst->key) RETURN_MODULE_NOOP;
+ if (fr_dlist_map_empty(&inst->map) || !inst->key) RETURN_MODULE_NOOP;
/*
* Expand the key to whatever it is. For attributes,
* and probably ':=' for server
* configuration items.
*/
- while ((map = fr_map_list_next(&entry->check, map))) {
+ while ((map = fr_dlist_map_next(&entry->check, map))) {
if (!tmpl_is_attr(map->lhs)) {
ERROR("%s[%d] Left side of check item %s is not an attribute",
entry->filename, entry->lineno, map->lhs->name);
* worth doing.
*/
map = NULL;
- while ((map = fr_map_list_next(&entry->reply, map))) {
+ while ((map = fr_dlist_map_next(&entry->reply, map))) {
if (!tmpl_is_attr(map->lhs)) {
ERROR("%s[%d] Left side of reply item %s is not an attribute",
entry->filename, entry->lineno, map->lhs->name);
/*
* Realize the map to a list of VPs
*/
- while ((map = fr_map_list_next(&pl->check, map))) {
+ while ((map = fr_dlist_map_next(&pl->check, map))) {
fr_pair_list_t tmp_list;
/*
fr_pair_list_free(&list);
/* ctx may be reply */
- if (!fr_map_list_empty(&pl->reply)) {
+ if (!fr_dlist_map_empty(&pl->reply)) {
map = NULL;
- while ((map = fr_map_list_next(&pl->reply, map))) {
+ while ((map = fr_dlist_map_next(&pl->reply, map))) {
fr_pair_list_t tmp_list;
fr_pair_list_init(&tmp_list);
if (map->op == T_OP_CMP_FALSE) continue;
return -1;
}
- while ((map = fr_map_list_next(maps, map))) {
+ while ((map = fr_dlist_map_next(maps, map))) {
CONF_PAIR *cp = cf_item_to_pair(map->ci);
char const *p;
* list member was pre-allocated and passed to the
* instantiation callback.
*/
- if (fr_map_list_next(maps, map)) {
+ if (fr_dlist_map_next(maps, map)) {
*tail = cache = talloc_zero(cache, rlm_json_jpath_cache_t);
tail = &cache->next;
}
goto finish;
}
- while ((map = fr_map_list_next(maps, map))) {
+ while ((map = fr_dlist_map_next(maps, map))) {
switch (map->rhs->type) {
/*
* Cached types
}
RINDENT();
- for (map = fr_map_list_head(maps), i = 0;
+ for (map = fr_dlist_map_head(maps), i = 0;
map != NULL;
- map = fr_map_list_next(maps, map), i++) {
+ map = fr_dlist_map_next(maps, map), i++) {
int ret;
fr_ldap_result_t attr;
}
}
- if (!fr_map_list_empty(&inst->user_map) || inst->valuepair_attr) {
+ if (!fr_dlist_map_empty(&inst->user_map) || inst->valuepair_attr) {
RDEBUG2("Processing user attributes");
RINDENT();
if (fr_ldap_map_do(request, handle, inst->valuepair_attr,
rlm_ldap_t *inst = talloc_get_type_abort(mctx->inst->data, rlm_ldap_t);
CONF_SECTION *conf = mctx->inst->conf;
- fr_map_list_init(&inst->user_map);
+ fr_dlist_map_init(&inst->user_map);
options = cf_section_find(conf, "options", NULL);
if (!options || !cf_pair_find(options, "chase_referrals")) {
fr_map_list_t *head = (fr_map_list_t *)out;
fr_assert(cf_item_is_section(ci));
- fr_map_list_init(head);
+ fr_dlist_map_init(head);
cs = cf_item_to_section(ci);
name2 = cf_section_name2(cs);
rcode = map_afrom_cs(ctx, head, cs, &parse_rules, &parse_rules, unlang_fixup_update, NULL, 128);
if (rcode < 0) return -1; /* message already printed */
- if (fr_map_list_empty(head)) {
+ if (fr_dlist_map_empty(head)) {
cf_log_err(cs, "'update' sections cannot be empty");
return -1;
}
* Create the VPs, and ignore any errors
* creating them.
*/
- while ((map = fr_map_list_next(&inst->parent->status_check_map, map))) {
+ while ((map = fr_dlist_map_next(&inst->parent->status_check_map, map))) {
/*
* Skip things which aren't attributes.
*/
* Initialize the sbuff for writing the config elements as header attributes
*/
fr_sbuff_init_talloc(uctx, &conf_buffer, &conf_ctx, 256, SIZE_MAX);
- conf_map = fr_map_list_head(&inst->header_maps);
+ conf_map = fr_dlist_map_head(&inst->header_maps);
/*
* Load in all of the header elements supplied in the config
next:
/* Check if there are more values to parse */
- if (!fr_map_list_next(&inst->header_maps, conf_map)) break;
+ if (!fr_dlist_map_next(&inst->header_maps, conf_map)) break;
/* reinitialize the buffer and move to the next value */
fr_sbuff_init_talloc(uctx, &conf_buffer, &conf_ctx, 256, SIZE_MAX);
- conf_map = fr_map_list_next(&inst->header_maps, conf_map);
+ conf_map = fr_dlist_map_next(&inst->header_maps, conf_map);
}
/* Add the FROM: line */
CONF_SECTION *conf = mctx->inst->conf;
CONF_SECTION *header;
- fr_map_list_init(&inst->header_maps);
+ fr_dlist_map_init(&inst->header_maps);
header = cf_section_find(conf, "header", NULL);
if (!header) return 0;
* faster than building a radix tree each time the
* map set is evaluated (map->rhs can be dynamic).
*/
- for (map = fr_map_list_head(maps), i = 0;
+ for (map = fr_dlist_map_head(maps), i = 0;
map && (i < MAX_SQL_FIELD_INDEX);
- map = fr_map_list_next(maps, map), i++) {
+ map = fr_dlist_map_next(maps, map), i++) {
/*
* Expand the RHS to get the name of the SQL field
*/
*/
while (((ret = rlm_sql_fetch_row(&row, inst, request, &handle)) == RLM_SQL_OK)) {
rows++;
- for (map = fr_map_list_head(maps), j = 0;
+ for (map = fr_dlist_map_head(maps), j = 0;
map && (j < MAX_SQL_FIELD_INDEX);
- map = fr_map_list_next(maps, map), j++) {
+ map = fr_dlist_map_next(maps, map), j++) {
if (field_index[j] < 0) continue; /* We didn't find the map RHS in the field set */
if (map_to_request(request, map, _sql_map_proc_get_value, row[field_index[j]]) < 0) goto error;
}