All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
libradius.h File Reference
#include <freeradius-devel/build.h>
#include <freeradius-devel/features.h>
#include <talloc.h>
#include <freeradius-devel/missing.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdbool.h>
#include <signal.h>
#include <freeradius-devel/threads.h>
#include <freeradius-devel/radius.h>
#include <freeradius-devel/token.h>
#include <freeradius-devel/hash.h>
#include <freeradius-devel/inet.h>
#include <freeradius-devel/regex.h>
#include <freeradius-devel/dict.h>
#include <freeradius-devel/pair.h>
#include <freeradius-devel/proto.h>
#include <freeradius-devel/conf.h>
#include <freeradius-devel/radpaths.h>
#include <freeradius-devel/sha1.h>
#include <freeradius-devel/md4.h>
#include <freeradius-devel/packet.h>
#include <freeradius-devel/tcp.h>
+ Include dependency graph for libradius.h:

Go to the source code of this file.

Data Structures

struct  fr_radius_ctx
 
struct  fr_randctx
 
struct  radius_packet
 

Macros

#define AUTH_PASS_LEN   (AUTH_VECTOR_LEN)
 
#define AUTH_VECTOR_LEN   16
 
#define BLANK_FORMAT   " " /* GCC_LINT whines about empty formats */
 
#define CHAP_VALUE_LENGTH   16
 
#define fr_assert(_x)   fr_assert_cond(__FILE__, __LINE__, #_x, (_x))
 
#define fr_exit(_x)   _fr_exit(__FILE__, __LINE__, (_x))
 
#define fr_exit_now(_x)   _fr_exit_now(__FILE__, __LINE__, (_x))
 
#define FR_FAULT_LOG(fmt,...)   fr_fault_log(fmt "\n", ## __VA_ARGS__)
 
#define FR_MAX_PACKET_CODE   (52)
 
#define FR_TUNNEL_PW_ENC_LENGTH(_x)   (2 + 1 + _x + PAD(_x + 1, 16))
 
#define FREE_MAGIC   (0xF4EEF4EE)
 
#define is_radius_code(_x)   ((_x > 0) && (_x < FR_MAX_PACKET_CODE))
 
#define is_truncated(_ret, _max)   ((_ret) >= (size_t)(_max))
 
#define MAGIC_COMMIT(_x)   ((uint32_t) (_x & 0xffffffff))
 
#define MAGIC_PREFIX(_x)   ((uint8_t) (_x >> 56))
 
#define MAGIC_VERSION(_x)   ((uint32_t) ((_x >> 32) & 0x00ffffff))
 
#define MAX_PASS_LEN   (128)
 
#define MAX_STRING_LEN   254 /* RFC2138: string 0-253 octets */
 
#define NEVER_RETURNS   CC_HINT(noreturn)
 
#define PAD(_x, _y)   (_y - ((_x) % _y))
 
#define PRINTF_LIKE(n)   CC_HINT(format(printf, n, n+1))
 
#define RADIUSD_MAGIC_NUMBER   ((uint64_t) HEXIFY3(f4, RADIUSD_VERSION, 00000000))
 
#define RBTREE_FLAG_LOCK   (1 << 1)
 
#define RBTREE_FLAG_NONE   (0)
 
#define RBTREE_FLAG_REPLACE   (1 << 0)
 
#define RETURN_IF_TRUNCATED(_p, _ret, _max)
 Boilerplate for checking truncation. More...
 
#define truncate_len(_ret, _max)   (((_ret) >= (size_t)(_max)) ? (((size_t)(_max)) - 1) : _ret)
 
#define UNUSED   CC_HINT(unused)
 
#define VERIFY_ALL_TALLOC
 

Typedefs

typedef struct fr_bt_marker fr_bt_marker_t
 
typedef struct fr_cbuff fr_cbuff_t
 
typedef void(*) fr_debug_state_ fr_debug_state )
 
typedef int(* fr_fault_cb_t )(int signum)
 Optional callback passed to fr_fault_setup. More...
 
