The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
proto_detail.c
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
17/**
18 * $Id: c30487d80787757cc8865fd2b65e6fa481432ae2 $
19 * @file proto_detail.c
20 * @brief Detail master protocol handler.
21 *
22 * @copyright 2017 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
23 * @copyright 2016 Alan DeKok (aland@freeradius.org)
24 */
25#include <freeradius-devel/io/application.h>
26#include <freeradius-devel/io/listen.h>
27#include <freeradius-devel/io/schedule.h>
28#include <freeradius-devel/radius/radius.h>
29#include <freeradius-devel/util/pair_legacy.h>
30
31#include <freeradius-devel/server/dl_module.h>
32#include <freeradius-devel/server/module.h>
33#include <freeradius-devel/server/module_rlm.h>
34
35#include "proto_detail.h"
36
38
39static int type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
40static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
41
42#if 0
43/*
44 * When we want detailed debugging here, without detailed server
45 * debugging.
46 */
47#define MPRINT DEBUG
48#else
49#define MPRINT(x, ...)
50#endif
51
52/** How to parse a Detail listen section
53 *
54 */
57 type), .func = type_parse },
58 { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_detail_t, io_submodule),
59 .func = transport_parse, .dflt = "file" },
60
61 /*
62 * Add this as a synonym so normal humans can understand it.
63 */
64 { FR_CONF_OFFSET("max_entry_size", proto_detail_t, max_packet_size) } ,
65
66 /*
67 * For performance tweaking. NOT for normal humans.
68 */
69 { FR_CONF_OFFSET("max_packet_size", proto_detail_t, max_packet_size) } ,
70 { FR_CONF_OFFSET("num_messages", proto_detail_t, num_messages) } ,
71
72 { FR_CONF_OFFSET("exit_when_done", proto_detail_t, exit_when_done) },
73
74 { FR_CONF_OFFSET("priority", proto_detail_t, priority) },
75
77};
78
80
83 { .out = &dict_freeradius, .proto = "freeradius" },
84
85 { NULL }
86};
87
93
96 { .out = &attr_packet_dst_ip_address, .name = "Net.Dst.IP", .type = FR_TYPE_COMBO_IP_ADDR, .dict = &dict_freeradius },
97 { .out = &attr_packet_dst_port, .name = "Net.Dst.Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius },
98 { .out = &attr_packet_original_timestamp, .name = "Packet-Original-Timestamp", .type = FR_TYPE_DATE, .dict = &dict_freeradius },
99 { .out = &attr_packet_src_ip_address, .name = "Net.Src.IP", .type = FR_TYPE_COMBO_IP_ADDR, .dict = &dict_freeradius },
100 { .out = &attr_packet_src_port, .name = "Net.Src.Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius },
101
102 { NULL }
103};
104
105/** Translates the packet-type into a submodule name
106 *
107 * @param[in] ctx to allocate data in (instance of proto_detail).
108 * @param[out] out Where to write a module_instance_t containing the module handle and instance.
109 * @param[in] parent Base structure address.
110 * @param[in] ci #CONF_PAIR specifying the name of the type module.
111 * @param[in] rule unused.
112 * @return
113 * - 0 on success.
114 * - -1 on failure.
115 */
116static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
117{
118 proto_detail_t *inst = talloc_get_type_abort(parent, proto_detail_t);
119 fr_dict_enum_value_t const *type_enum;
120 CONF_PAIR *cp = cf_item_to_pair(ci);
121 char const *value = cf_pair_value(cp);
122
123 *((char const **) out) = value;
124
126 if (!inst->dict) {
127 cf_log_err(ci, "Please define 'namespace' in this virtual server");
128 return -1;
129 }
130
131 inst->attr_packet_type = fr_dict_attr_by_name(NULL, fr_dict_root(inst->dict), "Packet-Type");
132 if (!inst->attr_packet_type) {
133 cf_log_err(ci, "Failed to find 'Packet-Type' attribute");
134 return -1;
135 }
136
137 if (!value) {
138 cf_log_err(ci, "No value given for 'type'");
139 return -1;
140 }
141
142 type_enum = fr_dict_enum_by_name(inst->attr_packet_type, value, -1);
143 if (!type_enum) {
144 cf_log_err(ci, "Invalid type \"%s\"", value);
145 return -1;
146 }
147
148 inst->code = type_enum->value->vb_uint32;
149 return 0;
150}
151
152static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
153{
154 proto_detail_t *inst = talloc_get_type_abort(parent, proto_detail_t);
155
156 if (unlikely(virtual_server_listen_transport_parse(ctx, out, parent, ci, rule) < 0)) {
157 return -1;
158 }
159
160 /*
161 * If we're not loading the work submodule directly, then try to load it here.
162 */
163 if (strcmp(inst->io_submodule->module->dl->name, "proto_detail_work") != 0) {
164 CONF_SECTION *transport_cs;
166 char const *inst_name;
167
168 inst->work_submodule = NULL;
169
171 fr_assert(mi);
172
173 transport_cs = cf_section_find(mi->conf, "work", NULL);
174 if (!transport_cs) {
175 transport_cs = cf_section_dup(mi->conf, mi->conf, inst->app_io_conf,
176 "work", NULL, false);
177 if (!transport_cs) {
178 cf_log_err(mi->conf, "Failed to create configuration for worker");
179 return -1;
180 }
181 }
182
183 if (module_instance_name_from_conf(&inst_name, transport_cs) < 0) return -1;
184
185 /*
186 * This *should* get bootstrapped at some point after this module
187 * as it's inserted into the three the caller is iterating over.
188 *
189 * We might want to revisit this, and use a linked list of modules
190 * to iterate over instead of a tree, so we can add this to the end
191 * of that list.
192 */
193 inst->work_submodule = module_instance_alloc(mi->ml, mi, DL_MODULE_TYPE_SUBMODULE,
194 "work", inst_name, 0);
195 if (inst->work_submodule == NULL) {
196 error:
197 cf_log_perr(mi->conf, "Failed to load proto_detail_work");
198 TALLOC_FREE(inst->work_submodule);
199 return -1;
200 }
201
202 if (module_instance_conf_parse(inst->work_submodule, transport_cs) < 0) goto error;
203
204 inst->work_io = (fr_app_io_t const *) inst->work_submodule->exported;
205 inst->work_io_instance = inst->work_submodule->data;
206 inst->work_io_conf = inst->work_submodule->conf;
207 }
208
209 return 0;
210}
211
212/** Decode the packet, and set the request->process function
213 *
214 */
215static int mod_decode(void const *instance, request_t *request, uint8_t *const data, size_t data_len)
216{
218 int num, lineno;
219 uint8_t const *p, *end;
220 fr_pair_t *vp;
221 fr_pair_list_t tmp_list;
222 fr_dcursor_t cursor;
223 time_t timestamp = 0;
224 fr_pair_parse_t root, relative;
225
226 RHEXDUMP3(data, data_len, "proto_detail decode packet");
227
228 request->packet->code = inst->code;
229
230 /*
231 * Set default addresses
232 */
233 request->packet->socket.fd = -1;
234 request->packet->socket.inet.src_ipaddr.af = AF_INET;
235 request->packet->socket.inet.src_ipaddr.addr.v4.s_addr = htonl(INADDR_NONE);
236 request->packet->socket.inet.dst_ipaddr = request->packet->socket.inet.src_ipaddr;
237
238 request->reply->socket.inet.src_ipaddr = request->packet->socket.inet.src_ipaddr;
239 request->reply->socket.inet.dst_ipaddr = request->packet->socket.inet.src_ipaddr;
240
241 end = data + data_len;
242
243 MPRINT("HEADER %s", data);
244
245 if (sscanf((char const *) data, "%*s %*s %*d %*d:%*d:%*d %d", &num) != 1) {
246 REDEBUG("Malformed header '%s'", (char const *) data);
247 return -1;
248 }
249
250 /*
251 * Skip the header
252 */
253 for (p = data; p < end; p++) {
254 if (!*p) break;
255 }
256
257 lineno = 1;
258 fr_pair_dcursor_init(&cursor, &request->request_pairs);
259 fr_dcursor_tail(&cursor); /* Ensure we only free what we add on error */
260 fr_pair_list_init(&tmp_list);
261
262 /*
263 * Parse each individual line.
264 */
265 while (p < end) {
266 /*
267 * Each record begins with a zero byte. If the
268 * next byte is also zero, that's the end of
269 * record indication.
270 */
271 if ((end - p) < 2) break;
272 if (!p[1]) break;
273
274 /*
275 * Already checked in the "read" routine. But it
276 * doesn't hurt to re-check it here.
277 */
278 if ((*p != '\0') && (*p != '\t')) {
279 REDEBUG("Malformed line %d", lineno);
280 fr_dcursor_free_list(&cursor);
281 return -1;
282 }
283
284 p += 2;
285
286 MPRINT("LINE :%s", p);
287
288 /*
289 * Skip this for backwards compatibility.
290 */
291 if (strncasecmp((char const *) p, "Request-Authenticator", 21) == 0) goto next;
292
293 /*
294 * The original time at which we received the
295 * packet. We need this to properly calculate
296 * Acct-Delay-Time.
297 */
298 if (strncasecmp((char const *) p, "Timestamp = ", 12) == 0) {
299 p += 12;
300
301 timestamp = atoi((char const *) p);
302
303 vp = fr_pair_afrom_da(request->request_ctx, attr_packet_original_timestamp);
304 if (vp) {
305 vp->vp_date = fr_unix_time_from_sec(timestamp);
306 fr_dcursor_append(&cursor, vp);
307 }
308 goto next;
309 }
310
311 /*
312 * This should also have been caught.
313 */
314 if (strncasecmp((char const *) p, "Donestamp", 9) == 0) {
315 goto next;
316 }
317
318 /*
319 * Ensure temporary list is empty before each use
320 */
321 fr_pair_list_free(&tmp_list);
322
323 /*
324 * Reinitialize every time.
325 *
326 * @todo - maybe we want to keep "relative' around between lines?
327 * So that the detail file reader can read:
328 *
329 * foo = {}
330 * .bar = baz
331 *
332 * and get
333 *
334 * foo = { bar = baz }
335 *
336 * But doing that would require updating the
337 * detail file writer to track parent / child
338 * relationships, which we're not yet prepared to
339 * do.
340 *
341 * @todo - this also doesn't create nested attributes properly,
342 * as the write will write:
343 *
344 * foo.bar = baz
345 *
346 * and then the final pair "foo" is _appended_ to the input list, without paying
347 * any attention to what's going on!
348 *
349 * We likely just want to pass in request_pairs the parse function, AND also don't
350 * mash "relative" between calls.
351 */
352 root = (fr_pair_parse_t) {
353 .ctx = request->request_ctx,
354 .da = fr_dict_root(request->proto_dict),
355 .list = &tmp_list,
356 };
357 relative = (fr_pair_parse_t) { };
358
359 if ((fr_pair_list_afrom_substr(&root, &relative,
360 &FR_SBUFF_IN((char const *) p, (data + data_len) - p)) > 0) && !fr_pair_list_empty(&tmp_list)) {
361 vp = fr_pair_list_head(&tmp_list);
362 fr_pair_list_append(&request->request_pairs, &tmp_list);
363 } else {
364 vp = NULL;
365 RWDEBUG("Ignoring line %d - :%s", lineno, p);
366 }
367
368 /*
369 * Set the original src/dst ip/port
370 */
371 if (vp) {
373 request->packet->socket.inet.src_ipaddr = vp->vp_ip;
374 } else if (vp->da == attr_packet_dst_ip_address) {
375 request->packet->socket.inet.dst_ipaddr = vp->vp_ip;
376 } else if (vp->da == attr_packet_src_port) {
377 request->packet->socket.inet.src_port = vp->vp_uint16;
378 } else if (vp->da == attr_packet_dst_port) {
379 request->packet->socket.inet.dst_port = vp->vp_uint16;
380 }
381 }
382
383 next:
384 lineno++;
385 while ((p < end) && (*p)) p++;
386 }
387
388 /*
389 * Let the app_io take care of populating additional fields in the request
390 */
391 return inst->app_io->decode(inst->app_io_instance, request, data, data_len);
392}
393
394static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
395{
396 if (buffer_len < 1) return -1;
397
398 *buffer = request->reply->code;
399 return 1;
400}
401
402static int mod_priority_set(void const *instance, UNUSED uint8_t const *buffer, UNUSED size_t buflen)
403{
405
406 /*
407 * Return the configured priority.
408 */
409 return inst->priority;
410}
411
412
413/** Open listen sockets/connect to external event source
414 *
415 * @param[in] instance Ctx data for this application.
416 * @param[in] sc to add our file descriptor to.
417 * @param[in] conf Listen section parsed to give us instance.
418 * @return
419 * - 0 on success.
420 * - -1 on failure.
421 */
422static int mod_open(void *instance, fr_schedule_t *sc, CONF_SECTION *conf)
423{
424 fr_listen_t *li;
425 proto_detail_t *inst = talloc_get_type_abort(instance, proto_detail_t);
426
427 /*
428 * Build the #fr_listen_t. This describes the complete
429 * path, data takes from the socket to the decoder and
430 * back again.
431 */
432 MEM(li = talloc_zero(inst, fr_listen_t)); /* Assigned thread steals the memory */
433 talloc_set_destructor(li, fr_io_listen_free);
434
435 li->app_io = inst->app_io;
436 li->thread_instance = talloc_zero_array(li, uint8_t, li->app_io->common.thread_inst_size);
437 talloc_set_name(li->thread_instance, "proto_%s_thread_t", inst->app_io->common.name);
438 li->app_io_instance = inst->app_io_instance;
439
440 li->app = &proto_detail;
441 li->app_instance = instance;
442 li->server_cs = inst->server_cs;
443
444 /*
445 * Set configurable parameters for message ring buffer.
446 */
447 li->default_message_size = inst->max_packet_size;
448 li->num_messages = inst->num_messages;
449
450 /*
451 * Open the file.
452 */
453 if (inst->app_io->open(li) < 0) {
454 cf_log_err(conf, "Failed opening %s file", inst->app_io->common.name);
455 talloc_free(li);
456 return -1;
457 }
458
460 li->name = li->app_io->get_name(li);
461
462 /*
463 * Testing: allow it to read a "detail.work" file
464 * directly.
465 */
466 if (strcmp(inst->io_submodule->module->dl->name, "proto_detail_work") == 0) {
467 if (!fr_schedule_listen_add(sc, li)) {
468 talloc_free(li);
469 return -1;
470 }
471
472 inst->listen = li;
473 return 0;
474 }
475
476 if (li->non_socket_listener) {
477 /*
478 * Add listener. Will insert polling timer.
479 */
480 if (!fr_schedule_listen_add(sc, li)) {
481 talloc_free(li);
482 return -1;
483 }
484 } else {
485 /*
486 * Watch the directory for changes.
487 */
488 if (!fr_schedule_directory_add(sc, li)) {
489 talloc_free(li);
490 return -1;
491 }
492 }
493
494 DEBUG("Listening on %s bound to virtual server %s",
496
497 inst->listen = li; /* Probably won't need it, but doesn't hurt */
498 inst->sc = sc;
499
500 return 0;
501}
502
503
504/** Instantiate the application
505 *
506 * Instantiate I/O and type submodules.
507 *
508 * @return
509 * - 0 on success.
510 * - -1 on failure.
511 */
512static int mod_instantiate(module_inst_ctx_t const *mctx)
513{
514 proto_detail_t *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_t);
515 CONF_SECTION *conf = mctx->mi->conf;
516
517 /*
518 * The listener is inside of a virtual server.
519 */
520 inst->server_cs = cf_item_to_section(cf_parent(conf));
521 inst->self = &proto_detail;
522
523 /*
524 * No IO module, it's an empty listener. That's not
525 * allowed for the detail file reader.
526 */
527 if (!inst->io_submodule) {
528 cf_log_err(conf, "Virtual server for detail files requires a 'transport' configuration");
529 return -1;
530 }
531
532 /*
533 * Bootstrap the I/O module
534 */
535 inst->app_io = (fr_app_io_t const *) inst->io_submodule->exported;
536 inst->app_io_instance = inst->io_submodule->data;
537 inst->app_io_conf = inst->io_submodule->conf;
538
539 /*
540 * These configuration items are not printed by default,
541 * because normal people shouldn't be touching them.
542 */
543 if (!inst->max_packet_size) inst->max_packet_size = inst->app_io->default_message_size;
544
545 if (!inst->num_messages) inst->num_messages = 2;
546
547 FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 2);
548 FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
549
550 FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
551 FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65536);
552
553 if (!inst->priority) inst->priority = PRIORITY_NORMAL;
554
555 return 0;
556}
557
559 .common = {
560 .magic = MODULE_MAGIC_INIT,
561 .name = "detail",
563 .inst_size = sizeof(proto_detail_t),
564
566 },
567 .open = mod_open,
568 .decode = mod_decode,
569 .encode = mod_encode,
570 .priority = mod_priority_set
571};
static int const char char buffer[256]
Definition acutest.h:576
module_t common
Common fields to all loadable modules.
Definition app_io.h:34
fr_io_name_t get_name
get the socket name
Definition app_io.h:70
Public structure describing an I/O path for a protocol.
Definition app_io.h:33
module_t common
Common fields provided by all modules.
Definition application.h:72
Describes a new application (protocol)
Definition application.h:71
#define unlikely(_x)
Definition build.h:383
#define UNUSED
Definition build.h:317
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:658
cf_parse_t func
Override default parsing behaviour for the specified type with a custom parsing function.
Definition cf_parse.h:612
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
Definition cf_parse.h:518
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition cf_parse.h:284
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
Definition cf_parse.h:434
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
Definition cf_parse.h:449
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition cf_parse.h:241
Defines a CONF_PAIR to C data type mapping.
Definition cf_parse.h:595
Common header for all CONF_* types.
Definition cf_priv.h:49
Configuration AVP similar to a fr_pair_t.
Definition cf_priv.h:70
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
Definition cf_util.c:1184
CONF_SECTION * cf_section_find(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a CONF_SECTION with name1 and optionally name2.
Definition cf_util.c:1027
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
Definition cf_util.c:683
CONF_SECTION * cf_section_dup(TALLOC_CTX *ctx, CONF_SECTION *parent, CONF_SECTION const *cs, char const *name1, char const *name2, bool copy_meta)
Duplicate a configuration section.
Definition cf_util.c:927
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
Definition cf_util.c:663
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
Definition cf_util.c:1593
#define cf_log_err(_cf, _fmt,...)
Definition cf_util.h:289
#define cf_parent(_cf)
Definition cf_util.h:101
#define cf_log_perr(_cf, _fmt,...)
Definition cf_util.h:296
#define PRIORITY_NORMAL
Definition channel.h:151
static int fr_dcursor_append(fr_dcursor_t *cursor, void *v)
Insert a single item at the end of the list.
Definition dcursor.h:406
static void * fr_dcursor_tail(fr_dcursor_t *cursor)
Wind cursor to the tail item in the list.
Definition dcursor.h:259
static void fr_dcursor_free_list(fr_dcursor_t *cursor)
Free the current item and all items after it.
Definition dcursor.h:663
#define MEM(x)
Definition debug.h:36
#define DEBUG(fmt,...)
Definition dhcpclient.c:39
fr_dict_attr_t const * fr_dict_attr_by_name(fr_dict_attr_err_t *err, fr_dict_attr_t const *parent, char const *attr))
Locate a fr_dict_attr_t by its name.
Definition dict_util.c:3265
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
Definition dict_util.c:2402
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition dict.h:272
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition dict.h:285
fr_value_box_t const * value
Enum value (what name maps to).
Definition dict.h:235
fr_dict_enum_value_t * fr_dict_enum_by_name(fr_dict_attr_t const *da, char const *name, ssize_t len)
Definition dict_util.c:3397
Specifies an attribute which must be present for the module to function.
Definition dict.h:271
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition dict.h:284
Value of an enumerated attribute.
Definition dict.h:231
Test enumeration values.
Definition dict_test.h:92
@ DL_MODULE_TYPE_SUBMODULE
Driver (or method in the case of EAP)
Definition dl_module.h:69
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
size_t num_messages
for the message ring buffer
Definition listen.h:53
bool non_socket_listener
special internal listener that does not use sockets.
Definition listen.h:46
char const * name
printable name for this socket - set by open
Definition listen.h:29
void const * app_instance
Definition listen.h:39
size_t default_message_size
copied from app_io, but may be changed
Definition listen.h:52
fr_app_t const * app
Definition listen.h:38
void const * app_io_instance
I/O path configuration context.
Definition listen.h:33
int fr_io_listen_free(fr_listen_t *li)
Definition master.c:3060
CONF_SECTION * server_cs
CONF_SECTION of the server.
Definition listen.h:41
void * thread_instance
thread / socket context
Definition listen.h:34
fr_app_io_t const * app_io
I/O path functions.
Definition listen.h:32
#define RWDEBUG(fmt,...)
Definition log.h:361
#define RHEXDUMP3(_data, _len, _fmt,...)
Definition log.h:705
talloc_free(reap)
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
@ FR_TYPE_VOID
User data.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
long int ssize_t
unsigned char uint8_t
int strncasecmp(char *s1, char *s2, int n)
Definition missing.c:36
module_instance_t * mi
Instance of the module being instantiated.
Definition module_ctx.h:51
Temporary structure to hold arguments for instantiation calls.
Definition module_ctx.h:50
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
Definition pair.c:285
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
Definition pair.c:46
fr_slen_t fr_pair_list_afrom_substr(fr_pair_parse_t const *root, fr_pair_parse_t *relative, fr_sbuff_t *in)
Parse a fr_pair_list_t from a substring.
struct fr_pair_parse_s fr_pair_parse_t
TALLOC_CTX * ctx
Definition pair_legacy.h:43
static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
fr_app_t proto_detail
static int type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static int mod_open(void *instance, fr_schedule_t *sc, CONF_SECTION *conf)
Open listen sockets/connect to external event source.
static fr_dict_attr_t const * attr_packet_src_port
static fr_dict_t const * dict_freeradius
#define MPRINT(x,...)
static int mod_decode(void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Decode the packet, and set the request->process function.
static fr_dict_attr_t const * attr_packet_original_timestamp
static int mod_priority_set(void const *instance, UNUSED uint8_t const *buffer, UNUSED size_t buflen)
fr_dict_attr_autoload_t proto_detail_dict_attr[]
fr_dict_autoload_t proto_detail_dict[]
static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static fr_dict_attr_t const * attr_packet_dst_ip_address
static int mod_instantiate(module_inst_ctx_t const *mctx)
Instantiate the application.
static fr_dict_attr_t const * attr_packet_src_ip_address
static fr_dict_attr_t const * attr_packet_dst_port
static conf_parser_t const proto_detail_config[]
How to parse a Detail listen section.
Detail master protocol handler.
#define fr_assert(_expr)
Definition rad_assert.h:38
#define REDEBUG(fmt,...)
Definition radclient.h:52
static rs_t * conf
Definition radsniff.c:53
static int instantiate(module_inst_ctx_t const *mctx)
Definition rlm_rest.c:1313
#define FR_SBUFF_IN(_start, _len_or_end)
fr_network_t * fr_schedule_directory_add(fr_schedule_t *sc, fr_listen_t *li)
Add a directory NOTE_EXTEND to a scheduler.
Definition schedule.c:924
fr_network_t * fr_schedule_listen_add(fr_schedule_t *sc, fr_listen_t *li)
Add a fr_listen_t to a scheduler.
Definition schedule.c:892
The scheduler.
Definition schedule.c:125
CONF_SECTION * conf
Module's instance configuration.
Definition module.h:330
void * data
Module's instance data.
Definition module.h:272
module_list_t * ml
Module list this instance belongs to.
Definition module.h:310
size_t thread_inst_size
Size of the module's thread-specific instance data.
Definition module.h:236
conf_parser_t const * config
How to convert a CONF_SECTION to a module instance.
Definition module.h:198
Module instance data.
Definition module.h:266
static const uchar sc[16]
Definition smbdes.c:115
module_instance_t * module_instance_alloc(module_list_t *ml, module_instance_t const *parent, dl_module_type_t type, char const *mod_name, char const *inst_name, module_instance_state_t init_state)
Allocate a new module and add it to a module list for later bootstrap/instantiation.
Definition module.c:1645
fr_slen_t module_instance_name_from_conf(char const **name, CONF_SECTION *conf)
Avoid boilerplate when setting the module instance name.
Definition module.c:729
int module_instance_conf_parse(module_instance_t *mi, CONF_SECTION *conf)
Covert a CONF_SECTION into parsed module instance data.
Definition module.c:758
eap_aka_sim_process_conf_t * inst
fr_aka_sim_id_type_t type
fr_pair_t * vp
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
Definition pair.h:69
#define talloc_get_type_abort_const
Definition talloc.h:282
static fr_unix_time_t fr_unix_time_from_sec(int64_t sec)
Definition time.h:449
bool fr_pair_list_empty(fr_pair_list_t const *list)
Is a valuepair list empty.
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
Appends a list of fr_pair_t from a temporary list to a destination list.
#define fr_pair_dcursor_init(_cursor, _list)
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.
Definition pair.h:591
fr_pair_t * fr_pair_list_head(fr_pair_list_t const *list)
Get the head of a valuepair list.
Definition pair_inline.c:42
static fr_slen_t parent
Definition pair.h:845
static fr_slen_t data
Definition value.h:1274
static size_t char ** out
Definition value.h:1012
module_instance_t * virtual_server_listener_by_data(void const *data)
Resolve proto data to a module instance.
int virtual_server_listen_transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic conf_parser_t func for loading drivers.
fr_dict_t const * virtual_server_dict_by_child_ci(CONF_ITEM const *ci)
Return the namespace for a given virtual server specified by a CONF_ITEM within the virtual server.