The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
module_filter.c
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: 0731acdda4fc035784cade6d4e74b665d38cbeab $
19 *
20 * @file unlang/module_filter.c
21 * @brief Functions populate a module list filter from compiled unlang actions.
22 *
23 * @copyright 2026 The FreeRADIUS server project
24 */
25RCSID("$Id: 0731acdda4fc035784cade6d4e74b665d38cbeab $")
26
27#include "edit_priv.h"
28#include "module_filter.h"
29#include "module_priv.h"
30#include "xlat_priv.h"
31
33{
34 xlat_exp_t const *exp = NULL;
35
36 while ((exp = xlat_exp_next(head, exp))) {
37 switch (exp->type) {
38 case XLAT_FUNC:
39 if (module_list_filter_add(filter, exp->call.func->mctx->mi) < 0) return -1;
40 break;
41
42 case XLAT_GROUP:
43 if (unlang_xlat_module_filter_populate(exp->group, filter) < 0) return -1;
44 break;
45
46 default:
47 break;
48 }
49 }
50 return 0;
51}
52
54{
55 switch (u->type) {
57 case UNLANG_TYPE_IF:
67 case UNLANG_TYPE_TRY:
72 {
73 /*
74 * For each of the group types, walk the children
75 */
77 unlang_list_foreach(&g->children, child) {
78 if (unlang_module_filter_populate(child, filter) < 0) return -1;
79 }
80 }
81 break;
82
84 {
86 if (module_list_filter_add(filter, m->mmc.mi) < 0) return -1;
87 }
88 break;
89
91 {
93 if (tmpl_is_xlat(t->tmpl) &&
94 (unlang_xlat_module_filter_populate(t->tmpl->data.xlat.ex, filter) < 0)) return -1;
95 }
96 break;
97
99 {
101 map_t *map = NULL;
102
103 while ((map = map_list_next(&e->maps, map))) {
104 if (tmpl_is_xlat(map->rhs) &&
105 (unlang_xlat_module_filter_populate(map->rhs->data.xlat.ex, filter) < 0)) return -1;
106 }
107 }
108 break;
109
110 default:
111 break;
112 }
113
114 return 0;
115}
#define RCSID(id)
Definition build.h:609
map_list_t maps
Head of the map list.
Definition edit_priv.h:33
static unlang_edit_t * unlang_generic_to_edit(unlang_t const *p)
Cast a generic structure to the edit extension.
Definition edit_priv.h:39
int unlang_module_filter_populate(unlang_t *u, module_list_filter_t *filter)
static int unlang_xlat_module_filter_populate(xlat_exp_head_t const *head, module_list_filter_t *filter)
Declarations for the unlang module interface.
static unlang_module_t * unlang_generic_to_module(unlang_t const *p)
Definition module_priv.h:86
module_method_call_t mmc
Everything needed to call a module method.
Definition module_priv.h:38
A call to a module method.
Definition module_priv.h:35
module_instance_t * mi
The process modules also push module calls onto the stack for execution.
Definition module_rlm.h:63
#define tmpl_is_xlat(vpt)
Definition tmpl.h:217
int module_list_filter_add(module_list_filter_t *filter, module_instance_t const *mi)
Add a module instance to a list filter.
Definition module.c:2009
A module list filter.
Definition module.c:58
Value pair map.
Definition map.h:77
tmpl_t * rhs
Typically describes a literal value or a src attribute to copy or compare.
Definition map.h:79
static fr_slen_t head
Definition xlat.h:410
#define unlang_list_foreach(_list_head, _iter)
static unlang_group_t * unlang_generic_to_group(unlang_t const *p)
unlang_list_t children
static unlang_tmpl_t * unlang_generic_to_tmpl(unlang_t const *p)
@ UNLANG_TYPE_SWITCH
Switch section.
Definition unlang_priv.h:59
@ UNLANG_TYPE_SUBREQUEST
create a child subrequest
Definition unlang_priv.h:67
@ UNLANG_TYPE_ELSIF
!Condition && Condition.
Definition unlang_priv.h:58
@ UNLANG_TYPE_ELSE
!Condition.
Definition unlang_priv.h:57
@ UNLANG_TYPE_LOAD_BALANCE
Load balance section.
Definition unlang_priv.h:53
@ UNLANG_TYPE_GROUP
Grouping section.
Definition unlang_priv.h:51
@ UNLANG_TYPE_TMPL
asynchronously expand a tmpl_t
Definition unlang_priv.h:81
@ UNLANG_TYPE_CASE
Case section (within a UNLANG_TYPE_SWITCH).
Definition unlang_priv.h:60
@ UNLANG_TYPE_TRY
try / catch blocks
Definition unlang_priv.h:76
@ UNLANG_TYPE_CALL
call another virtual server
Definition unlang_priv.h:71
@ UNLANG_TYPE_REDUNDANT
exactly like group, but with different default return codes
Definition unlang_priv.h:52
@ UNLANG_TYPE_IF
Condition.
Definition unlang_priv.h:56
@ UNLANG_TYPE_TIMEOUT
time-based timeouts.
Definition unlang_priv.h:73
@ UNLANG_TYPE_MODULE
Module method.
Definition unlang_priv.h:49
@ UNLANG_TYPE_REDUNDANT_LOAD_BALANCE
Redundant load balance section.
Definition unlang_priv.h:54
@ UNLANG_TYPE_CATCH
catch a previous try
Definition unlang_priv.h:77
@ UNLANG_TYPE_EDIT
edit VPs in place. After 20 years!
Definition unlang_priv.h:82
@ UNLANG_TYPE_FOREACH
Foreach section.
Definition unlang_priv.h:61
@ UNLANG_TYPE_PARALLEL
execute statements in parallel
Definition unlang_priv.h:55
tmpl_t const * tmpl
unlang_type_t type
The specialisation of this node.
Generic representation of a grouping.
A node in a graph of unlang_op_t (s) that we execute.
A naked xlat.
String expansion ("translation").
@ XLAT_FUNC
xlat module
Definition xlat_priv.h:112
@ XLAT_GROUP
encapsulated string of xlats
Definition xlat_priv.h:118
static xlat_exp_t * xlat_exp_next(xlat_exp_head_t const *head, xlat_exp_t const *node)
Definition xlat_priv.h:249
xlat_type_t _CONST type
type of this expansion.
Definition xlat_priv.h:157
An xlat expansion node.
Definition xlat_priv.h:150