#define RDEBUG2(fmt, ...) if (do_output && (fr_debug_lvl > 1)) fprintf(fr_log_fp, "(%" PRIu64 ") " fmt "\n", request->num, ## __VA_ARGS__)
typedef struct {
- uint64_t accepted; //!< Requests to which we received a accept
- uint64_t rejected; //!< Requests to which we received a reject
- uint64_t lost; //!< Requests to which we received no response
- uint64_t passed; //!< Requests which passed a filter
- uint64_t failed; //!< Requests which failed a fitler
+ uint64_t accepted; //!< Requests to which we received a accept
+ uint64_t rejected; //!< Requests to which we received a reject
+ uint64_t lost; //!< Requests to which we received no response
+ uint64_t passed; //!< Requests which passed a filter
+ uint64_t failed; //!< Requests which failed a fitler
} rc_stats_t;
typedef struct {
- char const *packets; //!< The file containing the request packet
- char const *filters; //!< The file containing the definition of the
- //!< packet we want to match.
+ char const *packets; //!< The file containing the request packet
+ char const *filters; //!< The file containing the definition of the
+ //!< packet we want to match.
} rc_file_pair_t;
typedef struct rc_request rc_request_t;
struct rc_request {
- uint64_t num; //!< The number (within the file) of the request were reading.
+ uint64_t num; //!< The number (within the file) of the request were reading.
- rc_request_t *prev;
- rc_request_t *next;
+ rc_request_t *prev;
+ rc_request_t *next;
- rc_file_pair_t *files; //!< Request and response file names.
+ rc_file_pair_t *files; //!< Request and response file names.
- fr_pair_t *password; //!< Password.Cleartext
- fr_time_delta_t timestamp;
+ fr_pair_t *password; //!< Password.Cleartext
+ fr_time_delta_t timestamp;
fr_radius_packet_t *packet; //!< The outgoing request.
fr_radius_packet_t *reply; //!< The incoming response.
- fr_pair_list_t filter; //!< If the reply passes the filter, then the request passes.
- FR_CODE filter_code; //!< Expected code of the response packet.
- int resend;
- int tries;
- bool done; //!< Whether the request is complete.
+ fr_pair_list_t *request_list;
+ fr_pair_list_t *reply_list;
- char const *name; //!< Test name (as specified in the request).
+ fr_pair_list_t filter; //!< If the reply passes the filter, then the request passes.
+ FR_CODE filter_code; //!< Expected code of the response packet.
+
+ int resend;
+ int tries;
+ bool done; //!< Whether the request is complete.
+
+ char const *name; //!< Test name (as specified in the request).
};
#ifdef __cplusplus
*/
cs_list = p = cf_section_name2(cs);
if (cs_list && (strcmp(cf_section_name1(cs), "update") == 0)) {
- p += radius_request_name(&our_lhs_rules.request_def, p, REQUEST_CURRENT);
+ p += tmpl_request_ref_by_name(&our_lhs_rules.request_def, p, REQUEST_CURRENT);
if (our_lhs_rules.request_def == REQUEST_UNKNOWN) {
cf_log_err(ci, "Default request specified in mapping section is invalid");
return -1;
/*
* We always put the request pairs into the environment
*/
- input_pairs = tmpl_request_pair_list(request, PAIR_LIST_REQUEST);
+ input_pairs = tmpl_list_head(request, PAIR_LIST_REQUEST);
/*
* Automagically switch output type depending on our destination
if (tmpl_is_list(map->lhs) && tmpl_is_list(map->rhs)) {
fr_pair_list_t *from = NULL;
- if (radius_request(&context, tmpl_request(map->rhs)) == 0) {
- from = tmpl_request_pair_list(context, tmpl_list(map->rhs));
+ if (tmpl_request_ptr(&context, tmpl_request(map->rhs)) == 0) {
+ from = tmpl_list_head(context, tmpl_list(map->rhs));
}
if (!from) return 0;
context = request;
request_ref = tmpl_request(map->lhs);
- if (radius_request(&context, request_ref) < 0) {
+ if (tmpl_request_ptr(&context, request_ref) < 0) {
REDEBUG("Mapping \"%.*s\" -> \"%.*s\" cannot be performed due to invalid request reference \"%s\" in right side of map",
(int)map->rhs->len, map->rhs->name, (int)map->lhs->len, map->lhs->name,
fr_table_str_by_value(tmpl_request_ref_table, request_ref, "<INVALID>"));
}
list_ref = tmpl_list(map->lhs);
- list = tmpl_request_pair_list(context, list_ref);
+ list = tmpl_list_head(context, list_ref);
if (!list) {
REDEBUG("Mapping \"%.*s\" -> \"%.*s\" cannot be performed due to to invalid list qualifier \"%s\" in left side of map",
(int)map->rhs->len, map->rhs->name, (int)map->lhs->len, map->lhs->name,
goto finish;
}
- parent = tmpl_request_pair_list_ctx(context, tmpl_list(map->lhs));
+ parent = tmpl_list_ctx(context, tmpl_list(map->lhs));
fr_assert(parent);
/*
tmpl_pair_list_t list_ref;
request_ref = tmpl_request(src_dst);
- if (radius_request(&context, request_ref) < 0) {
+ if (tmpl_request_ptr(&context, request_ref) < 0) {
REDEBUG("Mapping \"%.*s\" -> \"%.*s\" cannot be performed due to invalid request reference \"%s\"",
(int)map->rhs->len, map->rhs->name, (int)map->lhs->len, map->lhs->name,
fr_table_str_by_value(tmpl_request_ref_table, request_ref, "<INVALID>"));
}
list_ref = tmpl_list(src_dst);
- list = tmpl_request_pair_list(context, list_ref);
+ list = tmpl_list_head(context, list_ref);
if (!list) {
REDEBUG("Mapping \"%.*s\" -> \"%.*s\" cannot be performed due to to invalid list qualifier \"%s\"",
(int)map->rhs->len, map->rhs->name, (int)map->lhs->len, map->lhs->name,
* All this has been checked by #map_to_list_mod
*/
context = request;
- if (!fr_cond_assert(mod && radius_request(&context, tmpl_request(mod->lhs)) == 0)) return -1;
+ if (!fr_cond_assert(mod && tmpl_request_ptr(&context, tmpl_request(mod->lhs)) == 0)) return -1;
- vp_list = tmpl_request_pair_list(context, tmpl_list(mod->lhs));
+ vp_list = tmpl_list_head(context, tmpl_list(mod->lhs));
if (!fr_cond_assert(vp_list)) return -1;
- parent = tmpl_request_pair_list_ctx(context, tmpl_list(mod->lhs));
+ parent = tmpl_list_ctx(context, tmpl_list(mod->lhs));
fr_assert(parent);
/*
#define tmpl_pair_list_AND_CTX(_ctx, _head, _request, _ref, _list) \
do {\
request_t *_rctx = _request; \
- if ((radius_request(&_rctx, _ref) < 0) || \
- !(_head = tmpl_request_pair_list(_rctx, _list)) || \
- !(_ctx = tmpl_request_pair_list_ctx(_rctx, _list))) {\
+ if ((tmpl_request_ptr(&_rctx, _ref) < 0) || \
+ !(_head = tmpl_list_head(_rctx, _list)) || \
+ !(_ctx = tmpl_list_ctx(_rctx, _list))) {\
_ctx = NULL; \
_head = NULL; \
}\
void tmpl_debug(tmpl_t const *vpt);
-fr_pair_list_t *tmpl_request_pair_list(request_t *request, tmpl_pair_list_t list);
+fr_pair_list_t *tmpl_list_head(request_t *request, tmpl_pair_list_t list);
-fr_radius_packet_t *tmpl_request_packet(request_t *request, tmpl_pair_list_t list_name);
+fr_radius_packet_t *tmpl_packet_ptr(request_t *request, tmpl_pair_list_t list_name);
-TALLOC_CTX *tmpl_request_pair_list_ctx(request_t *request, tmpl_pair_list_t list_name);
+TALLOC_CTX *tmpl_list_ctx(request_t *request, tmpl_pair_list_t list_name);
size_t tmpl_pair_list_name(tmpl_pair_list_t *out, char const *name, tmpl_pair_list_t default_list);
-int radius_request(request_t **request, tmpl_request_ref_t name);
+int tmpl_request_ptr(request_t **request, tmpl_request_ref_t name);
-size_t radius_request_name(tmpl_request_ref_t *out, char const *name, tmpl_request_ref_t unknown);
+size_t tmpl_request_ref_by_name(tmpl_request_ref_t *out, char const *name, tmpl_request_ref_t unknown);
tmpl_t *tmpl_init_printf(tmpl_t *vpt, tmpl_type_t type, fr_token_t quote, char const *fmt, ...);
*
* @see tmpl_cursor_init
*/
-fr_pair_list_t *tmpl_request_pair_list(request_t *request, tmpl_pair_list_t list)
+fr_pair_list_t *tmpl_list_head(request_t *request, tmpl_pair_list_t list)
{
if (!request) return NULL;
*
* @see tmpl_pair_list
*/
-TALLOC_CTX *tmpl_request_pair_list_ctx(request_t *request, tmpl_pair_list_t list)
+TALLOC_CTX *tmpl_list_ctx(request_t *request, tmpl_pair_list_t list)
{
if (!request) return NULL;
*
* @see tmpl_pair_list
*/
-fr_radius_packet_t *tmpl_request_packet(request_t *request, tmpl_pair_list_t list)
+fr_radius_packet_t *tmpl_packet_ptr(request_t *request, tmpl_pair_list_t list)
{
switch (list) {
/* Don't add default */
* - 0 if request is valid in this context.
* - -1 if request is not valid in this context.
*/
-int radius_request(request_t **context, tmpl_request_ref_t name)
+int tmpl_request_ptr(request_t **context, tmpl_request_ref_t name)
{
request_t *request = *context;
* Navigate to the correct request context
*/
while ((rr = fr_dlist_next(&vpt->data.attribute.rr, rr))) {
- if (radius_request(&request, rr->request) < 0) {
+ if (tmpl_request_ptr(&request, rr->request) < 0) {
if (err) {
*err = -3;
fr_strerror_printf("Request context \"%s\" not available",
/*
* Get the right list in the specified context
*/
- list_head = tmpl_request_pair_list(request, tmpl_list(vpt));
+ list_head = tmpl_list_head(request, tmpl_list(vpt));
if (!list_head) {
if (err) {
*err = -2;
}
goto error;
}
- list_ctx = tmpl_request_pair_list_ctx(request, tmpl_list(vpt));
+ list_ctx = tmpl_list_ctx(request, tmpl_list(vpt));
/*
* Initialise the temporary cursor context
* Navigate to the correct request context
*/
while ((rr = fr_dlist_next(&vpt->data.attribute.rr, rr))) {
- if (radius_request(&request, rr->request) < 0) {
+ if (tmpl_request_ptr(&request, rr->request) < 0) {
fr_strerror_printf("Request context \"%s\" not available",
fr_table_str_by_value(tmpl_request_ref_table, rr->request, "<INVALID>"));
return -3;
/*
* Get the right list in the specified context
*/
- list_head = tmpl_request_pair_list(request, tmpl_list(vpt));
+ list_head = tmpl_list_head(request, tmpl_list(vpt));
if (!list_head) {
fr_strerror_printf("List \"%s\" not available in this context",
fr_table_str_by_value(pair_list_table, tmpl_list(vpt), "<INVALID>"));
return -2;
}
- list_ctx = tmpl_request_pair_list_ctx(request, tmpl_list(vpt));
+ list_ctx = tmpl_list_ctx(request, tmpl_list(vpt));
/*
* If it's a list, just return the list head
* These functions also resolve #pair_list_t and #tmpl_request_ref_t values to #request_t
* structs and the head of #fr_pair_t lists in those structs.
*
- * For adding new #fr_pair_t to the lists, the #tmpl_request_pair_list_ctx function can be used
+ * For adding new #fr_pair_t to the lists, the #tmpl_list_ctx function can be used
* to obtain the appropriate TALLOC_CTX pointer.
*
* @note These don't really have much to do with #tmpl_t. They're in the same
* @see tmpl_pair_list_name
* @see tmpl_request_ref_table
*/
-size_t radius_request_name(tmpl_request_ref_t *out, char const *name, tmpl_request_ref_t def)
+size_t tmpl_request_ref_by_name(tmpl_request_ref_t *out, char const *name, tmpl_request_ref_t def)
{
char const *p, *q;
* If there's no packet, we can't print any attribute
* referencing it.
*/
- packet = tmpl_request_packet(request, tmpl_list(vpt));
+ packet = tmpl_packet_ptr(request, tmpl_list(vpt));
if (!packet) return XLAT_ACTION_DONE;
if (tmpl_da(vpt) == attr_packet_type) {
}
if (inst->input_list) {
- input_pairs = tmpl_request_pair_list(request, inst->input_list);
+ input_pairs = tmpl_list_head(request, inst->input_list);
if (!input_pairs) {
REDEBUG("Failed to find input pairs for xlat");
return -1;
if (inst->input) {
fr_pair_list_t *input_pairs;
- input_pairs = tmpl_request_pair_list(request, inst->input_list);
+ input_pairs = tmpl_list_head(request, inst->input_list);
if (!input_pairs) {
RETURN_MODULE_INVALID;
}
RDEBUG("EXEC GOT -- %pV", m->box);
- output_pairs = tmpl_request_pair_list(request, inst->output_list);
+ output_pairs = tmpl_list_head(request, inst->output_list);
fr_assert(output_pairs != NULL);
- ctx = tmpl_request_pair_list_ctx(request, inst->output_list);
+ ctx = tmpl_list_ctx(request, inst->output_list);
vps = fr_pair_list_afrom_box(ctx, request->dict, m->box);
if (vps) fr_pair_list_move(output_pairs, &vps);
if (inst->input) {
fr_pair_list_t *input_pairs;
- input_pairs = tmpl_request_pair_list(request, inst->input_list);
+ input_pairs = tmpl_list_head(request, inst->input_list);
if (!input_pairs) RETURN_MODULE_INVALID;
env_pairs = *input_pairs;
}
if (inst->output) {
- if (!tmpl_request_pair_list(request, inst->output_list)) {
+ if (!tmpl_list_head(request, inst->output_list)) {
RETURN_MODULE_INVALID;
}
}
}
count = ldap_count_values_len(values);
- list = tmpl_request_pair_list(request, PAIR_LIST_CONTROL);
- list_ctx = tmpl_request_pair_list_ctx(request, PAIR_LIST_CONTROL);
+ list = tmpl_list_head(request, PAIR_LIST_CONTROL);
+ list_ctx = tmpl_list_ctx(request, PAIR_LIST_CONTROL);
fr_assert(list != NULL);
fr_assert(list_ctx != NULL);
continue;
}
- if (radius_request(&request, tmpl_request(dst)) < 0) {
+ if (tmpl_request_ptr(&request, tmpl_request(dst)) < 0) {
ERROR("Attribute name %s refers to outer request but not in a tunnel, skipping...", ckey);
talloc_free(dst);
continue;
continue;
}
- if (radius_request(¤t, tmpl_request(dst)) < 0) {
+ if (tmpl_request_ptr(¤t, tmpl_request(dst)) < 0) {
ERROR("%s - Attribute name %s.%s refers to outer request but not in a tunnel, skipping...",
funcname, list_name, s1);
talloc_free(dst);
goto skip;
}
- if (radius_request(¤t, tmpl_request(dst)) < 0) {
+ if (tmpl_request_ptr(¤t, tmpl_request(dst)) < 0) {
RWDEBUG("Attribute name refers to outer request but not in a tunnel (skipping)");
talloc_free(dst);
goto skip;
}
- vps = tmpl_request_pair_list(current, tmpl_list(dst));
+ vps = tmpl_list_head(current, tmpl_list(dst));
if (!vps) {
RWDEBUG("List not valid in this context (skipping)");
talloc_free(dst);
goto skip;
}
- ctx = tmpl_request_pair_list_ctx(current, tmpl_list(dst));
+ ctx = tmpl_list_ctx(current, tmpl_list(dst));
da = tmpl_da(dst);
fr_assert(vps);
continue;
}
- if (radius_request(¤t, tmpl_request(dst)) < 0) {
+ if (tmpl_request_ptr(¤t, tmpl_request(dst)) < 0) {
RWDEBUG("Attribute name refers to outer request but not in a tunnel (skipping)");
continue;
}
- vps = tmpl_request_pair_list(current, tmpl_list(dst));
+ vps = tmpl_list_head(current, tmpl_list(dst));
if (!vps) {
RWDEBUG("List not valid in this context (skipping)");
continue;
}
- ctx = tmpl_request_pair_list_ctx(current, tmpl_list(dst));
+ ctx = tmpl_list_ctx(current, tmpl_list(dst));
/*
* Alternative JSON structure which allows operator,