]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add a "pair-compare" function
authorAlan T. DeKok <aland@freeradius.org>
Thu, 4 Dec 2025 19:29:41 +0000 (14:29 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 4 Dec 2025 19:30:19 +0000 (14:30 -0500)
which allows for comparison operators

src/bin/unit_test_attribute.c

index 9aeccb006d3699f62232fc12a8a3bf3773c93daf..bd2ac158070939b2a58916e061cf5005c8eb1cf8 100644 (file)
@@ -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 <protocol>",