for (i = 0; i < self->count; i++) {
if (!self->values[i]->bv_len) continue;
- MEM(vp = fr_pair_afrom_da(ctx, tmpl_da(map->lhs)));
+ MEM(vp = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs)));
if (fr_pair_value_from_str(vp, self->values[i]->bv_val,
self->values[i]->bv_len, NULL, true) < 0) {
RPWDEBUG("Failed parsing value \"%pV\" for attribute %s",
fr_box_strvalue_len(self->values[i]->bv_val, self->values[i]->bv_len),
- tmpl_da(map->lhs)->name);
+ tmpl_attr_tail_da(map->lhs)->name);
talloc_free(vp); /* also frees escaped */
continue;
break;
case TMPL_TYPE_ATTR_UNRESOLVED:
- cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_unresolved(map->lhs));
+ cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_tail_unresolved(map->lhs));
return -1;
default:
break;
case TMPL_TYPE_ATTR_UNRESOLVED:
- cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_unresolved(map->rhs));
+ cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_tail_unresolved(map->rhs));
return -1;
default:
/* Logs own errors */
if (fr_redis_reply_to_value_box(map, &vpt, value,
- tmpl_da(map->lhs)->type, tmpl_da(map->lhs), false, false) < 0) {
+ tmpl_attr_tail_da(map->lhs)->type, tmpl_attr_tail_da(map->lhs), false, false) < 0) {
RPEDEBUG("Failed converting Redis data");
goto error;
}
* All attributes should have been defined by this point.
*/
case TMPL_TYPE_ATTR_UNRESOLVED:
- cf_log_err(cp, "Unknown attribute '%s'", tmpl_attr_unresolved(vpt));
+ cf_log_err(cp, "Unknown attribute '%s'", tmpl_attr_tail_unresolved(vpt));
return -1;
case TMPL_TYPE_UNRESOLVED:
case TMPL_TYPE_ATTR:
/*
* fast path? If there's only one attribute, AND
- * tmpl_num is a simple number, then just find
+ * tmpl_attr_tail_num is a simple number, then just find
* that attribute. This fast path should ideally
* avoid all of the cost of setting up the
* cursors?
cast_type = tmpl_rules_cast(other);
} else if (tmpl_is_attr(other)) {
- da = tmpl_da(other);
+ da = tmpl_attr_tail_da(other);
cast_type = da->type;
} else if (tmpl_is_data(other)) {
fr_value_box_t *rhs, rhs_cast;
fr_dict_attr_t const *da = NULL;
- if (tmpl_is_attr(map->lhs) && fr_type_is_null(tmpl_rules_cast(map->lhs))) da = tmpl_da(map->lhs);
+ if (tmpl_is_attr(map->lhs) && fr_type_is_null(tmpl_rules_cast(map->lhs))) da = tmpl_attr_tail_da(map->lhs);
fr_assert(lhs != NULL);
rhs = NULL; /* shut up clang scan */
break;
}
- rcode = paircmp_virtual(request, tmpl_da(map->lhs), map->op, rhs);
+ rcode = paircmp_virtual(request, tmpl_attr_tail_da(map->lhs), map->op, rhs);
rcode = (rcode == 0) ? 1 : 0;
if (rhs == &rhs_cast) fr_value_box_clear(&rhs_cast);
if (rcode != 0) break;
* Do JUST the virtual attribute comparison.
* Skip all of the rest of the complexity of paircmp().
*/
- rcode = paircmp_virtual(request, tmpl_da(map->lhs), c->data.map->op, rhs);
+ rcode = paircmp_virtual(request, tmpl_attr_tail_da(map->lhs), c->data.map->op, rhs);
rcode = (rcode == 0) ? 1 : 0;
goto done;
}
* Framed-Protocol, which is an integer data type.
*/
if (tmpl_is_attr(other)) {
- da = tmpl_da(other);
+ da = tmpl_attr_tail_da(other);
} else {
da = NULL;
}
/*
* Choose the attribute type which was parsed.
*/
- lhs_type = tmpl_da(c->data.map->lhs)->type;
+ lhs_type = tmpl_attr_tail_da(c->data.map->lhs)->type;
} else if (tmpl_is_exec(c->data.map->lhs)) {
lhs_type = FR_TYPE_STRING;
if (fr_type_is_numeric(lhs_type) && tmpl_is_attr(c->data.map->lhs)) rhs_type = lhs_type;
} else if (tmpl_is_attr(c->data.map->rhs)) {
- rhs_type = tmpl_da(c->data.map->rhs)->type;
+ rhs_type = tmpl_attr_tail_da(c->data.map->rhs)->type;
} else if (tmpl_is_exec(c->data.map->rhs)) {
rhs_type = FR_TYPE_STRING;
if (!tmpl_is_attr(vpt)) return 0;
- switch (tmpl_da(vpt)->type) {
+ switch (tmpl_attr_tail_da(vpt)->type) {
case FR_TYPE_LEAF:
break;
* Sanity check for nested types
*/
if (tmpl_is_attr(vpt) && (tmpl_attr_unknown_add(vpt) < 0)) {
- fr_strerror_printf("Failed defining attribute %s", tmpl_da(vpt)->name);
+ fr_strerror_printf("Failed defining attribute %s", tmpl_attr_tail_da(vpt)->name);
fr_sbuff_set(&our_in, &m);
goto error;
}
* be done in an xlat.
*/
if (tmpl_is_attr(map->rhs) &&
- (tmpl_num(map->rhs) == NUM_COUNT)) {
+ (tmpl_attr_tail_num(map->rhs) == NUM_COUNT)) {
cf_log_err(cp, "Cannot assign from a count");
goto error;
}
* If we know that the assignment is forbidden, then fail early.
*/
if (tmpl_is_attr(map->lhs) && tmpl_is_data(map->rhs)) {
- da = tmpl_da(map->lhs);
+ da = tmpl_attr_tail_da(map->lhs);
if (tmpl_cast_in_place(map->rhs, da->type, da) < 0) {
cf_log_err(cp, "Invalid assignment - %s", fr_strerror());
*/
if (is_child) {
fr_assert(tmpl_is_attr(parent->lhs));
- our_lhs_rules.attr.parent = tmpl_da(parent->lhs);
+ our_lhs_rules.attr.parent = tmpl_attr_tail_da(parent->lhs);
slen = tmpl_afrom_attr_substr(map, NULL, &map->lhs, &our_in,
&map_parse_rules_bareword_quoted, &our_lhs_rules);
* only be an attribute, etc. Not trivial, so we'll just
* skip all that for now.
*/
- if (tmpl_is_attr(map->lhs)) switch (tmpl_da(map->lhs)->type) {
+ if (tmpl_is_attr(map->lhs)) switch (tmpl_attr_tail_da(map->lhs)->type) {
case FR_TYPE_STRUCTURAL:
if ((map->op == T_OP_REG_EQ) || (map->op == T_OP_REG_NE)) {
fr_sbuff_set(&our_in, &m_op);
* about it.
*/
if ((map->op != T_OP_CMP_TRUE) && (map->op != T_OP_CMP_FALSE)) {
- fr_dict_attr_t const *da = tmpl_da(map->lhs);
+ fr_dict_attr_t const *da = tmpl_attr_tail_da(map->lhs);
if (tmpl_cast_in_place(map->rhs, da->type, da) < 0) {
fr_sbuff_set(&our_in, &m_rhs); /* Marker points to RHS */
goto error; /* re-do "goto marker" stuff to print out spaces ? */
}
- if (tmpl_da(map->lhs)->flags.is_unknown) {
+ if (tmpl_attr_tail_da(map->lhs)->flags.is_unknown) {
cf_log_err(ci, "Unknown attribute '%s'", map->lhs->name);
talloc_free(map);
goto error; /* re-do "goto marker" stuff to print out spaces ? */
* inner section.
*/
our_lhs_rules.attr.prefix = TMPL_ATTR_REF_PREFIX_NO;
- our_lhs_rules.attr.parent = tmpl_da(map->lhs);
+ our_lhs_rules.attr.parent = tmpl_attr_tail_da(map->lhs);
/*
* Groups MAY change dictionaries. If so, then swap the dictionary and the parent.
{
fr_pair_t *vp;
- MEM(vp = fr_pair_afrom_da(ctx, tmpl_da(map->lhs)));
+ MEM(vp = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs)));
vp->op = map->op;
if (fr_pair_value_from_str(vp, answer, strlen(answer), &fr_value_unescape_single, false) < 0) {
RPEDEBUG("Failed parsing exec output");
* Hoist this early, too.
*/
if (map->op == T_OP_CMP_TRUE) {
- MEM(n = fr_pair_afrom_da(ctx, tmpl_da(map->lhs)));
+ MEM(n = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs)));
n->op = map->op;
fr_pair_append(out, n);
return 0;
if (!tmpl_is_attr(map->lhs)) return -1;
- switch (tmpl_da(map->lhs)->type) {
+ switch (tmpl_attr_tail_da(map->lhs)->type) {
case FR_TYPE_STRUCTURAL:
break;
* recurse to generate the children into
* vp->vp_group
*/
- MEM(n = fr_pair_afrom_da(ctx, tmpl_da(map->lhs)));
+ MEM(n = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs)));
n->op = map->op;
for (child = map_list_next(&map->child, NULL);
switch (map->rhs->type) {
case TMPL_TYPE_XLAT:
fr_assert(tmpl_is_attr(map->lhs));
- fr_assert(tmpl_da(map->lhs)); /* We need to know which attribute to create */
+ fr_assert(tmpl_attr_tail_da(map->lhs)); /* We need to know which attribute to create */
fr_assert(tmpl_xlat(map->rhs) != NULL);
- MEM(n = fr_pair_afrom_da(ctx, tmpl_da(map->lhs)));
+ MEM(n = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs)));
/*
* We do the debug printing because xlat_aeval_compiled
case TMPL_TYPE_UNRESOLVED:
fr_assert(tmpl_is_attr(map->lhs));
- fr_assert(tmpl_da(map->lhs)); /* We need to know which attribute to create */
+ fr_assert(tmpl_attr_tail_da(map->lhs)); /* We need to know which attribute to create */
- MEM(n = fr_pair_afrom_da(ctx, tmpl_da(map->lhs)));
+ MEM(n = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs)));
if (fr_pair_value_from_str(n, map->rhs->name, strlen(map->rhs->name), NULL, false) < 0) {
rcode = 0;
fr_pair_t *vp;
fr_dcursor_t from;
- fr_assert((tmpl_is_attr(map->lhs) && tmpl_da(map->lhs)) ||
- (tmpl_is_list(map->lhs) && !tmpl_da(map->lhs)));
+ fr_assert((tmpl_is_attr(map->lhs) && tmpl_attr_tail_da(map->lhs)) ||
+ (tmpl_is_list(map->lhs) && !tmpl_attr_tail_da(map->lhs)));
/*
* @todo should log error, and return -1 for v3.1 (causes update to fail)
* to match dst.
*/
if (tmpl_is_attr(map->lhs) &&
- (tmpl_da(map->rhs)->type != tmpl_da(map->lhs)->type)) {
+ (tmpl_attr_tail_da(map->rhs)->type != tmpl_attr_tail_da(map->lhs)->type)) {
for (; vp; vp = fr_dcursor_current(&from)) {
- MEM(n = fr_pair_afrom_da(ctx, tmpl_da(map->lhs)));
+ MEM(n = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs)));
if (fr_value_box_cast(n, &n->data,
- tmpl_da(map->lhs)->type, tmpl_da(map->lhs), &vp->data) < 0) {
+ tmpl_attr_tail_da(map->lhs)->type, tmpl_attr_tail_da(map->lhs), &vp->data) < 0) {
RPEDEBUG("Attribute conversion failed");
fr_pair_list_free(&found);
talloc_free(n);
* and operators
*/
for (; vp; vp = fr_dcursor_next(&from)) {
- fr_pair_reinit_from_da(&found, vp, tmpl_da(map->lhs));
+ fr_pair_reinit_from_da(&found, vp, tmpl_attr_tail_da(map->lhs));
vp->op = map->op;
}
fr_pair_list_append(out, &found);
break;
case TMPL_TYPE_DATA:
- fr_assert(tmpl_da(map->lhs));
+ fr_assert(tmpl_attr_tail_da(map->lhs));
fr_assert(tmpl_is_attr(map->lhs));
- MEM(n = fr_pair_afrom_da(ctx, tmpl_da(map->lhs)));
+ MEM(n = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs)));
- if (tmpl_da(map->lhs)->type == tmpl_value_type(map->rhs)) {
+ if (tmpl_attr_tail_da(map->lhs)->type == tmpl_value_type(map->rhs)) {
if (fr_value_box_copy(n, &n->data, tmpl_value(map->rhs)) < 0) {
rcode = -1;
goto error;
/*
* Wildcard: delete all of the matching ones
*/
- if (tmpl_num(map->lhs) == NUM_UNSPEC) {
- fr_pair_delete_by_child_num(list, tmpl_da(map->lhs)->parent, tmpl_da(map->lhs)->attr);
+ if (tmpl_attr_tail_num(map->lhs) == NUM_UNSPEC) {
+ fr_pair_delete_by_child_num(list, tmpl_attr_tail_da(map->lhs)->parent, tmpl_attr_tail_da(map->lhs)->attr);
dst = NULL;
/*
* We've found the Nth one. Delete it, and only it.
* src_list attributes.
*
* This operation has two modes:
- * - If tmpl_num(map->lhs) > 0, we check each of the src_list attributes against
+ * - If tmpl_attr_tail_num(map->lhs) > 0, we check each of the src_list attributes against
* the dst attribute, to see if any of their values match.
- * - If tmpl_num(map->lhs) == NUM_UNSPEC, we compare all instances of the dst attribute
+ * - If tmpl_attr_tail_num(map->lhs) == NUM_UNSPEC, we compare all instances of the dst attribute
* against each of the src_list attributes.
*/
case T_OP_SUB_EQ:
/*
* Instance specific[n] delete
*/
- if (tmpl_num(map->lhs) != NUM_UNSPEC) {
+ if (tmpl_attr_tail_num(map->lhs) != NUM_UNSPEC) {
fr_pair_list_foreach(&src_list, vp) {
vp->op = T_OP_CMP_EQ;
rcode = paircmp_pairs(request, vp, dst);
*/
for (dst = fr_dcursor_current(&dst_list);
dst;
- dst = fr_dcursor_filter_next(&dst_list, fr_pair_matches_da, tmpl_da(map->lhs))) {
+ dst = fr_dcursor_filter_next(&dst_list, fr_pair_matches_da, tmpl_attr_tail_da(map->lhs))) {
fr_pair_list_foreach(&src_list, vp) {
vp->op = T_OP_CMP_EQ;
rcode = paircmp_pairs(request, vp, dst);
* see what happens...
*/
if (fr_value_box_cast(mod->rhs, tmpl_value(mod->rhs),
- mutated->cast ? mutated->cast : tmpl_da(mutated->lhs)->type,
- tmpl_da(mutated->lhs), &empty_string) < 0) {
+ mutated->cast ? mutated->cast : tmpl_attr_tail_da(mutated->lhs)->type,
+ tmpl_attr_tail_da(mutated->lhs), &empty_string) < 0) {
talloc_free(n);
return NULL;
}
* can only have a single value.
*/
if (tmpl_is_unresolved(mutated->rhs)) {
- fr_type_t type = tmpl_da(mutated->lhs)->type;
+ fr_type_t type = tmpl_attr_tail_da(mutated->lhs)->type;
fr_assert(tmpl_is_attr(mutated->lhs));
- fr_assert(tmpl_da(mutated->lhs)); /* We need to know which attribute to create */
+ fr_assert(tmpl_attr_tail_da(mutated->lhs)); /* We need to know which attribute to create */
n = list_mod_generic_afrom_map(ctx, original, mutated);
if (!n) goto error;
if (fr_value_box_from_str(map_list_head(&n->mod),
tmpl_value(map_list_head(&n->mod)->rhs), type,
- tmpl_da(mutated->lhs),
+ tmpl_attr_tail_da(mutated->lhs),
mutated->rhs->name, mutated->rhs->len,
fr_value_unescape_by_quote[(uint8_t)mutated->rhs->quote], false)) {
- RPEDEBUG("Assigning value to \"%s\" failed", tmpl_da(mutated->lhs)->name);
+ RPEDEBUG("Assigning value to \"%s\" failed", tmpl_attr_tail_da(mutated->lhs)->name);
goto error;
}
goto finish;
assign_values:
fr_assert(tmpl_is_attr(mutated->lhs));
- fr_assert(tmpl_da(mutated->lhs)); /* We need to know which attribute to create */
+ fr_assert(tmpl_attr_tail_da(mutated->lhs)); /* We need to know which attribute to create */
/*
* Empty value - Try and cast an empty string
if (fr_value_box_list_empty(rhs_result)) {
n = list_mod_empty_string_afrom_map(ctx, original, mutated);
if (!n) {
- RPEDEBUG("Assigning value to \"%s\" failed", tmpl_da(mutated->lhs)->name);
+ RPEDEBUG("Assigning value to \"%s\" failed", tmpl_attr_tail_da(mutated->lhs)->name);
xlat_error:
fr_dcursor_head(&values);
fr_dcursor_free_list(&values);
(void)fr_dcursor_init(&from, fr_value_box_list_dlist_head(rhs_result));
while ((vb = fr_dcursor_remove(&from))) {
- if (vb->type != tmpl_da(mutated->lhs)->type) {
+ if (vb->type != tmpl_attr_tail_da(mutated->lhs)->type) {
n_vb = fr_value_box_alloc_null(map_list_head(&n->mod)->rhs);
if (!n_vb) {
fr_dcursor_head(&from);
}
if (fr_value_box_cast(n_vb, n_vb,
- mutated->cast ? mutated->cast : tmpl_da(mutated->lhs)->type,
- tmpl_da(mutated->lhs), vb) < 0) {
- RPEDEBUG("Assigning value to \"%s\" failed", tmpl_da(mutated->lhs)->name);
+ mutated->cast ? mutated->cast : tmpl_attr_tail_da(mutated->lhs)->type,
+ tmpl_attr_tail_da(mutated->lhs), vb) < 0) {
+ RPEDEBUG("Assigning value to \"%s\" failed", tmpl_attr_tail_da(mutated->lhs)->name);
fr_dcursor_head(&from);
fr_dcursor_free_list(&from);
int err;
fr_assert(fr_value_box_list_empty(rhs_result));
- fr_assert((tmpl_is_attr(mutated->lhs) && tmpl_da(mutated->lhs)) ||
- (tmpl_is_list(mutated->lhs) && !tmpl_da(mutated->lhs)));
+ fr_assert((tmpl_is_attr(mutated->lhs) && tmpl_attr_tail_da(mutated->lhs)) ||
+ (tmpl_is_list(mutated->lhs) && !tmpl_attr_tail_da(mutated->lhs)));
/*
* Check source list
break;
case -1: /* No input pairs */
- RDEBUG3("No matching pairs found for \"%s\"", tmpl_da(mutated->rhs)->name);
+ RDEBUG3("No matching pairs found for \"%s\"", tmpl_attr_tail_da(mutated->rhs)->name);
/*
* Special case for := if RHS had no attributes
* we should delete all LHS attributes.
goto error;
}
- if (vp->data.type != tmpl_da(mutated->lhs)->type) {
+ if (vp->data.type != tmpl_attr_tail_da(mutated->lhs)->type) {
if (fr_value_box_cast(n_vb, n_vb,
- mutated->cast ? mutated->cast : tmpl_da(mutated->lhs)->type,
- tmpl_da(mutated->lhs), &vp->data) < 0) {
- RPEDEBUG("Assigning value to \"%s\" failed", tmpl_da(mutated->lhs)->name);
+ mutated->cast ? mutated->cast : tmpl_attr_tail_da(mutated->lhs)->type,
+ tmpl_attr_tail_da(mutated->lhs), &vp->data) < 0) {
+ RPEDEBUG("Assigning value to \"%s\" failed", tmpl_attr_tail_da(mutated->lhs)->name);
goto attr_error;
}
fr_value_box_t *vb, *n_vb;
fr_assert(fr_value_box_list_empty(rhs_result));
- fr_assert(tmpl_da(mutated->lhs));
+ fr_assert(tmpl_attr_tail_da(mutated->lhs));
fr_assert(tmpl_is_attr(mutated->lhs));
n = list_mod_generic_afrom_map(ctx, original, mutated);
* maps we still need to check if we need to
* cast.
*/
- if (tmpl_da(mutated->lhs)->type != tmpl_value_type(mutated->rhs)) {
+ if (tmpl_attr_tail_da(mutated->lhs)->type != tmpl_value_type(mutated->rhs)) {
if (fr_value_box_cast(n_vb, n_vb,
- mutated->cast ? mutated->cast : tmpl_da(mutated->lhs)->type,
- tmpl_da(mutated->lhs), vb) < 0) {
- RPEDEBUG("Assigning value to \"%s\" failed", tmpl_da(mutated->lhs)->name);
+ mutated->cast ? mutated->cast : tmpl_attr_tail_da(mutated->lhs)->type,
+ tmpl_attr_tail_da(mutated->lhs), vb) < 0) {
+ RPEDEBUG("Assigning value to \"%s\" failed", tmpl_attr_tail_da(mutated->lhs)->name);
goto data_error;
}
} else {
{
fr_pair_t *vp;
- MEM(vp = fr_pair_afrom_da(ctx, tmpl_da(attr)));
+ MEM(vp = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(attr)));
if (fr_value_box_copy(vp, &vp->data, value) < 0) {
talloc_free(vp);
return NULL;
/*
* The cursor was set to the Nth one. Delete it, and only it.
*/
- if (tmpl_num(map->lhs) != NUM_ALL) {
+ if (tmpl_attr_tail_num(map->lhs) != NUM_ALL) {
fr_dcursor_free_item(&list);
/*
* Wildcard: delete all of the matching ones
* src_list attributes.
*
* This operation has two modes:
- * - If tmpl_num(map->lhs) > 0, we check each of the src_list attributes against
+ * - If tmpl_attr_tail_num(map->lhs) > 0, we check each of the src_list attributes against
* the found attribute, to see if any of their values match.
- * - If tmpl_num(map->lhs) == NUM_UNSPEC, we compare all instances of the found attribute
+ * - If tmpl_attr_tail_num(map->lhs) == NUM_UNSPEC, we compare all instances of the found attribute
* against each of the src_list attributes.
*/
case T_OP_SUB_EQ:
* i.e. Remove this single instance if it matches
* any of these values.
*/
- if (tmpl_num(map->lhs) != NUM_ALL) {
+ if (tmpl_attr_tail_num(map->lhs) != NUM_ALL) {
fr_value_box_t *vb = tmpl_value(map_list_head(&vlm->mod)->rhs);
if (fr_value_box_cmp(vb, &found->data) == 0) {
/*
* Instance specific[n] overwrite
*/
- if (tmpl_num(map->lhs) != NUM_ALL) {
+ if (tmpl_attr_tail_num(map->lhs) != NUM_ALL) {
fr_dcursor_t from;
fr_pair_list_t vp_from;
/*
* Instance specific[n] filter
*/
- if (tmpl_num(map->lhs) != NUM_ALL) {
+ if (tmpl_attr_tail_num(map->lhs) != NUM_ALL) {
fr_value_box_t *vb = tmpl_value(mod->rhs);
bool remove = true;
return tmpl_request_list_num_elements(&vpt->data.attribute.rr);
}
+static inline tmpl_attr_t const *tmpl_attr_tail(tmpl_t const *vpt)
+{
+ tmpl_assert_type(tmpl_is_attr(vpt));
+
+ return tmpl_attr_list_tail(tmpl_attr(vpt));
+}
+
/**
*
* @hidecallergraph
*/
-static inline fr_dict_attr_t const *tmpl_da(tmpl_t const *vpt)
+static inline fr_dict_attr_t const *tmpl_attr_tail_da(tmpl_t const *vpt)
{
tmpl_attr_t *ar;
return ar->ar_da;
}
-static inline fr_dict_attr_t const *tmpl_unknown(tmpl_t const *vpt)
+static inline fr_dict_attr_t const *tmpl_attr_tail_unknown(tmpl_t const *vpt)
{
tmpl_attr_t *ar;
return ar->ar_unknown;
}
-static inline char const *tmpl_attr_unresolved(tmpl_t const *vpt)
+static inline char const *tmpl_attr_tail_unresolved(tmpl_t const *vpt)
{
tmpl_attr_t *ar;
return ar->ar_unresolved;
}
+static inline int16_t tmpl_attr_tail_num(tmpl_t const *vpt)
+{
+ tmpl_assert_type(tmpl_is_attr(vpt) ||
+ tmpl_is_attr_unresolved(vpt) ||
+ tmpl_is_list(vpt));
+
+ if (tmpl_is_list(vpt) && (tmpl_attr_list_num_elements(tmpl_attr(vpt)) == 0)) return NUM_ALL;
+
+ return tmpl_attr_list_tail(tmpl_attr(vpt))->ar_num;
+}
+
/** The number of attribute references contained within a tmpl
*
*/
return tmpl_attr_list_num_elements(tmpl_attr(vpt));
}
-static inline int16_t tmpl_num(tmpl_t const *vpt)
-{
- tmpl_assert_type(tmpl_is_attr(vpt) ||
- tmpl_is_attr_unresolved(vpt) ||
- tmpl_is_list(vpt));
-
- if (tmpl_is_list(vpt) && (tmpl_attr_list_num_elements(tmpl_attr(vpt)) == 0)) return NUM_ALL;
-
- return tmpl_attr_list_tail(tmpl_attr(vpt))->ar_num;
-}
-
static inline tmpl_pair_list_t tmpl_list(tmpl_t const *vpt)
{
tmpl_assert_type(tmpl_is_attr(vpt) ||
int tmpl_attr_unknown_add(tmpl_t *vpt);
-int tmpl_attr_unresolved_add(fr_dict_t *dict, tmpl_t *vpt,
+int tmpl_attr_tail_unresolved_add(fr_dict_t *dict, tmpl_t *vpt,
fr_type_t type, fr_dict_attr_flags_t const *flags) CC_HINT(nonnull(1));
#ifdef HAVE_REGEX
if (tmpl_is_list(vpt)) {
fr_strerror_printf("List \"%s\" is empty", vpt->name);
} else {
- fr_strerror_printf("No matching \"%s\" pairs found", tmpl_da(vpt)->name);
+ fr_strerror_printf("No matching \"%s\" pairs found", tmpl_attr_tail_da(vpt)->name);
}
}
return NULL;
switch (vpt->type) {
case TMPL_TYPE_ATTR:
- return tmpl_da(vpt)->type;
+ return tmpl_attr_tail_da(vpt)->type;
case TMPL_TYPE_DATA:
return tmpl_value_type(vpt);
tmpl_pair_list_and_ctx(ctx, head, request, tmpl_request(vpt), tmpl_list(vpt));
if (!head) return -1;
- MEM(vp = fr_pair_afrom_da(ctx, tmpl_da(vpt)));
+ MEM(vp = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(vpt)));
fr_pair_append(head, vp);
/*
* Virtual attributes always have a count of 1
*/
- if (tmpl_num(vpt) == NUM_COUNT) {
+ if (tmpl_attr_tail_num(vpt) == NUM_COUNT) {
MEM(value = fr_value_box_alloc(ctx, FR_TYPE_UINT32, NULL, false));
value->datum.uint32 = 1;
goto done;
/*
* Some non-packet expansions
*/
- if (tmpl_da(vpt) == attr_client_shortname) {
+ if (tmpl_attr_tail_da(vpt) == attr_client_shortname) {
RADCLIENT *client = client_from_request(request);
if (!client || !client->shortname) return 0;
MEM(value = fr_value_box_alloc_null(ctx));
- if (fr_value_box_bstrdup_buffer(ctx, value, tmpl_da(vpt), client->shortname, false) < 0) {
+ if (fr_value_box_bstrdup_buffer(ctx, value, tmpl_attr_tail_da(vpt), client->shortname, false) < 0) {
error:
talloc_free(value);
return -1;
goto done;
}
- if (tmpl_da(vpt) == attr_request_processing_stage) {
+ if (tmpl_attr_tail_da(vpt) == attr_request_processing_stage) {
if (!request->component) return 0;
MEM(value = fr_value_box_alloc_null(ctx));
- if (fr_value_box_strdup(ctx, value, tmpl_da(vpt), request->component, false) < 0) goto error;
+ if (fr_value_box_strdup(ctx, value, tmpl_attr_tail_da(vpt), request->component, false) < 0) goto error;
goto done;
}
- if (tmpl_da(vpt) == attr_virtual_server) {
+ if (tmpl_attr_tail_da(vpt) == attr_virtual_server) {
if (!unlang_call_current(request)) return 0;
MEM(value = fr_value_box_alloc_null(ctx));
- if (fr_value_box_bstrdup_buffer(ctx, value, tmpl_da(vpt),
+ if (fr_value_box_bstrdup_buffer(ctx, value, tmpl_attr_tail_da(vpt),
cf_section_name2(unlang_call_current(request)), false) < 0) goto error;
goto done;
}
- if (tmpl_da(vpt) == attr_module_return_code) {
- MEM(value = fr_value_box_alloc(ctx, tmpl_da(vpt)->type, tmpl_da(vpt), false));
+ if (tmpl_attr_tail_da(vpt) == attr_module_return_code) {
+ MEM(value = fr_value_box_alloc(ctx, tmpl_attr_tail_da(vpt)->type, tmpl_attr_tail_da(vpt), false));
value->datum.int32 = request->rcode;
goto done;
}
packet = tmpl_packet_ptr(request, tmpl_list(vpt));
if (!packet) return 0;
- if (tmpl_da(vpt) == attr_packet_type) {
+ if (tmpl_attr_tail_da(vpt) == attr_packet_type) {
if (!packet || !packet->code) return 0;
- MEM(value = fr_value_box_alloc(ctx, tmpl_da(vpt)->type, NULL, false));
- value->enumv = tmpl_da(vpt);
+ MEM(value = fr_value_box_alloc(ctx, tmpl_attr_tail_da(vpt)->type, NULL, false));
+ value->enumv = tmpl_attr_tail_da(vpt);
value->datum.int32 = packet->code;
/*
* because of the talloc checks sprinkled throughout the
* various VP functions.
*/
- } else if (tmpl_da(vpt) == attr_packet_authentication_vector) {
+ } else if (tmpl_attr_tail_da(vpt) == attr_packet_authentication_vector) {
MEM(value = fr_value_box_alloc_null(ctx));
- fr_value_box_memdup(ctx, value, tmpl_da(vpt), packet->vector, sizeof(packet->vector), true);
+ fr_value_box_memdup(ctx, value, tmpl_attr_tail_da(vpt), packet->vector, sizeof(packet->vector), true);
- } else if (tmpl_da(vpt) == attr_client_ip_address) {
+ } else if (tmpl_attr_tail_da(vpt) == attr_client_ip_address) {
RADCLIENT *client = client_from_request(request);
if (client) {
MEM(value = fr_value_box_alloc_null(ctx));
}
goto src_ip_address;
- } else if (tmpl_da(vpt) == attr_packet_src_ip_address) {
+ } else if (tmpl_attr_tail_da(vpt) == attr_packet_src_ip_address) {
src_ip_address:
if (!fr_socket_is_inet(packet->socket.proto) ||
(packet->socket.inet.src_ipaddr.af != AF_INET)) return 0;
MEM(value = fr_value_box_alloc_null(ctx));
- fr_value_box_ipaddr(value, tmpl_da(vpt), &packet->socket.inet.src_ipaddr, true);
+ fr_value_box_ipaddr(value, tmpl_attr_tail_da(vpt), &packet->socket.inet.src_ipaddr, true);
- } else if (tmpl_da(vpt) == attr_packet_dst_ip_address) {
+ } else if (tmpl_attr_tail_da(vpt) == attr_packet_dst_ip_address) {
if (!fr_socket_is_inet(packet->socket.proto) ||
(packet->socket.inet.dst_ipaddr.af != AF_INET)) return 0;
MEM(value = fr_value_box_alloc_null(ctx));
- fr_value_box_ipaddr(value, tmpl_da(vpt), &packet->socket.inet.dst_ipaddr, true);
+ fr_value_box_ipaddr(value, tmpl_attr_tail_da(vpt), &packet->socket.inet.dst_ipaddr, true);
- } else if (tmpl_da(vpt) == attr_packet_src_ipv6_address) {
+ } else if (tmpl_attr_tail_da(vpt) == attr_packet_src_ipv6_address) {
if (!fr_socket_is_inet(packet->socket.proto) ||
(packet->socket.inet.src_ipaddr.af != AF_INET6)) return 0;
MEM(value = fr_value_box_alloc_null(ctx));
- fr_value_box_ipaddr(value, tmpl_da(vpt), &packet->socket.inet.src_ipaddr, true);
+ fr_value_box_ipaddr(value, tmpl_attr_tail_da(vpt), &packet->socket.inet.src_ipaddr, true);
- } else if (tmpl_da(vpt) == attr_packet_dst_ipv6_address) {
+ } else if (tmpl_attr_tail_da(vpt) == attr_packet_dst_ipv6_address) {
if (!fr_socket_is_inet(packet->socket.proto) ||
(packet->socket.inet.dst_ipaddr.af != AF_INET6)) return 0;
MEM(value = fr_value_box_alloc_null(ctx));
- fr_value_box_ipaddr(value, tmpl_da(vpt), &packet->socket.inet.dst_ipaddr, true);
+ fr_value_box_ipaddr(value, tmpl_attr_tail_da(vpt), &packet->socket.inet.dst_ipaddr, true);
- } else if (tmpl_da(vpt) == attr_packet_src_port) {
+ } else if (tmpl_attr_tail_da(vpt) == attr_packet_src_port) {
if (!fr_socket_is_inet(packet->socket.proto)) return 0;
- MEM(value = fr_value_box_alloc(ctx, tmpl_da(vpt)->type, NULL, true));
+ MEM(value = fr_value_box_alloc(ctx, tmpl_attr_tail_da(vpt)->type, NULL, true));
value->datum.uint16 = packet->socket.inet.src_port;
- } else if (tmpl_da(vpt) == attr_packet_dst_port) {
+ } else if (tmpl_attr_tail_da(vpt) == attr_packet_dst_port) {
if (!fr_socket_is_inet(packet->socket.proto)) return 0;
- MEM(value = fr_value_box_alloc(ctx, tmpl_da(vpt)->type, NULL, true));
+ MEM(value = fr_value_box_alloc(ctx, tmpl_attr_tail_da(vpt)->type, NULL, true));
value->datum.uint16 = packet->socket.inet.dst_port;
} else {
- RERROR("Attribute \"%s\" incorrectly marked as virtual", tmpl_da(vpt)->name);
+ RERROR("Attribute \"%s\" incorrectly marked as virtual", tmpl_attr_tail_da(vpt)->name);
return -1;
}
* the virtual one.
*/
if (!vp) {
- if (tmpl_is_attr(vpt) && tmpl_da(vpt)->flags.virtual) {
+ if (tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual) {
ret = tmpl_eval_pair_virtual(ctx, &list, request, vpt);
goto done;
}
/*
* Zero count.
*/
- if (tmpl_num(vpt) == NUM_COUNT) {
+ if (tmpl_attr_tail_num(vpt) == NUM_COUNT) {
value = fr_value_box_alloc(ctx, FR_TYPE_UINT32, NULL, false);
if (!value) {
oom:
goto done;
}
- switch (tmpl_num(vpt)) {
+ switch (tmpl_attr_tail_num(vpt)) {
/*
* Return a count of the VPs.
*/
tmpl_attr_copy(vpt, list);
tmpl_attr_set_list(vpt, tmpl_list(list)); /* Remove when lists are attributes */
tmpl_attr_set_leaf_da(vpt, da); /* This should add a new da when lists are attributes */
- tmpl_attr_set_leaf_num(vpt, tmpl_num(list));
+ tmpl_attr_set_leaf_num(vpt, tmpl_attr_tail_num(list));
/*
* We need to rebuild the attribute name, to be the
tmpl_attr_insert(vpt, ar);
}
- if (tmpl_is_attr(vpt) && (tmpl_rules_cast(vpt) == tmpl_da(vpt)->type)) vpt->rules.cast = FR_TYPE_NULL;
+ if (tmpl_is_attr(vpt) && (tmpl_rules_cast(vpt) == tmpl_attr_tail_da(vpt)->type)) vpt->rules.cast = FR_TYPE_NULL;
fr_sbuff_marker_release(&m_s);
return 0;
/*
* Suppress useless casts.
*/
- if (tmpl_da(vpt)->type == tmpl_rules_cast(vpt)) {
+ if (tmpl_attr_tail_da(vpt)->type == tmpl_rules_cast(vpt)) {
vpt->rules.cast = FR_TYPE_NULL;
}
* we now need to check the cast type.
*/
if (!tmpl_needs_resolving(vpt) && !fr_type_is_null(t_rules->cast) &&
- !fr_type_cast(t_rules->cast, tmpl_da(vpt)->type)) {
+ !fr_type_cast(t_rules->cast, tmpl_attr_tail_da(vpt)->type)) {
fr_strerror_printf("Cannot cast type '%s' to '%s'",
- fr_type_to_str(tmpl_da(vpt)->type), fr_type_to_str(t_rules->cast));
+ fr_type_to_str(tmpl_attr_tail_da(vpt)->type), fr_type_to_str(t_rules->cast));
if (err) *err = TMPL_ATTR_ERROR_BAD_CAST;
fr_sbuff_set_to_start(&our_name);
goto error;
goto check_types;
case TMPL_TYPE_ATTR:
- src_type = tmpl_da(vpt)->type;
+ src_type = tmpl_attr_tail_da(vpt)->type;
/*
*
* #tmpl_attr_unknown_add converts a #TMPL_TYPE_ATTR with an unknown #fr_dict_attr_t to a
* #TMPL_TYPE_ATTR with a known #fr_dict_attr_t, by adding the unknown #fr_dict_attr_t to the main
- * dictionary, and updating the ``tmpl_da`` pointer.
+ * dictionary, and updating the ``tmpl_attr_tail_da`` pointer.
* @{
*/
/*
* Suppress casts to the same type.
*/
- if (tmpl_da(vpt)->type == type) {
+ if (tmpl_attr_tail_da(vpt)->type == type) {
vpt->rules.cast = FR_TYPE_NULL;
break;
}
ret = tmpl_attr_resolve(vpt, tr_rules);
if (ret < 0) return ret;
- if (dst_type == tmpl_da(vpt)->type) {
+ if (dst_type == tmpl_attr_tail_da(vpt)->type) {
vpt->rules.cast = FR_TYPE_NULL;
}
/** Add an unknown #fr_dict_attr_t specified by a #tmpl_t to the main dictionary
*
- * @param vpt to add. ``tmpl_da`` pointer will be updated to point to the
+ * @param vpt to add. ``tmpl_attr_tail_da`` pointer will be updated to point to the
* #fr_dict_attr_t inserted into the dictionary.
* @return
* - 1 noop (did nothing) - Not possible to convert tmpl.
TMPL_VERIFY(vpt);
- if (!tmpl_da(vpt)->flags.is_unknown) return 1; /* Ensure at least the leaf is unknown */
+ if (!tmpl_attr_tail_da(vpt)->flags.is_unknown) return 1; /* Ensure at least the leaf is unknown */
while ((ar = tmpl_attr_list_next(tmpl_attr(vpt), ar))) {
fr_dict_attr_t const *unknown, *known;
* are identical.
*
* @param[in] dict_def Default dictionary to use if none is
- * specified by the tmpl_attr_unresolved.
+ * specified by the tmpl_attr_tail_unresolved.
* @param[in] vpt specifying unresolved attribute to add.
- * ``tmpl_da`` pointer will be updated to
+ * ``tmpl_attr_tail_da`` pointer will be updated to
* point to the #fr_dict_attr_t inserted
* into the dictionary. Lists and requests
* will be preserved.
* - 0 on success.
* - -1 on failure.
*/
-int tmpl_attr_unresolved_add(fr_dict_t *dict_def, tmpl_t *vpt,
+int tmpl_attr_tail_unresolved_add(fr_dict_t *dict_def, tmpl_t *vpt,
fr_type_t type, fr_dict_attr_flags_t const *flags)
{
fr_dict_attr_t const *da;
if (!tmpl_is_attr_unresolved(vpt)) return 1;
if (fr_dict_attr_add(dict_def,
- fr_dict_root(fr_dict_internal()), tmpl_attr_unresolved(vpt), -1, type, flags) < 0) {
+ fr_dict_root(fr_dict_internal()), tmpl_attr_tail_unresolved(vpt), -1, type, flags) < 0) {
return -1;
}
- da = fr_dict_attr_by_name(NULL, fr_dict_root(dict_def), tmpl_attr_unresolved(vpt));
+ da = fr_dict_attr_by_name(NULL, fr_dict_root(dict_def), tmpl_attr_tail_unresolved(vpt));
if (!da) return -1;
if (type != da->type) {
file, line);
}
- if (tmpl_da(vpt)->flags.is_unknown) {
- if (tmpl_da(vpt) != tmpl_unknown(vpt)) {
+ if (tmpl_attr_tail_da(vpt)->flags.is_unknown) {
+ if (tmpl_attr_tail_da(vpt) != tmpl_attr_tail_unknown(vpt)) {
fr_fatal_assert_fail("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_ATTR "
"da is marked as unknown, but address is not equal to the template's "
"unknown da pointer", file, line);
/*
* Attribute may be present with multiple names
*/
- dict = fr_dict_by_da(tmpl_da(vpt));
+ dict = fr_dict_by_da(tmpl_attr_tail_da(vpt));
if (!dict) {
fr_fatal_assert_fail("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_ATTR "
"attribute \"%s\" (%s) not rooted in a dictionary",
- file, line, tmpl_da(vpt)->name,
- fr_type_to_str(tmpl_da(vpt)->type));
+ file, line, tmpl_attr_tail_da(vpt)->name,
+ fr_type_to_str(tmpl_attr_tail_da(vpt)->type));
}
- da = tmpl_da(vpt);
- if (!tmpl_da(vpt)->flags.is_unknown && !tmpl_da(vpt)->flags.is_raw && (da != tmpl_da(vpt))) {
+ da = tmpl_attr_tail_da(vpt);
+ if (!tmpl_attr_tail_da(vpt)->flags.is_unknown && !tmpl_attr_tail_da(vpt)->flags.is_raw && (da != tmpl_attr_tail_da(vpt))) {
fr_fatal_assert_fail("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_ATTR "
"dictionary pointer %p \"%s\" (%s) "
"and global dictionary pointer %p \"%s\" (%s) differ",
file, line,
- tmpl_da(vpt), tmpl_da(vpt)->name,
- fr_type_to_str(tmpl_da(vpt)->type),
+ tmpl_attr_tail_da(vpt), tmpl_attr_tail_da(vpt)->name,
+ fr_type_to_str(tmpl_attr_tail_da(vpt)->type),
da, da->name,
fr_type_to_str(da->type));
}
if (!vpt->rules.attr.list_as_attr && (tmpl_list(vpt) >= PAIR_LIST_UNKNOWN)) {
fr_fatal_assert_fail("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_ATTR "
"attribute \"%s\" has invalid list (%i)",
- file, line, tmpl_da(vpt)->name, tmpl_list(vpt));
+ file, line, tmpl_attr_tail_da(vpt)->name, tmpl_list(vpt));
}
tmpl_attr_verify(file, line, vpt);
if (!tmpl_is_attr(vpt)) return;
- da = tmpl_da(vpt);
+ da = tmpl_attr_tail_da(vpt);
/*
* The input tmpl is a leaf. We must parse the child as
/*
* Convert virtual &Attr-Foo to "%{Attr-Foo}"
*/
- if (tmpl_is_attr(vpt) && tmpl_da(vpt)->flags.virtual) {
+ if (tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual) {
if (tmpl_attr_to_xlat(ctx, vpt_p) < 0) {
return false;
}
* Where "foo" is dynamically defined.
*/
if (c->pass2_fixup == PASS2_FIXUP_TYPE) {
- if (!fr_dict_enum_by_name(tmpl_da(map->lhs), map->rhs->name, -1)) {
+ if (!fr_dict_enum_by_name(tmpl_attr_tail_da(map->lhs), map->rhs->name, -1)) {
cf_log_err(map->ci, "Invalid reference to non-existent %s %s { ... }",
- tmpl_da(map->lhs)->name,
+ tmpl_attr_tail_da(map->lhs)->name,
map->rhs->name);
return false;
}
if (tmpl_is_attr(map->lhs)) {
if ((map->rhs->len > 0) ||
(map->op != T_OP_CMP_EQ) ||
- (tmpl_da(map->lhs)->type == FR_TYPE_STRING) ||
- (tmpl_da(map->lhs)->type == FR_TYPE_OCTETS)) {
+ (tmpl_attr_tail_da(map->lhs)->type == FR_TYPE_STRING) ||
+ (tmpl_attr_tail_da(map->lhs)->type == FR_TYPE_OCTETS)) {
- if (tmpl_cast_in_place(map->rhs, tmpl_da(map->lhs)->type, tmpl_da(map->lhs)) < 0) {
+ if (tmpl_cast_in_place(map->rhs, tmpl_attr_tail_da(map->lhs)->type, tmpl_attr_tail_da(map->lhs)) < 0) {
cf_log_err(map->ci, "Failed to parse data type %s from string: %pV",
- fr_type_to_str(tmpl_da(map->lhs)->type),
+ fr_type_to_str(tmpl_attr_tail_da(map->lhs)->type),
fr_box_strvalue_len(map->rhs->name, map->rhs->len));
return false;
} /* else the cast was successful */
* xlat code does.
*/
vpt = c->data.map->lhs;
- if (tmpl_is_attr(vpt) && tmpl_da(vpt)->flags.virtual) {
+ if (tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual) {
if (tmpl_attr_to_xlat(c, &vpt) < 0) return false;
fr_assert(!tmpl_is_xlat_unresolved(map->lhs));
return true;
}
- if (!paircmp_find(tmpl_da(map->lhs))) return true;
+ if (!paircmp_find(tmpl_attr_tail_da(map->lhs))) return true;
/*
* It's a pair comparison. Do additional checks.
/*
* Force the RHS to be cast to whatever the LHS da is.
*/
- if (tmpl_cast_set(map->rhs, tmpl_da(map->lhs)->type) < 0) {
+ if (tmpl_cast_set(map->rhs, tmpl_attr_tail_da(map->lhs)->type) < 0) {
cf_log_perr(map->ci, "Failed setting rhs type");
};
return false;
}
- da = tmpl_da(map->lhs);
+ da = tmpl_attr_tail_da(map->lhs);
/*
* Resolve all children.
* ignore map->rhs.
*/
if (tmpl_is_attr(map->lhs) && tmpl_is_unresolved(map->rhs)) {
- fr_type_t type = tmpl_da(map->lhs)->type;
+ fr_type_t type = tmpl_attr_tail_da(map->lhs)->type;
/*
* @todo - allow passing octets to
* It's a literal string, just copy it.
* Don't escape anything.
*/
- if (tmpl_cast_in_place(map->rhs, type, tmpl_da(map->lhs)) < 0) {
+ if (tmpl_cast_in_place(map->rhs, type, tmpl_attr_tail_da(map->lhs)) < 0) {
cf_log_perr(map->ci, "Cannot convert RHS value (%s) to LHS attribute type (%s)",
fr_type_to_str(FR_TYPE_STRING),
- fr_type_to_str(tmpl_da(map->lhs)->type));
+ fr_type_to_str(tmpl_attr_tail_da(map->lhs)->type));
return -1;
}
return -1;
}
- parent = tmpl_da(parent_map->lhs);
+ parent = tmpl_attr_tail_da(parent_map->lhs);
/*
* Anal-retentive checks.
switch (map->lhs->type) {
case TMPL_TYPE_ATTR:
- da = tmpl_da(map->lhs);
+ da = tmpl_attr_tail_da(map->lhs);
if (!da->flags.internal && parent && (parent->type != FR_TYPE_GROUP) &&
(da->parent != parent)) {
cf_log_err(cp, "Invalid location for %s - it is not a child of %s",
/*
* Can't assign to [*] or [#]
*/
- num = tmpl_num(map->lhs);
+ num = tmpl_attr_tail_num(map->lhs);
if ((num == NUM_ALL) || (num == NUM_COUNT)) {
cf_log_err(cs, "Invalid array reference in %s", name);
goto fail;
/*
* If the DA isn't structural, then it can't have children.
*/
- parent_da = tmpl_da(map->lhs);
+ parent_da = tmpl_attr_tail_da(map->lhs);
if (fr_type_is_structural(parent_da->type)) {
map_t *child;
for (child = map_list_head(&map->child); child != NULL; child = map_list_next(&map->child, child)) {
if (!tmpl_is_attr(child->lhs)) continue;
- if (tmpl_num(child->lhs) != NUM_UNSPEC) {
+ if (tmpl_attr_tail_num(child->lhs) != NUM_UNSPEC) {
cf_log_err(child->ci, "Cannot use array references and values when deleting from a list");
goto fail;
}
/*
* Can't assign to [*] or [#]
*/
- num = tmpl_num(map->lhs);
+ num = tmpl_attr_tail_num(map->lhs);
if ((num == NUM_ALL) || (num == NUM_COUNT)) {
cf_log_err(cp, "Invalid array reference in %s", map->lhs->name);
goto fail;
type = tmpl_rules_cast(gext->vpt);
} else if (tmpl_is_attr(gext->vpt)) {
- type = tmpl_da(gext->vpt)->type;
+ type = tmpl_attr_tail_da(gext->vpt)->type;
}
htype = fr_htrie_hint(type);
fr_type_t cast_type = tmpl_rules_cast(switch_gext->vpt);
fr_dict_attr_t const *da = NULL;
- if (tmpl_is_attr(switch_gext->vpt)) da = tmpl_da(switch_gext->vpt);
+ if (tmpl_is_attr(switch_gext->vpt)) da = tmpl_attr_tail_da(switch_gext->vpt);
if (fr_type_is_null(cast_type) && da) cast_type = da->type;
return NULL;
}
- if ((tmpl_num(vpt) != NUM_ALL) && (tmpl_num(vpt) != NUM_UNSPEC)) {
+ if ((tmpl_attr_tail_num(vpt) != NUM_ALL) && (tmpl_attr_tail_num(vpt) != NUM_UNSPEC)) {
cf_log_err(cs, "MUST NOT use instance selectors in 'foreach'");
talloc_free(vpt);
return NULL;
* Anything resembling an integer or string is
* OK. Nothing else makes sense.
*/
- switch (tmpl_da(vpt)->type) {
+ switch (tmpl_attr_tail_da(vpt)->type) {
case FR_TYPE_INTEGER_EXCEPT_BOOL:
case FR_TYPE_STRING:
break;
}
}
- da = tmpl_da(current->lhs.vpt);
+ da = tmpl_attr_tail_da(current->lhs.vpt);
if (fr_type_is_group(da->type)) da = fr_dict_root(request->dict);
children = ¤t->rhs.pair_list;
if (fr_type_is_structural(vp->vp_type)) {
tmpl_dcursor_clear(&cc);
- if (tmpl_num(current->rhs.vpt) == NUM_ALL) {
+ if (tmpl_attr_tail_num(current->rhs.vpt) == NUM_ALL) {
REDEBUG("%s[%d] Wildcard for structural attribute %s is not yet implemented.", MAP_INFO, current->rhs.vpt->name);
return -1;
}
* the appropriate place.
*/
if (current->temporary_pair_list) {
- fr_dict_attr_t const *da = tmpl_da(current->lhs.vpt);
+ fr_dict_attr_t const *da = tmpl_attr_tail_da(current->lhs.vpt);
fr_pair_list_t *list = ¤t->parent->rhs.pair_list;
while (box) {
* If we're supposed to create the LHS, then go do that.
*/
if (current->lhs.create) {
- fr_dict_attr_t const *da = tmpl_da(current->lhs.vpt);
+ fr_dict_attr_t const *da = tmpl_attr_tail_da(current->lhs.vpt);
fr_pair_t *vp;
int err;
tmpl_dcursor_ctx_t lhs_cc;
*
* The we just apply the assignment to the LHS, over-writing it's value.
*/
- if ((map->op == T_OP_SET) && (tmpl_num(current->lhs.vpt) == NUM_UNSPEC)) {
+ if ((map->op == T_OP_SET) && (tmpl_attr_tail_num(current->lhs.vpt) == NUM_UNSPEC)) {
tmpl_dcursor_ctx_t cc;
fr_dcursor_t cursor;
- bool first = fr_type_is_structural(tmpl_da(current->lhs.vpt)->type);
+ bool first = fr_type_is_structural(tmpl_attr_tail_da(current->lhs.vpt)->type);
while (true) {
int err;
if (!vp) goto clear;
continue;
- } else if (fr_type_is_structural(tmpl_da(current->lhs.vpt)->type)) {
+ } else if (fr_type_is_structural(tmpl_attr_tail_da(current->lhs.vpt)->type)) {
/*
* We skipped the first structural member, so keep skipping it for all of the next vps.
*/
#endif
}
- if (fr_type_is_leaf(tmpl_da(current->lhs.vpt)->type)) {
+ if (fr_type_is_leaf(tmpl_attr_tail_da(current->lhs.vpt)->type)) {
if (apply_edits_to_leaf(request, state, current) < 0) return -1;
} else {
if (apply_edits_to_list(request, state, current) < 0) return -1;
* Fast path: child is empty, we don't need to do anything.
*/
if (fr_dlist_empty(&map->child.head)) {
- if (fr_type_is_leaf(tmpl_da(current->lhs.vpt)->type)) {
+ if (fr_type_is_leaf(tmpl_attr_tail_da(current->lhs.vpt)->type)) {
REDEBUG("%s[%d] Cannot assign empty list to a normal data type", MAP_INFO);
return -1;
}
* @todo - when we support value-box groups on the RHS in
* apply_edits_to_leaf(), this next block can be deleted.
*/
- if (fr_type_is_leaf(tmpl_da(current->lhs.vpt)->type) && (map->op != T_OP_SET)) {
+ if (fr_type_is_leaf(tmpl_attr_tail_da(current->lhs.vpt)->type) && (map->op != T_OP_SET)) {
REDEBUG("%s[%d] Must use ':=' when editing list of normal data types", MAP_INFO);
return -1;
}
child->map = map_list_head(child->map_head);
child->func = expand_lhs;
- if (fr_type_is_leaf(tmpl_da(current->lhs.vpt)->type)) {
+ if (fr_type_is_leaf(tmpl_attr_tail_da(current->lhs.vpt)->type)) {
child->check_lhs = check_lhs_value;
child->expanded_lhs = expanded_lhs_value;
} else {
* Don't create the leaf. The apply_edits_to_leaf() function will create them after the RHS has
* been expanded.
*/
- if (fr_type_is_leaf(tmpl_da(current->lhs.vpt)->type)) {
+ if (fr_type_is_leaf(tmpl_attr_tail_da(current->lhs.vpt)->type)) {
return expand_rhs(request, state, current);
}
* parent list, but fr_edit_list_apply_list_assignment() does that
* anyways.
*/
- MEM(current->lhs.vp = fr_pair_afrom_da(current, tmpl_da(current->lhs.vpt)));
+ MEM(current->lhs.vp = fr_pair_afrom_da(current, tmpl_attr_tail_da(current->lhs.vpt)));
fr_pair_append(¤t->parent->rhs.pair_list, current->lhs.vp);
current->lhs.vp->op = map->op;
}
/*
- * The LHS tmpl is now an attribute reference. Do some sanity checks on tmpl_num(), operators, etc.
+ * The LHS tmpl is now an attribute reference. Do some sanity checks on tmpl_attr_tail_num(), operators, etc.
* Once that's done, go expand the RHS.
*/
static int check_lhs(request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
* Create the attribute, including any necessary parents.
*/
if (map->op == T_OP_EQ) {
- if (tmpl_num(current->lhs.vpt) == NUM_UNSPEC) {
+ if (tmpl_attr_tail_num(current->lhs.vpt) == NUM_UNSPEC) {
current->lhs.create = true;
/*
}
} else if (map->op == T_OP_SET) {
- if (tmpl_num(current->lhs.vpt) == NUM_UNSPEC) {
+ if (tmpl_attr_tail_num(current->lhs.vpt) == NUM_UNSPEC) {
current->lhs.create = true;
return expand_rhs(request, state, current);
}
*
* because foo[3] is a single leaf value, not a list.
*/
- if (!map->rhs && fr_type_is_leaf(tmpl_da(current->lhs.vpt)->type)) {
+ if (!map->rhs && fr_type_is_leaf(tmpl_attr_tail_da(current->lhs.vpt)->type)) {
RPDEBUG("Can't set one entry to multiple values for %s", current->lhs.vpt->name);
return -1;
}
* &foo[1] exists, don't bother deleting it. Just over-write its value.
*/
fr_assert(map->op == T_OP_SET);
- fr_assert(tmpl_num(map->lhs) != NUM_UNSPEC);
+ fr_assert(tmpl_attr_tail_num(map->lhs) != NUM_UNSPEC);
// &control := ...
}
* select which frame is being used.
*/
if (tmpl_is_attr(gext->vpt) &&
- ((tmpl_da(gext->vpt)->type == FR_TYPE_UINT8) ||
- (tmpl_da(gext->vpt)->type == FR_TYPE_UINT16) ||
- (tmpl_da(gext->vpt)->type == FR_TYPE_UINT32) ||
- (tmpl_da(gext->vpt)->type == FR_TYPE_UINT64))) {
+ ((tmpl_attr_tail_da(gext->vpt)->type == FR_TYPE_UINT8) ||
+ (tmpl_attr_tail_da(gext->vpt)->type == FR_TYPE_UINT16) ||
+ (tmpl_attr_tail_da(gext->vpt)->type == FR_TYPE_UINT32) ||
+ (tmpl_attr_tail_da(gext->vpt)->type == FR_TYPE_UINT64))) {
fr_pair_t *vp;
slen = tmpl_find_vp(&vp, request, gext->vpt);
goto randomly_choose;
}
- switch (tmpl_da(gext->vpt)->type) {
+ switch (tmpl_attr_tail_da(gext->vpt)->type) {
case FR_TYPE_UINT8:
start = ((uint32_t) vp->vp_uint8) % g->num_children;
break;
goto fail;
}
- if (tmpl_da(gext->vpt)->type == FR_TYPE_STRING) {
+ if (tmpl_attr_tail_da(gext->vpt)->type == FR_TYPE_STRING) {
type_enum = fr_dict_enum_by_name(gext->attr_packet_type, attr->vp_strvalue, attr->vp_length);
if (!type_enum) {
RDEBUG("Unknown Packet-Type %pV", &attr->data);
bool pure; //!< has no external side effects, true for BOX, LITERAL, and some functions
bool can_purify; //!< if the xlat has a pure function with pure arguments.
- bool constant; //!< xlat is just tmpl_data, or XLAT_BOX
+ bool constant; //!< xlat is just tmpl_attr_tail_data, or XLAT_BOX
} xlat_flags_t;
/*
a->flags.needs_resolving = false;
}
- my_tr_rules.enumv = tmpl_da(a->vpt);
+ my_tr_rules.enumv = tmpl_attr_tail_da(a->vpt);
XLAT_DEBUG("\tresolve other b\n");
if (tmpl_resolve(b->vpt, &my_tr_rules) < 0) return -1;
b->flags.needs_resolving = false;
}
- my_tr_rules.enumv = tmpl_da(b->vpt);
+ my_tr_rules.enumv = tmpl_attr_tail_da(b->vpt);
XLAT_DEBUG("\tresolve other a\n");
if (tmpl_resolve(a->vpt, &my_tr_rules) < 0) return -1;
vp = tmpl_dcursor_init(NULL, NULL, &cc, &cursor, request, vpt);
if (!vp) {
- dst->vb_bool = tmpl_is_attr(vpt) && tmpl_da(vpt)->flags.virtual;
+ dst->vb_bool = tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual;
} else {
dst->vb_bool = true;
}
if (tmpl_is_attr(vpt)) {
fr_assert(!node->flags.pure);
if (tmpl_attr_unknown_add(vpt) < 0) {
- fr_strerror_printf("Failed defining attribute %s", tmpl_da(vpt)->name);
+ fr_strerror_printf("Failed defining attribute %s", tmpl_attr_tail_da(vpt)->name);
fr_sbuff_set(&our_in, &opand_m);
goto error;
}
if (!tmpl_is_attr(node->vpt)) return true;
- da = tmpl_da(node->vpt);
+ da = tmpl_attr_tail_da(node->vpt);
if (fr_type_is_structural(da->type)) {
if (da->dict == fr_dict_internal()) goto list;
*
* @todo - check lists for equality?
*/
- if ((lhs->type == XLAT_TMPL) && tmpl_is_attr(lhs->vpt) && fr_type_is_structural(tmpl_da(lhs->vpt)->type)) {
+ if ((lhs->type == XLAT_TMPL) && tmpl_is_attr(lhs->vpt) && fr_type_is_structural(tmpl_attr_tail_da(lhs->vpt)->type)) {
if ((op != T_OP_CMP_EQ) && (op != T_OP_NE)) {
fr_strerror_printf("Invalid operatord '%s' for left hand side structural attribute", fr_tokens[op]);
fr_sbuff_set(&our_in, &m_op);
xlat_t *func;
if (tmpl_is_attr(vpt)) {
- func = xlat_func_find(tmpl_da(vpt)->name, -1);
+ func = xlat_func_find(tmpl_attr_tail_da(vpt)->name, -1);
} else {
- func = xlat_func_find(tmpl_attr_unresolved(vpt), -1);
+ func = xlat_func_find(tmpl_attr_tail_unresolved(vpt), -1);
}
if (!func) return -1;
/*
* Deal with virtual attributes.
*/
- if (tmpl_is_attr(vpt) && tmpl_da(vpt)->flags.virtual) {
+ if (tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual) {
if (tmpl_attr_count(vpt) > 1) {
fr_strerror_const("Virtual attributes cannot be nested.");
goto error;
{
if (tmpl_is_attr(node->vpt)) {
fr_assert(!node->flags.pure);
- INFO_INDENT("attribute (%s)", tmpl_da(node->vpt)->name);
- if (tmpl_num(node->vpt) != NUM_UNSPEC) {
+ INFO_INDENT("attribute (%s)", tmpl_attr_tail_da(node->vpt)->name);
+ if (tmpl_attr_tail_num(node->vpt) != NUM_UNSPEC) {
FR_DLIST_HEAD(tmpl_request_list) const *list;
tmpl_request_t *rr = NULL;
INFO_INDENT("ref %d", rr->request);
}
INFO_INDENT("list %d", tmpl_list(node->vpt));
- if (tmpl_num(node->vpt) != NUM_UNSPEC) {
- if (tmpl_num(node->vpt) == NUM_COUNT) {
+ if (tmpl_attr_tail_num(node->vpt) != NUM_UNSPEC) {
+ if (tmpl_attr_tail_num(node->vpt) == NUM_COUNT) {
INFO_INDENT("[#]");
- } else if (tmpl_num(node->vpt) == NUM_ALL) {
+ } else if (tmpl_attr_tail_num(node->vpt) == NUM_ALL) {
INFO_INDENT("[*]");
} else {
- INFO_INDENT("[%d]", tmpl_num(node->vpt));
+ INFO_INDENT("[%d]", tmpl_attr_tail_num(node->vpt));
}
}
INFO_INDENT("}");
* Concat means something completely different as an attribute reference
* Count isn't implemented.
*/
- if ((tmpl_num(node->vpt) == NUM_COUNT) || (tmpl_num(node->vpt) == NUM_ALL)) return NULL;
+ if ((tmpl_attr_tail_num(node->vpt) == NUM_COUNT) || (tmpl_attr_tail_num(node->vpt) == NUM_ALL)) return NULL;
vpt = tmpl_alloc(ctx, TMPL_TYPE_ATTR, T_BARE_WORD, node->fmt, talloc_array_length(node->fmt) - 1);
if (!vpt) return NULL;
* see if it's actually a virtual attribute.
*/
if (tmpl_attr_count(vpt) == 1) {
- if (tmpl_is_attr(vpt) && tmpl_da(vpt)->flags.virtual) {
- func = xlat_func_find(tmpl_da(vpt)->name, -1);
+ if (tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual) {
+ func = xlat_func_find(tmpl_attr_tail_da(vpt)->name, -1);
if (!func) {
unresolved:
node = xlat_exp_alloc(head, XLAT_VIRTUAL_UNRESOLVED, vpt->name, vpt->len);
goto done;
} else if (tmpl_is_attr_unresolved(vpt)) {
- func = xlat_func_find(tmpl_attr_unresolved(vpt), -1);
+ func = xlat_func_find(tmpl_attr_tail_unresolved(vpt), -1);
if (!func) goto unresolved;
goto virtual;
}
*/
map = NULL;
while ((map = map_list_next(&sync_conf->entry_map, map))) {
- if (fr_type_is_structural(tmpl_da(map->lhs)->type)) {
+ if (fr_type_is_structural(tmpl_attr_tail_da(map->lhs)->type)) {
cf_log_err(map->ci, "Structural attribute \"%s\" invalid for LDAP sync update",
- tmpl_da(map->lhs)->name);
+ tmpl_attr_tail_da(map->lhs)->name);
return -1;
}
filename, entry->lineno, map->lhs->name);
return -1;
}
- da = tmpl_da(map->lhs);
+ da = tmpl_attr_tail_da(map->lhs);
/*
* If it's NOT a vendor attribute,
/*
* Pull out the cache created date
*/
- if (tmpl_da(map_list_head(&head)->lhs) == attr_cache_created) {
+ if (tmpl_attr_tail_da(map_list_head(&head)->lhs) == attr_cache_created) {
map_t *map;
c->created = tmpl_value(map_list_head(&head)->rhs)->vb_date;
/*
* Pull out the cache expires date
*/
- if (tmpl_da(map_list_head(&head)->lhs) == attr_cache_expires) {
+ if (tmpl_attr_tail_da(map_list_head(&head)->lhs) == attr_cache_expires) {
map_t *map;
c->expires = tmpl_value(map_list_head(&head)->rhs)->vb_date;
}
while ((map = map_list_next(&c->maps, map))) {
- if ((tmpl_da(map->lhs) != tmpl_da(target)) ||
+ if ((tmpl_attr_tail_da(map->lhs) != tmpl_attr_tail_da(target)) ||
(tmpl_list(map->lhs) != tmpl_list(target))) continue;
MEM(vb = fr_value_box_alloc_null(ctx));
/*
* Convert literal to a type appropriate for the VP.
*/
- if (tmpl_cast_in_place(map->rhs, tmpl_da(map->lhs)->type, tmpl_da(map->lhs)) < 0) goto error;
+ if (tmpl_cast_in_place(map->rhs, tmpl_attr_tail_da(map->lhs)->type, tmpl_attr_tail_da(map->lhs)) < 0) goto error;
/*
* Pull out the special attributes, and set the
* relevant cache entry fields.
*/
- if (fr_dict_attr_is_top_level(tmpl_da(map->lhs))) switch (tmpl_da(map->lhs)->attr) {
+ if (fr_dict_attr_is_top_level(tmpl_attr_tail_da(map->lhs))) switch (tmpl_attr_tail_da(map->lhs)->attr) {
case FR_CACHE_CREATED:
c->created = tmpl_value(map->rhs)->vb_date;
talloc_free(map);
* FIXME: allow multiple entries.
*/
if (tmpl_is_attr(map->lhs)) {
- da = tmpl_da(map->lhs);
+ da = tmpl_attr_tail_da(map->lhs);
} else {
char *attr;
MEM(vp = fr_pair_afrom_da(ctx, da));
if (fr_pair_value_from_str(vp, value, talloc_array_length(value) - 1, NULL, false) < 0) {
RWDEBUG("Failed parsing value \"%pV\" for attribute %s: %s", fr_box_strvalue(value),
- tmpl_da(map->lhs)->name, fr_strerror());
+ tmpl_attr_tail_da(map->lhs)->name, fr_strerror());
talloc_free(vp);
goto error;
}
*/
switch (map->lhs->type) {
case TMPL_TYPE_ATTR:
- type = tmpl_da(map->lhs)->type;
+ type = tmpl_attr_tail_da(map->lhs)->type;
break;
case TMPL_TYPE_LIST:
break;
case TMPL_TYPE_ATTR_UNRESOLVED:
- cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_unresolved(map->lhs));
+ cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_tail_unresolved(map->lhs));
return -1;
default:
break;
case TMPL_TYPE_ATTR_UNRESOLVED:
- cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_unresolved(map->rhs));
+ cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_tail_unresolved(map->rhs));
return -1;
default:
fr_assert(ctx != NULL);
if (tmpl_is_attr(map->lhs)) {
- da = tmpl_da(map->lhs);
+ da = tmpl_attr_tail_da(map->lhs);
} else {
char *attr;
if (fr_pair_value_from_str(vp, str, talloc_array_length(str) - 1, NULL, true) < 0) {
RPWDEBUG("Failed parsing value \"%pV\" for attribute %s", fr_box_strvalue_buffer(str),
- tmpl_da(map->lhs)->name);
+ tmpl_attr_tail_da(map->lhs)->name);
talloc_free(vp);
return -1;
return -1;
}
- da = tmpl_da(map->lhs);
+ da = tmpl_attr_tail_da(map->lhs);
/*
* Ignore attributes which are set
entry->filename, entry->lineno, map->lhs->name);
return -1;
}
- da = tmpl_da(map->lhs);
+ da = tmpl_attr_tail_da(map->lhs);
if ((htype != FR_HTRIE_TRIE) && (da == attr_next_shortest_prefix)) {
ERROR("%s[%d] Cannot use %s when key is not an IP / IP prefix",
char const *p;
#ifndef HAVE_JSON_OBJECT_GET_INT64
- if (tmpl_is_attr(map->lhs) && (tmpl_da(map->lhs)->type == FR_TYPE_UINT64)) {
+ if (tmpl_is_attr(map->lhs) && (tmpl_attr_tail_da(map->lhs)->type == FR_TYPE_UINT64)) {
cf_log_err(cp, "64bit integers are not supported by linked json-c. "
"Upgrade to json-c >= 0.10 to use this feature");
return -1;
fr_pair_list_free(out);
fr_value_box_list_init(&head);
- ret = fr_jpath_evaluate_leaf(request, &head, tmpl_da(map->lhs)->type, tmpl_da(map->lhs),
+ ret = fr_jpath_evaluate_leaf(request, &head, tmpl_attr_tail_da(map->lhs)->type, tmpl_attr_tail_da(map->lhs),
to_eval->root, to_eval->jpath);
if (ret < 0) {
RPEDEBUG("Failed evaluating jpath");
for (value = fr_value_box_list_head(&head);
value;
fr_pair_append(out, vp), value = fr_value_box_list_next(&head, value)) {
- MEM(vp = fr_pair_afrom_da(ctx, tmpl_da(map->lhs)));
+ MEM(vp = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs)));
if (fr_value_box_steal(vp, &vp->data, value) < 0) {
RPEDEBUG("Copying data to attribute failed");
continue;
}
- MEM(vp = fr_pair_afrom_da(ctx, tmpl_da(dst)));
+ MEM(vp = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(dst)));
talloc_free(dst);
if (fr_pair_value_from_str(vp, cval, strlen(cval), NULL, false) < 0) {
continue;
}
- MEM(vp = fr_pair_afrom_da(ctx, tmpl_da(dst)));
+ MEM(vp = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(dst)));
talloc_free(dst);
if (fr_pair_value_from_str(vp, s2, strlen(s2), NULL, false) < 0) {
/*
* Ignore internal attributes.
*/
- if (tmpl_da(map->lhs)->flags.internal) continue;
+ if (tmpl_attr_tail_da(map->lhs)->flags.internal) continue;
/*
* Ignore signalling attributes. They shouldn't exist.
*/
- if ((tmpl_da(map->lhs) == attr_proxy_state) ||
- (tmpl_da(map->lhs) == attr_message_authenticator)) continue;
+ if ((tmpl_attr_tail_da(map->lhs) == attr_proxy_state) ||
+ (tmpl_attr_tail_da(map->lhs) == attr_message_authenticator)) continue;
/*
* Allow passwords only in Access-Request packets.
*/
if ((inst->parent->status_check != FR_RADIUS_CODE_ACCESS_REQUEST) &&
- (tmpl_da(map->lhs) == attr_user_password)) continue;
+ (tmpl_attr_tail_da(map->lhs) == attr_user_password)) continue;
(void) map_to_request(request, map, map_to_vp, NULL);
}
*/
case REDIS_REPLY_INTEGER:
{
- if (tmpl_da(ip_map.lhs)->type != FR_TYPE_IPV4_ADDR) {
+ if (tmpl_attr_tail_da(ip_map.lhs)->type != FR_TYPE_IPV4_ADDR) {
fr_value_box_t tmp;
fr_value_box(&tmp, (uint32_t)ntohl((uint32_t)reply->element[1]->integer), true);
goto skip;
}
ctx = tmpl_list_ctx(current, tmpl_list(dst));
- da = tmpl_da(dst);
+ da = tmpl_attr_tail_da(dst);
fr_assert(vps);
level + 1, max_attrs);*/
} else {
vp = json_pair_alloc_leaf(instance, section, ctx, request,
- tmpl_da(dst), &flags, element);
+ tmpl_attr_tail_da(dst), &flags, element);
if (!vp) continue;
}
RINDENT();
fr_pair_t *vp;
char const *value = uctx;
- vp = fr_pair_afrom_da(ctx, tmpl_da(map->lhs));
+ vp = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs));
if (!vp) return -1;
/*
*/
if (fr_pair_value_from_str(vp, value, strlen(value), NULL, true) < 0) {
RPEDEBUG("Failed parsing value \"%pV\" for attribute %s",
- fr_box_strvalue_buffer(value), tmpl_da(map->lhs)->name);
+ fr_box_strvalue_buffer(value), tmpl_attr_tail_da(map->lhs)->name);
talloc_free(vp);
return -1;
* limit, so that the user will not need to login
* again. Do this only for Session-Timeout.
*/
- if ((tmpl_da(inst->reply_attr) == attr_session_timeout) &&
+ if ((tmpl_attr_tail_da(inst->reply_attr) == attr_session_timeout) &&
fr_time_gt(inst->reset_time, fr_time_wrap(0)) &&
((int64_t)res >= fr_time_delta_to_sec(fr_time_sub(inst->reset_time, request->packet->timestamp)))) {
fr_time_delta_t to_reset = fr_time_sub(inst->reset_time, request->packet->timestamp);
fr_assert(inst->limit_attr);
memset(&flags, 0, sizeof(flags));
- if (tmpl_attr_unresolved_add(fr_dict_unconst(dict_freeradius), inst->paircmp_attr, FR_TYPE_UINT64, &flags) < 0) {
+ if (tmpl_attr_tail_unresolved_add(fr_dict_unconst(dict_freeradius), inst->paircmp_attr, FR_TYPE_UINT64, &flags) < 0) {
cf_log_perr(conf, "Failed defining counter attribute");
return -1;
}
- if (tmpl_attr_unresolved_add(fr_dict_unconst(dict_freeradius), inst->limit_attr, FR_TYPE_UINT64, &flags) < 0) {
+ if (tmpl_attr_tail_unresolved_add(fr_dict_unconst(dict_freeradius), inst->limit_attr, FR_TYPE_UINT64, &flags) < 0) {
cf_log_perr(conf, "Failed defining check attribute");
return -1;
}
- if (tmpl_da(inst->paircmp_attr)->type != FR_TYPE_UINT64) {
- cf_log_err(conf, "Counter attribute %s MUST be uint64", tmpl_da(inst->paircmp_attr)->name);
+ if (tmpl_attr_tail_da(inst->paircmp_attr)->type != FR_TYPE_UINT64) {
+ cf_log_err(conf, "Counter attribute %s MUST be uint64", tmpl_attr_tail_da(inst->paircmp_attr)->name);
return -1;
}
- if (paircmp_register_by_name(tmpl_da(inst->paircmp_attr)->name, NULL, true,
+ if (paircmp_register_by_name(tmpl_attr_tail_da(inst->paircmp_attr)->name, NULL, true,
counter_cmp, inst) < 0) {
cf_log_perr(conf, "Failed registering comparison function for counter attribute %s",
- tmpl_da(inst->paircmp_attr)->name);
+ tmpl_attr_tail_da(inst->paircmp_attr)->name);
return -1;
}
- if (tmpl_da(inst->limit_attr)->type != FR_TYPE_UINT64) {
- cf_log_err(conf, "Check attribute %s MUST be uint64", tmpl_da(inst->limit_attr)->name);
+ if (tmpl_attr_tail_da(inst->limit_attr)->type != FR_TYPE_UINT64) {
+ cf_log_err(conf, "Check attribute %s MUST be uint64", tmpl_attr_tail_da(inst->limit_attr)->name);
return -1;
}