The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
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: c680fae94cfbfbf382b6bceea3acae8aaf24e33a $
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/module.h>
32#include <freeradius-devel/server/module_rlm.h>
33
34#include "proto_detail.h"
35
37
38static int type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
39static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
40
41#if 0
42/*
43 * When we want detailed debugging here, without detailed server
44 * debugging.
45 */
46#define MPRINT DEBUG
47#else
48#define MPRINT(x, ...)
49#endif
50
51/** How to parse a Detail listen section
52 *
53 */
56 type), .func = type_parse },
57 { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_detail_t, io_submodule),
58 .func = transport_parse, .dflt = "file" },
59
60 /*
61 * Add this as a synonym so normal humans can understand it.
62 */
63 { FR_CONF_OFFSET("max_entry_size", proto_detail_t, max_packet_size) } ,
64
65 /*
66 * For performance tweaking. NOT for normal humans.
67 */
68 { FR_CONF_OFFSET("max_packet_size", proto_detail_t, max_packet_size) } ,
69 { FR_CONF_OFFSET("num_messages", proto_detail_t, num_messages) } ,
70
71 { FR_CONF_OFFSET("exit_when_done", proto_detail_t, exit_when_done) },
72
73 { FR_CONF_OFFSET("priority", proto_detail_t, priority) },
74
76};
77
79
82 { .out = &dict_freeradius, .proto = "freeradius" },
83
85};
86
92
95 { .out = &attr_packet_dst_ip_address, .name = "Net.Dst.IP", .type = FR_TYPE_COMBO_IP_ADDR, .dict = &dict_freeradius },
96 { .out = &attr_packet_dst_port, .name = "Net.Dst.Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius },
97 { .out = &attr_packet_original_timestamp, .name = "Packet-Original-Timestamp", .type = FR_TYPE_DATE, .dict = &dict_freeradius },
98 { .out = &attr_packet_src_ip_address, .name = "Net.Src.IP", .type = FR_TYPE_COMBO_IP_ADDR, .dict = &dict_freeradius },
99 { .out = &attr_packet_src_port, .name = "Net.Src.Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius },
100
102};
103
104/** Translates the packet-type into a submodule name
105 *
106 * @param[in] ctx to allocate data in (instance of proto_detail).
107 * @param[out] out Where to write a module_instance_t containing the module handle and instance.
108 * @param[in] parent Base structure address.
109 * @param[in] ci #CONF_PAIR specifying the name of the type module.
110 * @param[in] rule unused.
111 * @return
112 * - 0 on success.
113 * - -1 on failure.
114 */
115static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
116{
117 proto_detail_t *inst = talloc_get_type_abort(parent, proto_detail_t);
118 fr_dict_enum_value_t const *type_enum;
119 CONF_PAIR *cp = cf_item_to_pair(ci);
120 char const *value = cf_pair_value(cp);
121
123 if (!inst->dict) {
124 cf_log_err(ci, "Please define 'namespace' in this virtual server");
125 return -1;
126 }
127
128 inst->attr_packet_type = fr_dict_attr_by_name(NULL, fr_dict_root(inst->dict), "Packet-Type");
129 if (!inst->attr_packet_type) {
130 cf_log_err(ci, "Failed to find 'Packet-Type' attribute");
131 return -1;
132 }
133
134 if (!value) {
135 cf_log_err(ci, "No value given for 'type'");
136 return -1;
137 }
138
139 type_enum = fr_dict_enum_by_name(inst->attr_packet_type, value, -1);
140 if (!type_enum) {
141 cf_log_err(ci, "Invalid type \"%s\"", value);
142 return -1;
143 }
144
145 inst->code = type_enum->value->vb_uint32;
146 *((char const **) out) = value;
147
148 return 0;
149}
150
151static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
152{
153 proto_detail_t *inst = talloc_get_type_abort(parent, proto_detail_t);
154
155 if (unlikely(virtual_server_listen_transport_parse(ctx, out, parent, ci, rule) < 0)) {
156 return -1;
157 }
158
159 /*
160 * If we're not loading the work submodule directly, then try to load it here.
161 */
162 if (strcmp(inst->io_submodule->module->dl->name, "proto_detail_work") != 0) {
163 CONF_SECTION *transport_cs;
165 char const *inst_name;
166
167 inst->work_submodule = NULL;
168
170 fr_assert(mi);
171
172 transport_cs = cf_section_find(mi->conf, "work", NULL);
173 if (!transport_cs) {
174 transport_cs = cf_section_dup(mi->conf, mi->conf, inst->app_io_conf,
175 "work", NULL, false);
176 if (!transport_cs) {
177 cf_log_err(mi->conf, "Failed to create configuration for worker");
178 return -1;
179 }
180 }
181
182 if (module_instance_name_from_conf(&inst_name, transport_cs) < 0) return -1;
183
184 /*
185 * This *should* get bootstrapped at some point after this module
186 * as it's inserted into the three the caller is iterating over.
187 *
188 * We might want to revisit this, and use a linked list of modules
189 * to iterate over instead of a tree, so we can add this to the end
190 * of that list.
191 */
192 inst->work_submodule = module_instance_alloc(mi->ml, mi, DL_MODULE_TYPE_SUBMODULE,
193 "work", inst_name, MODULE_INSTANCE_NONE);
194 if (inst->work_submodule == NULL) {
195 error:
196 cf_log_perr(mi->conf, "Failed to load proto_detail_work");
197 TALLOC_FREE(inst->work_submodule);
198 return -1;
199 }
200
201 if (module_instance_conf_parse(inst->work_submodule, transport_cs) < 0) goto error;
202
203 inst->work_io = (fr_app_io_t const *) inst->work_submodule->exported;
204 inst->work_io_instance = inst->work_submodule->data;
205 inst->work_io_conf = inst->work_submodule->conf;
206 }
207
208 return 0;
209}
210
211/** Decode the packet, and set the request->process function
212 *
213 */
214static int mod_decode(void const *instance, request_t *request, uint8_t *const data, size_t data_len)
215{
217 int num, lineno;
218 uint8_t const *p, *end;
219 fr_pair_t *vp;
220 fr_pair_list_t tmp_list;
221 fr_dcursor_t cursor;
222 time_t timestamp = 0;
223 fr_pair_parse_t root, relative;
224
225 RHEXDUMP3(data, data_len, "proto_detail decode packet");
226
227 request->packet->code = inst->code;
228
229 /*
230 * Set default addresses
231 */
232 request->packet->socket.fd = -1;
233 request->packet->socket.inet.src_ipaddr.af = AF_INET;
234 request->packet->socket.inet.src_ipaddr.addr.v4.s_addr = htonl(INADDR_NONE);
235 request->packet->socket.inet.dst_ipaddr = request->packet->socket.inet.src_ipaddr;
236
237 request->reply->socket.inet.src_ipaddr = request->packet->socket.inet.src_ipaddr;
238 request->reply->socket.inet.dst_ipaddr = request->packet->socket.inet.src_ipaddr;
239
240 end = data + data_len;
241
242 MPRINT("HEADER %s", data);
243
244 if (sscanf((char const *) data, "%*s %*s %*d %*d:%*d:%*d %d", &num) != 1) {
245 REDEBUG("Malformed header '%s'", (char const *) data);
246 return -1;
247 }
248
249 /*
250 * Skip the header
251 */
252 for (p = data; p < end; p++) {
253 if (!*p) break;
254 }
255
256 lineno = 1;
257 fr_pair_dcursor_init(&cursor, &request->request_pairs);
258 fr_dcursor_tail(&cursor); /* Ensure we only free what we add on error */
259 fr_pair_list_init(&tmp_list);
260
261 /*
262 * Parse each individual line.
263 */
264 while (p < end) {
265 fr_slen_t slen;
266
267 /*
268 * Each record begins with a zero byte. If the
269 * next byte is also zero, that's the end of
270 * record indication.
271 */
272 if ((end - p) < 2) break;
273 if (!p[1]) break;
274
275 /*
276 * Already checked in the "read" routine. But it
277 * doesn't hurt to re-check it here.
278 */
279 if ((*p != '\0') && (*p != '\t')) {
280 REDEBUG("Malformed line %d", lineno);
281 fr_dcursor_free_list(&cursor);
282 return -1;
283 }
284
285 p += 2;
286
287 MPRINT("LINE :%s", p);
288
289 /*
290 * Skip this for backwards compatibility.
291 */
292 if (strncasecmp((char const *) p, "Request-Authenticator", 21) == 0) goto next;
293
294 /*
295 * The original time at which we received the
296 * packet. We need this to properly calculate
297 * Acct-Delay-Time.
298 */
299 if (strncasecmp((char const *) p, "Timestamp = ", 12) == 0) {
300 p += 12;
301
302 timestamp = atoi((char const *) p);
303
305 if (vp) {
306 vp->vp_date = fr_unix_time_from_sec(timestamp);
307 fr_dcursor_append(&cursor, vp);
308 }
309 goto next;
310 }
311
312 /*
313 * This should also have been caught.
314 */
315 if (strncasecmp((char const *) p, "Donestamp", 9) == 0) {
316 goto next;
317 }
318
319 /*
320 * Reinitialize every time.
321 *
322 * @todo - maybe we want to keep "relative' around between lines?
323 * So that the detail file reader can read:
324 *
325 * foo = {}
326 * .bar = baz
327 *
328 * and get
329 *
330 * foo = { bar = baz }
331 *
332 * But doing that would require updating the
333 * detail file writer to track parent / child
334 * relationships, which we're not yet prepared to
335 * do.
336 *
337 * @todo - this also doesn't create nested attributes properly,
338 * as the write will write:
339 *
340 * foo.bar = baz
341 *
342 * and then the final pair "foo" is _appended_ to the input list, without paying
343 * any attention to what's going on!
344 *
345 * We likely just want to pass in request_pairs the parse function, AND also don't
346 * mash "relative" between calls.
347 */
348 root = (fr_pair_parse_t) {
349 .ctx = request->request_ctx,
350 .da = fr_dict_root(request->proto_dict),
351 .list = &tmp_list,
352 .dict = request->proto_dict,
353 .internal = fr_dict_internal(),
354 .allow_zeros = true,
355 };
356 relative = (fr_pair_parse_t) { };
357
358 slen = fr_pair_list_afrom_substr(&root, &relative,
359 &FR_SBUFF_IN((char const *) p, (data + data_len) - p));
360 if (slen < 0) {
361 RPEDEBUG("Failed reading line");
362 vp = NULL;
363
364 } else if ((slen == 0) || fr_pair_list_empty(&tmp_list)) {
365 vp = NULL;
366 RWDEBUG("Ignoring line %d - %s", lineno, p);
367
368 } else {
369 vp = fr_pair_list_head(&tmp_list);
370 }
371
372 /*
373 * Set the original src/dst ip/port
374 */
375 if (vp) {
377 request->packet->socket.inet.src_ipaddr = vp->vp_ip;
378 } else if (vp->da == attr_packet_dst_ip_address) {
379 request->packet->socket.inet.dst_ipaddr = vp->vp_ip;
380 } else if (vp->da == attr_packet_src_port) {
381 request->packet->socket.inet.src_port = vp->vp_uint16;
382 } else if (vp->da == attr_packet_dst_port) {
383 request->packet->socket.inet.dst_port = vp->vp_uint16;
384 }
385 }
386
387 next:
388 lineno++;
389 while ((p < end) && (*p)) p++;
390 }
391
392 fr_pair_list_append(&request->request_pairs, &tmp_list);
393
394 /*
395 * Let the app_io take care of populating additional fields in the request
396 */
397 return inst->app_io->decode(inst->app_io_instance, request, data, data_len);
398}
399
400static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
401{
402 if (buffer_len < 1) return -1;
403
404 *buffer = request->reply->code;
405 return 1;
406}
407
408static int mod_priority_set(void const *instance, UNUSED uint8_t const *buffer, UNUSED size_t buflen)
409{
411
412 /*
413 * Return the configured priority.
414 */
415 return inst->priority;
416}
417
418
419/** Open listen sockets/connect to external event source
420 *
421 * @param[in] instance Ctx data for this application.
422 * @param[in] sc to add our file descriptor to.
423 * @param[in] conf Listen section parsed to give us instance.
424 * @return
425 * - 0 on success.
426 * - -1 on failure.
427 */
428static int mod_open(void *instance, fr_schedule_t *sc, CONF_SECTION *conf)
429{
431 fr_listen_t *listen;
432 proto_detail_t *inst = talloc_get_type_abort(instance, proto_detail_t);
433
434 /*
435 * Build the listener. This describes the complete path data
436 * takes from the socket to the decoder and back again.
437 */
438 MEM(listen = fr_listen_alloc(inst, conf, inst->server_cs, &proto_detail, instance,
439 inst->app_io, inst->app_io_instance));
440
441 /*
442 * Set configurable parameters for message ring buffer.
443 */
444 listen->default_message_size = inst->max_packet_size;
445 listen->num_messages = inst->num_messages;
446
447 /*
448 * Then the socket of it we will open.
449 */
450 MEM(li = fr_listen_instance_alloc(inst, listen)); /* Assigned thread steals the memory */
451 talloc_set_destructor(li, fr_io_listen_free);
452
453 li->thread_instance = talloc_zero_array(li, uint8_t, listen->app_io->common.thread_inst_size);
454 talloc_set_name(li->thread_instance, "proto_%s_thread_t", inst->app_io->common.name);
455
456 /*
457 * Open the file.
458 */
459 if (inst->app_io->open(li) < 0) {
460 cf_log_err(conf, "Failed opening %s file", inst->app_io->common.name);
461 talloc_free(li);
462 return -1;
463 }
464
466 li->name = li->listen->app_io->get_name(li);
467
468 /*
469 * Testing: allow it to read a "detail.work" file
470 * directly.
471 */
472 if (strcmp(inst->io_submodule->module->dl->name, "proto_detail_work") == 0) {
473 if (!fr_schedule_listen_add(sc, li)) {
474 talloc_free(li);
475 return -1;
476 }
477
478 inst->listen = li;
479 return 0;
480 }
481
482 if (li->listen->non_socket_listener) {
483 /*
484 * Add listener. Will insert polling timer.
485 */
486 if (!fr_schedule_listen_add(sc, li)) {
487 talloc_free(li);
488 return -1;
489 }
490 } else {
491 /*
492 * Watch the directory for changes.
493 */
494 if (!fr_schedule_directory_add(sc, li)) {
495 talloc_free(li);
496 return -1;
497 }
498 }
499
500 DEBUG("Listening on %s bound to virtual server %s",
502
503 inst->listen = li; /* Probably won't need it, but doesn't hurt */
504 inst->sc = sc;
505
506 return 0;
507}
508
509
510/** Instantiate the application
511 *
512 * Instantiate I/O and type submodules.
513 *
514 * @return
515 * - 0 on success.
516 * - -1 on failure.
517 */
518static int mod_instantiate(module_inst_ctx_t const *mctx)
519{
520 proto_detail_t *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_t);
521 CONF_SECTION *conf = mctx->mi->conf;
522
523 /*
524 * The listener is inside of a virtual server.
525 */
526 inst->server_cs = cf_item_to_section(cf_parent(conf));
527 inst->self = &proto_detail;
528
529 /*
530 * No IO module, it's an empty listener. That's not
531 * allowed for the detail file reader.
532 */
533 if (!inst->io_submodule) {
534 cf_log_err(conf, "Virtual server for detail files requires a 'transport' configuration");
535 return -1;
536 }
537
538 /*
539 * Bootstrap the I/O module
540 */
541 inst->app_io = (fr_app_io_t const *) inst->io_submodule->exported;
542 inst->app_io_instance = inst->io_submodule->data;
543 inst->app_io_conf = inst->io_submodule->conf;
544
545 /*
546 * These configuration items are not printed by default,
547 * because normal people shouldn't be touching them.
548 */
549 if (!inst->max_packet_size) inst->max_packet_size = inst->app_io->default_message_size;
550
551 if (!inst->num_messages) inst->num_messages = 2;
552
553 FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 2);
554 FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
555
556 FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
557 FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65536);
558
559 if (!inst->priority) inst->priority = PRIORITY_NORMAL;
560
561 return 0;
562}
563
565 .common = {
566 .magic = MODULE_MAGIC_INIT,
567 .name = "detail",
569 .inst_size = sizeof(proto_detail_t),
570
571 .instantiate = mod_instantiate,
572 },
573 .open = mod_open,
574 .decode = mod_decode,
575 .encode = mod_encode,
576 .priority = mod_priority_set
577};
static int const char char buffer[256]
Definition acutest.h:641
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
static uint8_t request[4]
#define unlikely(_x)
Definition build.h:486
#define UNUSED
Definition build.h:415
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:722
cf_parse_t func
Override default parsing behaviour for the specified type with a custom parsing function.
Definition cf_parse.h:666
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
Definition cf_parse.h:572
#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:280
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
Definition cf_parse.h:466
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
Definition cf_parse.h:484
#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:238
Defines a CONF_PAIR to C data type mapping.
Definition cf_parse.h:649
Common header for all CONF_* types.
Definition cf_priv.h:54
Configuration AVP similar to a fr_pair_t.
Definition cf_priv.h:77
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:106
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
Definition cf_util.c:1405
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:1247
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
Definition cf_util.c:671
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:1052
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
Definition cf_util.c:651
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
Definition cf_util.c:1758
#define cf_log_err(_cf, _fmt,...)
Definition cf_util.h:340
#define cf_parent(_cf)
Definition cf_util.h:115
#define cf_log_perr(_cf, _fmt,...)
Definition cf_util.h:347
#define PRIORITY_NORMAL
Definition channel.h:158
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:258
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:38
#define DEBUG(fmt,...)
Definition dhcpclient.c:38
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:3600
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
Definition dict_util.c:2717
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition dict.h:316
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition dict.h:329
fr_value_box_t const * value
Enum value (what name maps to).
Definition dict.h:281
fr_dict_t const * fr_dict_internal(void)
Definition dict_util.c:5065
#define DICT_AUTOLOAD_TERMINATOR
Definition dict.h:335
fr_dict_enum_value_t const * fr_dict_enum_by_name(fr_dict_attr_t const *da, char const *name, ssize_t len)
Definition dict_util.c:3778
Specifies an attribute which must be present for the module to function.
Definition dict.h:315
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition dict.h:328
Value of an enumerated attribute.
Definition dict.h:277
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
talloc_free(hp)
#define RWDEBUG(fmt,...)
Definition log.h:378
#define RPEDEBUG(fmt,...)
Definition log.h:393
#define RHEXDUMP3(_data, _len, _fmt,...)
Definition log.h:724
int fr_io_listen_free(fr_listen_instance_t *li)
Free a socket's thread instance along with it.
Definition listen.c:126
fr_listen_t * fr_listen_alloc(TALLOC_CTX *ctx, CONF_SECTION *listen_cs, CONF_SECTION *server_cs, fr_app_t const *app, void const *app_instance, fr_app_io_t const *app_io, void const *app_io_instance)
Allocate a listener, and give it its id.
Definition listen.c:78
fr_listen_instance_t * fr_listen_instance_alloc(TALLOC_CTX *ctx, fr_listen_t *listen)
Allocate a socket of a listener.
Definition listen.c:111
size_t num_messages
for the message ring buffer
Definition listen.h:54
char const * name
printable name for this socket - set by open
Definition listen.h:68
fr_listen_t * listen
the listener this is a socket of.
Definition listen.h:65
fr_app_io_t const * app_io
I/O path functions.
Definition listen.h:33
void * thread_instance
thread / socket context
Definition listen.h:69
bool non_socket_listener
special internal listener that does not use sockets.
Definition listen.h:44
CONF_SECTION * server_cs
CONF_SECTION of the server.
Definition listen.h:40
size_t default_message_size
copied from app_io, but may be changed
Definition listen.h:53
@ 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
ssize_t fr_slen_t
int strncasecmp(char *s1, char *s2, int n)
Definition missing.c:35
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:284
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
Definition pair.c:47
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.
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:37
#define REDEBUG(fmt,...)
static rs_t * conf
Definition radsniff.c:52
#define FR_SBUFF_IN(_start, _len_or_end)
fr_network_t * fr_schedule_listen_add(fr_schedule_t *sc, fr_listen_instance_t *li)
Add a fr_listen_instance_t to a scheduler.
Definition schedule.c:786
fr_network_t * fr_schedule_directory_add(fr_schedule_t *sc, fr_listen_instance_t *li)
Add a directory NOTE_EXTEND to a scheduler.
Definition schedule.c:818
The scheduler.
Definition schedule.c:77
@ MODULE_INSTANCE_NONE
Not yet bootstrapped.
Definition module.h:269
CONF_SECTION * conf
Module's instance configuration.
Definition module.h:355
void * data
Module's instance data.
Definition module.h:297
module_list_t * ml
Module list this instance belongs to.
Definition module.h:335
size_t thread_inst_size
Size of the module's thread-specific instance data.
Definition module.h:249
conf_parser_t const * config
How to convert a CONF_SECTION to a module instance.
Definition module.h:207
Module instance data.
Definition module.h:291
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:1721
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:734
int module_instance_conf_parse(module_instance_t *mi, CONF_SECTION *conf)
Covert a CONF_SECTION into parsed module instance data.
Definition module.c:763
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:117
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_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:605
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:864
static fr_slen_t data
Definition value.h:1366
static fr_sbuff_err_t char ** out
Definition value.h:1061
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.