Radcli library 1.5.3
A simple radius library
Loading...
Searching...
No Matches
Main API

Main API Functions. More...

Data Structures

struct  server
struct  dict_attr
struct  dict_value
struct  dict_vendor
struct  rc_value_pair
struct  send_data

Macros

#define TRUE   1
#define FALSE   0
#define AUTH_PASS_LEN   (8 * 16) /* multiple of 16 */
#define AUTH_ID_LEN   64
#define RC_BUFFER_LEN   8192
#define RC_MAX_PACKET_LEN   4096 /* RFC 2865: maximum RADIUS packet size */
#define RC_NAME_LENGTH   64
#define MAX_SECRET_LENGTH   (16 * 16) /* MUST be multiple of 16 */
#define RADCLI_VENDOR_MASK   0xffffffff
#define VENDOR_BIT_SIZE   32
#define RADCLI_VENDOR_ATTR_SET(attr, vendor)
#define VENDOR(x)
#define ATTRID(x)
#define PW_MAX_MSG_SIZE   4096
#define RC_SERVER_MAX   8
#define AUTH_LOCAL_FST   (1<<0)
#define AUTH_RADIUS_FST   (1<<1)
#define AUTH_LOCAL_SND   (1<<2)
#define AUTH_RADIUS_SND   (1<<3)
#define AUTH_HDR_LEN   20
#define CHAP_VALUE_LENGTH   16
#define PW_AUTH_UDP_PORT   1812
#define PW_ACCT_UDP_PORT   1813
#define PW_DUMB   0
 1 and 2 are defined in FRAMED PROTOCOLS.
#define PW_AUTH_ONLY   3
#define PW_ALL   255
#define MGMT_POLL_SECRET   "Hardlyasecret"
 Default for Merit radiusd.
#define AUTH_STRING_LEN   253 /* maximum of 253 */
#define AUTH_VECTOR_LEN   16
#define RC_MIN(a, b)
#define RC_MAX(a, b)
#define PATH_MAX   1024
#define ENV_SIZE   128

Typedefs

typedef enum rc_type rc_type
typedef struct rc_conf rc_handle
typedef struct server SERVER
typedef enum rc_socket_type rc_socket_type
typedef enum rc_attr_type rc_attr_type
typedef enum rc_standard_codes rc_standard_codes
typedef enum rc_attr_id rc_attr_id
typedef enum rc_service_type rc_service_type
typedef enum rc_framed_protocol rc_framed_protocol
typedef enum rc_framed_routing_type rc_framed_routing_type
typedef enum rc_framed_comp rc_framed_comp
typedef enum rc_login_service_type rc_login_service_type
typedef enum rc_termination_action rc_termination_action
typedef enum rc_acct_status_type rc_acct_status_type
typedef enum rc_acct_terminate_cause rc_acct_terminate_cause
typedef enum rc_nas_port_type rc_nas_port_type
typedef enum rc_acct_auth_type rc_acct_auth_type
typedef enum rc_vendor_pec rc_vendor_type
typedef struct dict_attr DICT_ATTR
typedef struct dict_value DICT_VALUE
typedef struct dict_vendor DICT_VENDOR
typedef enum rc_send_status rc_send_status
typedef struct rc_value_pair VALUE_PAIR
typedef struct send_data SEND_DATA
typedef struct rc_aaa_ctx_st RC_AAA_CTX

Enumerations

