]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add CoA filter and reply file to rc_file_pair_t
authorAlan T. DeKok <aland@freeradius.org>
Fri, 2 Dec 2022 22:13:40 +0000 (17:13 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 2 Dec 2022 22:13:40 +0000 (17:13 -0500)
src/bin/radclient.c
src/bin/radclient.h

index 382d9a529c2d8af508b35e8f4970e66aa3c828c2..90bab668b5e8a860f5d98370605c7337d7589125 100644 (file)
@@ -1365,6 +1365,7 @@ int main(int argc, char **argv)
 #endif
        fr_dlist_head_t filenames;
        rc_request_t    *request;
+       rc_file_pair_t  *coa_files = NULL;
 
        /*
         *      It's easier having two sets of flags to set the
@@ -1401,7 +1402,7 @@ int main(int argc, char **argv)
        default_log.fd = STDOUT_FILENO;
        default_log.print_level = false;
 
-       while ((c = getopt(argc, argv, "46c:A:C:d:D:f:Fhi:n:p:P:r:sS:t:vx")) != -1) switch (c) {
+       while ((c = getopt(argc, argv, "46c:A:C:d:D:f:Fhi:n:o:p:P:r:sS:t:vx")) != -1) switch (c) {
                case '4':
                        force_af = AF_INET;
                        break;
@@ -1488,6 +1489,33 @@ int main(int argc, char **argv)
                        if (persec <= 0) usage();
                        break;
 
+               case 'o':
+                       if (!coa_files) {
+                               coa_files = fr_dlist_head(&filenames);
+                       } else {
+                               coa_files = fr_dlist_next(&filenames, coa_files);
+                       }
+
+                       if (!coa_files) {
+                               ERROR("There are fewer client filenames than CoA filenames");
+                               fr_exit_now(1);
+                       }
+
+                       {
+                               char const *p;
+
+                               p = strchr(optarg, ':');
+                               if (p) {
+                                       coa_files->coa_reply = talloc_strndup(coa_files, optarg, p - optarg);
+                                       if (!coa_files->coa_reply) goto oom;
+                                       coa_files->coa_filter = p + 1;
+                               } else {
+                                       coa_files->coa_reply = optarg;
+                                       coa_files->coa_filter = NULL;
+                               }
+                       }
+                       break;
+
                        /*
                         *      Note that sending MANY requests in
                         *      parallel can over-run the kernel
index 042da94cc4415f3d3eb66bdadc5a9f9a028b2113..c93b79f34c75cf84e4e1960a2c5368e39af9d8af 100644 (file)
@@ -61,6 +61,8 @@ 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              *coa_filter;    //!< file containing the CoA filter we want to match
+       char const              *coa_reply;     //!< file containing the CoA filter we want to match
 } rc_file_pair_t;
 
 typedef struct rc_request rc_request_t;