The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
mod_action.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2, or (at your option)
6 * any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17
18/**
19 * $Id: 5b4b28f03b9c91f2d524525f9663931d969fdf08 $
20 *
21 * @file unlang/mod_action.h
22 * @brief Unlang module actions
23 *
24 * @copyright 2024 The FreeRADIUS server project
25 */
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#include <freeradius-devel/server/rcode.h>
32#include <freeradius-devel/util/retry.h>
33
34#define MOD_PRIORITY(_x) ((_x) | 0x80)
35#define MOD_DEFINE(_x) MOD_PRIORITY_ ## _x = MOD_PRIORITY(_x)
36
37typedef enum {
38 MOD_ACTION_NOT_SET = 0, //!< default "not set by anything"
39 MOD_ACTION_RETRY = 1, //!< retry the instruction, MUST also set a retry config
40 MOD_ACTION_REJECT = 2, //!< change the rcode to REJECT, with unset priority
41 MOD_ACTION_RETURN = 3, //!< stop processing the section,
42 //!< and return the rcode with unset priority
43
45 MOD_DEFINE(2),
46 MOD_DEFINE(3),
47 MOD_DEFINE(4),
48 MOD_DEFINE(5),
49 MOD_DEFINE(6),
50 MOD_DEFINE(7),
51 MOD_DEFINE(8),
52
53 /*
54 * If ubsan or the compiler complains
55 * about the missing enum values we'll
56 * need to add them here.
57 *
58 * Defining MOD_PRIORITY_MAX ensures the
59 * enum will always be large enough.
60 */
63
64#define MOD_PRIORITY_MIN MOD_PRIORITY_1
65#define MOD_ACTION_VALID(_x) ((((_x) >= 0) && ((_x) <= 3)) || (((_x) >= MOD_PRIORITY_MIN) && ((_x) <= MOD_PRIORITY_MAX)))
66#define MOD_ACTION_VALID_SET(_x) ((((_x) > 0) && ((_x) <= 3)) || (((_x) >= MOD_PRIORITY_MIN) && ((_x) <= MOD_PRIORITY_MAX)))
67
72
73#define DEFAULT_MOD_ACTIONS { .actions = {}, .retry = RETRY_INIT }
74#define MOD_ACTIONS_FAIL_TIMEOUT_RETURN { .actions = { [RLM_MODULE_FAIL] = MOD_ACTION_RETURN, [RLM_MODULE_TIMEOUT] = MOD_ACTION_RETURN,}, .retry = RETRY_INIT }
75
81extern const char *mod_action_name[MOD_PRIORITY_MAX + 1];
82
83#ifdef __cplusplus
84}
85#endif
unlang_mod_actions_t const mod_actions_preacct
Definition mod_action.c:62
const char * mod_action_name[MOD_PRIORITY_MAX+1]
Definition mod_action.c:113
unlang_mod_action_t
Definition mod_action.h:37
@ MOD_ACTION_NOT_SET
default "not set by anything"
Definition mod_action.h:38
@ MOD_ACTION_RETURN
stop processing the section, and return the rcode with unset priority
Definition mod_action.h:41
@ MOD_ACTION_REJECT
change the rcode to REJECT, with unset priority
Definition mod_action.h:40
@ MOD_PRIORITY_MAX
Definition mod_action.h:61
@ MOD_ACTION_RETRY
retry the instruction, MUST also set a retry config
Definition mod_action.h:39
unlang_mod_actions_t const mod_actions_authenticate
Definition mod_action.c:30
unlang_mod_actions_t const mod_actions_accounting
Definition mod_action.c:78
fr_retry_config_t retry
Definition mod_action.h:70
unlang_mod_actions_t const mod_actions_authorize
Definition mod_action.c:46
#define MOD_PRIORITY(_x)
Definition mod_action.h:34
#define MOD_DEFINE(_x)
Definition mod_action.h:35
unlang_mod_actions_t const mod_actions_postauth
Definition mod_action.c:93
@ RLM_MODULE_NUMCODES
How many valid return codes there are.
Definition rcode.h:53