]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move actions to struct
authorAlan T. DeKok <aland@freeradius.org>
Wed, 25 Aug 2021 12:57:48 +0000 (08:57 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 25 Aug 2021 12:57:48 +0000 (08:57 -0400)
src/lib/unlang/call.c
src/lib/unlang/compile.c
src/lib/unlang/compile.h
src/lib/unlang/function.c
src/lib/unlang/interpret.c
src/lib/unlang/load_balance.c
src/lib/unlang/module.c
src/lib/unlang/subrequest_child.c
src/lib/unlang/tmpl.c
src/lib/unlang/unlang_priv.h
src/lib/unlang/xlat.c

index c08df388b2b94fb6ea2ed9170b1e9cf995eea642..84d56de20a25dc5cb105b6abba7bf5d5dc7bd209 100644 (file)
@@ -165,16 +165,18 @@ unlang_action_t unlang_call_push(request_t *request, CONF_SECTION *server_cs, bo
                                .name = name,
                                .debug_name = name,
                                .actions = {
-                                       [RLM_MODULE_REJECT]     = 0,
-                                       [RLM_MODULE_FAIL]       = MOD_ACTION_RETURN,    /* Exit out of nested levels */
-                                       [RLM_MODULE_OK]         = 0,
-                                       [RLM_MODULE_HANDLED]    = 0,
-                                       [RLM_MODULE_INVALID]    = 0,
-                                       [RLM_MODULE_DISALLOW]   = 0,
-                                       [RLM_MODULE_NOTFOUND]   = 0,
-                                       [RLM_MODULE_NOOP]       = 0,
-                                       [RLM_MODULE_UPDATED]    = 0
-                               }
+                                       .actions = {
+                                               [RLM_MODULE_REJECT]     = 0,
+                                               [RLM_MODULE_FAIL]       = MOD_ACTION_RETURN,    /* Exit out of nested levels */
+                                               [RLM_MODULE_OK]         = 0,
+                                               [RLM_MODULE_HANDLED]    = 0,
+                                               [RLM_MODULE_INVALID]    = 0,
+                                               [RLM_MODULE_DISALLOW]   = 0,
+                                               [RLM_MODULE_NOTFOUND]   = 0,
+                                               [RLM_MODULE_NOOP]       = 0,
+                                               [RLM_MODULE_UPDATED]    = 0
+                                       },
+                               },
                        }
                },
                .server_cs = server_cs,
index 44388342c5027b783826b7fcbadae31618d16d96..714454168a778a78419b427e9c040ac4a785fcdc 100644 (file)
@@ -82,10 +82,6 @@ static char const * const comp2str[] = {
        "post-auth"
 };
 
-typedef struct {
-       int actions[RLM_MODULE_NUMCODES];
-} unlang_actions_t;
-
 typedef struct {
        rlm_components_t        component;
        char const              *section_name1;
@@ -1098,15 +1094,15 @@ static void compile_action_defaults(unlang_t *c, unlang_compile_t *unlang_ctx)
            ((c->parent->type == UNLANG_TYPE_REDUNDANT) || (c->parent->type == UNLANG_TYPE_REDUNDANT_LOAD_BALANCE))) {
                for (i = 0; i < RLM_MODULE_NUMCODES; i++) {
                        if (i == RLM_MODULE_FAIL) {
-                               if (!c->actions[i]) {
-                                       c->actions[i] = 1;
+                               if (!c->actions.actions[i]) {
+                                       c->actions.actions[i] = 1;
                                }
 
                                continue;
                        }
 
-                       if (!c->actions[i]) {
-                               c->actions[i] = MOD_ACTION_RETURN;
+                       if (!c->actions.actions[i]) {
+                               c->actions.actions[i] = MOD_ACTION_RETURN;
                        }
                }
 
@@ -1118,8 +1114,8 @@ static void compile_action_defaults(unlang_t *c, unlang_compile_t *unlang_ctx)
         *      set.
         */
        for (i = 0; i < RLM_MODULE_NUMCODES; i++) {
-               if (!c->actions[i]) {
-                       c->actions[i] = unlang_ctx->actions[0].actions[i];
+               if (!c->actions.actions[i]) {
+                       c->actions.actions[i] = unlang_ctx->actions[0].actions[i];
                }
        }
 }
@@ -1480,13 +1476,13 @@ static int compile_action_pair(unlang_t *c, CONF_PAIR *cp)
                                   attr);
                        return 0;
                }
-               c->actions[rcode] = action;
+               c->actions.actions[rcode] = action;
 
        } else {                /* set all unset values to the default */
                int i;
 
                for (i = 0; i < RLM_MODULE_NUMCODES; i++) {
-                       if (!c->actions[i]) c->actions[i] = action;
+                       if (!c->actions.actions[i]) c->actions.actions[i] = action;
                }
        }
 