enum  rc_type { AUTH = 0 , ACCT = 1 }
enum  rc_socket_type { RC_SOCKET_UDP = 0 , RC_SOCKET_TLS = 1 , RC_SOCKET_DTLS = 2 , RC_SOCKET_TCP = 3 }
enum  rc_attr_type {
  PW_TYPE_STRING =0 , PW_TYPE_INTEGER =1 , PW_TYPE_IPADDR =2 , PW_TYPE_DATE =3 ,
  PW_TYPE_IPV6ADDR =4 , PW_TYPE_IPV6PREFIX =5 , PW_TYPE_MAX =6
}
enum  rc_standard_codes {
  PW_ACCESS_REQUEST =1 , PW_ACCESS_ACCEPT =2 , PW_ACCESS_REJECT =3 , PW_ACCOUNTING_REQUEST =4 ,
  PW_ACCOUNTING_RESPONSE =5 , PW_ACCOUNTING_STATUS =6 , PW_PASSWORD_REQUEST =7 , PW_PASSWORD_ACK =8 ,
  PW_PASSWORD_REJECT =9 , PW_ACCOUNTING_MESSAGE =10 , PW_ACCESS_CHALLENGE =11 , PW_STATUS_SERVER =12 ,
  PW_STATUS_CLIENT =13
}
enum  rc_attr_id {
  PW_USER_NAME =1 , PW_USER_PASSWORD =2 , PW_CHAP_PASSWORD =3 , PW_NAS_IP_ADDRESS =4 ,
  PW_NAS_PORT =5 , PW_SERVICE_TYPE =6 , PW_FRAMED_PROTOCOL =7 , PW_FRAMED_IP_ADDRESS =8 ,
  PW_FRAMED_IP_NETMASK =9 , PW_FRAMED_ROUTING =10 , PW_FILTER_ID =11 , PW_FRAMED_MTU =12 ,
  PW_FRAMED_COMPRESSION =13 , PW_LOGIN_IP_HOST =14 , PW_LOGIN_SERVICE =15 , PW_LOGIN_PORT =16 ,
  PW_OLD_PASSWORD =17 , PW_REPLY_MESSAGE =18 , PW_LOGIN_CALLBACK_NUMBER =19 , PW_FRAMED_CALLBACK_ID =20 ,
  PW_EXPIRATION =21 , PW_FRAMED_ROUTE =22 , PW_FRAMED_IPX_NETWORK =23 , PW_STATE =24 ,
  PW_CLASS =25 , PW_VENDOR_SPECIFIC =26 , PW_SESSION_TIMEOUT =27 , PW_IDLE_TIMEOUT =28 ,
  PW_TERMINATION_ACTION =29 , PW_CALLED_STATION_ID =30 , PW_CALLING_STATION_ID =31 , PW_NAS_IDENTIFIER =32 ,
  PW_PROXY_STATE =33 , PW_LOGIN_LAT_SERVICE =34 , PW_LOGIN_LAT_NODE =35 , PW_LOGIN_LAT_GROUP =36 ,
  PW_FRAMED_APPLETALK_LINK =37 , PW_FRAMED_APPLETALK_NETWORK =38 , PW_FRAMED_APPLETALK_ZONE =39 , PW_ACCT_STATUS_TYPE =40 ,
  PW_ACCT_DELAY_TIME =41 , PW_ACCT_INPUT_OCTETS =42 , PW_ACCT_OUTPUT_OCTETS =43 , PW_ACCT_SESSION_ID =44 ,
  PW_ACCT_AUTHENTIC =45 , PW_ACCT_SESSION_TIME =46 , PW_ACCT_INPUT_PACKETS =47 , PW_ACCT_OUTPUT_PACKETS =48 ,
  PW_ACCT_TERMINATE_CAUSE =49 , PW_ACCT_MULTI_SESSION_ID =50 , PW_ACCT_LINK_COUNT =51 , PW_ACCT_INPUT_GIGAWORDS =52 ,
  PW_ACCT_OUTPUT_GIGAWORDS =53 , PW_EVENT_TIMESTAMP =55 , PW_EGRESS_VLANID =56 , PW_INGRESS_FILTERS =57 ,
  PW_EGRESS_VLAN_NAME =58 , PW_USER_PRIORITY_TABLE =59 , PW_CHAP_CHALLENGE =60 , PW_NAS_PORT_TYPE =61 ,
  PW_PORT_LIMIT =62 , PW_LOGIN_LAT_PORT =63 , PW_TUNNEL_TYPE =64 , PW_TUNNEL_MEDIUM_TYPE =65 ,
  PW_TUNNEL_CLIENT_ENDPOINT =66 , PW_TUNNEL_SERVER_ENDPOINT =67 , PW_ACCT_TUNNEL_CONNECTION =68 , PW_TUNNEL_PASSWORD =69 ,
  PW_ARAP_PASSWORD =70 , PW_ARAP_FEATURES =71 , PW_ARAP_ZONE_ACCESS =72 , PW_ARAP_SECURITY =73 ,
  PW_ARAP_SECURITY_DATA =74 , PW_PASSWORD_RETRY =75 , PW_PROMPT =76 , PW_CONNECT_INFO =77 ,
  PW_CONFIGURATION_TOKEN =78 , PW_EAP_MESSAGE =79 , PW_MESSAGE_AUTHENTICATOR =80 , PW_TUNNEL_PRIVATE_GROUP_ID =81 ,
  PW_TUNNEL_ASSIGNMENT_ID =82 , PW_TUNNEL_PREFERENCE =83 , PW_ARAP_CHALLENGE_RESPONSE =84 , PW_ACCT_INTERIM_INTERVAL =85 ,
  PW_ACCT_TUNNEL_PACKETS_LOST =86 , PW_NAS_PORT_ID_STRING =87 , PW_FRAMED_POOL =88 , PW_CHARGEABLE_USER_IDENTITY =89 ,
  PW_CUI =89 , PW_TUNNEL_CLIENT_AUTH_ID =90 , PW_TUNNEL_SERVER_AUTH_ID =91 , PW_NAS_FILTER_RULE =92 ,
  PW_ORIGINATING_LINE_INFO =94 , PW_NAS_IPV6_ADDRESS =95 , PW_FRAMED_INTERFACE_ID =96 , PW_FRAMED_IPV6_PREFIX =97 ,
  PW_LOGIN_IPV6_HOST =98 , PW_FRAMED_IPV6_ROUTE =99 , PW_FRAMED_IPV6_POOL =100 , PW_ERROR_CAUSE =101 ,
  PW_EAP_KEY_NAME =102 , PW_DELEGATED_IPV6_PREFIX =123 , PW_FRAMED_IPV6_ADDRESS =168 , PW_DNS_SERVER_IPV6_ADDRESS =169 ,
  PW_ROUTE_IPV6_INFORMATION =170 , PW_DIGEST_RESPONSE =206 , PW_DIGEST_ATTRIBUTES =207 , PW_DIGEST_REALM =1063 ,
  PW_DIGEST_NONCE =1064 , PW_DIGEST_METHOD =1065 , PW_DIGEST_URI =1066 , PW_DIGEST_QOP =1067 ,
  PW_DIGEST_ALGORITHM =1068 , PW_DIGEST_BODY_DIGEST =1069 , PW_DIGEST_CNONCE =1070 , PW_DIGEST_NONCE_COUNT =1071 ,
  PW_DIGEST_USER_NAME =1072 , PW_USER_ID =222 , PW_USER_REALM =223
}
enum  rc_service_type {
  PW_LOGIN =1 , PW_FRAMED =2 , PW_CALLBACK_LOGIN =3 , PW_CALLBACK_FRAMED =4 ,
  PW_OUTBOUND =5 , PW_ADMINISTRATIVE =6 , PW_NAS_PROMPT =7 , PW_AUTHENTICATE_ONLY =8 ,
  PW_CALLBACK_NAS_PROMPT =9
}
enum  rc_framed_protocol {
  PW_PPP =1 , PW_SLIP =2 , PW_ARA = 3 , PW_GANDALF =4 ,
  PW_XYLOGICS =5
}
enum  rc_framed_routing_type { PW_NONE =0 , PW_BROADCAST =1 , PW_LISTEN =2 , PW_BROADCAST_LISTEN =3 }
enum  rc_framed_comp { PW_COMP_NONE =0 , PW_VAN_JACOBSON_TCP_IP =1 , PW_IPX_HEADER_COMPRESSION =2 , PW_COMP_LZS =3 }
enum  rc_login_service_type {
  PW_TELNET =0 , PW_RLOGIN =1 , PW_TCP_CLEAR =2 , PW_PORTMASTER =3 ,
  PW_LAT =4 , PW_X25_PAD =5 , PW_X25_T3POS =6
}
enum  rc_termination_action { PW_DEFAULT =0 , PW_RADIUS_REQUEST =1 }
enum  rc_acct_status_type {
  PW_STATUS_START =1 , PW_STATUS_STOP =2 , PW_STATUS_ALIVE =3 , PW_STATUS_MODEM_START =4 ,
  PW_STATUS_MODEM_STOP =5 , PW_STATUS_CANCEL =6 , PW_ACCOUNTING_ON =7 , PW_ACCOUNTING_OFF =8
}
enum  rc_acct_terminate_cause {
  PW_USER_REQUEST =1 , PW_LOST_CARRIER =2 , PW_LOST_SERVICE =3 , PW_ACCT_IDLE_TIMEOUT =4 ,
  PW_ACCT_SESSION_TIMEOUT =5 , PW_ADMIN_RESET =6 , PW_ADMIN_REBOOT =7 , PW_PORT_ERROR =8 ,
  PW_NAS_ERROR =9 , PW_NAS_REQUEST =10 , PW_NAS_REBOOT =11 , PW_PORT_UNNEEDED =12 ,
  PW_PORT_PREEMPTED =13 , PW_PORT_SUSPENDED =14 , PW_SERVICE_UNAVAILABLE =15 , PW_CALLBACK =16 ,
  PW_USER_ERROR =17 , PW_HOST_REQUEST =18
}
enum  rc_nas_port_type {
  PW_ASYNC =0 , PW_SYNC =1 , PW_ISDN_SYNC =2 , PW_ISDN_SYNC_V120 =3 ,
  PW_ISDN_SYNC_V110 =4 , PW_VIRTUAL =5
}
enum  rc_acct_auth_type { PW_RADIUS =1 , PW_LOCAL =2 , PW_REMOTE =3 }
enum  rc_vendor_pec { VENDOR_NONE =0 , VENDOR_MICROSOFT = 311 , VENDOR_ROARING_PENGUIN = 10055 }
enum  rc_vendor_attr_microsoft {
  PW_MS_CHAP_CHALLENGE = 11 , PW_MS_CHAP_RESPONSE = 1 , PW_MS_CHAP2_RESPONSE = 25 , PW_MS_CHAP2_SUCCESS = 26 ,
  PW_MS_MPPE_ENCRYPTION_POLICY = 7 , PW_MS_MPPE_ENCRYPTION_TYPE = 8 , PW_MS_MPPE_ENCRYPTION_TYPES =PW_MS_MPPE_ENCRYPTION_TYPE , PW_MS_CHAP_MPPE_KEYS = 12 ,
  PW_MS_MPPE_SEND_KEY = 16 , PW_MS_MPPE_RECV_KEY = 17 , PW_MS_PRIMARY_DNS_SERVER = 28 , PW_MS_SECONDARY_DNS_SERVER = 29 ,
  PW_MS_PRIMARY_NBNS_SERVER = 30 , PW_MS_SECONDARY_NBNS_SERVER = 31
}
enum  rc_vendor_attr_roaringpenguin { PW_RP_UPSTREAM_LIMIT =1 , PW_RP_DOWNSTREAM_LIMIT =2 }
enum  rc_send_status {
  NETUNREACH_RC =-4 , BADRESPID_RC =-3 , BADRESP_RC =-2 , ERROR_RC =-1 ,
  OK_RC =0 , TIMEOUT_RC =1 , REJECT_RC =2 , CHALLENGE_RC =3
}

Functions

const char * rc_aaa_ctx_get_secret (RC_AAA_CTX *ctx)
 Returns the secret available in this context. It is the secret value used in the request.
const void * rc_aaa_ctx_get_vector (RC_AAA_CTX *ctx)
 Returns a pointer request vector used in the request. It is of AUTH_VECTOR_LEN size.
void rc_aaa_ctx_free (RC_AAA_CTX *ctx)
 Deinitializes an RC_AAA_CTX structure.
VALUE_PAIRrc_avpair_add (rc_handle const *rh, VALUE_PAIR **list, uint32_t attrid, void const *pval, int len, uint32_t vendorspec)
 Adds an attribute-value pair to the given list.
void rc_avpair_remove (VALUE_PAIR **list, uint32_t attrid, uint32_t vendorspec)
 Removes an attribute-value pair from the given list.
VALUE_PAIRrc_avpair_next (VALUE_PAIR *t)
 Iterates through the attribute-value pairs.
int rc_avpair_assign (VALUE_PAIR *vp, void const *pval, int len)
 Assigns the given value to an attribute-value pair.
VALUE_PAIRrc_avpair_new (rc_handle const *rh, uint32_t attrid, void const *pval, int len, uint32_t vendorspec)
 Make a new attribute-value pair with given parameters.
VALUE_PAIRrc_avpair_gen (rc_handle const *rh, VALUE_PAIR *pair, unsigned char const *ptr, int length, uint32_t vendorspec)
 Decode a raw RADIUS attribute buffer into a VALUE_PAIR list.
VALUE_PAIRrc_avpair_get (VALUE_PAIR *vp, uint32_t attrid, uint32_t vendorspec)
 Find the first attribute value-pair (which matches the given attribute) from the specified value-pair list.
VALUE_PAIRrc_avpair_copy (VALUE_PAIR *p)
 Return a copy of the existing list "p" ala strdup().
void rc_avpair_insert (VALUE_PAIR **a, VALUE_PAIR *p, VALUE_PAIR *b)
 Insert a VALUE_PAIR into a list.
void rc_avpair_free (VALUE_PAIR *pair)
 Frees all value_pairs in the list.
int rc_avpair_parse (rc_handle const *rh, char const *buffer, VALUE_PAIR **first_pair)
 Parses the buffer to extract the attribute-value pairs.
int rc_avpair_tostr (rc_handle const *rh, VALUE_PAIR *pair, char *name, int ln, char *value, int lv)
 Translate an av_pair into printable strings.
char * rc_avpair_log (rc_handle const *rh, VALUE_PAIR *pair, char *buf, size_t buf_len)
 Format a sequence of attribute value pairs into a printable string.
int rc_avpair_get_uint32 (VALUE_PAIR *vp, uint32_t *res)
 Get the integer value of the given attribute value-pair.
