The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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: 48659d2af3a8c26d2b24d82353867a5b263fedc2 $
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 
31 extern fr_app_t proto_bfd;
32 
33 static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
34 static 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  */
39 static conf_parser_t const proto_bfd_config[] = {
40  { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_bfd_t, io.submodule),
41  .func = transport_parse },
42 
44 };
45 
46 static 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 ),
53  .func = auth_type_parse },
54 
55  { FR_CONF_OFFSET("port", bfd_session_t, port ) },
56 
58 };
59 
60 static fr_dict_t const *dict_bfd;
61 
64  { .out = &dict_bfd, .proto = "bfd" },
65  { NULL }
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},
83  { NULL }
84 };
85 
86 static 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_sever_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  */
105 static 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  */
124 static 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  */
144 static 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  /*
154  * Set the request dictionary so that we can do
155  * generic->protocol attribute conversions as
156  * the request runs through the server.
157  */
158  request->dict = dict_bfd;
159 
160  client = address->radclient;
161 
162  /*
163  * Hacks for now until we have a lower-level decode routine.
164  */
165  request->packet->code = bfd->state;
166  request->packet->id = fr_nbo_to_uint32((uint8_t const *) &bfd->my_disc);
167  request->reply->id = request->packet->id;
168 
169  request->packet->data = talloc_memdup(request->packet, data, data_len);
170  request->packet->data_len = data_len;
171 
172  /*
173  * Set the rest of the fields.
174  */
175  request->client = UNCONST(fr_client_t *, client);
176 
177  request->packet->socket = address->socket;
178  fr_socket_addr_swap(&request->reply->socket, &address->socket);
179 
180  REQUEST_VERIFY(request);
181 
182  /*
183  * Decode the packet into the reply.
184  */
185  if (wrapper->type == BFD_WRAPPER_SEND_PACKET) {
186  if (fr_bfd_decode(request->reply_ctx, &request->reply_pairs,
187  (uint8_t const *) bfd, bfd->length,
188  client->secret, talloc_array_length(client->secret) - 1) < 0) {
189  RPEDEBUG("Failed decoding packet");
190  return -1;
191  }
192 
193  request->reply->code = bfd->state;
194 
195  return 0;
196  }
197 
198  if (fr_bfd_decode(request->request_ctx, &request->request_pairs,
199  (uint8_t const *) bfd, bfd->length,
200  client->secret, talloc_array_length(client->secret) - 1) < 0) {
201  RPEDEBUG("Failed decoding packet");
202  return -1;
203  }
204 
205  /*
206  * Initialize the reply.
207  */
208  vp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_bfd_packet);
209  if (!vp) return -1;
210 
211  reply = fr_pair_copy(request->reply_ctx, vp);
212  fr_pair_append(&request->reply_pairs, reply);
213 
214  my = fr_pair_find_by_da_nested(&reply->vp_group, NULL, attr_my_discriminator);
215  your = fr_pair_find_by_da_nested(&reply->vp_group, NULL, attr_your_discriminator);
216 
217  if (my && your) {
218  uint32_t tmp = your->vp_uint32;
219 
220  your->vp_uint32 = my->vp_uint32;
221  my->vp_uint32 = tmp;
222  }
223 
224  if (fr_packet_pairs_from_packet(request->request_ctx, &request->request_pairs, request->packet) < 0) {
225  RPEDEBUG("Failed decoding 'Net.*' packet");
226  return -1;
227  }
228 
229  return 0;
230 }
231 
232 static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
233 {
234 // proto_bfd_t const *inst = talloc_get_type_abort_const(instance, proto_bfd_t);
235  fr_io_track_t *track = talloc_get_type_abort(request->async->packet_ctx, fr_io_track_t);
236  fr_io_address_t const *address = track->address;
237  fr_client_t const *client;
238  bfd_wrapper_t const *wrapper = (bfd_wrapper_t const *) request->packet->data;
239  bfd_packet_t const *bfd = (bfd_packet_t const *) wrapper->packet;
240  fr_pair_t *vp;
241  ssize_t slen;
242  fr_dbuff_t dbuff;
243 
244  /*
245  * Process layer NAK, or "Do not respond".
246  */
247  if ((buffer_len == 1) || (wrapper->type == BFD_WRAPPER_RECV_PACKET) || (wrapper->type == BFD_WRAPPER_STATE_CHANGE)) {
248  return 0;
249  }
250 
251  client = address->radclient;
252  fr_assert(client);
253 
254  fr_packet_net_from_pairs(request->reply, &request->reply_pairs);
255 
256  /*
257  * Dynamic client stuff
258  */
259  if (client->dynamic && !client->active) {
260  fr_client_t *new_client;
261 
262  fr_assert(buffer_len >= sizeof(client));
263 
264  /*
265  * Allocate the client. If that fails, send back a NAK.
266  *
267  * @todo - deal with NUMA zones? Or just deal with this
268  * client being in different memory.
269  *
270  * Maybe we should create a CONF_SECTION from the client,
271  * and pass *that* back to mod_write(), which can then
272  * parse it to create the actual client....
273  */
274  new_client = client_afrom_request(NULL, request);
275  if (!new_client) {
276  PERROR("Failed creating new client");
277  *buffer = true;
278  return 1;
279  }
280 
281  memcpy(buffer, &new_client, sizeof(new_client));
282  return sizeof(new_client);
283  }
284 
285  fr_assert((wrapper->packet + bfd->length) == (request->packet->data + request->packet->data_len));
286 
287  /*
288  * Don't bother re-encoding the packet.
289  */
290  memcpy(buffer, bfd, bfd->length);
291 
292  fr_assert(fr_bfd_packet_ok(NULL, buffer, bfd->length));
293 
294  vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_additional_data);
295  if (!vp) return bfd->length;
296 
297  fr_dbuff_init(&dbuff, buffer + bfd->length, buffer_len - bfd->length);
298  slen = fr_internal_encode_list(&dbuff, &vp->vp_group, NULL);
299  if (slen <= 0) return bfd->length;
300 
301  return bfd->length + slen;
302 }
303 
304 /** Open listen sockets/connect to external event source
305  *
306  * @param[in] instance Ctx data for this application.
307  * @param[in] sc to add our file descriptor to.
308  * @param[in] conf Listen section parsed to give us instance.
309  * @return
310  * - 0 on success.
311  * - -1 on failure.
312  */
313 static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
314 {
315  proto_bfd_t *inst = talloc_get_type_abort(instance, proto_bfd_t);
316 
317  inst->io.app = &proto_bfd;
318  inst->io.app_instance = instance;
319 
320  /*
321  * io.app_io should already be set
322  */
323  return fr_master_io_listen(&inst->io, sc,
324  inst->max_packet_size, inst->num_messages);
325 }
326 
327 /** Bootstrap the application
328  *
329  * Bootstrap I/O and type submodules.
330  *
331  * @return
332  * - 0 on success.
333  * - -1 on failure.
334  */
335 static int mod_instantiate(module_inst_ctx_t const *mctx)
336 {
337  proto_bfd_t *inst = talloc_get_type_abort(mctx->mi->data, proto_bfd_t);
338  CONF_SECTION *server;
339 
340  /*
341  * Ensure that the server CONF_SECTION is always set.
342  */
343  inst->io.server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
344 
345  /*
346  * No IO module, it's an empty listener.
347  */
348  if (!inst->io.submodule) return 0;
349 
350  /*
351  * Tell the master handler about the main protocol instance.
352  */
353  inst->io.app = &proto_bfd;
354  inst->io.app_instance = inst;
355 
356  /*
357  * We will need this for dynamic clients and connected sockets.
358  */
359  inst->io.mi = mctx->mi;
360  server = inst->io.server_cs;
361 
362  inst->peers = cf_data_value(cf_data_find(server, fr_rb_tree_t, "peers"));
363  if (!inst->peers) {
364  CONF_SECTION *cs = NULL;
365 
366  inst->peers = fr_rb_inline_talloc_alloc(inst, fr_client_t, node, client_cmp, NULL);
367  if (!inst->peers) return -1;
368 
369  while ((cs = cf_section_find_next(server, cs, "peer", CF_IDENT_ANY))) {
370  fr_client_t *c;
371  bfd_session_t *peer;
372 
373  if (cf_section_rules_push(cs, peer_config) < 0) return -1;
374 
375  c = client_afrom_cs(cs, cs, server, sizeof(bfd_session_t));
376  if (!c) {
377  error:
378  cf_log_err(cs, "Failed to parse peer %s", cf_section_name2(cs));
379  talloc_free(inst->peers);
380  return -1;
381  }
382 
383  if (c->proto != IPPROTO_UDP) {
384  cf_log_err(cs, "Peer must use 'proto = udp' in %s", cf_section_name2(cs));
385  goto error;
386  }
387 
388  peer = (bfd_session_t *) c;
389 
390  FR_TIME_DELTA_BOUND_CHECK("peer.min_transmit_interval", peer->desired_min_tx_interval, >=, fr_time_delta_from_usec(32));
391  FR_TIME_DELTA_BOUND_CHECK("peer.min_transmit_interval", peer->desired_min_tx_interval, <=, fr_time_delta_from_sec(2));
392 
393  FR_TIME_DELTA_BOUND_CHECK("peer.min_recieve_interval", peer->required_min_rx_interval, >=, fr_time_delta_from_usec(32));
394  FR_TIME_DELTA_BOUND_CHECK("peer.min_received_interval", peer->required_min_rx_interval, <=, fr_time_delta_from_sec(2));
395 
396  FR_INTEGER_BOUND_CHECK("peer.max_timeouts", peer->detect_multi, >=, 1);
397  FR_INTEGER_BOUND_CHECK("peer.max_timeouts", peer->detect_multi, <=, 10);
398 
399  if (((c->ipaddr.af == AF_INET) && (c->ipaddr.prefix != 32)) ||
400  ((c->ipaddr.af == AF_INET6) && (c->ipaddr.prefix != 128))) {
401  cf_log_err(cs, "Invalid IP prefix - cannot use ip/mask for BFD");
402  goto error;
403  }
404 
405  /*
406  * Secret and auth_type handling.
407  */
408  if (c->secret) {
409  if (!*c->secret) {
410  cf_log_err(cs, "Secret cannot be an empty string");
411  goto error;
412  }
413 
414  peer->secret_len = talloc_array_length(c->secret) - 1;
415  }
416 
417  switch (peer->auth_type) {
418  case BFD_AUTH_RESERVED:
419  if (c->secret) cf_log_warn(cs, "Ignoring 'secret' due to 'auth_type = none'");
420  break;
421 
422  case BFD_AUTH_SIMPLE:
423  case BFD_AUTH_KEYED_MD5:
425  if (!c->secret) {
426  cf_log_err(cs, "A 'secret' must be specified when using 'auth_type = simple'");
427  goto error;
428  }
429 
430  if (strlen(c->secret) > 16) {
431  cf_log_err(cs, "Length of 'secret' must be no more than 16 octets for 'auth_type = simple'");
432  goto error;
433  }
434  break;
435 
436  case BFD_AUTH_KEYED_SHA1:
438  if (!c->secret) {
439  cf_log_err(cs, "A 'secret' must be specified when using 'auth_type = ...'");
440  goto error;
441  }
442 
443  if (strlen(c->secret) > 20) {
444  cf_log_err(cs, "Length of 'secret' must be no more than 16 octets for 'auth_type = simple'");
445  goto error;
446  }
447  break;
448 
449  }
450 
451  c->active = true;
452 
453  if (!fr_rb_insert(inst->peers, c)) {
454  cf_log_err(cs, "Failed to add peer %s", cf_section_name2(cs));
455  goto error;
456  }
457  }
458 
459  (void) cf_data_add(server, inst->peers, "peers", false);
460  }
461 
462  /*
463  * These configuration items are not printed by default,
464  * because normal people shouldn't be touching them.
465  */
466  if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
467 
468  if (!inst->num_messages) inst->num_messages = 256;
469 
470  FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
471  FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
472 
473  FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
474  FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
475 
476  /*
477  * Instantiate the transport module before calling the
478  * common instantiation function.
479  */
480  if (module_instantiate(inst->io.submodule) < 0) return -1;
481 
482  /*
483  * Instantiate the master io submodule
484  */
486 }
487 
488 static int mod_load(void)
489 {
490  if (fr_bfd_global_init() < 0) {
491  PERROR("Failed initialising protocol library");
492  return -1;
493  }
494  return 0;
495 }
496 
497 static void mod_unload(void)
498 {
500 }
501 
503  .common = {
504  .magic = MODULE_MAGIC_INIT,
505  .name = "bfd",
506  .config = proto_bfd_config,
507  .inst_size = sizeof(proto_bfd_t),
508  .onload = mod_load,
509  .unload = mod_unload,
511  },
512  .dict = &dict_bfd,
513  .open = mod_open,
514  .decode = mod_decode,
515  .encode = mod_encode,
516 };
static int const char char buffer[256]
Definition: acutest.h:574
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:165
#define unlikely(_x)
Definition: build.h:379
#define UNUSED
Definition: build.h:313
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:626
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
Definition: cf_parse.h:486
#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:268
#define cf_section_rules_push(_cs, _rule)
Definition: cf_parse.h:658
#define FR_TIME_DELTA_BOUND_CHECK(_name, _var, _op, _bound)
Definition: cf_parse.h:497
#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:563
Common header for all CONF_* types.
Definition: cf_priv.h:49
A section grouping multiple CONF_PAIR.
Definition: cf_priv.h:89
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
Definition: cf_util.c:664
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
Definition: cf_util.c:1187
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
Definition: cf_util.c:1596
void * cf_data_value(CONF_DATA const *cd)
Return the user assigned value of CONF_DATA.
Definition: cf_util.c:1765
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
Definition: cf_util.c:684
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:1051
#define cf_log_err(_cf, _fmt,...)
Definition: cf_util.h:289
#define cf_data_add(_cf, _data, _name, _free)
Definition: cf_util.h:255
#define cf_data_find(_cf, _type, _name)
Definition: cf_util.h:244
#define cf_parent(_cf)
Definition: cf_util.h:101
#define cf_log_warn(_cf, _fmt,...)
Definition: cf_util.h:290
#define CF_IDENT_ANY
Definition: cf_util.h:78
#define fr_dbuff_init(_out, _start, _len_or_end)
Initialise an dbuff for encoding or decoding.
Definition: dbuff.h:354
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition: dict.h:250
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition: dict.h:263
Specifies an attribute which must be present for the module to function.
Definition: dict.h:249
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition: dict.h:262
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:63
int8_t fr_ipaddr_cmp(fr_ipaddr_t const *a, fr_ipaddr_t const *b)
Compare two ip addresses.
Definition: inet.c:1332
uint8_t prefix
Prefix length - Between 0-32 for IPv4 and 0-128 for IPv6.
Definition: inet.h:69
int af
Address family.
Definition: inet.h:64
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:119
int proto
Protocol number.
Definition: client.h:143
bool dynamic
Whether the client was dynamically defined.
Definition: client.h:118
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:376
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:89
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:139
talloc_free(reap)
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:3133
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:2925
fr_io_address_t const * address
of this packet.. shared between multiple packets
Definition: master.h:54
@ FR_TYPE_UINT32
32 Bit unsigned integer.
Definition: merged_model.c:99
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
Definition: merged_model.c:119
@ FR_TYPE_VOID
User data.
Definition: merged_model.c:127
@ FR_TYPE_GROUP
A grouping of other attributes.
Definition: merged_model.c:124
unsigned int uint32_t
Definition: merged_model.c:33
long int ssize_t
Definition: merged_model.c:24
unsigned char uint8_t
Definition: merged_model.c:30
#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:158
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:688
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:1340
fr_pair_t * fr_pair_copy(TALLOC_CTX *ctx, fr_pair_t const *vp)
Copy a single valuepair.
Definition: pair.c:484
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:765
static int mod_load(void)
Definition: proto_bfd.c:488
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:232
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:497
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:502
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:335
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:313
An instance of a proto_radius listen section.
Definition: proto_bfd.h:33
int fr_bfd_global_init(void)
Definition: base.c:221
void fr_bfd_global_free(void)
Definition: base.c:244
fr_table_num_ordered_t const bfd_auth_type_table[]
Definition: base.c:70
bool fr_bfd_packet_ok(char const **err, uint8_t const *packet, size_t packet_len)
Definition: base.c:83
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:303
static rs_t * conf
Definition: radsniff.c:53
bool fr_rb_insert(fr_rb_tree_t *tree, void const *data)
Insert data into a tree.
Definition: rb.c:624
#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:246
The main red black tree structure.
Definition: rb.h:73
#define REQUEST_VERIFY(_x)
Definition: request.h:276
static char const * name
static int instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_rest.c:1329
The scheduler.
Definition: schedule.c:125
CONF_SECTION * conf
Module's instance configuration.
Definition: module.h:329
void * data
Module's instance data.
Definition: module.h:271
module_instantiate_t instantiate
Callback to allow the module to register any per-instance resources like sockets and file handles.
Definition: module.h:218
module_t * exported
Public module structure.
Definition: module.h:276
Module instance data.
Definition: module.h:265
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:705
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:927
int module_instantiate(module_instance_t *instance)
Manually complete module setup by calling its instantiate function.
Definition: module.c:1195
fr_assert(0)
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:134
#define talloc_get_type_abort_const
Definition: talloc.h:271
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:844
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:121
static fr_slen_t data
Definition: value.h:1259
static size_t char ** out
Definition: value.h:984
int virtual_sever_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.