The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
rcode.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 of the License, or
6 * (at your option) 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
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/**
19 * $Id: 3bca4d4610f74244cb6d7a994ff66f76b61dc5b1 $
20 *
21 * @file lib/server/rcode.h
22 * @brief Return codes returned by modules and virtual server sections
23 *
24 * @copyright 2018 The FreeRADIUS server project
25 */
26RCSIDH(rcode_h, "$Id: 3bca4d4610f74244cb6d7a994ff66f76b61dc5b1 $")
27
28#include <freeradius-devel/util/table.h>
29#include <freeradius-devel/unlang/action.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/** Return codes indicating the result of the module call
36 *
37 * All module functions must return one of the codes listed below (apart from
38 * RLM_MODULE_NUMCODES, which is used to check for validity).
39 */
40typedef enum {
41 RLM_MODULE_REJECT = 0, //!< Immediately reject the request.
42 RLM_MODULE_FAIL, //!< Module failed, don't reply.
43 RLM_MODULE_OK, //!< The module is OK, continue.
44 RLM_MODULE_HANDLED, //!< The module handled the request, so stop.
45 RLM_MODULE_INVALID, //!< The module considers the request invalid.
46 RLM_MODULE_DISALLOW, //!< Reject the request (user is locked out).
47 RLM_MODULE_NOTFOUND, //!< User not found.
48 RLM_MODULE_NOOP, //!< Module succeeded without doing anything.
49 RLM_MODULE_UPDATED, //!< OK (pairs modified).
50 RLM_MODULE_TIMEOUT, //!< Module (or section) timed out.
51 RLM_MODULE_NUMCODES, //!< How many valid return codes there are.
52 RLM_MODULE_NOT_SET, //!< Error resolving rcode (should not be
53 //!< returned by modules).
55
56#define RETURN_MODULE_REJECT do { *p_result = RLM_MODULE_REJECT; return UNLANG_ACTION_CALCULATE_RESULT; } while (0)
57#define RETURN_MODULE_FAIL do { *p_result = RLM_MODULE_FAIL; return UNLANG_ACTION_CALCULATE_RESULT; } while (0)
58#define RETURN_MODULE_OK do { *p_result = RLM_MODULE_OK; return UNLANG_ACTION_CALCULATE_RESULT; } while (0)
59#define RETURN_MODULE_HANDLED do { *p_result = RLM_MODULE_HANDLED; return UNLANG_ACTION_CALCULATE_RESULT; } while (0)
60#define RETURN_MODULE_INVALID do { *p_result = RLM_MODULE_INVALID; return UNLANG_ACTION_CALCULATE_RESULT; } while (0)
61#define RETURN_MODULE_DISALLOW do { *p_result = RLM_MODULE_DISALLOW; return UNLANG_ACTION_CALCULATE_RESULT; } while (0)
62#define RETURN_MODULE_NOTFOUND do { *p_result = RLM_MODULE_NOTFOUND; return UNLANG_ACTION_CALCULATE_RESULT; } while (0)
63#define RETURN_MODULE_NOOP do { *p_result = RLM_MODULE_NOOP; return UNLANG_ACTION_CALCULATE_RESULT; } while (0)
64#define RETURN_MODULE_UPDATED do { *p_result = RLM_MODULE_UPDATED; return UNLANG_ACTION_CALCULATE_RESULT; } while (0)
65#define RETURN_MODULE_TIMEOUT do { *p_result = RLM_MODULE_TIMEOUT; return UNLANG_ACTION_CALCULATE_RESULT; } while (0)
66#define RETURN_MODULE_RCODE(_rcode) do { *p_result = (_rcode); return UNLANG_ACTION_CALCULATE_RESULT; } while (0)
67
68/** Don't modify the current rcode
69 */
70#define RETURN_MODULE_TRANSPARENT do { \
71 rlm_rcode_t _rcode = *p_result; \
72 *p_result = _rcode; \
73 return UNLANG_ACTION_CALCULATE_RESULT; \
74 } while (0)
75
77extern size_t rcode_table_len;
78
79/** Rcodes that translate to a user configurable section failing overall
80 *
81 */
82#define RLM_MODULE_USER_SECTION_REJECT \
83 RLM_MODULE_REJECT: \
84 case RLM_MODULE_FAIL: \
85 case RLM_MODULE_INVALID: \
86 case RLM_MODULE_DISALLOW: \
87 case RLM_MODULE_TIMEOUT
88
89#ifdef __cplusplus
90}
91#endif
#define RCSIDH(h, id)
Definition build.h:486
size_t rcode_table_len
Definition rcode.c:47
fr_table_num_sorted_t const rcode_table[]
Definition rcode.c:35
rlm_rcode_t
Return codes indicating the result of the module call.
Definition rcode.h:40
@ RLM_MODULE_INVALID
The module considers the request invalid.
Definition rcode.h:45
@ RLM_MODULE_OK
The module is OK, continue.
Definition rcode.h:43
@ RLM_MODULE_FAIL
Module failed, don't reply.
Definition rcode.h:42
@ RLM_MODULE_DISALLOW
Reject the request (user is locked out).
Definition rcode.h:46
@ RLM_MODULE_REJECT
Immediately reject the request.
Definition rcode.h:41
@ RLM_MODULE_TIMEOUT
Module (or section) timed out.
Definition rcode.h:50
@ RLM_MODULE_NOTFOUND
User not found.
Definition rcode.h:47
@ RLM_MODULE_UPDATED
OK (pairs modified).
Definition rcode.h:49
@ RLM_MODULE_NOT_SET
Error resolving rcode (should not be returned by modules).
Definition rcode.h:52
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
Definition rcode.h:48
@ RLM_MODULE_NUMCODES
How many valid return codes there are.
Definition rcode.h:51
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
Definition rcode.h:44
An element in a lexicographically sorted array of name to num mappings.
Definition table.h:49