summaryrefslogtreecommitdiff
path: root/accel-pppd/radius
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd/radius')
-rw-r--r--accel-pppd/radius/acct.c68
-rw-r--r--accel-pppd/radius/auth.c58
-rw-r--r--accel-pppd/radius/backup.c20
-rw-r--r--accel-pppd/radius/dict.c10
-rw-r--r--accel-pppd/radius/dm_coa.c20
-rw-r--r--accel-pppd/radius/packet.c46
-rw-r--r--accel-pppd/radius/radius.c54
-rw-r--r--accel-pppd/radius/radius_p.h6
-rw-r--r--accel-pppd/radius/req.c38
-rw-r--r--accel-pppd/radius/serv.c92
-rw-r--r--accel-pppd/radius/stat_accm.c10
11 files changed, 211 insertions, 211 deletions
diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c
index 7ac6e394..3d194474 100644
--- a/accel-pppd/radius/acct.c
+++ b/accel-pppd/radius/acct.c
@@ -23,7 +23,7 @@
static int req_set_RA(struct rad_req_t *req, const char *secret)
{
MD5_CTX ctx;
-
+
if (rad_packet_build(req->pack, req->RA))
return -1;
@@ -41,7 +41,7 @@ static int req_set_stat(struct rad_req_t *req, struct ap_session *ses)
struct radius_pd_t *rpd = req->rpd;
struct timespec ts;
int ret = 0;
-
+
if (ses->stop_time)
ts.tv_sec = ses->stop_time;
else
@@ -68,7 +68,7 @@ static void rad_acct_sent(struct rad_req_t *req, int res)
return;
__sync_add_and_fetch(&req->serv->stat_interim_sent, 1);
-
+
if (!req->hnd.tpd)
triton_md_register_handler(req->rpd->ses->ctrl->ctx, &req->hnd);
@@ -82,7 +82,7 @@ static void rad_acct_sent(struct rad_req_t *req, int res)
static void rad_acct_recv(struct rad_req_t *req)
{
- int dt = (req->reply->tv.tv_sec - req->pack->tv.tv_sec) * 1000 +
+ int dt = (req->reply->tv.tv_sec - req->pack->tv.tv_sec) * 1000 +
(req->reply->tv.tv_nsec - req->pack->tv.tv_nsec) / 1000000;
stat_accm_add(req->serv->stat_interim_query_1m, dt);
@@ -91,7 +91,7 @@ static void rad_acct_recv(struct rad_req_t *req)
triton_timer_del(&req->timeout);
triton_md_unregister_handler(&req->hnd, 1);
-
+
rad_packet_free(req->reply);
req->reply = NULL;
}
@@ -101,7 +101,7 @@ static void rad_acct_timeout(struct triton_timer_t *t)
struct rad_req_t *req = container_of(t, typeof(*req), timeout);
time_t dt;
struct timespec ts;
-
+
rad_server_req_exit(req);
rad_server_timeout(req->serv);
@@ -134,8 +134,8 @@ static void rad_acct_timeout(struct triton_timer_t *t)
}
if (conf_acct_delay_time)
- req->pack->id++;
-
+ req->pack->id++;
+
req->try = 0;
if (rad_req_send(req) && conf_acct_timeout) {
@@ -152,7 +152,7 @@ static void rad_acct_interim_update(struct triton_timer_t *t)
if (rpd->acct_req->entry.next || rpd->acct_req->timeout.tpd)
return;
- if (rpd->session_timeout.expire_tv.tv_sec &&
+ if (rpd->session_timeout.expire_tv.tv_sec &&
rpd->session_timeout.expire_tv.tv_sec - (_time() - rpd->ses->start_time) < INTERIM_SAFE_TIME)
return;
@@ -170,7 +170,7 @@ static void rad_acct_interim_update(struct triton_timer_t *t)
if (!rpd->acct_req->before_send)
req_set_RA(rpd->acct_req, rpd->acct_req->serv->secret);
-
+
rpd->acct_req->timeout.expire_tv.tv_sec = conf_timeout;
rpd->acct_req->try = 0;
@@ -185,7 +185,7 @@ static int rad_acct_before_send(struct rad_req_t *req)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
-
+
rad_packet_change_int(req->pack, NULL, "Acct-Delay-Time", ts.tv_sec - req->ts);
req_set_RA(req, req->serv->secret);
@@ -198,12 +198,12 @@ static void rad_acct_start_sent(struct rad_req_t *req, int res)
ap_session_terminate(req->rpd->ses, TERM_NAS_ERROR, 0);
return;
}
-
+
__sync_add_and_fetch(&req->serv->stat_acct_sent, 1);
-
+
if (!req->hnd.tpd)
triton_md_register_handler(req->rpd->ses->ctrl->ctx, &req->hnd);
-
+
triton_md_enable_handler(&req->hnd, MD_MODE_READ);
if (req->timeout.tpd)
@@ -215,7 +215,7 @@ static void rad_acct_start_sent(struct rad_req_t *req, int res)
static void rad_acct_start_recv(struct rad_req_t *req)
{
struct radius_pd_t *rpd = req->rpd;
- int dt = (req->reply->tv.tv_sec - req->pack->tv.tv_sec) * 1000 +
+ int dt = (req->reply->tv.tv_sec - req->pack->tv.tv_sec) * 1000 +
(req->reply->tv.tv_nsec - req->pack->tv.tv_nsec) / 1000000;
stat_accm_add(req->serv->stat_acct_query_1m, dt);
@@ -224,7 +224,7 @@ static void rad_acct_start_recv(struct rad_req_t *req)
triton_timer_del(&req->timeout);
triton_md_unregister_handler(&req->hnd, 1);
-
+
if (rpd->acct_interim_interval) {
rad_packet_free(req->reply);
req->reply = NULL;
@@ -244,20 +244,20 @@ static void rad_acct_start_recv(struct rad_req_t *req)
}
rpd->acct_started = 1;
-
+
ap_session_accounting_started(rpd->ses);
}
static void rad_acct_start_timeout(struct triton_timer_t *t)
{
struct rad_req_t *req = container_of(t, typeof(*req), timeout);
-
+
rad_server_timeout(req->serv);
__sync_add_and_fetch(&req->serv->stat_acct_lost, 1);
stat_accm_add(req->serv->stat_acct_lost_1m, 1);
stat_accm_add(req->serv->stat_acct_lost_5m, 1);
-
+
if (req->before_send)
req->pack->id++;
@@ -281,7 +281,7 @@ int rad_acct_start(struct radius_pd_t *rpd)
req->before_send = rad_acct_before_send;
else if (req_set_RA(req, req->serv->secret))
goto out_err;
-
+
req->recv = rad_acct_start_recv;
req->timeout.expire = rad_acct_start_timeout;
req->timeout.expire_tv.tv_sec = conf_timeout;
@@ -290,7 +290,7 @@ int rad_acct_start(struct radius_pd_t *rpd)
if (rad_req_send(req))
goto out_err;
-
+
rpd->acct_req = req;
return 0;
@@ -305,22 +305,22 @@ static void rad_acct_stop_sent(struct rad_req_t *req, int res)
if (res) {
if (ap_shutdown) {
struct radius_pd_t *rpd = req->rpd;
-
+
rad_req_free(req);
-
+
if (rpd)
rpd->acct_req = NULL;
} else if (req->rpd)
rad_acct_stop_defer(req->rpd);
-
+
return;
}
-
+
__sync_add_and_fetch(&req->serv->stat_acct_sent, 1);
-
+
if (!req->hnd.tpd)
triton_md_register_handler(req->rpd ? req->rpd->ses->ctrl->ctx : NULL, &req->hnd);
-
+
triton_md_enable_handler(&req->hnd, MD_MODE_READ);
if (req->timeout.tpd)
@@ -332,7 +332,7 @@ static void rad_acct_stop_sent(struct rad_req_t *req, int res)
static void rad_acct_stop_recv(struct rad_req_t *req)
{
struct radius_pd_t *rpd = req->rpd;
- int dt = (req->reply->tv.tv_sec - req->pack->tv.tv_sec) * 1000 +
+ int dt = (req->reply->tv.tv_sec - req->pack->tv.tv_sec) * 1000 +
(req->reply->tv.tv_nsec - req->pack->tv.tv_nsec) / 1000000;
stat_accm_add(req->serv->stat_acct_query_1m, dt);
@@ -360,7 +360,7 @@ static void rad_acct_stop_timeout(struct triton_timer_t *t)
__sync_add_and_fetch(&req->serv->stat_acct_lost, 1);
stat_accm_add(req->serv->stat_acct_lost_1m, 1);
stat_accm_add(req->serv->stat_acct_lost_5m, 1);
-
+
if (req->before_send)
req->pack->id++;
}
@@ -388,7 +388,7 @@ static void start_deferred(struct rad_req_t *req)
if (rad_req_read(&req->hnd))
return;
}
-
+
triton_timer_add(NULL, &req->timeout, 0);
}
@@ -416,7 +416,7 @@ int rad_acct_stop(struct radius_pd_t *rpd)
if (rpd->acct_interim_timer.tpd)
triton_timer_del(&rpd->acct_interim_timer);
- if (req) {
+ if (req) {
rad_server_req_cancel(req, 1);
clock_gettime(CLOCK_MONOTONIC, &ts);
@@ -426,7 +426,7 @@ int rad_acct_stop(struct radius_pd_t *rpd)
req = rad_req_alloc(rpd, CODE_ACCOUNTING_REQUEST, rpd->ses->username);
if (!req)
return -1;
-
+
if (rad_req_acct_fill(req)) {
log_ppp_error("radius:acct: failed to fill accounting attributes\n");
rad_req_free(req);
@@ -470,13 +470,13 @@ int rad_acct_stop(struct radius_pd_t *rpd)
rad_packet_change_val(req->pack, NULL, "Acct-Status-Type", "Stop");
req_set_stat(req, rpd->ses);
req_set_RA(req, req->serv->secret);
-
+
req->recv = rad_acct_stop_recv;
req->timeout.expire = rad_acct_start_timeout;
req->timeout.expire_tv.tv_sec = conf_timeout;
req->sent = rad_acct_stop_sent;
req->log = conf_verbose ? log_ppp_info1 : NULL;
-
+
if (rad_req_send(req)) {
rad_acct_stop_defer(rpd);
return -1;
diff --git a/accel-pppd/radius/auth.c b/accel-pppd/radius/auth.c
index 43dec233..fbc2fab5 100644
--- a/accel-pppd/radius/auth.c
+++ b/accel-pppd/radius/auth.c
@@ -22,7 +22,7 @@ static int decrypt_chap_mppe_keys(struct rad_req_t *req, struct rad_attr_t *attr
uint8_t sha1[SHA_DIGEST_LENGTH];
uint8_t plain[32];
int i;
-
+
if (attr->len != 32) {
log_ppp_warn("radius: %s: incorrect attribute length (%i)\n", attr->attr->name, attr->len);
return -1;
@@ -37,7 +37,7 @@ static int decrypt_chap_mppe_keys(struct rad_req_t *req, struct rad_attr_t *attr
for (i = 0; i < 16; i++)
plain[i] ^= md5[i];
-
+
MD5_Init(&md5_ctx);
MD5_Update(&md5_ctx, req->serv->secret, strlen(req->serv->secret));
MD5_Update(&md5_ctx, attr->val.octets, 16);
@@ -45,7 +45,7 @@ static int decrypt_chap_mppe_keys(struct rad_req_t *req, struct rad_attr_t *attr
for (i = 0; i < 16; i++)
plain[i + 16] ^= md5[i];
-
+
SHA1_Init(&sha1_ctx);
SHA1_Update(&sha1_ctx, plain + 8, 16);
SHA1_Update(&sha1_ctx, plain + 8, 16);
@@ -63,7 +63,7 @@ static int decrypt_mppe_key(struct rad_req_t *req, struct rad_attr_t *attr, uint
uint8_t md5[16];
uint8_t plain[32];
int i;
-
+
if (attr->len != 34) {
log_ppp_warn("radius: %s: incorrect attribute length (%i)\n", attr->attr->name, attr->len);
return -1;
@@ -84,7 +84,7 @@ static int decrypt_mppe_key(struct rad_req_t *req, struct rad_attr_t *attr, uint
for (i = 0; i < 16; i++)
plain[i] ^= md5[i];
-
+
if (plain[0] != 16) {
log_ppp_warn("radius: %s: incorrect key length (%i)\n", attr->attr->name, plain[0]);
return -1;
@@ -116,7 +116,7 @@ static uint8_t* encrypt_password(const char *passwd, const char *secret, const u
*epasswd_len = 0;
return (uint8_t *)1;
}
-
+
epasswd = _malloc(chunk_cnt * 16);
if (!epasswd) {
log_emerg("radius: out of memory\n");
@@ -132,7 +132,7 @@ static uint8_t* encrypt_password(const char *passwd, const char *secret, const u
MD5_Update(&ctx, secret, strlen(secret));
MD5_Update(&ctx, c, 16);
MD5_Final(b, &ctx);
-
+
for(j = 0; j < 16; j++)
epasswd[i * 16 + j] ^= b[j];
@@ -164,17 +164,17 @@ static void rad_auth_recv(struct rad_req_t *req)
unsigned int dt;
triton_timer_del(&req->timeout);
-
+
dt = (req->reply->tv.tv_sec - req->pack->tv.tv_sec) * 1000 + (req->reply->tv.tv_nsec - req->pack->tv.tv_nsec) / 1000000;
stat_accm_add(req->serv->stat_auth_query_1m, dt);
stat_accm_add(req->serv->stat_auth_query_5m, dt);
-
+
if (pack->code == CODE_ACCESS_ACCEPT) {
if (rad_proc_attrs(req)) {
rad_auth_finalize(req->rpd, PWDB_DENIED);
return;
}
-
+
struct ev_radius_t ev = {
.ses = req->rpd->ses,
.request = req->pack,
@@ -185,14 +185,14 @@ static void rad_auth_recv(struct rad_req_t *req)
rad_auth_finalize(req->rpd, PWDB_DENIED);
return;
}
-
+
if (req->rpd->auth_ctx->recv && req->rpd->auth_ctx->recv(req)) {
rad_auth_finalize(req->rpd, PWDB_DENIED);
return;
}
-
+
req->rpd->authenticated = 1;
-
+
rad_auth_finalize(req->rpd, PWDB_SUCCESS);
}
@@ -201,7 +201,7 @@ static void rad_auth_timeout(struct triton_timer_t *t)
struct rad_req_t *req = container_of(t, typeof(*req), timeout);
rad_server_timeout(req->serv);
-
+
__sync_add_and_fetch(&req->serv->stat_auth_lost, 1);
stat_accm_add(req->serv->stat_auth_lost_1m, 1);
stat_accm_add(req->serv->stat_auth_lost_5m, 1);
@@ -216,14 +216,14 @@ static void rad_auth_sent(struct rad_req_t *req, int res)
rad_auth_finalize(req->rpd, PWDB_DENIED);
return;
}
-
+
__sync_add_and_fetch(&req->serv->stat_auth_sent, 1);
-
+
if (!req->hnd.tpd)
triton_md_register_handler(req->rpd->ses->ctrl->ctx, &req->hnd);
-
+
triton_md_enable_handler(&req->hnd, MD_MODE_READ);
-
+
if (req->timeout.tpd)
triton_timer_mod(&req->timeout, 0);
else
@@ -233,10 +233,10 @@ static void rad_auth_sent(struct rad_req_t *req, int res)
static struct rad_req_t *rad_auth_req_alloc(struct radius_pd_t *rpd, const char *username, int (*recv)(struct rad_req_t *))
{
struct rad_req_t *req = rad_req_alloc(rpd, CODE_ACCESS_REQUEST, username);
-
+
if (!req)
return NULL;
-
+
if (conf_sid_in_auth) {
if (rad_packet_add_str(req->pack, NULL, "Acct-Session-Id", rpd->ses->sessionid))
goto out;
@@ -275,7 +275,7 @@ int rad_auth_pap(struct radius_pd_t *rpd, const char *username, va_list args)
if (!req)
return PWDB_DENIED;
-
+
epasswd = encrypt_password(passwd, req->serv->secret, req->RA, &epasswd_len);
if (!epasswd)
return PWDB_DENIED;
@@ -283,7 +283,7 @@ int rad_auth_pap(struct radius_pd_t *rpd, const char *username, va_list args)
r = rad_packet_add_octets(req->pack, NULL, "User-Password", epasswd, epasswd_len);
if (epasswd_len)
_free(epasswd);
-
+
if (r)
return PWDB_DENIED;
@@ -301,7 +301,7 @@ int rad_auth_chap_md5(struct radius_pd_t *rpd, const char *username, va_list arg
uint8_t *challenge = va_arg(args, uint8_t *);
int challenge_len = va_arg(args, int);
uint8_t *response = va_arg(args, uint8_t *);
-
+
if (!req)
return PWDB_DENIED;
@@ -316,7 +316,7 @@ int rad_auth_chap_md5(struct radius_pd_t *rpd, const char *username, va_list arg
if (rad_packet_add_octets(req->pack, NULL, "CHAP-Password", chap_password, 17))
return PWDB_DENIED;
-
+
if (rad_req_send(req))
return PWDB_DENIED;
@@ -410,10 +410,10 @@ int rad_auth_mschap_v1(struct radius_pd_t *rpd, const char *username, va_list ar
if (rad_packet_add_octets(req->pack, "Microsoft", "MS-CHAP-Challenge", challenge, challenge_len))
return PWDB_DENIED;
-
+
if (rad_packet_add_octets(req->pack, "Microsoft", "MS-CHAP-Response", response, sizeof(response)))
return PWDB_DENIED;
-
+
if (rad_req_send(req))
return PWDB_DENIED;
@@ -481,10 +481,10 @@ int rad_auth_mschap_v2(struct radius_pd_t *rpd, const char *username, va_list ar
if (rad_packet_add_octets(req->pack, "Microsoft", "MS-CHAP-Challenge", challenge, 16))
return PWDB_DENIED;
-
+
if (rad_packet_add_octets(req->pack, "Microsoft", "MS-CHAP2-Response", mschap_response, sizeof(mschap_response)))
return PWDB_DENIED;
-
+
if (rad_req_send(req))
return PWDB_DENIED;
@@ -494,7 +494,7 @@ int rad_auth_mschap_v2(struct radius_pd_t *rpd, const char *username, va_list ar
int rad_auth_null(struct radius_pd_t *rpd, const char *username, va_list args)
{
struct rad_req_t *req = rad_auth_req_alloc(rpd, username, NULL);
-
+
if (!req)
return PWDB_DENIED;
diff --git a/accel-pppd/radius/backup.c b/accel-pppd/radius/backup.c
index a44a7606..93ab3eb0 100644
--- a/accel-pppd/radius/backup.c
+++ b/accel-pppd/radius/backup.c
@@ -40,29 +40,29 @@ static int session_save(struct ap_session *ses, struct backup_mod *m)
return -2;
add_tag(RAD_TAG_INTERIM_INTERVAL, &rpd->acct_interim_interval, 4);
-
+
if (rpd->session_timeout.tpd)
add_tag(RAD_TAG_SESSION_TIMEOUT, &session_timeout, 8);
-
+
if (rpd->idle_timeout.tpd)
add_tag(RAD_TAG_IDLE_TIMEOUT, &idle_timeout, 4);
-
+
if (ses->ipv4 == &rpd->ipv4_addr)
add_tag(RAD_TAG_IPV4_ADDR, NULL, 0);
-
+
if (ses->ipv6 == &rpd->ipv6_addr)
add_tag(RAD_TAG_IPV6_ADDR, NULL, 0);
-
+
/*if (rpd->ipv6_pd_assigned) {
}*/
if (rpd->attr_class)
add_tag(RAD_TAG_ATTR_CLASS, rpd->attr_class, rpd->attr_class_len);
-
+
if (rpd->attr_state)
add_tag(RAD_TAG_ATTR_CLASS, rpd->attr_state, rpd->attr_state_len);
-
+
add_tag(RAD_TAG_TERMINATION_ACTION, &rpd->termination_action, 4);
if (rpd->acct_req) {
@@ -109,7 +109,7 @@ void radius_restore_session(struct ap_session *ses, struct radius_pd_t *rpd)
if (!m)
return;
-
+
list_for_each_entry(tag, &m->tag_list, entry) {
switch (tag->id) {
case RAD_TAG_INTERIM_INTERVAL:
@@ -149,10 +149,10 @@ void radius_restore_session(struct ap_session *ses, struct radius_pd_t *rpd)
break;
}
}
-
+
if (acct_addr)
rpd->acct_req = rad_req_alloc2(rpd, CODE_ACCOUNTING_REQUEST, rpd->ses->username, acct_addr, acct_port);
-
+
rpd->authenticated = 1;
}
diff --git a/accel-pppd/radius/dict.c b/accel-pppd/radius/dict.c
index 32af3445..7f4849cd 100644
--- a/accel-pppd/radius/dict.c
+++ b/accel-pppd/radius/dict.c
@@ -15,7 +15,7 @@ static struct rad_dict_t *dict;
static char *skip_word(char *ptr)
{
for(; *ptr; ptr++)
- if (*ptr == ' ' || *ptr == '\t' || *ptr == '\n')
+ if (*ptr == ' ' || *ptr == '\t' || *ptr == '\n')
break;
return ptr;
}
@@ -34,9 +34,9 @@ static int split(char *buf, char **ptr)
buf = skip_word(buf);
if (!*buf)
return i;
-
+
*buf = 0;
-
+
buf = skip_space(buf + 1);
if (!*buf)
return i;
@@ -82,7 +82,7 @@ static int dict_load(const char *fname)
log_emerg("radius: open dictioanary '%s': %s\n", fname, strerror(errno));
return -1;
}
-
+
items = &dict->items;
while (fgets(buf, BUF_SIZE, f)) {
@@ -301,7 +301,7 @@ __export struct rad_dict_attr_t *rad_dict_find_attr_id(struct rad_dict_vendor_t
{
struct rad_dict_attr_t *attr;
struct list_head *items = vendor ? &vendor->items : &dict->items;
-
+
list_for_each_entry(attr, items, entry)
if (attr->id == id)
return attr;
diff --git a/accel-pppd/radius/dm_coa.c b/accel-pppd/radius/dm_coa.c
index 0235ba4a..fd59bf11 100644
--- a/accel-pppd/radius/dm_coa.c
+++ b/accel-pppd/radius/dm_coa.c
@@ -36,7 +36,7 @@ static int dm_coa_check_RA(struct rad_packet_t *pack, const char *secret)
MD5_CTX ctx;
memset(RA, 0, 16);
-
+
MD5_Init(&ctx);
MD5_Update(&ctx, pack->buf, 4);
MD5_Update(&ctx, RA, 16);
@@ -69,7 +69,7 @@ static int dm_coa_send_ack(int fd, struct rad_packet_t *req, struct sockaddr_in
return -1;
reply->id = req->id;
-
+
if (rad_packet_build(reply, RA)) {
rad_packet_free(reply);
return -1;
@@ -83,7 +83,7 @@ static int dm_coa_send_ack(int fd, struct rad_packet_t *req, struct sockaddr_in
}
rad_packet_send(reply, fd, addr);
-
+
rad_packet_free(reply);
return 0;
@@ -118,7 +118,7 @@ static int dm_coa_send_nak(int fd, struct rad_packet_t *req, struct sockaddr_in
}
rad_packet_send(reply, fd, addr);
-
+
rad_packet_free(reply);
return 0;
@@ -135,7 +135,7 @@ static void disconnect_request(struct radius_pd_t *rpd)
dm_coa_send_ack(serv.hnd.fd, rpd->dm_coa_req, &rpd->dm_coa_addr);
rad_packet_free(rpd->dm_coa_req);
-
+
pthread_mutex_lock(&rpd->lock);
rpd->dm_coa_req = NULL;
pthread_mutex_unlock(&rpd->lock);
@@ -183,7 +183,7 @@ static void coa_request(struct radius_pd_t *rpd)
dm_coa_send_ack(serv.hnd.fd, rpd->dm_coa_req, &rpd->dm_coa_addr);
}
-
+
rad_packet_free(rpd->dm_coa_req);
pthread_mutex_lock(&rpd->lock);
@@ -232,14 +232,14 @@ static int dm_coa_read(struct triton_md_handler_t *h)
err_code = 403;
goto out_err;
}
-
+
rpd = rad_find_session_pack(pack);
if (!rpd) {
log_warn("radius:dm_coa: session not found\n");
err_code = 503;
goto out_err;
}
-
+
if (rpd->dm_coa_req) {
pthread_mutex_unlock(&rpd->lock);
goto out_err_no_reply;
@@ -292,7 +292,7 @@ static void init(void)
log_emerg("radius:dm_coa: socket: %s\n", strerror(errno));
return;
}
-
+
fcntl(serv.hnd.fd, F_SETFD, fcntl(serv.hnd.fd, F_GETFD) | FD_CLOEXEC);
addr.sin_family = AF_INET;
@@ -312,7 +312,7 @@ static void init(void)
close(serv.hnd.fd);
return;
}
-
+
triton_context_register(&serv.ctx, NULL);
triton_md_register_handler(&serv.ctx, &serv.hnd);
triton_md_enable_handler(&serv.hnd, MD_MODE_READ);
diff --git a/accel-pppd/radius/packet.c b/accel-pppd/radius/packet.c
index 87c337fe..92e43e2b 100644
--- a/accel-pppd/radius/packet.c
+++ b/accel-pppd/radius/packet.c
@@ -61,7 +61,7 @@ int rad_packet_build(struct rad_packet_t *pack, uint8_t *RA)
log_emerg("radius:packet: out of memory\n");
return -1;
}
-
+
pack->buf = ptr;
} else
ptr = pack->buf;
@@ -76,7 +76,7 @@ int rad_packet_build(struct rad_packet_t *pack, uint8_t *RA)
*ptr = 26; ptr++;
*ptr = attr->len + 2 + 6; ptr++;
*(uint32_t *)ptr = htonl(attr->vendor->id); ptr+=4;
- }
+ }
*ptr = attr->attr->id; ptr++;
*ptr = attr->len + 2; ptr++;
switch(attr->attr->type) {
@@ -133,7 +133,7 @@ int rad_packet_recv(int fd, struct rad_packet_t **p, struct sockaddr_in *addr)
log_emerg("radius:packet: out of memory\n");
goto out_err;
}
-
+
pack->buf = ptr;
clock_gettime(CLOCK_MONOTONIC, &pack->tv);
@@ -225,7 +225,7 @@ int rad_packet_recv(int fd, struct rad_packet_t **p, struct sockaddr_in *addr)
goto out_err;
}
memcpy(attr->val.octets, ptr, len);
- break;
+ break;
case ATTR_TYPE_DATE:
case ATTR_TYPE_INTEGER:
attr->val.integer = ntohl(*(uint32_t*)ptr);
@@ -260,7 +260,7 @@ out_err:
void rad_packet_free(struct rad_packet_t *pack)
{
struct rad_attr_t *attr;
-
+
if (pack->buf)
mempool_free(pack->buf);
//munmap(pack->buf, REQ_LENGTH_MAX);
@@ -286,7 +286,7 @@ void rad_packet_print(struct rad_packet_t *pack, struct rad_server_t *s, void (*
uint16_t u16[4];
} ifid_u;
in_addr_t addr;
-
+
if (s)
print("[RADIUS(%i) ", s->id);
else
@@ -392,7 +392,7 @@ int __export rad_packet_add_int(struct rad_packet_t *pack, const char *vendor_na
if (!attr)
return -1;
-
+
ra = mempool_alloc(attr_pool);
if (!ra)
return -1;
@@ -411,7 +411,7 @@ int __export rad_packet_add_int(struct rad_packet_t *pack, const char *vendor_na
int __export rad_packet_change_int(struct rad_packet_t *pack, const char *vendor_name, const char *name, int val)
{
struct rad_attr_t *ra;
-
+
ra = rad_packet_find_attr(pack, vendor_name, name);
if (!ra)
return -1;
@@ -439,10 +439,10 @@ int __export rad_packet_add_octets(struct rad_packet_t *pack, const char *vendor
vendor = NULL;
attr = rad_dict_find_attr(name);
}
-
+
if (!attr)
return -1;
-
+
ra = mempool_alloc(attr_pool);
if (!ra) {
log_emerg("radius: out of memory\n");
@@ -473,7 +473,7 @@ int __export rad_packet_add_octets(struct rad_packet_t *pack, const char *vendor
int __export rad_packet_change_octets(struct rad_packet_t *pack, const char *vendor_name, const char *name, const uint8_t *val, int len)
{
struct rad_attr_t *ra;
-
+
ra = rad_packet_find_attr(pack, vendor_name, name);
if (!ra)
return -1;
@@ -487,7 +487,7 @@ int __export rad_packet_change_octets(struct rad_packet_t *pack, const char *ven
log_emerg("radius: out of memory\n");
return -1;
}
-
+
pack->len += len - ra->len;
ra->len = len;
}
@@ -521,7 +521,7 @@ int __export rad_packet_add_str(struct rad_packet_t *pack, const char *vendor_na
if (!attr)
return -1;
-
+
ra = mempool_alloc(attr_pool);
if (!ra) {
log_emerg("radius: out of memory\n");
@@ -549,7 +549,7 @@ int __export rad_packet_add_str(struct rad_packet_t *pack, const char *vendor_na
int __export rad_packet_change_str(struct rad_packet_t *pack, const char *vendor_name, const char *name, const char *val, int len)
{
struct rad_attr_t *ra;
-
+
ra = rad_packet_find_attr(pack, vendor_name, name);
if (!ra)
return -1;
@@ -563,7 +563,7 @@ int __export rad_packet_change_str(struct rad_packet_t *pack, const char *vendor
log_emerg("radius: out of memory\n");
return -1;
}
-
+
pack->len += len - ra->len;
ra->len = len;
}
@@ -593,14 +593,14 @@ int __export rad_packet_add_val(struct rad_packet_t *pack, const char *vendor_na
vendor = NULL;
attr = rad_dict_find_attr(name);
}
-
+
if (!attr)
return -1;
v = rad_dict_find_val_name(attr, val);
if (!v)
return -1;
-
+
ra = mempool_alloc(attr_pool);
if (!ra)
return -1;
@@ -620,7 +620,7 @@ int __export rad_packet_change_val(struct rad_packet_t *pack, const char *vendor
{
struct rad_attr_t *ra;
struct rad_dict_value_t *v;
-
+
ra = rad_packet_find_attr(pack, vendor_name, name);
if (!ra)
return -1;
@@ -630,7 +630,7 @@ int __export rad_packet_change_val(struct rad_packet_t *pack, const char *vendor
return -1;
ra->val = v->val;
-
+
return 0;
}
@@ -660,7 +660,7 @@ int rad_packet_add_ifid(struct rad_packet_t *pack, const char *vendor_name, cons
if (!attr)
return -1;
-
+
ra = mempool_alloc(attr_pool);
if (!ra)
return -1;
@@ -697,7 +697,7 @@ int rad_packet_add_ipv6prefix(struct rad_packet_t *pack, const char *vendor_name
if (!attr)
return -1;
-
+
ra = mempool_alloc(attr_pool);
if (!ra)
return -1;
@@ -726,14 +726,14 @@ struct rad_attr_t __export *rad_packet_find_attr(struct rad_packet_t *pack, cons
return NULL;
} else
vendor = NULL;
-
+
list_for_each_entry(ra, &pack->attrs, entry) {
if (vendor && vendor != ra->vendor)
continue;
if (strcmp(ra->attr->name, name))
continue;
-
+
return ra;
}
diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c
index 02df42f5..83d6d07d 100644
--- a/accel-pppd/radius/radius.c
+++ b/accel-pppd/radius/radius.c
@@ -126,10 +126,10 @@ int rad_proc_attrs(struct rad_req_t *req)
else if (rpd->attr_state_len != attr->len)
rpd->attr_state = _realloc(rpd->attr_state, attr->len);
memcpy(rpd->attr_state, attr->val.octets, attr->len);
- rpd->attr_state_len = attr->len;
+ rpd->attr_state_len = attr->len;
break;
case Termination_Action:
- rpd->termination_action = attr->val.integer;
+ rpd->termination_action = attr->val.integer;
break;
case Framed_Interface_Id:
rpd->ipv6_addr.peer_intf_id = attr->val.ifid;
@@ -157,7 +157,7 @@ int rad_proc_attrs(struct rad_req_t *req)
if (wins.ses)
triton_event_fire(EV_WINS, &wins);
-
+
if (!rpd->ses->ipv6_dp && !list_empty(&rpd->ipv6_dp.prefix_list))
rpd->ses->ipv6_dp = &rpd->ipv6_dp;
@@ -178,14 +178,14 @@ static int rad_pwdb_check(struct pwdb_t *pwdb, struct ap_session *ses, pwdb_call
log_ppp_error("radius: username is too large to append realm\n");
return PWDB_DENIED;
}
-
+
memcpy(username1, username, len);
username1[len] = '@';
memcpy(username1 + len + 1, conf_default_realm, conf_default_realm_len);
username1[len + 1 + conf_default_realm_len] = 0;
username = username1;
}
-
+
rpd->auth_ctx = mempool_alloc(auth_ctx_pool);
memset(rpd->auth_ctx, 0, sizeof(*rpd->auth_ctx));
@@ -232,7 +232,7 @@ static int rad_pwdb_check(struct pwdb_t *pwdb, struct ap_session *ses, pwdb_call
static struct ipv4db_item_t *get_ipv4(struct ap_session *ses)
{
struct radius_pd_t *rpd = find_pd(ses);
-
+
if (rpd->ipv4_addr.peer_addr)
return &rpd->ipv4_addr;
return NULL;
@@ -305,7 +305,7 @@ static void ses_starting(struct ap_session *ses)
INIT_LIST_HEAD(&rpd->plugin_list);
INIT_LIST_HEAD(&rpd->ipv6_addr.addr_list);
INIT_LIST_HEAD(&rpd->ipv6_dp.prefix_list);
-
+
rpd->ipv4_addr.owner = &ipdb;
rpd->ipv6_addr.owner = &ipdb;
rpd->ipv6_dp.owner = &ipdb;
@@ -325,10 +325,10 @@ static void ses_starting(struct ap_session *ses)
static void ses_acct_start(struct ap_session *ses)
{
struct radius_pd_t *rpd = find_pd(ses);
-
+
if (!conf_accounting)
return;
-
+
if (!rpd->authenticated)
return;
@@ -402,13 +402,13 @@ static void ses_finished(struct ap_session *ses)
if (rpd->session_timeout.tpd)
triton_timer_del(&rpd->session_timeout);
-
+
if (rpd->idle_timeout.tpd)
triton_timer_del(&rpd->idle_timeout);
if (rpd->attr_class)
_free(rpd->attr_class);
-
+
if (rpd->attr_state)
_free(rpd->attr_state);
@@ -425,7 +425,7 @@ static void ses_finished(struct ap_session *ses)
}
list_del(&rpd->pd.entry);
-
+
release_pd(rpd);
}
@@ -458,7 +458,7 @@ void release_pd(struct radius_pd_t *rpd)
struct radius_pd_t *rad_find_session(const char *sessionid, const char *username, const char *port_id, int port, in_addr_t ipaddr, const char *csid)
{
struct radius_pd_t *rpd;
-
+
pthread_rwlock_rdlock(&sessions_lock);
list_for_each_entry(rpd, &sessions, entry) {
if (!rpd->ses->username)
@@ -492,7 +492,7 @@ struct radius_pd_t *rad_find_session_pack(struct rad_packet_t *pack)
int port = -1;
const char *port_id = NULL;
in_addr_t ipaddr = 0;
-
+
list_for_each_entry(attr, &pack->attrs, entry) {
if (attr->vendor)
continue;
@@ -523,7 +523,7 @@ struct radius_pd_t *rad_find_session_pack(struct rad_packet_t *pack)
if (username && !sessionid && port == -1 && ipaddr == 0 && !port_id)
return NULL;
-
+
return rad_find_session(sessionid, username, port_id, port, ipaddr, csid);
}
@@ -532,7 +532,7 @@ int rad_check_nas_pack(struct rad_packet_t *pack)
struct rad_attr_t *attr;
const char *ident = NULL;
in_addr_t ipaddr = 0;
-
+
list_for_each_entry(attr, &pack->attrs, entry) {
if (!strcmp(attr->attr->name, "NAS-Identifier"))
ident = attr->val.string;
@@ -548,7 +548,7 @@ int rad_check_nas_pack(struct rad_packet_t *pack)
if (conf_nas_ip_address && ipaddr && conf_nas_ip_address != ipaddr)
return -1;
-
+
return 0;
}
@@ -586,9 +586,9 @@ static int parse_server(const char *opt, in_addr_t *addr, int *port, char **secr
*p2 = 0;
else
return -1;
-
+
*addr = inet_addr(str);
-
+
if (p1) {
*port = atoi(p1 + 1);
if (*port <=0 )
@@ -600,7 +600,7 @@ static int parse_server(const char *opt, in_addr_t *addr, int *port, char **secr
*secret = p1;
if (p2)
_free(p2);
-
+
_free(str);
return 0;
@@ -613,7 +613,7 @@ static int load_config(void)
opt = conf_get_opt("radius", "max-try");
if (opt && atoi(opt) > 0)
conf_max_try = atoi(opt);
-
+
opt = conf_get_opt("radius", "timeout");
if (opt && atoi(opt) > 0)
conf_timeout = atoi(opt);
@@ -633,7 +633,7 @@ static int load_config(void)
opt = conf_get_opt("radius", "nas-ip-address");
if (opt)
conf_nas_ip_address = inet_addr(opt);
-
+
if (conf_nas_identifier)
_free(conf_nas_identifier);
opt = conf_get_opt("radius", "nas-identifier");
@@ -641,7 +641,7 @@ static int load_config(void)
conf_nas_identifier = _strdup(opt);
else
conf_nas_identifier = NULL;
-
+
opt = conf_get_opt("radius", "gw-ip-address");
if (opt)
conf_gw_ip_address = inet_addr(opt);
@@ -661,11 +661,11 @@ static int load_config(void)
opt = conf_get_opt("radius", "sid_in_auth");
if (opt)
conf_sid_in_auth = atoi(opt);
-
+
opt = conf_get_opt("radius", "require-nas-identification");
if (opt)
conf_require_nas_ident = atoi(opt);
-
+
opt = conf_get_opt("radius", "acct-interim-interval");
if (opt && atoi(opt) > 0)
conf_acct_interim_interval = atoi(opt);
@@ -675,7 +675,7 @@ static int load_config(void)
conf_acct_delay_time = atoi(opt);
conf_attr_tunnel_type = conf_get_opt("radius", "attr-tunnel-type");
-
+
conf_default_realm = conf_get_opt("radius", "default-realm");
if (conf_default_realm)
conf_default_realm_len = strlen(conf_default_realm);
@@ -695,7 +695,7 @@ static void radius_init(void)
if (load_config())
_exit(EXIT_FAILURE);
-
+
list_for_each_entry(opt1, &s->items, entry) {
if (strcmp(opt1->name, "dictionary") || !opt1->val)
continue;
diff --git a/accel-pppd/radius/radius_p.h b/accel-pppd/radius/radius_p.h
index 6f1be672..9687f820 100644
--- a/accel-pppd/radius/radius_p.h
+++ b/accel-pppd/radius/radius_p.h
@@ -70,9 +70,9 @@ struct rad_req_t {
struct radius_pd_t *rpd;
struct rad_server_t *serv;
-
+
in_addr_t server_addr;
-
+
int server_port;
int type:8;
int try:6;
@@ -214,7 +214,7 @@ int rad_server_realloc(struct rad_req_t *);
void rad_server_fail(struct rad_server_t *);
void rad_server_timeout(struct rad_server_t *);
void rad_server_reply(struct rad_server_t *);
-
+
void radius_restore_session(struct ap_session *ses, struct radius_pd_t *rpd);
struct rtnl_link_stats;
diff --git a/accel-pppd/radius/req.c b/accel-pppd/radius/req.c
index 129116b7..a2cf6a77 100644
--- a/accel-pppd/radius/req.c
+++ b/accel-pppd/radius/req.c
@@ -50,7 +50,7 @@ static struct rad_req_t *__rad_req_alloc(struct radius_pd_t *rpd, int code, cons
if (!req->serv)
goto out_err;
-
+
req->server_addr = req->serv->addr;
req->server_port = req->serv->auth_port;
@@ -73,7 +73,7 @@ static struct rad_req_t *__rad_req_alloc(struct radius_pd_t *rpd, int code, cons
if (rad_packet_add_str(req->pack, NULL, "User-Name", username))
goto out_err;
-
+
if (conf_nas_identifier)
if (rad_packet_add_str(req->pack, NULL, "NAS-Identifier", conf_nas_identifier))
goto out_err;
@@ -84,10 +84,10 @@ static struct rad_req_t *__rad_req_alloc(struct radius_pd_t *rpd, int code, cons
if (rad_packet_add_int(req->pack, NULL, "NAS-Port", rpd->ses->unit_idx))
goto out_err;
-
+
if (rad_packet_add_str(req->pack, NULL, "NAS-Port-Id", rpd->ses->ifname))
goto out_err;
-
+
if (req->rpd->ses->ctrl->type == CTRL_TYPE_IPOE) {
if (rad_packet_add_val(req->pack, NULL, "NAS-Port-Type", "Ethernet"))
goto out_err;
@@ -105,15 +105,15 @@ static struct rad_req_t *__rad_req_alloc(struct radius_pd_t *rpd, int code, cons
if (rpd->ses->ctrl->calling_station_id)
if (rad_packet_add_str(req->pack, NULL, "Calling-Station-Id", rpd->ses->ctrl->calling_station_id))
goto out_err;
-
+
if (rpd->ses->ctrl->called_station_id)
if (rad_packet_add_str(req->pack, NULL, "Called-Station-Id", rpd->ses->ctrl->called_station_id))
goto out_err;
-
+
if (rpd->attr_class)
if (rad_packet_add_octets(req->pack, NULL, "Class", rpd->attr_class, rpd->attr_class_len))
goto out_err;
-
+
if (conf_attr_tunnel_type)
if (rad_packet_add_str(req->pack, NULL, conf_attr_tunnel_type, rpd->ses->ctrl->name))
goto out_err;
@@ -240,7 +240,7 @@ void rad_req_free(struct rad_req_t *req)
triton_md_unregister_handler(&req->hnd, 1);
else if (req->hnd.fd != -1)
close(req->hnd.fd);
-
+
if (req->timeout.tpd)
triton_timer_del(&req->timeout);
@@ -288,7 +288,7 @@ static int make_socket(struct rad_req_t *req)
log_ppp_error("radius: failed to set nonblocking mode: %s\n", strerror(errno));
goto out_err;
}
-
+
return 0;
out_err:
@@ -313,18 +313,18 @@ int __rad_req_send(struct rad_req_t *req, int async)
if (req->hnd.fd == -1 && make_socket(req))
return -1;
-
+
if (req->before_send && req->before_send(req))
goto out_err;
if (!req->pack->buf && rad_packet_build(req->pack, req->RA))
goto out_err;
-
+
if (req->log) {
req->log("send ");
rad_packet_print(req->pack, req->serv, req->log);
}
-
+
if (req->sent)
req->sent(req, 0);
@@ -339,7 +339,7 @@ out_err:
close(req->hnd.fd);
req->hnd.fd = -1;
}
-
+
if (async && req->sent)
req->sent(req, -1);
@@ -355,9 +355,9 @@ int rad_req_send(struct rad_req_t *req)
if (req->try++ == conf_max_try) {
if (req->active)
rad_server_req_exit(req);
-
+
log_ppp_warn("radius: server(%i) not responding\n", req->serv->id);
-
+
if (rad_server_realloc(req)) {
if (req->rpd)
log_ppp_warn("radius: no available servers\n");
@@ -373,7 +373,7 @@ int rad_req_send(struct rad_req_t *req)
if (r >= 0)
break;
-
+
if (rad_server_realloc(req)) {
if (req->rpd)
log_ppp_warn("radius: no available servers\n");
@@ -399,13 +399,13 @@ int rad_req_read(struct triton_md_handler_t *h)
return 0;
rad_server_reply(req->serv);
-
+
if (pack->id == req->pack->id)
break;
-
+
rad_packet_free(pack);
}
-
+
req->reply = pack;
if (req->active)
diff --git a/accel-pppd/radius/serv.c b/accel-pppd/radius/serv.c
index 718a3b2d..c66cc283 100644
--- a/accel-pppd/radius/serv.c
+++ b/accel-pppd/radius/serv.c
@@ -38,7 +38,7 @@ static struct rad_server_t *__rad_server_get(int type, struct rad_server_t *excl
{
struct rad_server_t *s, *s0 = NULL, *s1 = NULL;
struct timespec ts;
-
+
clock_gettime(CLOCK_MONOTONIC, &ts);
list_for_each_entry(s, &serv_list, entry) {
@@ -61,7 +61,7 @@ static struct rad_server_t *__rad_server_get(int type, struct rad_server_t *excl
else if (!s1)
s1 = s;
}
-
+
if (!s0) {
s0 = s;
continue;
@@ -113,7 +113,7 @@ static void req_wakeup(struct rad_req_t *req)
log_switch(triton_context_self(), NULL);
log_ppp_debug("radius(%i): wakeup %p %i\n", req->serv->id, req, req->active);
-
+
if (!req->active)
return;
@@ -126,13 +126,13 @@ static void req_wakeup(struct rad_req_t *req)
req->serv->req_cnt--;
log_ppp_debug("radius(%i): server failed\n", req->serv->id);
pthread_mutex_unlock(&req->serv->lock);
-
+
req->send(req, -1);
return;
}
pthread_mutex_unlock(&req->serv->lock);
-
+
req->send(req, 1);
}
@@ -166,7 +166,7 @@ int rad_server_req_cancel(struct rad_req_t *req, int full)
if (req->timeout.tpd)
triton_timer_del(&req->timeout);
-
+
if (req->hnd.tpd)
triton_md_unregister_handler(&req->hnd, 0);
@@ -176,7 +176,7 @@ int rad_server_req_cancel(struct rad_req_t *req, int full)
int rad_server_req_enter(struct rad_req_t *req)
{
struct timespec ts;
-
+
if (req->serv->need_free || req->serv->starting)
return -1;
@@ -195,7 +195,7 @@ int rad_server_req_enter(struct rad_req_t *req)
assert(!req->entry.next);
pthread_mutex_lock(&req->serv->lock);
-
+
if (ts.tv_sec < req->serv->fail_time) {
pthread_mutex_unlock(&req->serv->lock);
return -1;
@@ -207,13 +207,13 @@ int rad_server_req_enter(struct rad_req_t *req)
req->serv->queue_cnt++;
log_ppp_debug("radius(%i): queue %p\n", req->serv->id, req);
pthread_mutex_unlock(&req->serv->lock);
-
+
if (req->hnd.tpd)
triton_md_disable_handler(&req->hnd, MD_MODE_READ);
return 0;
}
-
+
pthread_mutex_unlock(&req->serv->lock);
return 1;
}
@@ -221,12 +221,12 @@ int rad_server_req_enter(struct rad_req_t *req)
req->serv->req_cnt++;
log_ppp_debug("radius(%i): req_enter %i\n", req->serv->id, req->serv->req_cnt);
pthread_mutex_unlock(&req->serv->lock);
-
+
req->active = 1;
-
+
if (req->send)
return req->send(req, 0);
-
+
return 0;
}
@@ -289,7 +289,7 @@ void rad_server_fail(struct rad_server_t *s)
{
struct rad_req_t *r;
struct timespec ts;
-
+
clock_gettime(CLOCK_MONOTONIC, &ts);
pthread_mutex_lock(&s->lock);
@@ -329,7 +329,7 @@ void rad_server_reply(struct rad_server_t *s)
static int req_set_RA(struct rad_req_t *req, const char *secret)
{
MD5_CTX ctx;
-
+
if (rad_packet_build(req->pack, req->RA))
return -1;
@@ -373,7 +373,7 @@ static void acct_on_timeout(struct triton_timer_t *t)
rad_req_free(req);
if (s->starting)
s->starting = 0;
- else
+ else
__free_server(s);
return;
}
@@ -384,7 +384,7 @@ static void acct_on_timeout(struct triton_timer_t *t)
static void send_acct_on(struct rad_server_t *s)
{
struct rad_req_t *req = rad_req_alloc_empty();
-
+
log_switch(triton_context_self(), NULL);
memset(req, 0, sizeof(*req));
@@ -406,10 +406,10 @@ static void send_acct_on(struct rad_server_t *s)
req->pack = rad_packet_alloc(CODE_ACCOUNTING_REQUEST);
if (!req->pack)
goto out_err;
-
+
if (rad_packet_add_val(req->pack, NULL, "Acct-Status-Type", s->starting ? "Accounting-On" : "Accounting-Off"))
goto out_err;
-
+
if (conf_nas_identifier)
if (rad_packet_add_str(req->pack, NULL, "NAS-Identifier", conf_nas_identifier))
goto out_err;
@@ -417,7 +417,7 @@ static void send_acct_on(struct rad_server_t *s)
if (conf_nas_ip_address)
if (rad_packet_add_ipaddr(req->pack, NULL, "NAS-IP-Address", conf_nas_ip_address))
goto out_err;
-
+
if (req_set_RA(req, s->secret))
goto out_err;
@@ -426,7 +426,7 @@ static void send_acct_on(struct rad_server_t *s)
triton_timer_add(&s->ctx, &req->timeout, 0);
return;
-
+
out_err:
rad_req_free(req);
}
@@ -434,12 +434,12 @@ out_err:
static void serv_ctx_close(struct triton_context_t *ctx)
{
struct rad_server_t *s = container_of(ctx, typeof(*s), ctx);
-
+
if (s->timer.tpd)
triton_timer_del(&s->timer);
s->need_close = 1;
-
+
if (!s->client_cnt[0] && !s->client_cnt[1]) {
if (s->acct_on) {
s->acct_on = 0;
@@ -467,7 +467,7 @@ static void show_stat(struct rad_server_t *s, void *client)
cli_send(client, " state: active\r\n");
cli_sendv(client, " fail count: %lu\r\n", s->stat_fail_cnt);
-
+
cli_sendv(client, " request count: %i\r\n", s->req_cnt);
cli_sendv(client, " queue length: %i\r\n", s->queue_cnt);
@@ -539,7 +539,7 @@ static void __add_server(struct rad_server_t *s)
s->stat_interim_lost_5m = stat_accm_create(5 * 60);
s->stat_interim_query_1m = stat_accm_create(60);
s->stat_interim_query_5m = stat_accm_create(5 * 60);
-
+
s->ctx.close = serv_ctx_close;
triton_context_register(&s->ctx, NULL);
@@ -587,9 +587,9 @@ static int parse_server_old(const char *opt, in_addr_t *addr, int *port, char **
*p2 = 0;
else
return -1;
-
+
*addr = inet_addr(str);
-
+
if (p1) {
*port = atoi(p1 + 1);
if (*port <=0 )
@@ -646,7 +646,7 @@ static void add_server_old(void)
__add_server(s);
return;
}
-
+
__add_server(s);
if (acct_addr) {
@@ -670,14 +670,14 @@ static int parse_server1(const char *_opt, struct rad_server_t *s)
ptr1 = strchr(opt, ',');
if (!ptr1)
goto out;
-
+
ptr2 = strchr(ptr1 + 1, ',');
if (ptr2)
ptr3 = strchr(ptr2 + 1, ',');
else
ptr3 = NULL;
-
+
*ptr1 = 0;
if (ptr2)
*ptr2 = 0;
@@ -694,7 +694,7 @@ static int parse_server1(const char *_opt, struct rad_server_t *s)
}
} else
s->auth_port = 1812;
-
+
if (ptr3) {
if (ptr3[1]) {
s->acct_port = strtol(ptr3 + 1, &endptr, 10);
@@ -708,7 +708,7 @@ static int parse_server1(const char *_opt, struct rad_server_t *s)
s->fail_timeout = conf_fail_timeout;
s->req_limit = conf_req_limit;
s->max_fail = conf_max_fail;
-
+
return 0;
out:
@@ -725,7 +725,7 @@ static int parse_server2(const char *_opt, struct rad_server_t *s)
ptr1 = strchr(opt, ',');
if (!ptr1)
goto out;
-
+
ptr2 = strchr(ptr1 + 1, ',');
*ptr1 = 0;
@@ -770,7 +770,7 @@ static int parse_server2(const char *_opt, struct rad_server_t *s)
} else
s->fail_timeout = conf_fail_timeout;
}
-
+
ptr3 = strstr(ptr2, ",max-fail=");
if (ptr3) {
s->max_fail = strtol(ptr3 + 10, &endptr, 10);
@@ -778,7 +778,7 @@ static int parse_server2(const char *_opt, struct rad_server_t *s)
goto out;
} else
s->max_fail = conf_max_fail;
-
+
ptr3 = strstr(ptr2, ",weight=");
if (ptr3) {
s->weight = atoi(ptr3 + 8);
@@ -788,7 +788,7 @@ static int parse_server2(const char *_opt, struct rad_server_t *s)
}
} else
s->weight = 1;
-
+
ptr3 = strstr(ptr2, ",backup");
if (ptr3)
s->backup = 1;
@@ -799,7 +799,7 @@ static int parse_server2(const char *_opt, struct rad_server_t *s)
*ptr2 = 0;
s->secret = _strdup(ptr1 + 1);
-
+
_free(opt);
return 0;
@@ -813,12 +813,12 @@ out:
static void add_server(const char *opt)
{
struct rad_server_t *s = _malloc(sizeof(*s));
-
+
memset(s, 0, sizeof(*s));
if (!parse_server1(opt,s))
goto add;
-
+
if (!parse_server2(opt,s))
goto add;
@@ -841,13 +841,13 @@ static void load_config(void)
list_for_each_entry(s, &serv_list, entry)
s->need_free = 1;
-
+
opt1 = conf_get_opt("radius", "acct-on");
if (opt1)
conf_acct_on = atoi(opt1);
else
conf_acct_on = 0;
-
+
opt1 = conf_get_opt("radius", "fail-timeout");
if (!opt1)
opt1 = conf_get_opt("radius", "fail-time");
@@ -861,7 +861,7 @@ static void load_config(void)
conf_req_limit = atoi(opt1);
else
conf_req_limit = 0;
-
+
opt1 = conf_get_opt("radius", "max-fail");
if (opt1)
conf_max_fail = atoi(opt1);
@@ -873,7 +873,7 @@ static void load_config(void)
continue;
add_server(opt->val);
}
-
+
list_for_each_safe(pos, n, &serv_list) {
s = list_entry(pos, typeof(*s), entry);
if (s->need_free) {
@@ -893,9 +893,9 @@ static void load_config(void)
}
}
}
-
+
add_server_old();
-
+
conf_accounting = 0;
list_for_each_entry(s, &serv_list, entry) {
if (s->acct_port) {
@@ -903,7 +903,7 @@ static void load_config(void)
break;
}
}
-
+
list_for_each_entry(s, &serv_list, entry) {
if (s->starting) {
if (!conf_accounting || !s->auth_port)
diff --git a/accel-pppd/radius/stat_accm.c b/accel-pppd/radius/stat_accm.c
index 2388c5d3..fe5da6ed 100644
--- a/accel-pppd/radius/stat_accm.c
+++ b/accel-pppd/radius/stat_accm.c
@@ -52,7 +52,7 @@ static void stat_accm_clean(struct stat_accm_t *s)
{
struct item_t *it;
struct timespec ts;
-
+
clock_gettime(CLOCK_MONOTONIC, &ts);
while (!list_empty(&s->items)) {
@@ -71,11 +71,11 @@ void stat_accm_add(struct stat_accm_t *s, unsigned int val)
{
struct item_t *it;
struct timespec ts;
-
+
clock_gettime(CLOCK_MONOTONIC, &ts);
pthread_mutex_lock(&s->lock);
-
+
stat_accm_clean(s);
it = mempool_alloc(item_pool);
@@ -84,7 +84,7 @@ void stat_accm_add(struct stat_accm_t *s, unsigned int val)
list_add_tail(&it->entry, &s->items);
++s->items_cnt;
s->total += val;
-
+
pthread_mutex_unlock(&s->lock);
}
@@ -104,7 +104,7 @@ unsigned long stat_accm_get_avg(struct stat_accm_t *s)
stat_accm_clean(s);
val = s->items_cnt ? s->total/s->items_cnt : 0;
pthread_mutex_unlock(&s->lock);
-
+
return val;
}