The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
proto_radius.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: 004bbdd0dc676d5e7612e24f998acbc87c154534 $
19 * @file proto_radius.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/radius/radius.h>
26#include <freeradius-devel/io/listen.h>
27#include <freeradius-devel/unlang/xlat_func.h>
28#include <freeradius-devel/server/module_rlm.h>
29#include "proto_radius.h"
30
32
33static int type_parse(TALLOC_CTX *ctx, void *out, UNUSED 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
36static conf_parser_t const limit_config[] = {
37 { FR_CONF_OFFSET("cleanup_delay", proto_radius_t, io.cleanup_delay), .dflt = "5.0" } ,
38 { FR_CONF_OFFSET("idle_timeout", proto_radius_t, io.idle_timeout), .dflt = "30.0" } ,
39 { FR_CONF_OFFSET("dynamic_timeout", proto_radius_t, io.dynamic_timeout), .dflt = "600.0" } ,
40 { FR_CONF_OFFSET("nak_lifetime", proto_radius_t, io.nak_lifetime), .dflt = "30.0" } ,
41
42 { FR_CONF_OFFSET("max_connections", proto_radius_t, io.max_connections), .dflt = "1024" } ,
43 { FR_CONF_OFFSET("max_clients", proto_radius_t, io.max_clients), .dflt = "256" } ,
44 { FR_CONF_OFFSET("max_pending_packets", proto_radius_t, io.max_pending_packets), .dflt = "256" } ,
45
46 /*
47 * For performance tweaking. NOT for normal humans.
48 */
49 { FR_CONF_OFFSET("max_packet_size", proto_radius_t, max_packet_size) } ,
50 { FR_CONF_OFFSET("num_messages", proto_radius_t, num_messages) } ,
51
53};
54
56 { FR_CONF_OFFSET("Access-Request", proto_radius_t, priorities[FR_RADIUS_CODE_ACCESS_REQUEST]),
57 .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "high" },
58 { FR_CONF_OFFSET("Accounting-Request", proto_radius_t, priorities[FR_RADIUS_CODE_ACCOUNTING_REQUEST]),
59 .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "low" },
60 { FR_CONF_OFFSET("CoA-Request", proto_radius_t, priorities[FR_RADIUS_CODE_COA_REQUEST]),
61 .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
62 { FR_CONF_OFFSET("Disconnect-Request", proto_radius_t, priorities[FR_RADIUS_CODE_DISCONNECT_REQUEST]),
63 .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "low" },
64 { FR_CONF_OFFSET("Status-Server", proto_radius_t, priorities[FR_RADIUS_CODE_STATUS_SERVER]),
65 .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "now" },
66
68};
69
70static conf_parser_t const log_config[] = {
71 { FR_CONF_OFFSET("ignored_clients", proto_radius_t, io.log_ignored_clients), .dflt = "yes" } ,
72
74};
75
76/** How to parse a RADIUS listen section
77 *
78 */
81 { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_radius_t, io.submodule),
82 .func = transport_parse },
83
84 /*
85 * Check whether or not the *trailing* bits of a
86 * Tunnel-Password are zero, as they should be.
87 */
88 { FR_CONF_OFFSET("tunnel_password_zeros", proto_radius_t, tunnel_password_zeros) } ,
89
90 { FR_CONF_POINTER("limit", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) limit_config },
91 { FR_CONF_POINTER("priority", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) priority_config },
92
93 { FR_CONF_POINTER("log", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) log_config },
94
95 { FR_CONF_OFFSET("require_message_authenticator", proto_radius_t, require_message_authenticator),
98 .dflt = "no" },
99
100 { FR_CONF_OFFSET("limit_proxy_state", proto_radius_t, limit_proxy_state),
101 .func = cf_table_parse_int,
103 .dflt = "auto" },
104
106};
107
108static fr_dict_t const *dict_radius;
109
112 { .out = &dict_radius, .proto = "radius" },
114};
115
125
128 { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius},
129 { .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius},
130 { .out = &attr_state, .name = "State", .type = FR_TYPE_OCTETS, .dict = &dict_radius},
131 { .out = &attr_proxy_state, .name = "Proxy-State", .type = FR_TYPE_OCTETS, .dict = &dict_radius},
132 { .out = &attr_message_authenticator, .name = "Message-Authenticator", .type = FR_TYPE_OCTETS, .dict = &dict_radius},
133 { .out = &attr_eap_message, .name = "EAP-Message", .type = FR_TYPE_OCTETS, .dict = &dict_radius},
134 { .out = &attr_error_cause, .name = "Error-Cause", .type = FR_TYPE_UINT32, .dict = &dict_radius},
135 { .out = &attr_packet_id, .name = "Packet.Id", .type = FR_TYPE_UINT8, .dict = &dict_radius},
136 { .out = &attr_packet_authenticator, .name = "Packet.Authenticator", .type = FR_TYPE_OCTETS, .dict = &dict_radius},
138};
139
140/** Translates the packet-type into a submodule name
141 *
142 * If we found a Packet-Type = Access-Request CONF_PAIR for example, here's we'd load
143 * the proto_radius_auth module.
144 *
145 * @param[in] ctx to allocate data in (instance of proto_radius).
146 * @param[out] out Where to write a module_instance_t containing the module handle and instance.
147 * @param[in] parent Base structure address.
148 * @param[in] ci #CONF_PAIR specifying the name of the type module.
149 * @param[in] rule unused.
150 * @return
151 * - 0 on success.
152 * - -1 on failure.
153 */
154static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
155{
156 proto_radius_t *inst = talloc_get_type_abort(parent, proto_radius_t);
157 fr_dict_enum_value_t const *dv;
158 CONF_PAIR *cp;
159 char const *value;
160
161 cp = cf_item_to_pair(ci);
162 value = cf_pair_value(cp);
163
165 if (!dv || (dv->value->vb_uint32 >= FR_RADIUS_CODE_MAX)) {
166 cf_log_err(ci, "Unknown RADIUS packet type '%s'", value);
167 return -1;
168 }
169
170 inst->allowed[dv->value->vb_uint32] = true;
171 *((char const **) out) = value;
172
173 return 0;
174}
175
176static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
177{
178 proto_radius_t *inst = talloc_get_type_abort(parent, proto_radius_t);
180
181 if (unlikely(virtual_server_listen_transport_parse(ctx, out, parent, ci, rule) < 0)) {
182 return -1;
183 }
184
185 mi = talloc_get_type_abort(*(void **)out, module_instance_t);
186 inst->io.app_io = (fr_app_io_t const *)mi->exported;
187 inst->io.app_io_instance = mi->data;
188 inst->io.app_io_conf = mi->conf;
189
190 return 0;
191}
192
193static char const *url[FR_RADIUS_FAIL_MAX + 1] = {
194 [FR_RADIUS_FAIL_NONE] = "index",
195 [FR_RADIUS_FAIL_MIN_LENGTH_PACKET] = "packet_too_small",
196 [FR_RADIUS_FAIL_MAX_LENGTH_PACKET] = "packet_too_large",
197 [FR_RADIUS_FAIL_MIN_LENGTH_FIELD] = "mismatched_length",
198 [FR_RADIUS_FAIL_MIN_LENGTH_MISMATCH] = "mismatched_length",
199 [FR_RADIUS_FAIL_UNKNOWN_PACKET_CODE] = "unknown_packet_code",
200 [FR_RADIUS_FAIL_UNEXPECTED_REQUEST_CODE] = "unexpected_request_code",
201 [FR_RADIUS_FAIL_UNEXPECTED_RESPONSE_CODE] = "unexpected_response_code",
202 [FR_RADIUS_FAIL_TOO_MANY_ATTRIBUTES] = "too_many_attributes",
203
204 [FR_RADIUS_FAIL_INVALID_ATTRIBUTE] = "attribute_0",
205
206 [FR_RADIUS_FAIL_HEADER_OVERFLOW] = "attribute_header",
207 [FR_RADIUS_FAIL_ATTRIBUTE_TOO_SHORT] = "attribute_invalid_length",
208 [FR_RADIUS_FAIL_ATTRIBUTE_OVERFLOW] = "attribute_overflow",
209 [FR_RADIUS_FAIL_ATTRIBUTE_DECODE] = "decode_failure",
210
211 [FR_RADIUS_FAIL_MA_INVALID_LENGTH] = "message_authenticator_length",
212 [FR_RADIUS_FAIL_MA_MISSING] = "message_authenticator_missing",
213 [FR_RADIUS_FAIL_MA_INVALID] = "message_authenticator_invalid",
214 [FR_RADIUS_FAIL_MA_TOO_MANY] = "message_authenticator_too_many",
215 [FR_RADIUS_FAIL_PROXY_STATE_MISSING_MA] = "proxy_state_missing_ma",
216
217 [FR_RADIUS_FAIL_VERIFY] = "packet_fails_verification",
218 [FR_RADIUS_FAIL_NO_MATCHING_REQUEST] = "no_matching_request",
219 [FR_RADIUS_FAIL_IO_ERROR] = "io_error",
220 [FR_RADIUS_FAIL_MAX] = "index",
221};
222
223DIAG_OFF(format-nonliteral)
224/** Log a message in a canonical format.
225 *
226 * 'fmt' is from our source code, so we don't care about format literals.
227 */
229 fr_socket_t const *sock, char const *fmt, ...)
230{
231 va_list ap;
232 char const *msg;
233 char *to_free = NULL;
234
235 if (!DEBUG_ENABLED2) return;
236
237 va_start(ap, fmt);
238 if (*fmt) {
239 msg = to_free = talloc_vasprintf(NULL, fmt, ap);
240 } else {
241 msg = "";
242 }
243 va_end(ap);
244
245 fr_assert(reason <= FR_RADIUS_FAIL_MAX);
246
247 if (sock) {
248 EDEBUG2("proto_radius - discarding packet on socket %s from client %pV port %u - %s (%s)",
249 li->name,
250 fr_box_ipaddr(sock->inet.src_ipaddr), sock->inet.src_port,
251 msg,
253 } else {
254 EDEBUG2("proto_radius - discarding packet on socket %s - %s (%s)",
255 li->name, msg, fr_radius_decode_fail_reason[reason]);
256 }
257
258 EDEBUG2("For more information, please see " DOC_ROOT_URL "/troubleshooting/network/%s.html", url[reason]);
259
260 talloc_free(to_free);
261}
262DIAG_ON(format-nonliteral)
263
264/** Decode the packet
265 *
266 */
267static int mod_decode(void const *instance, request_t *request, uint8_t *const data, size_t data_len)
268{
270 fr_io_track_t const *track = talloc_get_type_abort_const(request->async->packet_ctx, fr_io_track_t);
271 fr_io_address_t const *address = track->address;
272 fr_client_t *client = UNCONST(fr_client_t *, address->radclient);
273 fr_radius_ctx_t common_ctx;
274 fr_radius_decode_ctx_t decode_ctx;
275
276 fr_radius_require_ma_t require_message_authenticator = client->require_message_authenticator_is_set ?
278 inst->require_message_authenticator;
279 fr_radius_limit_proxy_state_t limit_proxy_state = client->limit_proxy_state_is_set ?
280 client->limit_proxy_state:
281 inst->limit_proxy_state;
282 fr_pair_t *packet_vp;
283
285
286 common_ctx = (fr_radius_ctx_t) {
287 .secret = client->secret,
288 .secret_length = talloc_strlen(client->secret),
289 };
290
291 request->packet->code = data[0];
292
293 decode_ctx = (fr_radius_decode_ctx_t) {
294 .common = &common_ctx,
295 .tmp_ctx = talloc(request, uint8_t),
296 /* decode figures out request_authenticator */
297 .end = data + data_len,
298 .verify = client->active,
299 };
300
301 if (request->packet->code == FR_RADIUS_CODE_ACCESS_REQUEST) {
302 decode_ctx.require_message_authenticator = (require_message_authenticator == FR_RADIUS_REQUIRE_MA_YES);
303 decode_ctx.limit_proxy_state = (limit_proxy_state == FR_RADIUS_LIMIT_PROXY_STATE_YES);
304 }
305
306 /*
307 * The verify() routine over-writes the request packet vector.
308 *
309 * @todo - That needs to be changed.
310 */
311 request->packet->id = data[1];
312 request->reply->id = data[1];
313 memcpy(request->packet->vector, data + 4, sizeof(request->packet->vector));
314
315 request->packet->data = talloc_memdup(request->packet, data, data_len);
316 request->packet->data_len = data_len;
317
318 /*
319 * !client->active means a fake packet defining a dynamic client - so there will
320 * be no secret defined yet - so can't verify.
321 */
322 if (fr_radius_decode(request->request_ctx, &request->request_pairs,
323 data, data_len, &decode_ctx) < 0) {
324 talloc_free(decode_ctx.tmp_ctx);
325
326 proto_radius_log(track->li, decode_ctx.reason, &address->socket,
327 "%s ID %u - decoding failed (%s)",
329 return -1;
330 }
331 talloc_free(decode_ctx.tmp_ctx);
332
333 /*
334 * Set the rest of the fields.
335 */
336 request->client = client;
337
338 request->packet->socket = address->socket;
339 fr_socket_addr_swap(&request->reply->socket, &address->socket);
340
341 /*
342 * Do BlastRADIUS checks for Access-Request and Message-Authenticator
343 */
344 if ((request->packet->code == FR_RADIUS_CODE_ACCESS_REQUEST) &&
345 !client->blastradius_complaint &&
346 (require_message_authenticator != FR_RADIUS_REQUIRE_MA_YES)) {
347 bool has_ma = (fr_pair_find_by_da(&request->request_pairs, NULL, attr_message_authenticator) != NULL);
348
349 client->blastradius_complaint = true;
350
351 if (has_ma) {
352 RINFO("Packet from client %pV (%pV) contains a valid Message-Authenticator.",
353 fr_box_ipaddr(client->ipaddr),
355 RINFO("Please set \"require_message_authenticator = yes\"");
356
357 /*
358 * If require_message_authenticator is "auto", then we start requiring messages
359 * authenticator after the first Access-Request packet which contains one. This isn't
360 * vulnerable to the same attack as limit_proxy_state, as the attacker would need
361 * knowledge of the secret.
362 *
363 * Unfortunately there are many cases where auto mode can break things (dealing
364 * with multiple clients behind a NAT for example). So we don't recommend using
365 * it.
366 */
367 if (require_message_authenticator == FR_RADIUS_REQUIRE_MA_AUTO) {
368 if (!fr_pair_find_by_da(&request->request_pairs, NULL, attr_eap_message)) {
371
372 RINFO("Setting \"require_message_authenticator = yes\"");
373 } else {
374 RINFO("Not changing the value of 'require_message_authenticator = auto', as packet also contains EAP-Message");
375 }
376 }
377 } else {
378 RERROR("Packet from client %pV (%s) does not contain a Message-Authenticator.",
379 fr_box_ipaddr(client->ipaddr),
380 client->shortname);
381 RERROR("Upgrade the client, as your network is vulnerable to the BlastRADIUS attack.");
382 RERROR("Then set \"require_message_authenticator = yes\"");
383 }
384
385 /*
386 * We check limit_proxy_state only for packets without Message-Authenticator. But we
387 * check it unconditionally for the first packet.
388 *
389 * There is perhaps a small race window for an attacker when the server reboots, but
390 * there isn't much that we can do about that.
391 */
392 if (!has_ma && client->active && (limit_proxy_state == FR_RADIUS_LIMIT_PROXY_STATE_AUTO)) {
393 bool seen_ps = (fr_pair_find_by_da(&request->request_pairs, NULL, attr_proxy_state) != NULL);
394
395 RINFO("Packet from %pV (%s) %s Proxy-State. Setting \"limit_proxy_state = %s\"",
396 fr_box_ipaddr(client->ipaddr),
397 client->shortname,
398 seen_ps ? "contains" : "does not contain",
399 seen_ps ? "no" : "yes");
400
401 client->limit_proxy_state_is_set = true;
403 }
404 }
405
406 REQUEST_VERIFY(request);
407
408 /*
409 * If we're defining a dynamic client, this packet is
410 * fake. We don't have a secret, so we mash all of the
411 * encrypted attributes to sane (i.e. non-hurtful)
412 * values.
413 */
414 if (!client->active) {
415 fr_pair_t *vp;
416
417 fr_assert(client->dynamic);
418
420
421 for (vp = fr_pair_list_head(&request->request_pairs);
422 vp != NULL;
423 vp = fr_pair_list_next(&request->request_pairs, vp)) {
425 switch (vp->vp_type) {
426 default:
427 break;
428
429 case FR_TYPE_UINT32:
430 vp->vp_uint32 = 0;
431 break;
432
434 vp->vp_ipv4addr = INADDR_ANY;
435 break;
436
437 case FR_TYPE_OCTETS:
438 fr_pair_value_memdup(vp, (uint8_t const *) "", 1, true);
439 break;
440
441 case FR_TYPE_STRING:
442 fr_pair_value_strdup(vp, "", true);
443 break;
444 }
445 }
446 }
447 }
448
449 /*
450 * Set the sequence to be at least one. This will
451 * prioritize replies to Access-Challenges over other
452 * packets. The sequence will be updated (if necessary)
453 * by the RADIUS state machine. If the request yields,
454 * it will get re-inserted with an updated sequence
455 * number.
456 */
457 if ((request->packet->code == FR_RADIUS_CODE_ACCESS_REQUEST) &&
458 fr_pair_find_by_da(&request->request_pairs, NULL, attr_state)) {
459 request->sequence = 1;
460 }
461
462 if (fr_packet_pairs_from_packet(request->request_ctx, &request->request_pairs, request->packet) < 0) {
463 RPEDEBUG("Failed decoding 'Net.*' packet");
464 return -1;
465 }
466
467 /*
468 * Populate Packet structure with Id and Authenticator
469 */
470 MEM(packet_vp = fr_pair_afrom_da_nested(request->request_ctx, &request->request_pairs, attr_packet_id));
471 packet_vp->vp_uint8 = request->packet->id;
472 MEM(packet_vp = fr_pair_afrom_da_nested(request->request_ctx, &request->request_pairs, attr_packet_authenticator));
473 if (fr_value_box_memdup(packet_vp, &packet_vp->data, NULL, request->packet->data + 4,
474 RADIUS_AUTH_VECTOR_LENGTH, true) < 0) {
475 RPEDEBUG("Failed adding Authenticator pair");
476 return -1;
477 }
478
479 return 0;
480}
481
482static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
483{
484 fr_io_track_t *track = talloc_get_type_abort(request->async->packet_ctx, fr_io_track_t);
485 fr_io_address_t const *address = track->address;
486 uint32_t error_cause = 0;
487 ssize_t data_len;
488 fr_client_t const *client;
489 fr_radius_ctx_t common_ctx = {};
491
492 client = address->radclient;
493 fr_assert(client);
494
495 /*
496 * No reply was set, and the client supports Protocol-Error. Go create one.
497 */
498 if (unlikely((buffer_len > 1) && (request->reply->code == 0) && client->protocol_error)) {
499 switch (request->packet->code) {
501 RDEBUG2("There was no response configured - sending Access-Reject");
502 request->reply->code = FR_RADIUS_CODE_ACCESS_REJECT;
503 break;
504
506 RDEBUG2("There was no response configured - sending CoA-NAK");
507 request->reply->code = FR_RADIUS_CODE_COA_NAK;
508 goto not_routable;
509
511 RDEBUG2("There was no response configured - sending Disconnect-NAK");
512 request->reply->code = FR_RADIUS_CODE_DISCONNECT_NAK;
513 goto not_routable;
514
516 /*
517 * Send Protocol-Error reply.
518 *
519 * @todo - Session-Context-Not-Found is likely the wrong error.
520 */
521 RDEBUG2("There was no response configured - sending Protocol-Error");
522
523 request->reply->code = FR_RADIUS_CODE_PROTOCOL_ERROR;
524 error_cause = FR_ERROR_CAUSE_VALUE_SESSION_CONTEXT_NOT_FOUND;
525 goto force_reply;
526
527 default:
528 RDEBUG2("There was no response configured - not sending reply");
529 break;
530 }
531 }
532
533 /*
534 * Process layer NAK, or "Do not respond".
535 */
536 if ((buffer_len == 1) ||
537 (request->reply->code == FR_RADIUS_CODE_DO_NOT_RESPOND) ||
538 (request->reply->code == 0) || (request->reply->code >= FR_RADIUS_CODE_MAX)) {
539 track->do_not_respond = true;
540 return 1;
541 }
542
543 /*
544 * Not all clients support Protocol-Error. The admin might have forced Protocol-Error, or we
545 * might have received a Protocol-Error from a home server.
546 */
547 if ((request->reply->code == FR_RADIUS_CODE_PROTOCOL_ERROR) && !client->protocol_error) {
548 fr_pair_t *vp;
549
550 switch (request->packet->code) {
552 RWDEBUG("Client %s does not support Protocol-Error - rewriting to Access-Reject",
553 client->shortname);
554 request->reply->code = FR_RADIUS_CODE_ACCESS_REJECT;
555 break;
556
558 RWDEBUG2("Client %s does not support Protocol-Error - rewriting to CoA-NAK",
559 request->client->shortname);
560 request->reply->code = FR_RADIUS_CODE_COA_NAK;
561 goto not_routable;
562
564 RWDEBUG2("Client %s does not support Protocol-Error - rewriting to Disconnect-NAK",
565 request->client->shortname);
566 request->reply->code = FR_RADIUS_CODE_DISCONNECT_NAK;
567
568 not_routable:
569 error_cause = FR_ERROR_CAUSE_VALUE_PROXY_REQUEST_NOT_ROUTABLE;
570
571 force_reply:
572 fr_pair_list_free(&request->reply_pairs);
573
574 MEM(vp = fr_pair_afrom_da(request->reply_ctx, attr_error_cause));
575 fr_pair_append(&request->reply_pairs, vp);
576 vp->vp_uint32 = error_cause;
577 break;
578
580 default:
581 RWDEBUG2("Client %s does not support Protocol-Error - not replying to the client",
582 request->client->shortname);
583 track->do_not_respond = true;
584 return 1;
585 }
586 }
587
588 /*
589 * Dynamic client stuff
590 */
591 if (client->dynamic && !client->active) {
592 fr_client_t *new_client;
593
594 fr_assert(buffer_len >= sizeof(client));
595
596 /*
597 * We don't accept the new client, so don't do
598 * anything.
599 */
600 if (request->reply->code != FR_RADIUS_CODE_ACCESS_ACCEPT) {
601 *buffer = true;
602 return 1;
603 }
604
605 /*
606 * Allocate the client. If that fails, send back a NAK.
607 *
608 * @todo - deal with NUMA zones? Or just deal with this
609 * client being in different memory.
610 *
611 * Maybe we should create a CONF_SECTION from the client,
612 * and pass *that* back to mod_write(), which can then
613 * parse it to create the actual client....
614 */
615 new_client = client_afrom_request(NULL, request);
616 if (!new_client) {
617 PERROR("Failed creating new client");
618 *buffer = true;
619 return 1;
620 }
621
622 memcpy(buffer, &new_client, sizeof(new_client));
623 return sizeof(new_client);
624 }
625
626 /*
627 * Overwrite the src ip address on the outbound packet
628 * with the one specified by the client. This is useful
629 * to work around broken DSR implementations and other
630 * routing issues.
631 */
632 if (client->src_ipaddr.af != AF_UNSPEC) {
633 request->reply->socket.inet.src_ipaddr = client->src_ipaddr;
634 }
635
636 common_ctx = (fr_radius_ctx_t) {
637 .secret = client->secret,
638 .secret_length = talloc_strlen(client->secret),
639 };
641 .common = &common_ctx,
642 .request_authenticator = request->packet->data + 4,
643 .rand_ctx = (fr_fast_rand_t) {
644 .a = fr_rand(),
645 .b = fr_rand(),
646 },
647 .request_code = request->packet->data[0],
648 .code = request->reply->code,
649 .id = request->reply->id,
650#ifdef NAS_VIOLATES_RFC
651 .allow_vulnerable_clients = client->allow_vulnerable_clients,
652#endif
653 };
654
655 data_len = fr_radius_encode(&FR_DBUFF_TMP(buffer, buffer_len), &request->reply_pairs, &encode_ctx);
656 if (data_len < 0) {
657 RPEDEBUG("Failed encoding RADIUS reply");
658 return -1;
659 }
660
661 if (fr_radius_sign(buffer, request->packet->data + 4,
662 (uint8_t const *) client->secret, talloc_strlen(client->secret)) < 0) {
663 RPEDEBUG("Failed signing RADIUS reply");
664 return -1;
665 }
666
667 fr_packet_net_from_pairs(request->reply, &request->reply_pairs);
668
669 if (RDEBUG_ENABLED) {
670 RDEBUG("Sending %s ID %i from %pV:%i to %pV:%i length %zu via socket %s",
671 fr_radius_packet_name[request->reply->code],
672 request->reply->id,
673 fr_box_ipaddr(request->reply->socket.inet.src_ipaddr),
674 request->reply->socket.inet.src_port,
675 fr_box_ipaddr(request->reply->socket.inet.dst_ipaddr),
676 request->reply->socket.inet.dst_port,
677 data_len,
678 request->async->listen->name);
679
680 log_request_proto_pair_list(L_DBG_LVL_1, request, NULL, &request->reply_pairs, NULL);
681 }
682
683 return data_len;
684}
685
686static int mod_priority_set(void const *instance, uint8_t const *buffer, UNUSED size_t buflen)
687{
689
690 fr_assert(buffer[0] > 0);
692
693 /*
694 * Disallowed packet
695 */
696 if (!inst->priorities[buffer[0]]) return 0;
697
698 if (!inst->allowed[buffer[0]]) return -1;
699
700 /*
701 * @todo - if we cared, we could also return -1 for "this
702 * is a bad packet". But that's really only for
703 * mod_inject, as we assume that app_io->read() always
704 * returns good packets.
705 */
706
707 /*
708 * Return the configured priority.
709 */
710 return inst->priorities[buffer[0]];
711}
712
713/** Open listen sockets/connect to external event source
714 *
715 * @param[in] instance Ctx data for this application.
716 * @param[in] sc to add our file descriptor to.
717 * @param[in] conf Listen section parsed to give us instance.
718 * @return
719 * - 0 on success.
720 * - -1 on failure.
721 */
722static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
723{
724 proto_radius_t *inst = talloc_get_type_abort(instance, proto_radius_t);
725
726 /*
727 * io.app_io should already be set
728 */
729 return fr_master_io_listen(&inst->io, sc,
730 inst->max_packet_size, inst->num_messages);
731}
732
733/** Instantiate the application
734 *
735 * Instantiate I/O and type submodules.
736 *
737 * @return
738 * - 0 on success.
739 * - -1 on failure.
740 */
741static int mod_instantiate(module_inst_ctx_t const *mctx)
742{
743 proto_radius_t *inst = talloc_get_type_abort(mctx->mi->data, proto_radius_t);
744
745 /*
746 * No IO module, it's an empty listener.
747 */
748 if (!inst->io.submodule) return 0;
749
750 /*
751 * These timers are usually protocol specific.
752 */
753 FR_TIME_DELTA_BOUND_CHECK("idle_timeout", inst->io.idle_timeout, >=, fr_time_delta_from_sec(1));
754 FR_TIME_DELTA_BOUND_CHECK("idle_timeout", inst->io.idle_timeout, <=, fr_time_delta_from_sec(600));
755
756 FR_TIME_DELTA_BOUND_CHECK("nak_lifetime", inst->io.nak_lifetime, >=, fr_time_delta_from_sec(1));
757 FR_TIME_DELTA_BOUND_CHECK("nak_lifetime", inst->io.nak_lifetime, <=, fr_time_delta_from_sec(600));
758
759 FR_TIME_DELTA_BOUND_CHECK("cleanup_delay", inst->io.cleanup_delay, <=, fr_time_delta_from_sec(30));
760 FR_TIME_DELTA_BOUND_CHECK("cleanup_delay", inst->io.cleanup_delay, >, fr_time_delta_from_sec(0));
761
762#if 0
763 /*
764 * No Access-Request packets, then no cleanup delay.
765 */
766 if (!inst->allowed[FR_RADIUS_CODE_ACCESS_REQUEST]) {
767 inst->io.cleanup_delay = 0;
768 }
769#endif
770
771 /*
772 * Ensure that the server CONF_SECTION is always set.
773 */
774 inst->io.server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
775
776 /*
777 * These configuration items are not printed by default,
778 * because normal people shouldn't be touching them.
779 */
780 if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
781
782 if (!inst->num_messages) inst->num_messages = 256;
783
784 FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
785 FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
786
787 FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
788 FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
789
790 /*
791 * Tell the master handler about the main protocol instance.
792 */
793 inst->io.app = &proto_radius;
794 inst->io.app_instance = inst;
795
796 /*
797 * We will need this for dynamic clients and connected sockets.
798 */
799 inst->io.mi = mctx->mi;
800
801 /*
802 * Instantiate the transport module before calling the
803 * common instantiation function.
804 */
805 if (module_instantiate(inst->io.submodule) < 0) return -1;
806
807 /*
808 * Instantiate the master io submodule
809 */
811}
812
813/** Get the authentication vector.
814 *
815 * Note that we don't allow people to get the reply vector, because
816 * it doesn't exist until the reply is sent.
817 *
818 */
820 UNUSED xlat_ctx_t const *xctx, request_t *request,
821 UNUSED fr_value_box_list_t *in)
822{
823 fr_value_box_t *vb;
824
825 if (request->proto_dict != dict_radius) return XLAT_ACTION_FAIL;
826
827 MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_OCTETS, NULL));
828 if (fr_value_box_memdup(vb, vb, NULL, request->packet->vector, sizeof(request->packet->vector), true) < 0) {
829 talloc_free(vb);
830 return XLAT_ACTION_FAIL;
831 }
832
834
835 return XLAT_ACTION_DONE;
836}
837
838
839static int mod_load(void)
840{
841 if (fr_radius_global_init() < 0) {
842 PERROR("Failed initialising protocol library");
843 return -1;
844 }
845
846
847 if (!xlat_func_register(NULL, "radius.packet.vector", packet_vector_xlat, FR_TYPE_OCTETS)) {
849 return -1;
850 }
851
852 return 0;
853}
854
855static void mod_unload(void)
856{
857 xlat_func_unregister("radius.packet.vector");
858
860}
861
863 .common = {
864 .magic = MODULE_MAGIC_INIT,
865 .name = "radius",
867 .inst_size = sizeof(proto_radius_t),
868 .onload = mod_load,
869 .unload = mod_unload,
870 .instantiate = mod_instantiate
871 },
872 .dict = &dict_radius,
873 .open = mod_open,
874 .decode = mod_decode,
875 .encode = mod_encode,
876 .priority = mod_priority_set
877};
static int const char char buffer[256]
Definition acutest.h:576
va_end(args)
log_entry msg
Definition acutest.h:794
static int const char * fmt
Definition acutest.h:573
va_start(args, fmt)
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 DIAG_ON(_x)
Definition build.h:535
#define unlikely(_x)
Definition build.h:455
#define UNUSED
Definition build.h:384
#define DIAG_OFF(_x)
Definition build.h:534
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:695
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
Definition cf_util.c:675
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
Definition cf_util.c:1756
#define cf_log_err(_cf, _fmt,...)
Definition cf_util.h:345
#define cf_parent(_cf)
Definition cf_util.h:118
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
static int fr_dcursor_append(fr_dcursor_t *cursor, void *v)
Insert a single item at the end of the list.
Definition dcursor.h:406
#define MEM(x)
Definition debug.h:38
@ FR_RADIUS_CODE_ACCESS_REQUEST
RFC2865 - Access-Request.
Definition defs.h:33
@ FR_RADIUS_CODE_DISCONNECT_REQUEST
RFC3575/RFC5176 - Disconnect-Request.
Definition defs.h:46
@ FR_RADIUS_CODE_DO_NOT_RESPOND
Special rcode to indicate we will not respond.
Definition defs.h:54
@ FR_RADIUS_CODE_MAX
Maximum possible protocol code.
Definition defs.h:53
@ FR_RADIUS_CODE_STATUS_SERVER
RFC2865/RFC5997 - Status Server (request)
Definition defs.h:44
@ FR_RADIUS_CODE_COA_REQUEST
RFC3575/RFC5176 - CoA-Request.
Definition defs.h:49
@ FR_RADIUS_CODE_ACCESS_ACCEPT
RFC2865 - Access-Accept.
Definition defs.h:34
@ FR_RADIUS_CODE_COA_NAK
RFC3575/RFC5176 - CoA-Nak (not willing to perform)
Definition defs.h:51
@ FR_RADIUS_CODE_DISCONNECT_NAK
RFC3575/RFC5176 - Disconnect-Nak (not willing to perform)
Definition defs.h:48
@ FR_RADIUS_CODE_PROTOCOL_ERROR
RFC7930 - Protocol-Error (generic NAK)
Definition defs.h:52
@ FR_RADIUS_CODE_ACCOUNTING_REQUEST
RFC2866 - Accounting-Request.
Definition defs.h:36
@ FR_RADIUS_CODE_ACCESS_REJECT
RFC2865 - Access-Reject.
Definition defs.h:35
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
#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:3696
static fr_slen_t in
Definition dict.h:882
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
talloc_free(hp)
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
fr_radius_require_ma_t require_message_authenticator
Require RADIUS message authenticator for incoming packets.
Definition client.h:94
char const * secret
Secret PSK.
Definition client.h:90
bool active
for dynamic clients
Definition client.h:114
fr_ipaddr_t src_ipaddr
IPv4/IPv6 address to send responses from (family must match ipaddr).
Definition client.h:84
bool require_message_authenticator_is_set
Whether require_message_authenticator is set in the configuration.
Definition client.h:98
bool limit_proxy_state_is_set
Whether limit_proxy_state is set in the configuration.
Definition client.h:109
bool dynamic
Whether the client was dynamically defined.
Definition client.h:113
bool blastradius_complaint
whether we already did a BlastRADIUS complaint
Definition client.h:111
char const * shortname
Client nickname.
Definition client.h:88
bool protocol_error
Whether the client supports Protocol-Error.
Definition client.h:112
fr_radius_limit_proxy_state_t limit_proxy_state
Whether to allow Proxy-State in incoming packets that don't contain a message authenticator.
Definition client.h:105
Describes a host allowed to send packets to the server.
Definition client.h:80
void log_request_proto_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
Print a list of protocol fr_pair_ts.
Definition log.c:902
#define PERROR(_fmt,...)
Definition log.h:233
#define DEBUG_ENABLED2
True if global debug level 1-2 messages are enabled.
Definition log.h:263
#define RWDEBUG(fmt,...)
Definition log.h:378
#define RWDEBUG2(fmt,...)
Definition log.h:379
#define RERROR(fmt,...)
Definition log.h:315
#define RINFO(fmt,...)
Definition log.h:313
#define RPEDEBUG(fmt,...)
Definition log.h:393
#define EDEBUG2(_fmt,...)
Definition log.h:289
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:162
@ L_DBG_LVL_1
Highest priority debug messages (-x).
Definition log.h:67
fr_app_io_t fr_master_app_io
Definition master.c:3577
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:3367
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_listen_t const * li
listener associated with this tracking structure
Definition master.h:42
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_VOID
User data.
@ FR_TYPE_OCTETS
Raw octets.
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
#define RADIUS_AUTH_VECTOR_LENGTH
Definition net.h:89
int fr_pair_value_memdup(fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted)
Copy data into an "octets" data type.
Definition pair.c:2962
int fr_pair_value_strdup(fr_pair_t *vp, char const *src, bool tainted)
Copy data into an "string" data type.
Definition pair.c:2663
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_afrom_da_nested(TALLOC_CTX *ctx, fr_pair_list_t *list, fr_dict_attr_t const *da)
Create a pair (and all intermediate parents), and append it to the list.
Definition pair.c:480
static fr_internal_encode_ctx_t encode_ctx
static int mod_load(void)
static fr_dict_attr_t const * attr_packet_type
static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
static xlat_action_t packet_vector_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in)
Get the authentication vector.
static char const * url[FR_RADIUS_FAIL_MAX+1]
static fr_dict_attr_t const * attr_packet_authenticator
static fr_dict_attr_t const * attr_state
fr_dict_autoload_t proto_radius_dict[]
static conf_parser_t const limit_config[]
static fr_dict_attr_t const * attr_eap_message
static int type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
fr_app_t proto_radius
void proto_radius_log(fr_listen_t const *li, fr_radius_decode_fail_t reason, fr_socket_t const *sock, char const *fmt,...)
Log a message in a canonical format.
static int mod_decode(void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Decode the packet.
static fr_dict_t const * dict_radius
static conf_parser_t const log_config[]
static fr_dict_attr_t const * attr_error_cause
static void mod_unload(void)
static fr_dict_attr_t const * attr_proxy_state
static const conf_parser_t priority_config[]
static fr_dict_attr_t const * attr_user_name
static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static fr_dict_attr_t const * attr_packet_id
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)
fr_dict_attr_autoload_t proto_radius_dict_attr[]
static fr_dict_attr_t const * attr_message_authenticator
static conf_parser_t const proto_radius_config[]
How to parse a RADIUS listen section.
An instance of a proto_radius listen section.
ssize_t fr_radius_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t *packet, size_t packet_len, fr_radius_decode_ctx_t *decode_ctx)
Definition base.c:1178
size_t fr_radius_limit_proxy_state_table_len
Definition base.c:102
int fr_radius_sign(uint8_t *packet, uint8_t const *vector, uint8_t const *secret, size_t secret_len)
Sign a previously encoded packet.
Definition base.c:361
char const * fr_radius_decode_fail_reason[FR_RADIUS_FAIL_MAX+1]
Definition base.c:507
size_t fr_radius_require_ma_table_len
Definition base.c:93
int fr_radius_global_init(void)
Definition base.c:1313
void fr_radius_global_free(void)
Definition base.c:1337
fr_table_num_sorted_t const fr_radius_limit_proxy_state_table[]
Definition base.c:95
fr_table_num_sorted_t const fr_radius_require_ma_table[]
Definition base.c:86
ssize_t fr_radius_encode(fr_dbuff_t *dbuff, fr_pair_list_t *vps, fr_radius_encode_ctx_t *packet_ctx)
Definition base.c:1028
char const * fr_radius_packet_name[FR_RADIUS_CODE_MAX]
Definition base.c:115
#define fr_assert(_expr)
Definition rad_assert.h:37
#define RDEBUG2(fmt,...)
#define RDEBUG(fmt,...)
#define RDEBUG_ENABLED()
fr_radius_require_ma_t
Control whether Message-Authenticator is required in Access-Requests.
Definition radius.h:61
@ FR_RADIUS_REQUIRE_MA_YES
Require Message-Authenticator.
Definition radius.h:63
@ FR_RADIUS_REQUIRE_MA_AUTO
Only require Message-Authenticator if we've previously received a packet from this client with Messag...
Definition radius.h:64
fr_radius_decode_fail_t
Failure reasons.
Definition radius.h:89
@ FR_RADIUS_FAIL_ATTRIBUTE_DECODE
Definition radius.h:105
@ FR_RADIUS_FAIL_UNEXPECTED_REQUEST_CODE
Definition radius.h:96
@ FR_RADIUS_FAIL_ATTRIBUTE_OVERFLOW
Definition radius.h:104
@ FR_RADIUS_FAIL_VERIFY
Definition radius.h:113
@ FR_RADIUS_FAIL_NONE
Definition radius.h:90
@ FR_RADIUS_FAIL_MA_INVALID_LENGTH
Definition radius.h:107
@ FR_RADIUS_FAIL_MIN_LENGTH_FIELD
Definition radius.h:93
@ FR_RADIUS_FAIL_INVALID_ATTRIBUTE
Definition radius.h:100
@ FR_RADIUS_FAIL_IO_ERROR
Definition radius.h:115
@ FR_RADIUS_FAIL_MAX_LENGTH_PACKET
Definition radius.h:92
@ FR_RADIUS_FAIL_MA_MISSING
Definition radius.h:108
@ FR_RADIUS_FAIL_TOO_MANY_ATTRIBUTES
Definition radius.h:98
@ FR_RADIUS_FAIL_UNEXPECTED_RESPONSE_CODE
Definition radius.h:97
@ FR_RADIUS_FAIL_UNKNOWN_PACKET_CODE
Definition radius.h:95
@ FR_RADIUS_FAIL_MIN_LENGTH_MISMATCH
Definition radius.h:94
@ FR_RADIUS_FAIL_NO_MATCHING_REQUEST
Definition radius.h:114
@ FR_RADIUS_FAIL_HEADER_OVERFLOW
Definition radius.h:102
@ FR_RADIUS_FAIL_MIN_LENGTH_PACKET
Definition radius.h:91
@ FR_RADIUS_FAIL_MAX
Definition radius.h:116
@ FR_RADIUS_FAIL_ATTRIBUTE_TOO_SHORT
Definition radius.h:103
@ FR_RADIUS_FAIL_MA_INVALID
Definition radius.h:109
@ FR_RADIUS_FAIL_PROXY_STATE_MISSING_MA
Definition radius.h:111
@ FR_RADIUS_FAIL_MA_TOO_MANY
Definition radius.h:110
char const * secret
Definition radius.h:127
bool limit_proxy_state
Don't allow Proxy-State in requests.
Definition radius.h:173
#define fr_radius_flag_encrypted(_da)
Definition radius.h:208
bool require_message_authenticator
Definition radius.h:172
fr_radius_ctx_t const * common
Definition radius.h:159
fr_radius_limit_proxy_state_t
Control whether Proxy-State is allowed in Access-Requests.
Definition radius.h:75
@ FR_RADIUS_LIMIT_PROXY_STATE_NO
Do not limit Proxy-State.
Definition radius.h:76
@ FR_RADIUS_LIMIT_PROXY_STATE_AUTO
Do not allow Proxy-State unless:
Definition radius.h:81
@ FR_RADIUS_LIMIT_PROXY_STATE_YES
Limit Proxy-State.
Definition radius.h:78
fr_radius_decode_fail_t reason
reason for decode failure
Definition radius.h:166
TALLOC_CTX * tmp_ctx
for temporary things cleaned up during decoding
Definition radius.h:163
static rs_t * conf
Definition radsniff.c:52
uint32_t fr_rand(void)
Return a 32-bit random number.
Definition rand.c:104
Smaller fast random number generator.
Definition rand.h:54
#define REQUEST_VERIFY(_x)
Definition request.h:310
#define request_set_dynamic_client(_x)
Definition request.h:190
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
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
Definition pair.h:69
#define talloc_get_type_abort_const
Definition talloc.h:117
static 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
xlat_action_t
Definition xlat.h:37
@ XLAT_ACTION_FAIL
An xlat function failed.
Definition xlat.h:44
@ XLAT_ACTION_DONE
We're done evaluating this level of nesting.
Definition xlat.h:43
fr_pair_t * fr_pair_list_next(fr_pair_list_t const *list, fr_pair_t const *item))
Get the next item in a valuepair list after a specific entry.
Definition pair_inline.c:69
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
fr_pair_t * fr_pair_list_head(fr_pair_list_t const *list)
Get the head of a valuepair list.
Definition pair_inline.c:42
static fr_slen_t parent
Definition pair.h: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:126
Holds information necessary for binding or connecting to a socket.
Definition socket.h:60
char const * fr_strerror(void)
Get the last library error.
Definition strerror.c:558
#define DOC_ROOT_URL
Definition version.h:87
int fr_value_box_memdup(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, uint8_t const *src, size_t len, bool tainted)
Copy a buffer to a fr_value_box_t.
Definition value.c:5103
#define fr_value_box_alloc(_ctx, _type, _enumv)
Allocate a value box of a specific type.
Definition value.h:644
#define fr_box_ipaddr(_val)
Definition value.h:317
#define fr_box_strvalue_buffer(_val)
Definition value.h:312
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.
An xlat calling ctx.
Definition xlat_ctx.h:49
xlat_t * xlat_func_register(TALLOC_CTX *ctx, char const *name, xlat_func_t func, fr_type_t return_type)
Register an xlat function.
Definition xlat_func.c:225
void xlat_func_unregister(char const *name)
Unregister an xlat function.
Definition xlat_func.c:519