@@ -2211,7 +2207,7 @@ static unlang_t *compile_case(unlang_t *parent, unlang_compile_t *unlang_ctx, CO
         *      when we pick a 'case' statement, we don't
         *      fall through to processing the next one.
         */
-       for (i = 0; i < RLM_MODULE_NUMCODES; i++) c->actions[i] = MOD_ACTION_RETURN;
+       for (i = 0; i < RLM_MODULE_NUMCODES; i++) c->actions.actions[i] = MOD_ACTION_RETURN;
 
        return c;
 }
index 4b233e6178f41f83006f3a3808a0f3677658239d..6f23fd99d916e77f5d9da7dfa75578922b352568 100644 (file)
@@ -32,6 +32,10 @@ extern "C" {
 #include <freeradius-devel/server/components.h>
 #include <freeradius-devel/server/tmpl.h>
 
+typedef struct {
+       int actions[RLM_MODULE_NUMCODES];
+} unlang_actions_t;
+
 int            unlang_compile(CONF_SECTION *cs, rlm_components_t component, tmpl_rules_t const *rules, void **instruction);
 
 bool           unlang_compile_is_keyword(const char *name);
index 73c87f168a3c832773a5325e22fb5f36f4222f15..063c9b8602aa3e9a5c90a04cdae07dd8575c93af 100644 (file)
@@ -49,16 +49,18 @@ static unlang_t function_instruction = {
        .name = "function",
        .debug_name = "function",
        .actions = {
-               [RLM_MODULE_REJECT]     = 0,
-               [RLM_MODULE_FAIL]       = 0,
-               [RLM_MODULE_OK]         = 0,
-               [RLM_MODULE_HANDLED]    = 0,
-               [RLM_MODULE_INVALID]    = 0,
-               [RLM_MODULE_DISALLOW]   = 0,
-               [RLM_MODULE_NOTFOUND]   = 0,
-               [RLM_MODULE_NOOP]       = 0,
-               [RLM_MODULE_UPDATED]    = 0
-       }
+               .actions = {
+                       [RLM_MODULE_REJECT]     = 0,
+                       [RLM_MODULE_FAIL]       = 0,
+                       [RLM_MODULE_OK]         = 0,
+                       [RLM_MODULE_HANDLED]    = 0,
+                       [RLM_MODULE_INVALID]    = 0,
+                       [RLM_MODULE_DISALLOW]   = 0,
+                       [RLM_MODULE_NOTFOUND]   = 0,
+                       [RLM_MODULE_NOOP]       = 0,
+                       [RLM_MODULE_UPDATED]    = 0
+               },
+       },
 };
 
 /** Generic signal handler
index 676aba95155bad074f4d689508445159ed54fb3b..92f2cd9e1227f7458a5624fbb568feb74f048930 100644 (file)
@@ -221,7 +221,7 @@ unlang_frame_action_t result_calculate(request_t *request, unlang_stack_frame_t
        /*
         *      The child's action says return.  Do so.
         */
