The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
map_proc.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: 08832c95f57c50d6928938a323c77767724cec0f $
20 *
21 * @file lib/server/map_proc.h
22 * @brief Structures and prototypes for map functions
23 *
24 * @copyright 2015 The FreeRADIUS server project
25 * @copyright 2015 Arran Cudbard-bell (a.cudbardb@freeradius.org)
26 */
27RCSIDH(map_proc_h, "$Id: 08832c95f57c50d6928938a323c77767724cec0f $")
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33typedef struct map_proc map_proc_t;
35
36#ifdef __cplusplus
37}
38#endif
39
40#include <freeradius-devel/server/cf_util.h>
41#include <freeradius-devel/server/tmpl.h>
42#include <freeradius-devel/server/map.h>
43#include <freeradius-devel/util/value.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49/** Temporary structure to hold arguments for map calls
50 *
51 */
52typedef struct {
53 void *rctx; //!< Resume ctx that a module previously set.
54 void const *moi; //!< Map module instance.
55 void const *mpi; //!< Map processor instance.
56} map_ctx_t;
57
58/** Function to evaluate the src string and map the result to server attributes
59 *
60 * @param[out] p_result Result of applying the map:
61 * - #RLM_MODULE_NOOP - If no data available for given src, or no mappings matched available data.
62 * - #RLM_MODULE_UPDATED - If new pairs were added to the request.
63 * - #RLM_MODULE_FAIL - If an error occurred performing the mapping.
64 * @param[in] mpctx Call ctx for the map processor.
65 * @param[in] request The current request.
66 * @param[in,out] result Input data for the map processor. May be consumed by the
67 * map processor.
68 * @param[in] maps Head of the list of maps to process.
69 * @return one of UNLANG_ACTION_*
70 */
71typedef unlang_action_t (*map_proc_func_t)(unlang_result_t *p_result, map_ctx_t const *mpctx, request_t *request,
72 fr_value_box_list_t *result, map_list_t const *maps);
73
74/** Allocate new instance data for a map processor
75 *
76 * @param[in] cs #CONF_SECTION representing this instance of a map processor.
77 * @param[in] mod_inst Module instance that registered the #map_proc_t.
78 * @param[in] proc_inst Structure to populate. Allocated by #map_proc_instantiate.
79 * @param[in] src template.
80 * @param[in] maps Head of the list of maps to process.
81 * @return
82 * - 0 on success.
83 * - -1 on failure.
84 */
85typedef int (*map_proc_instantiate_t)(CONF_SECTION *cs, void const *mod_inst, void *proc_inst,
86 tmpl_t const *src, map_list_t const *maps);
87
89
90map_proc_t *map_proc_find(char const *name);
91
92int map_proc_register(TALLOC_CTX *ctx, void const *mod_inst, char const *name,
93 map_proc_func_t evaluate,
95
96int map_proc_unregister(char const *name);
97
98map_proc_inst_t *map_proc_instantiate(TALLOC_CTX *ctx, map_proc_t const *proc,
99 CONF_SECTION *cs, tmpl_t const *src, map_list_t const *maps);
100#ifdef __cplusplus
101}
102#endif
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
#define RCSIDH(h, id)
Definition build.h:486
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
int(* map_proc_instantiate_t)(CONF_SECTION *cs, void const *mod_inst, void *proc_inst, tmpl_t const *src, map_list_t const *maps)
Allocate new instance data for a map processor.
Definition map_proc.h:85
void const * mpi
Map processor instance.
Definition map_proc.h:55
map_proc_t * map_proc_find(char const *name)
Find a map processor by name.
Definition map_proc.c:81
unlang_action_t(* map_proc_func_t)(unlang_result_t *p_result, map_ctx_t const *mpctx, request_t *request, fr_value_box_list_t *result, map_list_t const *maps)
Function to evaluate the src string and map the result to server attributes.
Definition map_proc.h:71
int map_proc_unregister(char const *name)
Unregister a map processor by name.
Definition map_proc.c:177
void * rctx
Resume ctx that a module previously set.
Definition map_proc.h:53
map_proc_inst_t * map_proc_instantiate(TALLOC_CTX *ctx, map_proc_t const *proc, CONF_SECTION *cs, tmpl_t const *src, map_list_t const *maps)
Create a new map proc instance.
Definition map_proc.c:204
int map_proc_register(TALLOC_CTX *ctx, void const *mod_inst, char const *name, map_proc_func_t evaluate, map_proc_instantiate_t instantiate, size_t inst_size, fr_value_box_safe_for_t safe_for)
Register a map processor.
Definition map_proc.c:125
void const * moi
Map module instance.
Definition map_proc.h:54
fr_value_box_safe_for_t map_proc_literals_safe_for(map_proc_t const *proc)
Definition map_proc.c:69
Temporary structure to hold arguments for map calls.
Definition map_proc.h:52
Map processor registration.
Map processor instance.
static char const * name
static int instantiate(module_inst_ctx_t const *mctx)
Definition rlm_rest.c:1297
uintptr_t fr_value_box_safe_for_t
Escaping that's been applied to a value box.
Definition value.h:160