All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
map_proc.h
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 #ifndef _MAP_PROC_H
17 #define _MAP_PROC_H
18 /**
19  * $Id: f409f7d0fb866300775423f66d888f8835b1a2fe $
20  *
21  * @file include/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  */
27 RCSIDH(map_proc_h, "$Id: f409f7d0fb866300775423f66d888f8835b1a2fe $")
28 
29 #include <freeradius-devel/conffile.h>
30 #include <freeradius-devel/tmpl.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 typedef struct map_proc map_proc_t;
38 
39 /** Function to evaluate the src string and map the result to server attributes
40  *
41  * @param[in] mod_inst Instance of the module that registered the map_proc.
42  * @param[in] proc_inst Map proc data created by #map_proc_instantiate_t.
43  * @param[in] request The current request.
44  * @param[in] src Talloced buffer, the result of evaluating the src #vp_tmpl_t.
45  * @param[in] maps Head of the list of maps to process.
46  * @return
47  * - #RLM_MODULE_NOOP - If no data available for given src, or no mappings matched available data.
48  * - #RLM_MODULE_UPDATED - If new pairs were added to the request.
49  * - #RLM_MODULE_FAIL - If an error occurred performing the mapping.
50  */
51 typedef rlm_rcode_t (*map_proc_func_t)(void *mod_inst, void *proc_inst, REQUEST *request,
52  char const *src, vp_map_t const *maps);
53 
54 /** Allocate new instance data for a map processor
55  *
56  * @param[out] proc_inst Structure to populate. Allocated by #map_proc_instantiate.
57  * @param[in] mod_inst Module instance that registered the #map_proc_t.
58  * @param[in] src template.
59  * @param[in] maps Head of the list of maps to process.
60  * @return
61  * - 0 on success.
62  * - -1 on failure.
63  */
64 typedef int (*map_proc_instantiate_t)(void *proc_inst, void *mod_inst, vp_tmpl_t const *src, vp_map_t const *maps);
65 
66 map_proc_t *map_proc_find(char const *name);
67 
68 void map_proc_free(void);
69 int map_proc_register(void *mod_inst, char const *name,
70  map_proc_func_t evaluate,
71  xlat_escape_t escape,
72  map_proc_instantiate_t instantiate, size_t inst_size);
73 
74 map_proc_inst_t *map_proc_instantiate(TALLOC_CTX *ctx, map_proc_t const *proc,
75  vp_tmpl_t const *src, vp_map_t const *maps);
76 
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 #endif /* _FR_MAP_PROC_H */
#define RCSIDH(h, id)
Definition: build.h:136
static char const * name
int map_proc_register(void *mod_inst, char const *name, map_proc_func_t evaluate, xlat_escape_t escape, map_proc_instantiate_t instantiate, size_t inst_size)
Register a map processor.
Definition: map_proc.c:132
#define inst
size_t(* xlat_escape_t)(REQUEST *request, char *out, size_t outlen, char const *in, void *arg)
Definition: xlat.h:36
vp_map_t const * maps
Head of the map list.
Definition: map_proc.c:54
rlm_rcode_t map_proc(REQUEST *request, map_proc_inst_t const *inst)
Evaluate a set of maps using the specified map processor.
Definition: map_proc.c:225
map_proc_t * map_proc_find(char const *name)
Find a map processor by name.
Definition: map_proc.c:101
map_proc_t const * proc
Map processor.
Definition: map_proc.c:52
rlm_rcode_t(* map_proc_func_t)(void *mod_inst, void *proc_inst, REQUEST *request, char const *src, vp_map_t const *maps)
Function to evaluate the src string and map the result to server attributes.
Definition: map_proc.h:51
enum rlm_rcodes rlm_rcode_t
Return codes indicating the result of the module call.
Map processor registration.
Definition: map_proc.c:37
map_proc_inst_t * map_proc_instantiate(TALLOC_CTX *ctx, map_proc_t const *proc, vp_tmpl_t const *src, vp_map_t const *maps)
Create a new map proc instance.
Definition: map_proc.c:192
vp_tmpl_t const * src
Evaluated to provide source value for map processor.
Definition: map_proc.c:53
int(* map_proc_instantiate_t)(void *proc_inst, void *mod_inst, vp_tmpl_t const *src, vp_map_t const *maps)
Allocate new instance data for a map processor.
Definition: map_proc.h:64
void map_proc_free(void)
Definition: map_proc.c:113
Map processor instance.
Definition: map_proc.c:51
Value pair map.
Definition: map.h:46
A source or sink of value data.
Definition: tmpl.h:187