]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move unlang_ext_t fields to unlang_op_t
authorAlan T. DeKok <aland@freeradius.org>
Mon, 30 Jun 2025 16:09:25 +0000 (12:09 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 30 Jun 2025 17:25:38 +0000 (13:25 -0400)
in preparation for adding function-style arguments to keywords

19 files changed:
src/lib/unlang/call.c
src/lib/unlang/caller.c
src/lib/unlang/catch.c
src/lib/unlang/compile.c
src/lib/unlang/condition.c
src/lib/unlang/detach.c
src/lib/unlang/foreach.c
src/lib/unlang/group.c
src/lib/unlang/limit.c
src/lib/unlang/load_balance.c
src/lib/unlang/map.c
src/lib/unlang/parallel.c
src/lib/unlang/return.c
src/lib/unlang/subrequest.c
src/lib/unlang/switch.c
src/lib/unlang/timeout.c
src/lib/unlang/transaction.c
src/lib/unlang/try.c
src/lib/unlang/unlang_priv.h

index 3169b358a6f1ff2f13e4387b8cc8f765c0b1dc2c..53f35896c396b04fdcdd06581faf93a537d2cbb9 100644 (file)
@@ -250,8 +250,14 @@ void unlang_call_init(void)
 {
        unlang_register(UNLANG_TYPE_CALL,
                           &(unlang_op_t){
-                               .name                   = "call",
-                               .interpret              = unlang_call_frame_init,
-                               .flag                   = UNLANG_OP_FLAG_RCODE_SET | UNLANG_OP_FLAG_DEBUG_BRACES
+                               .name           = "call",
+                               .flag           = UNLANG_OP_FLAG_RCODE_SET | UNLANG_OP_FLAG_DEBUG_BRACES,
+                               .type           = UNLANG_TYPE_CALL,
+
+                               .interpret      = unlang_call_frame_init,
+
+
+                               .unlang_size    = sizeof(unlang_call_t),
+                               .unlang_name    = "unlang_call_t",
                           });
 }
index 578e082d6729ac7078839abe84ec5bbe02e80b70..def5c58345e635918f0906f2ab238eab94c0065f 100644 (file)
@@ -57,7 +57,12 @@ void unlang_caller_init(void)
        unlang_register(UNLANG_TYPE_CALLER,
                           &(unlang_op_t){
                                .name = "caller",
+                               .type = UNLANG_TYPE_CALLER,
+                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
                                .interpret = unlang_caller,
-                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES
+
+                               .unlang_size = sizeof(unlang_caller_t),
+                               .unlang_name = "unlang_caller_t",
                           });
 }
index 5aa85e517541afb8861b1483586ae9528f003280..c607be9f274ed12509dd0590b0a71eb6fc2e0775 100644 (file)
@@ -104,7 +104,12 @@ void unlang_catch_init(void)
        unlang_register(UNLANG_TYPE_CATCH,
                           &(unlang_op_t){
                                .name = "catch",
+                               .type = UNLANG_TYPE_CATCH,
+                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
                                .interpret = unlang_catch,
-                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES
+
+                               .unlang_size = sizeof(unlang_catch_t),
+                               .unlang_name = "unlang_catch_t",
                           });
 }
index 5b5a25f1d74f828408d1b459fad2c9b8a57ce932..537880159aa8e5ad47f60def7352796f6e0127f6 100644 (file)
@@ -131,7 +131,7 @@ void compile_copy_context(unlang_compile_t *dst, unlang_compile_t const *src)
 #define UPDATE_CTX2 compile_copy_context(&unlang_ctx2, unlang_ctx)
 
 
-static unlang_t *compile_empty(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_SECTION *cs, unlang_ext_t const *ext);
+static unlang_t *compile_empty(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_SECTION *cs, unlang_type_t type);
 
 static char const unlang_spaces[] = "                                                                                                                                                                                                                                                                ";
 
@@ -553,20 +553,23 @@ int unlang_fixup_update(map_t *map, void *ctx)
 }
 
 