-       if (instruction->actions[*result] == MOD_ACTION_RETURN) {
+       if (instruction->actions.actions[*result] == MOD_ACTION_RETURN) {
                if (*priority < 0) *priority = 0;
 
                RDEBUG4("** [%i] %s - action says to return with (%s %d)",
@@ -237,7 +237,7 @@ unlang_frame_action_t result_calculate(request_t *request, unlang_stack_frame_t
         *      If "reject", break out of the loop and return
         *      reject.
         */
-       if (instruction->actions[*result] == MOD_ACTION_REJECT) {
+       if (instruction->actions.actions[*result] == MOD_ACTION_REJECT) {
                if (*priority < 0) *priority = 0;
 
                RDEBUG4("** [%i] %s - action says to return with (%s %d)",
@@ -254,7 +254,7 @@ unlang_frame_action_t result_calculate(request_t *request, unlang_stack_frame_t
         *      code.  Grab it in preference to any unset priority.
         */
        if (*priority < 0) {
-               *priority = instruction->actions[*result];
+               *priority = instruction->actions.actions[*result];
 
                RDEBUG4("** [%i] %s - setting priority to (%s %d)",
                        stack->depth, __FUNCTION__,
@@ -479,7 +479,7 @@ unlang_frame_action_t frame_eval(request_t *request, unlang_stack_frame_t *frame
                         *      RLM_MODULE_NOT_SET means the instruction
                         *      doesn't want to modify the result.
                         */
-                       if (*result != RLM_MODULE_NOT_SET) *priority = instruction->actions[*result];
+                       if (*result != RLM_MODULE_NOT_SET) *priority = instruction->actions.actions[*result];
 
                        if (result_calculate(request, frame, result, priority) == UNLANG_FRAME_ACTION_POP) {
                                return UNLANG_FRAME_ACTION_POP;
index 00d1075d8f55658b27190278aeb1394b415723bd..06531214c27e354c728e6539f8085aa6c3e85549 100644 (file)
@@ -73,7 +73,7 @@ static unlang_action_t unlang_load_balance_next(rlm_rcode_t *p_result, request_t
                 *      If the current child says "return", then do
                 *      so.
                 */
-               if (redundant->child->actions[*p_result] == MOD_ACTION_RETURN) {
+               if (redundant->child->actions.actions[*p_result] == MOD_ACTION_RETURN) {
                        /* DON'T change p_result, as it is taken from the child */
                        return UNLANG_ACTION_CALCULATE_RESULT;
                }
index eedffae1c2724c3fec63023aa5de13619548350e..668cc8507c4e1165b6ada8f3a0563f849a32d131 100644 (file)
@@ -363,16 +363,18 @@ int unlang_module_push(rlm_rcode_t *p_result, request_t *request,
                        .name = module_instance->name,
                        .debug_name = module_instance->name,
                        .actions = {
-                               [RLM_MODULE_REJECT]     = 0,
-                               [RLM_MODULE_FAIL]       = MOD_ACTION_RETURN,    /* Exit out of nested levels */
-                               [RLM_MODULE_OK]         = 0,
-                               [RLM_MODULE_HANDLED]    = 0,
-                               [RLM_MODULE_INVALID]    = 0,
-                               [RLM_MODULE_DISALLOW]   = 0,
-                               [RLM_MODULE_NOTFOUND]   = 0,
-                               [RLM_MODULE_NOOP]       = 0,
-                               [RLM_MODULE_UPDATED]    = 0
-                       }
+                               .actions = {
+                                       [RLM_MODULE_REJECT]     = 0,
+                                       [RLM_MODULE_FAIL]       = MOD_ACTION_RETURN,    /* Exit out of nested levels */
+                                       [RLM_MODULE_OK]         = 0,
+                                       [RLM_MODULE_HANDLED]    = 0,
+                                       [RLM_MODULE_INVALID]    = 0,
+                                       [RLM_MODULE_DISALLOW]   = 0,
+                                       [RLM_MODULE_NOTFOUND]   = 0,
+                                       [RLM_MODULE_NOOP]       = 0,
+                                       [RLM_MODULE_UPDATED]    = 0
+                               },
+                       },
                },
                .instance = module_instance,
                .method = method
index 45b378d0f6522e3c6a6131c680a4d25c4ce01c6d..21d8969e0e5df17dfec3967a346e830f2de5640a 100644 (file)
@@ -389,16 +389,18 @@ int unlang_subrequest_child_op_init(void)
                                .name = "subrequest",
                                .debug_name = "subrequest",
                                .actions = {
-                                       [RLM_MODULE_REJECT]     = 0,
-                                       [RLM_MODULE_FAIL]       = 0,
-                                       [RLM_MODULE_OK]         = 0,
-                                       [RLM_MODULE_HANDLED]    = 0,
-                                       [RLM_MODULE_INVALID]    = 0,
-                                       [RLM_MODULE_DISALLOW]   = 0,
-                                       [RLM_MODULE_NOTFOUND]   = 0,
+                                       .actions = {
+                                               [RLM_MODULE_REJECT]     = 0,
+                                               [RLM_MODULE_FAIL]       = 0,
+                                               [RLM_MODULE_OK]         = 0,
+                                               [RLM_MODULE_HANDLED]    = 0,
+                                               [RLM_MODULE_INVALID]    = 0,
+                                               [RLM_MODULE_DISALLOW]   = 0,
+                                               [RLM_MODULE_NOTFOUND]   = 0,
                                        [RLM_MODULE_NOOP]       = 0,
-                                       [RLM_MODULE_UPDATED]    = 0
-                               }
+                                               [RLM_MODULE_UPDATED]    = 0
+                                       },
+                               },
                        }
                }
        };
index 5536b2ea822ce8d5cc2f15842ed230b80d664076..ac8bd63ccc0c39e57c52755f1eef648d5cadbc7d 100644 (file)
@@ -137,15 +137,17 @@ int unlang_tmpl_push(TALLOC_CTX *ctx, fr_value_box_list_t *out, request_t *reque
                .name = "tmpl",
                .debug_name = "tmpl",
                .actions = {
-                       [RLM_MODULE_REJECT]     = 0,
-                       [RLM_MODULE_FAIL]       = 0,
-                       [RLM_MODULE_OK]         = 0,
-                       [RLM_MODULE_HANDLED]    = 0,
-                       [RLM_MODULE_INVALID]    = 0,
-                       [RLM_MODULE_DISALLOW]   = 0,
-                       [RLM_MODULE_NOTFOUND]   = 0,
-                       [RLM_MODULE_NOOP]       = 0,
-                       [RLM_MODULE_UPDATED]    = 0
+                       .actions = {
+                               [RLM_MODULE_REJECT]     = 0,
+                               [RLM_MODULE_FAIL]       = 0,
+                               [RLM_MODULE_OK]         = 0,
+                               [RLM_MODULE_HANDLED]    = 0,
+                               [RLM_MODULE_INVALID]    = 0,
+                               [RLM_MODULE_DISALLOW]   = 0,
+                               [RLM_MODULE_NOTFOUND]   = 0,
+                               [RLM_MODULE_NOOP]       = 0,
+                               [RLM_MODULE_UPDATED]    = 0
+                       },
                },
        };
 
index eb447b6bc9a3c8b04f1104291e9b1c41ef423b7e..8302e44352ac853a836418124d5663046d21192b 100644 (file)
@@ -120,7 +120,7 @@ struct unlang_s {
        char const              *debug_name;    //!< Printed in log messages when the node is executed.
        unlang_type_t           type;           //!< The specialisation of this node.
        bool                    closed;         //!< whether or not this section is closed to new statements
-       int                     actions[RLM_MODULE_NUMCODES];   //!< Priorities for the various return codes.
+       unlang_actions_t        actions;        //!< Priorities, etc. for the various return codes.
 };
 
 /** Describes how to allocate an #unlang_group_t with additional memory keyword specific data
index 44d9f0b663268864edaf240d8ee28e9f744c6119..446b88c61343b17eea77ae91bbbd7e80a4d8cdbc 100644 (file)
@@ -79,15 +79,17 @@ static unlang_t xlat_instruction = {
        .name = "xlat",
        .debug_name = "xlat",
        .actions = {
-               [RLM_MODULE_REJECT]     = 0,
-               [RLM_MODULE_FAIL]       = MOD_ACTION_RETURN,    /* Exit out of nested levels */
-               [RLM_MODULE_OK]         = 0,
-               [RLM_MODULE_HANDLED]    = 0,
-               [RLM_MODULE_INVALID]    = 0,
-               [RLM_MODULE_DISALLOW]   = 0,
-               [RLM_MODULE_NOTFOUND]   = 0,
-               [RLM_MODULE_NOOP]       = 0,
-               [RLM_MODULE_UPDATED]    = 0
+               .actions = {
+                       [RLM_MODULE_REJECT]     = 0,
+                       [RLM_MODULE_FAIL]       = MOD_ACTION_RETURN,    /* Exit out of nested levels */
+                       [RLM_MODULE_OK]         = 0,
+                       [RLM_MODULE_HANDLED]    = 0,
+                       [RLM_MODULE_INVALID]    = 0,
+                       [RLM_MODULE_DISALLOW]   = 0,
+                       [RLM_MODULE_NOTFOUND]   = 0,
+                       [RLM_MODULE_NOOP]       = 0,
+                       [RLM_MODULE_UPDATED]    = 0
+               },
        },
 };