6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * Copyright 2004 The FreeRADIUS server project
21 * Copyright 2004 Alan DeKok <aland@cladju.com>
24 #include <freeradius-devel/autoconf.h>
29 #include <freeradius-devel/radiusd.h>
30 #include <freeradius-devel/modules.h>
31 #include <freeradius-devel/conffile.h>
33 static const char rcsid[] = "$Id$";
36 * Define a structure for our module configuration.
38 * It doesn't take any configuration right now...
40 typedef struct rlm_packet_t {
46 * A mapping of configuration file names to internal variables.
48 * Note that the string is dynamically allocated, so it MUST
49 * be freed. When the configuration file parse re-reads the string,
50 * it free's the old one, and strdup's the new one, placing the pointer
51 * to the strdup'd string into 'config.string'. This gets around
54 static const CONF_PARSER module_config[] = {
55 { "string", PW_TYPE_STRING_PTR, offsetof(rlm_packet_t,string), NULL, NULL},
57 { NULL, -1, 0, NULL, NULL } /* end the list */
61 static int packet_detach(void *instance)
63 rlm_packet_t *inst = instance;
65 if (inst->string) free(inst->string);
72 * Do any per-module initialization that is separate to each
73 * configured instance of the module. e.g. set up connections
74 * to external databases, read configuration files, set up
75 * dictionary entries, etc.
77 * If configuration information is given in the config section
78 * that must be referenced in later calls, store a handle to it
79 * in *instance otherwise put a null pointer there.
81 static int packet_instantiate(CONF_SECTION *conf, void **instance)
86 * Set up a storage area for instance data
88 inst = rad_malloc(sizeof(*inst));
92 memset(inst, 0, sizeof(*inst));
95 * If the configuration parameters can't be parsed, then
98 if (cf_section_parse(conf, inst, module_config) < 0) {
110 * Initialize the reply with the request.
112 static int packet_authorize(void *instance, REQUEST *request)
116 instance = instance; /* -Wunused */
118 vps = paircopy(request->packet->vps);
119 pairadd(&(request->reply->vps), vps);
120 return RLM_MODULE_UPDATED;
125 * The module name should be the only globally exported symbol.
126 * That is, everything else should be 'static'.
128 * If the module needs to temporarily modify it's instantiation
129 * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE.
130 * The server will then take care of ensuring that the module
131 * is single-threaded.
133 module_t rlm_copy_packet = {
136 RLM_TYPE_THREAD_SAFE, /* type */
137 packet_instantiate, /* instantiation */
138 packet_detach, /* detach */
140 NULL, /* authentication */
141 packet_authorize, /* authorization */
142 NULL, /* preaccounting */
143 NULL, /* accounting */
144 NULL, /* checksimul */
145 NULL, /* pre-proxy */
146 NULL, /* post-proxy */