-static unlang_group_t *group_allocate(unlang_t *parent, CONF_SECTION *cs, unlang_ext_t const *ext)
+static unlang_group_t *group_allocate(unlang_t *parent, CONF_SECTION *cs, unlang_type_t type)
 {
        unlang_group_t  *g;
        unlang_t        *c;
        TALLOC_CTX      *ctx;
+       unlang_op_t const *op = &unlang_ops[type];
 
        ctx = parent;
        if (!ctx) ctx = cs;
 
+       fr_assert(op->unlang_size > 0);
+
        /*
         *      All the groups have a common header
         */
-       g = (unlang_group_t *)_talloc_zero_pooled_object(ctx, ext->len, ext->type_name,
-                                                        ext->pool_headers, ext->pool_len);
+       g = (unlang_group_t *)_talloc_zero_pooled_object(ctx, op->unlang_size, op->unlang_name,
+                                                        op->pool_headers, op->pool_len);
        if (!g) return NULL;
 
        g->children = NULL;
@@ -575,7 +578,7 @@ static unlang_group_t *group_allocate(unlang_t *parent, CONF_SECTION *cs, unlang
 
        c = unlang_group_to_generic(g);
        c->parent = parent;
-       c->type = ext->type;
+       c->type = type;
        c->ci = CF_TO_ITEM(cs);
 
        return g;
@@ -695,12 +698,6 @@ static unlang_t *compile_map(unlang_t *parent, unlang_compile_t *unlang_ctx, CON
 
        tmpl_rules_t            t_rules;
 
-       static unlang_ext_t const map_ext = {
-               .type = UNLANG_TYPE_MAP,
-               .len = sizeof(unlang_map_t),
-               .type_name = "unlang_map_t"
-       };
-
        /*
         *      The RHS is NOT resolved in the context of the LHS.
         */
@@ -721,7 +718,7 @@ static unlang_t *compile_map(unlang_t *parent, unlang_compile_t *unlang_ctx, CON
        }
        t_rules.literals_safe_for = map_proc_literals_safe_for(proc);
 
-       g = group_allocate(parent, cs, &map_ext);
+       g = group_allocate(parent, cs, UNLANG_TYPE_MAP);
        if (!g) return NULL;
 
        gext = unlang_group_to_map(g);
@@ -1145,12 +1142,6 @@ static unlang_t *compile_update(unlang_t *parent, unlang_compile_t *unlang_ctx,
 
        tmpl_rules_t            t_rules;
 
-       static unlang_ext_t const update_ext = {
-               .type = UNLANG_TYPE_UPDATE,
-               .len = sizeof(unlang_map_t),
-               .type_name = "unlang_map_t"
-       };
-
        if (main_config_migrate_option_get("forbid_update")) {
                cf_log_err(cs, "The use of 'update' sections is forbidden by the server configuration");
                return NULL;
@@ -1172,7 +1163,7 @@ static unlang_t *compile_update(unlang_t *parent, unlang_compile_t *unlang_ctx,
        t_rules.attr.allow_wildcard = true;
        RULES_VERIFY(&t_rules);
 
-       g = group_allocate(parent, cs, &update_ext);
+       g = group_allocate(parent, cs, UNLANG_TYPE_UPDATE);
        if (!g) return NULL;
 
        gext = unlang_group_to_map(g);
@@ -1908,7 +1899,7 @@ bool unlang_compile_actions(unlang_mod_actions_t *actions, CONF_SECTION *action_
        return true;
 }
 
-static unlang_t *compile_empty(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_SECTION *cs, unlang_ext_t const *ext)
+static unlang_t *compile_empty(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_SECTION *cs, unlang_type_t type)
 {
        unlang_group_t *g;
        unlang_t *c;
@@ -1918,12 +1909,12 @@ static unlang_t *compile_empty(unlang_t *parent, unlang_compile_t *unlang_ctx, C
         *      *interpreter* type is GROUP, even if the *debug names*
         *      are something else.
         */
-       g = group_allocate(parent, cs, ext);
+       g = group_allocate(parent, cs, type);
        if (!g) return NULL;
 
        c = unlang_group_to_generic(g);
        if (!cs) {
-               c->name = unlang_ops[ext->type].name;
+               c->name = unlang_ops[type].name;
                c->debug_name = c->name;
 
        } else {
@@ -2242,8 +2233,7 @@ static unlang_t *compile_children(unlang_group_t *g, unlang_compile_t *unlang_ct
 /*
  *     Generic "compile a section with more unlang inside of it".
  */
-static unlang_t *compile_section(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_SECTION *cs,
-                                unlang_ext_t const *ext)
+static unlang_t *compile_section(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_SECTION *cs, unlang_type_t type)
 {
        unlang_group_t  *g;
        unlang_t        *c;
@@ -2255,7 +2245,7 @@ static unlang_t *compile_section(unlang_t *parent, unlang_compile_t *unlang_ctx,
        /*
         *      We always create a group, even if the section is empty.
         */
-       g = group_allocate(parent, cs, ext);
+       g = group_allocate(parent, cs, type);
        if (!g) return NULL;
 
        c = unlang_group_to_generic(g);
@@ -2271,7 +2261,7 @@ static unlang_t *compile_section(unlang_t *parent, unlang_compile_t *unlang_ctx,
         *      Make sure to tell the user that we're running a
         *      policy, and not anything else.
         */
-       if (ext->type == UNLANG_TYPE_POLICY) {
+       if (type == UNLANG_TYPE_POLICY) {
                MEM(c->debug_name = talloc_typed_asprintf(c, "policy %s", name1));
 
        } else if (!name2) {
@@ -2287,15 +2277,9 @@ static unlang_t *compile_section(unlang_t *parent, unlang_compile_t *unlang_ctx,
 
 static unlang_t *compile_group(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_ITEM const *ci)
 {
-       static unlang_ext_t const group = {
-               .type = UNLANG_TYPE_GROUP,
-               .len = sizeof(unlang_group_t),
-               .type_name = "unlang_group_t",
-       };
-
        if (!cf_item_next(ci, NULL)) return UNLANG_IGNORE;
 
-       return compile_section(parent, unlang_ctx, cf_item_to_section(ci), &group);
+       return compile_section(parent, unlang_ctx, cf_item_to_section(ci), UNLANG_TYPE_GROUP);
 }
 
 static fr_table_num_sorted_t transaction_keywords[] = {
@@ -2386,12 +2370,6 @@ static unlang_t *compile_transaction(unlang_t *parent, unlang_compile_t *unlang_
        unlang_t *c;
        unlang_compile_t unlang_ctx2;
 
-       static unlang_ext_t const transaction = {
-               .type = UNLANG_TYPE_TRANSACTION,
-               .len = sizeof(unlang_transaction_t),
-               .type_name = "unlang_transaction_t",
-       };
-
        if (cf_section_name2(cs) != NULL) {
                cf_log_err(cs, "Unexpected argument to 'transaction' section");
                cf_log_err(ci, DOC_KEYWORD_REF(transaction));
@@ -2415,7 +2393,7 @@ static unlang_t *compile_transaction(unlang_t *parent, unlang_compile_t *unlang_
        unlang_ctx2.actions.actions[RLM_MODULE_INVALID] = MOD_ACTION_RETURN;
        unlang_ctx2.actions.actions[RLM_MODULE_DISALLOW] = MOD_ACTION_RETURN;
 
-       g = group_allocate(parent, cs, &transaction);
+       g = group_allocate(parent, cs, UNLANG_TYPE_TRANSACTION);
        if (!g) return NULL;
 
        c = unlang_group_to_generic(g);
@@ -2443,12 +2421,6 @@ static unlang_t *compile_try(unlang_t *parent, unlang_compile_t *unlang_ctx, CON
        unlang_t *c;
        CONF_ITEM *next;
 
-       static unlang_ext_t const ext = {
-               .type = UNLANG_TYPE_TRY,
-               .len = sizeof(unlang_try_t),
-               .type_name = "unlang_try_t",
-       };
-
        /*
         *      The transaction is empty, ignore it.
         */
@@ -2473,7 +2445,7 @@ static unlang_t *compile_try(unlang_t *parent, unlang_compile_t *unlang_ctx, CON
                goto print_url;
        }
 
-       g = group_allocate(parent, cs, &ext);
+       g = group_allocate(parent, cs, UNLANG_TYPE_TRY);
        if (!g) return NULL;
 
        c = unlang_group_to_generic(g);
@@ -2511,12 +2483,6 @@ static unlang_t *compile_catch(unlang_t *parent, unlang_compile_t *unlang_ctx, C
        CONF_ITEM *prev;
        char const *name;
 
-       static unlang_ext_t const ext = {
-               .type = UNLANG_TYPE_CATCH,
-               .len = sizeof(unlang_catch_t),
-               .type_name = "unlang_catch_t",
-       };
-
        prev = cf_item_prev(cf_parent(ci), ci);
        while (prev && cf_item_is_data(prev)) prev = cf_item_prev(cf_parent(ci), prev);
 
@@ -2538,7 +2504,7 @@ static unlang_t *compile_catch(unlang_t *parent, unlang_compile_t *unlang_ctx, C
                goto fail;
        }
 
-       g = group_allocate(parent, cs, &ext);
+       g = group_allocate(parent, cs, UNLANG_TYPE_CATCH);
        if (!g) return NULL;
 
        c = unlang_group_to_generic(g);
@@ -2627,14 +2593,6 @@ static unlang_t *compile_switch(unlang_t *parent, unlang_compile_t *unlang_ctx,
        fr_type_t               type;
        fr_htrie_type_t         htype;
 
-       static unlang_ext_t const switch_ext = {
-               .type = UNLANG_TYPE_SWITCH,
-               .len = sizeof(unlang_switch_t),
-               .type_name = "unlang_switch_t",
-               .pool_headers = TMPL_POOL_DEF_HEADERS,
-               .pool_len = TMPL_POOL_DEF_LEN
-       };
-
        /*
         *      We allow unknown attributes here.
         */
@@ -2652,7 +2610,7 @@ static unlang_t *compile_switch(unlang_t *parent, unlang_compile_t *unlang_ctx,
 
        if (!cf_item_next(cs, NULL)) return UNLANG_IGNORE;
 
-       g = group_allocate(parent, cs, &switch_ext);
+       g = group_allocate(parent, cs, UNLANG_TYPE_SWITCH);
        if (!g) return NULL;
 
        gext = unlang_group_to_switch(g);
@@ -2872,12 +2830,6 @@ static unlang_t *compile_case(unlang_t *parent, unlang_compile_t *unlang_ctx, CO
        tmpl_t                  *vpt = NULL;
        tmpl_rules_t            t_rules;
 
-       static unlang_ext_t const case_ext = {
-               .type = UNLANG_TYPE_CASE,
-               .len = sizeof(unlang_case_t),
-               .type_name = "unlang_case_t",
-       };
-
        /*
         *      We allow unknown attributes here.
         */
@@ -2969,7 +2921,7 @@ static unlang_t *compile_case(unlang_t *parent, unlang_compile_t *unlang_ctx, CO
         *      will silently skip the match, and then fall through to
         *      the "default" statement.
         */
-       c = compile_section(parent, unlang_ctx, cs, &case_ext);
+       c = compile_section(parent, unlang_ctx, cs, UNLANG_TYPE_CASE);
        if (!c) {
                talloc_free(vpt);
                return NULL;
@@ -3000,12 +2952,6 @@ static unlang_t *compile_timeout(unlang_t *parent, unlang_compile_t *unlang_ctx,
        tmpl_t                  *vpt = NULL;
        fr_token_t              token;
 
-       static unlang_ext_t const timeout_ext = {
-               .type = UNLANG_TYPE_TIMEOUT,
-               .len = sizeof(unlang_timeout_t),
-               .type_name = "unlang_timeout_t",
-       };
-
        /*
         *      Timeout <time ref>
         */
@@ -3019,7 +2965,7 @@ static unlang_t *compile_timeout(unlang_t *parent, unlang_compile_t *unlang_ctx,
 
        if (!cf_item_next(cs, NULL)) return UNLANG_IGNORE;
 
-       g = group_allocate(parent, cs, &timeout_ext);
+       g = group_allocate(parent, cs, UNLANG_TYPE_TIMEOUT);
        if (!g) return NULL;
 
        gext = unlang_group_to_timeout(g);
@@ -3086,7 +3032,7 @@ static unlang_t *compile_timeout(unlang_t *parent, unlang_compile_t *unlang_ctx,
        /*
         *      Compile the contents of a "timeout".
         */
-       c = compile_section(parent, unlang_ctx, cs, &timeout_ext);
+       c = compile_section(parent, unlang_ctx, cs, UNLANG_TYPE_TIMEOUT);
        if (!c) return NULL;
 
        g = unlang_generic_to_group(c);
@@ -3110,12 +3056,6 @@ static unlang_t *compile_limit(unlang_t *parent, unlang_compile_t *unlang_ctx, C
        ssize_t                 slen;
        tmpl_rules_t            t_rules;
 
-       static unlang_ext_t const limit_ext = {
-               .type = UNLANG_TYPE_LIMIT,
-               .len = sizeof(unlang_limit_t),
-               .type_name = "unlang_limit_t",
-       };
-
        /*
         *      limit <number>
         */
@@ -3129,7 +3069,7 @@ static unlang_t *compile_limit(unlang_t *parent, unlang_compile_t *unlang_ctx, C
 
        if (!cf_item_next(cs, NULL)) return UNLANG_IGNORE;
 
-       g = group_allocate(parent, cs, &limit_ext);
+       g = group_allocate(parent, cs, UNLANG_TYPE_LIMIT);
        if (!g) return NULL;
 
        gext = unlang_group_to_limit(g);
@@ -3195,7 +3135,7 @@ static unlang_t *compile_limit(unlang_t *parent, unlang_compile_t *unlang_ctx, C
        /*
         *      Compile the contents of a "limit".
         */
-       c = compile_section(parent, unlang_ctx, cs, &limit_ext);
+       c = compile_section(parent, unlang_ctx, cs, UNLANG_TYPE_LIMIT);
        if (!c) return NULL;
 
        g = unlang_generic_to_group(c);
@@ -3228,14 +3168,6 @@ static unlang_t *compile_foreach(unlang_t *parent, unlang_compile_t *unlang_ctx,
        tmpl_rules_t            t_rules;
        unlang_compile_t        unlang_ctx2;
 
-       static unlang_ext_t const foreach_ext = {
-               .type = UNLANG_TYPE_FOREACH,
-               .len = sizeof(unlang_foreach_t),
-               .type_name = "unlang_foreach_t",
-               .pool_headers = TMPL_POOL_DEF_HEADERS,
-               .pool_len = TMPL_POOL_DEF_LEN
-       };
-
        /*
         *      Ignore empty "foreach" blocks, and don't even sanity check their arguments.
         */
@@ -3257,7 +3189,7 @@ static unlang_t *compile_foreach(unlang_t *parent, unlang_compile_t *unlang_ctx,
        /*
         *      Allocate a group for the "foreach" block.
         */
-       g = group_allocate(parent, cs, &foreach_ext);
+       g = group_allocate(parent, cs, UNLANG_TYPE_FOREACH);
        if (!g) return NULL;
 
        c = unlang_group_to_generic(g);
@@ -3458,12 +3390,6 @@ static unlang_t *compile_break(unlang_t *parent, unlang_compile_t *unlang_ctx, C
 {
        unlang_t *unlang;
 
-       static unlang_ext_t const break_ext = {
-               .type = UNLANG_TYPE_BREAK,
-               .len = sizeof(unlang_group_t),
-               .type_name = "unlang_group_t",
-       };
-
        for (unlang = parent; unlang != NULL; unlang = unlang->parent) {
                /*
                 *      "break" doesn't go past a return point.
@@ -3482,19 +3408,13 @@ static unlang_t *compile_break(unlang_t *parent, unlang_compile_t *unlang_ctx, C
 
        parent->closed = true;
 
-       return compile_empty(parent, unlang_ctx, NULL, &break_ext);
+       return compile_empty(parent, unlang_ctx, NULL, UNLANG_TYPE_BREAK);
 }
 
 static unlang_t *compile_continue(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_ITEM const *ci)
 {
        unlang_t *unlang;
 
-       static unlang_ext_t const break_ext = {
-               .type = UNLANG_TYPE_CONTINUE,
-               .len = sizeof(unlang_group_t),
-               .type_name = "unlang_group_t",
-       };
-
        for (unlang = parent; unlang != NULL; unlang = unlang->parent) {
                /*
                 *      "continue" doesn't go past a return point.
@@ -3513,7 +3433,7 @@ static unlang_t *compile_continue(unlang_t *parent, unlang_compile_t *unlang_ctx
 
        parent->closed = true;
 
-       return compile_empty(parent, unlang_ctx, NULL, &break_ext);
+       return compile_empty(parent, unlang_ctx, NULL, UNLANG_TYPE_CONTINUE);
 }
 
 
@@ -3521,12 +3441,6 @@ static unlang_t *compile_detach(unlang_t *parent, unlang_compile_t *unlang_ctx,
 {
        unlang_t *subrequest;
 
-       static unlang_ext_t const detach_ext = {
-               .type = UNLANG_TYPE_DETACH,
-               .len = sizeof(unlang_group_t),
-               .type_name = "unlang_group_t",
-       };
-
        for (subrequest = parent;
             subrequest != NULL;
             subrequest = subrequest->parent) {
@@ -3548,17 +3462,11 @@ static unlang_t *compile_detach(unlang_t *parent, unlang_compile_t *unlang_ctx,
                return NULL;
        }
 
-       return compile_empty(parent, unlang_ctx, NULL, &detach_ext);
+       return compile_empty(parent, unlang_ctx, NULL, UNLANG_TYPE_DETACH);
 }
 
 static unlang_t *compile_return(unlang_t *parent, unlang_compile_t *unlang_ctx, UNUSED CONF_ITEM const *ci)
 {
-       static unlang_ext_t const return_ext = {
-               .type = UNLANG_TYPE_RETURN,
-               .len = sizeof(unlang_group_t),
-               .type_name = "unlang_group_t",
-       };
-
        /*
         *      These types are all parallel, and therefore can have a "return" in them.
         */
@@ -3573,7 +3481,7 @@ static unlang_t *compile_return(unlang_t *parent, unlang_compile_t *unlang_ctx,
                break;
        }
 
-       return compile_empty(parent, unlang_ctx, NULL, &return_ext);
+       return compile_empty(parent, unlang_ctx, NULL, UNLANG_TYPE_RETURN);
 }
 
 static unlang_t *compile_tmpl(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_ITEM *ci)
@@ -3616,8 +3524,7 @@ static const fr_sbuff_term_t if_terminals = FR_SBUFF_TERMS(
        L("{"),
 );
 
-static unlang_t *compile_if_subsection(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_SECTION *cs,
-                                      unlang_ext_t const *ext)
+static unlang_t *compile_if_subsection(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_SECTION *cs, unlang_type_t type)
 {
        unlang_t                *c;
 
@@ -3634,7 +3541,7 @@ static unlang_t *compile_if_subsection(unlang_t *parent, unlang_compile_t *unlan
        };
 
        if (!cf_section_name2(cs)) {
-               cf_log_err(cs, "'%s' without condition", unlang_ops[ext->type].name);
+               cf_log_err(cs, "'%s' without condition", unlang_ops[type].name);
                return NULL;
        }
 
@@ -3691,7 +3598,7 @@ static unlang_t *compile_if_subsection(unlang_t *parent, unlang_compile_t *unlan
                 */
                if (is_truthy && !value) {
                        cf_log_debug_prefix(cs, "Skipping contents of '%s' as it is always 'false'",
-                                           unlang_ops[ext->type].name);
+                                           unlang_ops[type].name);
 
                        /*
                         *      Free the children, which frees any xlats,
@@ -3700,10 +3607,10 @@ static unlang_t *compile_if_subsection(unlang_t *parent, unlang_compile_t *unlan
                         *
                         *      However, we still need to cache the conditions, as they will be accessed at run-time.
                         */
-                       c = compile_empty(parent, unlang_ctx, cs, ext);
+                       c = compile_empty(parent, unlang_ctx, cs, type);
                        cf_section_free_children(cs);
                } else {
-                       c = compile_section(parent, unlang_ctx, cs, ext);
+                       c = compile_section(parent, unlang_ctx, cs, type);
                }
        }
 
@@ -3741,46 +3648,24 @@ static unlang_t *compile_if_subsection(unlang_t *parent, unlang_compile_t *unlan
 
 static unlang_t *compile_if(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_ITEM const *ci)
 {
-       static unlang_ext_t const if_ext = {
-               .type = UNLANG_TYPE_IF,
-               .len = sizeof(unlang_cond_t),
-               .type_name = "unlang_cond_t",
-               .pool_headers = 1 + 1 + (TMPL_POOL_DEF_HEADERS * 2),
-               .pool_len = sizeof(map_t) + (TMPL_POOL_DEF_LEN * 2)
-       };
-
-       return compile_if_subsection(parent, unlang_ctx, cf_item_to_section(ci), &if_ext);
+       return compile_if_subsection(parent, unlang_ctx, cf_item_to_section(ci), UNLANG_TYPE_IF);
 }
 
 static unlang_t *compile_elsif(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_ITEM const *ci)
 {
-       static unlang_ext_t const elsif_ext = {
-               .type = UNLANG_TYPE_ELSIF,
-               .len = sizeof(unlang_cond_t),
-               .type_name = "unlang_cond_t",
-               .pool_headers = 1 + 1 + (TMPL_POOL_DEF_HEADERS * 2),
-               .pool_len = sizeof(map_t) + (TMPL_POOL_DEF_LEN * 2)
-       };
-
-       return compile_if_subsection(parent, unlang_ctx, cf_item_to_section(ci), &elsif_ext);
+       return compile_if_subsection(parent, unlang_ctx, cf_item_to_section(ci), UNLANG_TYPE_ELSIF);
 }
 
 static unlang_t *compile_else(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_ITEM const *ci)
 {
        CONF_SECTION *cs = cf_item_to_section(ci);
 
-       static unlang_ext_t const else_ext = {
-               .type = UNLANG_TYPE_ELSE,
-               .len = sizeof(unlang_group_t),
-               .type_name = "unlang_group_t"
-       };
-
        if (cf_section_name2(cs)) {
                cf_log_err(cs, "'else' cannot have a condition");
                return NULL;
        }
 
-       return compile_section(parent, unlang_ctx, cs, &else_ext);
+       return compile_section(parent, unlang_ctx, cs, UNLANG_TYPE_ELSE);
 }
 
 /*
@@ -3842,19 +3727,13 @@ static unlang_t *compile_redundant(unlang_t *parent, unlang_compile_t *unlang_ct
        CONF_SECTION                    *cs = cf_item_to_section(ci);
        unlang_t                        *c;
 
-       static unlang_ext_t const       redundant_ext = {
-                                               .type = UNLANG_TYPE_REDUNDANT,
-                                               .len = sizeof(unlang_group_t),
-                                               .type_name = "unlang_group_t"
-                                       };
-
        if (!cf_item_next(cs, NULL)) return UNLANG_IGNORE;
 
        if (!validate_limited_subsection(cs, cf_section_name1(cs))) {
                return NULL;
        }
 
-       c = compile_section(parent, unlang_ctx, cs, &redundant_ext);
+       c = compile_section(parent, unlang_ctx, cs, UNLANG_TYPE_REDUNDANT);
        if (!c) return NULL;
 
        /*
@@ -3865,7 +3744,7 @@ static unlang_t *compile_redundant(unlang_t *parent, unlang_compile_t *unlang_ct
 }
 
 static unlang_t *compile_load_balance_subsection(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_SECTION *cs,
-                                                unlang_ext_t const *ext)
+                                                unlang_type_t type)
 {
        char const                      *name2;
        unlang_t                        *c;
@@ -3885,13 +3764,13 @@ static unlang_t *compile_load_balance_subsection(unlang_t *parent, unlang_compil
         *      No children?  Die!
         */
        if (!cf_item_next(cs, NULL)) {
-               cf_log_err(cs, "%s sections cannot be empty", unlang_ops[ext->type].name);
+               cf_log_err(cs, "%s sections cannot be empty", unlang_ops[type].name);
                return NULL;
        }
 
        if (!validate_limited_subsection(cs, cf_section_name1(cs))) return NULL;
 
-       c = compile_section(parent, unlang_ctx, cs, ext);
+       c = compile_section(parent, unlang_ctx, cs, type);
        if (!c) return NULL;
 
        g = unlang_generic_to_group(c);
@@ -3910,18 +3789,18 @@ static unlang_t *compile_load_balance_subsection(unlang_t *parent, unlang_compil
        }
 
        if (name2) {
-               fr_token_t type;
+               fr_token_t quote;
                ssize_t slen;
 
                /*
                 *      Create the template.  All attributes and xlats are
                 *      defined by now.
                 */
-               type = cf_section_name2_quote(cs);
+               quote = cf_section_name2_quote(cs);
                gext = unlang_group_to_load_balance(g);
                slen = tmpl_afrom_substr(gext, &gext->vpt,
                                         &FR_SBUFF_IN(name2, strlen(name2)),
-                                        type,
+                                        quote,
                                         NULL,
                                         &t_rules);
                if (!gext->vpt) {
@@ -3961,25 +3840,13 @@ static unlang_t *compile_load_balance_subsection(unlang_t *parent, unlang_compil
 
 static unlang_t *compile_load_balance(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_ITEM const *ci)
 {
-       static unlang_ext_t const load_balance_ext = {
-               .type = UNLANG_TYPE_LOAD_BALANCE,
-               .len = sizeof(unlang_load_balance_t),
-               .type_name = "unlang_load_balance_t"
-       };
-
-       return compile_load_balance_subsection(parent, unlang_ctx, cf_item_to_section(ci), &load_balance_ext);
+       return compile_load_balance_subsection(parent, unlang_ctx, cf_item_to_section(ci), UNLANG_TYPE_LOAD_BALANCE);
 }
 
 
 static unlang_t *compile_redundant_load_balance(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_ITEM const *ci)
 {
-       static unlang_ext_t const redundant_load_balance_ext = {
-               .type = UNLANG_TYPE_REDUNDANT_LOAD_BALANCE,
-               .len = sizeof(unlang_load_balance_t),
-               .type_name = "unlang_load_balance_t"
-       };
-
-       return compile_load_balance_subsection(parent, unlang_ctx, cf_item_to_section(ci), &redundant_load_balance_ext);
+       return compile_load_balance_subsection(parent, unlang_ctx, cf_item_to_section(ci), UNLANG_TYPE_REDUNDANT_LOAD_BALANCE);
 }
 
 static unlang_t *compile_parallel(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_ITEM const *ci)
@@ -3994,12 +3861,6 @@ static unlang_t *compile_parallel(unlang_t *parent, unlang_compile_t *unlang_ctx
        bool                            clone = true;
        bool                            detach = false;
 
-       static unlang_ext_t const       parallel_ext = {
-                                               .type = UNLANG_TYPE_PARALLEL,
-                                               .len = sizeof(unlang_parallel_t),
-                                               .type_name = "unlang_parallel_t"
-                                       };
-
        if (!cf_item_next(cs, NULL)) return UNLANG_IGNORE;
 
        /*
@@ -4032,7 +3893,7 @@ static unlang_t *compile_parallel(unlang_t *parent, unlang_compile_t *unlang_ctx
                return NULL;
        }
 
-       c = compile_section(parent, unlang_ctx, cs, &parallel_ext);
+       c = compile_section(parent, unlang_ctx, cs, UNLANG_TYPE_PARALLEL);
        if (!c) return NULL;
 
        g = unlang_generic_to_group(c);
@@ -4068,14 +3929,6 @@ static unlang_t *compile_subrequest(unlang_t *parent, unlang_compile_t *unlang_c
 
        tmpl_t                          *vpt = NULL, *src_vpt = NULL, *dst_vpt = NULL;
 
-       static unlang_ext_t const       subrequest_ext = {
-                                               .type = UNLANG_TYPE_SUBREQUEST,
-                                               .len = sizeof(unlang_subrequest_t),
-                                               .type_name = "unlang_subrequest_t",
-                                               .pool_headers = (TMPL_POOL_DEF_HEADERS * 3),
-                                               .pool_len = (TMPL_POOL_DEF_LEN * 3)
-                                       };
-
        /*
         *      subrequest { ... }
         *
@@ -4314,7 +4167,7 @@ get_packet_type:
        /*
         *      Compile the subsection with a *different* default dictionary.
         */
-       c = compile_section(parent, &unlang_ctx2, cs, &subrequest_ext);
+       c = compile_section(parent, &unlang_ctx2, cs, UNLANG_TYPE_SUBREQUEST);
        if (!c) return NULL;
 
        /*
@@ -4359,12 +4212,6 @@ static unlang_t *compile_call(unlang_t *parent, unlang_compile_t *unlang_ctx, CO
        fr_dict_t const                 *dict;
        fr_dict_attr_t const            *attr_packet_type;
 
-       static unlang_ext_t const       call_ext = {
-                                               .type = UNLANG_TYPE_CALL,
-                                               .len = sizeof(unlang_call_t),
-                                               .type_name = "unlang_call_t",
-                                       };
-
        server = cf_section_name2(cs);
        if (!server) {
                cf_log_err(cs, "You MUST specify a server name for 'call <server> { ... }'");
@@ -4410,7 +4257,7 @@ static unlang_t *compile_call(unlang_t *parent, unlang_compile_t *unlang_ctx, CO
                return NULL;
        }
 
-       c = compile_section(parent, unlang_ctx, cs, &call_ext);
+       c = compile_section(parent, unlang_ctx, cs, UNLANG_TYPE_CALL);
        if (!c) return NULL;
 
        /*
@@ -4442,12 +4289,6 @@ static unlang_t *compile_caller(unlang_t *parent, unlang_compile_t *unlang_ctx,
 
        fr_dict_autoload_talloc_t       *dict_ref = NULL;
 
-       static unlang_ext_t const       caller_ext = {
-                                               .type = UNLANG_TYPE_CALLER,
-                                               .len = sizeof(unlang_caller_t),
-                                               .type_name = "unlang_caller_t",
-                                       };
-
        name = cf_section_name2(cs);
        if (!name) {
                cf_log_err(cs, "You MUST specify a protocol name for 'caller <protocol> { ... }'");
@@ -4488,7 +4329,7 @@ static unlang_t *compile_caller(unlang_t *parent, unlang_compile_t *unlang_ctx,
        unlang_ctx2.section_name1 = "caller";
        unlang_ctx2.section_name2 = name;
 
-       c = compile_section(parent, &unlang_ctx2, cs, &caller_ext);
+       c = compile_section(parent, &unlang_ctx2, cs, UNLANG_TYPE_CALLER);
        if (!c) {
                talloc_free(dict_ref);
                return NULL;
@@ -4526,18 +4367,6 @@ static unlang_t *compile_function(unlang_t *parent, unlang_compile_t *unlang_ctx
        unlang_compile_t                unlang_ctx2;
        unlang_t                        *c;
 
-       static unlang_ext_t const       policy_ext = {
-                                               .type = UNLANG_TYPE_POLICY,
-                                               .len = sizeof(unlang_group_t),
-                                               .type_name = "unlang_group_t",
-                                       };
-
-       static unlang_ext_t const       group_ext = {
-                                               .type = UNLANG_TYPE_GROUP,
-                                               .len = sizeof(unlang_group_t),
-                                               .type_name = "unlang_group_t",
-                                       };
-
        /*
         *      module.c takes care of ensuring that this is:
         *
@@ -4572,7 +4401,7 @@ static unlang_t *compile_function(unlang_t *parent, unlang_compile_t *unlang_ctx
                 *      group foo { ...
                 */
                c = compile_section(parent, &unlang_ctx2, subcs,
-                                   policy ? &policy_ext : &group_ext);
+                                   policy ? UNLANG_TYPE_POLICY : UNLANG_TYPE_GROUP);
        }
        if (!c) return NULL;
        fr_assert(c != UNLANG_IGNORE);
@@ -5134,11 +4963,6 @@ int unlang_compile(virtual_server_t const *vs,
        tmpl_rules_t                    my_rules;
        char const                      *name1, *name2;
        CONF_DATA const                 *cd;
-       static unlang_ext_t const       group_ext = {
-                                               .type = UNLANG_TYPE_GROUP,
-                                               .len = sizeof(unlang_group_t),
-                                               .type_name = "unlang_group_t",
-       };
 
        /*
         *      Don't compile it twice, and don't print out debug
@@ -5173,7 +4997,7 @@ int unlang_compile(virtual_server_t const *vs,
                                .actions = *actions,
                                .rules = rules
                            },
-                           cs, &group_ext);
+                           cs, UNLANG_TYPE_GROUP);
        if (!c) return -1;
 
        if (DEBUG_ENABLED4) unlang_dump(c, 2);
index e80621626ea115e377d64fe04d5e36021be4afbf..135cdd8506c0b65e42eec945bc1986c2487cdd14 100644 (file)
@@ -117,8 +117,16 @@ void unlang_condition_init(void)
        unlang_register(UNLANG_TYPE_IF,
                           &(unlang_op_t){
                                .name = "if",
-                               .interpret = unlang_if,
+                               .type = UNLANG_TYPE_IF,
                                .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
+                               .interpret = unlang_if,
+
+                               .unlang_size = sizeof(unlang_cond_t),
+                               .unlang_name = "unlang_cond_t",
+                               .pool_headers = 1 + 1 + (TMPL_POOL_DEF_HEADERS * 2),
+                               .pool_len = sizeof(map_t) + (TMPL_POOL_DEF_LEN * 2),
+
                                .frame_state_size = sizeof(unlang_frame_state_cond_t),
                                .frame_state_type = "unlang_frame_state_cond_t",
                           });
@@ -126,15 +134,28 @@ void unlang_condition_init(void)
        unlang_register(UNLANG_TYPE_ELSE,
                           &(unlang_op_t){
                                .name = "else",
+                               .type = UNLANG_TYPE_ELSE,
                                .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
-                               .interpret = unlang_group
-                          });
+
+                               .interpret = unlang_group,
+
+                               .unlang_size = sizeof(unlang_group_t),
+                               .unlang_name = "unlang_group_t" 
+                  });
 
        unlang_register(UNLANG_TYPE_ELSIF,
                           &(unlang_op_t){
                                .name = "elseif",
-                               .interpret = unlang_if,
+                               .type = UNLANG_TYPE_ELSIF,
                                .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
+                               .interpret = unlang_if,
+
+                               .unlang_size = sizeof(unlang_cond_t),
+                               .unlang_name = "unlang_cond_t",
+                               .pool_headers = 1 + 1 + (TMPL_POOL_DEF_HEADERS * 2),
+                               .pool_len = sizeof(map_t) + (TMPL_POOL_DEF_LEN * 2),
+
                                .frame_state_size = sizeof(unlang_frame_state_cond_t),
                                .frame_state_type = "unlang_frame_state_cond_t",
                           });
index 52f2de2c51126f3a479f25cb6d66769db69b918d..6431e5677ef12e59396b4461c0ffc397d7122cc4 100644 (file)
@@ -56,6 +56,11 @@ void unlang_detach_init(void)
        unlang_register(UNLANG_TYPE_DETACH,
                        &(unlang_op_t){
                                .name = "detach",
+                               .type = UNLANG_TYPE_DETACH,
+
                                .interpret = unlang_detach,
-                       });
+
+                               .unlang_size = sizeof(unlang_group_t),
+                               .unlang_name = "unlang_group_t",        
+               });
 }
index 5872b407ede65222c670772bb8fe030f3b52ede1..d8e086089e3051a4b920671719c343471b0c8ce0 100644 (file)
@@ -552,19 +552,37 @@ void unlang_foreach_init(void)
        unlang_register(UNLANG_TYPE_FOREACH,
                           &(unlang_op_t){
                                .name = "foreach",
+                               .type = UNLANG_TYPE_FOREACH,
+                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_BREAK_POINT | UNLANG_OP_FLAG_CONTINUE_POINT,
+
                                .interpret = unlang_foreach,
-                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_BREAK_POINT | UNLANG_OP_FLAG_CONTINUE_POINT
+
+                               .unlang_size = sizeof(unlang_foreach_t),
+                               .unlang_name = "unlang_foreach_t",
+
+                               .pool_headers = TMPL_POOL_DEF_HEADERS,
+                               .pool_len = TMPL_POOL_DEF_LEN
                           });
 
        unlang_register(UNLANG_TYPE_BREAK,
                           &(unlang_op_t){
                                .name = "break",
+                               .type = UNLANG_TYPE_BREAK,
+
                                .interpret = unlang_break,
+
+                               .unlang_size = sizeof(unlang_group_t),
+                               .unlang_name = "unlang_group_t",
                           });
 
        unlang_register(UNLANG_TYPE_CONTINUE,
                           &(unlang_op_t){
                                .name = "continue",
+                               .type = UNLANG_TYPE_CONTINUE,
+
                                .interpret = unlang_continue,
+
+                               .unlang_size = sizeof(unlang_group_t),
+                               .unlang_name = "unlang_group_t",
                           });
 }
index 916028f339cb696baf3c23e4d20102441fa1b59f..b44b9e90ba2c892838bb5dc06a998da7df2c1ace 100644 (file)
@@ -44,21 +44,36 @@ void unlang_group_init(void)
        unlang_register(UNLANG_TYPE_GROUP,
                           &(unlang_op_t){
                                .name = "group",
+                               .type = UNLANG_TYPE_GROUP,
+                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
                                .interpret = unlang_group,
-                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES
+
+                               .unlang_size = sizeof(unlang_group_t),
+                               .unlang_name = "unlang_group_t",
                           });
 
        unlang_register(UNLANG_TYPE_REDUNDANT,
                           &(unlang_op_t){
                                .name = "redundant",
+                               .type = UNLANG_TYPE_REDUNDANT,
+                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
                                .interpret = unlang_group,
-                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES
+
+                               .unlang_size = sizeof(unlang_group_t),
+                               .unlang_name = "unlang_group_t",
                           });
 
        unlang_register(UNLANG_TYPE_POLICY,
                           &(unlang_op_t){
                                .name = "policy",
+                               .type = UNLANG_TYPE_POLICY,
+                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RETURN_POINT,
+
                                .interpret = unlang_policy,
-                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RETURN_POINT
-                          });
+
+                               .unlang_size = sizeof(unlang_group_t),
+                               .unlang_name = "unlang_group_t",        
+                  });
 }
index b0a45de71cb86083cababf938a5029bd0bcddbf2..b59ad654c0494c160710721c2804f266902f84cb 100644 (file)
@@ -127,9 +127,15 @@ void unlang_limit_init(void)
        unlang_register(UNLANG_TYPE_LIMIT,
                           &(unlang_op_t){
                                .name = "limit",
+                               .type = UNLANG_TYPE_LIMIT,
+                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
                                .interpret = unlang_limit,
                                .signal = unlang_limit_signal,
-                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
+                               .unlang_size = sizeof(unlang_limit_t),
+                               .unlang_name = "unlang_limit_t",
+
                                .frame_state_size = sizeof(unlang_frame_state_limit_t),
                                .frame_state_type = "unlang_frame_state_limit_t",
 
index a5691c3def3d928f48be3c7d9031ce3ff9beeb7e..90b841dc3af9597f5b54e85ff9aacdc2be0b6f92 100644 (file)
@@ -247,8 +247,14 @@ void unlang_load_balance_init(void)
        unlang_register(UNLANG_TYPE_LOAD_BALANCE,
                           &(unlang_op_t){
                                .name = "load-balance group",
-                               .interpret = unlang_load_balance,
+                               .type = UNLANG_TYPE_LOAD_BALANCE,
                                .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET,
+
+                               .interpret = unlang_load_balance,
+
+                               .unlang_size = sizeof(unlang_load_balance_t),
+                               .unlang_name = "unlang_load_balance_t",
+
                                .frame_state_size = sizeof(unlang_frame_state_redundant_t),
                                .frame_state_type = "unlang_frame_state_redundant_t",
                           });
@@ -256,8 +262,14 @@ void unlang_load_balance_init(void)
        unlang_register(UNLANG_TYPE_REDUNDANT_LOAD_BALANCE,
                           &(unlang_op_t){
                                .name = "redundant-load-balance group",
-                               .interpret = unlang_redundant_load_balance,
+                               .type = UNLANG_TYPE_REDUNDANT_LOAD_BALANCE,     
                                .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET,
+
+                               .interpret = unlang_redundant_load_balance,
+
+                               .unlang_size = sizeof(unlang_load_balance_t),
+                               .unlang_name = "unlang_load_balance_t",
+
                                .frame_state_size = sizeof(unlang_frame_state_redundant_t),
                                .frame_state_type = "unlang_frame_state_redundant_t",
                           });
index 8ccab42c2be9ec5be9bfba24747f1d43c27881e8..f5c91eabf6d310bf370972039099bab1cd7cfd87 100644 (file)
@@ -449,15 +449,26 @@ void unlang_map_init(void)
        unlang_register(UNLANG_TYPE_UPDATE,
                           &(unlang_op_t){
                                .name = "update",
+                               .type = UNLANG_TYPE_UPDATE,
+                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
                                .interpret = unlang_update_state_init,
-                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES
+
+                               .unlang_size = sizeof(unlang_map_t),
+                               .unlang_name = "unlang_map_t",
                           });
 
        unlang_register(UNLANG_TYPE_MAP,
                           &(unlang_op_t){
                                .name = "map",
+                               .type = UNLANG_TYPE_MAP,
                                .flag = UNLANG_OP_FLAG_RCODE_SET,
+
                                .interpret = unlang_map_state_init,
+
+                               .unlang_size = sizeof(unlang_map_t),
+                               .unlang_name = "unlang_map_t",
+
                                .frame_state_size = sizeof(unlang_frame_state_map_proc_t),
                                .frame_state_type = "unlang_frame_state_map_proc_t",
                           });
index cb0816cdfd0f4438fbd3d25838d7879437a9d440..35f1032aa73a449a2adec3433124a78ce318a3fe 100644 (file)
@@ -382,8 +382,13 @@ void unlang_parallel_init(void)
        unlang_register(UNLANG_TYPE_PARALLEL,
                           &(unlang_op_t){
                                .name = "parallel",
+                               .type = UNLANG_TYPE_PARALLEL,   
+                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET | UNLANG_OP_FLAG_NO_FORCE_UNWIND,
+
                                .interpret = unlang_parallel,
                                .signal = unlang_parallel_signal,
-                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET | UNLANG_OP_FLAG_NO_FORCE_UNWIND
+
+                               .unlang_size = sizeof(unlang_parallel_t),
+                               .unlang_name = "unlang_parallel_t"
                           });
 }
index ae05160c089f63c657858195fb31a9572e26b645..b43a420e14c4944fd7734eee65d4c18b3f389307 100644 (file)
@@ -51,6 +51,11 @@ void unlang_return_init(void)
        unlang_register(UNLANG_TYPE_RETURN,
                           &(unlang_op_t){
                                .name = "return",
+                               .type = UNLANG_TYPE_RETURN,
+
                                .interpret = unlang_return,
+
+                               .unlang_size = sizeof(unlang_group_t),
+                               .unlang_name = "unlang_group_t",
                           });
 }
index 76940199050bf0fc53cc91e15377347542d50ec4..652a59fe9ba84e07280f38ebd2e30738ab391644 100644 (file)
@@ -523,8 +523,8 @@ int unlang_subrequest_op_init(void)
        unlang_register(UNLANG_TYPE_SUBREQUEST,
                        &(unlang_op_t){
                                .name = "subrequest",
-                               .interpret = unlang_subrequest_init,
-                               .signal = unlang_subrequest_signal,
+                               .type = UNLANG_TYPE_SUBREQUEST,
+
                                /*
                                 *      Frame can't be cancelled, because children need to
                                 *      write out status to the parent.  If we don't do this,
@@ -537,6 +537,16 @@ int unlang_subrequest_op_init(void)
                                 *      guaranteed the parent still exists.
                                 */
                                .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET | UNLANG_OP_FLAG_NO_FORCE_UNWIND,
+
+                               .interpret = unlang_subrequest_init,
+                               .signal = unlang_subrequest_signal,
+
+
+                               .unlang_size = sizeof(unlang_subrequest_t),
+                               .unlang_name = "unlang_subrequest_t",
+                               .pool_headers = (TMPL_POOL_DEF_HEADERS * 3),
+                               .pool_len = (TMPL_POOL_DEF_LEN * 3),
+
                                .frame_state_size = sizeof(unlang_child_request_t),
                                .frame_state_type = "unlang_child_request_t",
                        });
index 68430d1154f56ba1226abd6f27ffe098cd33f291..5c68bfbbb3311735ba9623311f6a1281798e349b 100644 (file)
@@ -133,14 +133,29 @@ void unlang_switch_init(void)
        unlang_register(UNLANG_TYPE_SWITCH,
                           &(unlang_op_t){
                                .name = "switch",
+                               .type = UNLANG_TYPE_SWITCH,
+                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
                                .interpret = unlang_switch,
-                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES
+                                       
+
+                               .unlang_size = sizeof(unlang_switch_t),
+                               .unlang_name = "unlang_switch_t",
+
+                               .pool_headers = TMPL_POOL_DEF_HEADERS,
+                               .pool_len = TMPL_POOL_DEF_LEN
                           });
 
+
        unlang_register(UNLANG_TYPE_CASE,
                           &(unlang_op_t){
                                .name = "case",
+                               .type = UNLANG_TYPE_CASE,
+                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_BREAK_POINT,
+
                                .interpret = unlang_case,
-                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_BREAK_POINT
+
+                               .unlang_size = sizeof(unlang_case_t),
+                               .unlang_name = "unlang_case_t",
                           });
 }
index 6c17a9615761d785894b37f9feace2575ee85d59..73c90d260feb4afd1235eed0b865229fa8daaba4 100644 (file)
@@ -270,9 +270,15 @@ void unlang_timeout_init(void)
        unlang_register(UNLANG_TYPE_TIMEOUT,
                        &(unlang_op_t){
                                .name = "timeout",
-                               .interpret = unlang_timeout,
+                               .type = UNLANG_TYPE_TIMEOUT,
                                .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET,
+
+                               .interpret = unlang_timeout,
                                .signal = unlang_timeout_signal,
+
+                               .unlang_size = sizeof(unlang_timeout_t),
+                               .unlang_name = "unlang_timeout_t",
+
                                .frame_state_size = sizeof(unlang_frame_state_timeout_t),
                                .frame_state_type = "unlang_frame_state_timeout_t",
                        });
index dc081b90d02db18862a3f053b5fa7df81df76f5e..746d91503c11b95e02cee1d984487d960df75d9f 100644 (file)
@@ -139,10 +139,16 @@ void unlang_transaction_init(void)
        unlang_register(UNLANG_TYPE_TRANSACTION,
                           &(unlang_op_t){
                                .name = "transaction",
+                               .type = UNLANG_TYPE_TRANSACTION,
+                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
                                .interpret = unlang_transaction,
                                .signal = unlang_transaction_signal,
+
+                               .unlang_size = sizeof(unlang_transaction_t),
+                               .unlang_name = "unlang_transaction_t",
+
                                .frame_state_size = sizeof(unlang_frame_state_transaction_t),
                                .frame_state_type = "unlang_frame_state_transaction_t",
-                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES
                           });
 }
index 9317672fec6c569107c74368fe2aa7e803b0f50a..b76b97494b0c0634602471ceb895529121d9bcb7 100644 (file)
@@ -25,6 +25,7 @@
 RCSID("$Id$")
 
 #include "unlang_priv.h"
+#include "try_priv.h"
 #include "catch_priv.h"
 
 static unlang_action_t unlang_try(UNUSED unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
@@ -44,7 +45,12 @@ void unlang_try_init(void)
        unlang_register(UNLANG_TYPE_TRY,
                           &(unlang_op_t){
                                .name = "try",
+                               .type = UNLANG_TYPE_TRY,
+                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
                                .interpret = unlang_try,
-                               .flag = UNLANG_OP_FLAG_DEBUG_BRACES
+
+                               .unlang_size = sizeof(unlang_try_t),
+                               .unlang_name = "unlang_try_t",
                           });
 }
index 1eaf62b04088f85ef1209ba02b92d8a1ebf7201b..92aa232af9392741e47390de1c5970f98746cb19 100644 (file)
@@ -139,17 +139,6 @@ struct unlang_s {
        unlang_mod_actions_t    actions;        //!< Priorities, etc. for the various return codes.
 };
 
-/** Describes how to allocate an #unlang_group_t with additional memory keyword specific data
- *
- */
-typedef struct {
-       unlang_type_t           type;           //!< Keyword.
-       size_t                  len;            //!< Total length of the unlang_group_t + specialisation struct.
-       unsigned                pool_headers;   //!< How much additional space to allocate for chunk headers.
-       size_t                  pool_len;       //!< How much additional space to allocate for extensions.
-       char const              *type_name;     //!< Talloc type name.
-} unlang_ext_t;
-
 typedef struct {
        fr_dict_t               *dict;          //!< our dictionary
        fr_dict_attr_t const    *root;          //!< the root of our dictionary
@@ -237,7 +226,8 @@ DIAG_ON(attributes)
  * will return an #unlang_action_t, which determines what the interpreter does next.
  */
 typedef struct {
-       char const              *name;                          //!< Name of the operation.
+       char const              *name;                          //!< Name of the keyword
+       unlang_type_t           type;                           //!< enum value for the keyword
 
        unlang_process_t        interpret;                      //!< Function to interpret the keyword
 
@@ -245,6 +235,13 @@ typedef struct {
 
        unlang_dump_t           dump;                           //!< Dump additional information about the frame state.
 
+       size_t                  unlang_size;                    //!< Total length of the unlang_t + specialisation struct.
+       char const              *unlang_name;                   //!< Talloc type name for the unlang_t
+
+       unsigned                pool_headers;                   //!< How much additional space to allocate for chunk headers.
+       size_t                  pool_len;                       //!< How much additional space to allocate for chunks
+
+
        unlang_thread_instantiate_t thread_instantiate;         //!< per-thread instantiation function
        size_t                  thread_inst_size;
        char const              *thread_inst_type;