The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
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: 09214ca8968605a8f8c2fba798e5bcd1f57bc766 $
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 <freeradius-devel/protocol/dhcpv6/freeradius.internal.h>
30#include "proto_dhcpv6.h"
31
33static int type_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
34static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
35
37 { FR_CONF_OFFSET("Solicit", proto_dhcpv6_t, priorities[FR_DHCPV6_SOLICIT]),
38 .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
39 { FR_CONF_OFFSET("Request", proto_dhcpv6_t, priorities[FR_DHCPV6_REQUEST]),
40 .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
41 { FR_CONF_OFFSET("Renew", proto_dhcpv6_t, priorities[FR_DHCPV6_RENEW]),
42 .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
43 { FR_CONF_OFFSET("Rebind", proto_dhcpv6_t, priorities[FR_DHCPV6_REBIND]),
44 .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
45 { FR_CONF_OFFSET("Release", proto_dhcpv6_t, priorities[FR_DHCPV6_RELEASE]),
46 .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
47 { FR_CONF_OFFSET("Decline", proto_dhcpv6_t, priorities[FR_DHCPV6_DECLINE]),
48 .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
49 { FR_CONF_OFFSET("Information-Request", proto_dhcpv6_t, priorities[FR_DHCPV6_INFORMATION_REQUEST]),
50 .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
51 { FR_CONF_OFFSET("Relay-Forward", proto_dhcpv6_t, priorities[FR_DHCPV6_RELAY_FORWARD]),
52 .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
54};
55
56static conf_parser_t const limit_config[] = {
57 { FR_CONF_OFFSET("cleanup_delay", proto_dhcpv6_t, io.cleanup_delay), .dflt = "5.0" } ,
58 { FR_CONF_OFFSET("idle_timeout", proto_dhcpv6_t, io.idle_timeout), .dflt = "30.0" } ,
59 { FR_CONF_OFFSET("dynamic_timeout", proto_dhcpv6_t, io.dynamic_timeout), .dflt = "600.0" } ,
60 { FR_CONF_OFFSET("nak_lifetime", proto_dhcpv6_t, io.nak_lifetime), .dflt = "30.0" } ,
61
62 { FR_CONF_OFFSET("max_connections", proto_dhcpv6_t, io.max_connections), .dflt = "1024" } ,
63 { FR_CONF_OFFSET("max_clients", proto_dhcpv6_t, io.max_clients), .dflt = "256" } ,
64 { FR_CONF_OFFSET("max_pending_packets", proto_dhcpv6_t, io.max_pending_packets), .dflt = "256" } ,
65
66 /*
67 * For performance tweaking. NOT for normal humans.
68 */
69 { FR_CONF_OFFSET("max_packet_size", proto_dhcpv6_t, max_packet_size) } ,
70 { FR_CONF_OFFSET("num_messages", proto_dhcpv6_t, num_messages) } ,
71 { FR_CONF_POINTER("priority", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) priority_config },
72
74};
75
76static conf_parser_t const log_config[] = {
77 { FR_CONF_OFFSET("ignored_clients", proto_dhcpv6_t, io.log_ignored_clients), .dflt = "yes" } ,
78
80};
81
82/** How to parse a DHCPV6 listen section
83 *
84 */
87 { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_dhcpv6_t, io.submodule),
88 .func = transport_parse },
89
90 { FR_CONF_OFFSET("server-id", proto_dhcpv6_t, server_id_str), },
91
92 { FR_CONF_POINTER("log", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) log_config },
93 { FR_CONF_POINTER("limit", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) limit_config },
94
95
97};
98
99static fr_dict_t const *dict_dhcpv6;
100
103 { .out = &dict_dhcpv6, .proto = "dhcpv6" },
105};
106
110
113 { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_dhcpv6},
114 { .out = &attr_client_id, .name = "Client-Id", .type = FR_TYPE_STRUCT, .dict = &dict_dhcpv6},
115 { .out = &attr_server_id, .name = "Server-Id", .type = FR_TYPE_STRUCT, .dict = &dict_dhcpv6},
117};
118
119/** Translates the packet-type into a submodule name
120 *
121 * @param[in] ctx to allocate data in (instance of proto_dhcpv6).
122 * @param[out] out Where to write a module_instance_t containing the module handle and instance.
123 * @param[in] parent Base structure address.
124 * @param[in] ci #CONF_PAIR specifying the name of the type module.
125 * @param[in] rule unused.
126 * @return
127 * - 0 on success.
128 * - -1 on failure.
129 */
130static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent,
131 CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
132{
133 proto_dhcpv6_t *inst = talloc_get_type_abort(parent, proto_dhcpv6_t);
134 fr_dict_enum_value_t const *dv;
135 CONF_PAIR *cp;
136 char const *value;
137
138 cp = cf_item_to_pair(ci);
139 value = cf_pair_value(cp);
140
142 if (!dv || (dv->value->vb_uint32 >= FR_DHCPV6_CODE_MAX)) {
143 cf_log_err(ci, "Unknown DHCPv6 packet type '%s'", value);
144 return -1;
145 }
146
147 inst->allowed[dv->value->vb_uint32] = true;
148 *((char const **) out) = value;
149
150 return 0;
151}
152
153static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
154{
155 proto_dhcpv6_t *inst = talloc_get_type_abort(parent, proto_dhcpv6_t);
157
158 if (unlikely(virtual_server_listen_transport_parse(ctx, out, parent, ci, rule) < 0)) {
159 return -1;
160 }
161
162 mi = talloc_get_type_abort(*(void **)out, module_instance_t);
163 inst->io.app_io = (fr_app_io_t const *)mi->exported;
164 inst->io.app_io_instance = mi->data;
165 inst->io.app_io_conf = mi->conf;
166
167 return 0;
168}
169
170/** Decode the packet
171 *
172 */
173static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
174{
175 fr_io_track_t const *track = talloc_get_type_abort_const(request->async->packet_ctx, fr_io_track_t);
176 fr_io_address_t const *address = track->address;
177 fr_client_t const *client;
178 fr_packet_t *packet = request->packet;
179
180 RHEXDUMP3(data, data_len, "proto_dhcpv6 decode packet");
181
182 client = address->radclient;
183
184 /*
185 * Hacks for now until we have a lower-level decode routine.
186 */
187 request->packet->code = data[0];
188 request->packet->id = (data[1] << 16) | (data[2] << 8) | data[3];
189 request->reply->id = request->packet->id;
190
191 request->packet->data = talloc_memdup(request->packet, data, data_len);
192 request->packet->data_len = data_len;
193
194 /*
195 * Note that we don't set a limit on max_attributes here.
196 * That MUST be set and checked in the underlying
197 * transport, via a call to fr_dhcpv6_ok().
198 */
199 if (fr_dhcpv6_decode(request->request_ctx, &request->request_pairs, packet->data, packet->data_len) < 0) {
200 RPEDEBUG("Failed decoding packet");
201 return -1;
202 }
203
204 /*
205 * Set the rest of the fields.
206 */
207 request->client = UNCONST(fr_client_t *, client);
208
209 request->packet->socket = address->socket;
210 fr_socket_addr_swap(&request->reply->socket, &address->socket);
211
212 if (fr_packet_pairs_from_packet(request->request_ctx, &request->request_pairs, request->packet) < 0) {
213 RPEDEBUG("Failed decoding 'Net.*' packet");
214 return -1;
215 }
216
217 REQUEST_VERIFY(request);
218
219 return 0;
220}
221
222static ssize_t mod_encode(void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
223{
225 fr_io_track_t *track = talloc_get_type_abort(request->async->packet_ctx, fr_io_track_t);
226 fr_io_address_t const *address = track->address;
228 fr_dhcpv6_packet_t *original = (fr_dhcpv6_packet_t *) request->packet->data;
229 ssize_t data_len;
230 fr_client_t const *client;
231
232 /*
233 * Process layer NAK, never respond, or "Do not respond".
234 */
235 if ((buffer_len == 1) ||
236 (request->reply->code == FR_DHCPV6_DO_NOT_RESPOND) ||
237 (request->reply->code == 0) || (request->reply->code >= FR_DHCPV6_CODE_MAX)) {
238 track->do_not_respond = true;
239 return 1;
240 }
241
242 client = address->radclient;
243 fr_assert(client);
244
245 /*
246 * Dynamic client stuff
247 */
248 if (client->dynamic && !client->active) {
249 fr_client_t *new_client;
250
251 fr_assert(buffer_len >= sizeof(client));
252
253 /*
254 * We don't accept the new client, so don't do
255 * anything.
256 */
257 if (request->reply->code != FR_DHCPV6_REPLY) {
258 *buffer = true;
259 return 1;
260 }
261
262 /*
263 * Allocate the client. If that fails, send back a NAK.
264 *
265 * @todo - deal with NUMA zones? Or just deal with this
266 * client being in different memory.
267 *
268 * Maybe we should create a CONF_SECTION from the client,
269 * and pass *that* back to mod_write(), which can then
270 * parse it to create the actual client....
271 */
272 new_client = client_afrom_request(NULL, request);
273 if (!new_client) {
274 PERROR("Failed creating new client");
275 buffer[0] = true;
276 return 1;
277 }
278
279 memcpy(buffer, &new_client, sizeof(new_client));
280 return sizeof(new_client);
281 }
282
283 if (buffer_len < 4) {
284 REDEBUG("Output buffer is too small to hold a DHCPv6 packet.");
285 return -1;
286 }
287
288 /*
289 * If there's a servcer ID, then add it to responses where it's needed.
290 */
291 if (inst->server_id_pair) {
292 fr_pair_t *vp, *copy;
293
294 /*
295 * If the admin added it manually, then we assume that the admin knows what they're
296 * doing, and added it manually. The DHCPv6 "process" routines save / restore any
297 * existing Server-ID options. But in some cases, the request doesn't have a Server-ID,
298 * but it still has to go into Reply and Advertise. So we need to double-check those
299 * here.
300 */
301 vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_server_id);
302 if (vp) {
303 MEM(copy = fr_pair_copy(&request->reply_ctx, vp));
304 (void) fr_pair_append(&request->reply_pairs, copy);
305 }
306 }
307
308 memset(buffer, 0, buffer_len);
309 memcpy(&reply->transaction_id, &original->transaction_id, sizeof(reply->transaction_id));
310
311 data_len = fr_dhcpv6_encode(&FR_DBUFF_TMP(buffer, buffer_len),
312 request->packet->data, request->packet->data_len,
313 request->reply->code, &request->reply_pairs);
314 if (data_len < 0) {
315 RPEDEBUG("Failed encoding DHCPv6 reply");
316 return -1;
317 }
318
319 /*
320 * ACK the client ID.
321 */
322 if (!fr_dhcpv6_option_find(buffer + 4, buffer + data_len, attr_client_id->attr)) {
323 uint8_t const *client_id;
324
325 client_id = fr_dhcpv6_option_find(request->packet->data + 4, request->packet->data + request->packet->data_len, attr_client_id->attr);
326 if (client_id) {
327 size_t len = fr_nbo_to_uint16(client_id + 2);
328 if (len <= (buffer_len - (data_len + 4))) {
329 memcpy(buffer + data_len, client_id, 4 + len);
330 data_len += 4 + len;
331 }
332 }
333 }
334
335 RHEXDUMP3(buffer, data_len, "proto_dhcpv6 encode packet");
336
337 request->reply->data_len = data_len;
338 return data_len;
339}
340
341static int mod_priority_set(void const *instance, uint8_t const *buffer, UNUSED size_t buflen)
342{
344
345 fr_assert(buffer[0] > 0);
347
348 /*
349 * Disallowed packet
350 */
351 if (!inst->priorities[buffer[0]]) return 0;
352
353 if (!inst->allowed[buffer[0]]) return -1;
354
355 /*
356 * @todo - if we cared, we could also return -1 for "this
357 * is a bad packet". But that's really only for
358 * mod_inject, as we assume that app_io->read() always
359 * returns good packets.
360 */
361
362 /*
363 * Return the configured priority.
364 */
365 return inst->priorities[buffer[0]];
366}
367
368/** Open listen sockets/connect to external event source
369 *
370 * @param[in] instance Ctx data for this application.
371 * @param[in] sc to add our file descriptor to.
372 * @param[in] conf Listen section parsed to give us instance.
373 * @return
374 * - 0 on success.
375 * - -1 on failure.
376 */
377static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
378{
379 proto_dhcpv6_t *inst = talloc_get_type_abort(instance, proto_dhcpv6_t);
380
381 inst->io.app = &proto_dhcpv6;
382 inst->io.app_instance = instance;
383
384 return fr_master_io_listen(&inst->io, sc,
385 inst->max_packet_size, inst->num_messages);
386}
387
388/** Instantiate the application
389 *
390 * Instantiate I/O and type submodules.
391 *
392 * @return
393 * - 0 on success.
394 * - -1 on failure.
395 */
396static int mod_instantiate(module_inst_ctx_t const *mctx)
397{
398 proto_dhcpv6_t *inst = talloc_get_type_abort(mctx->mi->data, proto_dhcpv6_t);
399
400 /*
401 * Ensure that the server CONF_SECTION is always set.
402 */
403 inst->io.server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
404
405 fr_assert(dict_dhcpv6 != NULL);
407
408 /*
409 * No IO module, it's an empty listener.
410 */
411 if (!inst->io.submodule) return 0;
412
413 /*
414 * These timers are usually protocol specific.
415 */
416 FR_TIME_DELTA_BOUND_CHECK("idle_timeout", inst->io.idle_timeout, >=, fr_time_delta_from_sec(1));
417 FR_TIME_DELTA_BOUND_CHECK("idle_timeout", inst->io.idle_timeout, <=, fr_time_delta_from_sec(600));
418
419 FR_TIME_DELTA_BOUND_CHECK("nak_lifetime", inst->io.nak_lifetime, >=, fr_time_delta_from_sec(1));
420 FR_TIME_DELTA_BOUND_CHECK("nak_lifetime", inst->io.nak_lifetime, <=, fr_time_delta_from_sec(600));
421
422 FR_TIME_DELTA_BOUND_CHECK("cleanup_delay", inst->io.cleanup_delay, <=, fr_time_delta_from_sec(30));
423 FR_TIME_DELTA_BOUND_CHECK("cleanup_delay", inst->io.cleanup_delay, >, fr_time_delta_from_sec(0));
424
425 /*
426 * Tell the master handler about the main protocol instance.
427 */
428 inst->io.app = &proto_dhcpv6;
429 inst->io.app_instance = inst;
430
431 /*
432 * We will need this for dynamic clients and connected sockets.
433 */
434 inst->io.mi = mctx->mi;
435
436 /*
437 * These configuration items are not printed by default,
438 * because normal people shouldn't be touching them.
439 */
440 if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
441
442 if (!inst->num_messages) inst->num_messages = 256;
443
444 FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
445 FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
446
447 FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
448 FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
449
450 /*
451 * Parse the server-id configuration item.
452 */
453 if (inst->server_id_str) {
454 fr_pair_t *vp;
455 ssize_t slen;
456 fr_pair_parse_t root, relative;
457 fr_dcursor_t cursor;
458 uint8_t buffer[256];
459
461
462 root = (fr_pair_parse_t) {
463 .ctx = inst,
464 .da = attr_server_id,
465 .list = &vp->vp_group,
466 .dict = dict_dhcpv6,
467 .internal = fr_dict_internal(),
468 .allow_compare = false,
469 .allow_exec = false
470 };
471 relative = (fr_pair_parse_t) { };
472
473 slen = fr_pair_list_afrom_substr(&root, &relative, &FR_SBUFF_IN(inst->server_id_str, strlen(inst->server_id_str)));
474 if (slen <= 0) {
475 cf_log_perr(mctx->mi->conf, "Failed parsing 'server-id' configuration");
476 return -1;
477 }
478
479 inst->server_id_pair = vp;
480
482
483 slen = fr_dhcpv6_encode_option(&FR_DBUFF_TMP(buffer, sizeof(buffer)), &cursor,
485 if (slen < 0) {
486 cf_log_perr(mctx->mi->conf, "Failed encoding 'server-id' option");
487 return -1;
488 }
489
490 MEM(inst->server_id = talloc_memdup(inst, buffer, slen));
491 }
492
493 /*
494 * Instantiate the transport module before calling the
495 * common instantiation function.
496 */
497 if (module_instantiate(inst->io.submodule) < 0) return -1;
498
499 /*
500 * Instantiate the master io submodule
501 */
503}
504
505static int mod_load(void)
506{
507 if (fr_dhcpv6_global_init() < 0) {
508 PERROR("Failed initialising protocol library");
509 return -1;
510 }
511
512 return 0;
513}
514
515static void mod_unload(void)
516{
518}
519
521 .common = {
522 .magic = MODULE_MAGIC_INIT,
523 .name = "dhcpv6",
525 .inst_size = sizeof(proto_dhcpv6_t),
526 .onload = mod_load,
527 .unload = mod_unload,
528
529 .instantiate = mod_instantiate
530 },
531 .dict = &dict_dhcpv6,
532 .open = mod_open,
533 .decode = mod_decode,
534 .encode = mod_encode,
535 .priority = mod_priority_set
536};
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
#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
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:1724
#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 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:334
#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:268
#define FR_TIME_DELTA_BOUND_CHECK(_name, _var, _op, _bound)
Definition cf_parse.h:540
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
Definition cf_parse.h:447
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition cf_parse.h:423
#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
Configuration AVP similar to a fr_pair_t.
Definition cf_priv.h:77
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:106
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
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_parent(_cf)
Definition cf_util.h:118
#define cf_log_perr(_cf, _fmt,...)
Definition cf_util.h:352
size_t channel_packet_priority_len
Definition channel.c:168
fr_table_num_sorted_t const channel_packet_priority[]
Definition channel.c:162
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
Definition dbuff.h:522
#define MEM(x)
Definition debug.h:36
@ 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
ssize_t fr_dhcpv6_encode_option(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, void *encode_ctx)
Encode a DHCPv6 option and any sub-options.
Definition encode.c:679
uint8_t transaction_id[3]
Definition dhcpv6.h:116
subtype values for DHCPv4 and DHCPv6
Definition dhcpv6.h:114
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
Definition dict_util.c:2639
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
fr_value_box_t const * value
Enum value (what name maps to).
Definition dict.h:257
fr_dict_t const * fr_dict_internal(void)
Definition dict_util.c:4905
#define DICT_AUTOLOAD_TERMINATOR
Definition dict.h:311
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:3678
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
Value of an enumerated attribute.
Definition dict.h:253
Test enumeration values.
Definition dict_test.h:92
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.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
bool active
for dynamic clients
Definition client.h:120
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
#define RHEXDUMP3(_data, _len, _fmt,...)
Definition log.h:717
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
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
bool do_not_respond
don't respond
Definition master.h:51
@ 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.
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 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:146
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_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:290
fr_pair_t * fr_pair_copy(TALLOC_CTX *ctx, fr_pair_t const *vp)
Copy a single valuepair.
Definition pair.c:503
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 int mod_load(void)
static fr_dict_attr_t const * attr_packet_type
static conf_parser_t const limit_config[]
static int type_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
fr_app_t proto_dhcpv6
static fr_dict_attr_t const * attr_server_id
static conf_parser_t const log_config[]
static ssize_t mod_encode(void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
static void mod_unload(void)
fr_dict_attr_autoload_t proto_dhcpv6_dict_attr[]
static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Decode the packet.
static fr_dict_t const * dict_dhcpv6
static const conf_parser_t priority_config[]
static conf_parser_t const proto_dhcpv6_config[]
How to parse a DHCPV6 listen section.
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_client_id
fr_dict_autoload_t proto_dhcpv6_dict[]
static int mod_instantiate(module_inst_ctx_t const *mctx)
Instantiate the application.
static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
Open listen sockets/connect to external event source.
static int mod_priority_set(void const *instance, uint8_t const *buffer, UNUSED size_t buflen)
An instance of a proto_dhcpv6 listen section.
void * fr_dhcpv6_next_encodable(fr_dcursor_t *cursor, void *current, void *uctx)
DHCPV6-specific iterator.
Definition base.c:759
void fr_dhcpv6_global_free(void)
Definition base.c:981
uint8_t const * fr_dhcpv6_option_find(uint8_t const *start, uint8_t const *end, unsigned int option)
Definition base.c:253
int fr_dhcpv6_global_init(void)
Definition base.c:957
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:636
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:778
#define fr_assert(_expr)
Definition rad_assert.h:37
#define REDEBUG(fmt,...)
static rs_t * conf
Definition radsniff.c:52
#define REQUEST_VERIFY(_x)
Definition request.h:311
#define FR_SBUFF_IN(_start, _len_or_end)
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_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 talloc_get_type_abort_const
Definition talloc.h:117
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
Definition time.h:590
uint8_t * data
Packet data (body).
Definition packet.h:63
size_t data_len
Length of packet data.
Definition packet.h:64
#define fr_pair_dcursor_iter_init(_cursor, _list, _iter, _uctx)
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.
Definition pair.h:584
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.