static int number = 0;
- /*
- * Create and initialize the new request.
- */
- request = request_local_alloc_external(ctx, NULL);
-
- /*
- * FIXME - Should be less RADIUS centric, but everything
- * else assumes RADIUS at the moment so we can fix this later.
- */
- request->dict = dict_protocol;
- if (!request->dict) {
+ if (!dict_protocol) {
fr_strerror_printf_push("%s dictionary failed to load", PROTOCOL_NAME);
- error:
- talloc_free(request);
return NULL;
}
+ /*
+ * Create and initialize the new request.
+ */
+ request = request_local_alloc_external(ctx, (&(request_init_args_t){ .namespace = dict_protocol }));
+
request->packet = fr_packet_alloc(request, false);
if (!request->packet) {
+ oom:
fr_strerror_const("No memory");
- goto error;
+ error:
+ talloc_free(request);
+ return NULL;
}
request->packet->timestamp = fr_time();
request->reply = fr_packet_alloc(request, false);
- if (!request->reply) {
- fr_strerror_const("No memory");
- goto error;
- }
+ if (!request->reply) goto oom;
request->client = client;
request->number = number++;
{
request_t *request;
- request = request_alloc_internal(NULL, NULL);
+ request = request_alloc_internal(NULL, (&(request_init_args_t){ .namespace = old->proto_dict }));
if (!request) return NULL;
if (!request->packet) request->packet = fr_packet_alloc(request, false);
unlang_call_push(request, server_cs, UNLANG_TOP_FRAME);
request->master_state = REQUEST_ACTIVE;
- request->dict = old->dict;
return request;
}
int fd; //!< file descriptor for this socket - set by open
char const *name; //!< printable name for this socket - set by open
+ fr_dict_t const *dict; //!< dictionary for this listener
fr_app_io_t const *app_io; //!< I/O path functions.
void const *app_io_instance; //!< I/O path configuration context.
{
fr_ring_buffer_t *rb;
+ /*
+ * Associate the protocol dictionary with the listener, so that the decode functions can check /
+ * use it.
+ *
+ * A virtual server may start off with a "dictionary" block, and therefore define a local
+ * dictionary. So the "root" dictionary of a virtual server may not be a protocol dict.
+ */
+ fr_assert(li->server_cs != NULL);
+ li->dict = fr_dict_proto_dict(virtual_server_dict_by_cs(li->server_cs));
+
+ fr_assert(li->dict != NULL);
+
/*
* Skip a bunch of work if we're already in the network thread.
*/
int ret = -1;
request_t *request;
TALLOC_CTX *ctx;
- fr_listen_t const *listen;
+ fr_listen_t *listen = cd->listen;
if (fr_minmax_heap_num_elements(worker->time_order) >= (uint32_t) worker->config.max_requests) goto nak;
- ctx = request = request_alloc_external(NULL, NULL);
+ /*
+ * Receive a message to the worker queue, and decode it
+ * to a request.
+ */
+ fr_assert(listen != NULL);
+
+ ctx = request = request_alloc_external(NULL, (&(request_init_args_t){ .namespace = listen->dict }));
if (!request) goto nak;
worker_request_init(worker, request, now);
request->packet->timestamp = cd->request.recv_time; /* Legacy - Remove once everything looks at request->async */
- /*
- * Receive a message to the worker queue, and decode it
- * to a request.
- */
- fr_assert(cd->listen != NULL);
-
/*
* Update the transport-specific fields.
*/
request->async->recv_time = cd->request.recv_time;
- request->async->listen = cd->listen;
+ request->async->listen = listen;
request->async->packet_ctx = cd->packet_ctx;
request->async->priority = cd->priority;
- listen = request->async->listen;
/*
* Now that the "request" structure has been initialized, go decode the packet.
tmpl_rules_t lhs_rules = {
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->local_dict,
.request_def = tmpl_request(map->lhs),
.list_def = tmpl_list(map->lhs),
},
tmpl_rules_t rhs_rules = {
.attr = {
- .dict_def = request->dict
+ .dict_def = request->local_dict
},
.xlat = {
.runtime_el = lhs_rules.xlat.runtime_el,
int count, i;
tmpl_rules_t const parse_rules = {
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->proto_dict,
.list_def = request_attr_request,
},
.xlat = {
tmpl_rules_t const parse_rules = {
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->proto_dict,
.list_def = request_attr_request,
},
.xlat = {
slen = tmpl_afrom_attr_str(map, NULL, &map->lhs, key->str,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->proto_dict,
.list_def = request_attr_request
}
});
fr_pair_list_foreach(vps, vp) {
PAIR_VERIFY(vp);
- if (!fr_dict_attr_common_parent(fr_dict_root(request->dict), vp->da, true)) continue;
+ if (!fr_dict_attr_common_parent(fr_dict_root(request->proto_dict), vp->da, true)) continue;
log_request_pair(lvl, request, parent, vp, prefix);
}
slen = tmpl_afrom_attr_str(tmp_ctx, NULL, &exp_lhs, attr_str,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->local_dict,
.list_def = request_attr_request,
}
});
slen = tmpl_afrom_attr_str(tmp_ctx, NULL, &map_tmp.lhs, lhs_result_head->vb_strvalue,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->local_dict,
.list_def = request_attr_request,
}
});
/*
* Parse the VPs from the RHS.
*/
- fr_pair_list_afrom_box(ctx, &vp_head, request->dict, rhs_result_head);
+ fr_pair_list_afrom_box(ctx, &vp_head, request->proto_dict, rhs_result_head);
if (fr_pair_list_empty(&vp_head)) {
talloc_free(n);
RDEBUG2("No pairs returned by exec");
/*
* Create and initialize the new request.
*/
- request = request_local_alloc_external(autofree, NULL);
+ request = request_local_alloc_external(autofree, (&(request_init_args_t){ .namespace = test_dict }));
request->packet = fr_packet_alloc(request, false);
TEST_CHECK(request->packet != NULL);
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/atexit.h>
-static request_init_args_t default_args;
-
static fr_dict_t const *dict_freeradius;
extern fr_dict_autoload_t request_dict[];
static inline CC_HINT(always_inline) int request_child_init(request_t *child, request_t *parent)
{
child->number = parent->child_number++;
- if (!child->dict) child->dict = parent->dict;
+ if (!child->proto_dict) {
+ child->proto_dict = parent->proto_dict;
+ child->local_dict = parent->proto_dict;
+ }
if ((parent->seq_start == 0) || (parent->number == parent->seq_start)) {
child->name = talloc_typed_asprintf(child, "%s.%" PRIu64, parent->name, child->number);
request_t *request, request_type_t type,
request_init_args_t const *args)
{
+ fr_dict_t const *dict;
/*
* Sanity checks for different requests types
*/
switch (type) {
case REQUEST_TYPE_EXTERNAL:
+ fr_assert(args);
+
if (!fr_cond_assert_msg(!args->parent, "External requests must NOT have a parent")) return -1;
+
+ fr_assert(args->namespace);
+
+ dict = args->namespace;
break;
case REQUEST_TYPE_INTERNAL:
+ if (!args || !args->namespace) {
+ dict = fr_dict_internal();
+ } else {
+ dict = args->namespace;
+ }
break;
case REQUEST_TYPE_DETACHED:
#endif
.type = type,
.master_state = REQUEST_ACTIVE,
- .dict = args->namespace,
+ .proto_dict = fr_dict_proto_dict(dict),
+ .local_dict = dict,
.component = "<pre-core>",
.flags = {
- .detachable = args->detachable
+ .detachable = args && args->detachable,
},
.alloc_file = file,
.alloc_line = line
* the any uninitialised lists and
* create them locally.
*/
- memcpy(&request->pair_list, &args->pair_list, sizeof(request->pair_list));
+ if (args) memcpy(&request->pair_list, &args->pair_list, sizeof(request->pair_list));
#define list_init(_ctx, _list) \
do { \
* fields if this is going to be a
* child request.
*/
- if (args->parent) {
+ if (args && args->parent) {
if (request_child_init(request, args->parent) < 0) return -1;
if (args->detachable) {
request_t *request;
fr_dlist_head_t *free_list;
- if (!args) args = &default_args;
-
/*
* Setup the free list, or return the free
* list for this thread.
{
request_t *request;
- if (!args) args = &default_args;
-
request = request_alloc_pool(ctx);
if (request_init(file, line, request, type, args) < 0) return NULL;
fr_pair_list_verify(file, line, request->session_state_ctx, &request->session_state_pairs);
fr_pair_list_verify(file, line, request->local_ctx, &request->local_pairs);
+ fr_assert(request->proto_dict != NULL);
+ fr_assert(request->local_dict != NULL);
+
if (request->packet) {
packet_verify(file, line, request, request->packet, &request->request_pairs, "request");
}
uint64_t seq_start; //!< State sequence ID. Stable identifier for a sequence of requests
//!< and responses.
- fr_dict_t const *dict; //!< Dictionary of the protocol that this request belongs to.
+ fr_dict_t const *proto_dict; //!< Dictionary of the protocol that this request belongs to.
+ fr_dict_t const *local_dict; //!< dictionary for local variables
fr_pair_t *pair_root; //!< Root attribute which contains the
///< other list attributes as children.
/*
* Create and initialize the new request.
*/
- request = request_local_alloc_external(autofree, NULL);
+ request = request_local_alloc_external(autofree, (&(request_init_args_t){ .namespace = test_dict }));
request->packet = fr_packet_alloc(request, false);
TEST_CHECK(request->packet != NULL);
head = request_data_reference(request, &trigger_exec_main, REQUEST_INDEX_TRIGGER_ARGS);
- da = fr_dict_attr_by_name(NULL, fr_dict_root(request->dict ? request->dict : fr_dict_internal()),
- in_head->vb_strvalue);
+ da = fr_dict_attr_by_name(NULL, fr_dict_root(request->local_dict), in_head->vb_strvalue);
if (!da) {
ERROR("Unknown attribute \"%pV\"", in_head);
return XLAT_ACTION_FAIL;
&FR_SBUFF_IN(trigger->command, talloc_array_length(trigger->command) - 1),
NULL, NULL, &(tmpl_rules_t) {
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->local_dict,
.list_def = request_attr_request,
.allow_unresolved = false,
},
*/
while (fr_dbuff_remaining(&dbuff) > 0) {
if (fr_internal_decode_pair_dbuff(request->session_state_ctx, &tmp,
- fr_dict_root(request->dict), &dbuff, NULL) < 0) {
+ fr_dict_root(request->proto_dict), &dbuff, NULL) < 0) {
SESSION_ID(sess_id, sess);
fr_pair_list_free(&tmp);
/*
* No parent, or the dictionaries don't match. Ignore it.
*/
- if (!request->parent || (request->parent->dict != gext->dict)) {
+ if (!request->parent || (request->parent->proto_dict != gext->dict)) {
RDEBUG2("...");
return UNLANG_ACTION_EXECUTE_NEXT;
}
dict = unlang_ctx->rules->attr.dict_def;
packet_name = NULL;
+get_packet_type:
+ /*
+ * Local attributes cannot be used in a subrequest. They belong to the parent. Local attributes
+ * are NOT copied to the subrequest.
+ *
+ * @todo - maybe we want to copy local variables, too? But there may be multiple nested local
+ * variables, each with their own dictionary.
+ */
+ dict = fr_dict_proto_dict(dict);
+
/*
* Use dict name instead of "namespace", because "namespace" can be omitted.
*/
-get_packet_type:
da = fr_dict_attr_by_name(NULL, fr_dict_root(dict), "Packet-Type");
if (!da) {
cf_log_err(cs, "No such attribute 'Packet-Type' in namespace '%s'", fr_dict_root(dict)->name);
slen = tmpl_afrom_attr_str(ctx, NULL, &out->to_free, box->vb_strvalue,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->local_dict,
.list_def = request_attr_request,
}
});
* point. The ones which aren't moved will get deleted in this function.
*/
da = tmpl_attr_tail_da(current->lhs.vpt);
- if (fr_type_is_group(da->type)) da = fr_dict_root(request->dict);
+ if (fr_type_is_group(da->type)) da = fr_dict_root(request->proto_dict);
root = (fr_pair_parse_t) {
.ctx = current->ctx,
}
typedef struct {
- fr_dict_t const *dict;
- request_t *request;
+ fr_dict_t const *old_dict; //!< the previous dictionary for the request
+ request_t *request; //!< the request
} unlang_variable_ref_t;
static int _local_variables_free(unlang_variable_ref_t *ref)
vp = fr_pair_list_tail(&ref->request->local_pairs);
while (vp) {
prev = fr_pair_list_prev(&ref->request->local_pairs, vp);
- if (vp->da->dict != ref->dict) {
+ if (vp->da->dict != ref->request->local_dict) {
break;
}
vp = prev;
}
+ ref->request->local_dict = ref->old_dict;
+
return 0;
}
/*
* Set the destructor to clean up local variables.
*/
- ref->dict = g->variables->dict;
ref->request = request;
+ ref->old_dict = request->local_dict;
+ request->local_dict = g->variables->dict;
talloc_set_destructor(ref, _local_variables_free);
return UNLANG_ACTION_PUSHED_CHILD;
{
request_t *child;
+ /*
+ * A child cannot refer to local variables in the parent context.
+ */
+ fr_assert(fr_dict_proto_dict(namespace) == namespace);
+
child = request_alloc_internal(detachable ? NULL : parent,
(&(request_init_args_t){
.parent = parent,
for (i = 0; i < state->num_children; i++) {
fr_assert(state->children[i].instruction != NULL);
child = unlang_io_subrequest_alloc(request,
- request->dict, state->detach);
+ request->proto_dict, state->detach);
child->packet->code = request->packet->code;
RDEBUG3("parallel - child %s (%d/%d) INIT",
if (tmpl_afrom_attr_str(request, NULL, &vpt, fmt,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->local_dict,
.list_def = request_attr_request,
.allow_wildcard = true,
}
if (tmpl_afrom_attr_str(request, NULL, &vpt, fmt,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->local_dict,
.list_def = request_attr_request,
.allow_wildcard = true,
}
tmpl_rules_t attr_rules = {
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->local_dict,
.list_def = request_attr_request,
},
.xlat = {
return xa;
}
-typedef struct {
- fr_dict_t const *namespace; //!< Namespace we use for evaluating runtime expansions
-} xlat_eval_inst_t;
-
-static int xlat_eval_instantiate(xlat_inst_ctx_t const *xctx)
-{
- xlat_eval_inst_t *inst = talloc_get_type_abort(xctx->inst, xlat_eval_inst_t);
-
- inst->namespace = xctx->ex->call.dict;
-
- return 0;
-}
-
static xlat_arg_parser_t const xlat_func_eval_arg[] = {
{ .required = true, .concat = true, .type = FR_TYPE_STRING },
XLAT_ARG_PARSER_TERMINATOR
* @ingroup xlat_functions
*/
static xlat_action_t xlat_func_eval(TALLOC_CTX *ctx, fr_dcursor_t *out,
- xlat_ctx_t const *xctx,
+ UNUSED xlat_ctx_t const *xctx,
request_t *request, fr_value_box_list_t *args)
{
- xlat_eval_inst_t const *inst = talloc_get_type_abort_const(xctx->inst, xlat_eval_inst_t);
-
/*
* These are escaping rules applied to the
* input string. They're mostly here to
},
&(tmpl_rules_t){
.attr = {
- .dict_def = inst->namespace,
+ .dict_def = request->local_dict,
.list_def = request_attr_request,
.allow_unknown = false,
.allow_unresolved = false,
if (tmpl_afrom_attr_str(ctx, NULL, &vpt, in_head->vb_strvalue,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->local_dict,
.list_def = request_attr_request,
.allow_wildcard = true,
}
fr_test_point_pair_decode_t const *tp_decode = *(void * const *)xctx->inst;
if (tp_decode->test_ctx) {
- if (tp_decode->test_ctx(&decode_ctx, ctx, request->dict) < 0) {
+ if (tp_decode->test_ctx(&decode_ctx, ctx, request->proto_dict) < 0) {
return XLAT_ACTION_FAIL;
}
}
if (tmpl_afrom_attr_str(ctx, NULL, &vpt, in_head->vb_strvalue,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->proto_dict, /* we can't encode local attributes */
.list_def = request_attr_request,
.allow_wildcard = true,
}
* Create the encoding context.
*/
if (tp_encode->test_ctx) {
- if (tp_encode->test_ctx(&encode_ctx, vpt, request->dict) < 0) {
+ if (tp_encode->test_ctx(&encode_ctx, vpt, request->proto_dict) < 0) {
talloc_free(vpt);
return XLAT_ACTION_FAIL;
}
/*
* Don't check the dictionaries. By definition,
- * vp->da->dict==request->dict, OR else we're
+ * vp->da->dict==request->proto_dict, OR else we're
* using the internal encoder and encoding a real
* protocol.
*
XLAT_REGISTER_PURE("urlquote", xlat_func_urlquote, FR_TYPE_STRING, xlat_func_urlquote_arg);
XLAT_REGISTER_PURE("urlunquote", xlat_func_urlunquote, FR_TYPE_STRING, xlat_func_urlunquote_arg);
XLAT_REGISTER_PURE("eval", xlat_func_eval, FR_TYPE_VOID, xlat_func_eval_arg);
- xlat_func_instantiate_set(xlat, xlat_eval_instantiate, xlat_eval_inst_t, NULL, NULL);
return xlat_register_expressions();
}
NULL,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->local_dict,
.list_def = request_attr_request,
},
.xlat = {
{
int decoded = 0;
fr_pair_t *vp = NULL;
- fr_dict_attr_t const *parent = fr_dict_root(request->dict);
+ fr_dict_attr_t const *parent = fr_dict_root(request->proto_dict);
fr_pair_list_t head;
fr_pair_list_init(&head);
*/
if (!node->flags.pure) {
if (node->call.func->purify) {
- fr_dict_t const *dict = request->dict;
-
- /*
- * Swap in the node specific dictionary.
- *
- * The previous code stored the dictionary in the xlat_exp_head_t,
- * and whilst this wasn't wrong, it was duplicative.
- *
- * This allows future code to create inline definitions of local
- * attributes, and have them work correctly, as more deeply nested
- * expressions would swap in the correct dictionary.
- */
- request->dict = node->call.dict;
if (node->call.func->purify(node, node->call.inst->data, request) < 0) return -1;
- request->dict = dict;
} else {
if (xlat_purify_list_internal(node->call.args, request, T_BARE_WORD) < 0) return -1;
}
if (!head->flags.can_purify) return 0;
- request = request_alloc_internal(NULL, (&(request_init_args_t){ .namespace = fr_dict_internal() }));
+ request = request_alloc_internal(NULL, NULL);
if (!request) return -1;
if (intp) unlang_interpret_set(request, intp);
fr_dict_attr_t const *fr_dict_unlocal(fr_dict_attr_t const *da) CC_HINT(nonnull);
+fr_dict_t const *fr_dict_proto_dict(fr_dict_t const *dict) CC_HINT(nonnull);
+
fr_dict_t const *fr_dict_by_da(fr_dict_attr_t const *da) CC_HINT(nonnull);
fr_dict_t const *fr_dict_by_attr_name(fr_dict_attr_t const **found, char const *name);
}
/*
- * Get the real protocol dictionary behind the local one.
+ * Get the real protocol namespace behind a local one.
*/
fr_dict_attr_t const *fr_dict_unlocal(fr_dict_attr_t const *da)
{
return da;
}
+/*
+ * Get the real protocol dictionary behind a local one.
+ */
+fr_dict_t const *fr_dict_proto_dict(fr_dict_t const *dict)
+{
+ while (dict->next) dict = dict->next;
+
+ return dict;
+}
+
int fr_dict_attr_set_group(fr_dict_attr_t **da_p)
{
if ((*da_p)->type == FR_TYPE_GROUP) {
// proto_arp_t const *inst = talloc_get_type_abort_const(instance, proto_arp_t);
fr_arp_packet_t const *arp;
- /*
- * Set the request dictionary so that we can do
- * generic->protocol attribute conversions as
- * the request runs through the server.
- */
- request->dict = dict_arp;
-
if (fr_arp_decode(request->request_ctx, &request->request_pairs, data, data_len) < 0) {
RPEDEBUG("Failed decoding packet");
return -1;
bfd_wrapper_t const *wrapper = (bfd_wrapper_t const *) data;
bfd_packet_t const *bfd = (bfd_packet_t const *) wrapper->packet;
- /*
- * Set the request dictionary so that we can do
- * generic->protocol attribute conversions as
- * the request runs through the server.
- */
- request->dict = dict_bfd;
-
client = address->radclient;
/*
{
proto_cron_t const *inst = talloc_get_type_abort_const(instance, proto_cron_t);
- request->dict = inst->dict;
request->packet->code = inst->code;
/*
fr_io_track_t const *track = talloc_get_type_abort_const(request->async->packet_ctx, fr_io_track_t);
fr_io_address_t const *address = track->address;
- /*
- * Set the request dictionary so that we can do
- * generic->protocol attribute conversions as
- * the request runs through the server.
- */
- request->dict = inst->dict;
-
/*
* Hacks for now until we have a lower-level decode routine.
*/
static fr_dict_attr_t const *attr_packet_original_timestamp;
static fr_dict_attr_t const *attr_packet_src_ip_address;
static fr_dict_attr_t const *attr_packet_src_port;
-static fr_dict_attr_t const *attr_protocol;
extern fr_dict_attr_autoload_t proto_detail_dict_attr[];
fr_dict_attr_autoload_t proto_detail_dict_attr[] = {
{ .out = &attr_packet_original_timestamp, .name = "Packet-Original-Timestamp", .type = FR_TYPE_DATE, .dict = &dict_freeradius },
{ .out = &attr_packet_src_ip_address, .name = "Net.Src.IP", .type = FR_TYPE_COMBO_IP_ADDR, .dict = &dict_freeradius },
{ .out = &attr_packet_src_port, .name = "Net.Src.Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius },
- { .out = &attr_protocol, .name = "Protocol", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
{ NULL }
};
RHEXDUMP3(data, data_len, "proto_detail decode packet");
- request->dict = inst->dict;
request->packet->code = inst->code;
/*
*/
if ((*p != '\0') && (*p != '\t')) {
REDEBUG("Malformed line %d", lineno);
- error:
fr_dcursor_free_list(&cursor);
return -1;
}
*/
root = (fr_pair_parse_t) {
.ctx = request->request_ctx,
- .da = fr_dict_root(request->dict),
+ .da = fr_dict_root(request->proto_dict),
.list = &tmp_list,
};
relative = (fr_pair_parse_t) { };
request->packet->socket.inet.src_port = vp->vp_uint16;
} else if (vp->da == attr_packet_dst_port) {
request->packet->socket.inet.dst_port = vp->vp_uint16;
- } else if (vp->da == attr_protocol) {
- request->dict = fr_dict_by_protocol_num(vp->vp_uint32);
- if (!request->dict) {
- REDEBUG("Invalid protocol: %pP", vp);
- goto error;
- }
}
}
fr_client_t const *client;
fr_packet_t *packet = request->packet;
- /*
- * Set the request dictionary so that we can do
- * generic->protocol attribute conversions as
- * the request runs through the server.
- */
- request->dict = dict_dhcpv4;
-
RHEXDUMP3(data, data_len, "proto_dhcpv4 decode packet");
client = address->radclient;
fr_client_t const *client;
fr_packet_t *packet = request->packet;
- /*
- * Set the request dictionary so that we can do
- * generic->protocol attribute conversions as
- * the request runs through the server.
- */
- request->dict = dict_dhcpv6;
-
RHEXDUMP3(data, data_len, "proto_dhcpv6 decode packet");
client = address->radclient;
fr_dns_packet_t const *packet = (fr_dns_packet_t const *) data;
fr_dns_ctx_t packet_ctx;
- /*
- * Set the request dictionary so that we can do
- * generic->protocol attribute conversions as
- * the request runs through the server.
- */
- request->dict = dict_dns;
-
RHEXDUMP3(data, data_len, "proto_dns decode packet");
client = address->radclient;
ssize_t ret;
fr_pair_t *vp = NULL;
- request->dict = dict_ldap_sync;
+ fr_assert(request->proto_dict == dict_ldap_sync);
fr_dbuff_init(&dbuff, data, data_len);
* Extract attributes from the passed data
*/
ret = fr_internal_decode_list_dbuff(request->pair_list.request, &request->request_pairs,
- fr_dict_root(request->dict), &dbuff, NULL);
+ fr_dict_root(request->proto_dict), &dbuff, NULL);
if (ret < 0) return -1;
vp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_packet_type);
{
proto_load_t const *inst = talloc_get_type_abort_const(instance, proto_load_t);
- request->dict = inst->dict;
request->packet->code = inst->code;
/*
fr_io_track_t const *track = talloc_get_type_abort_const(request->async->packet_ctx, fr_io_track_t);
fr_io_address_t const *address = track->address;
- /*
- * Set the request dictionary so that we can do
- * generic->protocol attribute conversions as
- * the request runs through the server.
- */
- request->dict = inst->dict;
-
/*
* Hacks for now until we have a lower-level decode routine.
*/
fr_assert(data[0] < FR_RADIUS_CODE_MAX);
- /*
- * Set the request dictionary so that we can do
- * generic->protocol attribute conversions as
- * the request runs through the server.
- */
- request->dict = dict_radius;
-
common_ctx = (fr_radius_ctx_t) {
.secret = client->secret,
.secret_length = talloc_array_length(client->secret) - 1,
{
fr_value_box_t *vb;
- if (request->dict != dict_radius) return XLAT_ACTION_FAIL;
+ if (request->proto_dict != dict_radius) return XLAT_ACTION_FAIL;
MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_OCTETS, NULL));
if (fr_value_box_memdup(vb, vb, NULL, request->packet->vector, sizeof(request->packet->vector), true) < 0) {
RHEXDUMP3(data, data_len, "proto_tacacs decode packet");
- /*
- * Set the request dictionary so that we can do
- * generic->protocol attribute conversions as
- * the request runs through the server.
- */
- request->dict = dict_tacacs;
-
client = address->radclient;
/*
RHEXDUMP3(data, data_len, "proto_vmps decode packet");
- /*
- * Set the request dictionary so that we can do
- * generic->protocol attribute conversions as
- * the request runs through the server.
- */
- request->dict = dict_vmps;
-
client = address->radclient;
/*
MEM(c = talloc_zero(NULL, rlm_cache_entry_t));
map_list_init(&c->maps);
- ret = cache_deserialize(request, c, request->dict, from_store, len);
+ ret = cache_deserialize(request, c, request->proto_dict, from_store, len);
free(from_store);
if (ret < 0) {
RPERROR("Invalid entry");
NULL,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->proto_dict,
.list_def = request_attr_request,
}
});
return -1;
}
- da = fr_dict_attr_by_name(NULL, fr_dict_root(request->dict), attr);
+ da = fr_dict_attr_by_name(NULL, fr_dict_root(request->local_dict), attr);
if (!da) {
RWDEBUG("No such attribute '%s'", attr);
talloc_free(attr);
}
- da = fr_dict_attr_by_name(NULL, fr_dict_root(request->dict), attr);
+ da = fr_dict_attr_by_name(NULL, fr_dict_root(request->local_dict), attr);
if (!da) {
RWDEBUG("No such attribute '%s'", attr);
talloc_free(attr);
if (tmpl_afrom_attr_str(request, NULL, &vpt, name,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->proto_dict,
.list_def = request_attr_request,
}
}) <= 0) return -4;
fr_value_box_t *attr = fr_value_box_list_head(in);
fr_value_box_t *vb;
- da = fr_dict_attr_child_by_num(fr_dict_root(request->dict), attr->vb_uint32);
+ da = fr_dict_attr_child_by_num(fr_dict_root(request->proto_dict), attr->vb_uint32);
if (!da) {
REDEBUG("No attribute found with number %pV", attr);
return XLAT_ACTION_FAIL;
request_t *request, fr_value_box_list_t *in)
{
unsigned int attr = 0;
- fr_dict_attr_t const *parent = fr_dict_root(request->dict);
+ fr_dict_attr_t const *parent = fr_dict_root(request->proto_dict);
fr_dict_attr_t const *da;
ssize_t ret;
fr_value_box_t *attr_vb = fr_value_box_list_head(in);
MEM(eap_session->subrequest = unlang_subrequest_alloc(request,
method->submodule->namespace ?
*(method->submodule->namespace) :
- request->dict));
+ request->proto_dict));
if (method->submodule->clone_parent_lists) {
if (fr_pair_list_copy(eap_session->subrequest->control_ctx,
goto finish;
}
- MEM(child = unlang_subrequest_alloc(request, request->dict));
+ MEM(child = unlang_subrequest_alloc(request, request->proto_dict));
fr_assert(fr_pair_list_empty(&child->request_pairs));
switch (t->status) {
fr_sbuff_t in = FR_SBUFF_IN(box->vb_strvalue, box->vb_length);
tmpl_rules_t lhs_rules = (tmpl_rules_t) {
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->local_dict,
.list_def = tmpl_list(inst->output_list),
.list_presence = TMPL_ATTR_LIST_ALLOW,
.attr = {
.list_def = request_attr_request,
.allow_wildcard = true,
- .dict_def = request->dict,
+ .dict_def = request->proto_dict,
}
});
if (slen <= 0) {
t_rules = (tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->proto_dict,
.list_def = request_attr_request,
},
.xlat = {
tmpl_rules_t const parse_rules = {
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->proto_dict,
.list_def = request_attr_request,
},
.xlat = {
&(tmpl_rules_t){
.attr = {
.list_def = request_attr_request,
- .dict_def = request->dict,
+ .dict_def = request->local_dict,
.allow_unknown = true,
.allow_unresolved = false,
},
return -1;
}
- da = fr_dict_attr_by_name(NULL, fr_dict_root(request->dict), attr);
+ da = fr_dict_attr_by_name(NULL, fr_dict_root(request->proto_dict), attr);
if (!da) {
REDEBUG("Unknown or invalid attribute name \"%s\"", attr);
return -1;
if (tmpl_afrom_attr_str(request, NULL, &dst, ckey,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->proto_dict,
.list_def = request_attr_reply,
}
}) <= 0) {
if (inst->pwd_fmt->field[i] && *inst->pwd_fmt->field[i] && pw->field[i] &&
(i != inst->key_field) && inst->pwd_fmt->listflag[i] == when) {
if (!inst->ignore_empty || pw->field[i][0] != 0 ) { /* if value in key/value pair is not empty */
- fr_dict_attr_t const *da = fr_dict_attr_by_name(NULL, fr_dict_root(request->dict), inst->pwd_fmt->field[i]);
+ fr_dict_attr_t const *da = fr_dict_attr_by_name(NULL, fr_dict_root(request->proto_dict), inst->pwd_fmt->field[i]);
size_t len;
if (!da) {
fr_pair_list_init(&vps);
if (inst->replace.request &&
(get_hv_content(request->request_ctx, request, rad_request_hv, &vps, "request",
- fr_dict_root(request->dict), true)) > 0) {
+ fr_dict_root(request->proto_dict), true)) > 0) {
fr_pair_list_free(&request->request_pairs);
fr_pair_list_append(&request->request_pairs, &vps);
}
if (inst->replace.reply &&
(get_hv_content(request->reply_ctx, request, rad_reply_hv, &vps, "reply",
- fr_dict_root(request->dict), true)) > 0) {
+ fr_dict_root(request->proto_dict), true)) > 0) {
fr_pair_list_free(&request->reply_pairs);
fr_pair_list_append(&request->reply_pairs, &vps);
}
if (inst->replace.control &&
(get_hv_content(request->control_ctx, request, rad_config_hv, &vps, "control",
- fr_dict_root(request->dict), true)) > 0) {
+ fr_dict_root(request->proto_dict), true)) > 0) {
fr_pair_list_free(&request->control_pairs);
fr_pair_list_append(&request->control_pairs, &vps);
}
if (inst->replace.session &&
(get_hv_content(request->session_state_ctx, request, rad_state_hv, &vps, "session-state",
- fr_dict_root(request->dict), true)) > 0) {
+ fr_dict_root(request->proto_dict), true)) > 0) {
fr_pair_list_free(&request->session_state_pairs);
fr_pair_list_append(&request->session_state_pairs, &vps);
}
if (tmpl_afrom_attr_str(ctx, NULL, &dst, s1,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->proto_dict,
.list_def = request_attr_reply,
}
}) <= 0) {
fr_assert(!h->status_u && !h->status_request);
- MEM(request = request_local_alloc_external(h, NULL));
+ MEM(request = request_local_alloc_external(h, (&(request_init_args_t){ .namespace = dict_radius })));
MEM(u = talloc_zero(request, bio_request_t));
talloc_set_destructor(u, _bio_request_free);
if (!request->parent) {
u->proxied = (request->client->cs != NULL);
- } else if (!fr_dict_compatible(request->parent->dict, request->dict)) {
+ } else if (!fr_dict_compatible(request->parent->proto_dict, request->proto_dict)) {
u->proxied = false;
} else {
if (tmpl_afrom_attr_str(request, NULL, &dst, name,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->proto_dict,
.list_def = request_attr_reply
}
}) <= 0) {
if (tmpl_afrom_attr_str(request, NULL, &dst, name,
&(tmpl_rules_t){
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->proto_dict,
.list_def = request_attr_reply
}
}) <= 0) {
fr_sql_map_ctx_t *map_ctx = talloc_get_type_abort(uctx, fr_sql_map_ctx_t);
tmpl_rules_t lhs_rules = (tmpl_rules_t) {
.attr = {
- .dict_def = request->dict,
+ .dict_def = request->local_dict,
.list_def = map_ctx->list,
.list_presence = TMPL_ATTR_LIST_ALLOW
}
/*
* @todo - MULTI_PROTOCOL - make this protocol agnostic.
- * Perhaps keep stats in a hash table by (request->dict, request->code) ?
+ * Perhaps keep stats in a hash table by (request->proto_dict, request->code) ?
*/
typedef struct {
rlm_stats_data_t *stats;
rlm_stats_data_t mydata;
- if (request->dict != dict_radius) {
+ if (request->proto_dict != dict_radius) {
RWARN("%s can only be called in RADIUS virtual servers", mctx->mi->name);
RETURN_MODULE_NOOP;
}
rlm_stats_data_t mydata;
uint64_t local_stats[NUM_ELEMENTS(inst->mutable->stats)];
- if (request->dict != dict_radius) {
+ if (request->proto_dict != dict_radius) {
RWARN("%s can only be called in RADIUS virtual servers", mctx->mi->name);
RETURN_MODULE_NOOP;
}
* Don't print out debugging messages if we know
* they're useless.
*/
- if ((request->dict == dict_radius) && request->packet->code != FR_RADIUS_CODE_ACCESS_CHALLENGE) {
+ if ((request->proto_dict == dict_radius) && request->packet->code != FR_RADIUS_CODE_ACCESS_CHALLENGE) {
RDEBUG2("No cleartext password in the request. Can't do Yubikey authentication");
}
request->component = "arp";
request->module = NULL;
- fr_assert(request->dict == dict_arp);
+ fr_assert(request->proto_dict == dict_arp);
UPDATE_STATE(packet);
request->component = "bfd";
request->module = NULL;
- fr_assert(request->dict == dict_bfd);
+ fr_assert(request->proto_dict == dict_bfd);
wrapper = (bfd_wrapper_t const *) request->packet->data;
request->component = "dhcpv4";
request->module = NULL;
- fr_assert(request->dict == dict_dhcpv4);
+ fr_assert(request->proto_dict == dict_dhcpv4);
UPDATE_STATE(packet);
* Move the module failure messages upwards
* if requested to by the user.
*/
- if (inst->move_failure_message_to_parent && request->parent && (request->parent->dict == request->dict)) {
+ if (inst->move_failure_message_to_parent && request->parent && (request->parent->proto_dict == request->proto_dict)) {
fr_pair_t const *prev = NULL;
while ((failure_message = fr_pair_find_by_da(&request->request_pairs,
request->component = "dhcpv6";
request->module = NULL;
- fr_assert(request->dict == dict_dhcpv6);
+ fr_assert(request->proto_dict == dict_dhcpv6);
UPDATE_STATE(packet);
request->component = "dns";
request->module = NULL;
- fr_assert(request->dict == dict_dns);
+ fr_assert(request->proto_dict == dict_dns);
UPDATE_STATE(packet);
request->component = "ldap_sync";
request->module = NULL;
- fr_assert(request->dict == dict_ldap_sync);
+ fr_assert(request->proto_dict == dict_ldap_sync);
UPDATE_STATE(packet);
request->component = "radius";
request->module = NULL;
- fr_assert(request->dict == dict_radius);
+ fr_assert(request->proto_dict == dict_radius);
fr_assert(FR_RADIUS_PACKET_CODE_VALID(request->packet->code));
XLAT_ARGS(args, &secret);
- if (request->dict != dict_radius) return XLAT_ACTION_FAIL;
+ if (request->proto_dict != dict_radius) return XLAT_ACTION_FAIL;
MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_BOOL, NULL));
request->component = "tacacs";
request->module = NULL;
- fr_assert(request->dict == dict_tacacs);
+ fr_assert(request->proto_dict == dict_tacacs);
UPDATE_STATE(packet);
request->component = "test";
request->module = NULL;
- fr_assert(request->dict == dict_test);
+ fr_assert(request->proto_dict == dict_test);
UPDATE_STATE(packet);
request->component = "tls";
request->module = NULL;
- fr_assert(request->dict == dict_tls);
+ fr_assert(request->proto_dict == dict_tls);
UPDATE_STATE(packet);
request->component = "radius";
request->module = NULL;
- fr_assert(request->dict == dict_radius);
+ fr_assert(request->proto_dict == dict_radius);
UPDATE_STATE(packet);
request->component = "vmps";
request->module = NULL;
- fr_assert(request->dict == dict_vmps);
+ fr_assert(request->proto_dict == dict_vmps);
UPDATE_STATE(packet);