All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
libradius.h
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 #ifndef _FR_LIBRADIUS_H
17 #define _FR_LIBRADIUS_H
18 /*
19  * $Id: 716888f94fa534326bb90a1bd403e68a1f5620df $
20  *
21  * @file include/libradius.h
22  * @brief Structures and prototypes for the radius library.
23  *
24  * @copyright 1999-2014 The FreeRADIUS server project
25  */
26 
27 /*
28  * Compiler hinting macros. Included here for 3rd party consumers
29  * of libradius.h.
30  *
31  * @note Defines RCSIDH.
32  */
33 #include <freeradius-devel/build.h>
34 RCSIDH(libradius_h, "$Id: 716888f94fa534326bb90a1bd403e68a1f5620df $")
35 
36 /*
37  * Let any external program building against the library know what
38  * features the library was built with.
39  */
40 #include <freeradius-devel/features.h>
41 
42 #ifdef WITHOUT_VERSION_CHECK
43 # define RADIUSD_MAGIC_NUMBER ((uint64_t) (0xf4ee4ad3f4ee4ad3))
44 # define MAGIC_PREFIX(_x) ((uint8_t) 0x00)
45 # define MAGIC_VERSION(_x) ((uint32_t) 0x00000000)
46 # define MAGIC_COMMIT(_x) ((uint32_t) 0x00000000)
47 #else
48 # ifdef RADIUSD_VERSION_COMMIT
49 # define RADIUSD_MAGIC_NUMBER ((uint64_t) HEXIFY4(f4, RADIUSD_VERSION, RADIUSD_VERSION_COMMIT, 0))
50 # else
51 # define RADIUSD_MAGIC_NUMBER ((uint64_t) HEXIFY3(f4, RADIUSD_VERSION, 00000000))
52 # endif
53 # define MAGIC_PREFIX(_x) ((uint8_t) (_x >> 56))
54 # define MAGIC_VERSION(_x) ((uint32_t) ((_x >> 32) & 0x00ffffff))
55 # define MAGIC_COMMIT(_x) ((uint32_t) (_x & 0xffffffff))
56 #endif
57 
58 /*
59  * Talloc memory allocation is used in preference to malloc throughout
60  * the libraries and server.
61  */
62 #include <talloc.h>
63 
64 /*
65  * Defines signatures for any missing functions.
66  */
67 #include <freeradius-devel/missing.h>
68 
69 /*
70  * Include system headers.
71  */
72 #include <stdio.h>
73 #include <stdlib.h>
74 #include <stdarg.h>
75 #include <stdbool.h>
76 #include <signal.h>
77 
78 #ifdef HAVE_LIMITS_H
79 # include <limits.h>
80 #endif
81 
82 #include <freeradius-devel/threads.h>
83 #include <freeradius-devel/radius.h>
84 #include <freeradius-devel/token.h>
85 #include <freeradius-devel/hash.h>
86 #include <freeradius-devel/inet.h>
87 #include <freeradius-devel/regex.h>
88 #include <freeradius-devel/dict.h>
89 #include <freeradius-devel/pair.h>
90 #include <freeradius-devel/proto.h>
91 #include <freeradius-devel/conf.h>
92 #include <freeradius-devel/radpaths.h>
93 
94 #ifdef SIZEOF_UNSIGNED_INT
95 # if SIZEOF_UNSIGNED_INT != 4
96 # error FATAL: sizeof(unsigned int) != 4
97 # endif
98 #endif
99 
100 /*
101  * Include for modules.
102  */
103 #include <freeradius-devel/sha1.h>
104 #include <freeradius-devel/md4.h>
105 
106 #ifdef __cplusplus
107 extern "C" {
108 #endif
109 
110 #ifndef HAVE_SIG_T
111 typedef void (*sig_t)(int);
112 #endif
113 
114 #ifndef NDEBUG
115 # define FREE_MAGIC (0xF4EEF4EE)
116 #endif
117 
118 #define AUTH_VECTOR_LEN 16
119 #define CHAP_VALUE_LENGTH 16
120 #define MAX_STRING_LEN 254 /* RFC2138: string 0-253 octets */
121 
122 #ifdef _LIBRADIUS
123 # define RADIUS_HDR_LEN 20
124 # define VENDORPEC_USR 429
125 # define VENDORPEC_LUCENT 4846
126 # define VENDORPEC_STARENT 8164
127 # define DEBUG if (fr_debug_lvl && fr_log_fp) fr_printf_log
128 #endif
129 
130 #define PAD(_x, _y) (_y - ((_x) % _y))
131 
132 #define PRINTF_LIKE(n) CC_HINT(format(printf, n, n+1))
133 #define NEVER_RETURNS CC_HINT(noreturn)
134 #define UNUSED CC_HINT(unused)
135 #define BLANK_FORMAT " " /* GCC_LINT whines about empty formats */
136 
137 /*
138  * vector: Request authenticator from access-request packet
139  * Put in there by rad_decode, and must be put in the
140  * response RADIUS_PACKET as well before calling fr_radius_send
141  *
142  * verified: Filled in by rad_decode for accounting-request packets
143  *
144  * data,data_len: Used between fr_radius_recv and fr_radius_decode.
145  */
146 typedef struct radius_packet {
147  int sockfd; //!< Socket this packet was read from.
148  int if_index; //!< Index of receiving interface.
149  fr_ipaddr_t src_ipaddr; //!< Src IP address of packet.
150  fr_ipaddr_t dst_ipaddr; //!< Dst IP address of packet.
151  uint16_t src_port; //!< Src port of packet.
152  uint16_t dst_port; //!< DST Port of packet.
153 
154  int id; //!< Packet ID (used to link requests/responses).
155  unsigned int code; //!< Packet code (type).
156 
157  uint8_t vector[AUTH_VECTOR_LEN];//!< RADIUS authentication vector.
158 
159  struct timeval timestamp; //!< When we received the packet.
160  uint8_t *data; //!< Packet data (body).
161  size_t data_len; //!< Length of packet data.
162  VALUE_PAIR *vps; //!< Result of decoding the packet into VALUE_PAIRs.
163  ssize_t offset;
164 
165  uint32_t rounds; //!< for State[0]
166 
167 #ifdef WITH_TCP
168  size_t partial;
169  int proto;
170 #endif
171 } RADIUS_PACKET;
172 
173 typedef enum {
188 } decode_fail_t;
189 
190 /*
191  * Version check.
192  */
193 int fr_check_lib_magic(uint64_t magic);
194 
195 /*
196  * Printing functions.
197  */
198 int fr_utf8_char(uint8_t const *str, ssize_t inlen);
199 char const *fr_utf8_strchr(int *chr_len, char const *str, char const *chr);
200 size_t fr_snprint(char *out, size_t outlen, char const *in, ssize_t inlen, char quote);
201 size_t fr_snprint_len(char const *in, ssize_t inlen, char quote);
202 char *fr_asprint(TALLOC_CTX *ctx, char const *in, ssize_t inlen, char quote);
203 
204 #define is_truncated(_ret, _max) ((_ret) >= (size_t)(_max))
205 #define truncate_len(_ret, _max) (((_ret) >= (size_t)(_max)) ? (((size_t)(_max)) - 1) : _ret)
206 
207 /** Boilerplate for checking truncation
208  *
209  * If truncation has occurred, advance _p as far as possible without
210  * overrunning the output buffer, and \0 terminate. Then return the length
211  * of the buffer we would have needed to write the full value.
212  *
213  * If truncation has not occurred, advance _p by whatever the copy or print
214  * function returned.
215  */
216 #define RETURN_IF_TRUNCATED(_p, _ret, _max) \
217 do { \
218  if (is_truncated(_ret, _max)) { \
219  size_t _r = (_p - out) + _ret; \
220  _p += truncate_len(_ret, _max); \
221  *_p = '\0'; \
222  return _r; \
223  } \
224  _p += _ret; \
225 } while (0)
226 
227 /*
228  * radius.c
229  */
230 #define AUTH_PASS_LEN (AUTH_VECTOR_LEN)
231 #define MAX_PASS_LEN (128)
232 #define FR_TUNNEL_PW_ENC_LENGTH(_x) (2 + 1 + _x + PAD(_x + 1, 16))
233 extern FR_NAME_NUMBER const fr_request_types[];
234 
235 void fr_radius_make_secret(uint8_t *digest, uint8_t const *vector, char const *secret, uint8_t const *value);
236 
237 void fr_radius_print_hex(RADIUS_PACKET *packet);
238 
239 int fr_radius_send(RADIUS_PACKET *, RADIUS_PACKET const *, char const *secret);
240 
241 ssize_t fr_radius_len(uint8_t const *data, size_t data_len);
242 
243 bool fr_radius_ok(RADIUS_PACKET *packet, int flags, decode_fail_t *reason);
244 
245 RADIUS_PACKET *fr_radius_recv(TALLOC_CTX *ctx, int fd, int flags);
246 
247 ssize_t fr_radius_recv_header(int sockfd, fr_ipaddr_t *src_ipaddr, uint16_t *src_port, unsigned int *code);
248 
250 
251 int fr_radius_verify(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret);
252 
253 int fr_radius_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret);
254 
255 int fr_radius_encode(RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret);
256 
257 int fr_radius_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret);
258 
259 int fr_radius_digest_cmp(uint8_t const *a, uint8_t const *b, size_t length);
260 
261 RADIUS_PACKET *fr_radius_alloc(TALLOC_CTX *ctx, bool new_vector);
263 RADIUS_PACKET *fr_radius_copy(TALLOC_CTX *ctx, RADIUS_PACKET const *in);
265 
266 typedef struct fr_radius_ctx {
269  char const *secret;
271 
272 /*
273  * radius_encode.c
274  */
275 int fr_radius_encode_password(char *encpw, size_t *len, char const *secret, uint8_t const *vector);
276 
277 int fr_radius_encode_tunnel_password(char *encpw, size_t *len, char const *secret, uint8_t const *vector);
278 
279 int fr_radius_encode_chap_password(uint8_t *output, RADIUS_PACKET *packet, int id, VALUE_PAIR *password);
280 
281 ssize_t fr_radius_encode_value_hton(uint8_t const **out, VALUE_PAIR const *vp);
282 
283 int fr_radius_encode_pair(uint8_t *out, size_t outlen, vp_cursor_t *cursor, void *encoder_ctx);
284 
285 /*
286  * radius_decode.c
287  */
288 int fr_radius_decode_tlv_ok(uint8_t const *data, size_t length, size_t dv_type, size_t dv_length);
289 
290 ssize_t fr_radius_decode_password(char *encpw, size_t len, char const *secret, uint8_t const *vector);
291 
292 ssize_t fr_radius_decode_tunnel_password(uint8_t *encpw, size_t *len, char const *secret,
293  uint8_t const *vector);
294 
295 ssize_t fr_radius_decode_pair_value(TALLOC_CTX *ctx, vp_cursor_t *cursor, fr_dict_attr_t const *parent,
296  uint8_t const *data, size_t const attr_len, size_t const packet_len,
297  void *decoder_ctx);
298 
299 ssize_t fr_radius_decode_tlv(TALLOC_CTX *ctx, vp_cursor_t *cursor, fr_dict_attr_t const *parent,
300  uint8_t const *data, size_t data_len,
301  void *decoder_ctx);
302 
303 ssize_t fr_radius_decode_pair(TALLOC_CTX *ctx, vp_cursor_t *cursor, fr_dict_attr_t const *parent,
304  uint8_t const *data, size_t data_len,
305  void *decoder_ctx);
306 
307 /*
308  * cursor.c
309  */
310 VALUE_PAIR *fr_cursor_init(vp_cursor_t *cursor, VALUE_PAIR * const *node);
311 void fr_cursor_copy(vp_cursor_t *out, vp_cursor_t *in);
314 void fr_cursor_end(vp_cursor_t *cursor);
315 VALUE_PAIR *fr_cursor_next_by_num(vp_cursor_t *cursor, unsigned int vendor, unsigned int attr, int8_t tag);
316 
317 VALUE_PAIR *fr_cursor_next_by_da(vp_cursor_t *cursor, fr_dict_attr_t const *da, int8_t tag) CC_HINT(nonnull);
318 
322 void fr_cursor_insert(vp_cursor_t *cursor, VALUE_PAIR *vp);
323 void fr_cursor_merge(vp_cursor_t *cursor, VALUE_PAIR *vp);
326 void fr_cursor_free(vp_cursor_t *cursor);
327 
328 /* value.c */
329 int value_data_cmp(PW_TYPE a_type, value_data_t const *a,
330  PW_TYPE b_type, value_data_t const *b);
331 
333  PW_TYPE a_type, value_data_t const *a,
334  PW_TYPE b_type, value_data_t const *b);
335 
336 int value_data_from_str(TALLOC_CTX *ctx, value_data_t *dst,
337  PW_TYPE *src_type, fr_dict_attr_t const *src_enumv,
338  char const *src, ssize_t src_len, char quote);
339 
340 int value_data_cast(TALLOC_CTX *ctx, value_data_t *dst,
341  PW_TYPE dst_type, fr_dict_attr_t const *dst_enumv,
342  PW_TYPE src_type, fr_dict_attr_t const *src_enumv,
343  value_data_t const *src);
344 
345 int value_data_copy(TALLOC_CTX *ctx, value_data_t *dst, PW_TYPE type, const value_data_t *src);
346 
347 size_t value_data_snprint(char *out, size_t outlen,
348  PW_TYPE type, fr_dict_attr_t const *enumv,
349  value_data_t const *data, char quote);
350 
351 int value_data_steal(TALLOC_CTX *ctx, value_data_t *dst, PW_TYPE type, value_data_t const *src);
352 
353 char *value_data_asprint(TALLOC_CTX *ctx,
354  PW_TYPE type, fr_dict_attr_t const *enumv, value_data_t const *data,
355  char quote);
356 
357 /*
358  * Error functions.
359  */
360 void fr_strerror_printf(char const *, ...) CC_HINT(format (printf, 1, 2));
361 void fr_perror(char const *, ...) CC_HINT(format (printf, 1, 2));
362 void fr_canonicalize_error(TALLOC_CTX *ctx, char **spaces, char **text, ssize_t slen, char const *msg);
363 
364 char const *fr_strerror(void);
365 char const *fr_syserror(int num);
366 extern bool fr_dns_lookups; /* do IP -> hostname lookups? */
367 extern bool fr_hostname_lookups; /* do hostname -> IP lookups? */
368 extern int fr_debug_lvl; /* 0 = no debugging information */
369 extern uint32_t fr_max_attributes; /* per incoming packet */
370 #define FR_MAX_PACKET_CODE (52)
371 extern char const *fr_packet_codes[FR_MAX_PACKET_CODE];
372 #define is_radius_code(_x) ((_x > 0) && (_x < FR_MAX_PACKET_CODE))
373 extern FILE *fr_log_fp;
374 void fr_printf_log(char const *, ...) CC_HINT(format (printf, 1, 2));
375 
376 /*
377  * Several handy miscellaneous functions.
378  */
379 int fr_set_signal(int sig, sig_t func);
380 int fr_talloc_link_ctx(TALLOC_CTX *parent, TALLOC_CTX *child);
381 int rad_lockfd(int fd, int lock_len);
382 int rad_lockfd_nonblock(int fd, int lock_len);
383 int rad_unlockfd(int fd, int lock_len);
384 char *fr_abin2hex(TALLOC_CTX *ctx, uint8_t const *bin, size_t inlen);
385 size_t fr_bin2hex(char *hex, uint8_t const *bin, size_t inlen);
386 size_t fr_hex2bin(uint8_t *bin, size_t outlen, char const *hex, size_t inlen);
387 uint32_t fr_strtoul(char const *value, char **end);
388 bool is_whitespace(char const *value);
389 bool is_printable(void const *value, size_t len);
390 bool is_integer(char const *value);
391 bool is_zero(char const *value);
392 
393 int fr_nonblock(int fd);
394 int fr_blocking(int fd);
395 ssize_t fr_writev(int fd, struct iovec[], int iovcnt, struct timeval *timeout);
396 
397 ssize_t fr_utf8_to_ucs2(uint8_t *out, size_t outlen, char const *in, size_t inlen);
398 size_t fr_snprint_uint128(char *out, size_t outlen, uint128_t const num);
399 int fr_get_time(char const *date_str, time_t *date);
400 void fr_timeval_subtract(struct timeval *out, struct timeval const *end, struct timeval const *start);
401 void fr_timespec_subtract(struct timespec *out, struct timespec const *end, struct timespec const *start);
402 int fr_timeval_from_str(struct timeval *out, char const *in);
403 int8_t fr_pointer_cmp(void const *a, void const *b);
404 void fr_quick_sort(void const *to_sort[], int min_idx, int max_idx, fr_cmp_t cmp);
405 /*
406  * Define TALLOC_DEBUG to check overflows with talloc.
407  * we can't use valgrind, because the memory used by
408  * talloc is valid memory... just not for us.
409  */
410 #ifdef TALLOC_DEBUG
411 void fr_talloc_verify_cb(const void *ptr, int depth,
412  int max_depth, int is_ref,
413  void *private_data);
414 #define VERIFY_ALL_TALLOC talloc_report_depth_cb(NULL, 0, -1, fr_talloc_verify_cb, NULL)
415 #else
416 #define VERIFY_ALL_TALLOC
417 #endif
418 
419 #ifdef WITH_ASCEND_BINARY
420 /* filters.c */
421 int ascend_parse_filter(value_data_t *out, char const *value, size_t len);
422 void print_abinary(char *out, size_t outlen, uint8_t const *data, size_t len, int8_t quote);
423 #endif /*WITH_ASCEND_BINARY*/
424 
425 /* random numbers in isaac.c */
426 /* context of random number generator */
427 typedef struct fr_randctx {
428  uint32_t randcnt;
429  uint32_t randrsl[256];
430  uint32_t randmem[256];
431  uint32_t randa;
432  uint32_t randb;
433  uint32_t randc;
434 } fr_randctx;
435 
436 void fr_isaac(fr_randctx *ctx);
437 void fr_randinit(fr_randctx *ctx, int flag);
438 uint32_t fr_rand(void); /* like rand(), but better. */
439 void fr_rand_seed(void const *, size_t ); /* seed the random pool */
440 
441 
442 /* crypt wrapper from crypt.c */
443 int fr_crypt_check(char const *key, char const *salt);
444 
445 /* cbuff.c */
446 
447 typedef struct fr_cbuff fr_cbuff_t;
448 
449 fr_cbuff_t *fr_cbuff_alloc(TALLOC_CTX *ctx, uint32_t size, bool lock);
450 void fr_cbuff_rp_insert(fr_cbuff_t *cbuff, void *obj);
451 void *fr_cbuff_rp_next(fr_cbuff_t *cbuff, TALLOC_CTX *ctx);
452 
453 /* debug.c */
454 typedef enum {
455  DEBUG_STATE_UNKNOWN_NO_PTRACE = -3, //!< We don't have ptrace so can't check.
456  DEBUG_STATE_UNKNOWN_NO_PTRACE_CAP = -2, //!< CAP_SYS_PTRACE not set for the process.
457  DEBUG_STATE_UNKNOWN = -1, //!< Unknown, likely fr_get_debug_state() not called yet.
458  DEBUG_STATE_NOT_ATTACHED = 0, //!< We can attach, so a debugger must not be.
459  DEBUG_STATE_ATTACHED = 1 //!< We can't attach, it's likely a debugger is already tracing.
461 
462 #define FR_FAULT_LOG(fmt, ...) fr_fault_log(fmt "\n", ## __VA_ARGS__)
463 typedef void (*fr_fault_log_t)(char const *msg, ...) CC_HINT(format (printf, 1, 2));
465 
466 /** Optional callback passed to fr_fault_setup
467  *
468  * Allows optional logic to be run before calling the main fault handler.
469  *
470  * If the callback returns < 0, the main fault handler will not be called.
471  *
472  * @param signum signal raised.
473  * @return
474  * - 0 on success.
475  * - < 0 on failure.
476  */
477 typedef int (*fr_fault_cb_t)(int signum);
478 typedef struct fr_bt_marker fr_bt_marker_t;
479 
480 void fr_store_debug_state(void);
482 void fr_debug_break(bool always);
483 void backtrace_print(fr_cbuff_t *cbuff, void *obj);
484 int fr_backtrace_do(fr_bt_marker_t *marker);
485 fr_bt_marker_t *fr_backtrace_attach(fr_cbuff_t **cbuff, TALLOC_CTX *obj);
486 
487 void fr_panic_on_free(TALLOC_CTX *ctx);
488 int fr_set_dumpable_init(void);
490 int fr_reset_dumpable(void);
491 int fr_log_talloc_report(TALLOC_CTX *ctx);
492 void fr_fault(int sig);
493 void fr_talloc_fault_setup(void);
494 int fr_fault_setup(char const *cmd, char const *program);
495 void fr_fault_set_cb(fr_fault_cb_t func);
496 void fr_fault_set_log_fd(int fd);
497 void fr_fault_log(char const *msg, ...) CC_HINT(format (printf, 1, 2));
498 
499 # ifdef WITH_VERIFY_PTR
500 void fr_pair_verify(char const *file, int line, VALUE_PAIR const *vp);
501 void fr_pair_list_verify(char const *file, int line, TALLOC_CTX *expected, VALUE_PAIR *vps);
502 # endif
503 
504 bool fr_assert_cond(char const *file, int line, char const *expr, bool cond);
505 # define fr_assert(_x) fr_assert_cond(__FILE__, __LINE__, #_x, (_x))
506 
507 void NEVER_RETURNS _fr_exit(char const *file, int line, int status);
508 # define fr_exit(_x) _fr_exit(__FILE__, __LINE__, (_x))
509 
510 void NEVER_RETURNS _fr_exit_now(char const *file, int line, int status);
511 # define fr_exit_now(_x) _fr_exit_now(__FILE__, __LINE__, (_x))
512 
513 /* rbtree.c */
514 typedef struct rbtree_t rbtree_t;
515 typedef struct rbnode_t rbnode_t;
516 
517 /* callback order for walking */
518 typedef enum {
523 } rb_order_t;
524 
525 #define RBTREE_FLAG_NONE (0)
526 #define RBTREE_FLAG_REPLACE (1 << 0)
527 #define RBTREE_FLAG_LOCK (1 << 1)
528 
529 typedef int (*rb_comparator_t)(void const *ctx, void const *data);
530 typedef int (*rb_walker_t)(void *ctx, void *data);
531 typedef void (*rb_free_t)(void *data);
532 
533 rbtree_t *rbtree_create(TALLOC_CTX *ctx, rb_comparator_t compare, rb_free_t node_free, int flags);
534 void rbtree_free(rbtree_t *tree);
535 bool rbtree_insert(rbtree_t *tree, void *data);
537 void rbtree_delete(rbtree_t *tree, rbnode_t *z);
538 bool rbtree_deletebydata(rbtree_t *tree, void const *data);
539 rbnode_t *rbtree_find(rbtree_t *tree, void const *data);
540 void *rbtree_finddata(rbtree_t *tree, void const *data);
541 uint32_t rbtree_num_elements(rbtree_t *tree);
542 void *rbtree_node2data(rbtree_t *tree, rbnode_t *node);
543 
544 /*
545  * The callback should be declared as:
546  * int callback(void *context, void *data)
547  *
548  * The "context" is some user-defined context.
549  * The "data" is the pointer to the user data in the node,
550  * NOT the node itself.
551  *
552  * It should return 0 if all is OK, and !0 for any error.
553  * The walking will stop on any error.
554  *
555  * Except with RBTREE_DELETE_ORDER, where the callback should return <0 for
556  * errors, and may return 1 to delete the current node and halt,
557  * or 2 to delete the current node and continue. This may be
558  * used to batch-delete select nodes from a locked rbtree.
559  */
560 int rbtree_walk(rbtree_t *tree, rb_order_t order, rb_walker_t compare, void *context);
561 
562 /*
563  * FIFOs
564  */
565 typedef struct fr_fifo_t fr_fifo_t;
566 typedef void (*fr_fifo_free_t)(void *);
567 fr_fifo_t *fr_fifo_create(TALLOC_CTX *ctx, int max_entries, fr_fifo_free_t freeNode);
568 void fr_fifo_free(fr_fifo_t *fi);
569 int fr_fifo_push(fr_fifo_t *fi, void *data);
570 void *fr_fifo_pop(fr_fifo_t *fi);
571 void *fr_fifo_peek(fr_fifo_t *fi);
572 unsigned int fr_fifo_num_elements(fr_fifo_t *fi);
573 
574 /*
575  * socket.c
576  */
577 int fr_socket_client_unix(char const *path, bool async);
578 int fr_socket_client_udp(fr_ipaddr_t *src_ipaddr, fr_ipaddr_t *dst_ipaddr, uint16_t dst_port, bool async);
579 int fr_socket_client_tcp(fr_ipaddr_t *src_ipaddr, fr_ipaddr_t *dst_ipaddr, uint16_t dst_port, bool async);
580 int fr_socket_wait_for_connect(int sockfd, struct timeval const *timeout);
581 int fr_socket_server_base(int proto, fr_ipaddr_t *ipaddr, int *port, char const *port_name, bool async);
582 int fr_socket_server_bind(int sockfd, fr_ipaddr_t *ipaddr, int *port, char const *interface);
583 
584 #ifdef __cplusplus
585 }
586 #endif
587 
588 #include <freeradius-devel/packet.h>
589 
590 #ifdef WITH_TCP
591 # include <freeradius-devel/tcp.h>
592 #endif
593 
594 #endif /* _FR_LIBRADIUS_H */
int8_t(* fr_cmp_t)(void const *a, void const *b)
Definition: pair.h:227
int fr_radius_decode_tlv_ok(uint8_t const *data, size_t length, size_t dv_type, size_t dv_length)
Check if a set of RADIUS formatted TLVs are OK.
int(* fr_fault_cb_t)(int signum)
Optional callback passed to fr_fault_setup.
Definition: libradius.h:477
void fr_cursor_copy(vp_cursor_t *out, vp_cursor_t *in)
Copy a cursor.
Definition: cursor.c:95
bool lock
Perform thread synchronisation.
Definition: cbuff.c:48
int sockfd
Socket this packet was read from.
Definition: libradius.h:147
void fr_debug_break(bool always)
Break in debugger (if were running under a debugger)
Definition: debug.c:307
static int sockfd
Definition: radclient.c:59
#define RCSIDH(h, id)
Definition: build.h:136
FILE * fr_log_fp
Definition: radius.c:81
VALUE_PAIR * fr_cursor_first(vp_cursor_t *cursor)
Rewind cursor to the start of the list.
Definition: cursor.c:105
bool is_zero(char const *value)
Check whether the string is all zeros.
Definition: misc.c:365
int id
Packet ID (used to link requests/responses).
Definition: libradius.h:154
struct timeval timestamp
When we received the packet.
Definition: libradius.h:159
int fr_radius_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret)
Calculate/check digest, and decode radius attributes.
Definition: radius.c:1485
void rbtree_free(rbtree_t *tree)
Definition: rbtree.c:84
#define FR_MAX_PACKET_CODE
Definition: libradius.h:370
void fr_radius_print_hex(RADIUS_PACKET *packet)
Definition: radius.c:172
int fr_socket_client_tcp(fr_ipaddr_t *src_ipaddr, fr_ipaddr_t *dst_ipaddr, uint16_t dst_port, bool async)
Establish a connected TCP socket.
Definition: socket.c:167
int fr_radius_encode_pair(uint8_t *out, size_t outlen, vp_cursor_t *cursor, void *encoder_ctx)
Encode a data structure into a RADIUS attribute.
VALUE_PAIR * fr_cursor_last(vp_cursor_t *cursor)
Wind cursor to the last pair in the list.
Definition: cursor.c:126
int rad_lockfd(int fd, int lock_len)
Definition: misc.c:141
RADIUS_PACKET * fr_radius_copy(TALLOC_CTX *ctx, RADIUS_PACKET const *in)
Duplicate a RADIUS_PACKET.
Definition: radius.c:1751
int fr_blocking(int fd)
int fr_nonblock(int fd)
bool rbtree_deletebydata(rbtree_t *tree, void const *data)
Delete a node from the tree, based on given data, which MUST have come from rbtree_finddata().
Definition: rbtree.c:496
void fr_fault_set_cb(fr_fault_cb_t func)
Set a callback to be called before fr_fault()
Definition: debug.c:1043
Dictionary attribute.
Definition: dict.h:77
int(* rb_comparator_t)(void const *ctx, void const *data)
Definition: libradius.h:529
rbnode_t * rbtree_find(rbtree_t *tree, void const *data)
Find an element in the tree, returning the data, not the node.
Definition: rbtree.c:511
void fr_radius_recv_discard(int sockfd)
VALUE_PAIR * fr_cursor_next_by_num(vp_cursor_t *cursor, unsigned int vendor, unsigned int attr, int8_t tag)
Iterate over a collection of VALUE_PAIRs of a given type in the pairlist.
Definition: cursor.c:200
int8_t fr_pointer_cmp(void const *a, void const *b)
Compares two pointers.
Definition: misc.c:958
char const * fr_packet_codes[FR_MAX_PACKET_CODE]
Definition: radius.c:101
struct fr_bt_marker fr_bt_marker_t
Definition: libradius.h:478
uint32_t fr_rand(void)
Return a 32-bit random number.
Definition: radius.c:1621
rbnode_t * rbtree_insert_node(rbtree_t *tree, void *data)
Insert an element into the tree.
Definition: rbtree.c:258
decode_fail_t
Definition: libradius.h:173
fr_ipaddr_t src_ipaddr
Src IP address of packet.
Definition: libradius.h:149
void fr_rand_seed(void const *, size_t)
Seed the random number generator.
Definition: radius.c:1569
char const * secret
Definition: libradius.h:269
void fr_radius_make_secret(uint8_t *digest, uint8_t const *vector, char const *secret, uint8_t const *value)
Build an encrypted secret value to return in a reply packet.
Definition: radius.c:272
void(* sig_t)(int)
Definition: libradius.h:111
#define CC_HINT(_x)
Definition: build.h:71
int fr_socket_client_unix(char const *path, bool async)
int fr_reset_dumpable(void)
Reset dumpable state to previously configured value.
Definition: debug.c:573
uint32_t randmem[256]
Definition: libradius.h:430
VALUE_PAIR * vps
Result of decoding the packet into VALUE_PAIRs.
Definition: libradius.h:162
int fr_set_dumpable_init(void)
Get the current maximum for core files.
Definition: debug.c:513
char * fr_abin2hex(TALLOC_CTX *ctx, uint8_t const *bin, size_t inlen)
Convert binary data to a hex string.
Definition: misc.c:278
void fr_fifo_free(fr_fifo_t *fi)
Definition: fifo.c:55
VALUE_PAIR * fr_cursor_init(vp_cursor_t *cursor, VALUE_PAIR *const *node)
Setup a cursor to iterate over attribute pairs.
Definition: cursor.c:60
void fr_randinit(fr_randctx *ctx, int flag)
Definition: isaac.c:65
int fr_radius_send(RADIUS_PACKET *, RADIUS_PACKET const *, char const *secret)
Reply to the request.
Definition: radius.c:506
uint8_t length
Definition: proto_bfd.c:203
static float timeout
Definition: radclient.c:43
void * rbtree_finddata(rbtree_t *tree, void const *data)
Find the user data.
Definition: rbtree.c:537
int fr_log_talloc_report(TALLOC_CTX *ctx)
Generate a talloc memory report for a context and print to stderr/stdout.
Definition: debug.c:810
Definition: fifo.c:29
uint8_t * data
Packet data (body).
Definition: libradius.h:160
void fr_timespec_subtract(struct timespec *out, struct timespec const *end, struct timespec const *start)
Subtract one timespec from another.
Definition: misc.c:881
int fr_radius_encode_password(char *encpw, size_t *len, char const *secret, uint8_t const *vector)
Encode password.
ssize_t fr_radius_decode_password(char *encpw, size_t len, char const *secret, uint8_t const *vector)
Decode password.
uint16_t dst_port
DST Port of packet.
Definition: libradius.h:152
int fr_backtrace_do(fr_bt_marker_t *marker)
rb_order_t
Definition: libradius.h:518
uint16_t src_port
Src port of packet.
Definition: libradius.h:151
fr_ipaddr_t dst_ipaddr
Dst IP address of packet.
Definition: libradius.h:150
int fr_get_time(char const *date_str, time_t *date)
Convert string in various formats to a time_t.
Definition: misc.c:716
int fr_debug_lvl
Definition: misc.c:40
ssize_t fr_radius_encode_value_hton(uint8_t const **out, VALUE_PAIR const *vp)
Converts vp_data to network byte order.
Abstraction to allow iterating over different configurations of VALUE_PAIRs.
Definition: pair.h:144
size_t fr_snprint(char *out, size_t outlen, char const *in, ssize_t inlen, char quote)
Escape any non printable or non-UTF8 characters in the input string.
Definition: print.c:179
static char const * proto
Definition: radclient.c:63
FR_NAME_NUMBER const fr_request_types[]
Definition: radius.c:52
void NEVER_RETURNS _fr_exit_now(char const *file, int line, int status)
Exit possibly printing a message about why we're exiting.
Definition: debug.c:1130
size_t fr_snprint_len(char const *in, ssize_t inlen, char quote)
Find the length of the buffer required to fully escape a string with fr_prints.
Definition: print.c:371
int fr_fault_setup(char const *cmd, char const *program)
Registers signal handlers to execute panic_action on fatal signal.
Definition: debug.c:890
bool is_integer(char const *value)
Check whether the string is all numbers.
Definition: misc.c:350
uint32_t fr_max_attributes
Definition: radius.c:80
size_t partial
Definition: libradius.h:168
We don't have ptrace so can't check.
Definition: libradius.h:455
void(*) fr_debug_state_ fr_debug_state)
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
Definition: log.c:238
ssize_t fr_radius_decode_pair_value(TALLOC_CTX *ctx, vp_cursor_t *cursor, fr_dict_attr_t const *parent, uint8_t const *data, size_t const attr_len, size_t const packet_len, void *decoder_ctx)
Create any kind of VP from the attribute contents.
void fr_timeval_subtract(struct timeval *out, struct timeval const *end, struct timeval const *start)
Subtract one timeval from another.
Definition: misc.c:856
int fr_check_lib_magic(uint64_t magic)
Check if the application linking to the library has the correct magic number.
Definition: version.c:38
uint32_t randc
Definition: libradius.h:433
bool is_printable(void const *value, size_t len)
Check whether the string is made up of printable UTF8 chars.
Definition: misc.c:329
int value_data_cast(TALLOC_CTX *ctx, value_data_t *dst, PW_TYPE dst_type, fr_dict_attr_t const *dst_enumv, PW_TYPE src_type, fr_dict_attr_t const *src_enumv, value_data_t const *src)
Convert one type of value_data_t to another.
Definition: value.c:1073
rbtree_t * rbtree_create(TALLOC_CTX *ctx, rb_comparator_t compare, rb_free_t node_free, int flags)
Create a new RED-BLACK tree.
Definition: rbtree.c:112
int fr_radius_verify(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret)
Verify the Request/Response Authenticator (and Message-Authenticator if present) of a packet...
Definition: radius.c:1144
#define AUTH_VECTOR_LEN
Definition: libradius.h:118
We can't attach, it's likely a debugger is already tracing.
Definition: libradius.h:459
fr_fifo_t * fr_fifo_create(TALLOC_CTX *ctx, int max_entries, fr_fifo_free_t freeNode)
Definition: fifo.c:39
bool fr_radius_ok(RADIUS_PACKET *packet, int flags, decode_fail_t *reason)
See if the data pointed to by PTR is a valid RADIUS packet.
Definition: radius.c:731
void fr_cursor_merge(vp_cursor_t *cursor, VALUE_PAIR *vp)
Merges multiple VALUE_PAIR into the cursor.
Definition: cursor.c:394
void fr_fault(int sig)
Prints a simple backtrace (if execinfo is available) and calls panic_action if set.
Definition: debug.c:629
void fr_store_debug_state(void)
Should be run before using setuid or setgid to get useful results.
Definition: debug.c:258
static char spaces[]
Definition: proto.c:28
void fr_cursor_insert(vp_cursor_t *cursor, VALUE_PAIR *vp)
Insert a single VALUE_PAIR at the end of the list.
Definition: cursor.c:321
size_t fr_hex2bin(uint8_t *bin, size_t outlen, char const *hex, size_t inlen)
Convert hex strings to binary data.
Definition: misc.c:220
void bool fr_assert_cond(char const *file, int line, char const *expr, bool cond)
A soft assertion which triggers the fault handler in debug builds.
Definition: debug.c:1085
RADIUS_PACKET * fr_radius_alloc(TALLOC_CTX *ctx, bool new_vector)
Allocate a new RADIUS_PACKET.
Definition: radius.c:1651
void fr_fault_set_log_fd(int fd)
Set a file descriptor to log memory reports to.
Definition: debug.c:1072
void void fr_perror(char const *,...) CC_HINT(format(printf
We can attach, so a debugger must not be.
Definition: libradius.h:458
int fr_radius_encode_chap_password(uint8_t *output, RADIUS_PACKET *packet, int id, VALUE_PAIR *password)
void(* fr_fault_log_t)(char const *msg,...) CC_HINT(format(printf
Definition: libradius.h:463
void rbtree_delete(rbtree_t *tree, rbnode_t *z)
Definition: rbtree.c:488
unsigned int code
Packet code (type).
Definition: libradius.h:155
int rbtree_walk(rbtree_t *tree, rb_order_t order, rb_walker_t compare, void *context)
Definition: rbtree.c:693
int value_data_steal(TALLOC_CTX *ctx, value_data_t *dst, PW_TYPE type, value_data_t const *src)
Copy value data verbatim moving any buffers to the specified context.
Definition: value.c:1512
Stores an attribute, a value and various bits of other data.
Definition: pair.h:112
CAP_SYS_PTRACE not set for the process.
Definition: libradius.h:456
bool fr_dns_lookups
IP -> hostname lookups?
Definition: inet.c:28
VALUE_PAIR * fr_cursor_current(vp_cursor_t *cursor)
Return the VALUE_PAIR the cursor current points to.
Definition: cursor.c:304
void fr_fault_log(char const *msg,...) CC_HINT(format(printf
int fr_fifo_push(fr_fifo_t *fi, void *data)
Definition: fifo.c:79
bool is_whitespace(char const *value)
Check whether the string is all whitespace.
Definition: misc.c:311
void fr_isaac(fr_randctx *ctx)
Definition: isaac.c:29
ssize_t fr_writev(int fd, struct iovec[], int iovcnt, struct timeval *timeout)
Write out a vector to a file descriptor.
Definition: misc.c:492
int value_data_cmp(PW_TYPE a_type, value_data_t const *a, PW_TYPE b_type, value_data_t const *b)
Compare two values.
Definition: value.c:40
void fr_quick_sort(void const *to_sort[], int min_idx, int max_idx, fr_cmp_t cmp)
Quick sort an array of pointers using a comparator.
Definition: misc.c:997
uint8_t vector[AUTH_VECTOR_LEN]
RADIUS authentication vector.
Definition: libradius.h:157
char const * fr_strerror(void)
Get the last library error.
Definition: log.c:212
ssize_t fr_utf8_to_ucs2(uint8_t *out, size_t outlen, char const *in, size_t inlen)
Convert UTF8 string to UCS2 encoding.
Definition: misc.c:580
int(* rb_walker_t)(void *ctx, void *data)
Definition: libradius.h:530
uint32_t size
Definition: cbuff.c:42
void fr_printf_log(char const *,...) CC_HINT(format(printf
fr_debug_state_t
Definition: libradius.h:454
void * fr_fifo_pop(fr_fifo_t *fi)
Definition: fifo.c:92
int fr_crypt_check(char const *key, char const *salt)
Definition: crypt.c:55
ssize_t fr_radius_len(uint8_t const *data, size_t data_len)
See how big of a packet is in the buffer.
Definition: radius.c:679
int value_data_copy(TALLOC_CTX *ctx, value_data_t *dst, PW_TYPE type, const value_data_t *src)
Copy value data verbatim duplicating any buffers.
Definition: value.c:1479
int if_index
Index of receiving interface.
Definition: libradius.h:148
void fr_panic_on_free(TALLOC_CTX *ctx)
Insert memory into the context of another talloc memory chunk which causes a panic when freed...
Definition: debug.c:449
fr_bt_marker_t * fr_backtrace_attach(fr_cbuff_t **cbuff, TALLOC_CTX *obj)
char const * fr_utf8_strchr(int *chr_len, char const *str, char const *chr)
Return a pointer to the first UTF8 char in a string.
Definition: print.c:140
static bool allow_core_dumps
Definition: mainconfig.c:74
RADIUS_PACKET const * original
Definition: libradius.h:268
int fr_set_dumpable(bool allow_core_dumps)
Enable or disable core dumps.
Definition: debug.c:528
unsigned int state
Definition: proto_bfd.c:200
void(* rb_free_t)(void *data)
Definition: libradius.h:531
uint32_t rounds
for State[0]
Definition: libradius.h:165
uint32_t randrsl[256]
Definition: libradius.h:429
uint8_t data[]
Definition: eap_pwd.h:625
int fr_socket_server_base(int proto, fr_ipaddr_t *ipaddr, int *port, char const *port_name, bool async)
Open an IPv4 / IPv6, and UDP / TCP socket, server side.
Definition: socket.c:422
VALUE_PAIR * fr_cursor_replace(vp_cursor_t *cursor, VALUE_PAIR *new)
Replace the current pair.
Definition: cursor.c:491
ssize_t fr_radius_decode_pair(TALLOC_CTX *ctx, vp_cursor_t *cursor, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decoder_ctx)
Create a "normal" VALUE_PAIR from the given data.
VALUE_PAIR * fr_cursor_next(vp_cursor_t *cursor)
Advanced the cursor to the next VALUE_PAIR.
Definition: cursor.c:263
void fr_radius_free(RADIUS_PACKET **)
Free a RADIUS_PACKET.
Definition: radius.c:1727
bool fr_hostname_lookups
hostname -> IP lookups?
Definition: inet.c:29
uint32_t fr_strtoul(char const *value, char **end)
Consume the integer (or hex) portion of a value string.
Definition: misc.c:296
RADIUS_PACKET * fr_radius_alloc_reply(TALLOC_CTX *ctx, RADIUS_PACKET *)
Allocate a new RADIUS_PACKET response.
Definition: radius.c:1691
size_t data_len
Length of packet data.
Definition: libradius.h:161
char * fr_asprint(TALLOC_CTX *ctx, char const *in, ssize_t inlen, char quote)
Escape string that may contain binary data, and write it to a new buffer.
Definition: print.c:390
bool rbtree_insert(rbtree_t *tree, void *data)
Definition: rbtree.c:329
void void void fr_canonicalize_error(TALLOC_CTX *ctx, char **spaces, char **text, ssize_t slen, char const *msg)
Canonicalize error strings, removing tabs, and generate spaces for error marker.
Definition: log.c:359
int value_data_from_str(TALLOC_CTX *ctx, value_data_t *dst, PW_TYPE *src_type, fr_dict_attr_t const *src_enumv, char const *src, ssize_t src_len, char quote)
Convert string value to a value_data_t type.
Definition: value.c:455
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: radius.c:299
ssize_t fr_radius_decode_tunnel_password(uint8_t *encpw, size_t *len, char const *secret, uint8_t const *vector)
Decode Tunnel-Password encrypted attributes.
Definition: radius_decode.c:36
void fr_cbuff_rp_insert(fr_cbuff_t *cbuff, void *obj)
Insert a new element into the buffer, and steal it from it's original context.
Definition: cbuff.c:108
void * fr_cbuff_rp_next(fr_cbuff_t *cbuff, TALLOC_CTX *ctx)
Remove an item from the buffer, and reparent to ctx.
Definition: cbuff.c:136
unsigned int fr_fifo_num_elements(fr_fifo_t *fi)
Definition: fifo.c:115
static char const * secret
Definition: radclient.c:44
void backtrace_print(fr_cbuff_t *cbuff, void *obj)
int rad_unlockfd(int fd, int lock_len)
Definition: misc.c:191
ssize_t fr_radius_decode_tlv(TALLOC_CTX *ctx, vp_cursor_t *cursor, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decoder_ctx)
Convert TLVs to one or more VPs.
void fr_strerror_printf(char const *,...) CC_HINT(format(printf
void(* fr_fifo_free_t)(void *)
Definition: libradius.h:566
int fr_radius_digest_cmp(uint8_t const *a, uint8_t const *b, size_t length)
Do a comparison of two authentication digests by comparing the FULL digest.
Definition: radius.c:578
int fr_radius_encode(RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret)
Encode a packet.
Definition: radius.c:1318
int fr_talloc_link_ctx(TALLOC_CTX *parent, TALLOC_CTX *child)
Link a parent and a child context, so the child is freed before the parent.
Definition: misc.c:105
uint32_t randb
Definition: libradius.h:432
ssize_t offset
Definition: libradius.h:163
void int fr_set_signal(int sig, sig_t func)
Sets a signal handler using sigaction if available, else signal.
Definition: misc.c:56
struct radius_packet RADIUS_PACKET
struct fr_radius_ctx fr_radius_ctx_t
Unknown, likely fr_get_debug_state() not called yet.
Definition: libradius.h:457
VALUE_PAIR * fr_cursor_remove(vp_cursor_t *cursor)
Remove the current pair.
Definition: cursor.c:433
enum fr_token FR_TOKEN
void fr_talloc_fault_setup(void)
Register talloc fault handlers.
Definition: debug.c:872
VALUE_PAIR * fr_cursor_next_peek(vp_cursor_t *cursor)
Return the next VALUE_PAIR without advancing the cursor.
Definition: cursor.c:294
fr_fifo_free_t freeNode
Definition: fifo.c:33
Standard thread safe circular buffer.
Definition: cbuff.c:39
struct fr_randctx fr_randctx
IPv4/6 prefix.
Definition: inet.h:41
Definition: pair.c:37
int value_data_cmp_op(FR_TOKEN op, PW_TYPE a_type, value_data_t const *a, PW_TYPE b_type, value_data_t const *b)
Compare two attributes using an operator.
Definition: value.c:299
char const * fr_debug_state_to_msg(fr_debug_state_t state)
Return current value of debug_state.
Definition: debug.c:278
void fr_cursor_end(vp_cursor_t *cursor)
Moves cursor past the last attribute to the end.
Definition: cursor.c:164
int rad_lockfd_nonblock(int fd, int lock_len)
Definition: misc.c:166
int fr_utf8_char(uint8_t const *str, ssize_t inlen)
Checks for utf-8, taken from http://www.w3.org/International/questions/qa-forms-utf-8.
Definition: print.c:34
RADIUS_PACKET const * packet
Definition: libradius.h:267
RADIUS_PACKET * fr_radius_recv(TALLOC_CTX *ctx, int fd, int flags)
Receive UDP client requests, and fill in the basics of a RADIUS_PACKET structure. ...
Definition: radius.c:1050
int fr_socket_server_bind(int sockfd, fr_ipaddr_t *ipaddr, int *port, char const *interface)
Bind to an IPv4 / IPv6, and UDP / TCP socket, server side.
Definition: socket.c:615
static char const hex[]
Definition: smbencrypt.c:34
#define NEVER_RETURNS
Definition: libradius.h:133
int fr_socket_client_udp(fr_ipaddr_t *src_ipaddr, fr_ipaddr_t *dst_ipaddr, uint16_t dst_port, bool async)
Establish a connected UDP socket.
Definition: socket.c:273
size_t fr_snprint_uint128(char *out, size_t outlen, uint128_t const num)
Write 128bit unsigned integer to buffer.
Definition: misc.c:633
VALUE_PAIR * fr_cursor_next_by_da(vp_cursor_t *cursor, fr_dict_attr_t const *da, int8_t tag) CC_HINT(nonnull)
Iterate over attributes of a given DA in the pairlist.
Definition: cursor.c:237
uint32_t randcnt
Definition: libradius.h:428
void fr_cursor_free(vp_cursor_t *cursor)
Free the current pair and all pairs after it.
Definition: cursor.c:528
int fr_socket_wait_for_connect(int sockfd, struct timeval const *timeout)
Wait for a socket to be connected, with an optional timeout.
Definition: socket.c:359
int fr_radius_encode_tunnel_password(char *encpw, size_t *len, char const *secret, uint8_t const *vector)
Encode Tunnel-Password attributes when sending them out on the wire.
void NEVER_RETURNS _fr_exit(char const *file, int line, int status)
Exit possibly printing a message about why we're exiting.
Definition: debug.c:1106
uint32_t randa
Definition: libradius.h:431
void * rbtree_node2data(rbtree_t *tree, rbnode_t *node)
char * value_data_asprint(TALLOC_CTX *ctx, PW_TYPE type, fr_dict_attr_t const *enumv, value_data_t const *data, char quote)
Print one attribute value to a string.
Definition: value.c:1543
int fr_timeval_from_str(struct timeval *out, char const *in)
Create timeval from a string.
Definition: misc.c:907
size_t fr_bin2hex(char *hex, uint8_t const *bin, size_t inlen)
Convert binary data to a hex string.
Definition: misc.c:254
fr_cbuff_t * fr_cbuff_alloc(TALLOC_CTX *ctx, uint32_t size, bool lock)
PW_TYPE
Internal data types used within libfreeradius.
Definition: radius.h:31
uint32_t rbtree_num_elements(rbtree_t *tree)
Definition: rbtree.c:727
int fr_radius_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret)
Sign a previously encoded packet.
Definition: radius.c:389
size_t value_data_snprint(char *out, size_t outlen, PW_TYPE type, fr_dict_attr_t const *enumv, value_data_t const *data, char quote)
Print the value of an attribute to a string.
Definition: value.c:1727
void * fr_fifo_peek(fr_fifo_t *fi)
Definition: fifo.c:108