The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
proto_dhcpv6.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: f3a36783f1ec5d6bdaa48d11b09b74aca66a3229 $
19  * @file proto_dhcpv6.c
20  * @brief DHCPV6 master protocol handler.
21  *
22  * @copyright 2020 Network RADIUS SAS (legal@networkradius.com)
23  */
24 #define LOG_PREFIX "proto_dhcpv6"
25 
26 #include <freeradius-devel/io/listen.h>
27 #include <freeradius-devel/server/module_rlm.h>
28 #include <freeradius-devel/util/debug.h>
29 #include "proto_dhcpv6.h"
30 
31 extern fr_app_t proto_dhcpv6;
32 static int type_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
33 static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
34 
35 static const conf_parser_t priority_config[] = {
36  { FR_CONF_OFFSET("Solicit", proto_dhcpv6_t, priorities[FR_DHCPV6_SOLICIT]),
37  .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
38  { FR_CONF_OFFSET("Request", proto_dhcpv6_t, priorities[FR_DHCPV6_REQUEST]),
39  .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
40  { FR_CONF_OFFSET("Renew", proto_dhcpv6_t, priorities[FR_DHCPV6_RENEW]),
41  .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
42  { FR_CONF_OFFSET("Rebind", proto_dhcpv6_t, priorities[FR_DHCPV6_REBIND]),
43  .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
44  { FR_CONF_OFFSET("Release", proto_dhcpv6_t, priorities[FR_DHCPV6_RELEASE]),
45  .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
46  { FR_CONF_OFFSET("Decline", proto_dhcpv6_t, priorities[FR_DHCPV6_DECLINE]),
47  .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
48  { FR_CONF_OFFSET("Information-Request", proto_dhcpv6_t, priorities[FR_DHCPV6_INFORMATION_REQUEST]),
49  .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
50  { FR_CONF_OFFSET("Relay-Forward", proto_dhcpv6_t, priorities[FR_DHCPV6_RELAY_FORWARD]),
51  .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
53 };
54 
55 static conf_parser_t const limit_config[] = {
56  { FR_CONF_OFFSET("cleanup_delay", proto_dhcpv6_t, io.cleanup_delay), .dflt = "5.0" } ,
57  { FR_CONF_OFFSET("idle_timeout", proto_dhcpv6_t, io.idle_timeout), .dflt = "30.0" } ,
58  { FR_CONF_OFFSET("nak_lifetime", proto_dhcpv6_t, io.nak_lifetime), .dflt = "30.0" } ,
59 
60  { FR_CONF_OFFSET("max_connections", proto_dhcpv6_t, io.max_connections), .dflt = "1024" } ,
61  { FR_CONF_OFFSET("max_clients", proto_dhcpv6_t, io.max_clients), .dflt = "256" } ,
62  { FR_CONF_OFFSET("max_pending_packets", proto_dhcpv6_t, io.max_pending_packets), .dflt = "256" } ,
63 
64  /*
65  * For performance tweaking. NOT for normal humans.
66  */
67  { FR_CONF_OFFSET("max_packet_size", proto_dhcpv6_t, max_packet_size) } ,
68  { FR_CONF_OFFSET("num_messages", proto_dhcpv6_t, num_messages) } ,
69  { FR_CONF_POINTER("priority", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) priority_config },
70 
72 };
73 
74 /** How to parse a DHCPV6 listen section
75  *
76  */
78  { FR_CONF_OFFSET_FLAGS("type", CONF_FLAG_NOT_EMPTY, proto_dhcpv6_t, allowed_types), .func = type_parse },
79  { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_dhcpv6_t, io.submodule), .func = transport_parse },
80 
81  { FR_CONF_POINTER("limit", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) limit_config },
82 
84 };
85 
86 static fr_dict_t const *dict_dhcpv6;
87 
90  { .out = &dict_dhcpv6, .proto = "dhcpv6" },
91  { NULL }
92 };
93 
96 
99  { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_dhcpv6},
100  { .out = &attr_client_id, .name = "Client-Id", .type = FR_TYPE_STRUCT, .dict = &dict_dhcpv6},
101  { NULL }
102 };
103 
104 /** Wrapper around dl_instance which translates the packet-type into a submodule name
105  *
106  * @param[in] ctx to allocate data in (instance of proto_dhcpv6).
107  * @param[out] out Where to write a dl_module_inst_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  */
115 static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent,
116  CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
117 {
118  proto_dhcpv6_t *inst = talloc_get_type_abort(parent, proto_dhcpv6_t);
120  CONF_PAIR *cp;
121  char const *value;
122 
123  cp = cf_item_to_pair(ci);
124  value = cf_pair_value(cp);
125 
127  if (!dv || (dv->value->vb_uint32 >= FR_DHCPV6_CODE_MAX)) {
128  cf_log_err(ci, "Unknown DHCPv6 packet type '%s'", value);
129  return -1;
130  }
131 
132  inst->allowed[dv->value->vb_uint32] = true;
133  *((char const **) out) = value;
134 
135  return 0;
136 }
137 
138 /** Wrapper around dl_instance
139  *
140  * @param[in] ctx to allocate data in (instance of proto_dhcpv6).
141  * @param[out] out Where to write a dl_module_inst_t containing the module handle and instance.
142  * @param[in] parent Base structure address.
143  * @param[in] ci #CONF_PAIR specifying the name of the type module.
144  * @param[in] rule unused.
145  * @return
146  * - 0 on success.
147  * - -1 on failure.
148  */
149 static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
150  CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
151 {
152  char const *name = cf_pair_value(cf_item_to_pair(ci));
153  dl_module_inst_t *parent_inst;
155  CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
156  CONF_SECTION *transport_cs;
157  dl_module_inst_t *dl_mod_inst;
158 
159  transport_cs = cf_section_find(listen_cs, name, NULL);
160 
161  /*
162  * Allocate an empty section if one doesn't exist
163  * this is so defaults get parsed.
164  */
165  if (!transport_cs) transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
166 
167  parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_dhcpv6"));
168  fr_assert(parent_inst);
169 
170  /*
171  * Set the allowed codes so that we can compile them as
172  * necessary.
173  */
174  inst = talloc_get_type_abort(parent_inst->data, proto_dhcpv6_t);
175  inst->io.transport = name;
176 
177  if (dl_module_instance(ctx, &dl_mod_inst, parent_inst,
178  DL_MODULE_TYPE_SUBMODULE, name, dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
179  if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
180  talloc_free(dl_mod_inst);
181  return -1;
182  }
183  *((dl_module_inst_t **)out) = dl_mod_inst;
184 
185  return 0;
186 }
187 
188 /** Decode the packet
189  *
190  */
191 static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
192 {
193  fr_io_track_t const *track = talloc_get_type_abort_const(request->async->packet_ctx, fr_io_track_t);
194  fr_io_address_t const *address = track->address;
195  fr_client_t const *client;
196  fr_packet_t *packet = request->packet;
197 
198  /*
199  * Set the request dictionary so that we can do
200  * generic->protocol attribute conversions as
201  * the request runs through the server.
202  */
203  request->dict = dict_dhcpv6;
204 
205  RHEXDUMP3(data, data_len, "proto_dhcpv6 decode packet");
206 
207  client = address->radclient;
208 
209  /*
210  * Hacks for now until we have a lower-level decode routine.
211  */
212  request->packet->code = data[0];
213  request->packet->id = (data[1] << 16) | (data[2] << 8) | data[3];
214  request->reply->id = request->packet->id;
215 
216  request->packet->data = talloc_memdup(request->packet, data, data_len);
217  request->packet->data_len = data_len;
218 
219  /*
220  * Note that we don't set a limit on max_attributes here.
221  * That MUST be set and checked in the underlying
222  * transport, via a call to fr_dhcpv6_ok().
223  */
224  if (fr_dhcpv6_decode(request->request_ctx, &request->request_pairs, packet->data, packet->data_len) < 0) {
225  RPEDEBUG("Failed decoding packet");
226  return -1;
227  }
228 
229  /*
230  * Set the rest of the fields.
231  */
232  request->client = UNCONST(fr_client_t *, client);
233 
234  request->packet->socket = address->socket;
235  fr_socket_addr_swap(&request->reply->socket, &address->socket);
236 
237  REQUEST_VERIFY(request);
238 
239  return 0;
240 }
241 
242 static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
243 {
244  fr_io_track_t *track = talloc_get_type_abort(request->async->packet_ctx, fr_io_track_t);
245  fr_io_address_t const *address = track->address;
247  fr_dhcpv6_packet_t *original = (fr_dhcpv6_packet_t *) request->packet->data;
248  ssize_t data_len;
249  fr_client_t const *client;
250 
251  /*
252  * Process layer NAK, never respond, or "Do not respond".
253  */
254  if ((buffer_len == 1) ||
255  (request->reply->code == FR_DHCPV6_DO_NOT_RESPOND) ||
256  (request->reply->code == 0) || (request->reply->code >= FR_DHCPV6_CODE_MAX)) {
257  track->do_not_respond = true;
258  return 1;
259  }
260 
261  client = address->radclient;
262  fr_assert(client);
263 
264  /*
265  * Dynamic client stuff
266  */
267  if (client->dynamic && !client->active) {
268  fr_client_t *new_client;
269 
270  fr_assert(buffer_len >= sizeof(client));
271 
272  /*
273  * We don't accept the new client, so don't do
274  * anything.
275  */
276  if (request->reply->code != FR_DHCPV6_REPLY) {
277  *buffer = true;
278  return 1;
279  }
280 
281  /*
282  * Allocate the client. If that fails, send back a NAK.
283  *
284  * @todo - deal with NUMA zones? Or just deal with this
285  * client being in different memory.
286  *
287  * Maybe we should create a CONF_SECTION from the client,
288  * and pass *that* back to mod_write(), which can then
289  * parse it to create the actual client....
290  */
291  new_client = client_afrom_request(NULL, request);
292  if (!new_client) {
293  PERROR("Failed creating new client");
294  buffer[0] = true;
295  return 1;
296  }
297 
298  memcpy(buffer, &new_client, sizeof(new_client));
299  return sizeof(new_client);
300  }
301 
302  if (buffer_len < 4) {
303  REDEBUG("Output buffer is too small to hold a DHCPv6 packet.");
304  return -1;
305  }
306 
307  memset(buffer, 0, buffer_len);
308  memcpy(&reply->transaction_id, &original->transaction_id, sizeof(reply->transaction_id));
309 
310  data_len = fr_dhcpv6_encode(&FR_DBUFF_TMP(buffer, buffer_len),
311  request->packet->data, request->packet->data_len,
312  request->reply->code, &request->reply_pairs);
313  if (data_len < 0) {
314  RPEDEBUG("Failed encoding DHCPv6 reply");
315  return -1;
316  }
317 
318  /*
319  * ACK the client ID.
320  */
321  if (!fr_dhcpv6_option_find(buffer + 4, buffer + data_len, attr_client_id->attr)) {
322  uint8_t const *client_id;
323 
324  client_id = fr_dhcpv6_option_find(request->packet->data + 4, request->packet->data + request->packet->data_len, attr_client_id->attr);
325  if (client_id) {
326  size_t len = fr_nbo_to_uint16(client_id + 2);
327  if (len <= (buffer_len - (data_len + 4))) {
328  memcpy(buffer + data_len, client_id, 4 + len);
329  data_len += 4 + len;
330  }
331  }
332  }
333 
334  RHEXDUMP3(buffer, data_len, "proto_dhcpv6 encode packet");
335 
336  request->reply->data_len = data_len;
337  return data_len;
338 }
339 
340 static int mod_priority_set(void const *instance, uint8_t const *buffer, UNUSED size_t buflen)
341 {
343 
344  fr_assert(buffer[0] > 0);
346 
347  /*
348  * Disallowed packet
349  */
350  if (!inst->priorities[buffer[0]]) return 0;
351 
352  if (!inst->allowed[buffer[0]]) return -1;
353 
354  /*
355  * @todo - if we cared, we could also return -1 for "this
356  * is a bad packet". But that's really only for
357  * mod_inject, as we assume that app_io->read() always
358  * returns good packets.
359  */
360 
361  /*
362  * Return the configured priority.
363  */
364  return inst->priorities[buffer[0]];
365 }
366 
367 /** Open listen sockets/connect to external event source
368  *
369  * @param[in] instance Ctx data for this application.
370  * @param[in] sc to add our file descriptor to.
371  * @param[in] conf Listen section parsed to give us instance.
372  * @return
373  * - 0 on success.
374  * - -1 on failure.
375  */
376 static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
377 {
378  proto_dhcpv6_t *inst = talloc_get_type_abort(instance, proto_dhcpv6_t);
379 
380  inst->io.app = &proto_dhcpv6;
381  inst->io.app_instance = instance;
382 
383  return fr_master_io_listen(inst, &inst->io, sc,
384  inst->max_packet_size, inst->num_messages);
385 }
386 
387 /** Instantiate the application
388  *
389  * Instantiate I/O and type submodules.
390  *
391  * @return
392  * - 0 on success.
393  * - -1 on failure.
394  */
395 static int mod_instantiate(module_inst_ctx_t const *mctx)
396 {
397  proto_dhcpv6_t *inst = talloc_get_type_abort(mctx->inst->data, proto_dhcpv6_t);
398 
399  /*
400  * No IO module, it's an empty listener.
401  */
402  if (!inst->io.submodule) return 0;
403 
404  /*
405  * These configuration items are not printed by default,
406  * because normal people shouldn't be touching them.
407  */
408  if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
409 
410  if (!inst->num_messages) inst->num_messages = 256;
411 
412  FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
413  FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
414 
415  FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
416  FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
417 
418  /*
419  * Instantiate the master io submodule
420  */
422 }
423 
424 /** Bootstrap the application
425  *
426  * Bootstrap I/O and type submodules.
427  *
428  * @return
429  * - 0 on success.
430  * - -1 on failure.
431  */
432 static int mod_bootstrap(module_inst_ctx_t const *mctx)
433 {
434  proto_dhcpv6_t *inst = talloc_get_type_abort(mctx->inst->data, proto_dhcpv6_t);
435 
436  /*
437  * Ensure that the server CONF_SECTION is always set.
438  */
439  inst->io.server_cs = cf_item_to_section(cf_parent(mctx->inst->conf));
440 
441  fr_assert(dict_dhcpv6 != NULL);
442  fr_assert(attr_packet_type != NULL);
443 
444  /*
445  * No IO module, it's an empty listener.
446  */
447  if (!inst->io.submodule) return 0;
448 
449  /*
450  * These timers are usually protocol specific.
451  */
452  FR_TIME_DELTA_BOUND_CHECK("idle_timeout", inst->io.idle_timeout, >=, fr_time_delta_from_sec(1));
453  FR_TIME_DELTA_BOUND_CHECK("idle_timeout", inst->io.idle_timeout, <=, fr_time_delta_from_sec(600));
454 
455  FR_TIME_DELTA_BOUND_CHECK("nak_lifetime", inst->io.nak_lifetime, >=, fr_time_delta_from_sec(1));
456  FR_TIME_DELTA_BOUND_CHECK("nak_lifetime", inst->io.nak_lifetime, <=, fr_time_delta_from_sec(600));
457 
458  FR_TIME_DELTA_BOUND_CHECK("cleanup_delay", inst->io.cleanup_delay, <=, fr_time_delta_from_sec(30));
459  FR_TIME_DELTA_BOUND_CHECK("cleanup_delay", inst->io.cleanup_delay, >, fr_time_delta_from_sec(0));
460 
461  /*
462  * Tell the master handler about the main protocol instance.
463  */
464  inst->io.app = &proto_dhcpv6;
465  inst->io.app_instance = inst;
466 
467  /*
468  * We will need this for dynamic clients and connected sockets.
469  */
470  inst->io.dl_inst = dl_module_instance_by_data(inst);
471  fr_assert(inst != NULL);
472 
473  /*
474  * Bootstrap the master IO handler.
475  */
477 }
478 
479 static int mod_load(void)
480 {
481  if (fr_dhcpv6_global_init() < 0) {
482  PERROR("Failed initialising protocol library");
483  return -1;
484  }
485 
486  return 0;
487 }
488 
489 static void mod_unload(void)
490 {
492 }
493 
495  .common = {
496  .magic = MODULE_MAGIC_INIT,
497  .name = "dhcpv6",
498  .config = proto_dhcpv6_config,
499  .inst_size = sizeof(proto_dhcpv6_t),
500  .onload = mod_load,
501  .unload = mod_unload,
502 
503  .bootstrap = mod_bootstrap,
505  },
506  .dict = &dict_dhcpv6,
507  .open = mod_open,
508  .decode = mod_decode,
509  .encode = mod_encode,
510  .priority = mod_priority_set
511 };
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
module_t common
Common fields provided by all modules.
Definition: application.h:72
Describes a new application (protocol)
Definition: application.h:71
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
Definition: build.h:165
#define UNUSED
Definition: build.h:313
int cf_table_parse_int(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic function for parsing conf pair values as int.
Definition: cf_parse.c:1474
#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 FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
Definition: cf_parse.h:310
#define FR_CONF_OFFSET_FLAGS(_name, _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:256
#define FR_TIME_DELTA_BOUND_CHECK(_name, _var, _op, _bound)
Definition: cf_parse.h:497
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
Definition: cf_parse.h:421
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition: cf_parse.h:400
#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
Configuration AVP similar to a fr_pair_t.
Definition: cf_priv.h:70
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:629
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:970
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
Definition: cf_util.c:1511
void * cf_data_value(CONF_DATA const *cd)
Return the user assigned value of CONF_DATA.
Definition: cf_util.c:1680
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
Definition: cf_util.c:649
#define cf_log_err(_cf, _fmt,...)
Definition: cf_util.h:265
#define cf_data_find(_cf, _type, _name)
Definition: cf_util.h:220
#define cf_parent(_cf)
Definition: cf_util.h:98
#define cf_section_alloc(_ctx, _parent, _name1, _name2)
Definition: cf_util.h:137
size_t channel_packet_priority_len
Definition: channel.c:170
fr_table_num_sorted_t const channel_packet_priority[]
Definition: channel.c:164
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
Definition: dbuff.h:509
@ FR_DHCPV6_RELEASE
Definition: dhcpv6.h:75
@ FR_DHCPV6_DECLINE
Definition: dhcpv6.h:76
@ FR_DHCPV6_DO_NOT_RESPOND
Definition: dhcpv6.h:104
@ FR_DHCPV6_REBIND
Definition: dhcpv6.h:73
@ FR_DHCPV6_REPLY
Definition: dhcpv6.h:74
@ FR_DHCPV6_SOLICIT
Definition: dhcpv6.h:68
@ FR_DHCPV6_RENEW
Definition: dhcpv6.h:72
@ FR_DHCPV6_INFORMATION_REQUEST
Definition: dhcpv6.h:78
@ FR_DHCPV6_REQUEST
Definition: dhcpv6.h:70
@ FR_DHCPV6_CODE_MAX
Definition: dhcpv6.h:103
@ FR_DHCPV6_RELAY_FORWARD
Definition: dhcpv6.h:79
uint8_t transaction_id[3]
Definition: dhcpv6.h:124
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
fr_value_box_t const * value
Enum value (what name maps to).
Definition: dict.h:213
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:2992
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
Value of an enumerated attribute.
Definition: dict.h:209
Test enumeration values.
Definition: dict_test.h:92
int dl_module_instance(TALLOC_CTX *ctx, dl_module_inst_t **out, dl_module_inst_t const *parent, dl_module_type_t type, char const *mod_name, char const *inst_name)
Load a module and parse its CONF_SECTION in one operation.
Definition: dl_module.c:552
char const * dl_module_inst_name_from_conf(CONF_SECTION *conf)
Avoid boilerplate when setting the module instance name.
Definition: dl_module.c:584
dl_module_inst_t const * dl_module_instance_by_data(void const *data)
Lookup a dl_module_inst_t via instance data.
Definition: dl_module.c:215
int dl_module_conf_parse(dl_module_inst_t *dl_inst, CONF_SECTION *conf)
Definition: dl_module.c:594
@ DL_MODULE_TYPE_SUBMODULE
Driver (or method in the case of EAP)
Definition: dl_module.h:71
void *_CONST data
Module instance's parsed configuration.
Definition: dl_module.h:165
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:65
CONF_SECTION *_CONST conf
Module's instance configuration.
Definition: dl_module.h:166
A module/inst tuple.
Definition: dl_module.h:162
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
Describes a host allowed to send packets to the server.
Definition: client.h:77
#define PERROR(_fmt,...)
Definition: log.h:228
#define RPEDEBUG(fmt,...)
Definition: log.h:376
#define RHEXDUMP3(_data, _len, _fmt,...)
Definition: log.h:705
talloc_free(reap)
fr_app_io_t fr_master_app_io
Definition: master.c:3131
int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *inst, fr_schedule_t *sc, size_t default_message_size, size_t num_messages)
Definition: master.c:2923
fr_io_address_t const * address
of this packet.. shared between multiple packets
Definition: master.h:54
bool do_not_respond
don't respond
Definition: master.h:50
@ 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
long int ssize_t
Definition: merged_model.c:24
unsigned char uint8_t
Definition: merged_model.c:30
#define MODULE_INST_CTX(_dl_inst)
Wrapper to create a module_inst_ctx_t as a compound literal.
Definition: module_ctx.h:153
dl_module_inst_t const * inst
Dynamic loader API handle for the module.
Definition: module_ctx.h:52
Temporary structure to hold arguments for instantiation calls.
Definition: module_ctx.h:51
static uint16_t fr_nbo_to_uint16(uint8_t const data[static sizeof(uint16_t)])
Read an unsigned 16bit integer from wire format (big endian)
Definition: nbo.h:137
static int mod_load(void)
Definition: proto_dhcpv6.c:479
static fr_dict_attr_t const * attr_packet_type
Definition: proto_dhcpv6.c:94
static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
Definition: proto_dhcpv6.c:242
static conf_parser_t const limit_config[]
Definition: proto_dhcpv6.c:55
static int type_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
fr_app_t proto_dhcpv6
Definition: proto_dhcpv6.c:494
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Bootstrap the application.
Definition: proto_dhcpv6.c:432
static void mod_unload(void)
Definition: proto_dhcpv6.c:489
fr_dict_attr_autoload_t proto_dhcpv6_dict_attr[]
Definition: proto_dhcpv6.c:98
static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Decode the packet.
Definition: proto_dhcpv6.c:191
static fr_dict_t const * dict_dhcpv6
Definition: proto_dhcpv6.c:86
static const conf_parser_t priority_config[]
Definition: proto_dhcpv6.c:35
static conf_parser_t const proto_dhcpv6_config[]
How to parse a DHCPV6 listen section.
Definition: proto_dhcpv6.c:77
static fr_dict_attr_t const * attr_client_id
Definition: proto_dhcpv6.c:95
fr_dict_autoload_t proto_dhcpv6_dict[]
Definition: proto_dhcpv6.c:89
static int mod_instantiate(module_inst_ctx_t const *mctx)
Instantiate the application.
Definition: proto_dhcpv6.c:395
static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
Open listen sockets/connect to external event source.
Definition: proto_dhcpv6.c:376
static int mod_priority_set(void const *instance, uint8_t const *buffer, UNUSED size_t buflen)
Definition: proto_dhcpv6.c:340
static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
An instance of a proto_dhcpv6 listen section.
Definition: proto_dhcpv6.h:32
uint8_t const * fr_dhcpv6_option_find(uint8_t const *start, uint8_t const *end, unsigned int option)
Definition: base.c:243
void fr_dhcpv6_global_free(void)
Definition: base.c:938
int fr_dhcpv6_global_init(void)
Definition: base.c:896
ssize_t fr_dhcpv6_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *packet, size_t packet_len)
Decode a DHCPv6 packet.
Definition: base.c:578
ssize_t fr_dhcpv6_encode(fr_dbuff_t *dbuff, uint8_t const *original, size_t length, int msg_type, fr_pair_list_t *vps)
Encode a DHCPv6 packet.
Definition: base.c:717
#define REDEBUG(fmt,...)
Definition: radclient.h:52
static rs_t * conf
Definition: radsniff.c:53
#define REQUEST_VERIFY(_x)
Definition: request.h:275
static char const * name
static int instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_rest.c:1312
The scheduler.
Definition: schedule.c:125
module_instantiate_t instantiate
Definition: module.h:146
module_instantiate_t bootstrap
Definition: module.h:145
static const uchar sc[16]
Definition: smbdes.c:115
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:915
if(!subtype_vp) goto fail
fr_assert(0)
eap_aka_sim_process_conf_t * inst
#define talloc_get_type_abort_const
Definition: talloc.h:270
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
Definition: time.h:588
uint8_t * data
Packet data (body).
Definition: packet.h:63
size_t data_len
Length of packet data.
Definition: packet.h:64
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