int rc_avpair_get_in6 (VALUE_PAIR *vp, struct in6_addr *res, unsigned *prefix)
 Get the IPv6 address and prefix value of the given attribute value-pair.
int rc_avpair_get_raw (VALUE_PAIR *vp, char **res, unsigned *res_size)
 Get the raw value of the given attribute value-pair.
void rc_avpair_get_attr (VALUE_PAIR *vp, unsigned *type, unsigned *id)
 Get the attribute ID and type of the given attribute value-pair.
void rc_buildreq (rc_handle const *rh, SEND_DATA *data, int code, char *server, unsigned short port, char *secret, int timeout, int retries)
 Build a skeleton RADIUS request using information from the config file.
int rc_aaa_ctx (rc_handle *rh, RC_AAA_CTX **ctx, uint32_t nas_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg, int add_nas_port, rc_standard_codes request_type)
 Builds an authentication/accounting request and submits it to a server, optionally returning context.
int rc_aaa_ctx_server (rc_handle *rh, RC_AAA_CTX **ctx, SERVER *aaaserver, rc_type type, uint32_t nas_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg, int add_nas_port, rc_standard_codes request_type)
 Builds an authentication/accounting request and submits it to a specific server.
int rc_aaa (rc_handle *rh, uint32_t nas_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg, int add_nas_port, rc_standard_codes request_type)
 Builds an authentication/accounting request for port id nas_port with the value_pairs send and submits it to a server.
int rc_auth (rc_handle *rh, uint32_t nas_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg)
 Builds an authentication request for port id nas_port with the value_pairs send and submits it to a server.
int rc_auth_proxy (rc_handle *rh, VALUE_PAIR *send, VALUE_PAIR **received, char *msg)
 Builds an authentication request for proxying.
int rc_acct (rc_handle *rh, uint32_t nas_port, VALUE_PAIR *send)
 Builds an accounting request for port id nas_port with the value_pairs at send.
int rc_acct_proxy (rc_handle *rh, VALUE_PAIR *send)
 Builds an accounting request with the value_pairs at send.
int rc_acct_async (rc_handle *rh, uint32_t nas_port, VALUE_PAIR *send)
 Sends an accounting request to every configured accounting server without waiting for a reply.
int rc_check (rc_handle *rh, char *host, char *secret, unsigned short port, char *msg)
 Asks the server hostname on the specified port for a status message.
int rc_add_config (rc_handle *rh, char const *option_name, char const *option_val, char const *source, int line)
 Allow a config option to be added to rc_handle from inside a program.
rc_handle * rc_config_init (rc_handle *rh)
 Initialise a configuration structure for programmatic configuration.
int rc_apply_config (rc_handle *rh)
 Apply configuration and initialise the transport.
rc_handle * rc_read_config (char const *filename)
 Read the global config file.
char * rc_conf_str (rc_handle const *rh, char const *optname)
 Get the value of a config option.
int rc_conf_int (rc_handle const *rh, char const *optname)
 Get the value of a config option as an integer.
SERVERrc_conf_srv (rc_handle const *rh, char const *optname)
 Get the value of a config option.
int rc_test_config (rc_handle *rh, char const *filename)
 Tests the configuration the user supplied.
int rc_find_server_addr (rc_handle const *rh, char const *server_name, struct addrinfo **info, char *secret, rc_type type)
 Locate a server in the rh config or if not found, check for a servers file.
void rc_config_free (rc_handle *rh)
 Frees allocated config values.
rc_handle * rc_new (void)
 Initialises new Radius Client handle.
void rc_destroy (rc_handle *rh)
 Destroys Radius Client handle reclaiming all memory.
rc_socket_type rc_get_socket_type (rc_handle *rh)
 Returns the type of the socket used.
DICT_ATTRrc_dict_addattr (rc_handle *rh, char const *namestr, uint32_t value, int type, uint32_t vendorspec)
 Add attribute to dictionary.
DICT_VALUErc_dict_addval (rc_handle *rh, char const *attrstr, char const *namestr, uint32_t value)
 Add value to dictionary.
DICT_VENDORrc_dict_addvend (rc_handle *rh, char const *namestr, uint32_t vendorspec)
 Add vendor to dictionary.
int rc_read_dictionary (rc_handle *rh, char const *filename)
 Initialize the dictionary.
int rc_read_dictionary_from_buffer (rc_handle *rh, char const *buf, size_t size)
 Initialize the dictionary from Buffer.
DICT_ATTRrc_dict_getattr (rc_handle const *rh, uint64_t attribute)
 Lookup a DICT_ATTR by attribute number.
DICT_ATTRrc_dict_findattr (rc_handle const *rh, char const *attrname)
 Lookup a DICT_ATTR by its name.
DICT_VALUErc_dict_findval (rc_handle const *rh, char const *valname)
 Lookup a DICT_VALUE by its name.
DICT_VENDORrc_dict_findvend (rc_handle const *rh, char const *vendorname)
 Lookup a DICT_VENDOR by its name.
DICT_VENDORrc_dict_getvend (rc_handle const *rh, uint32_t vendorspec)
 Lookup a DICT_VENDOR by its IANA number.
DICT_VALUErc_dict_getval (rc_handle const *rh, uint32_t value, char const *attrname)
 Get DICT_VALUE based on attribute name and integer value number.
void rc_dict_free (rc_handle *rh)
 Frees the allocated dictionary.
int rc_send_server (rc_handle *rh, SEND_DATA *data, char *msg, rc_type type)
 Sends a request to a RADIUS server and waits for the reply.

Detailed Description

Main API Functions.

Macro Definition Documentation

◆ ATTRID

#define ATTRID ( x)
Value:
((x) & 0xffffffff)

Definition at line 68 of file radcli.h.

◆ AUTH_HDR_LEN

#define AUTH_HDR_LEN   20

Definition at line 112 of file radcli.h.

◆ AUTH_ID_LEN

#define AUTH_ID_LEN   64

Definition at line 54 of file radcli.h.

◆ AUTH_LOCAL_FST

#define AUTH_LOCAL_FST   (1<<0)

Definition at line 83 of file radcli.h.

◆ AUTH_LOCAL_SND

#define AUTH_LOCAL_SND   (1<<2)

Definition at line 85 of file radcli.h.

◆ AUTH_PASS_LEN

#define AUTH_PASS_LEN   (8 * 16) /* multiple of 16 */

Definition at line 53 of file radcli.h.

◆ AUTH_RADIUS_FST

#define AUTH_RADIUS_FST   (1<<1)

Definition at line 84 of file radcli.h.

◆ AUTH_RADIUS_SND

#define AUTH_RADIUS_SND   (1<<3)

Definition at line 86 of file radcli.h.

◆ AUTH_STRING_LEN

#define AUTH_STRING_LEN   253 /* maximum of 253 */

Definition at line 487 of file radcli.h.

◆ AUTH_VECTOR_LEN

#define AUTH_VECTOR_LEN   16

Definition at line 525 of file radcli.h.

◆ CHAP_VALUE_LENGTH

#define CHAP_VALUE_LENGTH   16

Definition at line 113 of file radcli.h.

◆ ENV_SIZE

#define ENV_SIZE   128

Definition at line 550 of file radcli.h.

◆ FALSE

#define FALSE   0

Definition at line 32 of file config.c.

◆ MAX_SECRET_LENGTH

#define MAX_SECRET_LENGTH   (16 * 16) /* MUST be multiple of 16 */

Definition at line 61 of file radcli.h.

◆ MGMT_POLL_SECRET

#define MGMT_POLL_SECRET   "Hardlyasecret"

Default for Merit radiusd.

Definition at line 471 of file radcli.h.

◆ PATH_MAX

#define PATH_MAX   1024

Definition at line 547 of file radcli.h.

◆ PW_ACCT_UDP_PORT

#define PW_ACCT_UDP_PORT   1813

Definition at line 116 of file radcli.h.

◆ PW_ALL

#define PW_ALL   255

Definition at line 434 of file radcli.h.

◆ PW_AUTH_ONLY

#define PW_AUTH_ONLY   3

Definition at line 433 of file radcli.h.

◆ PW_AUTH_UDP_PORT

#define PW_AUTH_UDP_PORT   1812

Definition at line 115 of file radcli.h.

◆ PW_DUMB

#define PW_DUMB   0

1 and 2 are defined in FRAMED PROTOCOLS.

Definition at line 432 of file radcli.h.

◆ PW_MAX_MSG_SIZE

#define PW_MAX_MSG_SIZE   4096

Definition at line 70 of file radcli.h.

◆ RADCLI_VENDOR_ATTR_SET

#define RADCLI_VENDOR_ATTR_SET ( attr,
vendor )
Value:
((attr)|((uint64_t)((vendor)&RADCLI_VENDOR_MASK)) << VENDOR_BIT_SIZE)

Definition at line 65 of file radcli.h.

◆ RADCLI_VENDOR_MASK

#define RADCLI_VENDOR_MASK   0xffffffff

Definition at line 63 of file radcli.h.

◆ RC_BUFFER_LEN

#define RC_BUFFER_LEN   8192