typedef void(* fr_fault_log_t )(char const *msg,...) CC_HINT(format(printf
 
typedef void(* fr_fifo_free_t )(void *)
 
typedef struct fr_fifo_t fr_fifo_t
 
typedef struct fr_radius_ctx fr_radius_ctx_t
 
typedef struct fr_randctx fr_randctx
 
typedef struct radius_packet RADIUS_PACKET
 
typedef int(* rb_comparator_t )(void const *ctx, void const *data)
 
typedef void(* rb_free_t )(void *data)
 
typedef int(* rb_walker_t )(void *ctx, void *data)
 
typedef struct rbnode_t rbnode_t
 
typedef struct rbtree_t rbtree_t
 
typedef void(* sig_t )(int)
 

Enumerations

enum  decode_fail_t {
  DECODE_FAIL_NONE = 0,
  DECODE_FAIL_MIN_LENGTH_PACKET,
  DECODE_FAIL_MIN_LENGTH_FIELD,
  DECODE_FAIL_MIN_LENGTH_MISMATCH,
  DECODE_FAIL_HEADER_OVERFLOW,
  DECODE_FAIL_UNKNOWN_PACKET_CODE,
  DECODE_FAIL_INVALID_ATTRIBUTE,
  DECODE_FAIL_ATTRIBUTE_TOO_SHORT,
  DECODE_FAIL_ATTRIBUTE_OVERFLOW,
  DECODE_FAIL_MA_INVALID_LENGTH,
  DECODE_FAIL_ATTRIBUTE_UNDERFLOW,
  DECODE_FAIL_TOO_MANY_ATTRIBUTES,
  DECODE_FAIL_MA_MISSING,
  DECODE_FAIL_MAX
}
 
enum  fr_debug_state_t {
  DEBUG_STATE_UNKNOWN_NO_PTRACE = -3,
  DEBUG_STATE_UNKNOWN_NO_PTRACE_CAP = -2,
  DEBUG_STATE_UNKNOWN = -1,
  DEBUG_STATE_NOT_ATTACHED = 0,
  DEBUG_STATE_ATTACHED = 1
}
 
enum  rb_order_t {
  RBTREE_PRE_ORDER,
  RBTREE_IN_ORDER,
  RBTREE_POST_ORDER,
  RBTREE_DELETE_ORDER
}
 

Functions

void NEVER_RETURNS _fr_exit (char const *file, int line, int status)
 Exit possibly printing a message about why we're exiting. More...
 
void NEVER_RETURNS _fr_exit_now (char const *file, int line, int status)
 Exit possibly printing a message about why we're exiting. More...
 
void backtrace_print (fr_cbuff_t *cbuff, void *obj)
 
char * fr_abin2hex (TALLOC_CTX *ctx, uint8_t const *bin, size_t inlen)
 Convert binary data to a hex string. More...
 
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. More...
 
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. More...
 
fr_bt_marker_tfr_backtrace_attach (fr_cbuff_t **cbuff, TALLOC_CTX *obj)
 
int fr_backtrace_do (fr_bt_marker_t *marker)
 
size_t fr_bin2hex (char *hex, uint8_t const *bin, size_t inlen)
 Convert binary data to a hex string. More...
 
int fr_blocking (int fd)
 
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. More...
 
fr_cbuff_tfr_cbuff_alloc (TALLOC_CTX *ctx, uint32_t size, bool lock)
 
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. More...
 
void * fr_cbuff_rp_next (fr_cbuff_t *cbuff, TALLOC_CTX *ctx)
 Remove an item from the buffer, and reparent to ctx. More...
 
int fr_check_lib_magic (uint64_t magic)
 Check if the application linking to the library has the correct magic number. More...
 
int fr_crypt_check (char const *key, char const *salt)
 
void fr_cursor_copy (vp_cursor_t *out, vp_cursor_t *in)
 Copy a cursor. More...
 
VALUE_PAIRfr_cursor_current (vp_cursor_t *cursor)
 Return the VALUE_PAIR the cursor current points to. More...
 
void fr_cursor_end (vp_cursor_t *cursor)
 Moves cursor past the last attribute to the end. More...
 
VALUE_PAIRfr_cursor_first (vp_cursor_t *cursor)
 Rewind cursor to the start of the list. More...
 
void fr_cursor_free (vp_cursor_t *cursor)
 Free the current pair and all pairs after it. More...
 
VALUE_PAIRfr_cursor_init (vp_cursor_t *cursor, VALUE_PAIR *const *node)
 Setup a cursor to iterate over attribute pairs. More...
 
void fr_cursor_insert (vp_cursor_t *cursor, VALUE_PAIR *vp)
 Insert a single VALUE_PAIR at the end of the list. More...
 
VALUE_PAIRfr_cursor_last (vp_cursor_t *cursor)
 Wind cursor to the last pair in the list. More...
 
void fr_cursor_merge (vp_cursor_t *cursor, VALUE_PAIR *vp)
 Merges multiple VALUE_PAIR into the cursor. More...
 
VALUE_PAIRfr_cursor_next (vp_cursor_t *cursor)
 Advanced the cursor to the next VALUE_PAIR. More...
 
VALUE_PAIRfr_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. More...
 
VALUE_PAIRfr_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. More...
 
VALUE_PAIRfr_cursor_next_peek (vp_cursor_t *cursor)
 Return the next VALUE_PAIR without advancing the cursor. More...
 
VALUE_PAIRfr_cursor_remove (vp_cursor_t *cursor)
 Remove the current pair. More...
 
VALUE_PAIRfr_cursor_replace (vp_cursor_t *cursor, VALUE_PAIR *new)
 Replace the current pair. More...
 
void fr_debug_break (bool always)
 Break in debugger (if were running under a debugger) More...
 
char const * fr_debug_state_to_msg (fr_debug_state_t state)
 Return current value of debug_state. More...
 
void fr_fault (int sig)
 Prints a simple backtrace (if execinfo is available) and calls panic_action if set. More...
 
void fr_fault_log (char const *msg,...) CC_HINT(format(printf
 
void fr_fault_set_cb (fr_fault_cb_t func)
 Set a callback to be called before fr_fault() More...
 
void fr_fault_set_log_fd (int fd)
 Set a file descriptor to log memory reports to. More...
 
int fr_fault_setup (char const *cmd, char const *program)
 Registers signal handlers to execute panic_action on fatal signal. More...
 
fr_fifo_tfr_fifo_create (TALLOC_CTX *ctx, int max_entries, fr_fifo_free_t freeNode)
 
void fr_fifo_free (fr_fifo_t *fi)
 
unsigned int fr_fifo_num_elements (fr_fifo_t *fi)
 
void * fr_fifo_peek (fr_fifo_t *fi)
 
void * fr_fifo_pop (fr_fifo_t *fi)
 
int fr_fifo_push (fr_fifo_t *fi, void *data)
 
int fr_get_time (char const *date_str, time_t *date)
 Convert string in various formats to a time_t. More...
 
size_t fr_hex2bin (uint8_t *bin, size_t outlen, char const *hex, size_t inlen)
 Convert hex strings to binary data. More...
 
void fr_isaac (fr_randctx *ctx)
 
int fr_log_talloc_report (TALLOC_CTX *ctx)
 Generate a talloc memory report for a context and print to stderr/stdout. More...
 
int fr_nonblock (int fd)
 
void fr_panic_on_free (TALLOC_CTX *ctx)
 Insert memory into the context of another talloc memory chunk which causes a panic when freed. More...
 
void void fr_perror (char const *,...) CC_HINT(format(printf
 
int8_t fr_pointer_cmp (void const *a, void const *b)
 Compares two pointers. More...
 
void fr_printf_log (char const *,...) CC_HINT(format(printf
 
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. More...
 
RADIUS_PACKETfr_radius_alloc (TALLOC_CTX *ctx, bool new_vector)
 Allocate a new RADIUS_PACKET. More...
 
RADIUS_PACKETfr_radius_alloc_reply (TALLOC_CTX *ctx, RADIUS_PACKET *)
 Allocate a new RADIUS_PACKET response. More...
 
RADIUS_PACKETfr_radius_copy (TALLOC_CTX *ctx, RADIUS_PACKET const *in)
 Duplicate a RADIUS_PACKET. More...
 
int fr_radius_decode (RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret)
 Calculate/check digest, and decode radius attributes. More...
 
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. More...
 
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. More...
 
ssize_t fr_radius_decode_password (char *encpw, size_t len, char const *secret, uint8_t const *vector)
 Decode password. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int fr_radius_encode (RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret)
 Encode a packet. More...
 
int fr_radius_encode_chap_password (uint8_t *output, RADIUS_PACKET *packet, int id, VALUE_PAIR *password)
 
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. More...
 
int fr_radius_encode_password (char *encpw, size_t *len, char const *secret, uint8_t const *vector)
 Encode password. More...
 
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. More...
 
ssize_t fr_radius_encode_value_hton (uint8_t const **out, VALUE_PAIR const *vp)
 Converts vp_data to network byte order. More...
 
void fr_radius_free (RADIUS_PACKET **)
 Free a RADIUS_PACKET. More...
 
ssize_t fr_radius_len (uint8_t const *data, size_t data_len)
 See how big of a packet is in the buffer. More...
 
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. More...
 
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. More...
 
void fr_radius_print_hex (RADIUS_PACKET *packet)
 
RADIUS_PACKETfr_radius_recv (TALLOC_CTX *ctx, int fd, int flags)
 Receive UDP client requests, and fill in the basics of a RADIUS_PACKET structure. More...
 
void fr_radius_recv_discard (int sockfd)
 
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. More...
 
int fr_radius_send (RADIUS_PACKET *, RADIUS_PACKET const *, char const *secret)
 Reply to the request. More...
 
int fr_radius_sign (RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret)
 Sign a previously encoded packet. More...
 
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. More...
 
uint32_t fr_rand (void)
 Return a 32-bit random number. More...
 
void fr_rand_seed (void const *, size_t)
 Seed the random number generator. More...
 
void fr_randinit (fr_randctx *ctx, int flag)
 
int fr_reset_dumpable (void)
 Reset dumpable state to previously configured value. More...
 
int fr_set_dumpable (bool allow_core_dumps)
 Enable or disable core dumps. More...
 
int fr_set_dumpable_init (void)
 Get the current maximum for core files. More...
 
void int fr_set_signal (int sig, sig_t func)
 Sets a signal handler using sigaction if available, else signal. More...
 
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. More...
 
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. More...
 
size_t fr_snprint_uint128 (char *out, size_t outlen, uint128_t const num)
 Write 128bit unsigned integer to buffer. More...
 
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. More...
 
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. More...
 
int fr_socket_client_unix (char const *path, bool async)
 
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. More...
 
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. More...
 
int fr_socket_wait_for_connect (int sockfd, struct timeval const *timeout)
 Wait for a socket to be connected, with an optional timeout. More...
 
void fr_store_debug_state (void)
 Should be run before using setuid or setgid to get useful results. More...
 
char const * fr_strerror (void)
 Get the last library error. More...
 
void fr_strerror_printf (char const *,...) CC_HINT(format(printf
 
uint32_t fr_strtoul (char const *value, char **end)
 Consume the integer (or hex) portion of a value string. More...
 
char const * fr_syserror (int num)
 Guaranteed to be thread-safe version of strerror. More...
 
void fr_talloc_fault_setup (void)
 Register talloc fault handlers. More...
 
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. More...
 
void fr_timespec_subtract (struct timespec *out, struct timespec const *end, struct timespec const *start)
 Subtract one timespec from another. More...
 
int fr_timeval_from_str (struct timeval *out, char const *in)
 Create timeval from a string. More...
 
void fr_timeval_subtract (struct timeval *out, struct timeval const *end, struct timeval const *start)
 Subtract one timeval from another. More...
 
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. More...
 
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. More...
 
ssize_t fr_utf8_to_ucs2 (uint8_t *out, size_t outlen, char const *in, size_t inlen)
 Convert UTF8 string to UCS2 encoding. More...
 
ssize_t fr_writev (int fd, struct iovec[], int iovcnt, struct timeval *timeout)
 Write out a vector to a file descriptor. More...
 
bool is_integer (char const *value)
 Check whether the string is all numbers. More...
 
bool is_printable (void const *value, size_t len)
 Check whether the string is made up of printable UTF8 chars. More...
 
bool is_whitespace (char const *value)
 Check whether the string is all whitespace. More...
 
bool is_zero (char const *value)
 Check whether the string is all zeros. More...
 
int rad_lockfd (int fd, int lock_len)
 
int rad_lockfd_nonblock (int fd, int lock_len)
 
int rad_unlockfd (int fd, int lock_len)
 
rbtree_trbtree_create (TALLOC_CTX *ctx, rb_comparator_t compare, rb_free_t node_free, int flags)
 Create a new RED-BLACK tree. More...
 
void rbtree_delete (rbtree_t *tree, rbnode_t *z)
 
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(). More...
 
rbnode_trbtree_find (rbtree_t *tree, void const *data)
 Find an element in the tree, returning the data, not the node. More...
 
void * rbtree_finddata (rbtree_t *tree, void const *data)
 Find the user data. More...
 
void rbtree_free (rbtree_t *tree)
 
bool rbtree_insert (rbtree_t *tree, void *data)
 
rbnode_trbtree_insert_node (rbtree_t *tree, void *data)
 Insert an element into the tree. More...
 
void * rbtree_node2data (rbtree_t *tree, rbnode_t *node)
 
uint32_t rbtree_num_elements (rbtree_t *tree)
 
int rbtree_walk (rbtree_t *tree, rb_order_t order, rb_walker_t compare, void *context)
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Variables

int fr_debug_lvl
 
bool fr_dns_lookups
 IP -> hostname lookups? More...
 
bool fr_hostname_lookups
 hostname -> IP lookups? More...
 
FILE * fr_log_fp
 
uint32_t fr_max_attributes
 
char const * fr_packet_codes [FR_MAX_PACKET_CODE]
 
FR_NAME_NUMBER const fr_request_types []
 

Data Structure Documentation

struct fr_radius_ctx

Definition at line 266 of file libradius.h.

+ Collaboration diagram for fr_radius_ctx:
Data Fields
RADIUS_PACKET const * original
RADIUS_PACKET const * packet
char const * secret
struct fr_randctx

Definition at line 427 of file libradius.h.

Data Fields
uint32_t randa
uint32_t randb
uint32_t randc
uint32_t randcnt
uint32_t randmem[256]
uint32_t randrsl[256]
struct radius_packet

Definition at line 146 of file libradius.h.

+ Collaboration diagram for radius_packet:
Data Fields
unsigned int code Packet code (type).
uint8_t * data Packet data (body).
size_t data_len Length of packet data.
fr_ipaddr_t dst_ipaddr Dst IP address of packet.
uint16_t dst_port DST Port of packet.
int id Packet ID (used to link requests/responses).
int if_index Index of receiving interface.
ssize_t offset
size_t partial
int proto
uint32_t rounds for State[0]
int sockfd Socket this packet was read from.
fr_ipaddr_t src_ipaddr Src IP address of packet.
uint16_t src_port Src port of packet.
struct timeval timestamp When we received the packet.
uint8_t vector[AUTH_VECTOR_LEN] RADIUS authentication vector.
VALUE_PAIR * vps Result of decoding the packet into VALUE_PAIRs.

Macro Definition Documentation

#define AUTH_PASS_LEN   (AUTH_VECTOR_LEN)

Definition at line 230 of file libradius.h.

#define AUTH_VECTOR_LEN   16

Definition at line 118 of file libradius.h.

#define BLANK_FORMAT   " " /* GCC_LINT whines about empty formats */

Definition at line 135 of file libradius.h.

#define CHAP_VALUE_LENGTH   16

Definition at line 119 of file libradius.h.

#define fr_assert (   _x)    fr_assert_cond(__FILE__, __LINE__, #_x, (_x))

Definition at line 505 of file libradius.h.

#define fr_exit (   _x)    _fr_exit(__FILE__, __LINE__, (_x))

Definition at line 508 of file libradius.h.

#define fr_exit_now (   _x)    _fr_exit_now(__FILE__, __LINE__, (_x))

Definition at line 511 of file libradius.h.

#define FR_FAULT_LOG (   fmt,
  ... 
)    fr_fault_log(fmt "\n", ## __VA_ARGS__)

Definition at line 462 of file libradius.h.

#define FR_MAX_PACKET_CODE   (52)

Definition at line 370 of file libradius.h.

#define FR_TUNNEL_PW_ENC_LENGTH (   _x)    (2 + 1 + _x + PAD(_x + 1, 16))

Definition at line 232 of file libradius.h.

#define FREE_MAGIC   (0xF4EEF4EE)

Definition at line 115 of file libradius.h.

#define is_radius_code (   _x)    ((_x > 0) && (_x < FR_MAX_PACKET_CODE))

Definition at line 372 of file libradius.h.

#define is_truncated (   _ret,
  _max 
)    ((_ret) >= (size_t)(_max))

Definition at line 204 of file libradius.h.

#define MAGIC_COMMIT (   _x)    ((uint32_t) (_x & 0xffffffff))

Definition at line 55 of file libradius.h.

#define MAGIC_PREFIX (   _x)    ((uint8_t) (_x >> 56))

Definition at line 53 of file libradius.h.

#define MAGIC_VERSION (   _x)    ((uint32_t) ((_x >> 32) & 0x00ffffff))

Definition at line 54 of file libradius.h.

#define MAX_PASS_LEN   (128)

Definition at line 231 of file libradius.h.

#define MAX_STRING_LEN   254 /* RFC2138: string 0-253 octets */

Definition at line 120 of file libradius.h.

#define NEVER_RETURNS   CC_HINT(noreturn)

Definition at line 133 of file libradius.h.

#define PAD (   _x,
  _y 
)    (_y - ((_x) % _y))

Definition at line 130 of file libradius.h.

#define PRINTF_LIKE (   n)    CC_HINT(format(printf, n, n+1))

Definition at line 132 of file libradius.h.

#define RADIUSD_MAGIC_NUMBER   ((uint64_t) HEXIFY3(f4, RADIUSD_VERSION, 00000000))

Definition at line 51 of file libradius.h.

#define RBTREE_FLAG_LOCK   (1 << 1)

Definition at line 527 of file libradius.h.

#define RBTREE_FLAG_NONE   (0)

Definition at line 525 of file libradius.h.

#define RBTREE_FLAG_REPLACE   (1 << 0)

Definition at line 526 of file libradius.h.

#define RETURN_IF_TRUNCATED (   _p,
  _ret,
  _max 
)
Value:
do { \
if (is_truncated(_ret, _max)) { \
size_t _r = (_p - out) + _ret; \
_p += truncate_len(_ret, _max); \
*_p = '\0'; \
return _r; \
} \
_p += _ret; \
} while (0)
#define is_truncated(_ret, _max)
Definition: libradius.h:204
#define truncate_len(_ret, _max)
Definition: libradius.h:205

Boilerplate for checking truncation.

If truncation has occurred, advance _p as far as possible without overrunning the output buffer, and \0 terminate. Then return the length of the buffer we would have needed to write the full value.

If truncation has not occurred, advance _p by whatever the copy or print function returned.

Definition at line 216 of file libradius.h.

#define truncate_len (   _ret,
  _max 
)    (((_ret) >= (size_t)(_max)) ? (((size_t)(_max)) - 1) : _ret)

Definition at line 205 of file libradius.h.

#define UNUSED   CC_HINT(unused)

Definition at line 134 of file libradius.h.

#define VERIFY_ALL_TALLOC

Definition at line 416 of file libradius.h.

Typedef Documentation

typedef struct fr_bt_marker fr_bt_marker_t

Definition at line 478 of file libradius.h.

typedef struct fr_cbuff fr_cbuff_t

Definition at line 447 of file libradius.h.

typedef void(*) fr_debug_state_ fr_debug_state)
typedef int(* fr_fault_cb_t)(int signum)

Optional callback passed to fr_fault_setup.

Allows optional logic to be run before calling the main fault handler.

If the callback returns < 0, the main fault handler will not be called.

Parameters
signumsignal raised.
Returns
  • 0 on success.
  • < 0 on failure.

Definition at line 477 of file libradius.h.

typedef void(* fr_fault_log_t)(char const *msg,...) CC_HINT(format(printf

Definition at line 463 of file libradius.h.

typedef void(* fr_fifo_free_t)(void *)

Definition at line 566 of file libradius.h.

typedef struct fr_fifo_t fr_fifo_t

Definition at line 565 of file libradius.h.

typedef struct fr_randctx fr_randctx
typedef struct radius_packet RADIUS_PACKET
typedef int(* rb_comparator_t)(void const *ctx, void const *data)

Definition at line 529 of file libradius.h.

typedef void(* rb_free_t)(void *data)

Definition at line 531 of file libradius.h.

typedef int(* rb_walker_t)(void *ctx, void *data)

Definition at line 530 of file libradius.h.

typedef struct rbnode_t rbnode_t

Definition at line 515 of file libradius.h.

typedef struct rbtree_t rbtree_t

Definition at line 514 of file libradius.h.

typedef void(* sig_t)(int)

Definition at line 111 of file libradius.h.

Enumeration Type Documentation

Enumerator
DECODE_FAIL_NONE 
DECODE_FAIL_MIN_LENGTH_PACKET 
DECODE_FAIL_MIN_LENGTH_FIELD 
DECODE_FAIL_MIN_LENGTH_MISMATCH 
DECODE_FAIL_HEADER_OVERFLOW 
DECODE_FAIL_UNKNOWN_PACKET_CODE 
DECODE_FAIL_INVALID_ATTRIBUTE 
DECODE_FAIL_ATTRIBUTE_TOO_SHORT 
DECODE_FAIL_ATTRIBUTE_OVERFLOW 
DECODE_FAIL_MA_INVALID_LENGTH 
DECODE_FAIL_ATTRIBUTE_UNDERFLOW 
DECODE_FAIL_TOO_MANY_ATTRIBUTES 
DECODE_FAIL_MA_MISSING 
DECODE_FAIL_MAX 

Definition at line 173 of file libradius.h.

Enumerator
DEBUG_STATE_UNKNOWN_NO_PTRACE 

We don't have ptrace so can't check.

DEBUG_STATE_UNKNOWN_NO_PTRACE_CAP 

CAP_SYS_PTRACE not set for the process.

DEBUG_STATE_UNKNOWN 

Unknown, likely fr_get_debug_state() not called yet.

DEBUG_STATE_NOT_ATTACHED 

We can attach, so a debugger must not be.

DEBUG_STATE_ATTACHED 

We can't attach, it's likely a debugger is already tracing.

Definition at line 454 of file libradius.h.

enum rb_order_t
Enumerator
RBTREE_PRE_ORDER 
RBTREE_IN_ORDER 
RBTREE_POST_ORDER 
RBTREE_DELETE_ORDER 

Definition at line 518 of file libradius.h.

Function Documentation

void NEVER_RETURNS _fr_exit ( char const *  file,
int  line,
int  status 
)

Exit possibly printing a message about why we're exiting.

Note
Use the fr_exit(status) macro instead of calling this function directly.
Parameters
filewhere fr_exit() was called.
linewhere fr_exit() was called.
statuswe're exiting with.

Definition at line 1106 of file debug.c.

+ Here is the call graph for this function:

void NEVER_RETURNS _fr_exit_now ( char const *  file,
int  line,
int  status 
)

Exit possibly printing a message about why we're exiting.

Note
Use the fr_exit_now(status) macro instead of calling this function directly.
Parameters
filewhere fr_exit_now() was called.
linewhere fr_exit_now() was called.
statuswe're exiting with.

Definition at line 1130 of file debug.c.

+ Here is the call graph for this function:

void backtrace_print ( fr_cbuff_t cbuff,
void *  obj 
)
char* fr_abin2hex ( TALLOC_CTX *  ctx,
uint8_t const *  bin,
size_t  inlen 
)

Convert binary data to a hex string.

Ascii encoded hex string will not be prefixed with '0x'

Parameters
[in]ctxto alloc buffer in.
[in]bininput.
[in]inlenof bin input.
Returns
length of data written to buffer.

Definition at line 278 of file misc.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

This is useful in situations where we expect printable strings as input, but under some conditions may get binary data. A good example is libldap and the arrays of struct berval ldap_get_values_len returns.

Parameters
[in]ctxTo allocate new buffer in.
[in]inString to escape.
[in]inlenLength of string. Should be >= 0 if the data may contain embedded \0s. Must be >= 0 if data may not be \0 terminated. If < 0 inlen will be calculated using strlen.
[in]quotethe quotation character.
Returns
new buffer holding the escaped string.

Definition at line 390 of file print.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Parameters
filethe assertion failed in.
lineof the assertion in the file.
exprthat was evaluated.
condResult of evaluating the expression.
Returns
the value of cond.

Definition at line 1085 of file debug.c.

+ Here is the call graph for this function:

fr_bt_marker_t* fr_backtrace_attach ( fr_cbuff_t **  cbuff,
TALLOC_CTX *  obj 
)
int fr_backtrace_do ( fr_bt_marker_t marker)
size_t fr_bin2hex ( char *  hex,
uint8_t const *  bin,
size_t  inlen 
)

Convert binary data to a hex string.

Ascii encoded hex string will not be prefixed with '0x'

Warning
If the output buffer isn't long enough, we have a buffer overflow.
Parameters
[out]hexBuffer to write hex output.
[in]bininput.
[in]inlenof bin input.
Returns
length of data written to buffer.

Definition at line 254 of file misc.c.

+ Here is the caller graph for this function:

int fr_blocking ( int  fd)

+ Here is the caller graph for this function:

void void void fr_canonicalize_error ( TALLOC_CTX *  ctx,
char **  sp,
char **  text,
ssize_t  slen,
char const *  msg 
)

Canonicalize error strings, removing tabs, and generate spaces for error marker.

Note
talloc_free must be called on the buffer returned in spaces and text

Used to produce error messages such as this:

 I'm a string with a parser # error
                            ^ Unexpected character in string

With code resembling this:

ERROR("%s", parsed_str);
ERROR("%s^ %s", space, text);
Todo:
merge with above function (radlog_request_marker)
Parameters
spWhere to write a dynamically allocated buffer of spaces used to indent the error text.
textWhere to write the canonicalized version of msg (the error text).
ctxto allocate the spaces and text buffers in.
slenof error marker. Expects negative integer value, as returned by parse functions.
msgto canonicalize.

Definition at line 359 of file log.c.

+ Here is the caller graph for this function:

fr_cbuff_t* fr_cbuff_alloc ( TALLOC_CTX *  ctx,
uint32_t  size,
bool  lock 
)
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.

cbuff will steal obj and insert it into it's own context.

Parameters
cbuffto insert element into
objto insert, must of been allocated with talloc

Definition at line 108 of file cbuff.c.

void* fr_cbuff_rp_next ( fr_cbuff_t cbuff,
TALLOC_CTX *  ctx 
)

Remove an item from the buffer, and reparent to ctx.

Parameters
cbuffto remove element from
ctxto hang obj off.
Returns
  • NULL if no elements in the buffer.
  • An element from the buffer reparented to ctx.

Definition at line 136 of file cbuff.c.

int fr_check_lib_magic ( uint64_t  magic)

Check if the application linking to the library has the correct magic number.

Parameters
magicnumber as defined by RADIUSD_MAGIC_NUMBER
Returns
  • 0 on success.
  • -1 on prefix mismatch.
  • -2 on version mismatch.
  • -3 on commit mismatch.

Definition at line 38 of file version.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_crypt_check ( char const *  key,
char const *  salt 
)

Definition at line 55 of file crypt.c.

+ Here is the call graph for this function:

void fr_cursor_copy ( vp_cursor_t out,
vp_cursor_t in 
)

Copy a cursor.

Parameters
inCursor to copy.
outWhere to copy the cursor to.

Definition at line 95 of file cursor.c.

VALUE_PAIR* fr_cursor_current ( vp_cursor_t cursor)

Return the VALUE_PAIR the cursor current points to.

Parameters
cursorto operate on.
Returns
the VALUE_PAIR the cursor currently points to.

Definition at line 304 of file cursor.c.

+ Here is the caller graph for this function:

void fr_cursor_end ( vp_cursor_t cursor)

Moves cursor past the last attribute to the end.

Primarily useful for setting up the cursor for freeing attributes added during the execution of a function, which later errors out, requiring only the attribute(s) that it added to be freed, and the attributes already present in the list to remain untouched.

int my_cursor_insert_func(vp_cursor_t *cursor)
{
fr_cursor_end(cursor);
fr_cursor_insert(cursor, fr_pair_alloc_by_num(NULL, 0, PW_MESSAGE_AUTHENTICATOR));
if (bad_thing) {
fr_cursor_free(cursor);
return -1;
}
return 0;
}
Parameters
cursorto operate on.

Definition at line 164 of file cursor.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_PAIR* fr_cursor_first ( vp_cursor_t cursor)

Rewind cursor to the start of the list.

Parameters
cursorto operate on.
Returns
VALUE_PAIR at the start of the list.

Definition at line 105 of file cursor.c.

+ Here is the caller graph for this function:

void fr_cursor_free ( vp_cursor_t cursor)

Free the current pair and all pairs after it.

Note
Use fr_cursor_remove and talloc_free to free single pairs.

Will move the cursor back one, then free the current pair and all VALUE_PAIRs after it.

Usually used in conjunction with fr_cursor_end and fr_cursor_insert.

Parameters
cursorto free pairs in.

Definition at line 528 of file cursor.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_PAIR* fr_cursor_init ( vp_cursor_t cursor,
VALUE_PAIR *const *  const_vp 
)

Setup a cursor to iterate over attribute pairs.

Parameters
cursorWhere to initialise the cursor (uses existing structure).
const_vpto start from.
Returns
the attribute pointed to by vp.

Definition at line 60 of file cursor.c.

+ Here is the caller graph for this function:

void fr_cursor_insert ( vp_cursor_t cursor,
VALUE_PAIR vp 
)

Insert a single VALUE_PAIR at the end of the list.

Note
Will not advance cursor position to new attribute, but will set cursor to this attribute, if it's the first one in the list.

Insert a VALUE_PAIR at the end of the list.

Parameters
cursorto operate on.
vpto insert.

Definition at line 321 of file cursor.c.

+ Here is the caller graph for this function:

VALUE_PAIR* fr_cursor_last ( vp_cursor_t cursor)

Wind cursor to the last pair in the list.

Parameters
cursorto operate on.
Returns
VALUE_PAIR at the end of the list.

Definition at line 126 of file cursor.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_cursor_merge ( vp_cursor_t cursor,
VALUE_PAIR add 
)

Merges multiple VALUE_PAIR into the cursor.

Add multiple VALUE_PAIR from add to cursor.

Parameters
cursorto insert VALUE_PAIRs with
addone or more VALUE_PAIRs (may be NULL, which results in noop).

Definition at line 394 of file cursor.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_PAIR* fr_cursor_next ( vp_cursor_t cursor)

Advanced the cursor to the next VALUE_PAIR.

Parameters
cursorto operate on.
Returns

Definition at line 263 of file cursor.c.

+ Here is the caller graph for this function:

VALUE_PAIR* fr_cursor_next_by_da ( vp_cursor_t cursor,
fr_dict_attr_t const *  da,
int8_t  tag 
)

Iterate over attributes of a given DA in the pairlist.

Find the next attribute of a given type. If no fr_cursor_next_by_* function has been called on a cursor before, or the previous call returned NULL, the search will start with the current attribute. Subsequent calls to fr_cursor_next_by_* functions will start the search from the previously matched attribute.

Note
fr_dict_attr_t pointers are compared, not the attribute numbers and vendors.
Parameters
cursorto operate on.
dato match.
tagto match. Either a tag number or TAG_ANY to match any tagged or untagged attribute, TAG_NONE to match attributes without tags.
Returns

Definition at line 237 of file cursor.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Find the next attribute of a given type. If no fr_cursor_next_by_* function has been called on a cursor before, or the previous call returned NULL, the search will start with the current attribute. Subsequent calls to fr_cursor_next_by_* functions will start the search from the previously matched attribute.

Parameters
cursorto operate on.
attrnumber to match.
vendornumber to match (0 for none vendor attribute).
tagto match. Either a tag number or TAG_ANY to match any tagged or untagged attribute, TAG_NONE to match attributes without tags.
Returns

Definition at line 200 of file cursor.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_PAIR* fr_cursor_next_peek ( vp_cursor_t cursor)

Return the next VALUE_PAIR without advancing the cursor.

Parameters
cursorto operate on.
Returns

Definition at line 294 of file cursor.c.

+ Here is the caller graph for this function:

VALUE_PAIR* fr_cursor_remove ( vp_cursor_t cursor)

Remove the current pair.

Todo:
this is really inefficient and should be fixed...

The current VP will be set to the one before the VP being removed, this is so the commonly used check and remove loop (below) works as expected.

for (vp = fr_cursor_init(&cursor, head);
vp;
vp = fr_cursor_next(&cursor) {
if (<condition>) {
vp = fr_cursor_remove(&cursor);
talloc_free(vp);
}
}
Parameters
cursorto remove the current pair from.
Returns

Definition at line 433 of file cursor.c.

+ Here is the caller graph for this function:

VALUE_PAIR* fr_cursor_replace ( vp_cursor_t cursor,
VALUE_PAIR new 
)

Replace the current pair.

Todo:
this is really inefficient and should be fixed...
Parameters
cursorto replace the current pair in.
newVALUE_PAIR to insert.
Returns

Definition at line 491 of file cursor.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_debug_break ( bool  always)

Break in debugger (if were running under a debugger)

If the server is running under a debugger this will raise a SIGTRAP which will pause the running process.

If the server is not running under debugger then this will do nothing.

Definition at line 307 of file debug.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char const* fr_debug_state_to_msg ( fr_debug_state_t  state)

Return current value of debug_state.

Parameters
stateto translate into a humanly readable value.
Returns
humanly readable version of debug state.

Definition at line 278 of file debug.c.

+ Here is the caller graph for this function:

void fr_fault ( int  sig)

Prints a simple backtrace (if execinfo is available) and calls panic_action if set.

Parameters
sigcaught

Definition at line 629 of file debug.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_fault_log ( char const *  msg,
  ... 
)
void fr_fault_set_cb ( fr_fault_cb_t  func)

Set a callback to be called before fr_fault()

Parameters
functo execute. If callback returns < 0 fr_fault will exit before running panic_action code.

Definition at line 1043 of file debug.c.

+ Here is the caller graph for this function:

void fr_fault_set_log_fd ( int  fd)

Set a file descriptor to log memory reports to.

Parameters
fdto write output to.

Definition at line 1072 of file debug.c.

+ Here is the caller graph for this function:

int fr_fault_setup ( char const *  cmd,
char const *  program 
)

Registers signal handlers to execute panic_action on fatal signal.

May be called multiple time to change the panic_action/program.

Parameters
cmdto execute on fault. If present p will be substituted for the parent PID before the command is executed, and e will be substituted for the currently running program.
programName of program currently executing (argv[0]).
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 890 of file debug.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_fifo_t* fr_fifo_create ( TALLOC_CTX *  ctx,
int  max_entries,
fr_fifo_free_t  freeNode 
)

Definition at line 39 of file fifo.c.

+ Here is the caller graph for this function:

void fr_fifo_free ( fr_fifo_t fi)

Definition at line 55 of file fifo.c.

unsigned int fr_fifo_num_elements ( fr_fifo_t fi)

Definition at line 115 of file fifo.c.

+ Here is the caller graph for this function:

void* fr_fifo_peek ( fr_fifo_t fi)

Definition at line 108 of file fifo.c.

+ Here is the caller graph for this function:

void* fr_fifo_pop ( fr_fifo_t fi)

Definition at line 92 of file fifo.c.

+ Here is the caller graph for this function:

int fr_fifo_push ( fr_fifo_t fi,
void *  data 
)

Definition at line 79 of file fifo.c.

+ Here is the caller graph for this function:

int fr_get_time ( char const *  date_str,
time_t *  date 
)

Convert string in various formats to a time_t.

Parameters
date_strinput date string.
datetime_t to write result to.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 716 of file misc.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t fr_hex2bin ( uint8_t *  bin,
size_t  outlen,
char const *  hex,
size_t  inlen 
)

Convert hex strings to binary data.

Parameters
binBuffer to write output to.
outlenlength of output buffer (or length of input string / 2).
hexinput string.
inlenlength of the input string
Returns
length of data written to buffer.

Definition at line 220 of file misc.c.

+ Here is the caller graph for this function:

void fr_isaac ( fr_randctx ctx)

Definition at line 29 of file isaac.c.

+ Here is the caller graph for this function:

int fr_log_talloc_report ( TALLOC_CTX *  ctx)

Generate a talloc memory report for a context and print to stderr/stdout.

Parameters
ctxto generate a report for, may be NULL in which case the root context is used.

Definition at line 810 of file debug.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_nonblock ( int  fd)

+ Here is the caller graph for this function:

void fr_panic_on_free ( TALLOC_CTX *  ctx)

Insert memory into the context of another talloc memory chunk which causes a panic when freed.

Parameters
ctxTALLOC_CTX to monitor for frees.

Definition at line 449 of file debug.c.

+ Here is the call graph for this function:

void void fr_perror ( char const *  ,
  ... 
)

+ Here is the caller graph for this function:

int8_t fr_pointer_cmp ( void const *  a,
void const *  b 
)

Compares two pointers.

Parameters
afirst pointer to compare.
bsecond pointer to compare.
Returns
  • -1 if a < b.
  • +1 if b > a.
  • 0 if both equal.

Definition at line 958 of file misc.c.

+ Here is the caller graph for this function:

void fr_printf_log ( char const *  ,
  ... 
)
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.

Parameters
to_sortarray of pointers to sort.
min_idxthe lowest index (usually 0).
max_idxthe highest index (usually length of array - 1).
cmpthe comparison function to use to sort the array elements.

Definition at line 997 of file misc.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RADIUS_PACKET* fr_radius_alloc ( TALLOC_CTX *  ctx,
bool  new_vector 
)

Allocate a new RADIUS_PACKET.

Parameters
ctxthe context in which the packet is allocated. May be NULL if the packet is not associated with a REQUEST.
new_vectorif true a new request authenticator will be generated.
Returns
  • New RADIUS_PACKET.
  • NULL on error.

Definition at line 1651 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RADIUS_PACKET* fr_radius_alloc_reply ( TALLOC_CTX *  ctx,
RADIUS_PACKET packet 
)

Allocate a new RADIUS_PACKET response.

Parameters
ctxthe context in which the packet is allocated. May be NULL if the packet is not associated with a REQUEST.
packetThe request packet.
Returns
  • New RADIUS_PACKET.
  • NULL on error.

Definition at line 1691 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RADIUS_PACKET* fr_radius_copy ( TALLOC_CTX *  ctx,
RADIUS_PACKET const *  in 
)

Duplicate a RADIUS_PACKET.

Parameters
ctxthe context in which the packet is allocated. May be NULL if the packet is not associated with a REQUEST.
inThe packet to copy
Returns
  • New RADIUS_PACKET.
  • NULL on error.

Definition at line 1751 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_radius_decode ( RADIUS_PACKET packet,
RADIUS_PACKET original,
char const *  secret 
)

Calculate/check digest, and decode radius attributes.

Returns
  • 0 on success
  • -1 on decoding error.

Definition at line 1485 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Definition at line 1337 of file radius_decode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

"length" is AT LEAST the length of this attribute, as we expect the caller to have verified the data with fr_radius_ok(). "length" may be up to the length of the packet.

Returns
  • Length on success.
  • -1 on failure.

Definition at line 809 of file radius_decode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ssize_t fr_radius_decode_password ( char *  passwd,
size_t  pwlen,
char const *  secret,
uint8_t const *  vector 
)

Decode password.

Definition at line 142 of file radius_decode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Definition at line 349 of file radius_decode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Definition at line 202 of file radius_decode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ssize_t fr_radius_decode_tunnel_password ( uint8_t *  passwd,
size_t *  pwlen,
char const *  secret,
uint8_t const *  vector 
)

Decode Tunnel-Password encrypted attributes.

Defined in RFC-2868, this uses a two char SALT along with the initial intermediate value, to differentiate it from the above.

Definition at line 36 of file radius_decode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Otherwise, the server can be subject to timing attacks that allow attackers find a valid message authenticator.

http://www.cs.rice.edu/~dwallach/pub/crosby-timing2009.pdf

Definition at line 578 of file radius.c.

+ Here is the caller graph for this function:

int fr_radius_encode ( RADIUS_PACKET packet,
RADIUS_PACKET const *  original,
char const *  secret 
)

Encode a packet.

Definition at line 1318 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_radius_encode_chap_password ( uint8_t *  output,
RADIUS_PACKET packet,
int  id,
VALUE_PAIR password 
)

+ Here is the caller graph for this function:

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.

This is the main entry point into the encoder. It sets up the encoder array we use for tracking our TLV/VSA/EVS nesting and then calls the appropriate dispatch function.

Definition at line 1488 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_radius_encode_password ( char *  passwd,
size_t *  pwlen,
char const *  secret,
uint8_t const *  vector 
)

Encode password.

We assume that the passwd buffer passed is big enough. RFC2138 says the password is max 128 chars, so the size of the passwd buffer must be at least 129 characters. Preferably it's just MAX_STRING_LEN.

int *pwlen is updated to the new length of the encrypted password - a multiple of 16 bytes.

Definition at line 187 of file radius_encode.c.

+ Here is the call graph for this function:

int fr_radius_encode_tunnel_password ( char *  passwd,
size_t *  pwlen,
char const *  secret,
uint8_t const *  vector 
)

Encode Tunnel-Password attributes when sending them out on the wire.

int *pwlen is updated to the new length of the encrypted password - a multiple of 16 bytes.

This is per RFC-2868 which adds a two char SALT to the initial intermediate value MD5 hash.

Definition at line 106 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ssize_t fr_radius_encode_value_hton ( uint8_t const **  out,
VALUE_PAIR const *  vp 
)

Converts vp_data to network byte order.

Provide a pointer to a buffer which contains the value of the VALUE_PAIR in an architecture independent format.

The pointer is only guaranteed to be valid between calls to fr_radius_encode_value_hton, and so long as the source VALUE_PAIR is not freed.

Parameters
outwhere to write the pointer to the value.
vpto get the value from.
Returns
  • The length of the value.
  • -1 on failure.

Definition at line 396 of file radius_encode.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_radius_free ( RADIUS_PACKET **  radius_packet_ptr)

Free a RADIUS_PACKET.

Definition at line 1727 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ssize_t fr_radius_len ( uint8_t const *  data,
size_t  data_len 
)

See how big of a packet is in the buffer.

Packet is not 'const * const' because we may update data_len, if there's more data in the UDP packet than in the RADIUS packet.

Parameters
datapointer to the packet buffer
data_lenlength of the packet buffer
Returns
<= 0 packet is bad. >0 how much of the data is a packet (can be larger than data_len)

Definition at line 679 of file radius.c.

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.

The secret is hidden by xoring with a MD5 digest created from the shared secret and the authentication vector. We put them into MD5 in the reverse order from that used when encrypting passwords to RADIUS.

Definition at line 272 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Packet is not 'const * const' because we may update data_len, if there's more data in the UDP packet than in the RADIUS packet.

Parameters
packetto check
flagsto control decoding
reasonif not NULL, will have the failure reason written to where it points.
Returns
  • True on success.
  • False on failure.

Definition at line 731 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_radius_print_hex ( RADIUS_PACKET packet)

Definition at line 172 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 at line 1050 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_radius_recv_discard ( int  sockfd)
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.

Note
fr_strerror errors are only available if fr_debug_lvl > 0. This is to reduce CPU time consumed when discarding malformed packet.
Parameters
[in]sockfdwe're reading from.
[out]src_ipaddrof the packet.
[out]src_portof the packet.
[out]codePointer to where to write the packet code.
Returns
  • -1 on failure.
  • 1 on decode error.
  • >= RADIUS_HDR_LEN on success. This is the packet length as specified in the header.

Definition at line 299 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_radius_send ( RADIUS_PACKET packet,
RADIUS_PACKET const *  original,
char const *  secret 
)

Reply to the request.

Also attach reply attribute value pairs and any user message provided.

Definition at line 506 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_radius_sign ( RADIUS_PACKET packet,
RADIUS_PACKET const *  original,
char const *  secret 
)

Sign a previously encoded packet.

Definition at line 389 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 at line 1144 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32_t fr_rand ( void  )

Return a 32-bit random number.

Definition at line 1621 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_rand_seed ( void const *  data,
size_t  size 
)

Seed the random number generator.

May be called any number of times.

Definition at line 1569 of file radius.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_randinit ( fr_randctx ctx,
int  flag 
)

Definition at line 65 of file isaac.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_reset_dumpable ( void  )

Reset dumpable state to previously configured value.

Needed after suid up/down

Returns
  • 0 on success.
  • -1 on failure.

Definition at line 573 of file debug.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_set_dumpable ( bool  allow_core_dumps)

Enable or disable core dumps.

Parameters
allow_core_dumpswhether to enable or disable core dumps.

Definition at line 528 of file debug.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_set_dumpable_init ( void  )

Get the current maximum for core files.

Do this before anything else so as to ensure it's properly initialized.

Definition at line 513 of file debug.c.

+ Here is the call graph for this function:

void int fr_set_signal ( int  sig,
sig_t  func 
)

Sets a signal handler using sigaction if available, else signal.

Parameters
sigto set handler for.
funchandler to set.

Definition at line 56 of file misc.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Note
Return value should be checked with is_truncated
Will always \0 terminate unless outlen == 0.
Parameters
[in]instring to escape.
[in]inlenlength of string to escape (lets us deal with embedded NULs)
[out]outwhere to write the escaped string.
[out]outlenthe length of the buffer pointed to by out.
[in]quotethe quotation character
Returns
  • The number of bytes written to the out buffer.
  • A number >= outlen if truncation has occurred.

Definition at line 179 of file print.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Were assuming here that's it's cheaper to figure out the length and do one alloc than repeatedly expand the buffer when we find extra chars which need to be added.

Parameters
instring to calculate the escaped length for.
inlenlength of the input string, if < 0 strlen will be used to check the length.
[in]quotethe quotation character.
Returns
the size of buffer required to hold the escaped string including the NUL byte.

Definition at line 371 of file print.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t fr_snprint_uint128 ( char *  out,
size_t  outlen,
uint128_t const  num 
)

Write 128bit unsigned integer to buffer.

Author
Alexey Frunze
Parameters
outwhere to write result to.
outlensize of out.
num128 bit integer.

Definition at line 633 of file misc.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

The following code demonstrates using this function with a connection timeout:

sockfd = fr_socket_client_tcp(NULL, ipaddr, port, true);
if (sockfd < 0) {
exit(1);
}
if ((errno == EINPROGRESS) && (fr_socket_wait_for_connect(sockfd, timeout) < 0)) {
error:
close(sockfd);
goto error;
}
//Optionally, if blocking operation is required
if (fr_blocking(sockfd) < 0) goto error;
Parameters
src_ipaddrto bind socket to, may be NULL if socket is not bound to any specific address.
dst_ipaddrWhere to connect to.
dst_portWhere to connect to.
asyncWhether to set the socket to nonblocking, allowing use of fr_socket_wait_for_connect.
Returns
  • FD on success
  • -1 on failure.

Definition at line 167 of file socket.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Connected UDP sockets can be used with write(), unlike unconnected sockets which must be used with sendto and recvfrom.

The following code demonstrates using this function with a connection timeout:

sockfd = fr_socket_client_udp(NULL, ipaddr, port, true);
if (sockfd < 0) {
exit(1);
}
if ((errno == EINPROGRESS) && (fr_socket_wait_for_connect(sockfd, timeout) < 0)) {
error:
close(sockfd);
goto error;
}
//Optionally, if blocking operation is required
if (fr_blocking(sockfd) < 0) goto error;
Parameters
src_ipaddrto bind socket to, may be NULL if socket is not bound to any specific address.
dst_ipaddrWhere to send datagrams.
dst_portWhere to send datagrams.
asyncWhether to set the socket to nonblocking, allowing use of fr_socket_wait_for_connect.
Returns
  • FD on success.
  • -1 on failure.

Definition at line 273 of file socket.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_socket_client_unix ( char const *  path,
bool  async 
)

+ Here is the caller graph for this function:

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.

Parameters
[in]protoIPPROTO_UDP or IPPROTO_TCP
[in]ipaddrThe IP address to listen on
[in,out]portthe port to listen on
[in]port_nameif port==0, the name of the port
[in]asyncwhether we block or not on reads and writes
Returns
  • Socket FD on success.
  • -1 on failure.

Definition at line 422 of file socket.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Parameters
[in]sockfdthe socket which was opened via fr_socket_server_base()
[in,out]ipaddrThe IP address to bind to
[in]portthe port to bind to
[in]interfacethe interface name to bind to
Returns
  • 0 on success
  • -1 on failure.

Definition at line 615 of file socket.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_socket_wait_for_connect ( int  sockfd,
struct timeval const *  timeout 
)

Wait for a socket to be connected, with an optional timeout.

Note
On error the caller is expected to close(sockfd).
Parameters
sockfdthe socket to wait on.
timeoutHow long to wait for socket to open.
Returns
  • 0 on success.
  • -1 on connection error.
  • -2 on timeout.
  • -3 on select error.

Definition at line 359 of file socket.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_store_debug_state ( void  )

Should be run before using setuid or setgid to get useful results.

Note
sets the fr_debug_state global.

Definition at line 258 of file debug.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char const* fr_strerror ( void  )

Get the last library error.

Will only return the last library error once, after which it will return a zero length string.

Returns
library error or zero length string.

Definition at line 212 of file log.c.

+ Here is the caller graph for this function:

void fr_strerror_printf ( char const *  ,
  ... 
)
uint32_t fr_strtoul ( char const *  value,
char **  end 
)

Consume the integer (or hex) portion of a value string.

Parameters
valuestring to parse.
endpointer to the first non numeric char.
Returns
integer value.

Definition at line 296 of file misc.c.

+ Here is the caller graph for this function:

char const* fr_syserror ( int  num)

Guaranteed to be thread-safe version of strerror.

Parameters
numerrno as returned by function or from global errno.
Returns
local specific error string relating to errno.

Definition at line 238 of file log.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_talloc_fault_setup ( void  )

Register talloc fault handlers.

Just register the fault handlers we need to make talloc produce useful debugging output.

Definition at line 872 of file debug.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Note
This is not thread safe. Do not free parent before threads are joined, do not call from a child thread.
It's OK to free the child before threads are joined, but this will leak memory until the parent is freed.
Parameters
parentwho's fate the child should share.
childbound to parent's lifecycle.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 105 of file misc.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_timespec_subtract ( struct timespec *  out,
struct timespec const *  end,
struct timespec const *  start 
)

Subtract one timespec from another.

Parameters
[out]outWhere to write difference.
[in]endTime closest to the present.
[in]startTime furthest in the past.

Definition at line 881 of file misc.c.

int fr_timeval_from_str ( struct timeval *  out,
char const *  in 
)

Create timeval from a string.

Parameters
[out]outWhere to write timeval.
[in]inString to parse.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 907 of file misc.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_timeval_subtract ( struct timeval *  out,
struct timeval const *  end,
struct timeval const *  start 
)

Subtract one timeval from another.

Parameters
[out]outWhere to write difference.
[in]endTime closest to the present.
[in]startTime furthest in the past.

Definition at line 856 of file misc.c.

+ Here is the caller graph for this function:

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.

Parameters
strinput string.
inlenlength of input string. May be -1 if str is \0 terminated.

Definition at line 34 of file print.c.

+ Here is the caller graph for this function:

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.

Parameters
[out]chr_lenWhere to write the length of the multibyte char passed in chr (may be NULL).
[in]strHaystack.
[in]chrMultibyte needle.
Returns
  • Position of chr in str.
  • NULL if not found.

Definition at line 140 of file print.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ssize_t fr_utf8_to_ucs2 ( uint8_t *  out,
size_t  outlen,
char const *  in,
size_t  inlen 
)

Convert UTF8 string to UCS2 encoding.

Note
Borrowed from src/crypto/ms_funcs.c of wpa_supplicant project (http://hostap.epitest.fi/wpa_supplicant/)
Parameters
[out]outWhere to write the ucs2 string.
[in]outlenSize of output buffer.
[in]inUTF8 string to convert.
[in]inlenlength of UTF8 string.
Returns
the size of the UCS2 string written to the output buffer (in bytes).

Definition at line 580 of file misc.c.

+ Here is the caller graph for this function:

ssize_t fr_writev ( int  fd,
struct iovec  vector[],
int  iovcnt,
struct timeval *  timeout 
)

Write out a vector to a file descriptor.

Wraps writev, calling it as necessary. If timeout is not NULL, timeout is applied to each call that returns EAGAIN or EWOULDBLOCK

Note
Should only be used on nonblocking file descriptors.
Socket should likely be closed on timeout.
iovec may be modified in such a way that it's not re-usable.
Leaves errno set to the last error that occurred.
Parameters
fdto write to.
vectorto write.
iovcntnumber of elements in iovec.
timeouthow long to wait for fd to become writeable before timing out.
Returns
  • Number of bytes written.
  • -1 on failure.

Definition at line 492 of file misc.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool is_integer ( char const *  value)

Check whether the string is all numbers.

Returns
  • true if the entirety of the string is number chars.
  • false if string contains no number chars.

Definition at line 350 of file misc.c.

+ Here is the caller graph for this function:

bool is_printable ( void const *  value,
size_t  len 
)

Check whether the string is made up of printable UTF8 chars.

Parameters
valueto check.
lenof value.
Returns
  • true if the string is printable.
  • false if the string contains non printable chars

Definition at line 329 of file misc.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool is_whitespace ( char const *  value)

Check whether the string is all whitespace.

Returns
  • true if the entirety of the string is whitespace.
  • false if the string contains non whitespace.

Definition at line 311 of file misc.c.

+ Here is the caller graph for this function:

bool is_zero ( char const *  value)

Check whether the string is all zeros.

Returns
  • true if the entirety of the string is all zeros.
  • false if string contains no zeros.

Definition at line 365 of file misc.c.

int rad_lockfd ( int  fd,
int  lock_len 
)

Definition at line 141 of file misc.c.

+ Here is the caller graph for this function:

int rad_lockfd_nonblock ( int  fd,
int  lock_len 
)

Definition at line 166 of file misc.c.

+ Here is the caller graph for this function:

int rad_unlockfd ( int  fd,
int  lock_len 
)

Definition at line 191 of file misc.c.

+ Here is the caller graph for this function:

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 at line 112 of file rbtree.c.

+ Here is the caller graph for this function:

void rbtree_delete ( rbtree_t tree,
rbnode_t z 
)

Definition at line 488 of file rbtree.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 at line 496 of file rbtree.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rbnode_t* rbtree_find ( rbtree_t tree,
void const *  data 
)

Find an element in the tree, returning the data, not the node.

Definition at line 511 of file rbtree.c.

+ Here is the caller graph for this function:

void* rbtree_finddata ( rbtree_t tree,
void const *  data 
)

Find the user data.

Definition at line 537 of file rbtree.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void rbtree_free ( rbtree_t tree)

Definition at line 84 of file rbtree.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool rbtree_insert ( rbtree_t tree,
void *  data 
)

Definition at line 329 of file rbtree.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rbnode_t* rbtree_insert_node ( rbtree_t tree,
void *  data 
)

Insert an element into the tree.

Definition at line 258 of file rbtree.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* rbtree_node2data ( rbtree_t tree,
rbnode_t node 
)

+ Here is the caller graph for this function:

uint32_t rbtree_num_elements ( rbtree_t tree)

Definition at line 727 of file rbtree.c.

+ Here is the caller graph for this function:

int rbtree_walk ( rbtree_t tree,
rb_order_t  order,
rb_walker_t  compare,
void *  context 
)

Definition at line 693 of file rbtree.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 at line 1543 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Note
This should be the canonical function used to convert between data types.
Parameters
ctxto allocate buffers in (usually the same as dst)
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvEnumerated values used to converts strings to integers.
src_typeto cast from.
src_enumvEnumerated values used to convert integers to strings.
srcInput data.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1073 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Parameters
[in]a_typeof data to compare.
[in]aValue to compare.
[in]b_typeof data to compare.
[in]bValue to compare.
Returns
  • -1 if a is less than b.
  • 0 if both are equal.
  • 1 if a is more than b.
  • < -1 on failure.

Definition at line 40 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Parameters
[in]opto use in comparison.
[in]a_typeof data to compare.
[in]aValue to compare.
[in]b_typeof data to compare.
[in]bValue to compare.
Returns
  • 1 if true
  • 0 if false
  • -1 on failure.

Definition at line 299 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int value_data_copy ( TALLOC_CTX *  ctx,
value_data_t dst,
PW_TYPE  src_type,
const value_data_t src 
)

Copy value data verbatim duplicating any buffers.

Parameters
ctxTo allocate buffers in.
dstWhere to copy value_data to.
src_typeType of src.
srcWhere to copy value_data from.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1479 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Parameters
[in]ctxto alloc strings in.
[out]dstwhere to write parsed value.
[in,out]src_typeof value data to create/type of value created.
[in]src_enumvfr_dict_attr_t with string aliases for integer values.
[in]srcString to convert. Binary safe for variable length values if len is provided.
[in]src_lenmay be < 0 in which case strlen(len) is used to determine length, else src_len should be the length of the string or sub string to parse.
[in]quotequotation character used to drive de-escaping
Returns
  • 0 on success.
  • -1 on parse error.

Definition at line 455 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Note
return value should be checked with is_truncated.
Will always \0 terminate unless outlen == 0.
Parameters
outWhere to write the printed version of the attribute value.
outlenLength of the output buffer.
typeof data being printed.
enumvEnumerated string values for integer types.
datato print.
quotechar to escape in string output.
Returns
  • The number of bytes written to the out buffer.
  • A number >= outlen if truncation has occurred.

Definition at line 1727 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int value_data_steal ( TALLOC_CTX *  ctx,
value_data_t dst,
PW_TYPE  src_type,
const value_data_t src 
)

Copy value data verbatim moving any buffers to the specified context.

Parameters
ctxTo allocate buffers in.
dstWhere to copy value_data to.
src_typeType of src.
srcWhere to copy value_data from.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1512 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

int fr_debug_lvl

Definition at line 40 of file misc.c.

bool fr_dns_lookups

IP -> hostname lookups?

Definition at line 28 of file inet.c.

bool fr_hostname_lookups

hostname -> IP lookups?

Definition at line 29 of file inet.c.

FILE* fr_log_fp

Definition at line 81 of file radius.c.

uint32_t fr_max_attributes

Definition at line 80 of file radius.c.

char const* fr_packet_codes[FR_MAX_PACKET_CODE]

Definition at line 101 of file radius.c.

FR_NAME_NUMBER const fr_request_types[]

Definition at line 52 of file radius.c.