From: Arran Cudbard-Bell Date: Mon, 21 Nov 2022 23:32:00 +0000 (-0800) Subject: Make it clear what's being returned with tmpl_attr accessors X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ba3c68a847b04792de79c33bbfc34b5db04cad1;p=thirdparty%2Ffreeradius-server.git Make it clear what's being returned with tmpl_attr accessors --- diff --git a/src/lib/ldap/map.c b/src/lib/ldap/map.c index d529a4747fb..be76b8c6070 100644 --- a/src/lib/ldap/map.c +++ b/src/lib/ldap/map.c @@ -165,13 +165,13 @@ int fr_ldap_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *reques 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; @@ -207,7 +207,7 @@ int fr_ldap_map_verify(map_t *map, UNUSED void *instance) 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: @@ -228,7 +228,7 @@ int fr_ldap_map_verify(map_t *map, UNUSED void *instance) 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: diff --git a/src/lib/redis/redis.c b/src/lib/redis/redis.c index 6d98c16a06c..d8d82cc28ed 100644 --- a/src/lib/redis/redis.c +++ b/src/lib/redis/redis.c @@ -409,7 +409,7 @@ int fr_redis_reply_to_map(TALLOC_CTX *ctx, map_list_t *out, request_t *request, /* 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; } diff --git a/src/lib/server/cf_parse.c b/src/lib/server/cf_parse.c index 9b17deda863..bd660e76b91 100644 --- a/src/lib/server/cf_parse.c +++ b/src/lib/server/cf_parse.c @@ -1071,7 +1071,7 @@ static int cf_parse_tmpl_pass2(UNUSED CONF_SECTION *cs, tmpl_t **out, CONF_PAIR * 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: diff --git a/src/lib/server/cond_eval.c b/src/lib/server/cond_eval.c index cb5e49c1414..82883fc50f8 100644 --- a/src/lib/server/cond_eval.c +++ b/src/lib/server/cond_eval.c @@ -371,7 +371,7 @@ static int cond_realize_tmpl(request_t *request, 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? @@ -420,7 +420,7 @@ static int cond_realize_tmpl(request_t *request, 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)) { @@ -525,7 +525,7 @@ static bool cond_compare_attrs(request_t *request, fr_value_box_t *lhs, map_t co 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 */ @@ -577,7 +577,7 @@ static bool cond_compare_virtual(request_t *request, map_t const *map) 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; @@ -725,7 +725,7 @@ static bool cond_eval_map(request_t *request, fr_cond_t const *c, * 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; } diff --git a/src/lib/server/cond_tokenize.c b/src/lib/server/cond_tokenize.c index 6e55f43f644..cbfd858e792 100644 --- a/src/lib/server/cond_tokenize.c +++ b/src/lib/server/cond_tokenize.c @@ -183,7 +183,7 @@ static int cond_cast_tmpl(tmpl_t *vpt, fr_type_t type, tmpl_t *other) * 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; } @@ -351,7 +351,7 @@ int fr_cond_promote_types(fr_cond_t *c, fr_sbuff_t *in, fr_sbuff_marker_t *m_lhs /* * 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; @@ -389,7 +389,7 @@ int fr_cond_promote_types(fr_cond_t *c, fr_sbuff_t *in, fr_sbuff_marker_t *m_lhs 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; @@ -887,7 +887,7 @@ static CC_HINT(nonnull) int cond_forbid_groups(tmpl_t *vpt, fr_sbuff_t *in, fr_s if (!tmpl_is_attr(vpt)) return 0; - switch (tmpl_da(vpt)->type) { + switch (tmpl_attr_tail_da(vpt)->type) { case FR_TYPE_LEAF: break; @@ -1034,7 +1034,7 @@ static fr_slen_t cond_tokenize_operand(fr_cond_t *c, tmpl_t **out, * 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; } diff --git a/src/lib/server/map.c b/src/lib/server/map.c index 8325d5fe703..07547093b8b 100644 --- a/src/lib/server/map.c +++ b/src/lib/server/map.c @@ -229,7 +229,7 @@ int map_afrom_cp(TALLOC_CTX *ctx, map_t **out, map_t *parent, CONF_PAIR *cp, * 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; } @@ -238,7 +238,7 @@ int map_afrom_cp(TALLOC_CTX *ctx, map_t **out, map_t *parent, CONF_PAIR *cp, * 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()); @@ -442,7 +442,7 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuf */ 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); @@ -523,7 +523,7 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuf * 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); @@ -632,7 +632,7 @@ parse_rhs: * 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 */ @@ -806,7 +806,7 @@ do_children: 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 ? */ @@ -826,7 +826,7 @@ do_children: * 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. @@ -1343,7 +1343,7 @@ static int map_exec_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *reque { 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"); @@ -1398,7 +1398,7 @@ int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t co * 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; @@ -1413,7 +1413,7 @@ int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t co 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; @@ -1426,7 +1426,7 @@ int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t co * 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); @@ -1487,10 +1487,10 @@ int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t co 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 @@ -1523,9 +1523,9 @@ int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t co 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; @@ -1540,8 +1540,8 @@ int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t co 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) @@ -1555,12 +1555,12 @@ int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t co * 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); @@ -1583,7 +1583,7 @@ int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t co * 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); @@ -1591,12 +1591,12 @@ int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t co 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; @@ -1883,8 +1883,8 @@ int map_to_request(request_t *request, map_t const *map, radius_map_getvalue_t f /* * 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. @@ -1905,9 +1905,9 @@ int map_to_request(request_t *request, map_t const *map, radius_map_getvalue_t f * 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: @@ -1920,7 +1920,7 @@ int map_to_request(request_t *request, map_t const *map, radius_map_getvalue_t f /* * 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); @@ -1941,7 +1941,7 @@ int map_to_request(request_t *request, map_t const *map, radius_map_getvalue_t f */ 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); diff --git a/src/lib/server/map_async.c b/src/lib/server/map_async.c index c5b8f7471c5..8ed1ef6842d 100644 --- a/src/lib/server/map_async.c +++ b/src/lib/server/map_async.c @@ -189,8 +189,8 @@ static inline vp_list_mod_t *list_mod_empty_string_afrom_map(TALLOC_CTX *ctx, * 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; } @@ -444,10 +444,10 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, * 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; @@ -456,10 +456,10 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, 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; @@ -482,7 +482,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, 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 @@ -493,7 +493,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, 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); @@ -510,7 +510,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, (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); @@ -519,9 +519,9 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, } 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); @@ -545,8 +545,8 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, 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 @@ -563,7 +563,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, 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. @@ -598,11 +598,11 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, 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; } @@ -621,7 +621,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, 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); @@ -642,11 +642,11 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, * 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 { @@ -810,7 +810,7 @@ static inline fr_pair_t *map_list_mod_to_vp(TALLOC_CTX *ctx, tmpl_t const *attr, { 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; @@ -1103,7 +1103,7 @@ int map_list_mod_apply(request_t *request, vp_list_mod_t const *vlm) /* * 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 @@ -1123,9 +1123,9 @@ int map_list_mod_apply(request_t *request, vp_list_mod_t const *vlm) * 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: @@ -1139,7 +1139,7 @@ int map_list_mod_apply(request_t *request, vp_list_mod_t const *vlm) * 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) { @@ -1215,7 +1215,7 @@ int map_list_mod_apply(request_t *request, vp_list_mod_t const *vlm) /* * 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; @@ -1251,7 +1251,7 @@ int map_list_mod_apply(request_t *request, vp_list_mod_t const *vlm) /* * 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; diff --git a/src/lib/server/tmpl.h b/src/lib/server/tmpl.h index 6f02e327a50..51013598abc 100644 --- a/src/lib/server/tmpl.h +++ b/src/lib/server/tmpl.h @@ -670,11 +670,18 @@ static inline size_t tmpl_request_ref_count(tmpl_t const *vpt) 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; @@ -686,7 +693,7 @@ static inline fr_dict_attr_t const *tmpl_da(tmpl_t const *vpt) 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; @@ -698,7 +705,7 @@ static inline fr_dict_attr_t const *tmpl_unknown(tmpl_t const *vpt) 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; @@ -710,6 +717,17 @@ static inline char const *tmpl_attr_unresolved(tmpl_t const *vpt) 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 * */ @@ -721,17 +739,6 @@ static inline size_t tmpl_attr_count(tmpl_t const *vpt) 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) || @@ -1096,7 +1103,7 @@ void tmpl_attr_to_raw(tmpl_t *vpt) CC_HINT(nonnull); 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 diff --git a/src/lib/server/tmpl_dcursor.c b/src/lib/server/tmpl_dcursor.c index 22313f527c4..62bb1e9bfca 100644 --- a/src/lib/server/tmpl_dcursor.c +++ b/src/lib/server/tmpl_dcursor.c @@ -358,7 +358,7 @@ fr_pair_t *tmpl_dcursor_init_relative(int *err, TALLOC_CTX *ctx, tmpl_dcursor_ct 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; diff --git a/src/lib/server/tmpl_eval.c b/src/lib/server/tmpl_eval.c index 1fa9605fb72..2eb6bee0f18 100644 --- a/src/lib/server/tmpl_eval.c +++ b/src/lib/server/tmpl_eval.c @@ -323,7 +323,7 @@ fr_type_t tmpl_expanded_type(tmpl_t const *vpt) 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); @@ -1044,7 +1044,7 @@ int tmpl_find_or_add_vp(fr_pair_t **out, request_t *request, tmpl_t const *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); @@ -1172,7 +1172,7 @@ static int tmpl_eval_pair_virtual(TALLOC_CTX *ctx, FR_DLIST_HEAD(fr_value_box_li /* * 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; @@ -1181,12 +1181,12 @@ static int tmpl_eval_pair_virtual(TALLOC_CTX *ctx, FR_DLIST_HEAD(fr_value_box_li /* * 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; @@ -1194,25 +1194,25 @@ static int tmpl_eval_pair_virtual(TALLOC_CTX *ctx, FR_DLIST_HEAD(fr_value_box_li 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; } @@ -1225,11 +1225,11 @@ static int tmpl_eval_pair_virtual(TALLOC_CTX *ctx, FR_DLIST_HEAD(fr_value_box_li 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; /* @@ -1238,11 +1238,11 @@ static int tmpl_eval_pair_virtual(TALLOC_CTX *ctx, FR_DLIST_HEAD(fr_value_box_li * 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)); @@ -1251,49 +1251,49 @@ static int tmpl_eval_pair_virtual(TALLOC_CTX *ctx, FR_DLIST_HEAD(fr_value_box_li } 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; } @@ -1351,7 +1351,7 @@ int tmpl_eval_pair(TALLOC_CTX *ctx, FR_DLIST_HEAD(fr_value_box_list) *out, reque * 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; } @@ -1359,7 +1359,7 @@ int tmpl_eval_pair(TALLOC_CTX *ctx, FR_DLIST_HEAD(fr_value_box_list) *out, reque /* * 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: @@ -1374,7 +1374,7 @@ int tmpl_eval_pair(TALLOC_CTX *ctx, FR_DLIST_HEAD(fr_value_box_list) *out, reque goto done; } - switch (tmpl_num(vpt)) { + switch (tmpl_attr_tail_num(vpt)) { /* * Return a count of the VPs. */ diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index 2439c2ea65d..fb0083b0bc2 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -1243,7 +1243,7 @@ int tmpl_attr_afrom_list(TALLOC_CTX *ctx, tmpl_t **out, tmpl_t const *list, fr_d 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 @@ -1903,7 +1903,7 @@ do_suffix: 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; @@ -2188,7 +2188,7 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err, /* * 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; } @@ -2231,9 +2231,9 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err, * 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; @@ -3401,7 +3401,7 @@ int tmpl_cast_set(tmpl_t *vpt, fr_type_t dst_type) goto check_types; case TMPL_TYPE_ATTR: - src_type = tmpl_da(vpt)->type; + src_type = tmpl_attr_tail_da(vpt)->type; /* @@ -3467,7 +3467,7 @@ ssize_t tmpl_regex_flags_substr(tmpl_t *vpt, fr_sbuff_t *in, fr_sbuff_term_t con * * #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. * @{ */ @@ -3598,7 +3598,7 @@ int tmpl_cast_in_place(tmpl_t *vpt, fr_type_t type, fr_dict_attr_t const *enumv) /* * 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; } @@ -3869,7 +3869,7 @@ int tmpl_resolve(tmpl_t *vpt, tmpl_res_rules_t const *tr_rules) 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; } @@ -4066,7 +4066,7 @@ void tmpl_attr_to_raw(tmpl_t *vpt) /** 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. @@ -4088,7 +4088,7 @@ int tmpl_attr_unknown_add(tmpl_t *vpt) 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; @@ -4161,9 +4161,9 @@ int tmpl_attr_unknown_add(tmpl_t *vpt) * 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. @@ -4174,7 +4174,7 @@ int tmpl_attr_unknown_add(tmpl_t *vpt) * - 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; @@ -4186,10 +4186,10 @@ int tmpl_attr_unresolved_add(fr_dict_t *dict_def, tmpl_t *vpt, 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) { @@ -4853,8 +4853,8 @@ void tmpl_verify(char const *file, int line, tmpl_t const *vpt) 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); @@ -4869,22 +4869,22 @@ void tmpl_verify(char const *file, int line, tmpl_t const *vpt) /* * 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)); } @@ -4892,7 +4892,7 @@ void tmpl_verify(char const *file, int line, tmpl_t const *vpt) 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); @@ -5459,7 +5459,7 @@ void tmpl_rules_child_init(TALLOC_CTX *ctx, tmpl_rules_t *out, tmpl_rules_t cons 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 diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index d2ca9b85c3c..cb41ef2e07b 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -244,7 +244,7 @@ static bool pass2_fixup_tmpl(TALLOC_CTX *ctx, tmpl_t **vpt_p, CONF_ITEM const *c /* * 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; } @@ -279,9 +279,9 @@ static bool pass2_fixup_cond_map(fr_cond_t *c, CONF_ITEM *ci, fr_dict_t const *d * 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; } @@ -357,12 +357,12 @@ static bool pass2_fixup_cond_map(fr_cond_t *c, CONF_ITEM *ci, fr_dict_t const *d 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 */ @@ -477,7 +477,7 @@ static bool pass2_fixup_cond_map(fr_cond_t *c, CONF_ITEM *ci, fr_dict_t const *d * 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)); @@ -498,7 +498,7 @@ static bool pass2_fixup_cond_map(fr_cond_t *c, CONF_ITEM *ci, fr_dict_t const *d 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. @@ -517,7 +517,7 @@ static bool pass2_fixup_cond_map(fr_cond_t *c, CONF_ITEM *ci, fr_dict_t const *d /* * 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"); }; @@ -584,7 +584,7 @@ static bool pass2_fixup_map(map_t *map, tmpl_rules_t const *rules, fr_dict_attr_ return false; } - da = tmpl_da(map->lhs); + da = tmpl_attr_tail_da(map->lhs); /* * Resolve all children. @@ -1001,7 +1001,7 @@ int unlang_fixup_update(map_t *map, void *ctx) * 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 @@ -1014,10 +1014,10 @@ int unlang_fixup_update(map_t *map, void *ctx) * 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; } @@ -1727,7 +1727,7 @@ static int unlang_fixup_edit(map_t *map, void *ctx) return -1; } - parent = tmpl_da(parent_map->lhs); + parent = tmpl_attr_tail_da(parent_map->lhs); /* * Anal-retentive checks. @@ -1746,7 +1746,7 @@ static int unlang_fixup_edit(map_t *map, void *ctx) 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", @@ -1873,7 +1873,7 @@ static unlang_t *compile_edit_section(unlang_t *parent, unlang_compile_t *unlang /* * 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; @@ -1882,7 +1882,7 @@ static unlang_t *compile_edit_section(unlang_t *parent, unlang_compile_t *unlang /* * 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; @@ -1896,7 +1896,7 @@ static unlang_t *compile_edit_section(unlang_t *parent, unlang_compile_t *unlang 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; } @@ -1995,7 +1995,7 @@ static unlang_t *compile_edit_pair(unlang_t *parent, unlang_compile_t *unlang_ct /* * 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; @@ -2856,7 +2856,7 @@ static unlang_t *compile_switch(unlang_t *parent, unlang_compile_t *unlang_ctx, 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); @@ -3035,7 +3035,7 @@ static unlang_t *compile_case(unlang_t *parent, unlang_compile_t *unlang_ctx, CO 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; @@ -3389,7 +3389,7 @@ static unlang_t *compile_foreach(unlang_t *parent, unlang_compile_t *unlang_ctx, 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; @@ -4076,7 +4076,7 @@ static unlang_t *compile_subrequest(unlang_t *parent, unlang_compile_t *unlang_c * 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; diff --git a/src/lib/unlang/edit.c b/src/lib/unlang/edit.c index f2012c59811..95b860221c0 100644 --- a/src/lib/unlang/edit.c +++ b/src/lib/unlang/edit.c @@ -296,7 +296,7 @@ static int apply_edits_to_list(request_t *request, unlang_frame_state_edit_t *st } } - 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; @@ -371,7 +371,7 @@ static int apply_edits_to_list(request_t *request, unlang_frame_state_edit_t *st 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; } @@ -574,7 +574,7 @@ static int apply_edits_to_leaf(request_t *request, unlang_frame_state_edit_t *st * 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) { @@ -599,7 +599,7 @@ static int apply_edits_to_leaf(request_t *request, unlang_frame_state_edit_t *st * 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; @@ -801,10 +801,10 @@ static int check_rhs(request_t *request, unlang_frame_state_edit_t *state, edit_ * * 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; @@ -834,7 +834,7 @@ static int check_rhs(request_t *request, unlang_frame_state_edit_t *state, edit_ 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. */ @@ -894,7 +894,7 @@ static int check_rhs(request_t *request, unlang_frame_state_edit_t *state, edit_ #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; @@ -950,7 +950,7 @@ static int expand_rhs_list(request_t *request, unlang_frame_state_edit_t *state, * 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; } @@ -964,7 +964,7 @@ static int expand_rhs_list(request_t *request, unlang_frame_state_edit_t *state, * @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; } @@ -992,7 +992,7 @@ static int expand_rhs_list(request_t *request, unlang_frame_state_edit_t *state, 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 { @@ -1138,7 +1138,7 @@ static int check_lhs_nested(request_t *request, unlang_frame_state_edit_t *state * 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); } @@ -1155,7 +1155,7 @@ static int check_lhs_nested(request_t *request, unlang_frame_state_edit_t *state * 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; @@ -1163,7 +1163,7 @@ static int check_lhs_nested(request_t *request, unlang_frame_state_edit_t *state } /* - * 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) @@ -1181,7 +1181,7 @@ static int check_lhs(request_t *request, unlang_frame_state_edit_t *state, edit_ * 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; /* @@ -1190,7 +1190,7 @@ static int check_lhs(request_t *request, unlang_frame_state_edit_t *state, edit_ } } 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); } @@ -1209,7 +1209,7 @@ static int check_lhs(request_t *request, unlang_frame_state_edit_t *state, edit_ * * 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; } @@ -1255,7 +1255,7 @@ static int check_lhs(request_t *request, unlang_frame_state_edit_t *state, edit_ * &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 := ... } diff --git a/src/lib/unlang/load_balance.c b/src/lib/unlang/load_balance.c index e64b1140b79..edef0458775 100644 --- a/src/lib/unlang/load_balance.c +++ b/src/lib/unlang/load_balance.c @@ -135,10 +135,10 @@ static unlang_action_t unlang_load_balance(rlm_rcode_t *p_result, request_t *req * 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); @@ -147,7 +147,7 @@ static unlang_action_t unlang_load_balance(rlm_rcode_t *p_result, request_t *req 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; diff --git a/src/lib/unlang/subrequest.c b/src/lib/unlang/subrequest.c index 7cffcc1011e..9075708a07a 100644 --- a/src/lib/unlang/subrequest.c +++ b/src/lib/unlang/subrequest.c @@ -167,7 +167,7 @@ static unlang_action_t unlang_subrequest_parent_init(rlm_rcode_t *p_result, requ 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); diff --git a/src/lib/unlang/xlat.h b/src/lib/unlang/xlat.h index b13882c9d0a..abd34c1ce2b 100644 --- a/src/lib/unlang/xlat.h +++ b/src/lib/unlang/xlat.h @@ -109,7 +109,7 @@ typedef struct { 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; /* diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 68c5549da60..94010f0e0fe 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -296,7 +296,7 @@ static int xlat_expr_resolve_binary(xlat_exp_t *node, UNUSED void *inst, xlat_re 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; @@ -317,7 +317,7 @@ static int xlat_expr_resolve_binary(xlat_exp_t *node, UNUSED void *inst, xlat_re 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; @@ -1508,7 +1508,7 @@ static xlat_action_t xlat_attr_exists(TALLOC_CTX *ctx, fr_dcursor_t *out, 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; } @@ -2369,7 +2369,7 @@ static fr_slen_t tokenize_field(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf 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; } @@ -2447,7 +2447,7 @@ static bool valid_type(xlat_exp_t *node) 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; @@ -2598,7 +2598,7 @@ redo: * * @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); diff --git a/src/lib/unlang/xlat_tokenize.c b/src/lib/unlang/xlat_tokenize.c index 1c9ed9835e8..df5f8dc6a66 100644 --- a/src/lib/unlang/xlat_tokenize.c +++ b/src/lib/unlang/xlat_tokenize.c @@ -592,9 +592,9 @@ static int xlat_resolve_virtual_attribute(xlat_exp_t *node, tmpl_t *vpt) 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; @@ -661,7 +661,7 @@ static inline int xlat_tokenize_attribute(xlat_exp_head_t *head, fr_sbuff_t *in, /* * 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; @@ -1113,8 +1113,8 @@ static void _xlat_debug(xlat_exp_head_t const *head, int depth) { 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; @@ -1128,13 +1128,13 @@ static void _xlat_debug(xlat_exp_head_t const *head, int depth) 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("}"); @@ -1972,7 +1972,7 @@ tmpl_t *xlat_to_tmpl_attr(TALLOC_CTX *ctx, xlat_exp_head_t *head) * 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; @@ -2010,8 +2010,8 @@ int xlat_from_tmpl_attr(TALLOC_CTX *ctx, xlat_exp_head_t **out, tmpl_t **vpt_p) * 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); @@ -2034,7 +2034,7 @@ int xlat_from_tmpl_attr(TALLOC_CTX *ctx, xlat_exp_head_t **out, tmpl_t **vpt_p) 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; } diff --git a/src/listen/ldap_sync/proto_ldap_sync.c b/src/listen/ldap_sync/proto_ldap_sync.c index 8ad8b00cffb..da71041596b 100644 --- a/src/listen/ldap_sync/proto_ldap_sync.c +++ b/src/listen/ldap_sync/proto_ldap_sync.c @@ -361,9 +361,9 @@ static int mod_instantiate(module_inst_ctx_t const *mctx) */ 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; } diff --git a/src/modules/rlm_attr_filter/rlm_attr_filter.c b/src/modules/rlm_attr_filter/rlm_attr_filter.c index 83b338fc9a3..bd2a8e7c3a5 100644 --- a/src/modules/rlm_attr_filter/rlm_attr_filter.c +++ b/src/modules/rlm_attr_filter/rlm_attr_filter.c @@ -132,7 +132,7 @@ static int attr_filter_getfile(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx, c 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, diff --git a/src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c b/src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c index d8ee23b7d60..ed37b6b26d4 100644 --- a/src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c +++ b/src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c @@ -215,7 +215,7 @@ static cache_status_t cache_entry_find(rlm_cache_entry_t **out, /* * 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; @@ -227,7 +227,7 @@ static cache_status_t cache_entry_find(rlm_cache_entry_t **out, /* * 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; diff --git a/src/modules/rlm_cache/rlm_cache.c b/src/modules/rlm_cache/rlm_cache.c index 8605605d617..32269cde755 100644 --- a/src/modules/rlm_cache/rlm_cache.c +++ b/src/modules/rlm_cache/rlm_cache.c @@ -872,7 +872,7 @@ xlat_action_t cache_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, } 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)); diff --git a/src/modules/rlm_cache/serialize.c b/src/modules/rlm_cache/serialize.c index b0da2bc25ff..f755bd0ea1e 100644 --- a/src/modules/rlm_cache/serialize.c +++ b/src/modules/rlm_cache/serialize.c @@ -145,13 +145,13 @@ int cache_deserialize(rlm_cache_entry_t *c, fr_dict_t const *dict, char *in, ssi /* * 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); diff --git a/src/modules/rlm_client/rlm_client.c b/src/modules/rlm_client/rlm_client.c index aa21608a450..95045947e35 100644 --- a/src/modules/rlm_client/rlm_client.c +++ b/src/modules/rlm_client/rlm_client.c @@ -57,7 +57,7 @@ static int _map_proc_client_get_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request * 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; @@ -86,7 +86,7 @@ static int _map_proc_client_get_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request 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; } diff --git a/src/modules/rlm_csv/rlm_csv.c b/src/modules/rlm_csv/rlm_csv.c index 528a1788435..a7a9aab468d 100644 --- a/src/modules/rlm_csv/rlm_csv.c +++ b/src/modules/rlm_csv/rlm_csv.c @@ -400,14 +400,14 @@ static int csv_map_verify(map_t *map, void *instance) */ 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: @@ -448,7 +448,7 @@ static int csv_map_verify(map_t *map, void *instance) 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: @@ -850,7 +850,7 @@ static int csv_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *req 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; @@ -875,7 +875,7 @@ static int csv_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *req 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; diff --git a/src/modules/rlm_files/rlm_files.c b/src/modules/rlm_files/rlm_files.c index 0c264903af6..27d6a1f37bd 100644 --- a/src/modules/rlm_files/rlm_files.c +++ b/src/modules/rlm_files/rlm_files.c @@ -159,7 +159,7 @@ static int getusersfile(TALLOC_CTX *ctx, char const *filename, fr_htrie_t **ptre return -1; } - da = tmpl_da(map->lhs); + da = tmpl_attr_tail_da(map->lhs); /* * Ignore attributes which are set @@ -199,7 +199,7 @@ static int getusersfile(TALLOC_CTX *ctx, char const *filename, fr_htrie_t **ptre 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", diff --git a/src/modules/rlm_json/rlm_json.c b/src/modules/rlm_json/rlm_json.c index 59e7e32ceda..5315d26d23c 100644 --- a/src/modules/rlm_json/rlm_json.c +++ b/src/modules/rlm_json/rlm_json.c @@ -301,7 +301,7 @@ static int mod_map_proc_instantiate(CONF_SECTION *cs, UNUSED void *mod_inst, voi 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; @@ -379,7 +379,7 @@ static int _json_map_proc_get_value(TALLOC_CTX *ctx, fr_pair_list_t *out, reques 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"); @@ -391,7 +391,7 @@ static int _json_map_proc_get_value(TALLOC_CTX *ctx, fr_pair_list_t *out, reques 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"); diff --git a/src/modules/rlm_mruby/rlm_mruby.c b/src/modules/rlm_mruby/rlm_mruby.c index 80f9f7206a5..59d05c503d3 100644 --- a/src/modules/rlm_mruby/rlm_mruby.c +++ b/src/modules/rlm_mruby/rlm_mruby.c @@ -375,7 +375,7 @@ static void add_vp_tuple(TALLOC_CTX *ctx, request_t *request, fr_pair_list_t *vp 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) { diff --git a/src/modules/rlm_python/rlm_python.c b/src/modules/rlm_python/rlm_python.c index 37381339d90..9601f37331a 100644 --- a/src/modules/rlm_python/rlm_python.c +++ b/src/modules/rlm_python/rlm_python.c @@ -314,7 +314,7 @@ static void mod_vptuple(TALLOC_CTX *ctx, module_ctx_t const *mctx, request_t *re 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) { diff --git a/src/modules/rlm_radius/rlm_radius_udp.c b/src/modules/rlm_radius/rlm_radius_udp.c index 91ac947062a..0ff4be86107 100644 --- a/src/modules/rlm_radius/rlm_radius_udp.c +++ b/src/modules/rlm_radius/rlm_radius_udp.c @@ -379,19 +379,19 @@ static void CC_HINT(nonnull) status_check_alloc(udp_handle_t *h) /* * 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); } diff --git a/src/modules/rlm_redis_ippool/rlm_redis_ippool.c b/src/modules/rlm_redis_ippool/rlm_redis_ippool.c index 75490ec8553..3a8816532fc 100644 --- a/src/modules/rlm_redis_ippool/rlm_redis_ippool.c +++ b/src/modules/rlm_redis_ippool/rlm_redis_ippool.c @@ -694,7 +694,7 @@ static ippool_rcode_t redis_ippool_allocate(rlm_redis_ippool_t const *inst, requ */ 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); diff --git a/src/modules/rlm_rest/rest.c b/src/modules/rlm_rest/rest.c index 1c7cff69f05..2674e83ecc4 100644 --- a/src/modules/rlm_rest/rest.c +++ b/src/modules/rlm_rest/rest.c @@ -762,7 +762,7 @@ static int rest_decode_post(UNUSED rlm_rest_t const *instance, UNUSED rlm_rest_s goto skip; } ctx = tmpl_list_ctx(current, tmpl_list(dst)); - da = tmpl_da(dst); + da = tmpl_attr_tail_da(dst); fr_assert(vps); @@ -1155,7 +1155,7 @@ static int json_pair_alloc(rlm_rest_t const *instance, rlm_rest_section_t const 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(); diff --git a/src/modules/rlm_sql/rlm_sql.c b/src/modules/rlm_sql/rlm_sql.c index 62ffc281e06..58b37176c3c 100644 --- a/src/modules/rlm_sql/rlm_sql.c +++ b/src/modules/rlm_sql/rlm_sql.c @@ -332,7 +332,7 @@ static int _sql_map_proc_get_value(TALLOC_CTX *ctx, fr_pair_list_t *out, 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; /* @@ -341,7 +341,7 @@ static int _sql_map_proc_get_value(TALLOC_CTX *ctx, fr_pair_list_t *out, */ 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; diff --git a/src/modules/rlm_sqlcounter/rlm_sqlcounter.c b/src/modules/rlm_sqlcounter/rlm_sqlcounter.c index d07c33a8fbf..03b8f41b794 100644 --- a/src/modules/rlm_sqlcounter/rlm_sqlcounter.c +++ b/src/modules/rlm_sqlcounter/rlm_sqlcounter.c @@ -467,7 +467,7 @@ static unlang_action_t CC_HINT(nonnull) mod_authorize(rlm_rcode_t *p_result, mod * 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); @@ -592,29 +592,29 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) 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; }