11#include <radcli/radcli.h>
25static unsigned char rc_get_id()
27 return (
unsigned char)(random() & UCHAR_MAX);
42 unsigned short port,
char *secret,
int timeout,
int retries)
49 data->retries = retries;
70int rc_aaa_ctx(rc_handle * rh, RC_AAA_CTX ** ctx, uint32_t nas_port,
78 request_type != PW_ACCOUNTING_REQUEST) {
85 if (aaaserver == NULL)
89 nas_port, send, received, msg,
90 add_nas_port, request_type);
115 char *msg,
int add_nas_port,
121 int timeout = rc_conf_int(rh,
"radius_timeout");
122 int retries = rc_conf_int(rh,
"radius_retries");
123 double start_time = 0;
131 if (add_nas_port != 0
137 &nas_port, 0, 0) == NULL)
141 if (request_type == PW_ACCOUNTING_REQUEST) {
148 if (adt_vp == NULL) {
156 start_time = now - adt_vp->
lvalue;
167 rc_buildreq(rh, &data, request_type, aaaserver->name[servernum],
168 aaaserver->port[servernum],
169 aaaserver->secret[servernum], timeout, retries);
171 if (request_type == PW_ACCOUNTING_REQUEST) {
172 dtime = rc_getmtime() - start_time;
176 result = rc_send_server_ctx(rh, ctx, &data, msg, type);
178 if ((result == OK_RC) || (result == CHALLENGE_RC) || (result == REJECT_RC)) {
179 if (request_type != PW_ACCOUNTING_REQUEST) {
186 "rc_send_server_ctx returned success for server %u", servernum);
193 DEBUG(LOG_INFO,
"rc_send_server_ctx returned error (%d) for server %u: (remaining: %d)",
194 result, servernum, aaaserver->max-servernum);
196 }
while (servernum < aaaserver->max && ((result == TIMEOUT_RC) || (result == NETUNREACH_RC)));
216 VALUE_PAIR ** received,
char *msg,
int add_nas_port,
219 return rc_aaa_ctx(rh, NULL, nas_port, send, received, msg,
220 add_nas_port, request_type);
239 return rc_aaa(rh, nas_port, send, received, msg, 1,
260 return rc_aaa(rh, 0, send, received, msg, 0, PW_ACCESS_REQUEST);
276 return rc_aaa(rh, nas_port, send, NULL, NULL, 1,
277 PW_ACCOUNTING_REQUEST);
290 return rc_aaa(rh, 0, send, NULL, NULL, 0, PW_ACCOUNTING_REQUEST);
303int rc_check(rc_handle * rh,
char *host,
char *secret,
unsigned short port,
308 uint32_t service_type;
309 int timeout = rc_conf_int(rh,
"radius_timeout");
310 int retries = rc_conf_int(rh,
"radius_retries");
324 service_type = PW_ADMINISTRATIVE;
328 rc_buildreq(rh, &data, PW_STATUS_SERVER, host, port, secret, timeout,
int rc_acct(rc_handle *rh, uint32_t nas_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 nas_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg)
void rc_buildreq(rc_handle const *rh, SEND_DATA *data, int code, char *server, unsigned short port, char *secret, int timeout, int retries)
int rc_acct_proxy(rc_handle *rh, VALUE_PAIR *send)
void rc_avpair_free(VALUE_PAIR *pair)
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)
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)
int rc_avpair_assign(VALUE_PAIR *vp, void const *pval, int len)
int rc_send_server(rc_handle *rh, SEND_DATA *data, char *msg, rc_type type)
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)
int rc_check(rc_handle *rh, char *host, char *secret, unsigned short port, char *msg)
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)
VALUE_PAIR * rc_avpair_get(VALUE_PAIR *vp, uint32_t attrid, uint32_t vendorspec)
@ ACCT
Request for accounting server.
@ AUTH
Request for authentication server.
@ PW_NAS_PORT
Its type is integer.
@ PW_SERVICE_TYPE
Its type is integer.
@ PW_ACCT_DELAY_TIME
Its type is integer.
@ RC_SOCKET_DTLS
DTLS socket.
@ RC_SOCKET_TLS
TLS socket.
uint32_t lvalue
attribute value if type is PW_TYPE_INTEGER, PW_TYPE_DATE or PW_TYPE_IPADDR.
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.