30#include <netinet/in.h>
33#include <sys/socket.h>
49#define AUTH_PASS_LEN (8 * 16)
52#define RC_BUFFER_LEN 8192
54#define RC_NAME_LENGTH 32
56#define MAX_SECRET_LENGTH (16 * 16)
58#define RADCLI_VENDOR_MASK 0xffffffff
59#define VENDOR_BIT_SIZE 32
60#define RADCLI_VENDOR_ATTR_SET(attr, vendor) ((attr)|((uint64_t)((vendor)&RADCLI_VENDOR_MASK)) << VENDOR_BIT_SIZE)
62#define VENDOR(x) (((x) >> VENDOR_BIT_SIZE) & 0xffffffff)
63#define ATTRID(x) ((x) & 0xffffffff)
65#define PW_MAX_MSG_SIZE 4096
76#define RC_SERVER_MAX 8
78#define AUTH_LOCAL_FST (1<<0)
79#define AUTH_RADIUS_FST (1<<1)
80#define AUTH_LOCAL_SND (1<<2)
81#define AUTH_RADIUS_SND (1<<3)
84typedef struct rc_conf rc_handle;
92 char *name[RC_SERVER_MAX];
93 uint16_t port[RC_SERVER_MAX];
94 char *secret[RC_SERVER_MAX];
107#define AUTH_HDR_LEN 20
108#define CHAP_VALUE_LENGTH 16
110#define PW_AUTH_UDP_PORT 1812
111#define PW_ACCT_UDP_PORT 1813
131 PW_ACCOUNTING_REQUEST=4,
132 PW_ACCOUNTING_RESPONSE=5,
133 PW_ACCOUNTING_STATUS=6,
134 PW_PASSWORD_REQUEST=7,
136 PW_PASSWORD_REJECT=9,
137 PW_ACCOUNTING_MESSAGE=10,
138 PW_ACCESS_CHALLENGE=11,
281 PW_CALLBACK_FRAMED=4,
285 PW_AUTHENTICATE_ONLY=8,
286 PW_CALLBACK_NAS_PROMPT=9
305 PW_BROADCAST_LISTEN=3
314 PW_VAN_JACOBSON_TCP_IP=1,
315 PW_IPX_HEADER_COMPRESSION=2,
345 PW_STATUS_MODEM_START=4,
346 PW_STATUS_MODEM_STOP=5,
358 PW_ACCT_IDLE_TIMEOUT=4,
359 PW_ACCT_SESSION_TIMEOUT=5,
367 PW_PORT_PREEMPTED=13,
368 PW_PORT_SUSPENDED=14,
369 PW_SERVICE_UNAVAILABLE=15,
398 VENDOR_MICROSOFT = 311,
399 VENDOR_ROARING_PENGUIN = 10055
403enum rc_vendor_attr_microsoft {
404 PW_MS_CHAP_CHALLENGE = 11,
405 PW_MS_CHAP_RESPONSE = 1,
406 PW_MS_CHAP2_RESPONSE = 25,
407 PW_MS_CHAP2_SUCCESS = 26,
408 PW_MS_MPPE_ENCRYPTION_POLICY= 7,
409 PW_MS_MPPE_ENCRYPTION_TYPE= 8,
410 PW_MS_MPPE_ENCRYPTION_TYPES=PW_MS_MPPE_ENCRYPTION_TYPE,
411 PW_MS_CHAP_MPPE_KEYS = 12,
412 PW_MS_MPPE_SEND_KEY = 16,
413 PW_MS_MPPE_RECV_KEY = 17,
414 PW_MS_PRIMARY_DNS_SERVER= 28,
415 PW_MS_SECONDARY_DNS_SERVER= 29,
416 PW_MS_PRIMARY_NBNS_SERVER= 30,
417 PW_MS_SECONDARY_NBNS_SERVER= 31,
421enum rc_vendor_attr_roaringpenguin {
422 PW_RP_UPSTREAM_LIMIT =1,
423 PW_RP_DOWNSTREAM_LIMIT =2,
428#define PW_AUTH_ONLY 3
443 char attrname[RC_NAME_LENGTH +1];
444 char name[RC_NAME_LENGTH + 1];
451 char vendorname[RC_NAME_LENGTH +1];
457#define MGMT_POLL_SECRET "Hardlyasecret"
473# define AUTH_STRING_LEN 253
502#define AUTH_VECTOR_LEN 16
505typedef struct rc_aaa_ctx_st RC_AAA_CTX;
508#define RC_MIN(a, b) ((a) < (b) ? (a) : (b))
511#define RC_MAX(a, b) ((a) > (b) ? (a) : (b))
574VALUE_PAIR *
rc_avpair_new (rc_handle
const *rh, uint32_t attrid,
void const *pval,
int len, uint32_t vendorspec);
576 int length, uint32_t vendorspec);
595 char *secret,
int timeout,
int retries);
601int rc_check(rc_handle *rh,
char *host,
char *secret,
unsigned short port,
char *msg);
609 rc_type type, uint32_t client_port,
615int rc_add_config(rc_handle *rh,
char const *option_name,
char const *option_val,
char const *source,
int line);
618char *
rc_conf_str(rc_handle
const *rh,
char const *optname);
619int rc_conf_int(rc_handle
const *rh,
char const *optname);
624 struct addrinfo** info,
char *secret,
rc_type type);
630#define test_config rc_test_config
659int rc_get_srcaddr(
struct sockaddr *lia,
const struct sockaddr *ria);
663void rc_setdebug(
int debug);
680#define _RADCLI_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
681#if !defined RADCLI_INTERNAL_BUILD
682# if _RADCLI_GCC_VERSION >= 30100
683# define _RADCLI_GCC_ATTR_DEPRECATED __attribute__ ((__deprecated__))
686char *rc_mksid(
void) _RADCLI_GCC_ATTR_DEPRECATED;
unsigned short rc_getport(int type)
int rc_get_srcaddr(struct sockaddr *lia, const struct sockaddr *ria)
void rc_openlog(char const *ident)
int rc_own_hostname(char *hostname, int len)
void rc_avpair_remove(VALUE_PAIR **list, uint32_t attrid, uint32_t vendorspec)
DICT_VALUE * rc_dict_getval(rc_handle const *rh, uint32_t value, char const *attrname)
int rc_avpair_get_raw(VALUE_PAIR *vp, char **res, unsigned *res_size)
char * rc_avpair_log(rc_handle const *rh, VALUE_PAIR *pair, char *buf, size_t buf_len)
rc_socket_type rc_get_socket_type(rc_handle *rh)
VALUE_PAIR * rc_avpair_next(VALUE_PAIR *t)
const void * rc_aaa_ctx_get_vector(RC_AAA_CTX *ctx)
int rc_acct(rc_handle *rh, uint32_t client_port, VALUE_PAIR *send)
int rc_auth_proxy(rc_handle *rh, VALUE_PAIR *send, VALUE_PAIR **received, char *msg)
int rc_auth(rc_handle *rh, uint32_t client_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg)
int rc_avpair_get_uint32(VALUE_PAIR *vp, uint32_t *res)
void rc_buildreq(rc_handle const *rh, SEND_DATA *data, int code, char *server, unsigned short port, char *secret, int timeout, int retries)
DICT_ATTR * rc_dict_addattr(rc_handle *rh, char const *namestr, uint32_t value, int type, uint32_t vendorspec)
int rc_avpair_get_in6(VALUE_PAIR *vp, struct in6_addr *res, unsigned *prefix)
void rc_avpair_get_attr(VALUE_PAIR *vp, unsigned *type, unsigned *id)
VALUE_PAIR * rc_avpair_gen(rc_handle const *rh, VALUE_PAIR *pair, unsigned char const *ptr, int length, uint32_t vendorspec)
void rc_destroy(rc_handle *rh)
DICT_VENDOR * rc_dict_findvend(rc_handle const *rh, char const *vendorname)
int rc_acct_proxy(rc_handle *rh, VALUE_PAIR *send)
const char * rc_aaa_ctx_get_secret(RC_AAA_CTX *ctx)
void rc_avpair_free(VALUE_PAIR *pair)
int rc_read_dictionary_from_buffer(rc_handle *rh, char const *buf, size_t size)
int rc_aaa_ctx(rc_handle *rh, RC_AAA_CTX **ctx, uint32_t client_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg, int add_nas_port, rc_standard_codes request_type)
VALUE_PAIR * rc_avpair_copy(VALUE_PAIR *p)
int rc_avpair_tostr(rc_handle const *rh, VALUE_PAIR *pair, char *name, int ln, char *value, int lv)
int rc_aaa(rc_handle *rh, uint32_t client_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg, int add_nas_port, rc_standard_codes request_type)
int rc_avpair_assign(VALUE_PAIR *vp, void const *pval, int len)
DICT_VALUE * rc_dict_findval(rc_handle const *rh, char const *valname)
int rc_send_server(rc_handle *rh, SEND_DATA *data, char *msg, rc_type type)
int rc_avpair_parse(rc_handle const *rh, char const *buffer, VALUE_PAIR **first_pair)
rc_handle * rc_read_config(char const *filename)
int rc_read_dictionary(rc_handle *rh, char const *filename)
int rc_aaa_ctx_server(rc_handle *rh, RC_AAA_CTX **ctx, SERVER *aaaserver, rc_type type, uint32_t client_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg, int add_nas_port, rc_standard_codes request_type)
int rc_check(rc_handle *rh, char *host, char *secret, unsigned short port, char *msg)
DICT_VENDOR * rc_dict_getvend(rc_handle const *rh, uint32_t vendorspec)
char * rc_conf_str(rc_handle const *rh, char const *optname)
int rc_test_config(rc_handle *rh, char const *filename)
DICT_ATTR * rc_dict_getattr(rc_handle const *rh, uint64_t attribute)
void rc_dict_free(rc_handle *rh)
rc_handle * rc_config_init(rc_handle *rh)
void rc_config_free(rc_handle *rh)
DICT_VALUE * rc_dict_addval(rc_handle *rh, char const *attrstr, char const *namestr, uint32_t value)
int rc_find_server_addr(rc_handle const *rh, char const *server_name, struct addrinfo **info, char *secret, rc_type type)
DICT_VENDOR * rc_dict_addvend(rc_handle *rh, char const *vendorname, uint32_t value)
SERVER * rc_conf_srv(rc_handle const *rh, char const *optname)
VALUE_PAIR * rc_avpair_add(rc_handle const *rh, VALUE_PAIR **list, uint32_t attrid, void const *pval, int len, uint32_t vendorspec)
void rc_aaa_ctx_free(RC_AAA_CTX *ctx)
void rc_avpair_insert(VALUE_PAIR **a, VALUE_PAIR *p, VALUE_PAIR *b)
VALUE_PAIR * rc_avpair_get(VALUE_PAIR *vp, uint32_t attrid, uint32_t vendorspec)
DICT_ATTR * rc_dict_findattr(rc_handle const *rh, char const *attrname)
int rc_add_config(rc_handle *rh, char const *option_name, char const *option_val, char const *source, int line)
VALUE_PAIR * rc_avpair_new(rc_handle const *rh, uint32_t attrid, void const *pval, int len, uint32_t vendorspec)
int rc_apply_config(rc_handle *rh)
@ ACCT
Request for accounting server.
@ AUTH
Request for authentication server.
@ PW_NAS_PORT_ID_STRING
Its type is string.
@ PW_ACCT_LINK_COUNT
Its type is integer.
@ PW_ACCT_INPUT_GIGAWORDS
Its type is integer.
@ PW_ORIGINATING_LINE_INFO
Its type is string.
@ PW_USER_REALM
Its type is string.
@ PW_TUNNEL_CLIENT_ENDPOINT
Its type is string.
@ PW_FILTER_ID
Its type is string.
@ PW_DIGEST_NONCE
Its type is string.
@ PW_FRAMED_POOL
Its type is string.
@ PW_NAS_IDENTIFIER
Its type is string.
@ PW_ACCT_SESSION_TIME
Its type is integer.
@ PW_NAS_PORT_TYPE
Its type is integer.
@ PW_ARAP_FEATURES
Its type is string.
@ PW_ACCT_INPUT_OCTETS
Its type is integer.
@ PW_ACCT_TUNNEL_PACKETS_LOST
Its type is integer.
@ PW_DIGEST_REALM
Its type is string.
@ PW_TUNNEL_TYPE
Its type is string.
@ PW_ACCT_STATUS_TYPE
Its type is integer.
@ PW_USER_ID
Its type is string.
@ PW_FRAMED_INTERFACE_ID
Its type is string.
@ PW_TERMINATION_ACTION
Its type is integer.
@ PW_ACCT_TUNNEL_CONNECTION
Its type is string.
@ PW_DIGEST_USER_NAME
Its type is string.
@ PW_CHAP_PASSWORD
Its type is string.
@ PW_OLD_PASSWORD
Its type is string - deprecated.
@ PW_FRAMED_APPLETALK_NETWORK
Its type is integer.
@ PW_ACCT_INPUT_PACKETS
Its type is integer.
@ PW_NAS_IP_ADDRESS
Its type is ipaddr.
@ PW_FRAMED_ROUTING
Its type is integer.
@ PW_ACCT_SESSION_ID
Its type is string.
@ PW_FRAMED_IP_ADDRESS
Its type is ipaddr.
@ PW_CONNECT_INFO
Its type is string.
@ PW_PASSWORD_RETRY
Its type is integer.
@ PW_PROXY_STATE
Its type is string.
@ PW_TUNNEL_SERVER_ENDPOINT
Its type is string.
@ PW_LOGIN_LAT_NODE
Its type is string.
@ PW_ACCT_OUTPUT_PACKETS
Its type is integer.
@ PW_EVENT_TIMESTAMP
Its type is integer.
@ PW_TUNNEL_ASSIGNMENT_ID
Its type is string.
@ PW_DIGEST_URI
Its type is string.
@ PW_SESSION_TIMEOUT
Its type is integer.
@ PW_DIGEST_QOP
Its type is string.
@ PW_FRAMED_IPV6_ROUTE
Its type is string.
@ PW_NAS_PORT
Its type is integer.
@ PW_DIGEST_BODY_DIGEST
Its type is string.
@ PW_ACCT_OUTPUT_GIGAWORDS
Its type is integer.
@ PW_DNS_SERVER_IPV6_ADDRESS
Its type is ipaddr6.
@ PW_FRAMED_COMPRESSION
Its type is integer.
@ PW_EGRESS_VLANID
Its type is string.
@ PW_FRAMED_IPV6_ADDRESS
Its type is ipaddr6.
@ PW_SERVICE_TYPE
Its type is integer.
@ PW_TUNNEL_PREFERENCE
Its type is string.
@ PW_PORT_LIMIT
Its type is integer.
@ PW_CUI
Its type is string.
@ PW_LOGIN_LAT_SERVICE
Its type is string.
@ PW_FRAMED_IPV6_POOL
Its type is string.
@ PW_TUNNEL_CLIENT_AUTH_ID
Its type is string.
@ PW_NAS_IPV6_ADDRESS
Its type is string.
@ PW_CALLED_STATION_ID
Its type is string.
@ PW_DIGEST_ATTRIBUTES
Its type is string.
@ PW_FRAMED_APPLETALK_LINK
Its type is integer.
@ PW_CALLING_STATION_ID
Its type is string.
@ PW_LOGIN_CALLBACK_NUMBER
Its type is string.
@ PW_EXPIRATION
Its type is date - deprecated.
@ PW_ARAP_SECURITY
Its type is integer.
@ PW_USER_PRIORITY_TABLE
Its type is string.
@ PW_PROMPT
Its type is integer.
@ PW_FRAMED_IPV6_PREFIX
Its type is string.
@ PW_TUNNEL_MEDIUM_TYPE
Its type is integer.
@ PW_DIGEST_NONCE_COUNT
Its type is string.
@ PW_EAP_MESSAGE
Its type is string.
@ PW_FRAMED_IP_NETMASK
Its type is ipaddr.
@ PW_LOGIN_PORT
Its type is integer.
@ PW_FRAMED_IPX_NETWORK
Its type is integer.
@ PW_DIGEST_ALGORITHM
Its type is string.
@ PW_ACCT_TERMINATE_CAUSE
Its type is integer.
@ PW_LOGIN_LAT_GROUP
Its type is string.
@ PW_TUNNEL_PASSWORD
Its type is string.
@ PW_LOGIN_IPV6_HOST
Its type is string.
@ PW_ROUTE_IPV6_INFORMATION
Its type is ipv6prefix.
@ PW_EAP_KEY_NAME
Its type is string.
@ PW_DIGEST_RESPONSE
Its type is string.
@ PW_FRAMED_MTU
Its type is integer.
@ PW_LOGIN_LAT_PORT
Its type is string.
@ PW_ACCT_MULTI_SESSION_ID
Its type is string.
@ PW_ACCT_OUTPUT_OCTETS
Its type is integer.
@ PW_FRAMED_APPLETALK_ZONE
Its type is string.
@ PW_DIGEST_CNONCE
Its type is string.
@ PW_TUNNEL_SERVER_AUTH_ID
Its type is string.
@ PW_ARAP_SECURITY_DATA
Its type is string.
@ PW_LOGIN_SERVICE
Its type is integer.
@ PW_DIGEST_METHOD
Its type is string.
@ PW_TUNNEL_PRIVATE_GROUP_ID
Its type is string.
@ PW_LOGIN_IP_HOST
Its type is ipaddr.
@ PW_ACCT_DELAY_TIME
Its type is integer.
@ PW_STATE
Its type is string.
@ PW_EGRESS_VLAN_NAME
Its type is string.
@ PW_ERROR_CAUSE
Its type is integer.
@ PW_USER_NAME
Its type is string.
@ PW_MESSAGE_AUTHENTICATOR
Its type is string.
@ PW_DELEGATED_IPV6_PREFIX
Its type is ipv6prefix.
@ PW_REPLY_MESSAGE
Its type is string.
@ PW_VENDOR_SPECIFIC
Its type is string.
@ PW_CHAP_CHALLENGE
Its type is string.
@ PW_ACCT_AUTHENTIC
Its type is integer.
@ PW_USER_PASSWORD
Its type is string.
@ PW_INGRESS_FILTERS
Its type is integer.
@ PW_CHARGEABLE_USER_IDENTITY
Its type is string.
@ PW_FRAMED_PROTOCOL
Its type is integer.
@ PW_ARAP_ZONE_ACCESS
Its type is integer.
@ PW_FRAMED_CALLBACK_ID
Its type is string.
@ PW_ARAP_CHALLENGE_RESPONSE
Its type is string.
@ PW_NAS_FILTER_RULE
Its type is string.
@ PW_IDLE_TIMEOUT
Its type is integer.
@ PW_ARAP_PASSWORD
Its type is string.
@ PW_FRAMED_ROUTE
Its type is string.
@ PW_ACCT_INTERIM_INTERVAL
Its type is integer.
@ PW_CONFIGURATION_TOKEN
Its type is string.
@ PW_CLASS
Its type is string.
@ PW_TYPE_IPADDR
The attribute is an IPv4 address in host-byte order.
@ PW_TYPE_IPV6ADDR
The attribute is an 128-bit IPv6 address.
@ PW_TYPE_MAX
Maximum number of types (last+1)
@ PW_TYPE_IPV6PREFIX
The attribute is an IPv6 prefix; the lvalue will indicate its size.
@ PW_TYPE_INTEGER
The attribute is a 32-bit integer.
@ PW_TYPE_DATE
The attribute contains a 32-bit number indicating the seconds since epoch.
@ PW_TYPE_STRING
The attribute is a printable string.
@ RC_SOCKET_UDP
Plain UDP socket.
@ RC_SOCKET_TCP
Plain TCP socket.
@ RC_SOCKET_DTLS
DTLS socket.
@ RC_SOCKET_TLS
TLS socket.
int rc_tls_fd(rc_handle *rh)
int rc_check_tls(rc_handle *rh)
rc_attr_type type
string, int, etc..
uint64_t value
attribute index and vendor number; use VENDOR() and ATTRID() to separate.
char name[RC_NAME_LENGTH+1]
attribute name.
rc_attr_type type
attribute type.
uint64_t attribute
attribute numeric value of type rc_attr_id including vendor; use VENDOR() and ATTRID() to separate.
uint32_t lvalue
attribute value if type is PW_TYPE_INTEGER, PW_TYPE_DATE or PW_TYPE_IPADDR.
char strvalue[AUTH_STRING_LEN+1]
contains attribute value in other cases.
char name[RC_NAME_LENGTH+1]
attribute name if known.
int timeout
Session timeout in seconds.
char * secret
Shared secret of RADIUS server.
uint8_t seq_nbr
Packet sequence number.
int svc_port
RADIUS protocol destination port.
char * server
Name/address of RADIUS server.
VALUE_PAIR * send_pairs
More a/v pairs to send.
VALUE_PAIR * receive_pairs
Where to place received a/v pairs.
uint8_t code
RADIUS packet code.
double deadtime_ends[RC_SERVER_MAX]
unused