Definition at line 56 of file radcli.h.

◆ RC_MAX

#define RC_MAX ( a,
b )
Value:
((a) > (b) ? (a) : (b))

Definition at line 543 of file radcli.h.

◆ RC_MAX_PACKET_LEN

#define RC_MAX_PACKET_LEN   4096 /* RFC 2865: maximum RADIUS packet size */

Definition at line 57 of file radcli.h.

◆ RC_MIN

#define RC_MIN ( a,
b )
Value:
((a) < (b) ? (a) : (b))

Definition at line 540 of file radcli.h.

◆ RC_NAME_LENGTH

#define RC_NAME_LENGTH   64

Definition at line 59 of file radcli.h.

◆ RC_SERVER_MAX

#define RC_SERVER_MAX   8

Definition at line 81 of file radcli.h.

◆ TRUE

#define TRUE   1

Definition at line 31 of file config.c.

◆ VENDOR

#define VENDOR ( x)
Value:
(((x) >> VENDOR_BIT_SIZE) & 0xffffffff)

Definition at line 67 of file radcli.h.

◆ VENDOR_BIT_SIZE

#define VENDOR_BIT_SIZE   32

Definition at line 64 of file radcli.h.

Typedef Documentation

◆ RC_AAA_CTX

typedef struct rc_aaa_ctx_st RC_AAA_CTX

Opaque context returned by rc_aaa_ctx() after a successful request.

Captures the shared secret and the request authenticator vector (AUTH_VECTOR_LEN bytes) that were used in the last request. These can be retrieved with rc_aaa_ctx_get_secret() and rc_aaa_ctx_get_vector().

Pass NULL for the ctx argument to rc_aaa_ctx() if this information is not needed. When a context is no longer needed, free it with rc_aaa_ctx_free().

Definition at line 537 of file radcli.h.

◆ rc_handle

typedef struct rc_conf rc_handle

Definition at line 89 of file radcli.h.

Enumeration Type Documentation

◆ rc_acct_auth_type

RFC2866 Acct-Authentic values

Definition at line 393 of file radcli.h.

◆ rc_acct_status_type

RFC2866 Acct-Status-Type values

Definition at line 346 of file radcli.h.

◆ rc_acct_terminate_cause

RFC2866 Acct-Terminate-Cause values

Definition at line 359 of file radcli.h.

◆ rc_attr_id

enum rc_attr_id

Standard RADIUS attribute-value pair identifiers

Enumerator
PW_USER_NAME 

Its type is string.

PW_USER_PASSWORD 

Its type is string.

PW_CHAP_PASSWORD 

Its type is string.

PW_NAS_IP_ADDRESS 

Its type is ipaddr.

PW_NAS_PORT 

Its type is integer.

PW_SERVICE_TYPE 

Its type is integer.

PW_FRAMED_PROTOCOL 

Its type is integer.

PW_FRAMED_IP_ADDRESS 

Its type is ipaddr.

PW_FRAMED_IP_NETMASK 

Its type is ipaddr.

PW_FRAMED_ROUTING 

Its type is integer.

PW_FILTER_ID 

Its type is string.

PW_FRAMED_MTU 

Its type is integer.

PW_FRAMED_COMPRESSION 

Its type is integer.

PW_LOGIN_IP_HOST 

Its type is ipaddr.

PW_LOGIN_SERVICE 

Its type is integer.

PW_LOGIN_PORT 

Its type is integer.

PW_OLD_PASSWORD 

Its type is string - deprecated.

PW_REPLY_MESSAGE 

Its type is string.

PW_LOGIN_CALLBACK_NUMBER 

Its type is string.

PW_FRAMED_CALLBACK_ID 

Its type is string.

PW_EXPIRATION 

Its type is date - deprecated.

PW_FRAMED_ROUTE 

Its type is string.

PW_FRAMED_IPX_NETWORK 

Its type is integer.

PW_STATE 

Its type is string.

PW_CLASS 

Its type is string.

PW_VENDOR_SPECIFIC 

Its type is string.

PW_SESSION_TIMEOUT 

Its type is integer.

PW_IDLE_TIMEOUT 

Its type is integer.

PW_TERMINATION_ACTION 

Its type is integer.

PW_CALLED_STATION_ID 

Its type is string.

PW_CALLING_STATION_ID 

Its type is string.

PW_NAS_IDENTIFIER 

Its type is string.

PW_PROXY_STATE 

Its type is string.

PW_LOGIN_LAT_SERVICE 

Its type is string.

PW_LOGIN_LAT_NODE 

Its type is string.

PW_LOGIN_LAT_GROUP 

Its type is string.

PW_FRAMED_APPLETALK_LINK 

Its type is integer.

PW_FRAMED_APPLETALK_NETWORK 

Its type is integer.

PW_FRAMED_APPLETALK_ZONE 

Its type is string.

PW_ACCT_STATUS_TYPE 

Its type is integer.

PW_ACCT_DELAY_TIME 

Its type is integer.

PW_ACCT_INPUT_OCTETS 

Its type is integer.

PW_ACCT_OUTPUT_OCTETS 

Its type is integer.

PW_ACCT_SESSION_ID 

Its type is string.

PW_ACCT_AUTHENTIC 

Its type is integer.

PW_ACCT_SESSION_TIME 

Its type is integer.

PW_ACCT_INPUT_PACKETS 

Its type is integer.

PW_ACCT_OUTPUT_PACKETS 

Its type is integer.

PW_ACCT_TERMINATE_CAUSE 

Its type is integer.

PW_ACCT_MULTI_SESSION_ID 

Its type is string.

PW_ACCT_LINK_COUNT 

Its type is integer.

PW_ACCT_INPUT_GIGAWORDS 

Its type is integer.

PW_ACCT_OUTPUT_GIGAWORDS 

Its type is integer.

PW_EVENT_TIMESTAMP 

Its type is integer.

PW_EGRESS_VLANID 

Its type is string.

PW_INGRESS_FILTERS 

Its type is integer.

PW_EGRESS_VLAN_NAME 

Its type is string.

PW_USER_PRIORITY_TABLE 

Its type is string.

PW_CHAP_CHALLENGE 

Its type is string.

PW_NAS_PORT_TYPE 

Its type is integer.

PW_PORT_LIMIT 

Its type is integer.

PW_LOGIN_LAT_PORT 

Its type is string.

PW_TUNNEL_TYPE 

Its type is string.

PW_TUNNEL_MEDIUM_TYPE 

Its type is integer.

PW_TUNNEL_CLIENT_ENDPOINT 

Its type is string.

PW_TUNNEL_SERVER_ENDPOINT 

Its type is string.

PW_ACCT_TUNNEL_CONNECTION 

Its type is string.

PW_TUNNEL_PASSWORD 

Its type is string.

PW_ARAP_PASSWORD 

Its type is string.

PW_ARAP_FEATURES 

Its type is string.

PW_ARAP_ZONE_ACCESS 

Its type is integer.

PW_ARAP_SECURITY 

Its type is integer.

PW_ARAP_SECURITY_DATA 

Its type is string.

PW_PASSWORD_RETRY 

Its type is integer.

PW_PROMPT 

Its type is integer.

PW_CONNECT_INFO 

Its type is string.

PW_CONFIGURATION_TOKEN 

Its type is string.

PW_EAP_MESSAGE 

Its type is string.

PW_MESSAGE_AUTHENTICATOR 

Its type is string.

PW_TUNNEL_PRIVATE_GROUP_ID 

Its type is string.

PW_TUNNEL_ASSIGNMENT_ID 

Its type is string.

PW_TUNNEL_PREFERENCE 

Its type is string.

PW_ARAP_CHALLENGE_RESPONSE 

Its type is string.

PW_ACCT_INTERIM_INTERVAL 

Its type is integer.

PW_ACCT_TUNNEL_PACKETS_LOST 

Its type is integer.

PW_NAS_PORT_ID_STRING 

Its type is string.

PW_FRAMED_POOL 

Its type is string.

PW_CHARGEABLE_USER_IDENTITY 

Its type is string.

PW_CUI 

Its type is string.

PW_TUNNEL_CLIENT_AUTH_ID 

Its type is string.

PW_TUNNEL_SERVER_AUTH_ID 

Its type is string.

PW_NAS_FILTER_RULE 

Its type is string.

PW_ORIGINATING_LINE_INFO 

Its type is string.

PW_NAS_IPV6_ADDRESS 

Its type is string.

PW_FRAMED_INTERFACE_ID 

Its type is string.

PW_FRAMED_IPV6_PREFIX 

Its type is string.

PW_LOGIN_IPV6_HOST 

Its type is string.

PW_FRAMED_IPV6_ROUTE 

Its type is string.

PW_FRAMED_IPV6_POOL 

Its type is string.

PW_ERROR_CAUSE 

Its type is integer.

PW_EAP_KEY_NAME 

Its type is string.

PW_DELEGATED_IPV6_PREFIX 

Its type is ipv6prefix.

PW_FRAMED_IPV6_ADDRESS 

Its type is ipaddr6.

PW_DNS_SERVER_IPV6_ADDRESS 

Its type is ipaddr6.

