The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
detach.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: 374320ef33d86d7f95ae366d487a711c1a563ac5 $
19 *
20 * @file unlang/detach.c
21 * @brief Unlang detach keyword
22 *
23 * @copyright 2021 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
24 */
25RCSID("$Id: 374320ef33d86d7f95ae366d487a711c1a563ac5 $")
26
27#include "unlang_priv.h"
28
29/** Signal a child to detach
30 *
31 */
33{
34 /*
35 * Signal all frames in the child's stack
36 * that it's time to detach.
37 */
39
40 /*
41 * Detach failed...
42 */
43 if (unlikely(request->parent != NULL)) {
45 }
46
47 p_result->rcode = RLM_MODULE_NOT_SET;
49}
50
52{
53 unlang_t *subrequest;
54
55 for (subrequest = parent;
56 subrequest != NULL;
57 subrequest = subrequest->parent) {
58 if (subrequest->type == UNLANG_TYPE_SUBREQUEST) break;
59 }
60
61 if (!subrequest) {
62 cf_log_err(ci, "'detach' can only be used inside of a 'subrequest' section.");
63 cf_log_err(ci, DOC_KEYWORD_REF(detach));
64 return NULL;
65 }
66
67 /*
68 * This really overloads the functionality of
69 * cf_item_next().
70 */
71 if ((parent == subrequest) && !cf_item_next(ci, ci)) {
72 cf_log_err(ci, "'detach' cannot be used as the last entry in a section, as there is nothing more to do");
73 return NULL;
74 }
75
77}
78
79/** Initialise subrequest ops
80 *
81 */
83{
85 .name = "detach",
86 .type = UNLANG_TYPE_DETACH,
88
89 .compile = unlang_compile_detach,
90 .interpret = unlang_detach,
91
92 .unlang_size = sizeof(unlang_group_t),
93 .unlang_name = "unlang_group_t",
94 });
95}
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
@ UNLANG_ACTION_CALCULATE_RESULT
Calculate a new section rlm_rcode_t value.
Definition action.h:37
#define RCSID(id)
Definition build.h:485
#define unlikely(_x)
Definition build.h:383
#define UNUSED
Definition build.h:317
Common header for all CONF_* types.
Definition cf_priv.h:49
#define cf_log_err(_cf, _fmt,...)
Definition cf_util.h:289
#define cf_item_next(_parent, _curr)
Definition cf_util.h:92
unlang_t * unlang_compile_empty(unlang_t *parent, UNUSED unlang_compile_ctx_t *unlang_ctx, CONF_SECTION *cs, unlang_type_t type)
Definition compile.c:1233
static unlang_action_t unlang_detach(unlang_result_t *p_result, request_t *request, UNUSED unlang_stack_frame_t *frame)
Signal a child to detach.
Definition detach.c:32
static unlang_t * unlang_compile_detach(unlang_t *parent, unlang_compile_ctx_t *unlang_ctx, CONF_ITEM const *ci)
Definition detach.c:51
void unlang_detach_init(void)
Initialise subrequest ops.
Definition detach.c:82
void unlang_interpret_signal(request_t *request, fr_signal_t action)
Send a signal (usually stop) to a request.
Definition interpret.c:1396
rlm_rcode_t rcode
The current rcode, from executing the instruction or merging the result from a frame.
Definition interpret.h:134
static TALLOC_CTX * unlang_ctx
Definition base.c:71
void unlang_register(unlang_op_t *op)
Register an operation with the interpreter.
Definition base.c:56
#define RETURN_UNLANG_FAIL
Definition rcode.h:57
@ RLM_MODULE_NOT_SET
Error resolving rcode (should not be returned by modules).
Definition rcode.h:52
@ FR_SIGNAL_DETACH
Request is being detached from its parent.
Definition signal.h:45
unlang_t * parent
Previous node.
@ UNLANG_TYPE_SUBREQUEST
create a child subrequest
Definition unlang_priv.h:66
@ UNLANG_TYPE_DETACH
detach a child
Definition unlang_priv.h:69
@ UNLANG_OP_FLAG_SINGLE_WORD
the operation is parsed and compiled as a single word
unlang_type_t type
The specialisation of this node.
Generic representation of a grouping.
An unlang operation.
A node in a graph of unlang_op_t (s) that we execute.
Our interpreter stack, as distinct from the C stack.
static fr_slen_t parent
Definition pair.h:839
#define DOC_KEYWORD_REF(_x)
Definition version.h:89