161 radcli_code *out_code, radcli_avp_list **out_attrs)
163 rc_handle *rh = (rc_handle *)ctx;
167 const radcli_attr_def *d_adt;
169 int timeout, retries;
170 int servernum, result = ERROR_RC;
172 if (rh == NULL || send == NULL)
175 if (code != RADCLI_CODE_ACCESS_REQUEST && code != RADCLI_CODE_ACCOUNTING_REQUEST) {
176 rc_log(LOG_ERR,
"radcli_aaa: code must be RADCLI_CODE_ACCESS_REQUEST "
177 "or RADCLI_CODE_ACCOUNTING_REQUEST");
183 if (rh->so_type == RC_SOCKET_TLS || rh->so_type == RC_SOCKET_DTLS ||
184 code == RADCLI_CODE_ACCESS_REQUEST) {
185 optname =
"authserver";
188 optname =
"acctserver";
192 servers = radcli2_priv_conf_srv(rh, optname);
193 if (servers == NULL || servers->max == 0) {
194 rc_log(LOG_ERR,
"radcli_aaa: no %s configured", optname);
198 timeout = rc_conf_int_id(rh, OPT_RADIUS_TIMEOUT);
199 retries = rc_conf_int_id(rh, OPT_RADIUS_RETRIES);
210 start_time = rc_getmtime();
211 if (code == RADCLI_CODE_ACCOUNTING_REQUEST && d_adt != NULL) {
214 if (existing != NULL) {
224 radcli_avp_list *attempt;
225 uint8_t recv_buffer[RC_BUFFER_LEN];
226 unsigned char vector[AUTH_VECTOR_LEN];
228 uint8_t reply_code = 0;
229 char server[AUTH_ID_LEN + 1] =
"";
230 char secret[MAX_SECRET_LENGTH + 1] =
"";
232 attempt = build_attempt(send, code, d_adt, start_time);
236 strlcpy(server, servers->name[servernum],
sizeof(server));
237 if (servers->secret[servernum] != NULL)
238 strlcpy(secret, servers->secret[servernum],
sizeof(secret));
240 result = radcli_do_exchange(rh, (uint8_t)code, attempt, server,
241 servers->port[servernum], secret,
242 timeout, retries, 0, type,
243 recv_buffer,
sizeof(recv_buffer), &recv_len,
244 vector, &reply_code);
247 memset(secret, 0,
sizeof(secret));
249 if (result == OK_RC || result == REJECT_RC || result == CHALLENGE_RC) {
250 radcli_avp_list *decoded = NULL;
253 if (radcli_avp_decode(rh, servers->secret[servernum] ? servers->secret[servernum] :
"",
254 vector, recv_buffer, recv_len, 0, &decoded) != 0)
258 if (out_code != NULL)
260 if (out_attrs != NULL)
261 *out_attrs = decoded;
265 DEBUG(rh, LOG_INFO,
"radcli_aaa: succeeded against server %u (%s)",
270 DEBUG(rh, LOG_INFO,
"radcli_aaa: attempt against server %u (%s) failed "
271 "(%d); remaining: %d", servernum, server, result,
272 servers->max - servernum - 1);
274 }
while (servernum < servers->max && (result == TIMEOUT_RC || result == NETUNREACH_RC));
int radcli_aaa(radcli_ctx *ctx, radcli_code code, const radcli_avp_list *send, radcli_code *out_code, radcli_avp_list **out_attrs)
Perform an authentication or accounting exchange with Acct-Delay-Time autofill and fail-over across e...