PW_ROUTE_IPV6_INFORMATION 

Its type is ipv6prefix.

Experimental SIP-specific attributes (draft-sterman-aaa-sip-00.txt etc)

PW_DIGEST_RESPONSE 

Its type is string.

PW_DIGEST_ATTRIBUTES 

Its type is string.

PW_DIGEST_REALM 

Its type is string.

PW_DIGEST_NONCE 

Its type is string.

PW_DIGEST_METHOD 

Its type is string.

PW_DIGEST_URI 

Its type is string.

PW_DIGEST_QOP 

Its type is string.

PW_DIGEST_ALGORITHM 

Its type is string.

PW_DIGEST_BODY_DIGEST 

Its type is string.

PW_DIGEST_CNONCE 

Its type is string.

PW_DIGEST_NONCE_COUNT 

Its type is string.

PW_DIGEST_USER_NAME 

Its type is string.

Merit Experimental Extensions

PW_USER_ID 

Its type is string.

PW_USER_REALM 

Its type is string.

Definition at line 150 of file radcli.h.

◆ rc_attr_type

Attribute types

Enumerator
PW_TYPE_STRING 

The attribute is a printable string.

PW_TYPE_INTEGER 

The attribute is a 32-bit integer.

PW_TYPE_IPADDR 

The attribute is an IPv4 address in host-byte order.

PW_TYPE_DATE 

The attribute contains a 32-bit number indicating the seconds since epoch.

PW_TYPE_IPV6ADDR 

The attribute is an 128-bit IPv6 address.

PW_TYPE_IPV6PREFIX 

The attribute is an IPv6 prefix; the lvalue will indicate its size.

PW_TYPE_MAX 

Maximum number of types (last+1)

Definition at line 120 of file radcli.h.

◆ rc_framed_comp

FRAMED COMPRESSION TYPES RFC2865 Framed-Compression values

Definition at line 317 of file radcli.h.

◆ rc_framed_protocol

RFC2865 Framed-Protocol values

Definition at line 296 of file radcli.h.

◆ rc_framed_routing_type

RFC2865 Framed-Routing values

Definition at line 306 of file radcli.h.

◆ rc_login_service_type

RFC2865 Login-Service values

Definition at line 326 of file radcli.h.

◆ rc_nas_port_type

RFC2866 NAS-Port-Type values

Definition at line 382 of file radcli.h.

◆ rc_send_status

Return codes for rc_send_server()

Definition at line 475 of file radcli.h.

◆ rc_service_type

RFC2865 Service-Type values

Definition at line 282 of file radcli.h.

◆ rc_socket_type

Indicate the type of the socket

Enumerator
RC_SOCKET_UDP 

Plain UDP socket.

RC_SOCKET_TLS 

TLS socket.

RC_SOCKET_DTLS 

DTLS socket.

RC_SOCKET_TCP 

Plain TCP socket.

Definition at line 105 of file radcli.h.

◆ rc_standard_codes

Standard RADIUS request codes

Definition at line 132 of file radcli.h.

◆ rc_termination_action

RFC2865 Termination-Action values

Definition at line 338 of file radcli.h.

◆ rc_type

enum rc_type

Codes to indicate the type of server

Enumerator
AUTH 

Request for authentication server.

ACCT 

Request for accounting server.

Definition at line 74 of file radcli.h.

◆ rc_vendor_attr_microsoft

enum rc_vendor_attr_microsoft

Definition at line 408 of file radcli.h.

◆ rc_vendor_attr_roaringpenguin

enum rc_vendor_attr_roaringpenguin

Definition at line 426 of file radcli.h.

◆ rc_vendor_pec

Function Documentation

◆ rc_aaa()

int rc_aaa ( rc_handle * rh,
uint32_t nas_port,
VALUE_PAIR * send,
VALUE_PAIR ** received,
char * msg,
int add_nas_port,
rc_standard_codes request_type )

Builds an authentication/accounting request for port id nas_port with the value_pairs send and submits it to a server.

Parameters
rha handle to parsed configuration.
nas_portthe physical NAS port number to use (may be zero).
senda VALUE_PAIR array of values (e.g., PW_USER_NAME).
receivedan allocated array of received values.
msgmust be an array of PW_MAX_MSG_SIZE or NULL; will contain the concatenation of any PW_REPLY_MESSAGE received.
add_nas_portthis should be zero; if non-zero it will include PW_NAS_PORT in sent pairs.
request_typeone of standard RADIUS codes (e.g., PW_ACCESS_REQUEST).
Returns
received value_pairs in received, messages from the server in msg and OK_RC (0) on success, CHALLENGE_RC (3) on Access-Challenge received, negative on failure as return value.

Definition at line 283 of file buildreq.c.

◆ rc_aaa_ctx()

int rc_aaa_ctx ( rc_handle * rh,
RC_AAA_CTX ** ctx,
uint32_t nas_port,
VALUE_PAIR * send,
VALUE_PAIR ** received,
char * msg,
int add_nas_port,
rc_standard_codes request_type )

Builds an authentication/accounting request and submits it to a server, optionally returning context.

Selects the server list from configuration (authserver or acctserver depending on request_type and transport), sends the request with automatic retry and server failover, and returns the server's response.

Note
Use rc_auth() or rc_acct() when no context is needed (they call this with ctx set to NULL). Pass a non-NULL ctx only when you need to inspect the secret and vector used in the request afterwards.
Parameters
rha handle to parsed configuration.
ctxif non-NULL, receives an allocated RC_AAA_CTX on success; the caller must free it with rc_aaa_ctx_free(). Pass NULL if not needed.
nas_portthe physical NAS port number to include (may be zero).
sendVALUE_PAIR list of attributes to send (e.g., PW_USER_NAME).
receivedon success, receives the server's reply VALUE_PAIR list; the caller must free it with rc_avpair_free().
msgif non-NULL, must point to a buffer of PW_MAX_MSG_SIZE bytes; will contain the concatenation of any PW_REPLY_MESSAGE attributes received.
add_nas_portif non-zero, PW_NAS_PORT is added to the sent pairs.
request_typeone of the standard RADIUS codes (e.g., PW_ACCESS_REQUEST).
Returns
OK_RC (0) on success, CHALLENGE_RC (3) on Access-Challenge, REJECT_RC (2) on Access-Reject, or a negative error code on failure.

Definition at line 166 of file buildreq.c.

◆ rc_aaa_ctx_free()

void rc_aaa_ctx_free ( RC_AAA_CTX * ctx)

Deinitializes an RC_AAA_CTX structure.

Parameters
ctxa pointer to a RC_AAA_CTX structure.

Definition at line 62 of file aaa_ctx.c.

◆ rc_aaa_ctx_get_secret()

const char * rc_aaa_ctx_get_secret ( RC_AAA_CTX * ctx)

Returns the secret available in this context. It is the secret value used in the request.

Parameters
ctxa pointer to a RC_AAA_CTX structure.
Returns
a null-terminated string.

Definition at line 41 of file aaa_ctx.c.

◆ rc_aaa_ctx_get_vector()

const void * rc_aaa_ctx_get_vector ( RC_AAA_CTX * ctx)

Returns a pointer request vector used in the request. It is of AUTH_VECTOR_LEN size.

Parameters
ctxa pointer to a RC_AAA_CTX structure.
Returns
a pointer to the vector.

Definition at line 52 of file aaa_ctx.c.

◆ rc_aaa_ctx_server()

int rc_aaa_ctx_server ( rc_handle * rh,
RC_AAA_CTX ** ctx,
SERVER * aaaserver,
rc_type type,
uint32_t nas_port,
VALUE_PAIR * send,
VALUE_PAIR ** received,
char * msg,
int add_nas_port,
rc_standard_codes request_type )

Builds an authentication/accounting request and submits it to a specific server.

Like rc_aaa_ctx() but sends to aaaserver instead of the server list from the configuration. Use this when the caller has already selected the server (e.g., in proxy scenarios).

Parameters
rha handle to parsed configuration.
ctxif non-NULL, receives an allocated RC_AAA_CTX on success; the caller must free it with rc_aaa_ctx_free(). Pass NULL if not needed.
aaaservera non-NULL SERVER describing the target server(s).
typeAUTH to use the authentication port, ACCT for the accounting port. Under TLS/DTLS only AUTH is valid (both auth and acct share the same TLS connection to the authserver).
nas_portthe physical NAS port number to include (may be zero).
sendVALUE_PAIR list of attributes to send (e.g., PW_USER_NAME).
receivedon success, receives the server's reply VALUE_PAIR list; the caller must free it with rc_avpair_free().
msgif non-NULL, must point to a buffer of PW_MAX_MSG_SIZE bytes; will contain the concatenation of any PW_REPLY_MESSAGE attributes received.
add_nas_portif non-zero, PW_NAS_PORT is added to the sent pairs.
request_typeone of the standard RADIUS codes (e.g., PW_ACCESS_REQUEST).
Returns
OK_RC (0) on success, CHALLENGE_RC (3) on Access-Challenge, REJECT_RC (2) on Access-Reject, or a negative error code on failure.

Definition at line 205 of file buildreq.c.

