The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
proto_bfd.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: 7ef23f5b0897b4b8d9b64707938d5ffa46b83536 $
19 * @file proto_bfd.c
20 * @brief RADIUS 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/listen.h>
26#include <freeradius-devel/server/module_rlm.h>
27#include <freeradius-devel/internal/internal.h>
28
29#include "proto_bfd.h"
30
31extern fr_app_t proto_bfd;
32
33static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
34static int auth_type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
35
36/** How to parse a BFD listen section
37 *
38 */
40 { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_bfd_t, io.submodule),
42
44};
45
46static const conf_parser_t peer_config[] = {
47 { FR_CONF_OFFSET("min_transmit_interval", bfd_session_t, desired_min_tx_interval ) },
48 { FR_CONF_OFFSET("min_receive_interval", bfd_session_t, required_min_rx_interval ) },
49 { FR_CONF_OFFSET("max_timeouts", bfd_session_t, detect_multi ) },
50 { FR_CONF_OFFSET("demand", bfd_session_t, demand_mode ) },
51
52 { FR_CONF_OFFSET_TYPE_FLAGS("auth_type", FR_TYPE_VOID, 0, bfd_session_t, auth_type ),
54
55 { FR_CONF_OFFSET("port", bfd_session_t, port ) },
56
58};
59
60static fr_dict_t const *dict_bfd;
61
64 { .out = &dict_bfd, .proto = "bfd" },
66};
67
73
76 { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_bfd},
77
78 { .out = &attr_bfd_packet, .name = "Packet", .type = FR_TYPE_STRUCT, .dict = &dict_bfd},
79 { .out = &attr_my_discriminator, .name = "Packet.my-discriminator", .type = FR_TYPE_UINT32, .dict = &dict_bfd},
80 { .out = &attr_your_discriminator, .name = "Packet.your-discriminator", .type = FR_TYPE_UINT32, .dict = &dict_bfd},
81
82 { .out = &attr_additional_data, .name = "Additional-Data", .type = FR_TYPE_GROUP, .dict = &dict_bfd},
84};
85
86static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
87{
88 proto_bfd_t *inst = talloc_get_type_abort(parent, proto_bfd_t);
90
91 if (unlikely(virtual_server_listen_transport_parse(ctx, out, parent, ci, rule) < 0)) {
92 return -1;
93 }
94
95 mi = talloc_get_type_abort(*(void **)out, module_instance_t);
96 inst->io.app_io = (fr_app_io_t const *)mi->exported;
97 inst->io.app_io_instance = mi->data;
98 inst->io.app_io_conf = mi->conf;
99
100 return 0;
101}
102/*
103 * They all have to be UDP.
104 */
105static int8_t client_cmp(void const *one, void const *two)
106{
107 fr_client_t const *a = one;
108 fr_client_t const *b = two;
109
110 return fr_ipaddr_cmp(&a->ipaddr, &b->ipaddr);
111}
112
113/** Parse auth_type
114 *
115 * @param[in] ctx to allocate data in (instance of proto_bfd).
116 * @param[out] out Where to write the auth_type value
117 * @param[in] parent Base structure address.
118 * @param[in] ci #CONF_PAIR specifying the name of the type module.
119 * @param[in] rule unused.
120 * @return
121 * - 0 on success.
122 * - -1 on failure.
123 */
124static int auth_type_parse(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
125{
126 char const *name = cf_pair_value(cf_item_to_pair(ci));
127 int auth_type;
128
130 if (auth_type < 0) {
131 cf_log_err(ci, "Invalid value for 'auth_type'");
132 return -1;
133 }
134
135 *(bfd_auth_type_t *) out = auth_type;
136
137 return 0;
138}
139
140
141/** Decode the packet
142 *
143 */
144static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
145{
146 fr_io_track_t const *track = talloc_get_type_abort_const(request->async->packet_ctx, fr_io_track_t);
147 fr_io_address_t const *address = track->address;
148 fr_client_t const *client;
149 fr_pair_t *vp, *reply, *my, *your;
150 bfd_wrapper_t const *wrapper = (bfd_wrapper_t const *) data;
151 bfd_packet_t const *bfd = (bfd_packet_t const *) wrapper->packet;
152
153 client = address->radclient;
154
155 /*
156 * Hacks for now until we have a lower-level decode routine.
157 */
158 request->packet->code = bfd->state;
159 request->packet->id = fr_nbo_to_uint32((uint8_t const *) &bfd->my_disc);
160 request->reply->id = request->packet->id;
161
162 request->packet->data = talloc_memdup(request->packet, data, data_len);
163 request->packet->data_len = data_len;
164
165 /*
166 * Set the rest of the fields.
167 */
168 request->client = UNCONST(fr_client_t *, client);
169
170 request->packet->socket = address->socket;
171 fr_socket_addr_swap(&request->reply->socket, &address->socket);
172
173 REQUEST_VERIFY(request);
174
175 /*
176 * Decode the packet into the reply.
177 */
178 if (wrapper->type == BFD_WRAPPER_SEND_PACKET) {
179 if (fr_bfd_decode(request->reply_ctx, &request->reply_pairs,
180 (uint8_t const *) bfd, bfd->length,
181 client->secret, talloc_strlen(client->secret)) < 0) {
182 RPEDEBUG("Failed decoding packet");
183 return -1;
184 }
185
186 request->reply->code = bfd->state;
187
188 return 0;
189 }
190
191 if (fr_bfd_decode(request->request_ctx, &request->request_pairs,
192 (uint8_t const *) bfd, bfd->length,
193 client->secret, talloc_strlen(client->secret)) < 0) {
194 RPEDEBUG("Failed decoding packet");
195 return -1;
196 }
197
198 /*
199 * Initialize the reply.
200 */
201 MEM(vp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_bfd_packet));
202
203 MEM(reply = fr_pair_copy(request->reply_ctx, vp));
204 fr_pair_append(&request->reply_pairs, reply);
205
206 my = fr_pair_find_by_da_nested(&reply->vp_group, NULL, attr_my_discriminator);
207 your = fr_pair_find_by_da_nested(&reply->vp_group, NULL, attr_your_discriminator);
208
209 if (my && your) {
210 uint32_t tmp = your->vp_uint32;
211
212 your->vp_uint32 = my->vp_uint32;
213 my->vp_uint32 = tmp;
214 }
215
216 if (fr_packet_pairs_from_packet(request->request_ctx, &request->request_pairs, request->packet) < 0) {
217 RPEDEBUG("Failed decoding 'Net.*' packet");
218 return -1;
219 }
220
221 return 0;
222}
223
224static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
225{
226// proto_bfd_t const *inst = talloc_get_type_abort_const(instance, proto_bfd_t);
227 fr_io_track_t *track = talloc_get_type_abort(request->async->packet_ctx, fr_io_track_t);
228 fr_io_address_t const *address = track->address;
229 fr_client_t const *client;
230 bfd_wrapper_t const *wrapper = (bfd_wrapper_t const *) request->packet->data;
231 bfd_packet_t const *bfd = (bfd_packet_t const *) wrapper->packet;
232 fr_pair_t *vp;
233 ssize_t slen;
234 fr_dbuff_t dbuff;
235
236 /*
237 * Process layer NAK, or "Do not respond".
238 */
239 if ((buffer_len == 1) || (wrapper->type == BFD_WRAPPER_RECV_PACKET) || (wrapper->type == BFD_WRAPPER_STATE_CHANGE)) {
240 return 0;
241 }
242
243 client = address->radclient;
244 fr_assert(client);
245
246 fr_packet_net_from_pairs(request->reply, &request->reply_pairs);
247
248 /*
249 * Dynamic client stuff
250 */
251 if (client->dynamic && !client->active) {
252 fr_client_t *new_client;
253
254 fr_assert(buffer_len >= sizeof(client));
255
256 /*
257 * Allocate the client. If that fails, send back a NAK.
258 *
259 * @todo - deal with NUMA zones? Or just deal with this
260 * client being in different memory.
261 *
262 * Maybe we should create a CONF_SECTION from the client,
263 * and pass *that* back to mod_write(), which can then
264 * parse it to create the actual client....
265 */
266 new_client = client_afrom_request(NULL, request);
267 if (!new_client) {
268 PERROR("Failed creating new client");
269 *buffer = true;
270 return 1;
271 }
272
273 memcpy(buffer, &new_client, sizeof(new_client));
274 return sizeof(new_client);
275 }
276
277 fr_assert((wrapper->packet + bfd->length) == (request->packet->data + request->packet->data_len));
278
279 /*
280 * Don't bother re-encoding the packet.
281 */
282 memcpy(buffer, bfd, bfd->length);
283
284 fr_assert(fr_bfd_packet_ok(NULL, buffer, bfd->length));
285
286 vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_additional_data);
287 if (!vp) return bfd->length;
288
289 fr_dbuff_init(&dbuff, buffer + bfd->length, buffer_len - bfd->length);
290 slen = fr_internal_encode_list(&dbuff, &vp->vp_group, NULL);
291 if (slen <= 0) return bfd->length;
292
293 return bfd->length + slen;
294}
295
296/** Open listen sockets/connect to external event source
297 *
298 * @param[in] instance Ctx data for this application.
299 * @param[in] sc to add our file descriptor to.
300 * @param[in] conf Listen section parsed to give us instance.
301 * @return
302 * - 0 on success.
303 * - -1 on failure.
304 */
305static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
306{
307 proto_bfd_t *inst = talloc_get_type_abort(instance, proto_bfd_t);
308
309 inst->io.app = &proto_bfd;
310 inst->io.app_instance = instance;
311
312 /*
313 * io.app_io should already be set
314 */
315 return fr_master_io_listen(&inst->io, sc,
316 inst->max_packet_size, inst->num_messages);
317}
318
319/** Bootstrap the application
320 *
321 * Bootstrap I/O and type submodules.
322 *
323 * @return
324 * - 0 on success.
325 * - -1 on failure.
326 */
327static int mod_instantiate(module_inst_ctx_t const *mctx)
328{
329 proto_bfd_t *inst = talloc_get_type_abort(mctx->mi->data, proto_bfd_t);
330 CONF_SECTION *server;
331
332 /*
333 * Ensure that the server CONF_SECTION is always set.
334 */
335 inst->io.server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
336
337 /*
338 * No IO module, it's an empty listener.
339 */
340 if (!inst->io.submodule) return 0;
341
342 /*
343 * Tell the master handler about the main protocol instance.
344 */
345 inst->io.app = &proto_bfd;
346 inst->io.app_instance = inst;
347
348 /*
349 * We will need this for dynamic clients and connected sockets.
350 */
351 inst->io.mi = mctx->mi;
352 server = inst->io.server_cs;
353
354 inst->peers = cf_data_value(cf_data_find(server, fr_rb_tree_t, "peers"));
355 if (!inst->peers) {
356 CONF_SECTION *cs = NULL;
357
359 if (!inst->peers) return -1;
360
361 while ((cs = cf_section_find_next(server, cs, "peer", CF_IDENT_ANY))) {
362 fr_client_t *c;
363 bfd_session_t *peer;
364
365 if (cf_section_rules_push(cs, peer_config) < 0) return -1;
366
367 c = client_afrom_cs(cs, cs, server, sizeof(bfd_session_t));
368 if (!c) {
369 error:
370 cf_log_err(cs, "Failed to parse peer %s", cf_section_name2(cs));
371 talloc_free(inst->peers);
372 return -1;
373 }
374
375 if (c->proto != IPPROTO_UDP) {
376 cf_log_err(cs, "Peer must use 'proto = udp' in %s", cf_section_name2(cs));
377 goto error;
378 }
379
380 peer = (bfd_session_t *) c;
381
382 FR_TIME_DELTA_BOUND_CHECK("peer.min_transmit_interval", peer->desired_min_tx_interval, >=, fr_time_delta_from_usec(32));
383 FR_TIME_DELTA_BOUND_CHECK("peer.min_transmit_interval", peer->desired_min_tx_interval, <=, fr_time_delta_from_sec(2));
384
385 FR_TIME_DELTA_BOUND_CHECK("peer.min_recieve_interval", peer->required_min_rx_interval, >=, fr_time_delta_from_usec(32));
386 FR_TIME_DELTA_BOUND_CHECK("peer.min_received_interval", peer->required_min_rx_interval, <=, fr_time_delta_from_sec(2));
387
388 FR_INTEGER_BOUND_CHECK("peer.max_timeouts", peer->detect_multi, >=, 1);
389 FR_INTEGER_BOUND_CHECK("peer.max_timeouts", peer->detect_multi, <=, 10);
390
391 if (((c->ipaddr.af == AF_INET) && (c->ipaddr.prefix != 32)) ||
392 ((c->ipaddr.af == AF_INET6) && (c->ipaddr.prefix != 128))) {
393 cf_log_err(cs, "Invalid IP prefix - cannot use ip/mask for BFD");
394 goto error;
395 }
396
397 /*
398 * Secret and auth_type handling.
399 */
400 if (c->secret) {
401 if (!*c->secret) {
402 cf_log_err(cs, "Secret cannot be an empty string");
403 goto error;
404 }
405
406 peer->secret_len = talloc_strlen(c->secret);
407 }
408
409 switch (peer->auth_type) {
411 if (c->secret) cf_log_warn(cs, "Ignoring 'secret' due to 'auth_type = none'");
412 break;
413
414 case BFD_AUTH_SIMPLE:
417 if (!c->secret) {
418 cf_log_err(cs, "A 'secret' must be specified when using 'auth_type = simple'");
419 goto error;
420 }
421
422 if (strlen(c->secret) > 16) {
423 cf_log_err(cs, "Length of 'secret' must be no more than 16 octets for 'auth_type = simple'");
424 goto error;
425 }
426 break;
427
430 if (!c->secret) {
431 cf_log_err(cs, "A 'secret' must be specified when using 'auth_type = ...'");
432 goto error;
433 }
434
435 if (strlen(c->secret) > 20) {
436 cf_log_err(cs, "Length of 'secret' must be no more than 20 octets for 'auth_type = simple'");
437 goto error;
438 }
439 break;
440
441 }
442
443 c->active = true;
444
445 if (!fr_rb_insert(inst->peers, c)) {
446 cf_log_err(cs, "Failed to add peer %s", cf_section_name2(cs));
447 goto error;
448 }
449 }
450
451 (void) cf_data_add(server, inst->peers, "peers", false);
452 }
453
454 /*
455 * These configuration items are not printed by default,
456 * because normal people shouldn't be touching them.
457 */
458 if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
459
460 if (!inst->num_messages) inst->num_messages = 256;
461
462 FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
463 FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
464
465 FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
466 FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
467
468 /*
469 * Instantiate the transport module before calling the
470 * common instantiation function.
471 */
472 if (module_instantiate(inst->io.submodule) < 0) return -1;
473
474 /*
475 * Instantiate the master io submodule
476 */
478}
479
480static int mod_load(void)
481{
482 if (fr_bfd_global_init() < 0) {
483 PERROR("Failed initialising protocol library");
484 return -1;
485 }
486 return 0;
487}
488
489static void mod_unload(void)
490{
492}
493
495 .common = {
496 .magic = MODULE_MAGIC_INIT,
497 .name = "bfd",
499 .inst_size = sizeof(proto_bfd_t),
500 .onload = mod_load,
501 .unload = mod_unload,
502 .instantiate = mod_instantiate
503 },
504 .dict = &dict_bfd,
505 .open = mod_open,
506 .decode = mod_decode,
507 .encode = mod_encode,
508};
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
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
bfd_auth_type_t
Definition bfd.h:52
@ BFD_AUTH_MET_KEYED_MD5
Definition bfd.h:56
@ BFD_AUTH_MET_KEYED_SHA1
Definition bfd.h:58
@ BFD_AUTH_SIMPLE
Definition bfd.h:54
@ BFD_AUTH_KEYED_SHA1
Definition bfd.h:57
@ BFD_AUTH_KEYED_MD5
Definition bfd.h:55
@ BFD_AUTH_RESERVED
Definition bfd.h:53
ssize_t fr_bfd_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *packet, size_t packet_len, char const *secret, size_t secret_len)
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
Definition build.h:186
#define unlikely(_x)
Definition build.h:407
#define UNUSED
Definition build.h:336
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:669
cf_parse_t func
Override default parsing behaviour for the specified type with a custom parsing function.
Definition cf_parse.h:623
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
Definition cf_parse.h:529
#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
#define cf_section_rules_push(_cs, _rule)
Definition cf_parse.h:701
#define FR_TIME_DELTA_BOUND_CHECK(_name, _var, _op, _bound)
Definition cf_parse.h:540
#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:606
Common header for all CONF_* types.
Definition cf_priv.h:54
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:1352
void * cf_data_value(CONF_DATA const *cd)
Return the user assigned value of CONF_DATA.
Definition cf_util.c:1906
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
Definition cf_util.c:692
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
Definition cf_util.c:672
CONF_SECTION * cf_section_find_next(CONF_SECTION const *cs, CONF_SECTION const *prev, char const *name1, char const *name2)
Return the next matching section.
Definition cf_util.c:1215
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
Definition cf_util.c:1746
#define cf_log_err(_cf, _fmt,...)
Definition cf_util.h:345
#define cf_data_add(_cf, _data, _name, _free)
Definition cf_util.h:311
#define cf_data_find(_cf, _type, _name)
Definition cf_util.h:300
#define cf_parent(_cf)
Definition cf_util.h:118
#define cf_log_warn(_cf, _fmt,...)
Definition cf_util.h:346
#define CF_IDENT_ANY
Definition cf_util.h:80
#define fr_dbuff_init(_out, _start, _len_or_end)
Initialise an dbuff for encoding or decoding.
Definition dbuff.h:362
#define MEM(x)
Definition debug.h:36
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition dict.h:292
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition dict.h:305
#define DICT_AUTOLOAD_TERMINATOR
Definition dict.h:311
Specifies an attribute which must be present for the module to function.
Definition dict.h:291
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition dict.h:304
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
void fr_bio_shutdown & my
Definition fd_errno.h:73
talloc_free(hp)
int8_t fr_ipaddr_cmp(fr_ipaddr_t const *a, fr_ipaddr_t const *b)
Compare two ip addresses.
Definition inet.c:1353
uint8_t prefix
Prefix length - Between 0-32 for IPv4 and 0-128 for IPv6.
Definition inet.h:68
int af
Address family.
Definition inet.h:63
fr_socket_t socket
src/dst ip and port.
Definition base.h:336
fr_client_t const * radclient
old-style client definition
Definition base.h:338
fr_ipaddr_t ipaddr
IPv4/IPv6 address of the host.
Definition client.h:83
char const * secret
Secret PSK.
Definition client.h:90
bool active
for dynamic clients
Definition client.h:120
int proto
Protocol number.
Definition client.h:147
bool dynamic
Whether the client was dynamically defined.
Definition client.h:119
Describes a host allowed to send packets to the server.
Definition client.h:80
#define PERROR(_fmt,...)
Definition log.h:228
#define RPEDEBUG(fmt,...)
Definition log.h:388
int fr_packet_pairs_from_packet(TALLOC_CTX *ctx, fr_pair_list_t *list, fr_packet_t const *packet)
Allocate a "Net." struct with src/dst host and port.
Definition packet.c:91
void fr_packet_net_from_pairs(fr_packet_t *packet, fr_pair_list_t const *list)
Convert pairs to information in a packet.
Definition packet.c:154
size_t secret_len
doesn't change while we're running
Definition session.h:106
fr_time_delta_t required_min_rx_interval
intervals between receives
Definition session.h:82
@ BFD_WRAPPER_STATE_CHANGE
Definition session.h:128
@ BFD_WRAPPER_SEND_PACKET
Definition session.h:127
@ BFD_WRAPPER_RECV_PACKET
Definition session.h:126
uint8_t packet[]
Definition session.h:145
bfd_auth_type_t auth_type
what kind of authentication is used
Definition session.h:101
uint32_t detect_multi
Definition session.h:79
fr_time_delta_t desired_min_tx_interval
intervals between transmits
Definition session.h:81
uint32_t type
Definition session.h:142
fr_app_io_t fr_master_app_io
Definition master.c:3549
int fr_master_io_listen(fr_io_instance_t *inst, fr_schedule_t *sc, size_t default_message_size, size_t num_messages)
Definition master.c:3339
fr_io_address_t const * address
of this packet.. shared between multiple packets
Definition master.h:55
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
@ FR_TYPE_VOID
User data.
@ FR_TYPE_GROUP
A grouping of other attributes.
unsigned int uint32_t
long int ssize_t
unsigned char uint8_t
#define MODULE_INST_CTX(_mi)
Wrapper to create a module_inst_ctx_t as a compound literal.
Definition module_ctx.h:158
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
static uint32_t fr_nbo_to_uint32(uint8_t const data[static sizeof(uint32_t)])
Read an unsigned 32bit integer from wire format (big endian)
Definition nbo.h:167
fr_pair_t * fr_pair_find_by_da_nested(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find a pair with a matching fr_dict_attr_t, by walking the nested fr_dict_attr_t tree.
Definition pair.c:784
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
Definition pair.c:707
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
Definition pair.c:1352
fr_pair_t * fr_pair_copy(TALLOC_CTX *ctx, fr_pair_t const *vp)
Copy a single valuepair.
Definition pair.c:503
static int mod_load(void)
Definition proto_bfd.c:480
static fr_dict_attr_t const * attr_packet_type
Definition proto_bfd.c:68
static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
Definition proto_bfd.c:224
static int8_t client_cmp(void const *one, void const *two)
Definition proto_bfd.c:105
static fr_dict_attr_t const * attr_bfd_packet
Definition proto_bfd.c:69
static conf_parser_t const proto_bfd_config[]
How to parse a BFD listen section.
Definition proto_bfd.c:39
static fr_dict_attr_t const * attr_my_discriminator
Definition proto_bfd.c:70
static fr_dict_attr_t const * attr_additional_data
Definition proto_bfd.c:72
fr_dict_attr_autoload_t proto_bfd_dict_attr[]
Definition proto_bfd.c:75
static void mod_unload(void)
Definition proto_bfd.c:489
static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Decode the packet.
Definition proto_bfd.c:144
fr_app_t proto_bfd
Definition proto_bfd.c:494
fr_dict_autoload_t proto_bfd_dict[]
Definition proto_bfd.c:63
static fr_dict_attr_t const * attr_your_discriminator
Definition proto_bfd.c:71
static int auth_type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static const conf_parser_t peer_config[]
Definition proto_bfd.c:46
static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Definition proto_bfd.c:86
static fr_dict_t const * dict_bfd
Definition proto_bfd.c:60
static int mod_instantiate(module_inst_ctx_t const *mctx)
Bootstrap the application.
Definition proto_bfd.c:327
static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
Open listen sockets/connect to external event source.
Definition proto_bfd.c:305
An instance of a proto_radius listen section.
Definition proto_bfd.h:33
int fr_bfd_global_init(void)
Definition base.c:222
void fr_bfd_global_free(void)
Definition base.c:247
fr_table_num_ordered_t const bfd_auth_type_table[]
Definition base.c:71
bool fr_bfd_packet_ok(char const **err, uint8_t const *packet, size_t packet_len)
Definition base.c:84
ssize_t fr_internal_encode_list(fr_dbuff_t *dbuff, fr_pair_list_t const *list, void *encode_ctx)
Encode a list of pairs using the internal encoder.
Definition encode.c:304
#define fr_assert(_expr)
Definition rad_assert.h:37
static rs_t * conf
Definition radsniff.c:52
bool fr_rb_insert(fr_rb_tree_t *tree, void const *data)
Insert data into a tree.
Definition rb.c:626
#define fr_rb_inline_talloc_alloc(_ctx, _type, _field, _data_cmp, _data_free)
Allocs a red black that verifies elements are of a specific talloc type.
Definition rb.h:244
The main red black tree structure.
Definition rb.h:71
#define REQUEST_VERIFY(_x)
Definition request.h:311
static char const * name
The scheduler.
Definition schedule.c:76
CONF_SECTION * conf
Module's instance configuration.
Definition module.h:351
void * data
Module's instance data.
Definition module.h:293
module_instantiate_t instantiate
Callback to allow the module to register any per-instance resources like sockets and file handles.
Definition module.h:227
conf_parser_t const * config
How to convert a CONF_SECTION to a module instance.
Definition module.h:206
module_t * exported
Public module structure.
Definition module.h:298
Module instance data.
Definition module.h:287
static const uchar sc[16]
Definition smbdes.c:115
fr_client_t * client_afrom_cs(TALLOC_CTX *ctx, CONF_SECTION *cs, CONF_SECTION *server_cs, size_t extra)
Allocate a new client from a config section.
Definition client.c:736
fr_client_t * client_afrom_request(TALLOC_CTX *ctx, request_t *request)
Create a new client, consuming all attributes in the control list of the request.
Definition client.c:966
int module_instantiate(module_instance_t *instance)
Manually complete module setup by calling its instantiate function.
Definition module.c:1224
eap_aka_sim_process_conf_t * inst
fr_pair_t * vp
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
#define fr_table_value_by_str(_table, _name, _def)
Convert a string to a value using a sorted or ordered table.
Definition table.h:685
#define talloc_get_type_abort_const
Definition talloc.h:117
static size_t talloc_strlen(char const *s)
Returns the length of a talloc array containing a string.
Definition talloc.h:143
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
Definition time.h:590
static fr_time_delta_t fr_time_delta_from_usec(int64_t usec)
Definition time.h:568
static fr_slen_t parent
Definition pair.h:858
static void fr_socket_addr_swap(fr_socket_t *dst, fr_socket_t const *src)
Swap src/dst information of a fr_socket_t.
Definition socket.h:118
static fr_slen_t data
Definition value.h:1340
static size_t char ** out
Definition value.h:1030
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.