Originally fr_pair_list_t was the same as fr_dlist_head_t, but no longer.
if (fr_debug_lvl > 1) fr_dhcpv4_print_hex(stdout, reply->data, reply->data_len);
- fr_dcursor_init(&cursor, &reply_vps);
+ fr_dcursor_init(&cursor, fr_pair_list_order(&reply_vps));
if (fr_dhcpv4_decode(reply, &reply_vps, reply->data, reply->data_len, &reply->code) < 0) {
ERROR("Failed decoding reply");
return NULL;
last_match = fr_pair_list_head(vps);
- fr_dcursor_init(&list_cursor, vps);
+ fr_dcursor_init(&list_cursor, fr_pair_list_order(vps));
for (i = 0; i < num; i++) {
match = fr_dcursor_filter_next(&list_cursor, fr_pair_matches_da, da[i]);
if (!match) {
* attribute grouping to coalesce all related index
* attributes under a single request OID.
*/
- for (vp = fr_dcursor_init(&cursor, head);
+ for (vp = fr_dcursor_init(&cursor, fr_pair_list_order(head));
vp;
vp = fr_dcursor_next(&cursor)) {
fr_dict_attr_t const *common;
return EXIT_FAILURE;
}
fr_pair_list_init(&request_vps);
- fr_dcursor_init(&cursor, &request_vps);
+ fr_dcursor_init(&cursor, fr_pair_list_order(&request_vps));
NEXT_LINE(line, buffer);
#endif
}
- for (vp = fr_dcursor_talloc_iter_init(&cursor, &head,
+ for (vp = fr_dcursor_talloc_iter_init(&cursor, fr_pair_list_order(&head),
tp->next_encodable ? tp->next_encodable : fr_proto_next_encodable,
cc->tmpl_rules.dict_def ? cc->tmpl_rules.dict_def : cc->config->dict, fr_pair_t);
vp;
ctx.ctx = cc->tmp_ctx;
ctx.parent = fr_dict_root(cc->tmpl_rules.dict_def);
ctx.cursor = &cursor;
- fr_dcursor_init(&cursor, &head);
+ fr_dcursor_init(&cursor, fr_pair_list_order(&head));
p = in;
end = in + inlen;
}
};
- for (vp = fr_dcursor_init(&cursor, &request->request_pairs);
+ for (vp = fr_dcursor_init(&cursor, fr_pair_list_order(&request->request_pairs));
vp;
vp = fr_dcursor_next(&cursor)) {
/*
} /* loop over the VP's we read in */
if (fr_debug_lvl) {
- for (vp = fr_dcursor_init(&cursor, &request->request_pairs);
+ for (vp = fr_dcursor_init(&cursor, fr_pair_list_order(&request->request_pairs));
vp;
vp = fr_dcursor_next(&cursor)) {
/*
dv = fr_dict_enum_by_value(attr_packet_type, fr_box_uint32(packet->code));
if (dv) fprintf(fp, "%s\n", dv->name);
- for (vp = fr_dcursor_init(&cursor, list);
+ for (vp = fr_dcursor_init(&cursor, fr_pair_list_order(list));
vp;
vp = fr_dcursor_next(&cursor)) {
/*
ptr += 4;
end = ptr + total;
- fr_dcursor_init(&cursor, &request->reply_pairs);
+ fr_dcursor_init(&cursor, fr_pair_list_order(&request->reply_pairs));
while ((vp = fr_dcursor_current(&cursor)) && (ptr < end)) {
/*
* Skip things which shouldn't be in channel bindings.
* Group attributes with similar lineages together
*/
fr_pair_list_sort(to_encode, fr_pair_cmp_by_parent_num);
- if (fr_dcursor_init(&cursor, to_encode) == vp) fr_dcursor_next(&cursor); /* Skip subtype if it came out first */
+ if (fr_dcursor_init(&cursor, fr_pair_list_order(to_encode)) == vp) {
+ fr_dcursor_next(&cursor); /* Skip subtype if it came out first */
+ }
/*
* Will we need to generate a HMAC?
case FR_EAP_METHOD_SIM:
case FR_EAP_METHOD_AKA:
case FR_EAP_METHOD_AKA_PRIME:
- fr_dcursor_init(&cursor, &request->request_pairs);
+ fr_dcursor_init(&cursor, fr_pair_list_order(&request->request_pairs));
decode_ctx = mod_session->ctx;
decode_ctx.hmac_extra = mod_session->response_hmac_extra;
}
fr_pair_list_copy(NULL, &args, &ef->trigger_args);
- fr_dcursor_init(&cursor, &args);
+ fr_dcursor_init(&cursor, fr_pair_list_order(&args));
MEM(vp = fr_pair_afrom_da(NULL, da));
fr_pair_value_strdup(vp, entry->filename);
*/
if (tmpl_copy_pairs(ctx, &found, request, map->rhs) < 0) return 0;
- vp = fr_dcursor_init(&from, &found);
+ vp = fr_dcursor_init(&from, fr_pair_list_order(&found));
/*
* Src/Dst attributes don't match, convert src attributes
return 0; /* No pairs returned */
}
- (void)fr_dcursor_init(&from, &vp_head);
+ (void)fr_dcursor_init(&from, fr_pair_list_order(&vp_head));
while ((vp = fr_dcursor_remove(&from))) {
map_t *mod;
tmpl_rules_t rules;
map_list_mod_to_vps(parent, &vp_from, vlm);
if (fr_pair_list_empty(&vp_from)) goto finish;
- fr_dcursor_init(&from, &vp_from);
- fr_dcursor_init(&to_insert, &vp_to_insert);
- fr_dcursor_init(&to, vp_list);
+ fr_dcursor_init(&from, fr_pair_list_order(&vp_from));
+ fr_dcursor_init(&to_insert, fr_pair_list_order(&vp_to_insert));
+ fr_dcursor_init(&to, fr_pair_list_order(vp_list));
while ((vp = fr_dcursor_remove(&from))) {
for (vp_to = fr_dcursor_head(&to);
map_list_mod_to_vps(parent, &vp_from, vlm);
if (fr_pair_list_empty(&vp_from)) goto finish;
- fr_dcursor_init(&from, &vp_from);
+ fr_dcursor_init(&from, fr_pair_list_order(&vp_from));
fr_dcursor_merge(&list, &from); /* Merge first (insert after current attribute) */
fr_dcursor_free_item(&list); /* Then free the current attribute */
fr_pair_t *op;
fr_pair_list_init(&head);
- fr_dcursor_init(&request_cursor, &request->request_pairs);
+ fr_dcursor_init(&request_cursor, fr_pair_list_order(&request->request_pairs));
fr_dcursor_iter_by_da_init(&op_cursor, &request->request_pairs, attr_snmp_operation);
- fr_dcursor_init(&reply_cursor, &request->reply_pairs);
- fr_dcursor_init(&out_cursor, &head);
+ fr_dcursor_init(&reply_cursor, fr_pair_list_order(&request->reply_pairs));
+ fr_dcursor_init(&out_cursor, fr_pair_list_order(&head));
RDEBUG2("Processing SNMP stats request");
* by the state context.
*/
if (entry->ctx) {
- for (vp = fr_dcursor_init(&cursor, &entry->ctx->children);
+ for (vp = fr_dcursor_init(&cursor, fr_pair_list_order(&entry->ctx->children));
vp;
vp = fr_dcursor_next(&cursor)) {
fr_assert(entry->ctx == talloc_parent(vp));
.func = _tmpl_cursor_child_eval,
.list_ctx = list_ctx
};
- fr_dcursor_init(&ns->group.cursor, list);
+ fr_dcursor_init(&ns->group.cursor, fr_pair_list_order(list));
fr_dlist_insert_tail(&cc->nested, ns);
}
list_head = &vp->vp_group;
_tmpl_pair_cursor_init(vp, list_head, ar, cc);
curr = fr_pair_list_head(list_head);
- list = &list_head->order;
+ list = UNCONST(fr_dlist_head_t *, fr_pair_list_order(list_head));
continue;
}
/*
* Get the first entry from the tmpl
*/
- vp = fr_dcursor_talloc_iter_init(cursor, list_head, _tmpl_cursor_next, cc, fr_pair_t);
+ vp = fr_dcursor_talloc_iter_init(cursor, fr_pair_list_order(list_head), _tmpl_cursor_next, cc, fr_pair_t);
if (!vp) {
if (err) {
*err = -1;
* Encode the session-state contents and
* add it to the ticket.
*/
- for (vp = fr_dcursor_init(&dcursor, &request->session_state_pairs);
+ for (vp = fr_dcursor_init(&dcursor, fr_pair_list_order(&request->session_state_pairs));
vp;
vp = fr_dcursor_current(&dcursor)) {
slen = fr_internal_encode_pair(&dbuff, &dcursor, NULL);
foreach->request = request;
foreach->depth = foreach_depth;
fr_pair_list_append(&foreach->vps, &vps);
- fr_dcursor_talloc_init(&foreach->cursor, &foreach->vps, fr_pair_t);
+ fr_dcursor_talloc_init(&foreach->cursor, fr_pair_list_order(&foreach->vps), fr_pair_t);
#ifndef NDEBUG
foreach->indent = request->log.unlang_indent;
#endif
fr_dlist_head_t order; //!< Maintains the relative order of pairs in a list.
} fr_pair_list_t;
+static inline fr_dlist_head_t _CONST *fr_pair_list_order(fr_pair_list_t _CONST *list)
+{
+ return &list->order;
+}
+
/** Stores an attribute, a value and various bits of other data
*
* fr_pair_ts are the main data structure used in the server
*/
our_out = FR_SBUFF_NO_ADVANCE(out);
FR_SBUFF_IN_CHAR_RETURN(&our_out, '{', ' ');
- for (child = fr_dcursor_init(&cursor, &vp->vp_group);
+ for (child = fr_dcursor_init(&cursor, fr_pair_list_order(&vp->vp_group));
child != NULL;
child = fr_dcursor_next(&cursor)) {
FR_SBUFF_RETURN(fr_pair_print, &our_out, vp, child);
fr_pair_append(&local_pairs, fr_pair_afrom_da(autofree, fr_dict_attr_test_tlv));
/* lets' count */
- for (vp = fr_dcursor_init(&cursor, &local_pairs);
+ for (vp = fr_dcursor_init(&cursor, fr_pair_list_order(&local_pairs));
vp;
vp = fr_dcursor_next(&cursor)) count++;
TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, fr_dict_attr_test_string) == 0);
/* lets' count */
- for (vp = fr_dcursor_init(&cursor, &local_pairs);
+ for (vp = fr_dcursor_init(&cursor, fr_pair_list_order(&local_pairs));
vp;
vp = fr_dcursor_next(&cursor)) {
TEST_CASE("Expected (vp->da == fr_dict_attr_test_string)");
TEST_CHECK(fr_pair_list_copy_by_da(autofree, &local_pairs, &test_pairs, fr_dict_attr_test_string, 0) > 0);
TEST_CASE("The 'local_pairs' should have only fr_dict_attr_test_string");
- for (vp = fr_dcursor_init(&cursor, &local_pairs);
+ for (vp = fr_dcursor_init(&cursor, fr_pair_list_order(&local_pairs));
vp;
vp = fr_dcursor_next(&cursor)) {
TEST_CASE("Validating VP_VERIFY()");
TEST_CHECK(fr_pair_list_copy_by_ancestor(autofree, &local_pairs, &test_pairs, fr_dict_attr_test_tlv, 0) > 0);
TEST_CASE("The 'local_pairs' should have only fr_dict_attr_test_tlv_string (ancestor of 'Test-TLV-Root'");
- for (vp = fr_dcursor_init(&cursor, &local_pairs);
+ for (vp = fr_dcursor_init(&cursor, fr_pair_list_order(&local_pairs));
vp;
vp = fr_dcursor_next(&cursor)) {
TEST_CASE("Validating VP_VERIFY()");
fr_pair_list_sort(&local_pairs, fr_pair_cmp_by_da);
TEST_CASE("1st (da == fr_dict_attr_test_string)");
- TEST_CHECK((vp = fr_dcursor_init(&cursor, &local_pairs)) != NULL);
+ TEST_CHECK((vp = fr_dcursor_init(&cursor, fr_pair_list_order(&local_pairs))) != NULL);
TEST_CHECK(vp && vp->da == fr_dict_attr_test_string);
TEST_CASE("2nd (da == fr_dict_attr_test_octets)");
fr_pair_t *sorted = fr_dcursor_current(parent_cursor); /* NOT const */
fr_pair_list_sort(&sorted->vp_group, pair_sort_increasing);
- fr_dcursor_init(&child_cursor, &sorted->vp_group);
+ fr_dcursor_init(&child_cursor, fr_pair_list_order(&sorted->vp_group));
/*
* Build the da_stack for the new structure.
}
lineno = 1;
- fr_dcursor_init(&cursor, &request->request_pairs);
+ fr_dcursor_init(&cursor, fr_pair_list_order(&request->request_pairs));
fr_dcursor_tail(&cursor); /* Ensure we only free what we add on error */
fr_pair_list_init(&tmp_list);
request->reply->socket.inet.src_ipaddr = client->src_ipaddr;
}
- fr_dcursor_talloc_iter_init(&cursor, &request->reply_pairs, fr_proto_next_encodable, dict_vmps, fr_pair_t);
+ fr_dcursor_talloc_iter_init(&cursor, fr_pair_list_order(&request->reply_pairs), fr_proto_next_encodable, dict_vmps, fr_pair_t);
data_len = fr_vmps_encode(&FR_DBUFF_TMP(buffer, buffer_len), request->packet->data,
request->reply->code, request->reply->id, &cursor);
/*
* Clear control attributes
*/
- for (vp = fr_dcursor_init(&cursor, &request->control_pairs);
+ for (vp = fr_dcursor_init(&cursor, fr_pair_list_order(&request->control_pairs));
vp;
vp = fr_dcursor_next(&cursor)) {
again:
/*
* Add the tunneled attributes to the request request.
*/
- fr_dcursor_init(&cursor, &request->request_pairs);
+ fr_dcursor_init(&cursor, fr_pair_list_order(&request->request_pairs));
if (eap_ttls_decode_pair(request, request->request_ctx, &cursor, fr_dict_root(fr_dict_internal()),
data, data_len, tls_session->ssl) < 0) {
RPEDEBUG("Decoding TTLS TLVs failed");
t->type->vp_uint32 = (uint32_t) type;
t->lvl->vp_uint32 = (uint32_t) lvl;
- fr_dcursor_init(&cursor, &request->request_pairs);
+ fr_dcursor_init(&cursor, fr_pair_list_order(&request->request_pairs));
fr_dcursor_prepend(&cursor, t->msg);
fr_dcursor_prepend(&cursor, t->type);
fr_dcursor_prepend(&cursor, t->lvl);
REDEBUG("Failed allocating user data to hold cursor");
return -1;
}
- fr_dcursor_init(cursor, &request->request_pairs); /* @FIXME: Shouldn't use list head */
+ fr_dcursor_init(cursor, fr_pair_list_order(&request->request_pairs)); /* @FIXME: Shouldn't use list head */
lua_pushlightuserdata(L, cursor);
lua_pushcclosure(L, _lua_list_iterator, 1);
/* Attribute list table */
fr_pair_list_sort(&request->request_pairs, fr_pair_cmp_by_da);
- fr_dcursor_init(&cursor, &request->request_pairs);
+ fr_dcursor_init(&cursor, fr_pair_list_order(&request->request_pairs));
/*
* Setup the environment
RINDENT();
fr_pair_list_sort(vps, fr_pair_cmp_by_da);
- for (vp = fr_dcursor_init(&cursor, vps);
+ for (vp = fr_dcursor_init(&cursor, fr_pair_list_order(vps));
vp;
vp = fr_dcursor_next(&cursor)) {
fr_pair_t *next;
case REST_HTTP_BODY_POST:
rest_request_init(section, request, &ctx->request);
- fr_dcursor_init(&(ctx->request.cursor), &request->request_pairs);
+ fr_dcursor_init(&(ctx->request.cursor), fr_pair_list_order(&request->request_pairs));
if (rest_request_config_body(inst, section, request, randle, rest_encode_post) < 0) return -1;
/*
* Find the first attribute which is parented by ARP-Packet.
*/
- for (vp = fr_dcursor_init(&cursor, vps);
+ for (vp = fr_dcursor_init(&cursor, fr_pair_list_order(vps));
vp;
vp = fr_dcursor_next(&cursor)) {
if (vp->da->parent == attr_arp_packet) break;
* operates correctly. This changes the order of the list, but never mind...
*/
fr_pair_list_sort(vps, fr_dhcpv4_attr_cmp);
- fr_dcursor_talloc_iter_init(&cursor, vps, fr_proto_next_encodable, dict_dhcpv4, fr_pair_t);
+ fr_dcursor_talloc_iter_init(&cursor, fr_pair_list_order(vps), fr_proto_next_encodable, dict_dhcpv4, fr_pair_t);
/*
* Each call to fr_dhcpv4_encode_option will encode one complete DHCP option,
case FR_TYPE_STRUCTURAL:
break;
- default:
+ default:
fr_strerror_printf("Internal sanity check failed");
return -1;
}
}
do_child:
- fr_dcursor_init(&child_cursor, &vp->vp_group);
+ fr_dcursor_init(&child_cursor, fr_pair_list_order(&vp->vp_group));
work_dbuff = FR_DBUFF(dbuff);
while ((vp = fr_dcursor_current(&child_cursor)) != NULL) {
packet_ctx.original = original;
packet_ctx.original_length = length;
- fr_dcursor_talloc_iter_init(&cursor, vps, fr_dhcpv6_next_encodable, dict_dhcpv6, fr_pair_t);
+ fr_dcursor_talloc_iter_init(&cursor, fr_pair_list_order(vps), fr_dhcpv6_next_encodable, dict_dhcpv6, fr_pair_t);
while ((fr_dbuff_extend(&frame_dbuff) > 0) && (fr_dcursor_current(&cursor) != NULL)) {
slen = fr_dhcpv6_encode_option(&frame_dbuff, &cursor, &packet_ctx);
switch (slen) {
* Encode the child options.
*/
if (!fr_pair_list_empty(&vp->vp_group)) {
- (void) fr_dcursor_init(&child_cursor, &vp->vp_group);
+ (void) fr_dcursor_init(&child_cursor, fr_pair_list_order(&vp->vp_group));
while (fr_dcursor_current(&child_cursor) != NULL) {
slen = fr_dhcpv6_encode_option(&work_dbuff, &child_cursor, encode_ctx);
}
do_child:
- fr_dcursor_init(&child_cursor, &vp->vp_group);
+ fr_dcursor_init(&child_cursor, fr_pair_list_order(&vp->vp_group));
work_dbuff = FR_DBUFF(dbuff);
while ((vp = fr_dcursor_current(&child_cursor)) != NULL) {
if (vp->da->type == FR_TYPE_STRUCT) {
fr_dcursor_t child_cursor;
- fr_dcursor_init(&child_cursor, &vp->vp_group);
+ fr_dcursor_init(&child_cursor, fr_pair_list_order(&vp->vp_group));
slen = fr_struct_to_network(&work_dbuff, da_stack, depth, &child_cursor, encode_ctx, encode_value_trampoline, encode_tlv);
if (slen < 0) return slen;
}
do_child:
- fr_dcursor_init(&child_cursor, &vp->vp_group);
+ fr_dcursor_init(&child_cursor, fr_pair_list_order(&vp->vp_group));
work_dbuff = FR_DBUFF(dbuff);
while ((vp = fr_dcursor_current(&child_cursor)) != NULL) {
if (vp->da->type == FR_TYPE_STRUCT) {
fr_dcursor_t child_cursor;
- fr_dcursor_init(&child_cursor, &vp->vp_group);
+ fr_dcursor_init(&child_cursor, fr_pair_list_order(&vp->vp_group));
slen = fr_struct_to_network(&work_dbuff, &da_stack, 0, &child_cursor, encode_ctx, encode_value_trampoline, NULL);
if (slen <= 0) return slen;
ssize_t slen;
fr_dcursor_t child_cursor;
- fr_dcursor_init(&child_cursor, &vp->vp_group);
+ fr_dcursor_init(&child_cursor, fr_pair_list_order(&vp->vp_group));
slen = fr_struct_to_network(&work_dbuff, da_stack, 0, &child_cursor, packet_ctx, encode_value_trampoline, NULL);
if (slen <= 0) return slen;
/*
* Encode the header.
*/
- fr_dcursor_init(&child_cursor, &vp->vp_group);
+ fr_dcursor_init(&child_cursor, fr_pair_list_order(&vp->vp_group));
fr_proto_da_stack_build(&da_stack, attr_dns_packet);
slen = fr_struct_to_network(&work_dbuff, &da_stack, 0, &cursor, packet_ctx, encode_value_trampoline, NULL);
* we need to do an intermediary TLV
* VP to retain the nesting structure.
*/
- if (fr_dcursor_init(&cursor, &children) && fr_dcursor_next(&cursor)) {
+ if (fr_dcursor_init(&cursor, fr_pair_list_order(&children)) && fr_dcursor_next(&cursor)) {
fr_pair_t *tlv;
tlv = fr_pair_afrom_da(ctx, parent_da);
fr_dcursor_t children;
fr_pair_t *child;
- for (child = fr_dcursor_talloc_init(&children, &vp->vp_group, fr_pair_t);
+ for (child = fr_dcursor_talloc_init(&children, fr_pair_list_order(&vp->vp_group), fr_pair_t);
child;
child = fr_dcursor_current(&children)) {
{
fr_dcursor_t children;
- for (vp = fr_dcursor_talloc_init(&children, &vp->vp_group, fr_pair_t);
+ for (vp = fr_dcursor_talloc_init(&children, fr_pair_list_order(&vp->vp_group), fr_pair_t);
vp;
vp = fr_dcursor_current(&children)) {
FR_PROTO_TRACE("encode ctx changed %s -> %s", da->name, vp->da->name);
/*
* Loop over the reply attributes for the packet.
*/
- fr_dcursor_talloc_iter_init(&cursor, vps, fr_radius_next_encodable, dict_radius, fr_pair_t);
+ fr_dcursor_talloc_iter_init(&cursor, fr_pair_list_order(vps), fr_radius_next_encodable, dict_radius, fr_pair_t);
while ((vp = fr_dcursor_current(&cursor))) {
VP_VERIFY(vp);
return PAIR_ENCODE_SKIPPED;
}
- fr_dcursor_init(&child_cursor, &vp->vp_group);
+ fr_dcursor_init(&child_cursor, fr_pair_list_order(&vp->vp_group));
vp = fr_dcursor_current(&child_cursor);
fr_proto_da_stack_build(da_stack, vp->da);
/*
* Note that we skip tags inside of tags!
*/
- fr_dcursor_talloc_iter_init(&cursor, vps, fr_proto_next_encodable, dict_radius, fr_pair_t);
+ fr_dcursor_talloc_iter_init(&cursor, fr_pair_list_order(vps),
+ fr_proto_next_encodable, dict_radius, fr_pair_t);
while ((vp = fr_dcursor_current(&cursor))) {
VP_VERIFY(vp);
fr_assert(vp->da == da);
work_dbuff = FR_DBUFF(dbuff);
- fr_dcursor_init(&child_cursor, &vp->vp_group);
+ fr_dcursor_init(&child_cursor, fr_pair_list_order(&vp->vp_group));
while ((vp = fr_dcursor_current(&child_cursor)) != NULL) {
fr_proto_da_stack_build(da_stack, vp->da);
* Loop over the children of this Vendor-Specific
* attribute.
*/
- fr_dcursor_init(&child_cursor, &vp->vp_group);
+ fr_dcursor_init(&child_cursor, fr_pair_list_order(&vp->vp_group));
while ((vp = fr_dcursor_current(&child_cursor)) != NULL) {
fr_proto_da_stack_build(da_stack, vp->da);
/*
* Find the first attribute which is parented by TACACS-Packet.
*/
- for (vp = fr_dcursor_init(&cursor, vps);
+ for (vp = fr_dcursor_init(&cursor, fr_pair_list_order(vps));
vp;
vp = fr_dcursor_next(&cursor)) {
if (vp->da->parent == attr_tacacs_packet) break;
{
fr_dcursor_t cursor;
- fr_dcursor_talloc_iter_init(&cursor, vps, fr_proto_next_encodable, dict_vmps, fr_pair_t);
+ fr_dcursor_talloc_iter_init(&cursor, fr_pair_list_order(vps), fr_proto_next_encodable, dict_vmps, fr_pair_t);
return fr_vmps_encode(&FR_DBUFF_TMP(data, data_len), NULL, -1, -1, &cursor);
}