summaryrefslogtreecommitdiff
path: root/accel-pppd/radius
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd/radius')
-rw-r--r--accel-pppd/radius/acct.c72
-rw-r--r--accel-pppd/radius/auth.c21
-rw-r--r--accel-pppd/radius/dm_coa.c12
-rw-r--r--accel-pppd/radius/radius.c87
-rw-r--r--accel-pppd/radius/radius.h4
-rw-r--r--accel-pppd/radius/radius_p.h6
-rw-r--r--accel-pppd/radius/req.c34
-rw-r--r--accel-pppd/radius/serv.c6
8 files changed, 127 insertions, 115 deletions
diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c
index 76ad3299..dfc982d4 100644
--- a/accel-pppd/radius/acct.c
+++ b/accel-pppd/radius/acct.c
@@ -32,40 +32,42 @@ static int req_set_RA(struct rad_req_t *req, const char *secret)
return 0;
}
-static void req_set_stat(struct rad_req_t *req, struct ppp_t *ppp)
+static void req_set_stat(struct rad_req_t *req, struct ap_session *ses)
{
struct ifpppstatsreq ifreq;
time_t stop_time;
- if (ppp->stop_time)
- stop_time = ppp->stop_time;
+ if (ses->stop_time)
+ stop_time = ses->stop_time;
else
time(&stop_time);
memset(&ifreq, 0, sizeof(ifreq));
ifreq.stats_ptr = (void *)&ifreq.stats;
- strcpy(ifreq.ifr__name, ppp->ifname);
+ strcpy(ifreq.ifr__name, ses->ifname);
- if (ioctl(sock_fd, SIOCGPPPSTATS, &ifreq)) {
- log_ppp_error("radius: failed to get ppp statistics: %s\n", strerror(errno));
- return;
- }
+ if (ses->ctrl->type != CTRL_TYPE_IPOE) {
+ if (ioctl(sock_fd, SIOCGPPPSTATS, &ifreq)) {
+ log_ppp_error("radius: failed to get ppp statistics: %s\n", strerror(errno));
+ return;
+ }
- if (ifreq.stats.p.ppp_ibytes < req->rpd->acct_input_octets)
- req->rpd->acct_input_gigawords++;
- req->rpd->acct_input_octets = ifreq.stats.p.ppp_ibytes;
-
- if (ifreq.stats.p.ppp_obytes < req->rpd->acct_output_octets)
- req->rpd->acct_output_gigawords++;
- req->rpd->acct_output_octets = ifreq.stats.p.ppp_obytes;
-
- rad_packet_change_int(req->pack, NULL, "Acct-Input-Octets", ifreq.stats.p.ppp_ibytes);
- rad_packet_change_int(req->pack, NULL, "Acct-Output-Octets", ifreq.stats.p.ppp_obytes);
- rad_packet_change_int(req->pack, NULL, "Acct-Input-Packets", ifreq.stats.p.ppp_ipackets);
- rad_packet_change_int(req->pack, NULL, "Acct-Output-Packets", ifreq.stats.p.ppp_opackets);
- rad_packet_change_int(req->pack, NULL, "Acct-Input-Gigawords", req->rpd->acct_input_gigawords);
- rad_packet_change_int(req->pack, NULL, "Acct-Output-Gigawords", req->rpd->acct_output_gigawords);
- rad_packet_change_int(req->pack, NULL, "Acct-Session-Time", stop_time - ppp->start_time);
+ if (ifreq.stats.p.ppp_ibytes < req->rpd->acct_input_octets)
+ req->rpd->acct_input_gigawords++;
+ req->rpd->acct_input_octets = ifreq.stats.p.ppp_ibytes;
+
+ if (ifreq.stats.p.ppp_obytes < req->rpd->acct_output_octets)
+ req->rpd->acct_output_gigawords++;
+ req->rpd->acct_output_octets = ifreq.stats.p.ppp_obytes;
+
+ rad_packet_change_int(req->pack, NULL, "Acct-Input-Octets", ifreq.stats.p.ppp_ibytes);
+ rad_packet_change_int(req->pack, NULL, "Acct-Output-Octets", ifreq.stats.p.ppp_obytes);
+ rad_packet_change_int(req->pack, NULL, "Acct-Input-Packets", ifreq.stats.p.ppp_ipackets);
+ rad_packet_change_int(req->pack, NULL, "Acct-Output-Packets", ifreq.stats.p.ppp_opackets);
+ rad_packet_change_int(req->pack, NULL, "Acct-Input-Gigawords", req->rpd->acct_input_gigawords);
+ rad_packet_change_int(req->pack, NULL, "Acct-Output-Gigawords", req->rpd->acct_output_gigawords);
+ }
+ rad_packet_change_int(req->pack, NULL, "Acct-Session-Time", stop_time - ses->start_time);
}
static int rad_acct_read(struct triton_md_handler_t *h)
@@ -125,7 +127,7 @@ static void __rad_req_send(struct rad_req_t *req)
if (rad_server_realloc(req)) {
if (conf_acct_timeout) {
log_ppp_warn("radius:acct: no servers available, terminating session...\n");
- ppp_terminate(req->rpd->ppp, TERM_NAS_ERROR, 0);
+ ap_session_terminate(req->rpd->ses, TERM_NAS_ERROR, 0);
}
break;
}
@@ -134,7 +136,7 @@ static void __rad_req_send(struct rad_req_t *req)
rad_req_send(req, conf_interim_verbose);
if (!req->hnd.tpd) {
- triton_md_register_handler(req->rpd->ppp->ctrl->ctx, &req->hnd);
+ triton_md_register_handler(req->rpd->ses->ctrl->ctx, &req->hnd);
triton_md_enable_handler(&req->hnd, MD_MODE_READ);
}
@@ -167,7 +169,7 @@ static void rad_acct_timeout(struct triton_timer_t *t)
rad_server_fail(req->serv);
if (rad_server_realloc(req)) {
log_ppp_warn("radius:acct: no servers available, terminating session...\n");
- ppp_terminate(req->rpd->ppp, TERM_NAS_ERROR, 0);
+ ap_session_terminate(req->rpd->ses, TERM_NAS_ERROR, 0);
return;
}
time(&req->rpd->acct_timestamp);
@@ -201,10 +203,10 @@ static void rad_acct_interim_update(struct triton_timer_t *t)
return;
if (rpd->session_timeout.expire_tv.tv_sec &&
- rpd->session_timeout.expire_tv.tv_sec - (time(NULL) - rpd->ppp->start_time) < INTERIM_SAFE_TIME)
+ rpd->session_timeout.expire_tv.tv_sec - (time(NULL) - rpd->ses->start_time) < INTERIM_SAFE_TIME)
return;
- req_set_stat(rpd->acct_req, rpd->ppp);
+ req_set_stat(rpd->acct_req, rpd->ses);
if (!rpd->acct_interim_interval)
return;
@@ -221,7 +223,7 @@ static void rad_acct_interim_update(struct triton_timer_t *t)
__sync_add_and_fetch(&rpd->acct_req->serv->stat_interim_sent, 1);
rpd->acct_req->timeout.period = conf_timeout * 1000;
- triton_timer_add(rpd->ppp->ctrl->ctx, &rpd->acct_req->timeout, 0);
+ triton_timer_add(rpd->ses->ctrl->ctx, &rpd->acct_req->timeout, 0);
}
int rad_acct_start(struct radius_pd_t *rpd)
@@ -233,7 +235,7 @@ int rad_acct_start(struct radius_pd_t *rpd)
if (!conf_accounting)
return 0;
- rpd->acct_req = rad_req_alloc(rpd, CODE_ACCOUNTING_REQUEST, rpd->ppp->username);
+ rpd->acct_req = rad_req_alloc(rpd, CODE_ACCOUNTING_REQUEST, rpd->ses->username);
if (!rpd->acct_req)
return -1;
@@ -244,7 +246,7 @@ int rad_acct_start(struct radius_pd_t *rpd)
//if (rad_req_add_val(rpd->acct_req, "Acct-Status-Type", "Start", 4))
// goto out_err;
- //if (rad_req_add_str(rpd->acct_req, "Acct-Session-Id", rpd->ppp->sessionid, PPP_SESSIONID_LEN, 1))
+ //if (rad_req_add_str(rpd->acct_req, "Acct-Session-Id", rpd->ses->ionid, PPP_SESSIONID_LEN, 1))
// goto out_err;
if (rpd->acct_req->reply) {
@@ -325,7 +327,7 @@ int rad_acct_start(struct radius_pd_t *rpd)
rpd->acct_req->hnd.read = rad_acct_read;
- triton_md_register_handler(rpd->ppp->ctrl->ctx, &rpd->acct_req->hnd);
+ triton_md_register_handler(rpd->ses->ctrl->ctx, &rpd->acct_req->hnd);
if (triton_md_enable_handler(&rpd->acct_req->hnd, MD_MODE_READ))
goto out_err;
@@ -334,7 +336,7 @@ int rad_acct_start(struct radius_pd_t *rpd)
rpd->acct_interim_timer.expire = rad_acct_interim_update;
rpd->acct_interim_timer.period = rpd->acct_interim_interval ? rpd->acct_interim_interval * 1000 : STAT_UPDATE_INTERVAL;
- if (rpd->acct_interim_interval && triton_timer_add(rpd->ppp->ctrl->ctx, &rpd->acct_interim_timer, 0)) {
+ if (rpd->acct_interim_interval && triton_timer_add(rpd->ses->ctrl->ctx, &rpd->acct_interim_timer, 0)) {
triton_md_unregister_handler(&rpd->acct_req->hnd);
triton_timer_del(&rpd->acct_req->timeout);
goto out_err;
@@ -364,7 +366,7 @@ void rad_acct_stop(struct radius_pd_t *rpd)
if (rpd->acct_req->timeout.tpd)
triton_timer_del(&rpd->acct_req->timeout);
- switch (rpd->ppp->terminate_cause) {
+ switch (rpd->ses->terminate_cause) {
case TERM_USER_REQUEST:
rad_packet_add_val(rpd->acct_req->pack, NULL, "Acct-Terminate-Cause", "User-Request");
break;
@@ -392,7 +394,7 @@ void rad_acct_stop(struct radius_pd_t *rpd)
break;
}
rad_packet_change_val(rpd->acct_req->pack, NULL, "Acct-Status-Type", "Stop");
- req_set_stat(rpd->acct_req, rpd->ppp);
+ req_set_stat(rpd->acct_req, rpd->ses);
req_set_RA(rpd->acct_req, rpd->acct_req->serv->secret);
/// !!! rad_req_add_val(rpd->acct_req, "Acct-Terminate-Cause", "");
diff --git a/accel-pppd/radius/auth.c b/accel-pppd/radius/auth.c
index 3e5d281d..6a0b3a96 100644
--- a/accel-pppd/radius/auth.c
+++ b/accel-pppd/radius/auth.c
@@ -243,13 +243,13 @@ int rad_auth_pap(struct radius_pd_t *rpd, const char *username, va_list args)
_free(epasswd);
if (conf_sid_in_auth)
- if (rad_packet_add_str(req->pack, NULL, "Acct-Session-Id", rpd->ppp->sessionid))
+ if (rad_packet_add_str(req->pack, NULL, "Acct-Session-Id", rpd->ses->sessionid))
return -1;
r = rad_auth_send(req);
if (r == PWDB_SUCCESS) {
struct ev_radius_t ev = {
- .ppp = rpd->ppp,
+ .ses = rpd->ses,
.request = req->pack,
.reply = req->reply,
};
@@ -311,13 +311,13 @@ int rad_auth_chap_md5(struct radius_pd_t *rpd, const char *username, va_list arg
}
if (conf_sid_in_auth)
- if (rad_packet_add_str(rpd->auth_req->pack, NULL, "Acct-Session-Id", rpd->ppp->sessionid))
+ if (rad_packet_add_str(rpd->auth_req->pack, NULL, "Acct-Session-Id", rpd->ses->sessionid))
goto out;
r = rad_auth_send(rpd->auth_req);
if (r == PWDB_SUCCESS) {
struct ev_radius_t ev = {
- .ppp = rpd->ppp,
+ .ses = rpd->ses,
.request = rpd->auth_req->pack,
.reply = rpd->auth_req->reply,
};
@@ -339,9 +339,12 @@ static void setup_mppe(struct rad_req_t *req, const uint8_t *challenge)
uint8_t mppe_recv_key[16];
uint8_t mppe_send_key[16];
struct ev_mppe_keys_t ev_mppe = {
- .ppp = req->rpd->ppp,
+ .ppp = container_of(req->rpd->ses, typeof(struct ppp_t), ses),
};
+ if (req->rpd->ses->ctrl->type == CTRL_TYPE_IPOE)
+ return;
+
list_for_each_entry(attr, &req->reply->attrs, entry) {
if (attr->vendor && attr->vendor->id == Vendor_Microsoft) {
switch (attr->attr->id) {
@@ -426,14 +429,14 @@ int rad_auth_mschap_v1(struct radius_pd_t *rpd, const char *username, va_list ar
}
if (conf_sid_in_auth)
- if (rad_packet_add_str(rpd->auth_req->pack, NULL, "Acct-Session-Id", rpd->ppp->sessionid))
+ if (rad_packet_add_str(rpd->auth_req->pack, NULL, "Acct-Session-Id", rpd->ses->sessionid))
goto out;
r = rad_auth_send(rpd->auth_req);
if (r == PWDB_SUCCESS) {
struct ev_radius_t ev = {
- .ppp = rpd->ppp,
+ .ses = rpd->ses,
.request = rpd->auth_req->pack,
.reply = rpd->auth_req->reply,
};
@@ -508,7 +511,7 @@ int rad_auth_mschap_v2(struct radius_pd_t *rpd, const char *username, va_list ar
}
if (conf_sid_in_auth)
- if (rad_packet_add_str(rpd->auth_req->pack, NULL, "Acct-Session-Id", rpd->ppp->sessionid))
+ if (rad_packet_add_str(rpd->auth_req->pack, NULL, "Acct-Session-Id", rpd->ses->sessionid))
goto out;
r = rad_auth_send(rpd->auth_req);
@@ -522,7 +525,7 @@ int rad_auth_mschap_v2(struct radius_pd_t *rpd, const char *username, va_list ar
}
if (r == PWDB_SUCCESS) {
struct ev_radius_t ev = {
- .ppp = rpd->ppp,
+ .ses = rpd->ses,
.request = rpd->auth_req->pack,
.reply = rpd->auth_req->reply,
};
diff --git a/accel-pppd/radius/dm_coa.c b/accel-pppd/radius/dm_coa.c
index f6197e7c..a2757362 100644
--- a/accel-pppd/radius/dm_coa.c
+++ b/accel-pppd/radius/dm_coa.c
@@ -140,13 +140,13 @@ static void disconnect_request(struct radius_pd_t *rpd)
rpd->dm_coa_req = NULL;
pthread_mutex_unlock(&rpd->lock);
- ppp_terminate(rpd->ppp, TERM_ADMIN_RESET, 0);
+ ap_session_terminate(rpd->ses, TERM_ADMIN_RESET, 0);
}
static void coa_request(struct radius_pd_t *rpd)
{
struct ev_radius_t ev = {
- .ppp = rpd->ppp,
+ .ses = rpd->ses,
.request = rpd->dm_coa_req,
};
@@ -171,8 +171,8 @@ static void coa_request(struct radius_pd_t *rpd)
void dm_coa_cancel(struct radius_pd_t *rpd)
{
- triton_cancel_call(rpd->ppp->ctrl->ctx, (triton_event_func)disconnect_request);
- triton_cancel_call(rpd->ppp->ctrl->ctx, (triton_event_func)coa_request);
+ triton_cancel_call(rpd->ses->ctrl->ctx, (triton_event_func)disconnect_request);
+ triton_cancel_call(rpd->ses->ctrl->ctx, (triton_event_func)coa_request);
rad_packet_free(rpd->dm_coa_req);
}
@@ -227,9 +227,9 @@ static int dm_coa_read(struct triton_md_handler_t *h)
memcpy(&rpd->dm_coa_addr, &addr, sizeof(addr));
if (pack->code == CODE_DISCONNECT_REQUEST)
- triton_context_call(rpd->ppp->ctrl->ctx, (triton_event_func)disconnect_request, rpd);
+ triton_context_call(rpd->ses->ctrl->ctx, (triton_event_func)disconnect_request, rpd);
else
- triton_context_call(rpd->ppp->ctrl->ctx, (triton_event_func)coa_request, rpd);
+ triton_context_call(rpd->ses->ctrl->ctx, (triton_event_func)coa_request, rpd);
pthread_mutex_unlock(&rpd->lock);
diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c
index 8f17fcc9..b654f29c 100644
--- a/accel-pppd/radius/radius.c
+++ b/accel-pppd/radius/radius.c
@@ -60,18 +60,18 @@ int rad_proc_attrs(struct rad_req_t *req)
struct ev_dns_t dns;
int res = 0;
- dns.ppp = NULL;
+ dns.ses = NULL;
req->rpd->acct_interim_interval = conf_acct_interim_interval;
list_for_each_entry(attr, &req->reply->attrs, entry) {
if (attr->vendor && attr->vendor->id == Vendor_Microsoft) {
switch (attr->attr->id) {
case MS_Primary_DNS_Server:
- dns.ppp = req->rpd->ppp;
+ dns.ses = req->rpd->ses;
dns.dns1 = attr->val.ipaddr;
break;
case MS_Secondary_DNS_Server:
- dns.ppp = req->rpd->ppp;
+ dns.ses = req->rpd->ses;
dns.dns2 = attr->val.ipaddr;
break;
}
@@ -132,18 +132,18 @@ int rad_proc_attrs(struct rad_req_t *req)
}
}
- if (dns.ppp)
+ if (dns.ses)
triton_event_fire(EV_DNS, &dns);
return res;
}
-static int check(struct pwdb_t *pwdb, struct ppp_t *ppp, const char *username, int type, va_list _args)
+static int check(struct pwdb_t *pwdb, struct ap_session *ses, const char *username, int type, va_list _args)
{
int r = PWDB_NO_IMPL;
va_list args;
int chap_type;
- struct radius_pd_t *rpd = find_pd(ppp);
+ struct radius_pd_t *rpd = find_pd(ses);
va_copy(args, _args);
@@ -175,18 +175,18 @@ static int check(struct pwdb_t *pwdb, struct ppp_t *ppp, const char *username, i
return r;
}
-static struct ipv4db_item_t *get_ipv4(struct ppp_t *ppp)
+static struct ipv4db_item_t *get_ipv4(struct ap_session *ses)
{
- struct radius_pd_t *rpd = find_pd(ppp);
+ struct radius_pd_t *rpd = find_pd(ses);
if (rpd->ipv4_addr.peer_addr)
return &rpd->ipv4_addr;
return NULL;
}
-static struct ipv6db_item_t *get_ipv6(struct ppp_t *ppp)
+static struct ipv6db_item_t *get_ipv6(struct ap_session *ses)
{
- struct radius_pd_t *rpd = find_pd(ppp);
+ struct radius_pd_t *rpd = find_pd(ses);
rpd->ipv6_addr.owner = &ipdb;
rpd->ipv6_addr.intf_id = 0;
@@ -197,9 +197,9 @@ static struct ipv6db_item_t *get_ipv6(struct ppp_t *ppp)
return NULL;
}
-static struct ipv6db_prefix_t *get_ipv6_prefix(struct ppp_t *ppp)
+static struct ipv6db_prefix_t *get_ipv6_prefix(struct ap_session *ses)
{
- struct radius_pd_t *rpd = find_pd(ppp);
+ struct radius_pd_t *rpd = find_pd(ses);
rpd->ipv6_dp.owner = &ipdb;
@@ -214,66 +214,67 @@ static struct ipv6db_prefix_t *get_ipv6_prefix(struct ppp_t *ppp)
static void session_timeout(struct triton_timer_t *t)
{
struct radius_pd_t *rpd = container_of(t, typeof(*rpd), session_timeout);
+
log_ppp_msg("radius: session timed out\n");
- if (rpd->ppp->stop_time)
+ if (rpd->ses->stop_time)
return;
- if (rpd->termination_action == Termination_Action_RADIUS_Request) {
- if (ppp_auth_restart(rpd->ppp))
- ppp_terminate(rpd->ppp, TERM_SESSION_TIMEOUT, 0);
+ if (rpd->termination_action == Termination_Action_RADIUS_Request && rpd->ses->ctrl->type != CTRL_TYPE_IPOE) {
+ if (ppp_auth_restart(container_of(rpd->ses, struct ppp_t, ses)))
+ ap_session_terminate(rpd->ses, TERM_SESSION_TIMEOUT, 0);
} else
- ppp_terminate(rpd->ppp, TERM_SESSION_TIMEOUT, 0);
+ ap_session_terminate(rpd->ses, TERM_SESSION_TIMEOUT, 0);
}
-static void ppp_starting(struct ppp_t *ppp)
+static void ses_starting(struct ap_session *ses)
{
struct radius_pd_t *rpd = mempool_alloc(rpd_pool);
memset(rpd, 0, sizeof(*rpd));
rpd->pd.key = &pd_key;
- rpd->ppp = ppp;
+ rpd->ses = ses;
pthread_mutex_init(&rpd->lock, NULL);
INIT_LIST_HEAD(&rpd->plugin_list);
INIT_LIST_HEAD(&rpd->ipv6_addr.addr_list);
INIT_LIST_HEAD(&rpd->ipv6_dp.prefix_list);
- list_add_tail(&rpd->pd.entry, &ppp->pd_list);
+ list_add_tail(&rpd->pd.entry, &ses->pd_list);
pthread_rwlock_wrlock(&sessions_lock);
list_add_tail(&rpd->entry, &sessions);
pthread_rwlock_unlock(&sessions_lock);
}
-static void ppp_acct_start(struct ppp_t *ppp)
+static void ses_acct_start(struct ap_session *ses)
{
- struct radius_pd_t *rpd = find_pd(ppp);
+ struct radius_pd_t *rpd = find_pd(ses);
if (!rpd->authenticated)
return;
if (rad_acct_start(rpd)) {
- ppp_terminate(rpd->ppp, TERM_NAS_ERROR, 0);
+ ap_session_terminate(rpd->ses, TERM_NAS_ERROR, 0);
return;
}
if (rpd->session_timeout.expire_tv.tv_sec) {
rpd->session_timeout.expire = session_timeout;
- triton_timer_add(ppp->ctrl->ctx, &rpd->session_timeout, 0);
+ triton_timer_add(ses->ctrl->ctx, &rpd->session_timeout, 0);
}
}
-static void ppp_finishing(struct ppp_t *ppp)
+static void ses_finishing(struct ap_session *ses)
{
- struct radius_pd_t *rpd = find_pd(ppp);
+ struct radius_pd_t *rpd = find_pd(ses);
if (!rpd->authenticated)
return;
rad_acct_stop(rpd);
}
-static void ppp_finished(struct ppp_t *ppp)
+static void ses_finished(struct ap_session *ses)
{
- struct radius_pd_t *rpd = find_pd(ppp);
+ struct radius_pd_t *rpd = find_pd(ses);
struct ipv6db_addr_t *a;
pthread_rwlock_wrlock(&sessions_lock);
@@ -317,12 +318,12 @@ static void ppp_finished(struct ppp_t *ppp)
mempool_free(rpd);
}
-struct radius_pd_t *find_pd(struct ppp_t *ppp)
+struct radius_pd_t *find_pd(struct ap_session *ses)
{
- struct ppp_pd_t *pd;
+ struct ap_private *pd;
struct radius_pd_t *rpd;
- list_for_each_entry(pd, &ppp->pd_list, entry) {
+ list_for_each_entry(pd, &ses->pd_list, entry) {
if (pd->key == &pd_key) {
rpd = container_of(pd, typeof(*rpd), pd);
return rpd;
@@ -339,17 +340,17 @@ struct radius_pd_t *rad_find_session(const char *sessionid, const char *username
pthread_rwlock_rdlock(&sessions_lock);
list_for_each_entry(rpd, &sessions, entry) {
- if (!rpd->ppp->username)
+ if (!rpd->ses->username)
continue;
- if (sessionid && strcmp(sessionid, rpd->ppp->sessionid))
+ if (sessionid && strcmp(sessionid, rpd->ses->sessionid))
continue;
- if (username && strcmp(username, rpd->ppp->username))
+ if (username && strcmp(username, rpd->ses->username))
continue;
- if (port_id >= 0 && port_id != rpd->ppp->unit_idx)
+ if (port_id >= 0 && port_id != rpd->ses->unit_idx)
continue;
- if (ipaddr && rpd->ppp->ipv4 && ipaddr != rpd->ppp->ipv4->peer_addr)
+ if (ipaddr && rpd->ses->ipv4 && ipaddr != rpd->ses->ipv4->peer_addr)
continue;
- if (csid && rpd->ppp->ctrl->calling_station_id && strcmp(csid, rpd->ppp->ctrl->calling_station_id))
+ if (csid && rpd->ses->ctrl->calling_station_id && strcmp(csid, rpd->ses->ctrl->calling_station_id))
continue;
pthread_mutex_lock(&rpd->lock);
pthread_rwlock_unlock(&sessions_lock);
@@ -422,9 +423,9 @@ int rad_check_nas_pack(struct rad_packet_t *pack)
return 0;
}
-void __export rad_register_plugin(struct ppp_t *ppp, struct rad_plugin_t *plugin)
+void __export rad_register_plugin(struct ap_session *ses, struct rad_plugin_t *plugin)
{
- struct radius_pd_t *rpd = find_pd(ppp);
+ struct radius_pd_t *rpd = find_pd(ses);
if (!rpd)
return;
@@ -575,10 +576,10 @@ static void radius_init(void)
pwdb_register(&pwdb);
ipdb_register(&ipdb);
- triton_event_register_handler(EV_PPP_STARTING, (triton_event_func)ppp_starting);
- triton_event_register_handler(EV_PPP_ACCT_START, (triton_event_func)ppp_acct_start);
- triton_event_register_handler(EV_PPP_FINISHING, (triton_event_func)ppp_finishing);
- triton_event_register_handler(EV_PPP_FINISHED, (triton_event_func)ppp_finished);
+ triton_event_register_handler(EV_SES_STARTING, (triton_event_func)ses_starting);
+ triton_event_register_handler(EV_SES_ACCT_START, (triton_event_func)ses_acct_start);
+ triton_event_register_handler(EV_SES_FINISHING, (triton_event_func)ses_finishing);
+ triton_event_register_handler(EV_SES_FINISHED, (triton_event_func)ses_finished);
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
}
diff --git a/accel-pppd/radius/radius.h b/accel-pppd/radius/radius.h
index 296fd133..ad27b898 100644
--- a/accel-pppd/radius/radius.h
+++ b/accel-pppd/radius/radius.h
@@ -102,9 +102,9 @@ struct rad_plugin_t
int (*send_accounting_request)(struct rad_plugin_t *, struct rad_packet_t *pack);
};
-struct ppp_t;
+struct ap_session;
-void rad_register_plugin(struct ppp_t *, struct rad_plugin_t *);
+void rad_register_plugin(struct ap_session *, struct rad_plugin_t *);
struct rad_dict_attr_t *rad_dict_find_attr(const char *name);
struct rad_dict_attr_t *rad_dict_find_attr_id(struct rad_dict_vendor_t *vendor, int type);
diff --git a/accel-pppd/radius/radius_p.h b/accel-pppd/radius/radius_p.h
index 7422bbf3..e2c48bf9 100644
--- a/accel-pppd/radius/radius_p.h
+++ b/accel-pppd/radius/radius_p.h
@@ -15,8 +15,8 @@ struct rad_server_t;
struct radius_pd_t
{
struct list_head entry;
- struct ppp_pd_t pd;
- struct ppp_t *ppp;
+ struct ap_private pd;
+ struct ap_session *ses;
pthread_mutex_t lock;
int authenticated:1;
@@ -147,7 +147,7 @@ void rad_req_free(struct rad_req_t *);
int rad_req_send(struct rad_req_t *, int verbose);
int rad_req_wait(struct rad_req_t *, int);
-struct radius_pd_t *find_pd(struct ppp_t *ppp);
+struct radius_pd_t *find_pd(struct ap_session *ses);
int rad_proc_attrs(struct rad_req_t *req);
int rad_auth_pap(struct radius_pd_t *rpd, const char *username, va_list args);
diff --git a/accel-pppd/radius/req.c b/accel-pppd/radius/req.c
index cc0b261a..33273b43 100644
--- a/accel-pppd/radius/req.c
+++ b/accel-pppd/radius/req.c
@@ -20,6 +20,7 @@ static void rad_req_timeout(struct triton_timer_t *t);
struct rad_req_t *rad_req_alloc(struct radius_pd_t *rpd, int code, const char *username)
{
struct rad_plugin_t *plugin;
+ struct ppp_t *ppp = NULL;
struct rad_req_t *req = _malloc(sizeof(*req));
if (!req) {
@@ -27,6 +28,9 @@ struct rad_req_t *rad_req_alloc(struct radius_pd_t *rpd, int code, const char *u
return NULL;
}
+ if (rpd->ses->ctrl->type != CTRL_TYPE_IPOE)
+ ppp = container_of(rpd->ses, typeof(*ppp), ses);
+
memset(req, 0, sizeof(*req));
req->rpd = rpd;
req->hnd.fd = -1;
@@ -63,19 +67,21 @@ struct rad_req_t *rad_req_alloc(struct radius_pd_t *rpd, int code, const char *u
if (conf_nas_ip_address)
if (rad_packet_add_ipaddr(req->pack, NULL, "NAS-IP-Address", conf_nas_ip_address))
goto out_err;
- if (rad_packet_add_int(req->pack, NULL, "NAS-Port", rpd->ppp->unit_idx))
- goto out_err;
+ if (ppp) {
+ if (rad_packet_add_int(req->pack, NULL, "NAS-Port", ppp->ses.unit_idx))
+ goto out_err;
+ }
if (rad_packet_add_val(req->pack, NULL, "NAS-Port-Type", "Virtual"))
goto out_err;
if (rad_packet_add_val(req->pack, NULL, "Service-Type", "Framed-User"))
goto out_err;
if (rad_packet_add_val(req->pack, NULL, "Framed-Protocol", "PPP"))
goto out_err;
- if (rpd->ppp->ctrl->calling_station_id)
- if (rad_packet_add_str(req->pack, NULL, "Calling-Station-Id", rpd->ppp->ctrl->calling_station_id))
+ 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->ppp->ctrl->called_station_id)
- if (rad_packet_add_str(req->pack, NULL, "Called-Station-Id", rpd->ppp->ctrl->called_station_id))
+ 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))
@@ -117,7 +123,7 @@ int rad_req_acct_fill(struct rad_req_t *req)
return -1;
if (rad_packet_add_val(req->pack, NULL, "Acct-Authentic", "RADIUS"))
return -1;
- if (rad_packet_add_str(req->pack, NULL, "Acct-Session-Id", req->rpd->ppp->sessionid))
+ if (rad_packet_add_str(req->pack, NULL, "Acct-Session-Id", req->rpd->ses->sessionid))
return -1;
if (rad_packet_add_int(req->pack, NULL, "Acct-Session-Time", 0))
return -1;
@@ -137,14 +143,14 @@ int rad_req_acct_fill(struct rad_req_t *req)
if (rad_packet_add_int(req->pack, NULL, "Acct-Delay-Time", 0))
return -1;
}
- if (req->rpd->ppp->ipv4) {
- if (rad_packet_add_ipaddr(req->pack, NULL, "Framed-IP-Address", req->rpd->ppp->ipv4->peer_addr))
+ if (req->rpd->ses->ipv4) {
+ if (rad_packet_add_ipaddr(req->pack, NULL, "Framed-IP-Address", req->rpd->ses->ipv4->peer_addr))
return -1;
}
- if (req->rpd->ppp->ipv6) {
- if (rad_packet_add_ifid(req->pack, NULL, "Framed-Interface-Id", req->rpd->ppp->ipv6->peer_intf_id))
+ if (req->rpd->ses->ipv6) {
+ if (rad_packet_add_ifid(req->pack, NULL, "Framed-Interface-Id", req->rpd->ses->ipv6->peer_intf_id))
return -1;
- list_for_each_entry(a, &req->rpd->ppp->ipv6->addr_list, entry) {
+ list_for_each_entry(a, &req->rpd->ses->ipv6->addr_list, entry) {
if (rad_packet_add_ipv6prefix(req->pack, NULL, "Framed-IPv6-Prefix", &a->addr, a->prefix_len))
return -1;
}
@@ -235,7 +241,7 @@ out_err:
static void req_wakeup(struct rad_req_t *req)
{
- struct triton_context_t *ctx = req->rpd->ppp->ctrl->ctx;
+ struct triton_context_t *ctx = req->rpd->ses->ctrl->ctx;
if (req->timeout.tpd)
triton_timer_del(&req->timeout);
triton_md_unregister_handler(&req->hnd);
@@ -277,7 +283,7 @@ int rad_req_wait(struct rad_req_t *req, int timeout)
req->hnd.read = rad_req_read;
req->timeout.expire = rad_req_timeout;
- triton_context_register(&req->ctx, req->rpd->ppp);
+ triton_context_register(&req->ctx, req->rpd->ses);
triton_context_set_priority(&req->ctx, 1);
triton_md_register_handler(&req->ctx, &req->hnd);
triton_md_enable_handler(&req->hnd, MD_MODE_READ);
diff --git a/accel-pppd/radius/serv.c b/accel-pppd/radius/serv.c
index 30219f75..4de6ad1e 100644
--- a/accel-pppd/radius/serv.c
+++ b/accel-pppd/radius/serv.c
@@ -132,7 +132,7 @@ void rad_server_req_exit(struct rad_req_t *req)
pthread_mutex_unlock(&req->serv->lock);
if (r)
- triton_context_wakeup(r->rpd->ppp->ctrl->ctx);
+ triton_context_wakeup(r->rpd->ses->ctrl->ctx);
}
int rad_server_realloc(struct rad_req_t *req)
@@ -182,7 +182,7 @@ void rad_server_fail(struct rad_server_t *s)
while (!list_empty(&s->req_queue)) {
r = list_entry(s->req_queue.next, typeof(*r), entry);
list_del(&r->entry);
- triton_context_wakeup(r->rpd->ppp->ctrl->ctx);
+ triton_context_wakeup(r->rpd->ses->ctrl->ctx);
}
}
@@ -559,7 +559,7 @@ static void load_config(void)
while (!list_empty(&s->req_queue)) {
r = list_entry(s->req_queue.next, typeof(*r), entry);
list_del(&r->entry);
- triton_context_wakeup(r->rpd->ppp->ctrl->ctx);
+ triton_context_wakeup(r->rpd->ses->ctrl->ctx);
}
if (!s->client_cnt[0] && !s->client_cnt[1])