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: b0b0d6b34a9ce9df8708903e33384158d0437ac7 $
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: b0b0d6b34a9ce9df8708903e33384158d0437ac7 $")
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_NOT_SET = 0, //!< Error resolving rcode (should not be
42 //!< returned by modules).
43 RLM_MODULE_REJECT, //!< Immediately reject the request.
44 RLM_MODULE_FAIL, //!< Module failed, don't reply.
45 RLM_MODULE_OK, //!< The module is OK, continue.
46 RLM_MODULE_HANDLED, //!< The module handled the request, so stop.
47 RLM_MODULE_INVALID, //!< The module considers the request invalid.
48 RLM_MODULE_DISALLOW, //!< Reject the request (user is locked out).
49 RLM_MODULE_NOTFOUND, //!< User not found.
50 RLM_MODULE_NOOP, //!< Module succeeded without doing anything.
51 RLM_MODULE_UPDATED, //!< OK (pairs modified).
52 RLM_MODULE_TIMEOUT, //!< Module (or section) timed out.
53 RLM_MODULE_NUMCODES, //!< How many valid return codes there are.
55
56
57#define RETURN_UNLANG_RCODE(_rcode) do { p_result->rcode = (_rcode); return UNLANG_ACTION_CALCULATE_RESULT; } while (0)
58#define RETURN_UNLANG_REJECT RETURN_UNLANG_RCODE(RLM_MODULE_REJECT)
59#define RETURN_UNLANG_FAIL RETURN_UNLANG_RCODE(RLM_MODULE_FAIL)
60#define RETURN_UNLANG_OK RETURN_UNLANG_RCODE(RLM_MODULE_OK)
61#define RETURN_UNLANG_HANDLED RETURN_UNLANG_RCODE(RLM_MODULE_HANDLED)
62#define RETURN_UNLANG_INVALID RETURN_UNLANG_RCODE(RLM_MODULE_INVALID)
63#define RETURN_UNLANG_DISALLOW RETURN_UNLANG_RCODE(RLM_MODULE_DISALLOW)
64#define RETURN_UNLANG_NOTFOUND RETURN_UNLANG_RCODE(RLM_MODULE_NOTFOUND)
65#define RETURN_UNLANG_NOOP RETURN_UNLANG_RCODE(RLM_MODULE_NOOP)
66#define RETURN_UNLANG_UPDATED RETURN_UNLANG_RCODE(RLM_MODULE_UPDATED)
67#define RETURN_UNLANG_TIMEOUT RETURN_UNLANG_RCODE(RLM_MODULE_TIMEOUT)
68
70extern size_t rcode_table_len;
71
72/** Rcodes that translate to a user configurable section failing overall
73 *
74 */
75#define RLM_MODULE_USER_SECTION_REJECT \
76 RLM_MODULE_REJECT: \
77 case RLM_MODULE_FAIL: \
78 case RLM_MODULE_INVALID: \
79 case RLM_MODULE_DISALLOW: \
80 case RLM_MODULE_TIMEOUT
81
82#ifdef __cplusplus
83}
84#endif
#define RCSIDH(h, id)
Definition build.h:486
size_t rcode_table_len
Definition rcode.c:48
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:47
@ RLM_MODULE_OK
The module is OK, continue.
Definition rcode.h:45
@ RLM_MODULE_FAIL
Module failed, don't reply.
Definition rcode.h:44
@ RLM_MODULE_DISALLOW
Reject the request (user is locked out).
Definition rcode.h:48
@ RLM_MODULE_REJECT
Immediately reject the request.
Definition rcode.h:43
@ RLM_MODULE_TIMEOUT
Module (or section) timed out.
Definition rcode.h:52
@ RLM_MODULE_NOTFOUND
User not found.
Definition rcode.h:49
@ RLM_MODULE_UPDATED
OK (pairs modified).
Definition rcode.h:51
@ RLM_MODULE_NOT_SET
Error resolving rcode (should not be returned by modules).
Definition rcode.h:41
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
Definition rcode.h:50
@ RLM_MODULE_NUMCODES
How many valid return codes there are.
Definition rcode.h:53
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
Definition rcode.h:46
An element in a lexicographically sorted array of name to num mappings.
Definition table.h:49