From: Arran Cudbard-Bell Date: Fri, 15 Sep 2017 06:05:04 +0000 (+0700) Subject: Swap out more calls to use the new cursor api X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4219dcd6b41c1984235cebb297dce21692f0efe2;p=thirdparty%2Ffreeradius-server.git Swap out more calls to use the new cursor api --- diff --git a/src/lib/util/pair.c b/src/lib/util/pair.c index 80d5e504eae..e16b327cb93 100644 --- a/src/lib/util/pair.c +++ b/src/lib/util/pair.c @@ -536,15 +536,15 @@ VALUE_PAIR *fr_pair_make(TALLOC_CTX *ctx, VALUE_PAIR **vps, void fr_pair_list_free(VALUE_PAIR **vps) { VALUE_PAIR *vp; - vp_cursor_t cursor; + fr_cursor_t cursor; if (!vps || !*vps) { return; } - for (vp = fr_pair_cursor_init(&cursor, vps); + for (vp = fr_cursor_init(&cursor, vps); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { VP_VERIFY(vp); talloc_free(vp); } @@ -564,14 +564,11 @@ int fr_pair_to_unknown(VALUE_PAIR *vp) fr_dict_attr_t const *da; VP_VERIFY(vp); - if (vp->da->flags.is_unknown) { - return 0; - } + if (vp->da->flags.is_unknown) return 0; da = fr_dict_unknown_afrom_fields(vp, vp->da->parent, vp->da->vendor, vp->da->attr); if (!da) return -1; - fr_dict_unknown_free(&vp->da); /* Only frees unknown attributes */ vp->da = da; @@ -620,7 +617,7 @@ VALUE_PAIR *fr_pair_find_by_da(VALUE_PAIR *head, fr_dict_attr_t const *da, int8_ { vp_cursor_t cursor; - if(!fr_cond_assert(da)) return NULL; + if (!fr_cond_assert(da)) return NULL; (void) fr_pair_cursor_init(&cursor, &head); return fr_pair_cursor_next_by_da(&cursor, da, tag); @@ -1037,12 +1034,12 @@ int fr_pair_cmp(VALUE_PAIR *a, VALUE_PAIR *b) */ int fr_pair_list_cmp(VALUE_PAIR *a, VALUE_PAIR *b) { - vp_cursor_t a_cursor, b_cursor; + fr_cursor_t a_cursor, b_cursor; VALUE_PAIR *a_p, *b_p; - for (a_p = fr_pair_cursor_init(&a_cursor, &a), b_p = fr_pair_cursor_init(&b_cursor, &b); + for (a_p = fr_cursor_init(&a_cursor, &a), b_p = fr_cursor_init(&b_cursor, &b); a_p && b_p; - a_p = fr_pair_cursor_next(&a_cursor), b_p = fr_pair_cursor_next(&b_cursor)) { + a_p = fr_cursor_next(&a_cursor), b_p = fr_cursor_next(&b_cursor)) { int ret; /* Same VP, no point doing expensive checks */ @@ -1213,8 +1210,8 @@ void fr_pair_validate_debug(TALLOC_CTX *ctx, VALUE_PAIR const *failed[2]) */ bool fr_pair_validate(VALUE_PAIR const *failed[2], VALUE_PAIR *filter, VALUE_PAIR *list) { - vp_cursor_t filter_cursor; - vp_cursor_t list_cursor; + fr_cursor_t filter_cursor; + fr_cursor_t list_cursor; VALUE_PAIR *check, *match; @@ -1231,8 +1228,8 @@ bool fr_pair_validate(VALUE_PAIR const *failed[2], VALUE_PAIR *filter, VALUE_PAI fr_pair_list_sort(&filter, fr_pair_cmp_by_da_tag); fr_pair_list_sort(&list, fr_pair_cmp_by_da_tag); - check = fr_pair_cursor_init(&filter_cursor, &filter); - match = fr_pair_cursor_init(&list_cursor, &list); + check = fr_cursor_init(&filter_cursor, &filter); + match = fr_cursor_init(&list_cursor, &list); while (match || check) { /* * Lists are of different lengths @@ -1255,8 +1252,8 @@ bool fr_pair_validate(VALUE_PAIR const *failed[2], VALUE_PAIR *filter, VALUE_PAI */ if (fr_pair_cmp(check, match) != 1) goto mismatch; - check = fr_pair_cursor_next(&filter_cursor); - match = fr_pair_cursor_next(&list_cursor); + check = fr_cursor_next(&filter_cursor); + match = fr_cursor_next(&list_cursor); } return true; diff --git a/src/main/auth.c b/src/main/auth.c index 3ecdaabb834..62a69001a83 100644 --- a/src/main/auth.c +++ b/src/main/auth.c @@ -164,11 +164,11 @@ static int rad_authlog(char const *msg, REQUEST *request, int goodpass) */ static int CC_HINT(nonnull) rad_check_password(REQUEST *request) { - vp_cursor_t cursor; - VALUE_PAIR *auth_type_pair; - int auth_type = -1; - int result; - int auth_type_count = 0; + vp_cursor_t cursor; + VALUE_PAIR *auth_type_pair; + int auth_type = -1; + int result; + int auth_type_count = 0; /* * Look for matching check items. We skip the whole lot diff --git a/src/main/command.c b/src/main/command.c index 3250c83ea00..fae85a2137d 100644 --- a/src/main/command.c +++ b/src/main/command.c @@ -1754,7 +1754,7 @@ static int null_socket_dencode(UNUSED rad_listen_t *listener, UNUSED REQUEST *re static int null_socket_send(UNUSED rad_listen_t *listener, REQUEST *request) { - vp_cursor_t cursor; + fr_cursor_t cursor; char *output_file; FILE *fp; @@ -1790,9 +1790,9 @@ static int null_socket_send(UNUSED rad_listen_t *listener, REQUEST *request) } RINDENT(); - for (vp = fr_pair_cursor_init(&cursor, &request->reply->vps); + for (vp = fr_cursor_init(&cursor, &request->reply->vps); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { fr_pair_snprint(buffer, sizeof(buffer), vp); fprintf(fp, "%s\n", buffer); RDEBUG("%s", buffer); @@ -1903,17 +1903,17 @@ static int command_inject_from(rad_listen_t *listener, int argc, char *argv[]) static int command_inject_file(rad_listen_t *listener, int argc, char *argv[]) { - static int inject_id = 0; - int ret; - bool filedone; - fr_command_socket_t *sock = listener->data; - rad_listen_t *fake; - RADIUS_PACKET *packet; - vp_cursor_t cursor; - VALUE_PAIR *vp; - FILE *fp; - RAD_REQUEST_FUNP fun = NULL; - char buffer[2048]; + static int inject_id = 0; + int ret; + bool filedone; + fr_command_socket_t *sock = listener->data; + rad_listen_t *fake; + RADIUS_PACKET *packet; + vp_cursor_t cursor; + VALUE_PAIR *vp; + FILE *fp; + RAD_REQUEST_FUNP fun = NULL; + char buffer[2048]; if (argc < 2) { cprintf_error(listener, "You must specify \n"); @@ -1993,9 +1993,9 @@ static int command_inject_file(rad_listen_t *listener, int argc, char *argv[]) buffer, sizeof(buffer)), packet->code, packet->id); - for (vp = fr_pair_cursor_init(&cursor, &packet->vps); + for (vp = fr_cursor_init(&cursor, &packet->vps); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { fr_pair_snprint(buffer, sizeof(buffer), vp); DEBUG("\t%s", buffer); } diff --git a/src/main/cond_eval.c b/src/main/cond_eval.c index 2e52f8cfdd4..96828bc7621 100644 --- a/src/main/cond_eval.c +++ b/src/main/cond_eval.c @@ -770,15 +770,15 @@ int cond_eval(REQUEST *request, int modreturn, int depth, fr_cond_t const *c) */ void radius_pairmove(REQUEST *request, VALUE_PAIR **to, VALUE_PAIR *from, bool do_xlat) { - int i, j, count, from_count, to_count, tailto; - vp_cursor_t cursor; - VALUE_PAIR *vp, *next, **last; - VALUE_PAIR **from_list, **to_list; - VALUE_PAIR *append, **append_tail; - VALUE_PAIR *to_copy; - bool *edited = NULL; - REQUEST *fixup = NULL; - TALLOC_CTX *ctx; + int i, j, count, from_count, to_count, tailto; + fr_cursor_t cursor; + VALUE_PAIR *vp, *next, **last; + VALUE_PAIR **from_list, **to_list; + VALUE_PAIR *append, **append_tail; + VALUE_PAIR *to_copy; + bool *edited = NULL; + REQUEST *fixup = NULL; + TALLOC_CTX *ctx; /* * Set up arrays for editing, to remove some of the @@ -802,10 +802,10 @@ void radius_pairmove(REQUEST *request, VALUE_PAIR **to, VALUE_PAIR *from, bool d * the matching attributes are deleted. */ count = 0; - for (vp = fr_pair_cursor_init(&cursor, &from); vp; vp = fr_pair_cursor_next(&cursor)) count++; + for (vp = fr_cursor_init(&cursor, &from); vp; vp = fr_cursor_next(&cursor)) count++; from_list = talloc_array(request, VALUE_PAIR *, count); - for (vp = fr_pair_cursor_init(&cursor, to); vp; vp = fr_pair_cursor_next(&cursor)) count++; + for (vp = fr_cursor_init(&cursor, to); vp; vp = fr_cursor_next(&cursor)) count++; to_list = talloc_array(request, VALUE_PAIR *, count); append = NULL; diff --git a/src/main/map.c b/src/main/map.c index 6c081501190..194a96f8e38 100644 --- a/src/main/map.c +++ b/src/main/map.c @@ -700,12 +700,12 @@ static int map_exec_to_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, v */ int map_to_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t const *map, UNUSED void *uctx) { - int rcode = 0; - VALUE_PAIR *vp = NULL, *found = NULL, *n; - REQUEST *context = request; - vp_cursor_t cursor; - ssize_t slen; - char *str; + int rcode = 0; + VALUE_PAIR *vp = NULL, *found = NULL, *n; + REQUEST *context = request; + fr_cursor_t cursor; + ssize_t slen; + char *str; *out = NULL; @@ -740,9 +740,9 @@ int map_to_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t cons */ if (!found) return 0; - for (vp = fr_pair_cursor_init(&cursor, &found); + for (vp = fr_cursor_init(&cursor, &found); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { vp->op = T_OP_ADD; } @@ -836,7 +836,7 @@ int map_to_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t cons case TMPL_TYPE_ATTR: { - vp_cursor_t from; + fr_cursor_t from; rad_assert(((map->lhs->type == TMPL_TYPE_ATTR) && map->lhs->tmpl_da) || ((map->lhs->type == TMPL_TYPE_LIST) && !map->lhs->tmpl_da)); @@ -846,7 +846,7 @@ int map_to_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t cons */ if (tmpl_copy_vps(ctx, &found, request, map->rhs) < 0) return 0; - vp = fr_pair_cursor_init(&from, &found); + vp = fr_cursor_init(&from, &found); /* * Src/Dst attributes don't match, convert src attributes @@ -854,29 +854,30 @@ int map_to_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t cons */ if ((map->lhs->type == TMPL_TYPE_ATTR) && (map->rhs->tmpl_da->type != map->lhs->tmpl_da->type)) { - vp_cursor_t to; + fr_cursor_t to; - (void) fr_pair_cursor_init(&to, out); - for (; vp; vp = fr_pair_cursor_next(&from)) { + (void) fr_cursor_init(&to, out); + for (; vp; vp = fr_cursor_current(&from)) { n = fr_pair_afrom_da(ctx, map->lhs->tmpl_da); if (!n) return -1; if (fr_value_box_cast(n, &n->data, - map->lhs->tmpl_da->type, map->lhs->tmpl_da, &vp->data) < 0) { + map->lhs->tmpl_da->type, map->lhs->tmpl_da, &vp->data) < 0) { RPEDEBUG("Attribute conversion failed"); fr_pair_list_free(&found); talloc_free(n); return -1; } - vp = fr_pair_cursor_remove(&from); + vp = fr_cursor_remove(&from); /* advances cursor */ talloc_free(vp); rad_assert((n->vp_type != FR_TYPE_STRING) || (n->vp_strvalue != NULL)); n->op = map->op; n->tag = map->lhs->tmpl_tag; - fr_pair_cursor_append(&to, n); + fr_cursor_append(&to, n); } + return 0; } @@ -884,7 +885,7 @@ int map_to_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t cons * Otherwise we just need to fixup the attribute types * and operators */ - for (; vp; vp = fr_pair_cursor_next(&from)) { + for (; vp; vp = fr_cursor_next(&from)) { vp->da = map->lhs->tmpl_da; vp->op = map->op; vp->tag = map->lhs->tmpl_tag; diff --git a/src/main/pair.c b/src/main/pair.c index b6592581681..ffac6d423f5 100644 --- a/src/main/pair.c +++ b/src/main/pair.c @@ -480,18 +480,18 @@ void paircompare_unregister_instance(void *instance) int paircompare(REQUEST *request, VALUE_PAIR *req_list, VALUE_PAIR *check, VALUE_PAIR **rep_list) { - vp_cursor_t cursor; - VALUE_PAIR *check_item; - VALUE_PAIR *auth_item; - fr_dict_attr_t const *from; + fr_cursor_t cursor; + VALUE_PAIR *check_item; + VALUE_PAIR *auth_item; + fr_dict_attr_t const *from; - int result = 0; - int compare; - bool first_only; + int result = 0; + int compare; + bool first_only; - for (check_item = fr_pair_cursor_init(&cursor, &check); + for (check_item = fr_cursor_init(&cursor, &check); check_item; - check_item = fr_pair_cursor_next(&cursor)) { + check_item = fr_cursor_next(&cursor)) { /* * If the user is setting a configuration value, * then don't bother comparing it to any attributes @@ -759,7 +759,7 @@ void rdebug_pair(fr_log_lvl_t level, REQUEST *request, VALUE_PAIR *vp, char cons */ void rdebug_pair_list(fr_log_lvl_t level, REQUEST *request, VALUE_PAIR *vp, char const *prefix) { - vp_cursor_t cursor; + fr_cursor_t cursor; char *value; if (!vp || !request || !request->log.dst) return; @@ -767,9 +767,9 @@ void rdebug_pair_list(fr_log_lvl_t level, REQUEST *request, VALUE_PAIR *vp, char if (!radlog_debug_enabled(L_DBG, level, request)) return; RINDENT(); - for (vp = fr_pair_cursor_init(&cursor, &vp); + for (vp = fr_cursor_init(&cursor, &vp); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { VP_VERIFY(vp); value = fr_pair_asprint(request, vp, '"'); @@ -788,7 +788,7 @@ void rdebug_pair_list(fr_log_lvl_t level, REQUEST *request, VALUE_PAIR *vp, char */ void rdebug_proto_pair_list(fr_log_lvl_t level, REQUEST *request, VALUE_PAIR *vp, char const *prefix) { - vp_cursor_t cursor; + fr_cursor_t cursor; char *value; if (!vp || !request || !request->log.dst) return; @@ -796,9 +796,9 @@ void rdebug_proto_pair_list(fr_log_lvl_t level, REQUEST *request, VALUE_PAIR *vp if (!radlog_debug_enabled(L_DBG, level, request)) return; RINDENT(); - for (vp = fr_pair_cursor_init(&cursor, &vp); + for (vp = fr_cursor_init(&cursor, &vp); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { VP_VERIFY(vp); if (vp->da->flags.internal) continue; diff --git a/src/main/radclient.c b/src/main/radclient.c index 2a0aa346e4f..7d0f3888ca3 100644 --- a/src/main/radclient.c +++ b/src/main/radclient.c @@ -277,13 +277,13 @@ static bool already_hex(VALUE_PAIR *vp) */ static int radclient_init(TALLOC_CTX *ctx, rc_file_pair_t *files) { - FILE *packets, *filters = NULL; + FILE *packets, *filters = NULL; - vp_cursor_t cursor; - VALUE_PAIR *vp; - rc_request_t *request; - bool packets_done = false; - uint64_t num = 0; + fr_cursor_t cursor; + VALUE_PAIR *vp; + rc_request_t *request; + bool packets_done = false; + uint64_t num = 0; assert(files->packets != NULL); @@ -395,9 +395,10 @@ static int radclient_init(TALLOC_CTX *ctx, rc_file_pair_t *files) /* * xlat expansions aren't supported here */ - for (vp = fr_pair_cursor_init(&cursor, &request->filter); + for (vp = fr_cursor_init(&cursor, &request->filter); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { + again: if (vp->type == VT_XLAT) { vp->type = VT_DATA; vp->vp_strvalue = vp->xlat; @@ -407,10 +408,12 @@ static int radclient_init(TALLOC_CTX *ctx, rc_file_pair_t *files) if (vp->da->vendor == 0 ) switch (vp->da->attr) { case FR_RESPONSE_PACKET_TYPE: case FR_PACKET_TYPE: - fr_pair_cursor_remove(&cursor); /* so we don't break the filter */ + vp = fr_cursor_remove(&cursor); /* so we don't break the filter */ request->filter_code = vp->vp_uint32; talloc_free(vp); - + vp = fr_cursor_current(&cursor); + if (!vp) break; + goto again; default: break; } @@ -425,9 +428,9 @@ static int radclient_init(TALLOC_CTX *ctx, rc_file_pair_t *files) /* * Process special attributes */ - for (vp = fr_pair_cursor_init(&cursor, &request->packet->vps); + for (vp = fr_cursor_init(&cursor, &request->packet->vps); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { /* * Double quoted strings get marked up as xlat expansions, * but we don't support that in request. diff --git a/src/main/unit_test_module.c b/src/main/unit_test_module.c index cba20502c51..ab6929ac6c2 100644 --- a/src/main/unit_test_module.c +++ b/src/main/unit_test_module.c @@ -95,7 +95,7 @@ static REQUEST *request_from_file(FILE *fp, fr_event_list_t *el, RADCLIENT *clie { VALUE_PAIR *vp; REQUEST *request; - vp_cursor_t cursor; + fr_cursor_t cursor; struct timeval now; static int number = 0; @@ -162,9 +162,9 @@ static REQUEST *request_from_file(FILE *fp, fr_event_list_t *el, RADCLIENT *clie /* * Fix up Digest-Attributes issues */ - for (vp = fr_pair_cursor_init(&cursor, &request->packet->vps); + for (vp = fr_cursor_init(&cursor, &request->packet->vps); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { /* * Double quoted strings get marked up as xlat expansions, * but we don't support that here. @@ -297,9 +297,9 @@ static REQUEST *request_from_file(FILE *fp, fr_event_list_t *el, RADCLIENT *clie #endif if (rad_debug_lvl) { - for (vp = fr_pair_cursor_init(&cursor, &request->packet->vps); + for (vp = fr_cursor_init(&cursor, &request->packet->vps); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { /* * Take this opportunity to verify all the VALUE_PAIRs are still valid. */ @@ -367,7 +367,7 @@ static REQUEST *request_from_file(FILE *fp, fr_event_list_t *el, RADCLIENT *clie static void print_packet(FILE *fp, RADIUS_PACKET *packet) { VALUE_PAIR *vp; - vp_cursor_t cursor; + fr_cursor_t cursor; if (!packet) { fprintf(fp, "\n"); @@ -376,9 +376,9 @@ static void print_packet(FILE *fp, RADIUS_PACKET *packet) fprintf(fp, "%s\n", fr_packet_codes[packet->code]); - for (vp = fr_pair_cursor_init(&cursor, &packet->vps); + for (vp = fr_cursor_init(&cursor, &packet->vps); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { /* * Take this opportunity to verify all the VALUE_PAIRs are still valid. */ diff --git a/src/modules/rlm_cache/rlm_cache.c b/src/modules/rlm_cache/rlm_cache.c index e93f03058ae..fb9dae8fe70 100644 --- a/src/modules/rlm_cache/rlm_cache.c +++ b/src/modules/rlm_cache/rlm_cache.c @@ -323,7 +323,7 @@ static rlm_rcode_t cache_insert(rlm_cache_t const *inst, REQUEST *request, rlm_c pool = talloc_pool(NULL, 1024); for (map = inst->maps; map != NULL; map = map->next) { VALUE_PAIR *to_cache = NULL; - vp_cursor_t cursor; + fr_cursor_t cursor; rad_assert(map->lhs && map->rhs); @@ -336,9 +336,9 @@ static rlm_rcode_t cache_insert(rlm_cache_t const *inst, REQUEST *request, rlm_c continue; } - for (vp = fr_pair_cursor_init(&cursor, &to_cache); + for (vp = fr_cursor_init(&cursor, &to_cache); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { /* * Prevent people from accidentally caching * cache control attributes. @@ -545,7 +545,7 @@ static rlm_rcode_t mod_cache_it(void *instance, UNUSED void *thread, REQUEST *re rlm_cache_handle_t *handle; - vp_cursor_t cursor; + fr_cursor_t cursor; VALUE_PAIR *vp; bool merge = true, insert = true, expire = false, set_ttl = false; @@ -762,9 +762,10 @@ finish: /* * Clear control attributes */ - for (vp = fr_pair_cursor_init(&cursor, &request->control); + for (vp = fr_cursor_init(&cursor, &request->control); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { + again: if (vp->da->vendor == 0) switch (vp->da->attr) { case FR_CACHE_TTL: case FR_CACHE_STATUS_ONLY: @@ -772,9 +773,11 @@ finish: case FR_CACHE_ALLOW_INSERT: case FR_CACHE_MERGE_NEW: RDEBUG2("Removing &control:%s", vp->da->name); - vp = fr_pair_cursor_remove(&cursor); + vp = fr_cursor_remove(&cursor); talloc_free(vp); - break; + vp = fr_cursor_current(&cursor); + if (!vp) break; + goto again; } } diff --git a/src/modules/rlm_detail/rlm_detail.c b/src/modules/rlm_detail/rlm_detail.c index 537899344a7..3692cc2b410 100644 --- a/src/modules/rlm_detail/rlm_detail.c +++ b/src/modules/rlm_detail/rlm_detail.c @@ -294,11 +294,11 @@ static int detail_write(FILE *out, rlm_detail_t const *inst, REQUEST *request, R } { - vp_cursor_t cursor; + fr_cursor_t cursor; /* Write each attribute/value to the log file */ - for (vp = fr_pair_cursor_init(&cursor, &packet->vps); + for (vp = fr_cursor_init(&cursor, &packet->vps); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { FR_TOKEN op; if (inst->ht && fr_hash_table_finddata(inst->ht, vp->da)) continue; diff --git a/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c b/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c index 8f269b5ce2b..5feff3c1b86 100644 --- a/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c +++ b/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c @@ -138,7 +138,7 @@ static int diameter_verify(REQUEST *request, uint8_t const *data, unsigned int d /* * Convert diameter attributes to our VALUE_PAIR's */ -static ssize_t eap_ttls_decode_pair(TALLOC_CTX *ctx, vp_cursor_t *cursor, fr_dict_attr_t const *parent, +static ssize_t eap_ttls_decode_pair(TALLOC_CTX *ctx, fr_cursor_t *cursor, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decoder_ctx) { @@ -158,7 +158,7 @@ static ssize_t eap_ttls_decode_pair(TALLOC_CTX *ctx, vp_cursor_t *cursor, fr_dic if ((end - p) < 8) { fr_strerror_printf("Malformed diameter VPs. Needed at least 8 bytes, got %zu bytes", end - p); error: - fr_pair_cursor_free(cursor); + fr_cursor_list_free(cursor); return -1; } @@ -234,7 +234,7 @@ do_value: * to the nearest 4-byte boundary. */ p += (value_len + 0x03) & ~0x03; - fr_pair_cursor_append(cursor, vp); + fr_cursor_append(cursor, vp); if (vp->da->flags.is_unknown) continue; @@ -307,12 +307,14 @@ static int vp2diameter(REQUEST *request, tls_session_t *tls_session, VALUE_PAIR size_t total; uint64_t attr64; VALUE_PAIR *vp; - vp_cursor_t cursor; + fr_cursor_t cursor; p = buffer; total = 0; - for (vp = fr_pair_cursor_init(&cursor, &first); vp; vp = fr_pair_cursor_next(&cursor)) { + for (vp = fr_cursor_init(&cursor, &first); + vp; + vp = fr_cursor_next(&cursor)) { /* * Too much data: die. */ @@ -441,8 +443,8 @@ static rlm_rcode_t CC_HINT(nonnull) process_reply(NDEBUG_UNUSED eap_session_t *e { rlm_rcode_t rcode = RLM_MODULE_REJECT; VALUE_PAIR *vp, *tunnel_vps = NULL; - vp_cursor_t cursor; - vp_cursor_t to_tunnel; + fr_cursor_t cursor; + fr_cursor_t to_tunnel; ttls_tunnel_t *t = tls_session->opaque; @@ -474,16 +476,16 @@ static rlm_rcode_t CC_HINT(nonnull) process_reply(NDEBUG_UNUSED eap_session_t *e { RDEBUG("Got tunneled Access-Accept"); - fr_pair_cursor_init(&to_tunnel, &tunnel_vps); + fr_cursor_init(&to_tunnel, &tunnel_vps); rcode = RLM_MODULE_OK; /* * Copy what we need into the TTLS tunnel and leave * the rest to be cleaned up. */ - for (vp = fr_pair_cursor_init(&cursor, &reply->vps); + for (vp = fr_cursor_init(&cursor, &reply->vps); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { switch (vp->da->vendor) { case VENDORPEC_MICROSOFT: if (vp->da->attr == FR_MSCHAP2_SUCCESS) { @@ -491,7 +493,7 @@ static rlm_rcode_t CC_HINT(nonnull) process_reply(NDEBUG_UNUSED eap_session_t *e rcode = RLM_MODULE_HANDLED; t->authenticated = true; - fr_pair_cursor_prepend(&to_tunnel, fr_pair_copy(tls_session, vp)); + fr_cursor_prepend(&to_tunnel, fr_pair_copy(tls_session, vp)); } break; @@ -499,7 +501,7 @@ static rlm_rcode_t CC_HINT(nonnull) process_reply(NDEBUG_UNUSED eap_session_t *e if (vp->da->attr == FR_UKERNA_CHBIND) { rcode = RLM_MODULE_HANDLED; t->authenticated = true; - fr_pair_cursor_prepend(&to_tunnel, fr_pair_copy(tls_session, vp)); + fr_cursor_prepend(&to_tunnel, fr_pair_copy(tls_session, vp)); } break; @@ -525,19 +527,19 @@ static rlm_rcode_t CC_HINT(nonnull) process_reply(NDEBUG_UNUSED eap_session_t *e case FR_CODE_ACCESS_CHALLENGE: RDEBUG("Got tunneled Access-Challenge"); - fr_pair_cursor_init(&to_tunnel, &tunnel_vps); + fr_cursor_init(&to_tunnel, &tunnel_vps); /* * Copy what we need into the TTLS tunnel and leave * the rest to be cleaned up. */ - for (vp = fr_pair_cursor_init(&cursor, &reply->vps); + for (vp = fr_cursor_init(&cursor, &reply->vps); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { switch (vp->da->vendor) { case VENDORPEC_UKERNA: if (vp->da->attr == FR_UKERNA_CHBIND) { - fr_pair_cursor_prepend(&to_tunnel, fr_pair_copy(tls_session, vp)); + fr_cursor_prepend(&to_tunnel, fr_pair_copy(tls_session, vp)); } break; @@ -545,7 +547,7 @@ static rlm_rcode_t CC_HINT(nonnull) process_reply(NDEBUG_UNUSED eap_session_t *e switch (vp->da->attr) { case FR_EAP_MESSAGE: case FR_REPLY_MESSAGE: - fr_pair_cursor_prepend(&to_tunnel, fr_pair_copy(tls_session, vp)); + fr_cursor_prepend(&to_tunnel, fr_pair_copy(tls_session, vp)); break; default: @@ -716,7 +718,7 @@ FR_CODE eap_ttls_process(eap_session_t *eap_session, tls_session_t *tls_session) rlm_rcode_t rcode; REQUEST *fake = NULL; VALUE_PAIR *vp = NULL; - vp_cursor_t cursor; + fr_cursor_t cursor; ttls_tunnel_t *t; uint8_t const *data; size_t data_len; @@ -768,7 +770,7 @@ FR_CODE eap_ttls_process(eap_session_t *eap_session, tls_session_t *tls_session) /* * Add the tunneled attributes to the fake request. */ - fr_pair_cursor_init(&cursor, &fake->packet->vps); + fr_cursor_init(&cursor, &fake->packet->vps); if (eap_ttls_decode_pair(fake->packet, &cursor, fr_dict_root(fr_dict_internal), data, data_len, tls_session->ssl) < 0) { RPEDEBUG("Decoding TTLS TLVs failed"); diff --git a/src/modules/rlm_files/rlm_files.c b/src/modules/rlm_files/rlm_files.c index 31242eea076..533566b7bce 100644 --- a/src/modules/rlm_files/rlm_files.c +++ b/src/modules/rlm_files/rlm_files.c @@ -122,7 +122,7 @@ static int getusersfile(TALLOC_CTX *ctx, char const *filename, rbtree_t **ptree) entry = users; while (entry) { - vp_cursor_t cursor; + fr_cursor_t cursor; /* * Look for improper use of '=' in the @@ -131,7 +131,9 @@ static int getusersfile(TALLOC_CTX *ctx, char const *filename, rbtree_t **ptree) * and probably ':=' for server * configuration items. */ - for (vp = fr_pair_cursor_init(&cursor, &entry->check); vp; vp = fr_pair_cursor_next(&cursor)) { + for (vp = fr_cursor_init(&cursor, &entry->check); + vp; + vp = fr_cursor_next(&cursor)) { /* * Ignore attributes which are set * properly. @@ -163,7 +165,9 @@ static int getusersfile(TALLOC_CTX *ctx, char const *filename, rbtree_t **ptree) * It's a common enough mistake, that it's * worth doing. */ - for (vp = fr_pair_cursor_init(&cursor, &entry->reply); vp; vp = fr_pair_cursor_next(&cursor)) { + for (vp = fr_cursor_init(&cursor, &entry->reply); + vp; + vp = fr_cursor_next(&cursor)) { /* * If it's NOT a vendor attribute, * and it's NOT a wire protocol @@ -330,7 +334,7 @@ static rlm_rcode_t file_common(rlm_files_t const *inst, REQUEST *request, char c * Find the entry for the user. */ while (user_pl || default_pl) { - vp_cursor_t cursor; + fr_cursor_t cursor; VALUE_PAIR *vp; PAIR_LIST const *pl; @@ -360,9 +364,9 @@ static rlm_rcode_t file_common(rlm_files_t const *inst, REQUEST *request, char c } check_tmp = fr_pair_list_copy(request, pl->check); - for (vp = fr_pair_cursor_init(&cursor, &check_tmp); + for (vp = fr_cursor_init(&cursor, &check_tmp); vp; - vp = fr_pair_cursor_next(&cursor)) { + vp = fr_cursor_next(&cursor)) { if (xlat_eval_do(request, vp) < 0) { RWARN("Failed parsing expanded value for check item, skipping entry: %s", fr_strerror()); fr_pair_list_free(&check_tmp); diff --git a/src/modules/rlm_json/json.c b/src/modules/rlm_json/json.c index a84213f6446..95595b70f6e 100644 --- a/src/modules/rlm_json/json.c +++ b/src/modules/rlm_json/json.c @@ -315,7 +315,7 @@ void fr_json_version_print(void) */ const char *fr_json_afrom_pair_list(TALLOC_CTX *ctx, VALUE_PAIR **vps, const char *prefix) { - vp_cursor_t cursor; + fr_cursor_t cursor; VALUE_PAIR *vp; struct json_object *obj; const char *p; @@ -323,7 +323,9 @@ const char *fr_json_afrom_pair_list(TALLOC_CTX *ctx, VALUE_PAIR **vps, const cha MEM(obj = json_object_new_object()); - for (vp = fr_pair_cursor_init(&cursor, vps); vp; vp = fr_pair_cursor_next(&cursor)) { + for (vp = fr_cursor_init(&cursor, vps); + vp; + vp = fr_cursor_next(&cursor)) { char const *name_with_prefix; fr_dict_enum_t const *dv; struct json_object *vp_object, *values, *value, *type_name;