◆ rc_acct()

int rc_acct ( rc_handle * rh,
uint32_t nas_port,
VALUE_PAIR * send )

Builds an accounting request for port id nas_port with the value_pairs at send.

Note
NAS-IP-Address, NAS-Port and Acct-Delay-Time get filled in by this function, the rest has to be supplied.
Parameters
rha handle to parsed configuration.
nas_portthe physical NAS port number to use (may be zero).
senda VALUE_PAIR array of values (e.g., PW_USER_NAME).
Returns
received value_pairs in received, and OK_RC (0) on success, CHALLENGE_RC (3) on Access-Challenge received, negative on failure as return value.

Definition at line 342 of file buildreq.c.

◆ rc_acct_async()

int rc_acct_async ( rc_handle * rh,
uint32_t nas_port,
VALUE_PAIR * send )

Sends an accounting request to every configured accounting server without waiting for a reply.

Selects the server list the same way rc_acct() does (acctserver, or authserver under TLS/DTLS). Unlike rc_acct()/rc_aaa(), which stop at the first server that replies and fail over to the next only after a timeout, this sends to every configured server unconditionally, since there is no reply to judge success or failure by. Intended for best-effort notifications such as an Accounting-Stop sent while an application is shutting down and cannot afford to block.

Parameters
rha handle to parsed configuration.
nas_portthe physical NAS port number to include (may be zero).
sendVALUE_PAIR list of attributes to send; NAS-Port and Acct-Delay-Time are filled in as with rc_acct().
Returns
OK_RC (0) if the packet was handed to the socket layer for at least one server, ERROR_RC if no accounting servers are configured or the send failed for all of them.

Definition at line 443 of file buildreq.c.

◆ rc_acct_proxy()

int rc_acct_proxy ( rc_handle * rh,
VALUE_PAIR * send )

Builds an accounting request with the value_pairs at send.

Parameters
rha handle to parsed configuration.
senda VALUE_PAIR array of values (e.g., PW_USER_NAME).
Returns
OK_RC (0) on success, CHALLENGE_RC (3) on Access-Challenge received, negative on failure as return value.

Definition at line 355 of file buildreq.c.

◆ rc_add_config()

int rc_add_config ( rc_handle * rh,
char const * option_name,
char const * option_val,
char const * source,
int line )

Allow a config option to be added to rc_handle from inside a program.

That allows programs to setup a handle without loading a configuration file.

Parameters
rha handle to parsed configuration.
option_namethe name of the option.
option_valthe value to be added.
sourcetypically should be FILE or func for logging purposes.
lineLINE for logging purposes.
Returns
0 on success, -1 on failure.

Definition at line 337 of file config.c.

◆ rc_apply_config()

int rc_apply_config ( rc_handle * rh)

Apply configuration and initialise the transport.

Must be called after all rc_add_config() calls when using programmatic configuration (i.e., without a config file). Initialises the transport selected by the serv-type option, including the TLS/DTLS handshake for TLS and DTLS transports.

Note
rc_read_config() calls this internally; do not call it again after rc_read_config().

See rc_config_init() for the full programmatic usage example.

Parameters
rha handle to parsed configuration.
Returns
0 on success, -1 on failure.

Definition at line 575 of file config.c.

◆ rc_auth()

int rc_auth ( rc_handle * rh,
uint32_t nas_port,
VALUE_PAIR * send,
VALUE_PAIR ** received,
char * msg )

Builds an authentication request for port id nas_port with the value_pairs send and submits it to a server.

Parameters
rha handle to parsed configuration.
nas_portthe physical NAS port number to use (may be zero).
senda VALUE_PAIR array of values (e.g., PW_USER_NAME).
receivedan allocated array of received values.
msgmust be an array of PW_MAX_MSG_SIZE or NULL; will contain the concatenation of any PW_REPLY_MESSAGE received.
Returns
received value_pairs in received, messages from the server in msg (if non-NULL), and OK_RC (0) on success,CHALLENGE_RC (3) on Access-Challenge received, negative on failure as return value.
Examples
radexample.c.

Definition at line 303 of file buildreq.c.

◆ rc_auth_proxy()

int rc_auth_proxy ( rc_handle * rh,
VALUE_PAIR * send,
VALUE_PAIR ** received,
char * msg )

Builds an authentication request for proxying.

Builds an authentication request with the value_pairs send and submits it to a server. Works for a proxy; does not add IP address, and does does not rely on config file.

Parameters
rha handle to parsed configuration.
senda VALUE_PAIR array of values (e.g., PW_USER_NAME).
receivedan allocated array of received values.
msgmust be an array of PW_MAX_MSG_SIZE or NULL; will contain the concatenation of any PW_REPLY_MESSAGE received.
Returns
received value_pairs in received, messages from the server in msg (if non-NULL) and OK_RC (0) on success, CHALLENGE_RC (3) on Access-Challenge received, negative on failure as return value.

Definition at line 325 of file buildreq.c.

◆ rc_avpair_add()

VALUE_PAIR * rc_avpair_add ( rc_handle const * rh,
VALUE_PAIR ** list,
uint32_t attrid,
void const * pval,
int len,
uint32_t vendorspec )

Adds an attribute-value pair to the given list.

See rc_avpair_assign() for the format of the data.

Note
It always appends the new pair to the end of the list.
Parameters
rha handle to parsed configuration.
lista VALUE_PAIR array of values; initially must be NULL.
attridThe attribute of the pair to add (e.g., PW_USER_NAME).
pvalthe value (e.g., the actual username).
lenthe length of pval, or -1 if to calculate (in case of strings).
vendorspecThe vendor ID in case of a vendor specific value - 0 otherwise.
Returns
pointer to added a/v pair upon success, NULL pointer upon failure.
Examples
radexample.c.

Definition at line 46 of file avpair.c.

◆ rc_avpair_assign()

int rc_avpair_assign ( VALUE_PAIR * vp,
void const * pval,
int len )

Assigns the given value to an attribute-value pair.

If the value is of type PW_TYPE_STRING it must either be a null terminated string with len set to -1, or raw data with length properly set. For PW_TYPE_DATE, PW_TYPE_INTEGER, and PW_TYPE_IPADDR an uint32_t number should be set at pval. For IPv4 addresses it should be in host byte order.

For PW_TYPE_IPV6ADDR type a 16-byte long address is expected, and for PW_TYPE_IPV6PREFIX the rfc3162 prefix format is expected. Simply that is a zero byte, a byte with the value of prefix (e.g., 112), and the remaining bytes are the IPv6 address.

Parameters
vpa pointer to a VALUE_PAIR structure.
pvalthe value (e.g., the actual username).
lenthe length of pval, or -1 if to calculate (in case of strings).
Returns
0 on success or -1 on failure.

Definition at line 135 of file avpair.c.

◆ rc_avpair_copy()

VALUE_PAIR * rc_avpair_copy ( VALUE_PAIR * p)

Return a copy of the existing list "p" ala strdup().

Parameters
pa pointer to a VALUE_PAIR structure.
Returns
the copy of "p".

Definition at line 497 of file avpair.c.

◆ rc_avpair_free()

void rc_avpair_free ( VALUE_PAIR * pair)

Frees all value_pairs in the list.

Parameters
paira pointer to a VALUE_PAIR structure.
Examples
radexample.c.

Definition at line 584 of file avpair.c.

◆ rc_avpair_gen()

VALUE_PAIR * rc_avpair_gen ( rc_handle const * rh,
VALUE_PAIR * pair,
unsigned char const * ptr,
int length,
uint32_t vendorspec )

Decode a raw RADIUS attribute buffer into a VALUE_PAIR list.

Note
This is a low-level function retained for ABI compatibility with freeradius-client and radiusclient-ng. Application code should not call it directly; build requests with rc_avpair_add() and send them with rc_auth() or rc_acct(), which handle wire encoding and decoding internally.

Decodes the attribute/value region of a received RADIUS packet (the bytes that follow the 20-byte fixed header) into a linked list of VALUE_PAIR structures. Unknown attributes are logged and skipped; they are not a hard error.

Parameters
rha handle to parsed configuration (used for dictionary lookups).
pairoptional existing VALUE_PAIR list to append decoded attributes to; pass NULL to start a fresh list.
ptrpointer to the start of the attribute data region.
lengthnumber of bytes in the attribute region.
vendorspecvendor PEN when decoding a vendor-specific sub-attribute block; pass 0 for top-level packet attributes.
Returns
head of the (possibly extended) VALUE_PAIR list, or NULL on a hard decode error (malformed length field, allocation failure).

Definition at line 459 of file avpair.c.

◆ rc_avpair_get()

VALUE_PAIR * rc_avpair_get ( VALUE_PAIR * vp,
uint32_t attrid,
uint32_t vendorspec )

Find the first attribute value-pair (which matches the given attribute) from the specified value-pair list.

Parameters
vpa pointer to a VALUE_PAIR structure.
attridThe attribute of the pair to find (e.g., PW_USER_NAME).
vendorspecThe vendor ID in case of a vendor specific value - 0 otherwise.
Returns
the value pair found.

