The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
packet.c
Go to the documentation of this file.
1/*
2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
6 *
7 * This library 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 GNU
10 * Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; 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: 6ebec053ab9104cf697347a3b55da5263703141b $
19 *
20 * @file protocols/radius/packet.c
21 * @brief Functions to deal with fr_packet_t data structures.
22 *
23 * @copyright 2000-2017 The FreeRADIUS server project
24 */
25RCSID("$Id: 6ebec053ab9104cf697347a3b55da5263703141b $")
26
27#include "attrs.h"
28
29#include <freeradius-devel/util/udp.h>
30#include <freeradius-devel/util/syserror.h>
31
32#include <fcntl.h>
33
34/*
35 * Some messages get printed out only in debugging mode.
36 */
37#define FR_DEBUG_STRERROR_PRINTF if (fr_debug_lvl) fr_strerror_printf
38
39
40/** Encode a packet
41 *
42 */
44 fr_packet_t const *original, char const *secret)
45{
46 ssize_t slen;
47 fr_radius_ctx_t common = {};
49
50 /*
51 * A 4K packet, aligned on 64-bits.
52 */
54
55#ifndef NDEBUG
57#endif
58
59 common.secret = secret;
61
63 .common = &common,
64 .request_authenticator = original ? original->data + 4 : NULL,
65 .rand_ctx = (fr_fast_rand_t) {
66 .a = fr_rand(),
67 .b = fr_rand(),
68 },
69 .request_code = original ? original->data[0] : 0,
70 .code = packet->code,
71 .id = packet->id,
72 };
73
74#if defined(__clang_analyzer__) || defined(__COVERITY__)
75 /*
76 * Neither the clang analyser nor Coverity sees fr_radius_encode()
77 * fill the buffer through the dbuff, and both report the
78 * memcpy() below as a read of uninitialised memory.
79 */
80 memset(data, 0, sizeof(data));
81#endif
82 slen = fr_radius_encode(&FR_DBUFF_TMP(data, sizeof(data)), list, &packet_ctx);
83 if (slen < 0) return slen;
84
85 /*
86 * Fill in the rest of the fields, and copy the data over
87 * from the local stack to the newly allocated memory.
88 *
89 * Yes, all this 'memcpy' is slow, but it means
90 * that we only allocate the minimum amount of
91 * memory for a request.
92 */
93 packet->data_len = (size_t) slen;
94 packet->data = talloc_array(packet, uint8_t, packet->data_len);
95 if (!packet->data) {
96 fr_strerror_const("Out of memory");
97 return -1;
98 }
99
100 memcpy(packet->data, data, packet->data_len);
101
102 return 0;
103}
104
105/** See if the data pointed to by PTR is a valid RADIUS packet.
106 *
107 * Packet is not 'const * const' because we may update data_len, if there's more data
108 * in the UDP packet than in the RADIUS packet.
109 *
110 * This function can only be called for UDP packets.
111 *
112 * @param[in] packet to check.
113 * @param[in] max_attributes to decode.
114 * @param[in] require_message_authenticator to require Message-Authenticator.
115 * @param[out] reason if not NULL, will have the failure reason written to where it points.
116 * @return
117 * - True on success.
118 * - False on failure.
119 */
120bool fr_radius_packet_ok(fr_packet_t *packet, uint32_t max_attributes, bool require_message_authenticator, fr_radius_decode_fail_t *reason)
121{
122 size_t len = packet->data_len;
123
124 if (!fr_radius_ok(packet->data, &len, max_attributes, require_message_authenticator, reason)) {
125 return false;
126 }
127 fr_assert(packet->data_len >= len);
128 packet->data_len = len; /* UDP packet may be larger than RADIUS header len */
129
130 /*
131 * Fill RADIUS header fields
132 */
133 packet->code = packet->data[0];
134 packet->id = packet->data[1];
135 memcpy(packet->vector, packet->data + 4, sizeof(packet->vector));
136 return true;
137}
138
139
140/** Verify the Request/Response Authenticator (and Message-Authenticator if present) of a packet
141 *
142 */
143int fr_radius_packet_verify(fr_packet_t *packet, fr_packet_t *original, char const *secret)
144{
145 char buffer[INET6_ADDRSTRLEN];
146
147 if (!packet->data) return -1;
148
149 if (fr_radius_verify(packet->data, original ? original->data + 4 : NULL,
150 (uint8_t const *) secret, talloc_strlen(secret), false, false) < 0) {
151 fr_strerror_printf_push("Received invalid packet from %s",
152 inet_ntop(packet->socket.inet.src_ipaddr.af, &packet->socket.inet.src_ipaddr.addr,
153 buffer, sizeof(buffer)));
154 return -1;
155 }
156
157 return 0;
158}
159
160
161/** Sign a previously encoded packet
162 *
163 */
164int fr_radius_packet_sign(fr_packet_t *packet, fr_packet_t const *original,
165 char const *secret)
166{
167 int ret;
168
169 ret = fr_radius_sign(packet->data, original ? original->data + 4 : NULL,
170 (uint8_t const *) secret, talloc_strlen(secret));
171 if (ret < 0) return ret;
172
173 memcpy(packet->vector, packet->data + 4, RADIUS_AUTH_VECTOR_LENGTH);
174 return 0;
175}
176
177
178/** Wrapper for recvfrom, which handles recvfromto, IPv6, and all possible combinations
179 *
180 */
181static ssize_t rad_recvfrom(int sockfd, fr_packet_t *packet, int flags)
182{
183 ssize_t data_len;
184
185 data_len = fr_radius_recv_header(sockfd, &packet->socket.inet.src_ipaddr, &packet->socket.inet.src_port, &packet->code);
186 if (data_len < 0) {
187 if ((errno == EAGAIN) || (errno == EINTR)) return 0;
188 return -1;
189 }
190
191 if (data_len == 0) return -1; /* invalid packet */
192
193 packet->data = talloc_array(packet, uint8_t, data_len);
194 if (!packet->data) return -1;
195
196 packet->data_len = data_len;
197
198 return udp_recv(sockfd, flags, &packet->socket, packet->data, packet->data_len, &packet->timestamp);
199}
200
201
202/** Receive UDP client requests, and fill in the basics of a fr_packet_t structure
203 *
204 */
205fr_packet_t *fr_packet_recv(TALLOC_CTX *ctx, int fd, int flags, uint32_t max_attributes, bool require_message_authenticator)
206{
207 ssize_t data_len;
208 fr_packet_t *packet;
209
210 /*
211 * Allocate the new request data structure
212 */
213 packet = fr_packet_alloc(ctx, false);
214 if (!packet) {
215 fr_strerror_const("out of memory");
216 return NULL;
217 }
218
219 data_len = rad_recvfrom(fd, packet, flags);
220 if (data_len < 0) {
221 FR_DEBUG_STRERROR_PRINTF("Error receiving packet: %s", fr_syserror(errno));
222 fr_packet_free(&packet);
223 return NULL;
224 }
225
226#ifdef WITH_VERIFY_PTR
227 /*
228 * Double-check that the fields we want are filled in.
229 */
230 if ((packet->socket.inet.src_ipaddr.af == AF_UNSPEC) ||
231 (packet->socket.inet.src_port == 0) ||
232 (packet->socket.inet.dst_ipaddr.af == AF_UNSPEC) ||
233 (packet->socket.inet.dst_port == 0)) {
234 FR_DEBUG_STRERROR_PRINTF("Error receiving packet: %s", fr_syserror(errno));
235 fr_packet_free(&packet);
236 return NULL;
237 }
238#endif
239
240 packet->data_len = data_len; /* unsigned vs signed */
241
242 /*
243 * If the packet is too big, then rad_recvfrom did NOT
244 * allocate memory. Instead, it just discarded the
245 * packet.
246 */
247 if (packet->data_len > MAX_PACKET_LEN) {
248 FR_DEBUG_STRERROR_PRINTF("Discarding packet: Larger than RFC limitation of 4096 bytes");
249 fr_packet_free(&packet);
250 return NULL;
251 }
252
253 /*
254 * Read no data. Continue.
255 * This check is AFTER the MAX_PACKET_LEN check above, because
256 * if the packet is larger than MAX_PACKET_LEN, we also have
257 * packet->data == NULL
258 */
259 if ((packet->data_len == 0) || !packet->data) {
260 FR_DEBUG_STRERROR_PRINTF("Empty packet: Socket is not ready");
261 fr_packet_free(&packet);
262 return NULL;
263 }
264
265 /*
266 * See if it's a well-formed RADIUS packet.
267 */
268 if (!fr_radius_packet_ok(packet, max_attributes, require_message_authenticator, NULL)) {
269 fr_packet_free(&packet);
270 return NULL;
271 }
272
273 /*
274 * Remember which socket we read the packet from.
275 */
276 packet->socket.fd = fd;
277
278 /*
279 * FIXME: Do even more filtering by only permitting
280 * certain IP's. The problem is that we don't know
281 * how to do this properly for all possible clients...
282 */
283
284 return packet;
285}
286
287/** Reply to the request
288 *
289 * Also attach reply attribute value pairs and any user message provided.
290 *
291 * @return
292 * - >=0 amount of data written. 0 if the packet has no socket.
293 * - -1 on failure.
294 */
296 fr_packet_t const *original, char const *secret)
297{
298 /*
299 * Maybe it's a fake packet. Don't send it.
300 */
301 if (packet->socket.fd < 0) {
302 return 0;
303 }
304
305 /*
306 * First time through, allocate room for the packet
307 */
308 if (!packet->data) {
309 /*
310 * Encode the packet.
311 */
312 if (fr_radius_packet_encode(packet, list, original, secret) < 0) {
313 return -1;
314 }
315
316 /*
317 * Re-sign it, including updating the
318 * Message-Authenticator.
319 */
320 if (fr_radius_packet_sign(packet, original, secret) < 0) {
321 return -1;
322 }
323
324 /*
325 * If packet->data points to data, then we print out
326 * the VP list again only for debugging.
327 */
328 }
329
330 /*
331 * If the socket is TCP, call write(). Calling sendto()
332 * is allowed on some platforms, but it's not nice.
333 */
334 if (packet->socket.type == SOCK_STREAM) {
335 ssize_t ret;
336
337 ret = write(packet->socket.fd, packet->data, packet->data_len);
338 if (ret >= 0) return ret;
339
340 fr_strerror_printf("sendto failed: %s", fr_syserror(errno));
341 return -1;
342 }
343
344 /*
345 * And send it on it's way.
346 *
347 * No need to call fr_socket_addr_swap as apparently
348 * the address is already inverted.
349 */
350 return udp_send(&packet->socket, 0, packet->data, packet->data_len);
351}
352
353void _fr_packet_log_hex(fr_log_t const *log, fr_packet_t const *packet, char const *file, int line)
354{
355 uint8_t const *attr, *end;
356 char buffer[1024];
357
358 if (!packet->data) return;
359
360 fr_log(log, L_DBG, file, line, " Socket : %d", packet->socket.fd);
361 fr_log(log, L_DBG, file, line, " Proto : %d", (packet->socket.type == SOCK_STREAM) ? IPPROTO_TCP : IPPROTO_UDP);
362
363 if ((packet->socket.inet.src_ipaddr.af == AF_INET) || (packet->socket.inet.src_ipaddr.af == AF_INET6)) {
364 fr_log(log, L_DBG, file, line, " Src IP : %pV", fr_box_ipaddr(packet->socket.inet.src_ipaddr));
365 fr_log(log, L_DBG, file, line, " Src Port : %u", packet->socket.inet.src_port);
366 fr_log(log, L_DBG, file, line, " Dst IP : %pV", fr_box_ipaddr(packet->socket.inet.dst_ipaddr));
367 fr_log(log, L_DBG, file, line, " Dst Port : %u", packet->socket.inet.dst_port);
368 }
369
370 if ((packet->data[0] > 0) && (packet->data[0] < FR_RADIUS_CODE_MAX)) {
371 fr_log(log, L_DBG, file, line, " Code : %s", fr_radius_packet_name[packet->data[0]]);
372 } else {
373 fr_log(log, L_DBG, file, line, " Code : %u", packet->data[0]);
374 }
375
376 fr_log(log, L_DBG, file, line, " Id : %u", packet->data[1]);
377 fr_log(log, L_DBG, file, line, " Length : %u", fr_nbo_to_uint16(packet->data + 2));
378 fr_log(log, L_DBG, file, line, " Vector : %pH", fr_box_octets(packet->data + 4, RADIUS_AUTH_VECTOR_LENGTH));
379
380 if (packet->data_len <= 20) return;
381
382 for (attr = packet->data + 20, end = packet->data + packet->data_len;
383 attr < end;
384 attr += attr[1]) {
385 int i, len, offset = 2;
386 unsigned int vendor = 0;
387 char *p;
388 char const *truncated = "";
389
390 /*
391 * rad_packet_ok() already checks, but let's do defense in depth.
392 */
393 if (attr[1] < 2) break;
394
395 snprintf(buffer, sizeof(buffer), "%02x %02x ", attr[0], attr[1]);
396 p = buffer + strlen(buffer);
397 if ((attr[0] == FR_VENDOR_SPECIFIC) &&
398 (attr[1] > 6)) {
399 vendor = fr_nbo_to_uint32(attr + 2);
400
401 snprintf(p, buffer + sizeof(buffer) - p, "%02x%02x%02x%02x (%u) ",
402 attr[2], attr[3], attr[4], attr[5], vendor);
403 offset = 6;
404 p += strlen(p);
405 }
406
407 len = attr[1] - offset;
408 if (len > 15) {
409 len = 15;
410 truncated = "...";
411 }
412
413 for (i = 0; i < len; i++) {
414 snprintf(p, buffer + sizeof(buffer) - p, "%02x ", attr[offset + i]);
415 p += 3;
416 }
417
418 fr_log(log, L_DBG, file, line, " %s%s\n", buffer, truncated);
419 }
420}
421
422/*
423 * Debug the packet if requested.
424 */
425void fr_radius_packet_header_log(fr_log_t const *log, fr_packet_t *packet, bool received)
426{
427 char src_ipaddr[FR_IPADDR_STRLEN];
428 char dst_ipaddr[FR_IPADDR_STRLEN];
429 char const *via_prefix = "";
430 char const *via_ifname = "";
431 char const *via_suffix = "";
432#ifdef WITH_IFINDEX_NAME_RESOLUTION
433 char if_name[IFNAMSIZ];
434#endif
435
436 if (!log) return;
437 if (!packet) return;
438
439#ifdef WITH_IFINDEX_NAME_RESOLUTION
440 if (received) {
441 via_prefix = "via ";
442 via_ifname = fr_ifname_from_ifindex(if_name, packet->socket.inet.ifindex);
443 via_suffix = " ";
444 }
445#endif
446
447 /*
448 * Client-specific debugging re-prints the input
449 * packet into the client log.
450 *
451 * This really belongs in a utility library
452 */
453 if (FR_RADIUS_PACKET_CODE_VALID(packet->code)) {
454 fr_log(log, L_DBG, __FILE__, __LINE__,
455 "%s %s Id %i from %s%s%s:%i to %s%s%s:%i "
456 "%s%s%slength %zu\n",
457 received ? "Received" : "Sent",
459 packet->id,
460 packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "",
461 fr_inet_ntop(src_ipaddr, sizeof(src_ipaddr), &packet->socket.inet.src_ipaddr),
462 packet->socket.inet.src_ipaddr.af == AF_INET6 ? "]" : "",
463 packet->socket.inet.src_port,
464 packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "[" : "",
465 fr_inet_ntop(dst_ipaddr, sizeof(dst_ipaddr), &packet->socket.inet.dst_ipaddr),
466 packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "",
467 packet->socket.inet.dst_port,
468 via_prefix, via_ifname, via_suffix,
469 packet->data_len);
470 } else {
471 fr_log(log, L_DBG, __FILE__, __LINE__,
472 "%s code %u Id %i from %s%s%s:%i to %s%s%s:%i "
473 "%s%s%slength %zu\n",
474 received ? "Received" : "Sent",
475 packet->code,
476 packet->id,
477 packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "",
478 fr_inet_ntop(src_ipaddr, sizeof(src_ipaddr), &packet->socket.inet.src_ipaddr),
479 packet->socket.inet.src_ipaddr.af == AF_INET6 ? "]" : "",
480 packet->socket.inet.src_port,
481 packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "[" : "",
482 fr_inet_ntop(dst_ipaddr, sizeof(dst_ipaddr), &packet->socket.inet.dst_ipaddr),
483 packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "",
484 packet->socket.inet.dst_port,
485 via_prefix, via_ifname, via_suffix,
486 packet->data_len);
487 }
488}
489
490/*
491 * Debug the packet header and all attributes. This function is only called by the client code.
492 */
493void fr_radius_packet_log(fr_log_t const *log, fr_packet_t *packet, fr_pair_list_t *list, bool received)
494{
495 fr_radius_packet_header_log(log, packet, received);
496
497 if (!fr_debug_lvl) return;
498
499 /*
500 * If we're auto-adding Message Authenticator, then print
501 * out that we're auto-adding it.
502 */
503 if (!received) switch (packet->code) {
507 fr_log(log, L_DBG, __FILE__, __LINE__, "\tMessage-Authenticator = 0x\n");
508 }
509 break;
510
511 default:
512 break;
513 }
514
515 fr_pair_list_log(log, 4, list);
516#ifndef NDEBUG
517 if (fr_debug_lvl >= L_DBG_LVL_4) fr_packet_log_hex(log, packet);
518#endif
519}
static int const char char buffer[256]
Definition acutest.h:641
int const char * file
Definition acutest.h:855
void int line
Definition acutest.h:810
static int packet_ctx
the tests pass only the address of packet_ctx
#define RCSID(id)
Definition build.h:603
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
Definition dbuff.h:556
@ FR_RADIUS_CODE_ACCESS_REQUEST
RFC2865 - Access-Request.
Definition defs.h:33
@ 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
#define MAX_PACKET_LEN
Definition defs.h:68
static int sockfd
Definition dhcpclient.c:55
char * fr_inet_ntop(char out[static FR_IPADDR_STRLEN], size_t outlen, fr_ipaddr_t const *addr)
Print the address portion of a fr_ipaddr_t.
Definition inet.c:1025
#define FR_IPADDR_STRLEN
Like INET6_ADDRSTRLEN but includes space for the textual Zone ID.
Definition inet.h:89
int fr_debug_lvl
Definition log.c:41
fr_log_t default_log
Definition log.c:308
#define fr_log(_log, _lvl, _file, _line, _fmt,...)
Definition log.h:172
@ L_DBG_LVL_4
4th highest priority debug messages (-xxxx | -Xxx).
Definition log.h:70
@ L_DBG
Only displayed when debugging is enabled.
Definition log.h:56
fr_packet_t * fr_packet_alloc(TALLOC_CTX *ctx, bool new_vector)
Allocate a new fr_packet_t.
Definition packet.c:38
void fr_packet_free(fr_packet_t **packet_p)
Free a fr_packet_t.
Definition packet.c:89
ssize_t udp_send(fr_socket_t const *sock, int flags, void *data, size_t data_len)
Send a packet via a UDP socket.
Definition udp.c:42
ssize_t udp_recv(int sockfd, int flags, fr_socket_t *socket_out, void *data, size_t data_len, fr_time_t *when)
Read a UDP packet.
Definition udp.c:144
bool fr_radius_ok(uint8_t const *packet, size_t *packet_len_p, uint32_t max_attributes, bool require_message_authenticator, decode_fail_t *reason)
unsigned int uint32_t
long int ssize_t
unsigned char uint8_t
unsigned long int size_t
char const * inet_ntop(int af, void const *src, char *dst, size_t cnt)
Definition missing.c:447
static uint16_t fr_nbo_to_uint16(uint8_t const data[static sizeof(uint16_t)])
Read an unsigned 16bit integer from wire format (big endian)
Definition nbo.h:146
static uint32_t fr_nbo_to_uint32(uint8_t const data[static sizeof(uint32_t)])
Read an unsigned 32bit integer from wire format (big endian)
Definition nbo.h:167
#define RADIUS_AUTH_VECTOR_LENGTH
Definition net.h:89
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:716
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
int fr_radius_verify(uint8_t *packet, uint8_t const *vector, uint8_t const *secret, size_t secret_len, bool require_message_authenticator, bool limit_proxy_state)
Verify the signature of a request / response packet.
Definition base.c:839
ssize_t fr_radius_encode(fr_dbuff_t *dbuff, fr_pair_list_t *vps, fr_radius_encode_ctx_t *packet_ctx)
Definition base.c:1033
char const * fr_radius_packet_name[FR_RADIUS_CODE_MAX]
Definition base.c:115
ssize_t fr_radius_recv_header(int sockfd, fr_ipaddr_t *src_ipaddr, uint16_t *src_port, unsigned int *code)
Basic validation of RADIUS packet header.
Definition base.c:288
static ssize_t rad_recvfrom(int sockfd, fr_packet_t *packet, int flags)
Wrapper for recvfrom, which handles recvfromto, IPv6, and all possible combinations.
Definition packet.c:181
int fr_radius_packet_sign(fr_packet_t *packet, fr_packet_t const *original, char const *secret)
Sign a previously encoded packet.
Definition packet.c:164
void fr_radius_packet_header_log(fr_log_t const *log, fr_packet_t *packet, bool received)
Definition packet.c:425
bool fr_radius_packet_ok(fr_packet_t *packet, uint32_t max_attributes, bool require_message_authenticator, fr_radius_decode_fail_t *reason)
See if the data pointed to by PTR is a valid RADIUS packet.
Definition packet.c:120
int fr_radius_packet_verify(fr_packet_t *packet, fr_packet_t *original, char const *secret)
Verify the Request/Response Authenticator (and Message-Authenticator if present) of a packet.
Definition packet.c:143
void _fr_packet_log_hex(fr_log_t const *log, fr_packet_t const *packet, char const *file, int line)
Definition packet.c:353
ssize_t fr_radius_packet_send(fr_packet_t *packet, fr_pair_list_t *list, fr_packet_t const *original, char const *secret)
Reply to the request.
Definition packet.c:295
#define FR_DEBUG_STRERROR_PRINTF
Definition packet.c:37
fr_packet_t * fr_packet_recv(TALLOC_CTX *ctx, int fd, int flags, uint32_t max_attributes, bool require_message_authenticator)
Receive UDP client requests, and fill in the basics of a fr_packet_t structure.
Definition packet.c:205
void fr_radius_packet_log(fr_log_t const *log, fr_packet_t *packet, fr_pair_list_t *list, bool received)
Definition packet.c:493
ssize_t fr_radius_packet_encode(fr_packet_t *packet, fr_pair_list_t *list, fr_packet_t const *original, char const *secret)
Encode a packet.
Definition packet.c:43
#define fr_assert(_expr)
Definition rad_assert.h:37
static char * secret
static fr_dict_attr_t const * attr_message_authenticator
Definition radclient.c:128
char const * secret
Definition radius.h:127
fr_radius_decode_fail_t
Failure reasons.
Definition radius.h:89
#define fr_packet_log_hex(_log, _packet)
Definition radius.h:321
size_t secret_length
Definition radius.h:128
#define FR_RADIUS_PACKET_CODE_VALID(_x)
Definition radius.h:51
uint32_t fr_rand(void)
Return a 32-bit random number.
Definition rand.c:128
Smaller fast random number generator.
Definition rand.h:54
PUBLIC int snprintf(char *string, size_t length, char *format, va_alist)
Definition snprintf.c:689
Definition log.h:93
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
Definition syserror.c:243
static size_t talloc_strlen(char const *s)
Returns the length of a talloc array containing a string.
Definition talloc.h:143
unsigned int code
Packet code (type).
Definition packet.h:61
fr_socket_t socket
This packet was received on.
Definition packet.h:57
int id
Packet ID (used to link requests/responses).
Definition packet.h:60
uint8_t * data
Packet data (body).
Definition packet.h:63
size_t data_len
Length of packet data.
Definition packet.h:64
uint8_t vector[RADIUS_AUTH_VECTOR_LENGTH]
RADIUS authentication vector.
Definition packet.h:69
fr_time_t timestamp
When we received the packet.
Definition packet.h:58
#define fr_pair_list_log(_log, _lvl, _list)
Definition pair.h:870
int af
AF_INET, AF_INET6, or AF_UNIX.
Definition socket.h:83
int fd
File descriptor if this is a live socket.
Definition socket.h:86
int type
SOCK_STREAM, SOCK_DGRAM, etc.
Definition socket.h:84
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
Definition strerror.h:64
#define fr_strerror_printf_push(_fmt,...)
Add a message to an existing stack of messages at the tail.
Definition strerror.h:84
#define fr_strerror_const(_msg)
Definition strerror.h:223
#define fr_box_ipaddr(_val)
Definition value.h:348
static fr_slen_t data
Definition value.h:1366
static fr_sbuff_err_t char size_t * len
Definition value.h:1061
#define fr_box_octets(_val, _len)
Definition value.h:342