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