.attr = {
.dict_def = cc->tmpl_rules.attr.dict_def ?
cc->tmpl_rules.attr.dict_def : cc->config->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_unresolved = cc->tmpl_rules.attr.allow_unresolved
},
});
.dict_def = cc->tmpl_rules.attr.dict_def ?
cc->tmpl_rules.attr.dict_def : cc->config->dict,
.allow_unresolved = cc->tmpl_rules.attr.allow_unresolved,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
}
});
if (dec_len <= 0) {
.dict_def = cc->tmpl_rules.attr.dict_def ?
cc->tmpl_rules.attr.dict_def : cc->config->dict,
.allow_unresolved = cc->tmpl_rules.attr.allow_unresolved,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
},
});
if (dec_len <= 0) {
.attr = {
.dict_def = cc->tmpl_rules.attr.dict_def ?
cc->tmpl_rules.attr.dict_def : cc->config->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_unresolved = cc->tmpl_rules.attr.allow_unresolved
},
});
cc->fuzzer_dir = -1;
- cc->tmpl_rules.attr.list_def = PAIR_LIST_REQUEST;
+ cc->tmpl_rules.attr.list_def = request_attr_request;
return cc;
}
tmpl_rules_t parse_rules = {
.attr = {
.dict_def = dict_radius,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_foreign = false, /* tests are in the RADIUS dictionary */
}
};
&(tmpl_rules_t) {
.attr = {
.dict_def = dict_protocol,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_unresolved = true,
}
}
t_rules = (tmpl_rules_t) {
.attr = {
.dict_def = dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_unresolved = true,
.allow_unknown = true
}
};
fr_sbuff_t sbuff = FR_SBUFF_IN(cp->value, strlen(cp->value));
- rules.attr.list_def = PAIR_LIST_REQUEST;
+ rules.attr.list_def = request_attr_request;
/*
* Parse the cast operator for barewords
*/
&(tmpl_rules_t) {
.attr = {
.dict_def = dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_unknown = false,
.allow_unresolved = false,
.allow_foreign = (dict == NULL)
/*
* We always put the request pairs into the environment
*/
- input_pairs = tmpl_list_head(request, PAIR_LIST_REQUEST);
+ input_pairs = tmpl_list_head(request, request_attr_request);
/*
* Automagically switch output type depending on our destination
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.prefix = TMPL_ATTR_REF_PREFIX_NO
}
});
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.prefix = TMPL_ATTR_REF_PREFIX_NO
}
});
*/
#define TMPL_MAX_REQUEST_REF_NESTING 10
-#define PAIR_LIST_UNKNOWN NULL
-#define PAIR_LIST_REQUEST request_attr_request
-#define PAIR_LIST_REPLY request_attr_reply
-#define PAIR_LIST_CONTROL request_attr_control
-#define PAIR_LIST_STATE request_attr_state
-
extern fr_table_num_ordered_t const pair_list_table[];
extern size_t pair_list_table_len;
fr_pair_list_t *head;
fr_value_box_t value;
- tmpl_pair_list_and_ctx(ctx, head, request, CURRENT_REQUEST, PAIR_LIST_REQUEST);
+ tmpl_pair_list_and_ctx(ctx, head, request, CURRENT_REQUEST, request_attr_request);
if (!list) return -1; // error
value.strvalue = talloc_typed_strdup(NULL, "my new username");
tmpl_afrom_attr_substr(autofree, NULL, &vars->vpt, &FR_SBUFF_IN(ref, strlen(ref)), NULL, &(tmpl_rules_t){
.attr = {
.dict_def = test_dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
}});
TEST_CHECK(vars->vpt!= NULL);
TEST_MSG("Failed creating tmpl from %s: %s", ref, fr_strerror());
tmpl_afrom_attr_substr(autofree, NULL, &vars->vpt, &FR_SBUFF_IN(ref, strlen(ref)), NULL, &(tmpl_rules_t){
.attr = {
.dict_def = test_dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
}});
TEST_CHECK(vars->vpt!= NULL);
TEST_MSG("Failed creating tmpl from %s: %s", ref, fr_strerror());
{
if (!request) return NULL;
- if (list == PAIR_LIST_REQUEST) {
+ if (list == request_attr_request) {
if (!request->packet) return NULL;
return &request->request_pairs;
}
- if (list == PAIR_LIST_REPLY) {
+ if (list == request_attr_reply) {
if (!request->reply) return NULL;
return &request->reply_pairs;
}
- if (list == PAIR_LIST_CONTROL) return &request->control_pairs;
+ if (list == request_attr_control) return &request->control_pairs;
- if (list == PAIR_LIST_STATE) return &request->session_state_pairs;
+ if (list == request_attr_state) return &request->session_state_pairs;
RWDEBUG2("List \"%s\" is not available", tmpl_list_name(list, "<INVALID>"));
{
if (!request) return NULL;
- if (list == PAIR_LIST_REQUEST) return request->request_ctx;
+ if (list == request_attr_request) return request->request_ctx;
- if (list == PAIR_LIST_REPLY) return request->reply_ctx;
+ if (list == request_attr_reply) return request->reply_ctx;
- if (list == PAIR_LIST_CONTROL) return request->control_ctx;
+ if (list == request_attr_control) return request->control_ctx;
- if (list == PAIR_LIST_STATE) return request->session_state_ctx;
+ if (list == request_attr_state) return request->session_state_ctx;
return NULL;
}
*/
fr_radius_packet_t *tmpl_packet_ptr(request_t *request, fr_dict_attr_t const *list)
{
- if (list == PAIR_LIST_REQUEST) return request->packet;
+ if (list == request_attr_request) return request->packet;
- if (list == PAIR_LIST_REPLY) return request->reply;
+ if (list == request_attr_reply) return request->reply;
return NULL;
}
*
* Defaults are used if a NULL rules pointer is passed to the parsing function.
*/
-#define DEFAULT_RULES tmpl_rules_t const default_rules = { .attr = { .list_def = PAIR_LIST_REQUEST }}
+#define DEFAULT_RULES tmpl_rules_t const default_rules = { .attr = { .list_def = request_attr_request }}
/* clang-format off */
* for that list to out. This value may be passed to #tmpl_pair_list, along with the current
* #request_t, to get a pointer to the actual list in the #request_t.
*
- * If we're sure we've definitely found a list qualifier token delimiter (``:``) but the
- * string doesn't match a #tmpl_pair_list qualifier, return 0 and write #PAIR_LIST_UNKNOWN
- * to out.
- *
* If we can't find a string that looks like a request qualifier, set out to def, and
* return 0.
*
.ar_parent = fr_dict_root(fr_dict_internal())
};
- fr_assert(at_rules->list_def != PAIR_LIST_UNKNOWN);
+ fr_assert(at_rules->list_def);
ar->ar_da = at_rules->list_def;
/*
.attr = {
.dict_def = dict,
.prefix = TMPL_ATTR_REF_PREFIX_NO,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.disallow_qualifiers = true, /* for now, until more tests are made */
/*
.attr = {
.dict_def = dict,
.prefix = TMPL_ATTR_REF_PREFIX_YES,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.disallow_qualifiers = true, /* for now, until rlm_files supports it */
}
};
}
t->name = q;
- lhs_rules.attr.list_def = PAIR_LIST_CONTROL;
+ lhs_rules.attr.list_def = request_attr_control;
comma = false;
check_item:
* for regexes we want to look at the
* request list.
*/
- tmpl_attr_set_list(new_map->lhs, PAIR_LIST_REQUEST);
+ tmpl_attr_set_list(new_map->lhs, request_attr_request);
if (tmpl_is_regex_uncompiled(new_map->rhs) &&
(tmpl_regex_compile(new_map->rhs, false) < 0)) {
/*
* Setup the reply items.
*/
- lhs_rules.attr.list_def = PAIR_LIST_REPLY;
+ lhs_rules.attr.list_def = request_attr_reply;
comma = false;
reply_item:
}
}
- fr_assert(tmpl_list(new_map->lhs) == PAIR_LIST_REPLY);
+ fr_assert(tmpl_list(new_map->lhs) == request_attr_reply);
if (!new_map->parent) map_list_insert_tail(&t->reply, new_map);
tmpl_rules_t parse_rules = {
.attr = {
.dict_def = *(process->dict),
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
},
};
NULL,
&(tmpl_rules_t){
.attr = {
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_unknown = true
}
});
*/
if (!tmpl_is_attr(map->lhs) ||
!tmpl_request_ref_is_current(tmpl_request(map->lhs)) ||
- (tmpl_list(map->lhs) != PAIR_LIST_REQUEST)) {
+ (tmpl_list(map->lhs) != request_attr_request)) {
return true;
}
char const *name1, *name2;
fr_assert(unlang_ctx->rules != NULL);
- fr_assert(unlang_ctx->rules->attr.list_def != PAIR_LIST_UNKNOWN);
+ fr_assert(unlang_ctx->rules->attr.list_def);
/*
* We always create a group, even if the section is empty.
*/
tmpl_rules_t t_rules = (tmpl_rules_t) {
.attr = {
.dict_def = xr_rules.tr_rules->dict_def,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_unresolved = true,
.allow_unknown = true
}
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.prefix = TMPL_ATTR_REF_PREFIX_NO
}
});
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.prefix = TMPL_ATTR_REF_PREFIX_AUTO
}
}) <= 0) return -4;
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_wildcard = true,
.prefix = TMPL_ATTR_REF_PREFIX_AUTO
}
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.prefix = TMPL_ATTR_REF_PREFIX_AUTO
}
}) <= 0) {
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.prefix = TMPL_ATTR_REF_PREFIX_AUTO
}
}) <= 0) {
tmpl_rules_t attr_rules = {
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.prefix = TMPL_ATTR_REF_PREFIX_AUTO
}
};
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_unknown = false,
.allow_unresolved = false,
.allow_foreign = false,
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_unknown = false,
.allow_unresolved = false,
.allow_foreign = false,
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_wildcard = true,
.prefix = TMPL_ATTR_REF_PREFIX_AUTO
}
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_wildcard = true,
.prefix = TMPL_ATTR_REF_PREFIX_AUTO
}
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
}
});
if (len == 0) {
.attr = {
.dict_def = request->dict,
.request_def = &tmpl_request_def_current,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.prefix = TMPL_ATTR_REF_PREFIX_AUTO,
.allow_unknown = false,
.allow_unresolved = false,
* see if it's actually a virtual attribute.
*/
if ((tmpl_attr_num_elements(vpt) == 1) ||
- (((tmpl_attr_list_head(tmpl_attr(vpt))->da) == PAIR_LIST_REQUEST) && tmpl_attr_num_elements(vpt) == 2)){
+ (((tmpl_attr_list_head(tmpl_attr(vpt))->da) == request_attr_request) && tmpl_attr_num_elements(vpt) == 2)){
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) {
/* Strict rules for the update map as it's processed with limited functionality */
.attr = {
.dict_def = dict_ldap_sync,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_foreign = false,
.allow_unknown = false,
.allow_unresolved = false,
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.prefix = TMPL_ATTR_REF_PREFIX_AUTO
}
});
{
tmpl_rules_t parse_rules = {
.attr = {
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_wildcard = true,
.allow_foreign = true /* Because we don't know where we'll be called */
}
/*
* Convert JSON data into maps
*/
- if ((mod_json_object_to_map(pool, &maps, request, cookie->jobj, PAIR_LIST_CONTROL) < 0) ||
- (mod_json_object_to_map(pool, &maps, request, cookie->jobj, PAIR_LIST_REPLY) < 0) ||
- (mod_json_object_to_map(pool, &maps, request, cookie->jobj, PAIR_LIST_REQUEST) < 0) ||
- (mod_json_object_to_map(pool, &maps, request, cookie->jobj, PAIR_LIST_STATE) < 0)) {
+ if ((mod_json_object_to_map(pool, &maps, request, cookie->jobj, request_attr_control) < 0) ||
+ (mod_json_object_to_map(pool, &maps, request, cookie->jobj, request_attr_reply) < 0) ||
+ (mod_json_object_to_map(pool, &maps, request, cookie->jobj, request_attr_request) < 0) ||
+ (mod_json_object_to_map(pool, &maps, request, cookie->jobj, request_attr_state) < 0)) {
invalid:
talloc_free(pool);
rcode = RLM_MODULE_INVALID;
if (inst->input) {
p = inst->input;
- p += tmpl_pair_list_name(&inst->input_list, p, PAIR_LIST_UNKNOWN);
- if ((inst->input_list == PAIR_LIST_UNKNOWN) || (*p != '\0')) {
+ p += tmpl_pair_list_name(&inst->input_list, p, NULL);
+ if (!inst->input_list || (*p != '\0')) {
cf_log_err(conf, "Invalid input list '%s'", inst->input);
return -1;
}
if (inst->output) {
p = inst->output;
- p += tmpl_pair_list_name(&inst->output_list, p, PAIR_LIST_UNKNOWN);
- if ((inst->output_list == PAIR_LIST_UNKNOWN) || (*p != '\0')) {
+ p += tmpl_pair_list_name(&inst->output_list, p, NULL);
+ if (!inst->output_list || (*p != '\0')) {
cf_log_err(conf, "Invalid output list '%s'", inst->output);
return -1;
}
T_BACK_QUOTED_STRING, NULL,
&(tmpl_rules_t) {
.attr = {
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_foreign = true,
.allow_unresolved = false,
.allow_unknown = false
* assertion that they do not get out of
* sync.
*/
- fr_assert(tmpl_list(map->lhs) == PAIR_LIST_REPLY);
+ fr_assert(tmpl_list(map->lhs) == request_attr_reply);
}
}
&json_arg_parse_rules,
&(tmpl_rules_t){
.attr = {
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_wildcard = true,
.dict_def = request->dict
}
}
count = ldap_count_values_len(values);
- list = tmpl_list_head(request, PAIR_LIST_CONTROL);
- list_ctx = tmpl_list_ctx(request, PAIR_LIST_CONTROL);
+ list = tmpl_list_head(request, request_attr_control);
+ list_ctx = tmpl_list_ctx(request, request_attr_control);
fr_assert(list != NULL);
fr_assert(list_ctx != NULL);
{
tmpl_rules_t parse_rules = {
.attr = {
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.allow_foreign = true /* Because we don't know where we'll be called */
}
};
NULL,
&(tmpl_rules_t){
.attr = {
- .list_def = PAIR_LIST_REQUEST,
+ .list_def = request_attr_request,
.dict_def = request->dict,
.allow_unknown = true,
.allow_unresolved = false,
lua_setfield(L, -2, "pairs");
lua_newtable(L); /* Attribute list meta-table */
- lua_pushinteger(L, PAIR_LIST_REQUEST);
+ lua_pushinteger(L, request_attr_request->attr);
lua_pushcclosure(L, _lua_pair_accessor_init, 1);
lua_setfield(L, -2, "__index");
lua_setmetatable(L, -2);
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REPLY
+ .list_def = request_attr_reply
}
}) <= 0) {
ERROR("Failed to find attribute %s", ckey);
&(tmpl_rules_t){
.attr = {
.dict_def = request->dict,
- .list_def = PAIR_LIST_REPLY
+ .list_def = request_attr_reply
}
}) <= 0) {
ERROR("%s - Failed to find attribute %s.%s", funcname, list_name, s1);
.attr = {
.prefix = TMPL_ATTR_REF_PREFIX_NO,
.dict_def = request->dict,
- .list_def = PAIR_LIST_REPLY
+ .list_def = request_attr_reply
}
}) <= 0) {
RPWDEBUG("Failed parsing attribute (skipping)");
.attr = {
.prefix = TMPL_ATTR_REF_PREFIX_NO,
.dict_def = request->dict,
- .list_def = PAIR_LIST_REPLY
+ .list_def = request_attr_reply
}
}) <= 0) {
RPWDEBUG("Failed parsing attribute (skipping)");