Definition at line 480 of file avpair.c.

◆ rc_avpair_get_attr()

void rc_avpair_get_attr ( VALUE_PAIR * vp,
unsigned * type,
unsigned * id )

Get the attribute ID and type of the given attribute value-pair.

Parameters
vpa pointer to a VALUE_PAIR structure.
typeThe attribute type, of type rc_attr_type
idThe attribute identifier, of type rc_attr_id

Definition at line 1109 of file avpair.c.

◆ rc_avpair_get_in6()

int rc_avpair_get_in6 ( VALUE_PAIR * vp,
struct in6_addr * res,
unsigned * prefix )

Get the IPv6 address and prefix value of the given attribute value-pair.

This function is valid for PW_TYPE_IPV6ADDR, PW_TYPE_IPV6PREFIX.

Parameters
vpa pointer to a VALUE_PAIR structure.
resAn in6_addr structure for result to be copied in.
prefixIf of type PW_TYPE_IPV6PREFIX the prefix will be copied (may be NULL).
Returns
zero on success or -1 on failure.

Definition at line 1057 of file avpair.c.

◆ rc_avpair_get_raw()

int rc_avpair_get_raw ( VALUE_PAIR * vp,
char ** res,
unsigned * res_size )

Get the raw value of the given attribute value-pair.

This function is valid for PW_TYPE_STRING, PW_TYPE_IPV6ADDR, PW_TYPE_IPV6PREFIX.

Parameters
vpa pointer to a VALUE_PAIR structure.
resWill contain pointer to the data value.
res_sizeWill contain the data size.
Returns
zero on success or -1 on failure.

Definition at line 1089 of file avpair.c.

◆ rc_avpair_get_uint32()

int rc_avpair_get_uint32 ( VALUE_PAIR * vp,
uint32_t * res )

Get the integer value of the given attribute value-pair.

This function is valid for PW_TYPE_INTEGER, PW_TYPE_IPADDR. PW_TYPE_DATE. In PW_TYPE_IPADDR this value will contain the IPv4 address in host by order.

Parameters
vpa pointer to a VALUE_PAIR structure.
resThe integer value returned.
Returns
zero on success or -1 on failure.

Definition at line 1036 of file avpair.c.

◆ rc_avpair_insert()

void rc_avpair_insert ( VALUE_PAIR ** a,
VALUE_PAIR * p,
VALUE_PAIR * b )

Insert a VALUE_PAIR into a list.

Given the address of an existing list "a" and a pointer to an entry "p" in that list, add the value pair "b" to the "a" list after the "p" entry. If "p" is NULL, add the value pair "b" to the end of "a".

Parameters
aa VALUE_PAIR array of values.
pa pointer to a VALUE_PAIR in a.
bThe VALUE_PAIR pointer to add in a.

Definition at line 532 of file avpair.c.

◆ rc_avpair_log()

char * rc_avpair_log ( rc_handle const * rh,
VALUE_PAIR * pair,
char * buf,
size_t buf_len )

Format a sequence of attribute value pairs into a printable string.

The caller should provide a storage buffer and the buffer length.

Parameters
rha handle to parsed configuration.
paira pointer to a VALUE_PAIR structure.
bufwill hold the string output of the pair.
buf_lenthe size of buf.
Returns
a pointer to provided storage buffer.

Definition at line 1004 of file avpair.c.

◆ rc_avpair_new()

VALUE_PAIR * rc_avpair_new ( rc_handle const * rh,
uint32_t attrid,
void const * pval,
int len,
uint32_t vendorspec )

Make a new attribute-value pair with given parameters.

See rc_avpair_assign() for the format of the data.

Parameters
rha handle to parsed configuration.
attridThe attribute of the pair to add (e.g., PW_USER_NAME).
pvalthe value (e.g., the actual username).
lenthe length of pval, or -1 if to calculate (in case of strings).
vendorspecThe vendor ID in case of a vendor specific value - 0 otherwise.
Returns
pointer to generated a/v pair when successful, NULL when failure.

Definition at line 196 of file avpair.c.

◆ rc_avpair_next()

VALUE_PAIR * rc_avpair_next ( VALUE_PAIR * t)

Iterates through the attribute-value pairs.

The attribute-value are organized in a linked-list, and this function provides a way to iterate them given the first element initially.

Parameters
tthe current pair.
Returns
pointer to the next pair, or NULL when finished.
Examples
radexample.c.

Definition at line 112 of file avpair.c.

◆ rc_avpair_parse()

int rc_avpair_parse ( rc_handle const * rh,
char const * buffer,
VALUE_PAIR ** first_pair )

Parses the buffer to extract the attribute-value pairs.

Parameters
rha handle to parsed configuration.
bufferthe buffer to be parsed.
first_pairan allocated array of values.
Returns
0 on successful parse of attribute-value pair, or -1 on syntax (or other) error detected.

Definition at line 650 of file avpair.c.

◆ rc_avpair_remove()

void rc_avpair_remove ( VALUE_PAIR ** list,
uint32_t attrid,
uint32_t vendorspec )

Removes an attribute-value pair from the given list.

See rc_avpair_assign() for the format of the data.

Parameters
lista VALUE_PAIR array of values
attridThe attribute of the pair to remove (e.g., PW_USER_NAME).
vendorspecThe vendor ID in case of a vendor specific value - 0 otherwise.

Definition at line 69 of file avpair.c.

◆ rc_avpair_tostr()

int rc_avpair_tostr ( rc_handle const * rh,
VALUE_PAIR * pair,
char * name,
int ln,
char * value,
int lv )

Translate an av_pair into printable strings.

Parameters
rha handle to parsed configuration.
paira pointer to a VALUE_PAIR structure.
namethe name of the pair.
lnthe size of name.
valuethe value of the pair.
lvthe size of value.
Returns
0 on success, -1 on failure.
Examples
radexample.c.

Definition at line 883 of file avpair.c.

◆ rc_buildreq()

void rc_buildreq ( rc_handle const * rh,
SEND_DATA * data,
int code,
char * server,
unsigned short port,
char * secret,
int timeout,
int retries )

Build a skeleton RADIUS request using information from the config file.

Note
This is a low-level helper used internally by rc_aaa_ctx_server(). Normal applications should call rc_auth() or rc_acct() instead of constructing SEND_DATA directly.
Parameters
rha handle to parsed configuration.
dataa pointer to a SEND_DATA structure.
codeone of standard RADIUS codes (e.g., PW_ACCESS_REQUEST).
serverthe name of the server.
portthe server's port number.
secretthe secret used by the server.
timeoutthe timeout in seconds of a message.
retriesthe number of retries.

Definition at line 47 of file buildreq.c.

◆ rc_check()

int rc_check ( rc_handle * rh,
char * host,
char * secret,
unsigned short port,
char * msg )

Asks the server hostname on the specified port for a status message.

Parameters
rha handle to parsed configuration.
hostthe name of the server.
secretthe secret used by the server.
portthe server's port number.
msgmust be an array of PW_MAX_MSG_SIZE or NULL; will contain the concatenation of any PW_REPLY_MESSAGE received.
Returns
OK_RC (0) on success, negative on failure as return value.

Definition at line 464 of file buildreq.c.

◆ rc_conf_int()

int rc_conf_int ( rc_handle const * rh,
char const * optname )

Get the value of a config option as an integer.

Parameters
rha handle to parsed configuration.
optnamethe name of an option.
Returns
config option value, or 0 if not found or not an integer.

Definition at line 864 of file config.c.

◆ rc_conf_srv()

SERVER * rc_conf_srv ( rc_handle const * rh,
char const * optname )

Get the value of a config option.

Parameters
rha handle to parsed configuration.
optnamethe name of an option.
Returns
config option value.

Definition at line 875 of file config.c.

◆ rc_conf_str()

char * rc_conf_str ( rc_handle const * rh,
char const * optname )

Get the value of a config option.

Parameters
rha handle to parsed configuration.
optnamethe name of an option.
Returns
config option value.

Definition at line 817 of file config.c.

◆ rc_config_free()

void rc_config_free ( rc_handle * rh)

Frees allocated config values.

Parameters
rha handle to parsed configuration

For legacy compatibility reasons this will not release any dictionary entries. To release all memory from the handle use rc_destroy() instead.

Definition at line 1187 of file config.c.

◆ rc_config_init()

rc_handle * rc_config_init ( rc_handle * rh)

Initialise a configuration structure for programmatic configuration.

Use this when you want to configure radcli from code rather than from a file. The full call sequence is:

rc_handle *rh = rc_new();
rh = rc_config_init(rh);
rc_add_config(rh, "authserver", "radius.example.com:1812:sharedsecret",
__FILE__, __LINE__);
rc_add_config(rh, "serv-type", "udp", __FILE__, __LINE__);
// rh is now ready for rc_auth() / rc_acct()
rc_handle * rc_new(void)
Initialises new Radius Client handle.
Definition config.c:1218
rc_handle * rc_config_init(rc_handle *rh)
Initialise a configuration structure for programmatic configuration.
Definition config.c:404
int rc_add_config(rc_handle *rh, char const *option_name, char const *option_val, char const *source, int line)
Allow a config option to be added to rc_handle from inside a program.
Definition config.c:337
int rc_apply_config(rc_handle *rh)
Apply configuration and initialise the transport.
Definition config.c:575

