From: Alan T. DeKok Date: Thu, 4 Dec 2025 19:29:41 +0000 (-0500) Subject: add a "pair-compare" function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef7904dc92216df5cf02c6c520dd279e7804933d;p=thirdparty%2Ffreeradius-server.git add a "pair-compare" function which allows for comparison operators --- diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index 9aeccb006d3..bd2ac158070 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -2686,8 +2686,9 @@ static size_t command_no(command_result_t *result, command_file_ctx_t *cc, /** Parse an print an attribute pair or pair list. * */ -static size_t command_pair(command_result_t *result, command_file_ctx_t *cc, - char *data, UNUSED size_t data_used, char *in, size_t inlen) +static size_t command_pair_common(command_result_t *result, command_file_ctx_t *cc, + char *data, UNUSED size_t data_used, char *in, size_t inlen, + bool allow_compare) { fr_pair_list_t head; ssize_t slen; @@ -2702,6 +2703,7 @@ static size_t command_pair(command_result_t *result, command_file_ctx_t *cc, .list = &head, .dict = dict, .internal = fr_dict_internal(), + .allow_compare = allow_compare, }; relative = (fr_pair_parse_t) { }; @@ -2727,6 +2729,19 @@ static size_t command_pair(command_result_t *result, command_file_ctx_t *cc, RETURN_OK(slen); } +static size_t command_pair(command_result_t *result, command_file_ctx_t *cc, + char *data, size_t data_used, char *in, size_t inlen) +{ + return command_pair_common(result, cc, data, data_used, in, inlen, false); +} + +static size_t command_pair_compare(command_result_t *result, command_file_ctx_t *cc, + char *data, size_t data_used, char *in, size_t inlen) +{ + return command_pair_common(result, cc, data, data_used, in, inlen, true); +} + + /** Dynamically load a protocol library * */ @@ -3520,6 +3535,11 @@ static fr_table_ptr_sorted_t commands[] = { .usage = "pair ... data ...", .description = "Parse a list of pairs", }}, + { L("pair-compare "), &(command_entry_t){ + .func = command_pair_compare, + .usage = "pair-compare ... data ...", + .description = "Parse a list of pairs, allowing comparison operators", + }}, { L("proto "), &(command_entry_t){ .func = command_proto, .usage = "proto ",