The provided handle must have been allocated with rc_new(). Call rc_apply_config() after all rc_add_config() calls to activate the configuration and initialise the transport.

Parameters
rha handle allocated by rc_new().
Returns
rh on success, NULL on failure (rh is freed on failure).

Definition at line 404 of file config.c.

◆ rc_destroy()

void rc_destroy ( rc_handle * rh)

Destroys Radius Client handle reclaiming all memory.

Parameters
rhThe Radius client handle to free.
Examples
radexample.c.

Definition at line 1249 of file config.c.

◆ rc_dict_addattr()

DICT_ATTR * rc_dict_addattr ( rc_handle * rh,
char const * namestr,
uint32_t value,
int type,
uint32_t vendorspec )

Add attribute to dictionary.

Does not check if such attribute already exists

Parameters
rha handle to configuration.
namestrattribute name
typeattribute type
valueattribute value
vendorspecvendorspec
Returns
added attr on success, NULL on failure

Definition at line 38 of file dict.c.

◆ rc_dict_addval()

DICT_VALUE * rc_dict_addval ( rc_handle * rh,
char const * attrstr,
char const * namestr,
uint32_t value )

Add value to dictionary.

Does not check if such value already exists

Parameters
rha handle to configuration.
attrstrattribute name
namestrname
valueattribute value
Returns
added value on success, NULL on failure

Definition at line 81 of file dict.c.

◆ rc_dict_addvend()

DICT_VENDOR * rc_dict_addvend ( rc_handle * rh,
char const * namestr,
uint32_t vendorspec )

Add vendor to dictionary.

Does not check if such vendor already exists

Parameters
rha handle to configuration.
namestrvendor name
vendorspecvendorspec
Returns
added value on success, NULL on failure

Definition at line 122 of file dict.c.

◆ rc_dict_findattr()

DICT_ATTR * rc_dict_findattr ( rc_handle const * rh,
char const * attrname )

Lookup a DICT_ATTR by its name.

Parameters
rha handle to parsed configuration.
attrnamethe attribute name.
Returns
the full attribute structure based on the attribute name.

Definition at line 627 of file dict.c.

◆ rc_dict_findval()

DICT_VALUE * rc_dict_findval ( rc_handle const * rh,
char const * valname )

Lookup a DICT_VALUE by its name.

Parameters
rha handle to parsed configuration.
valnamethe value name.
Returns
the full value structure based on the value name.

Definition at line 650 of file dict.c.

◆ rc_dict_findvend()

DICT_VENDOR * rc_dict_findvend ( rc_handle const * rh,
char const * vendorname )

Lookup a DICT_VENDOR by its name.

Parameters
rha handle to parsed configuration.
vendornamethe vendor name.
Returns
the full vendor structure based on the vendor name.

Definition at line 671 of file dict.c.

◆ rc_dict_free()

void rc_dict_free ( rc_handle * rh)

Frees the allocated dictionary.

Parameters
rha handle to parsed configuration.

Definition at line 725 of file dict.c.

◆ rc_dict_getattr()

DICT_ATTR * rc_dict_getattr ( rc_handle const * rh,
uint64_t attribute )

Lookup a DICT_ATTR by attribute number.

Parameters
rha handle to parsed configuration.
attributethe attribute ID.
Returns
the full attribute structure based on the attribute id number.

Definition at line 604 of file dict.c.

◆ rc_dict_getval()

DICT_VALUE * rc_dict_getval ( rc_handle const * rh,
uint32_t value,
char const * attrname )

Get DICT_VALUE based on attribute name and integer value number.

Parameters
rha handle to parsed configuration.
valuethe attribute value.
attrnamethe attribute name.
Returns
the full value structure based on the actual value and the associated attribute name.

Definition at line 704 of file dict.c.

◆ rc_dict_getvend()

DICT_VENDOR * rc_dict_getvend ( rc_handle const * rh,
uint32_t vendorspec )

Lookup a DICT_VENDOR by its IANA number.

Parameters
rha handle to parsed configuration.
vendorspecthe vendor ID.
Returns
the full vendor structure based on the vendor id number.

Definition at line 687 of file dict.c.

◆ rc_find_server_addr()

int rc_find_server_addr ( rc_handle const * rh,
char const * server_name,
struct addrinfo ** info,
char * secret,
rc_type type )

Locate a server in the rh config or if not found, check for a servers file.

Parameters
rha handle to parsed configuration.
server_namethe name of the server.
infowill hold a pointer to addrinfo
secretwill hold the server's secret (of MAX_SECRET_LENGTH).
typeAUTH or ACCT
Returns
0 on success, -1 on failure.

Definition at line 1037 of file config.c.

◆ rc_get_socket_type()

rc_socket_type rc_get_socket_type ( rc_handle * rh)

Returns the type of the socket used.

That indicates the type of connection used with the radius server, and can be UDP, TLS or DTLS.

Returns
the type of the socket

Definition at line 1273 of file config.c.

◆ rc_new()

rc_handle * rc_new ( void )

Initialises new Radius Client handle.

Returns
a new rc_handle (free with rc_destroy).

Definition at line 1218 of file config.c.

◆ rc_read_config()

rc_handle * rc_read_config ( char const * filename)

Read the global config file.

This is the primary way to initialise radcli. Loads the configuration file, initialises the transport (including TLS/DTLS handshake when applicable), and returns an opaque handle for use in subsequent calls. The format is compatible with radiusclient-ng and freeradius-client.

Standard RFC 2865/2866/2869 attributes are built into the library; the dictionary option is only needed for vendor-specific attributes.

Recognised configuration options:

Server address:

  • authserver: authentication server; format is host[:port[:secret]] (may be repeated for failover, comma-separated).
  • acctserver: accounting server; same format as authserver.

Transport:

  • serv-type: one of udp (default), tcp, tls, dtls.
  • namespace: Linux network namespace name to use for socket operations.

TLS/DTLS credentials (required when serv-type is tls or dtls):

  • tls-ca-file: PEM file of the CA certificate used to verify the server.
  • tls-cert-file: PEM file of the client certificate.
  • tls-key-file: PEM file of the client private key.
  • tls-verify-hostname: set to false to skip server hostname verification (not recommended).

Security:

  • require-message-authenticator: set to no to accept responses that lack the Message-Authenticator attribute. Enabled by default per draft-ietf-radext-deprecating-radius-10 (CVE-2024-3596 / BLAST RADIUS); only disable for legacy servers that predate RFC 3579. Has no effect over RADIUS/TLS or RADIUS/DTLS, where this mitigation is never enforced, per draft-ietf-radext-deprecating-radius-10 Section 4.

Tuning:

  • radius_timeout: request timeout in seconds (integer, default 3).
  • radius_retries: number of retries per server (integer, default 3).
  • nas-ip: source IP address to bind to when sending requests.
  • nas-identifier: NAS-Identifier string sent in requests.
  • dictionary: path to an additional attribute dictionary file.
  • clientdebug: debug verbosity level (integer; 0 = off).
Parameters
filenamepath to the configuration file.
Returns
new rc_handle on success, NULL on failure.
Examples
radexample.c.

Definition at line 676 of file config.c.

◆ rc_read_dictionary()

int rc_read_dictionary ( rc_handle * rh,
char const * filename )

Initialize the dictionary.

Read all ATTRIBUTES into the dictionary_attributes list. Read all VALUES into the dictionary_values list.

Parameters
rha handle to parsed configuration.
filenamethe name of the dictionary file.
Returns
0 on success, -1 on failure.

Definition at line 544 of file dict.c.

◆ rc_read_dictionary_from_buffer()

int rc_read_dictionary_from_buffer ( rc_handle * rh,
char const * buf,
size_t size )

Initialize the dictionary from Buffer.

Read all ATTRIBUTES into the dictionary_attributes list. Read all VALUES into the dictionary_values list.

Parameters
rha handle to parsed configuration.
bufbuffer holding Dictionary info
sizesize of buffer
Returns
0 on success, -1 on failure.

Definition at line 579 of file dict.c.

◆ rc_send_server()

int rc_send_server ( rc_handle * rh,
SEND_DATA * data,
char * msg,
rc_type type )

Sends a request to a RADIUS server and waits for the reply.

Parameters
rha handle to parsed configuration
dataa pointer to a SEND_DATA structure
msgmust be an array of PW_MAX_MSG_SIZE or NULL; will contain the concatenation of any PW_REPLY_MESSAGE received.
typemust be AUTH or ACCT
Returns
OK_RC (0) on success, TIMEOUT_RC on timeout REJECT_RC on access reject, or negative on failure as return value.

Definition at line 231 of file sendserver.c.

◆ rc_test_config()

int rc_test_config ( rc_handle * rh,
char const * filename )

Tests the configuration the user supplied.

Parameters
rha handle to parsed configuration.
filenamea name of a configuration file.
Returns
0 on success, -1 when failure.

Definition at line 895 of file config.c.