summaryrefslogtreecommitdiff
path: root/accel-pppd/ppp
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd/ppp')
-rw-r--r--accel-pppd/ppp/ccp_mppe.c19
-rw-r--r--accel-pppd/ppp/ipcp_opt_dns.c10
-rw-r--r--accel-pppd/ppp/ipcp_opt_ipaddr.c48
-rw-r--r--accel-pppd/ppp/ipv6cp_opt_intfid.c58
-rw-r--r--accel-pppd/ppp/lcp_opt_mru.c8
-rw-r--r--accel-pppd/ppp/ppp.c243
-rw-r--r--accel-pppd/ppp/ppp.h95
-rw-r--r--accel-pppd/ppp/ppp_auth.c48
-rw-r--r--accel-pppd/ppp/ppp_auth.h2
-rw-r--r--accel-pppd/ppp/ppp_ccp.c25
-rw-r--r--accel-pppd/ppp/ppp_fsm.c4
-rw-r--r--accel-pppd/ppp/ppp_ifcfg.c36
-rw-r--r--accel-pppd/ppp/ppp_ipcp.c38
-rw-r--r--accel-pppd/ppp/ppp_ipv6cp.c38
-rw-r--r--accel-pppd/ppp/ppp_lcp.c32
15 files changed, 222 insertions, 482 deletions
diff --git a/accel-pppd/ppp/ccp_mppe.c b/accel-pppd/ppp/ccp_mppe.c
index 388e2f6c..ae2b2cae 100644
--- a/accel-pppd/ppp/ccp_mppe.c
+++ b/accel-pppd/ppp/ccp_mppe.c
@@ -61,10 +61,10 @@ static struct ccp_option_t *mppe_init(struct ppp_ccp_t *ccp)
memset(mppe_opt, 0, sizeof(*mppe_opt));
int mppe;
- if (ccp->ppp->ctrl->mppe == MPPE_UNSET)
+ if (ccp->ppp->ses.ctrl->mppe == MPPE_UNSET)
mppe = conf_mppe;
else
- mppe = ccp->ppp->ctrl->mppe;
+ mppe = ccp->ppp->ses.ctrl->mppe;
if (mppe != MPPE_ALLOW)
mppe_opt->policy = mppe;
@@ -78,6 +78,9 @@ static struct ccp_option_t *mppe_init(struct ppp_ccp_t *ccp)
if (mppe == MPPE_REQUIRE || mppe == MPPE_PREFER)
ccp->ld.passive = 0;
+
+ if (mppe == MPPE_REQUIRE)
+ ccp->ld.optional = 0;
mppe_opt->opt.id = CI_MPPE;
mppe_opt->opt.len = 6;
@@ -121,7 +124,7 @@ static int decrease_mtu(struct ppp_t *ppp)
{
struct ifreq ifr;
- strcpy(ifr.ifr_name, ppp->ifname);
+ strcpy(ifr.ifr_name, ppp->ses.ifname);
if (ioctl(sock_fd, SIOCGIFMTU, &ifr)) {
log_ppp_error("mppe: failed to get MTU: %s\n", strerror(errno));
@@ -173,10 +176,10 @@ static int mppe_recv_conf_req(struct ppp_ccp_t *ccp, struct ccp_option_t *opt, u
struct ccp_opt32_t *opt32 = (struct ccp_opt32_t *)ptr;
int mppe;
- if (ccp->ppp->ctrl->mppe == MPPE_UNSET)
+ if (ccp->ppp->ses.ctrl->mppe == MPPE_UNSET)
mppe = conf_mppe;
else
- mppe = ccp->ppp->ctrl->mppe;
+ mppe = ccp->ppp->ses.ctrl->mppe;
if (!ptr) {
if (mppe_opt->policy == 2)
@@ -299,12 +302,12 @@ static void ev_mppe_keys(struct ev_mppe_keys_t *ev)
return;
}
- if (ccp->ppp->ctrl->mppe == MPPE_UNSET)
+ if (ccp->ppp->ses.ctrl->mppe == MPPE_UNSET)
mppe = conf_mppe;
else
- mppe = ev->ppp->ctrl->mppe;
+ mppe = ev->ppp->ses.ctrl->mppe;
- if (ev->ppp->ctrl->mppe == MPPE_UNSET) {
+ if (ev->ppp->ses.ctrl->mppe == MPPE_UNSET) {
mppe_opt->policy = ev->policy;
if (ev->policy == 2) {
diff --git a/accel-pppd/ppp/ipcp_opt_dns.c b/accel-pppd/ppp/ipcp_opt_dns.c
index 19183eb7..1ca8723b 100644
--- a/accel-pppd/ppp/ipcp_opt_dns.c
+++ b/accel-pppd/ppp/ipcp_opt_dns.c
@@ -143,11 +143,17 @@ static void dns2_print(void (*print)(const char *fmt,...),struct ipcp_option_t *
static void ev_dns(struct ev_dns_t *ev)
{
struct dns_option_t *dns_opt;
+ struct ppp_t *ppp;
- dns_opt = container_of(ipcp_find_option(ev->ppp, &dns1_opt_hnd), typeof(*dns_opt), opt);
+ if (ev->ses->ctrl->type == CTRL_TYPE_IPOE)
+ return;
+
+ ppp = container_of(ev->ses, typeof(*ppp), ses);
+
+ dns_opt = container_of(ipcp_find_option(ppp, &dns1_opt_hnd), typeof(*dns_opt), opt);
dns_opt->addr = ev->dns1;
- dns_opt = container_of(ipcp_find_option(ev->ppp, &dns2_opt_hnd), typeof(*dns_opt), opt);
+ dns_opt = container_of(ipcp_find_option(ppp, &dns2_opt_hnd), typeof(*dns_opt), opt);
dns_opt->addr = ev->dns2;
}
diff --git a/accel-pppd/ppp/ipcp_opt_ipaddr.c b/accel-pppd/ppp/ipcp_opt_ipaddr.c
index e965f5c2..44dd3ddd 100644
--- a/accel-pppd/ppp/ipcp_opt_ipaddr.c
+++ b/accel-pppd/ppp/ipcp_opt_ipaddr.c
@@ -58,9 +58,9 @@ static void ipaddr_free(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt)
{
struct ipaddr_option_t *ipaddr_opt = container_of(opt, typeof(*ipaddr_opt), opt);
- if (ipcp->ppp->ipv4) {
- ipdb_put_ipv4(ipcp->ppp, ipcp->ppp->ipv4);
- ipcp->ppp->ipv4 = NULL;
+ if (ipcp->ppp->ses.ipv4) {
+ ipdb_put_ipv4(&ipcp->ppp->ses, ipcp->ppp->ses.ipv4);
+ ipcp->ppp->ses.ipv4 = NULL;
}
_free(ipaddr_opt);
@@ -68,40 +68,40 @@ static void ipaddr_free(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt)
static int check_exists(struct ppp_t *self_ppp, in_addr_t addr)
{
- struct ppp_t *ppp;
+ struct ap_session *ses;
int r = 0;
- pthread_rwlock_rdlock(&ppp_lock);
- list_for_each_entry(ppp, &ppp_list, entry) {
- if (!ppp->terminating && ppp->ipv4 && ppp->ipv4->peer_addr == addr && ppp != self_ppp) {
- log_ppp_warn("ppp: requested IPv4 address already assigned to %s\n", ppp->ifname);
+ pthread_rwlock_rdlock(&ses_lock);
+ list_for_each_entry(ses, &ses_list, entry) {
+ if (!ses->terminating && ses->ipv4 && ses->ipv4->peer_addr == addr && ses != &self_ppp->ses) {
+ log_ppp_warn("ppp: requested IPv4 address already assigned to %s\n", ses->ifname);
r = 1;
break;
}
}
- pthread_rwlock_unlock(&ppp_lock);
+ pthread_rwlock_unlock(&ses_lock);
return r;
}
static int alloc_ip(struct ppp_t *ppp)
{
- ppp->ipv4 = ipdb_get_ipv4(ppp);
- if (!ppp->ipv4) {
+ ppp->ses.ipv4 = ipdb_get_ipv4(&ppp->ses);
+ if (!ppp->ses.ipv4) {
log_ppp_warn("ppp: no free IPv4 address\n");
return IPCP_OPT_CLOSE;
}
- if (iprange_tunnel_check(ppp->ipv4->peer_addr)) {
+ if (iprange_tunnel_check(ppp->ses.ipv4->peer_addr)) {
log_ppp_warn("ppp:ipcp: to avoid kernel soft lockup requested IP cannot be assigned (%i.%i.%i.%i)\n",
- ppp->ipv4->peer_addr&0xff,
- (ppp->ipv4->peer_addr >> 8)&0xff,
- (ppp->ipv4->peer_addr >> 16)&0xff,
- (ppp->ipv4->peer_addr >> 24)&0xff);
+ ppp->ses.ipv4->peer_addr&0xff,
+ (ppp->ses.ipv4->peer_addr >> 8)&0xff,
+ (ppp->ses.ipv4->peer_addr >> 16)&0xff,
+ (ppp->ses.ipv4->peer_addr >> 24)&0xff);
return IPCP_OPT_FAIL;
}
- if (conf_check_exists && check_exists(ppp, ppp->ipv4->peer_addr))
+ if (conf_check_exists && check_exists(ppp, ppp->ses.ipv4->peer_addr))
return IPCP_OPT_FAIL;
return 0;
@@ -113,7 +113,7 @@ static int ipaddr_send_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *o
struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr;
int r;
- if (!ipcp->ppp->ipv4) {
+ if (!ipcp->ppp->ses.ipv4) {
r = alloc_ip(ipcp->ppp);
if (r)
return r;
@@ -121,7 +121,7 @@ static int ipaddr_send_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *o
opt32->hdr.id = CI_ADDR;
opt32->hdr.len = 6;
- opt32->val = ipcp->ppp->ipv4->addr;
+ opt32->val = ipcp->ppp->ses.ipv4->addr;
return 6;
}
@@ -131,7 +131,7 @@ static int ipaddr_send_conf_nak(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *o
struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr;
opt32->hdr.id = CI_ADDR;
opt32->hdr.len = 6;
- opt32->val = ipcp->ppp->ipv4->peer_addr;
+ opt32->val = ipcp->ppp->ses.ipv4->peer_addr;
return 6;
}
@@ -141,7 +141,7 @@ static int ipaddr_recv_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *o
struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr;
int r;
- if (!ipcp->ppp->ipv4) {
+ if (!ipcp->ppp->ses.ipv4) {
r = alloc_ip(ipcp->ppp);
if (r)
return r;
@@ -150,7 +150,7 @@ static int ipaddr_recv_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *o
if (opt32->hdr.len != 6)
return IPCP_OPT_REJ;
- if (ipcp->ppp->ipv4->peer_addr == opt32->val) {
+ if (ipcp->ppp->ses.ipv4->peer_addr == opt32->val) {
ipcp->delay_ack = ccp_ipcp_started(ipcp->ppp);
return IPCP_OPT_ACK;
}
@@ -166,8 +166,8 @@ static void ipaddr_print(void (*print)(const char *fmt,...),struct ipcp_option_t
if (ptr)
in.s_addr = opt32->val;
- else if (ipaddr_opt->ppp->ipv4)
- in.s_addr = ipaddr_opt->ppp->ipv4->addr;
+ else if (ipaddr_opt->ppp->ses.ipv4)
+ in.s_addr = ipaddr_opt->ppp->ses.ipv4->addr;
print("<addr %s>",inet_ntoa(in));
}
diff --git a/accel-pppd/ppp/ipv6cp_opt_intfid.c b/accel-pppd/ppp/ipv6cp_opt_intfid.c
index 9a2ddee0..21f0b931 100644
--- a/accel-pppd/ppp/ipv6cp_opt_intfid.c
+++ b/accel-pppd/ppp/ipv6cp_opt_intfid.c
@@ -72,9 +72,9 @@ static void ipaddr_free(struct ppp_ipv6cp_t *ipv6cp, struct ipv6cp_option_t *opt
{
struct ipaddr_option_t *ipaddr_opt=container_of(opt,typeof(*ipaddr_opt),opt);
- if (ipv6cp->ppp->ipv6) {
- ipdb_put_ipv6(ipv6cp->ppp, ipv6cp->ppp->ipv6);
- ipv6cp->ppp->ipv6 = NULL;
+ if (ipv6cp->ppp->ses.ipv6) {
+ ipdb_put_ipv6(&ipv6cp->ppp->ses, ipv6cp->ppp->ses.ipv6);
+ ipv6cp->ppp->ses.ipv6 = NULL;
}
_free(ipaddr_opt);
@@ -82,24 +82,24 @@ static void ipaddr_free(struct ppp_ipv6cp_t *ipv6cp, struct ipv6cp_option_t *opt
static int check_exists(struct ppp_t *self_ppp)
{
- struct ppp_t *ppp;
+ struct ap_session *ses;
struct ipv6db_addr_t *a1, *a2;
int r = 0;
- pthread_rwlock_rdlock(&ppp_lock);
- list_for_each_entry(ppp, &ppp_list, entry) {
- if (ppp->terminating)
+ pthread_rwlock_rdlock(&ses_lock);
+ list_for_each_entry(ses, &ses_list, entry) {
+ if (ses->terminating)
continue;
- if (!ppp->ipv6)
+ if (!ses->ipv6)
continue;
- if (ppp == self_ppp)
+ if (ses == &self_ppp->ses)
continue;
- list_for_each_entry(a1, &ppp->ipv6->addr_list, entry) {
- list_for_each_entry(a2, &self_ppp->ipv6->addr_list, entry) {
+ list_for_each_entry(a1, &ses->ipv6->addr_list, entry) {
+ list_for_each_entry(a2, &ses->ipv6->addr_list, entry) {
if (a1->addr.s6_addr32[0] == a2->addr.s6_addr32[0] &&
a1->addr.s6_addr32[1] == a2->addr.s6_addr32[1]) {
- log_ppp_warn("ppp: requested IPv6 address already assigned to %s\n", ppp->ifname);
+ log_ppp_warn("ppp: requested IPv6 address already assigned to %s\n", ses->ifname);
r = 1;
goto out;
}
@@ -107,7 +107,7 @@ static int check_exists(struct ppp_t *self_ppp)
}
}
out:
- pthread_rwlock_unlock(&ppp_lock);
+ pthread_rwlock_unlock(&ses_lock);
return r;
}
@@ -148,9 +148,9 @@ static uint64_t generate_peer_intf_id(struct ppp_t *ppp)
case INTF_ID_CSID:
break;
case INTF_ID_IPV4:
- if (ppp->ipv4) {
+ if (ppp->ses.ipv4) {
for (i = 0; i < 4; i++) {
- sprintf(str, "%i", (ppp->ipv4->peer_addr >> (i*8)) & 0xff);
+ sprintf(str, "%i", (ppp->ses.ipv4->peer_addr >> (i*8)) & 0xff);
sscanf(str, "%x", &n);
u.addr16[i] = htons(n);
}
@@ -163,14 +163,14 @@ static uint64_t generate_peer_intf_id(struct ppp_t *ppp)
static int alloc_ip(struct ppp_t *ppp)
{
- ppp->ipv6 = ipdb_get_ipv6(ppp);
- if (!ppp->ipv6) {
+ ppp->ses.ipv6 = ipdb_get_ipv6(&ppp->ses);
+ if (!ppp->ses.ipv6) {
log_ppp_warn("ppp: no free IPv6 address\n");
return IPV6CP_OPT_CLOSE;
}
- if (!ppp->ipv6->intf_id)
- ppp->ipv6->intf_id = generate_intf_id(ppp);
+ if (!ppp->ses.ipv6->intf_id)
+ ppp->ses.ipv6->intf_id = generate_intf_id(ppp);
if (conf_check_exists && check_exists(ppp))
return IPV6CP_OPT_FAIL;
@@ -184,7 +184,7 @@ static int ipaddr_send_conf_req(struct ppp_ipv6cp_t *ipv6cp, struct ipv6cp_optio
struct ipv6cp_opt64_t *opt64 = (struct ipv6cp_opt64_t *)ptr;
int r;
- if (!ipv6cp->ppp->ipv6) {
+ if (!ipv6cp->ppp->ses.ipv6) {
r = alloc_ip(ipv6cp->ppp);
if (r)
return r;
@@ -192,7 +192,7 @@ static int ipaddr_send_conf_req(struct ppp_ipv6cp_t *ipv6cp, struct ipv6cp_optio
opt64->hdr.id = CI_INTFID;
opt64->hdr.len = 10;
- opt64->val = ipv6cp->ppp->ipv6->intf_id;
+ opt64->val = ipv6cp->ppp->ses.ipv6->intf_id;
return 10;
}
@@ -202,7 +202,7 @@ static int ipaddr_send_conf_nak(struct ppp_ipv6cp_t *ipv6cp, struct ipv6cp_optio
struct ipv6cp_opt64_t *opt64 = (struct ipv6cp_opt64_t *)ptr;
opt64->hdr.id = CI_INTFID;
opt64->hdr.len = 10;
- opt64->val = ipv6cp->ppp->ipv6->peer_intf_id;
+ opt64->val = ipv6cp->ppp->ses.ipv6->peer_intf_id;
return 10;
}
@@ -215,21 +215,21 @@ static int ipaddr_recv_conf_req(struct ppp_ipv6cp_t *ipv6cp, struct ipv6cp_optio
if (opt64->hdr.len != 10)
return IPV6CP_OPT_REJ;
- if (!ipv6cp->ppp->ipv6) {
+ if (!ipv6cp->ppp->ses.ipv6) {
r = alloc_ip(ipv6cp->ppp);
if (r)
return r;
}
if (conf_accept_peer_intf_id && opt64->val)
- ipv6cp->ppp->ipv6->peer_intf_id = opt64->val;
- else if (!ipv6cp->ppp->ipv6->peer_intf_id) {
- ipv6cp->ppp->ipv6->peer_intf_id = generate_peer_intf_id(ipv6cp->ppp);
- if (!ipv6cp->ppp->ipv6->peer_intf_id)
+ ipv6cp->ppp->ses.ipv6->peer_intf_id = opt64->val;
+ else if (!ipv6cp->ppp->ses.ipv6->peer_intf_id) {
+ ipv6cp->ppp->ses.ipv6->peer_intf_id = generate_peer_intf_id(ipv6cp->ppp);
+ if (!ipv6cp->ppp->ses.ipv6->peer_intf_id)
return IPV6CP_OPT_TERMACK;
}
- if (opt64->val && ipv6cp->ppp->ipv6->peer_intf_id == opt64->val && opt64->val != ipv6cp->ppp->ipv6->intf_id) {
+ if (opt64->val && ipv6cp->ppp->ses.ipv6->peer_intf_id == opt64->val && opt64->val != ipv6cp->ppp->ses.ipv6->intf_id) {
ipv6cp->delay_ack = ccp_ipcp_started(ipv6cp->ppp);
ipaddr_opt->started = 1;
return IPV6CP_OPT_ACK;
@@ -247,7 +247,7 @@ static void ipaddr_print(void (*print)(const char *fmt,...), struct ipv6cp_optio
if (ptr)
*(uint64_t *)(a.s6_addr + 8) = opt64->val;
else
- *(uint64_t *)(a.s6_addr + 8) = ipaddr_opt->ppp->ipv6->intf_id;
+ *(uint64_t *)(a.s6_addr + 8) = ipaddr_opt->ppp->ses.ipv6->intf_id;
print("<addr %x:%x:%x:%x>", ntohs(a.s6_addr16[4]), ntohs(a.s6_addr16[5]), ntohs(a.s6_addr16[6]), ntohs(a.s6_addr16[7]));
}
diff --git a/accel-pppd/ppp/lcp_opt_mru.c b/accel-pppd/ppp/lcp_opt_mru.c
index 577e0191..10dc54e7 100644
--- a/accel-pppd/ppp/lcp_opt_mru.c
+++ b/accel-pppd/ppp/lcp_opt_mru.c
@@ -53,10 +53,10 @@ static struct lcp_option_t *mru_init(struct ppp_lcp_t *lcp)
{
struct mru_option_t *mru_opt=_malloc(sizeof(*mru_opt));
memset(mru_opt, 0, sizeof(*mru_opt));
- mru_opt->mru = (conf_mru && conf_mru <= lcp->ppp->ctrl->max_mtu) ? conf_mru : lcp->ppp->ctrl->max_mtu;
+ mru_opt->mru = (conf_mru && conf_mru <= lcp->ppp->ses.ctrl->max_mtu) ? conf_mru : lcp->ppp->ses.ctrl->max_mtu;
if (mru_opt->mru > conf_max_mtu)
mru_opt->mru = conf_max_mtu;
- mru_opt->mtu = (conf_mtu && conf_mtu <= lcp->ppp->ctrl->max_mtu) ? conf_mtu : lcp->ppp->ctrl->max_mtu;
+ mru_opt->mtu = (conf_mtu && conf_mtu <= lcp->ppp->ses.ctrl->max_mtu) ? conf_mtu : lcp->ppp->ses.ctrl->max_mtu;
if (mru_opt->mtu > conf_max_mtu)
mru_opt->mtu = conf_max_mtu;
mru_opt->opt.id = CI_MRU;
@@ -107,7 +107,7 @@ static int mru_recv_conf_req(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, ui
if (opt16->hdr.len != 4)
return LCP_OPT_REJ;
- if (ntohs(opt16->val) < conf_min_mtu || ntohs(opt16->val) > lcp->ppp->ctrl->max_mtu || ntohs(opt16->val) > conf_max_mtu)
+ if (ntohs(opt16->val) < conf_min_mtu || ntohs(opt16->val) > lcp->ppp->ses.ctrl->max_mtu || ntohs(opt16->val) > conf_max_mtu)
return LCP_OPT_NAK;
mru_opt->mtu = ntohs(opt16->val);
@@ -121,7 +121,7 @@ static int mru_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, ui
.ifr_mtu = mru_opt->mtu,
};
- strcpy(ifr.ifr_name, lcp->ppp->ifname);
+ strcpy(ifr.ifr_name, lcp->ppp->ses.ifname);
if (ioctl(lcp->ppp->unit_fd, PPPIOCSMRU, &mru_opt->mru))
log_ppp_error("lcp:mru: failed to set MRU: %s\n", strerror(errno));
diff --git a/accel-pppd/ppp/ppp.c b/accel-pppd/ppp/ppp.c
index 814240cd..9a006676 100644
--- a/accel-pppd/ppp/ppp.c
+++ b/accel-pppd/ppp/ppp.c
@@ -16,6 +16,7 @@
#include "triton.h"
+#include "ap_session.h"
#include "events.h"
#include "ppp.h"
#include "ppp_fsm.h"
@@ -27,30 +28,13 @@
#include "memdebug.h"
int __export conf_ppp_verbose;
-int conf_sid_ucase;
int conf_single_session = -1;
int conf_unit_cache = 0;
-pthread_rwlock_t __export ppp_lock = PTHREAD_RWLOCK_INITIALIZER;
-__export LIST_HEAD(ppp_list);
-
-int __export sock_fd;
-int __export sock6_fd;
-int __export urandom_fd;
-
-int __export ppp_shutdown;
-
static mempool_t buf_pool;
static LIST_HEAD(layers);
-static unsigned long long seq;
-#if __WORDSIZE == 32
-static spinlock_t seq_lock;
-#endif
-
-__export struct ppp_stat_t ppp_stat;
-
struct layer_node_t
{
struct list_head entry;
@@ -78,37 +62,19 @@ static void start_first_layer(struct ppp_t *);
void __export ppp_init(struct ppp_t *ppp)
{
- memset(ppp,0,sizeof(*ppp));
+ memset(ppp, 0, sizeof(*ppp));
INIT_LIST_HEAD(&ppp->layers);
INIT_LIST_HEAD(&ppp->chan_handlers);
INIT_LIST_HEAD(&ppp->unit_handlers);
- INIT_LIST_HEAD(&ppp->pd_list);
ppp->fd = -1;
ppp->chan_fd = -1;
ppp->unit_fd = -1;
-}
-static void generate_sessionid(struct ppp_t *ppp)
-{
- unsigned long long sid;
-
-#if __WORDSIZE == 32
- spin_lock(&seq_lock);
- sid = ++seq;
- spin_unlock(&seq_lock);
-#else
- sid = __sync_add_and_fetch(&seq, 1);
-#endif
-
- if (conf_sid_ucase)
- sprintf(ppp->sessionid, "%016llX", sid);
- else
- sprintf(ppp->sessionid, "%016llx", sid);
+ ap_session_init(&ppp->ses);
}
int __export establish_ppp(struct ppp_t *ppp)
{
- struct ifreq ifr;
struct pppunit_cache *uc = NULL;
/* Open an instance of /dev/ppp and connect the channel to it */
@@ -142,7 +108,7 @@ int __export establish_ppp(struct ppp_t *ppp)
if (uc) {
ppp->unit_fd = uc->fd;
- ppp->unit_idx = uc->unit_idx;
+ ppp->ses.unit_idx = uc->unit_idx;
mempool_free(uc);
} else {
ppp->unit_fd = open("/dev/ppp", O_RDWR);
@@ -153,8 +119,8 @@ int __export establish_ppp(struct ppp_t *ppp)
fcntl(ppp->unit_fd, F_SETFD, fcntl(ppp->unit_fd, F_GETFD) | FD_CLOEXEC);
- ppp->unit_idx = -1;
- if (ioctl(ppp->unit_fd, PPPIOCNEWUNIT, &ppp->unit_idx) < 0) {
+ ppp->ses.unit_idx = -1;
+ if (ioctl(ppp->unit_fd, PPPIOCNEWUNIT, &ppp->ses.unit_idx) < 0) {
log_ppp_error("ioctl(PPPIOCNEWUNIT): %s\n", strerror(errno));
goto exit_close_unit;
}
@@ -165,7 +131,7 @@ int __export establish_ppp(struct ppp_t *ppp)
}
}
- if (ioctl(ppp->chan_fd, PPPIOCCONNECT, &ppp->unit_idx) < 0) {
+ if (ioctl(ppp->chan_fd, PPPIOCCONNECT, &ppp->ses.unit_idx) < 0) {
log_ppp_error("ioctl(PPPIOCCONNECT): %s\n", strerror(errno));
goto exit_close_unit;
}
@@ -175,20 +141,9 @@ int __export establish_ppp(struct ppp_t *ppp)
goto exit_close_unit;
}
- ppp->start_time = time(NULL);
- generate_sessionid(ppp);
- sprintf(ppp->ifname, "ppp%i", ppp->unit_idx);
-
- memset(&ifr, 0, sizeof(ifr));
- strcpy(ifr.ifr_name, ppp->ifname);
-
- if (ioctl(sock_fd, SIOCGIFINDEX, &ifr)) {
- log_ppp_error("ppp: ioctl(SIOCGIFINDEX): %s\n", strerror(errno));
- goto exit_close_unit;
- }
- ppp->ifindex = ifr.ifr_ifindex;
-
- log_ppp_info1("connect: %s <--> %s(%s)\n", ppp->ifname, ppp->ctrl->name, ppp->chan_name);
+ sprintf(ppp->ses.ifname, "ppp%i", ppp->ses.unit_idx);
+
+ log_ppp_info1("connect: %s <--> %s(%s)\n", ppp->ses.ifname, ppp->ses.ctrl->name, ppp->ses.chan_name);
init_layers(ppp);
@@ -203,22 +158,15 @@ int __export establish_ppp(struct ppp_t *ppp)
ppp->chan_hnd.read = ppp_chan_read;
ppp->unit_hnd.fd = ppp->unit_fd;
ppp->unit_hnd.read = ppp_unit_read;
- triton_md_register_handler(ppp->ctrl->ctx, &ppp->chan_hnd);
- triton_md_register_handler(ppp->ctrl->ctx, &ppp->unit_hnd);
+ triton_md_register_handler(ppp->ses.ctrl->ctx, &ppp->chan_hnd);
+ triton_md_register_handler(ppp->ses.ctrl->ctx, &ppp->unit_hnd);
triton_md_enable_handler(&ppp->chan_hnd, MD_MODE_READ);
triton_md_enable_handler(&ppp->unit_hnd, MD_MODE_READ);
- ppp->state = PPP_STATE_STARTING;
- __sync_add_and_fetch(&ppp_stat.starting, 1);
-
- pthread_rwlock_wrlock(&ppp_lock);
- list_add_tail(&ppp->entry, &ppp_list);
- pthread_rwlock_unlock(&ppp_lock);
-
log_ppp_debug("ppp established\n");
- triton_event_fire(EV_PPP_STARTING, ppp);
+ ap_session_starting(&ppp->ses);
start_first_layer(ppp);
@@ -239,23 +187,7 @@ static void destablish_ppp(struct ppp_t *ppp)
{
struct pppunit_cache *uc;
- triton_event_fire(EV_PPP_PRE_FINISHED, ppp);
-
- pthread_rwlock_wrlock(&ppp_lock);
- list_del(&ppp->entry);
- pthread_rwlock_unlock(&ppp_lock);
-
- switch (ppp->state) {
- case PPP_STATE_ACTIVE:
- __sync_sub_and_fetch(&ppp_stat.active, 1);
- break;
- case PPP_STATE_STARTING:
- __sync_sub_and_fetch(&ppp_stat.starting, 1);
- break;
- case PPP_STATE_FINISHING:
- __sync_sub_and_fetch(&ppp_stat.finishing, 1);
- break;
- }
+ triton_event_fire(EV_SES_PRE_FINISHED, ppp);
triton_md_unregister_handler(&ppp->chan_hnd);
triton_md_unregister_handler(&ppp->unit_hnd);
@@ -263,7 +195,7 @@ static void destablish_ppp(struct ppp_t *ppp)
if (uc_size < conf_unit_cache) {
uc = mempool_alloc(uc_pool);
uc->fd = ppp->unit_fd;
- uc->unit_idx = ppp->unit_idx;
+ uc->unit_idx = ppp->ses.unit_idx;
pthread_mutex_lock(&uc_lock);
list_add_tail(&uc->entry, &uc_list);
@@ -281,32 +213,11 @@ static void destablish_ppp(struct ppp_t *ppp)
_free_layers(ppp);
- ppp->terminated = 1;
-
log_ppp_debug("ppp destablished\n");
- triton_event_fire(EV_PPP_FINISHED, ppp);
- ppp->ctrl->finished(ppp);
-
mempool_free(ppp->buf);
- if (ppp->username) {
- _free(ppp->username);
- ppp->username = NULL;
- }
-
- if (ppp->ipv4_pool_name) {
- _free(ppp->ipv4_pool_name);
- ppp->ipv4_pool_name = NULL;
- }
-
- if (ppp->ipv6_pool_name) {
- _free(ppp->ipv6_pool_name);
- ppp->ipv6_pool_name = NULL;
- }
-
- if (ppp_shutdown && !ppp_stat.starting && !ppp_stat.active && !ppp_stat.finishing)
- kill(getpid(), SIGTERM);
+ ap_session_finished(&ppp->ses);
}
/*void print_buf(uint8_t *buf, int size)
@@ -362,7 +273,7 @@ cont:
//printf("ppp_chan_read: ");
//print_buf(ppp->buf,ppp->buf_size);
if (ppp->buf_size == 0) {
- ppp_terminate(ppp, TERM_NAS_ERROR, 1);
+ ap_session_terminate(&ppp->ses, TERM_NAS_ERROR, 1);
return 1;
}
@@ -376,7 +287,7 @@ cont:
if (ppp_h->proto == proto) {
ppp_h->recv(ppp_h);
if (ppp->chan_fd == -1) {
- //ppp->ctrl->finished(ppp);
+ //ppp->ses.ctrl->finished(ppp);
return 1;
}
goto cont;
@@ -410,7 +321,7 @@ cont:
//print_buf(ppp->buf,ppp->buf_size);
/*if (ppp->buf_size == 0) {
- ppp_terminate(ppp, TERM_NAS_ERROR, 1);
+ ap_session_terminate(ppp, TERM_NAS_ERROR, 1);
return 1;
}*/
@@ -424,7 +335,7 @@ cont:
if (ppp_h->proto == proto) {
ppp_h->recv(ppp_h);
if (ppp->unit_fd == -1) {
- //ppp->ctrl->finished(ppp);
+ //ppp->ses.ctrl->finished(ppp);
return 1;
}
goto cont;
@@ -472,18 +383,15 @@ static void __ppp_layer_started(struct ppp_t *ppp, struct ppp_layer_data_t *d)
if (n->entry.next == &ppp->layers) {
- if (ppp->state == PPP_STATE_STARTING) {
- ppp->state = PPP_STATE_ACTIVE;
- __sync_sub_and_fetch(&ppp_stat.starting, 1);
- __sync_add_and_fetch(&ppp_stat.active, 1);
- ppp_ifup(ppp);
+ if (ppp->ses.state == AP_STATE_STARTING) {
+ ap_session_activate(&ppp->ses);
}
} else {
n = list_entry(n->entry.next, typeof(*n), entry);
list_for_each_entry(d, &n->items, entry) {
d->starting = 1;
if (d->layer->start(d)) {
- ppp_terminate(ppp, TERM_NAS_ERROR, 0);
+ ap_session_terminate(&ppp->ses, TERM_NAS_ERROR, 0);
return;
}
}
@@ -527,41 +435,13 @@ void __export ppp_layer_finished(struct ppp_t *ppp, struct ppp_layer_data_t *d)
destablish_ppp(ppp);
}
-void __export ppp_terminate(struct ppp_t *ppp, int cause, int hard)
+void __export ppp_terminate(struct ap_session *ses, int hard)
{
+ struct ppp_t *ppp = container_of(ses, typeof(*ppp), ses);
struct layer_node_t *n;
struct ppp_layer_data_t *d;
int s = 0;
- if (ppp->terminated)
- return;
-
- if (!ppp->stop_time)
- time(&ppp->stop_time);
-
- if (!ppp->terminate_cause)
- ppp->terminate_cause = cause;
-
- if (ppp->terminating) {
- if (hard)
- destablish_ppp(ppp);
- return;
- }
-
- ppp->terminating = 1;
- if (ppp->state == PPP_STATE_ACTIVE)
- __sync_sub_and_fetch(&ppp_stat.active, 1);
- else
- __sync_sub_and_fetch(&ppp_stat.starting, 1);
- __sync_add_and_fetch(&ppp_stat.finishing, 1);
- ppp->state = PPP_STATE_FINISHING;
-
- log_ppp_debug("ppp_terminate\n");
-
- ppp_ifdown(ppp);
-
- triton_event_fire(EV_PPP_FINISHING, ppp);
-
if (hard) {
destablish_ppp(ppp);
return;
@@ -577,6 +457,7 @@ void __export ppp_terminate(struct ppp_t *ppp, int cause, int hard)
}
if (s)
return;
+
destablish_ppp(ppp);
}
@@ -689,7 +570,7 @@ static void start_first_layer(struct ppp_t *ppp)
list_for_each_entry(d, &n->items, entry) {
d->starting = 1;
if (d->layer->start(d)) {
- ppp_terminate(ppp, TERM_NAS_ERROR, 0);
+ ap_session_terminate(&ppp->ses, TERM_NAS_ERROR, 0);
return;
}
}
@@ -710,44 +591,14 @@ struct ppp_layer_data_t *ppp_find_layer_data(struct ppp_t *ppp, struct ppp_layer
return NULL;
}
-void ppp_shutdown_soft(void)
-{
- ppp_shutdown = 1;
-
- if (!ppp_stat.starting && !ppp_stat.active && !ppp_stat.finishing)
- kill(getpid(), SIGTERM);
-}
-
-static void save_seq(void)
-{
- FILE *f;
- char *opt = conf_get_opt("ppp", "seq-file");
- if (!opt)
- opt = "/var/run/accel-ppp/seq";
-
- f = fopen(opt, "w");
- if (f) {
- fprintf(f, "%llu", seq);
- fclose(f);
- }
-}
-
static void load_config(void)
{
- char *opt;
+ const char *opt;
opt = conf_get_opt("ppp", "verbose");
if (opt && atoi(opt) > 0)
conf_ppp_verbose = 1;
- opt = conf_get_opt("ppp", "sid-case");
- if (opt) {
- if (!strcmp(opt, "upper"))
- conf_sid_ucase = 1;
- else if (strcmp(opt, "lower"))
- log_emerg("ppp: sid-case: invalid format\n");
- }
-
opt = conf_get_opt("ppp", "single-session");
if (opt) {
if (!strcmp(opt, "deny"))
@@ -766,49 +617,11 @@ static void load_config(void)
static void init(void)
{
- char *opt;
- FILE *f;
-
buf_pool = mempool_create(PPP_MRU);
uc_pool = mempool_create(sizeof(struct pppunit_cache));
- sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
- if (sock_fd < 0) {
- perror("socket");
- _exit(EXIT_FAILURE);
- }
-
- fcntl(sock_fd, F_SETFD, fcntl(sock_fd, F_GETFD) | FD_CLOEXEC);
-
- sock6_fd = socket(AF_INET6, SOCK_DGRAM, 0);
- if (sock6_fd < 0)
- log_warn("ppp: kernel doesn't support ipv6\n");
- else
- fcntl(sock6_fd, F_SETFD, fcntl(sock6_fd, F_GETFD) | FD_CLOEXEC);
-
- urandom_fd = open("/dev/urandom", O_RDONLY);
- if (urandom_fd < 0) {
- log_emerg("failed to open /dev/urandom: %s\n", strerror(errno));
- return;
- }
-
- fcntl(urandom_fd, F_SETFD, fcntl(urandom_fd, F_GETFD) | FD_CLOEXEC);
-
- opt = conf_get_opt("ppp", "seq-file");
- if (!opt)
- opt = "/var/run/accel-ppp/seq";
-
- f = fopen(opt, "r");
- if (f) {
- fscanf(f, "%llu", &seq);
- fclose(f);
- } else
- seq = (unsigned long long)random() * (unsigned long long)random();
-
load_config();
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
-
- atexit(save_seq);
}
DEFINE_INIT(2, init);
diff --git a/accel-pppd/ppp/ppp.h b/accel-pppd/ppp/ppp.h
index e37c75d3..f5e0922a 100644
--- a/accel-pppd/ppp/ppp.h
+++ b/accel-pppd/ppp/ppp.h
@@ -8,6 +8,7 @@
#include "triton.h"
#include "list.h"
+#include "ap_session.h"
/*
* Packet header = Code, id, length.
@@ -15,7 +16,6 @@
#define PPP_HEADERLEN 4
#define PPP_MTU 1500
-
/*
* Protocol field values.
*/
@@ -39,60 +39,15 @@
#define PPP_CBCP 0xc029 /* Callback Control Protocol */
#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */
-#define PPP_SESSIONID_LEN 16
-#define PPP_IFNAME_LEN 10
-
-#define PPP_STATE_STARTING 1
-#define PPP_STATE_ACTIVE 2
-#define PPP_STATE_FINISHING 3
-
-#define TERM_USER_REQUEST 1
-#define TERM_SESSION_TIMEOUT 2
-#define TERM_ADMIN_RESET 3
-#define TERM_USER_ERROR 4
-#define TERM_NAS_ERROR 5
-#define TERM_NAS_REQUEST 6
-#define TERM_NAS_REBOOT 7
-#define TERM_AUTH_ERROR 8
-#define TERM_LOST_CARRIER 9
-
-#define CTRL_TYPE_PPTP 1
-#define CTRL_TYPE_L2TP 2
-#define CTRL_TYPE_PPPOE 3
-
-#define MPPE_UNSET -2
-#define MPPE_ALLOW -1
-#define MPPE_DENY 0
-#define MPPE_PREFER 1
-#define MPPE_REQUIRE 2
-
struct ppp_t;
struct ipv4db_item_t;
struct ipv6db_item_t;
-struct ppp_ctrl_t
-{
- struct triton_context_t *ctx;
- int type;
- const char *name;
- int max_mtu;
- int mppe;
- char *calling_station_id;
- char *called_station_id;
- void (*started)(struct ppp_t*);
- void (*finished)(struct ppp_t*);
-};
-
-struct ppp_pd_t
-{
- struct list_head entry;
- void *key;
-};
-
struct ppp_t
{
- struct list_head entry;
+ struct ap_session ses;
+
struct triton_md_handler_t chan_hnd;
struct triton_md_handler_t unit_hnd;
int fd;
@@ -100,27 +55,6 @@ struct ppp_t
int unit_fd;
int chan_idx;
- int unit_idx;
-
- int state;
- char *chan_name;
- char ifname[PPP_IFNAME_LEN];
- int ifindex;
- char sessionid[PPP_SESSIONID_LEN+1];
- time_t start_time;
- time_t stop_time;
- char *username;
- struct ipv4db_item_t *ipv4;
- struct ipv6db_item_t *ipv6;
- char *ipv4_pool_name;
- char *ipv6_pool_name;
- const char *comp;
-
- struct ppp_ctrl_t *ctrl;
-
- int terminating:1;
- int terminated:1;
- int terminate_cause;
void *buf;
int buf_size;
@@ -130,9 +64,8 @@ struct ppp_t
struct list_head layers;
+ const char *comp;
struct ppp_lcp_t *lcp;
-
- struct list_head pd_list;
};
struct ppp_layer_t;
@@ -166,13 +99,6 @@ struct ppp_handler_t
void (*recv_proto_rej)(struct ppp_handler_t *h);
};
-struct ppp_stat_t
-{
- unsigned int active;
- unsigned int starting;
- unsigned int finishing;
-};
-
struct ppp_t *alloc_ppp(void);
void ppp_init(struct ppp_t *ppp);
int establish_ppp(struct ppp_t *ppp);
@@ -189,7 +115,7 @@ void ppp_layer_started(struct ppp_t *ppp,struct ppp_layer_data_t*);
void ppp_layer_finished(struct ppp_t *ppp,struct ppp_layer_data_t*);
void ppp_layer_passive(struct ppp_t *ppp,struct ppp_layer_data_t*);
-void ppp_terminate(struct ppp_t *ppp, int hard, int cause);
+void ppp_terminate(struct ap_session *ses, int hard);
void ppp_register_chan_handler(struct ppp_t *, struct ppp_handler_t *);
void ppp_register_unit_handler(struct ppp_t * ,struct ppp_handler_t *);
@@ -199,20 +125,9 @@ int ppp_register_layer(const char *name, struct ppp_layer_t *);
void ppp_unregister_layer(struct ppp_layer_t *);
struct ppp_layer_data_t *ppp_find_layer_data(struct ppp_t *, struct ppp_layer_t *);
-extern int ppp_shutdown;
-void ppp_shutdown_soft(void);
-
int ppp_ipv6_nd_start(struct ppp_t *ppp, uint64_t intf_id);
extern int conf_ppp_verbose;
extern int conf_single_session;
-extern pthread_rwlock_t ppp_lock;
-extern struct list_head ppp_list;
-
-extern struct ppp_stat_t ppp_stat;
-
-extern int sock_fd; // internet socket for ioctls
-extern int sock6_fd; // internet socket for ioctls
-extern int urandom_fd;
#endif
diff --git a/accel-pppd/ppp/ppp_auth.c b/accel-pppd/ppp/ppp_auth.c
index 7603d8cf..805bf741 100644
--- a/accel-pppd/ppp/ppp_auth.c
+++ b/accel-pppd/ppp/ppp_auth.c
@@ -312,60 +312,60 @@ static void auth_layer_free(struct ppp_layer_data_t *ld)
log_ppp_debug("auth_layer_free\n");
- triton_cancel_call(ad->ppp->ctrl->ctx, (triton_event_func)__ppp_auth_started);
+ triton_cancel_call(ad->ppp->ses.ctrl->ctx, (triton_event_func)__ppp_auth_started);
_free(ad);
}
-static void ppp_terminate_sec(struct ppp_t *ppp)
+static void __terminate_sec(struct ap_session *ses)
{
- ppp_terminate(ppp, TERM_NAS_REQUEST, 0);
+ ap_session_terminate(ses, TERM_NAS_REQUEST, 0);
}
static void __ppp_auth_started(struct ppp_t *ppp)
{
struct auth_layer_data_t *ad = container_of(ppp_find_layer_data(ppp, &auth_layer), typeof(*ad), ld);
- if (ppp->terminating)
+ if (ppp->ses.terminating)
return;
log_ppp_debug("auth_layer_started\n");
ppp_layer_started(ppp, &ad->ld);
- log_ppp_info1("%s: authentication successed\n", ppp->username);
- triton_event_fire(EV_PPP_AUTHORIZED, ppp);
+ log_ppp_info1("%s: authentication successed\n", ppp->ses.username);
+ triton_event_fire(EV_SES_AUTHORIZED, ppp);
}
int __export ppp_auth_successed(struct ppp_t *ppp, char *username)
{
- struct ppp_t *p;
+ struct ap_session *ses;
struct auth_layer_data_t *ad = container_of(ppp_find_layer_data(ppp, &auth_layer), typeof(*ad), ld);
if (conf_single_session >= 0) {
- pthread_rwlock_rdlock(&ppp_lock);
- list_for_each_entry(p, &ppp_list, entry) {
- if (p->username && !strcmp(p->username, username)) {
+ pthread_rwlock_rdlock(&ses_lock);
+ list_for_each_entry(ses, &ses_list, entry) {
+ if (ses->username && !strcmp(ses->username, username)) {
if (conf_single_session == 0) {
- pthread_rwlock_unlock(&ppp_lock);
+ pthread_rwlock_unlock(&ses_lock);
log_ppp_info1("%s: second session denied\n", username);
return -1;
} else {
if (conf_single_session == 1) {
- ppp_ifdown(p);
- triton_context_call(p->ctrl->ctx, (triton_event_func)ppp_terminate_sec, p);
+ ap_session_ifdown(ses);
+ triton_context_call(ses->ctrl->ctx, (triton_event_func)__terminate_sec, ses);
}
}
}
}
- pthread_rwlock_unlock(&ppp_lock);
+ pthread_rwlock_unlock(&ses_lock);
}
- pthread_rwlock_wrlock(&ppp_lock);
- ppp->username = username;
- pthread_rwlock_unlock(&ppp_lock);
+ pthread_rwlock_wrlock(&ses_lock);
+ ppp->ses.username = username;
+ pthread_rwlock_unlock(&ses_lock);
- triton_context_call(ppp->ctrl->ctx, (triton_event_func)__ppp_auth_started, ppp);
+ triton_context_call(ppp->ses.ctrl->ctx, (triton_event_func)__ppp_auth_started, ppp);
return 0;
}
@@ -373,16 +373,16 @@ int __export ppp_auth_successed(struct ppp_t *ppp, char *username)
void __export ppp_auth_failed(struct ppp_t *ppp, char *username)
{
if (username) {
- pthread_rwlock_wrlock(&ppp_lock);
- if (!ppp->username)
- ppp->username = _strdup(username);
- pthread_rwlock_unlock(&ppp_lock);
+ pthread_rwlock_wrlock(&ses_lock);
+ if (!ppp->ses.username)
+ ppp->ses.username = _strdup(username);
+ pthread_rwlock_unlock(&ses_lock);
log_ppp_info1("%s: authentication failed\n", username);
log_info1("%s: authentication failed\n", username);
- triton_event_fire(EV_PPP_AUTH_FAILED, ppp);
+ triton_event_fire(EV_SES_AUTH_FAILED, ppp);
} else
log_ppp_info1("authentication failed\n");
- ppp_terminate(ppp, TERM_AUTH_ERROR, 0);
+ ap_session_terminate(&ppp->ses, TERM_AUTH_ERROR, 0);
}
int __export ppp_auth_register_handler(struct ppp_auth_handler_t *h)
diff --git a/accel-pppd/ppp/ppp_auth.h b/accel-pppd/ppp/ppp_auth.h
index 6f86d260..b6a7b145 100644
--- a/accel-pppd/ppp/ppp_auth.h
+++ b/accel-pppd/ppp/ppp_auth.h
@@ -31,7 +31,7 @@ int ppp_auth_register_handler(struct ppp_auth_handler_t*);
int ppp_auth_successed(struct ppp_t *ppp, char *username);
void ppp_auth_failed(struct ppp_t *ppp, char *username);
-int ppp_auth_restart(struct ppp_t *ppp);
+int ppp_auth_restart(struct ppp_t *ppp);
#endif
diff --git a/accel-pppd/ppp/ppp_ccp.c b/accel-pppd/ppp/ppp_ccp.c
index 297d9bc7..058e7b38 100644
--- a/accel-pppd/ppp/ppp_ccp.c
+++ b/accel-pppd/ppp/ppp_ccp.c
@@ -180,7 +180,10 @@ void ccp_layer_free(struct ppp_layer_data_t *ld)
struct ppp_ccp_t *ccp = container_of(ld, typeof(*ccp), ld);
log_ppp_debug("ccp_layer_free\n");
-
+
+ if (ccp->ppp->unit_fd != -1)
+ ccp_set_flags(ccp->ppp->unit_fd, 0, 0);
+
ppp_unregister_handler(ccp->ppp, &ccp->hnd);
ccp_options_free(ccp);
ppp_fsm_free(&ccp->fsm);
@@ -196,7 +199,7 @@ static void ccp_layer_up(struct ppp_fsm_t *fsm)
log_ppp_debug("ccp_layer_started\n");
ccp->started = 1;
if (ccp_set_flags(ccp->ppp->unit_fd, 1, 1)) {
- ppp_terminate(ccp->ppp, TERM_NAS_ERROR, 0);
+ ap_session_terminate(&ccp->ppp->ses, TERM_NAS_ERROR, 0);
return;
}
ppp_layer_started(ccp->ppp, &ccp->ld);
@@ -211,8 +214,8 @@ static void ccp_layer_finished(struct ppp_fsm_t *fsm)
if (!ccp->started)
ppp_layer_passive(ccp->ppp, &ccp->ld);
- else if (!ccp->ppp->terminating)
- ppp_terminate(ccp->ppp, TERM_USER_ERROR, 0);
+ else if (!ccp->ppp->ses.terminating)
+ ap_session_terminate(&ccp->ppp->ses, TERM_USER_ERROR, 0);
fsm->fsm_state = FSM_Closed;
}
@@ -631,10 +634,10 @@ static void ccp_recv(struct ppp_handler_t*h)
struct ppp_ccp_t *ccp = container_of(h, typeof(*ccp), hnd);
int r;
- if (!ccp->starting || ccp->fsm.fsm_state == FSM_Closed || ccp->ppp->terminating || ccp->ppp->state == PPP_STATE_ACTIVE) {
+ if (!ccp->starting || ccp->fsm.fsm_state == FSM_Closed || ccp->ppp->ses.terminating || ccp->ppp->ses.state == AP_STATE_ACTIVE) {
if (conf_ppp_verbose)
log_ppp_warn("CCP: discarding packet\n");
- if (ccp->fsm.fsm_state == FSM_Closed || !conf_ccp || ccp->ppp->state == PPP_STATE_ACTIVE)
+ if (ccp->fsm.fsm_state == FSM_Closed || !conf_ccp || ccp->ppp->ses.state == AP_STATE_ACTIVE)
lcp_send_proto_rej(ccp->ppp, PPP_CCP);
return;
}
@@ -684,11 +687,11 @@ static void ccp_recv(struct ppp_handler_t*h)
ccp_free_conf_req(ccp);
if (r == CCP_OPT_FAIL)
- ppp_terminate(ccp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&ccp->ppp->ses, TERM_USER_ERROR, 0);
break;
case CONFACK:
if (ccp_recv_conf_ack(ccp, (uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN))
- ppp_terminate(ccp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&ccp->ppp->ses, TERM_USER_ERROR, 0);
else
ppp_fsm_recv_conf_ack(&ccp->fsm);
break;
@@ -698,7 +701,7 @@ static void ccp_recv(struct ppp_handler_t*h)
break;
case CONFREJ:
if (ccp_recv_conf_rej(ccp, (uint8_t*)(hdr + 1),ntohs(hdr->len) - PPP_HDRLEN))
- ppp_terminate(ccp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&ccp->ppp->ses, TERM_USER_ERROR, 0);
else
ppp_fsm_recv_conf_rej(&ccp->fsm);
break;
@@ -729,8 +732,8 @@ static void ccp_recv_proto_rej(struct ppp_handler_t *h)
{
struct ppp_ccp_t *ccp = container_of(h, typeof(*ccp), hnd);
- if (!ccp->ld.passive) {
- ppp_terminate(ccp->ppp, TERM_USER_ERROR, 0);
+ if (!ccp->ld.optional) {
+ ap_session_terminate(&ccp->ppp->ses, TERM_USER_ERROR, 0);
return;
}
diff --git a/accel-pppd/ppp/ppp_fsm.c b/accel-pppd/ppp/ppp_fsm.c
index 27021d18..babaf667 100644
--- a/accel-pppd/ppp/ppp_fsm.c
+++ b/accel-pppd/ppp/ppp_fsm.c
@@ -505,14 +505,14 @@ static void init_req_counter(struct ppp_fsm_t *layer,int timeout)
layer->restart_counter = timeout;
if (!layer->restart_timer.tpd)
- triton_timer_add(layer->ppp->ctrl->ctx, &layer->restart_timer, 0);
+ triton_timer_add(layer->ppp->ses.ctrl->ctx, &layer->restart_timer, 0);
}
static void zero_req_counter(struct ppp_fsm_t *layer)
{
layer->restart_counter=0;
if (!layer->restart_timer.tpd)
- triton_timer_add(layer->ppp->ctrl->ctx, &layer->restart_timer, 0);
+ triton_timer_add(layer->ppp->ses.ctrl->ctx, &layer->restart_timer, 0);
}
static void restart_timer_func(struct triton_timer_t *t)
diff --git a/accel-pppd/ppp/ppp_ifcfg.c b/accel-pppd/ppp/ppp_ifcfg.c
index f916251d..bcad3f4b 100644
--- a/accel-pppd/ppp/ppp_ifcfg.c
+++ b/accel-pppd/ppp/ppp_ifcfg.c
@@ -59,52 +59,52 @@ void ppp_ifup(struct ppp_t *ppp)
struct npioctl np;
struct sockaddr_in addr;
- triton_event_fire(EV_PPP_ACCT_START, ppp);
+ triton_event_fire(EV_SES_ACCT_START, ppp);
if (ppp->stop_time)
return;
- triton_event_fire(EV_PPP_PRE_UP, ppp);
+ triton_event_fire(EV_SES_PRE_UP, ppp);
if (ppp->stop_time)
return;
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, ppp->ifname);
- if (ppp->ipv4) {
+ if (ppp->ses.ipv4) {
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = ppp->ipv4->addr;
+ addr.sin_addr.s_addr = ppp->ses.ipv4->addr;
memcpy(&ifr.ifr_addr,&addr,sizeof(addr));
if (ioctl(sock_fd, SIOCSIFADDR, &ifr))
log_ppp_error("ppp: failed to set IPv4 address: %s\n", strerror(errno));
- addr.sin_addr.s_addr = ppp->ipv4->peer_addr;
+ addr.sin_addr.s_addr = ppp->ses.ipv4->peer_addr;
memcpy(&ifr.ifr_dstaddr,&addr,sizeof(addr));
if (ioctl(sock_fd, SIOCSIFDSTADDR, &ifr))
log_ppp_error("ppp: failed to set peer IPv4 address: %s\n", strerror(errno));
}
- if (ppp->ipv6) {
+ if (ppp->ses.ipv6) {
devconf(ppp, "accept_ra", "0");
devconf(ppp, "autoconf", "0");
devconf(ppp, "forwarding", "1");
memset(&ifr6, 0, sizeof(ifr6));
ifr6.ifr6_addr.s6_addr32[0] = htons(0xfe80);
- *(uint64_t *)(ifr6.ifr6_addr.s6_addr + 8) = ppp->ipv6->intf_id;
+ *(uint64_t *)(ifr6.ifr6_addr.s6_addr + 8) = ppp->ses.ipv6->intf_id;
ifr6.ifr6_prefixlen = 64;
ifr6.ifr6_ifindex = ppp->ifindex;
if (ioctl(sock6_fd, SIOCSIFADDR, &ifr6))
log_ppp_error("ppp: faild to set LL IPv6 address: %s\n", strerror(errno));
- list_for_each_entry(a, &ppp->ipv6->addr_list, entry) {
+ list_for_each_entry(a, &ppp->ses.ipv6->addr_list, entry) {
if (a->prefix_len == 128)
continue;
- build_addr(a, ppp->ipv6->intf_id, &ifr6.ifr6_addr);
+ build_addr(a, ppp->ses.ipv6->intf_id, &ifr6.ifr6_addr);
ifr6.ifr6_prefixlen = a->prefix_len;
if (ioctl(sock6_fd, SIOCSIFADDR, &ifr6))
@@ -120,7 +120,7 @@ void ppp_ifup(struct ppp_t *ppp)
if (ioctl(sock_fd, SIOCSIFFLAGS, &ifr))
log_ppp_error("ppp: failed to set interface flags: %s\n", strerror(errno));
- if (ppp->ipv4) {
+ if (ppp->ses.ipv4) {
np.protocol = PPP_IP;
np.mode = NPMODE_PASS;
@@ -128,7 +128,7 @@ void ppp_ifup(struct ppp_t *ppp)
log_ppp_error("ppp: failed to set NP (IPv4) mode: %s\n", strerror(errno));
}
- if (ppp->ipv6) {
+ if (ppp->ses.ipv6) {
np.protocol = PPP_IPV6;
np.mode = NPMODE_PASS;
@@ -136,9 +136,9 @@ void ppp_ifup(struct ppp_t *ppp)
log_ppp_error("ppp: failed to set NP (IPv6) mode: %s\n", strerror(errno));
}
- ppp->ctrl->started(ppp);
+ ppp->ses.ctrl->started(ppp);
- triton_event_fire(EV_PPP_STARTED, ppp);
+ triton_event_fire(EV_SES_STARTED, ppp);
}
void __export ppp_ifdown(struct ppp_t *ppp)
@@ -152,27 +152,27 @@ void __export ppp_ifdown(struct ppp_t *ppp)
strcpy(ifr.ifr_name, ppp->ifname);
ioctl(sock_fd, SIOCSIFFLAGS, &ifr);
- if (ppp->ipv4) {
+ if (ppp->ses.ipv4) {
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
memcpy(&ifr.ifr_addr,&addr,sizeof(addr));
ioctl(sock_fd, SIOCSIFADDR, &ifr);
}
- if (ppp->ipv6) {
+ if (ppp->ses.ipv6) {
memset(&ifr6, 0, sizeof(ifr6));
ifr6.ifr6_addr.s6_addr32[0] = htons(0xfe80);
- *(uint64_t *)(ifr6.ifr6_addr.s6_addr + 8) = ppp->ipv6->intf_id;
+ *(uint64_t *)(ifr6.ifr6_addr.s6_addr + 8) = ppp->ses.ipv6->intf_id;
ifr6.ifr6_prefixlen = 64;
ifr6.ifr6_ifindex = ppp->ifindex;
ioctl(sock6_fd, SIOCDIFADDR, &ifr6);
- list_for_each_entry(a, &ppp->ipv6->addr_list, entry) {
+ list_for_each_entry(a, &ppp->ses.ipv6->addr_list, entry) {
if (a->prefix_len == 128)
continue;
- build_addr(a, ppp->ipv6->intf_id, &ifr6.ifr6_addr);
+ build_addr(a, ppp->ses.ipv6->intf_id, &ifr6.ifr6_addr);
ifr6.ifr6_prefixlen = a->prefix_len;
ioctl(sock6_fd, SIOCDIFADDR, &ifr6);
diff --git a/accel-pppd/ppp/ppp_ipcp.c b/accel-pppd/ppp/ppp_ipcp.c
index 9ec92d49..c05e20b1 100644
--- a/accel-pppd/ppp/ppp_ipcp.c
+++ b/accel-pppd/ppp/ppp_ipcp.c
@@ -121,8 +121,8 @@ static void ipcp_start_timeout(struct triton_timer_t *t)
triton_timer_del(t);
- if (ipcp->ppp->state == PPP_STATE_STARTING)
- ppp_terminate(ipcp->ppp, TERM_USER_ERROR, 0);
+ if (ipcp->ppp->ses.state == AP_STATE_STARTING)
+ ap_session_terminate(&ipcp->ppp->ses, TERM_USER_ERROR, 0);
}
int ipcp_layer_start(struct ppp_layer_data_t *ld)
@@ -137,7 +137,7 @@ int ipcp_layer_start(struct ppp_layer_data_t *ld)
if (ipcp->ld.passive) {
ipcp->timeout.expire = ipcp_start_timeout;
ipcp->timeout.expire_tv.tv_sec = START_TIMEOUT;
- triton_timer_add(ipcp->ppp->ctrl->ctx, &ipcp->timeout, 0);
+ triton_timer_add(ipcp->ppp->ses.ctrl->ctx, &ipcp->timeout, 0);
} else {
ppp_fsm_lower_up(&ipcp->fsm);
if (ppp_fsm_open(&ipcp->fsm))
@@ -202,17 +202,17 @@ static void ipcp_layer_finished(struct ppp_fsm_t *fsm)
if (!ipcp->started) {
if (conf_ipv4 == IPV4_REQUIRE)
- ppp_terminate(ipcp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&ipcp->ppp->ses, TERM_USER_ERROR, 0);
else
ppp_layer_passive(ipcp->ppp, &ipcp->ld);
- } else if (!ipcp->ppp->terminating)
- ppp_terminate(ipcp->ppp, TERM_USER_ERROR, 0);
+ } else if (!ipcp->ppp->ses.terminating)
+ ap_session_terminate(&ipcp->ppp->ses, TERM_USER_ERROR, 0);
fsm->fsm_state = FSM_Closed;
- if (ipcp->ppp->ipv4) {
- ipdb_put_ipv4(ipcp->ppp, ipcp->ppp->ipv4);
- ipcp->ppp->ipv4 = NULL;
+ if (ipcp->ppp->ses.ipv4) {
+ ipdb_put_ipv4(&ipcp->ppp->ses, ipcp->ppp->ses.ipv4);
+ ipcp->ppp->ses.ipv4 = NULL;
}
}
@@ -446,12 +446,12 @@ static int ipcp_recv_conf_req(struct ppp_ipcp_t *ipcp, uint8_t *data, int size)
}
if (r == IPCP_OPT_CLOSE) {
if (conf_ipv4 == IPV4_REQUIRE)
- ppp_terminate(ipcp->ppp, TERM_NAS_ERROR, 0);
+ ap_session_terminate(&ipcp->ppp->ses, TERM_NAS_ERROR, 0);
else
lcp_send_proto_rej(ipcp->ppp, PPP_IPCP);
return 0;
}
- if (ipcp->ppp->stop_time)
+ if (ipcp->ppp->ses.stop_time)
return -1;
lopt->state = r;
ropt->state = r;
@@ -660,10 +660,10 @@ static void ipcp_recv(struct ppp_handler_t*h)
int r;
int delay_ack = ipcp->delay_ack;
- if (!ipcp->starting || ipcp->fsm.fsm_state == FSM_Closed || ipcp->ppp->terminating || conf_ipv4 == IPV4_DENY) {
+ if (!ipcp->starting || ipcp->fsm.fsm_state == FSM_Closed || ipcp->ppp->ses.terminating || conf_ipv4 == IPV4_DENY) {
if (conf_ppp_verbose)
log_ppp_warn("IPCP: discarding packet\n");
- if (ipcp->ppp->terminating)
+ if (ipcp->ppp->ses.terminating)
return;
if (ipcp->fsm.fsm_state == FSM_Closed || conf_ipv4 == IPV4_DENY)
lcp_send_proto_rej(ipcp->ppp, PPP_IPCP);
@@ -689,7 +689,7 @@ static void ipcp_recv(struct ppp_handler_t*h)
switch(hdr->code) {
case CONFREQ:
r = ipcp_recv_conf_req(ipcp,(uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN);
- if (ipcp->ppp->stop_time) {
+ if (ipcp->ppp->ses.stop_time) {
ipcp_free_conf_req(ipcp);
return;
}
@@ -721,11 +721,11 @@ static void ipcp_recv(struct ppp_handler_t*h)
}
ipcp_free_conf_req(ipcp);
if (r == IPCP_OPT_FAIL)
- ppp_terminate(ipcp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&ipcp->ppp->ses, TERM_USER_ERROR, 0);
break;
case CONFACK:
if (ipcp_recv_conf_ack(ipcp,(uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN))
- ppp_terminate(ipcp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&ipcp->ppp->ses, TERM_USER_ERROR, 0);
else
ppp_fsm_recv_conf_ack(&ipcp->fsm);
break;
@@ -735,7 +735,7 @@ static void ipcp_recv(struct ppp_handler_t*h)
break;
case CONFREJ:
if (ipcp_recv_conf_rej(ipcp, (uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN))
- ppp_terminate(ipcp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&ipcp->ppp->ses, TERM_USER_ERROR, 0);
else
ppp_fsm_recv_conf_rej(&ipcp->fsm);
break;
@@ -743,13 +743,13 @@ static void ipcp_recv(struct ppp_handler_t*h)
if (conf_ppp_verbose)
log_ppp_info2("recv [IPCP TermReq id=%x]\n", hdr->id);
ppp_fsm_recv_term_req(&ipcp->fsm);
- ppp_terminate(ipcp->ppp, TERM_USER_REQUEST, 0);
+ ap_session_terminate(&ipcp->ppp->ses, TERM_USER_REQUEST, 0);
break;
case TERMACK:
if (conf_ppp_verbose)
log_ppp_info2("recv [IPCP TermAck id=%x]\n", hdr->id);
//ppp_fsm_recv_term_ack(&ipcp->fsm);
- //ppp_terminate(ipcp->ppp, 0);
+ //ap_session_terminate(&ipcp->ppp->ses, 0);
break;
case CODEREJ:
if (conf_ppp_verbose)
diff --git a/accel-pppd/ppp/ppp_ipv6cp.c b/accel-pppd/ppp/ppp_ipv6cp.c
index 9e7bf784..ee666267 100644
--- a/accel-pppd/ppp/ppp_ipv6cp.c
+++ b/accel-pppd/ppp/ppp_ipv6cp.c
@@ -119,8 +119,8 @@ static void ipv6cp_start_timeout(struct triton_timer_t *t)
triton_timer_del(t);
- if (ipv6cp->ppp->state == PPP_STATE_STARTING)
- ppp_terminate(ipv6cp->ppp, TERM_USER_ERROR, 0);
+ if (ipv6cp->ppp->ses.state == AP_STATE_STARTING)
+ ap_session_terminate(&ipv6cp->ppp->ses, TERM_USER_ERROR, 0);
}
int ipv6cp_layer_start(struct ppp_layer_data_t *ld)
@@ -137,7 +137,7 @@ int ipv6cp_layer_start(struct ppp_layer_data_t *ld)
if (ipv6cp->ld.passive) {
ipv6cp->timeout.expire = ipv6cp_start_timeout;
ipv6cp->timeout.expire_tv.tv_sec = START_TIMEOUT;
- triton_timer_add(ipv6cp->ppp->ctrl->ctx, &ipv6cp->timeout, 0);
+ triton_timer_add(ipv6cp->ppp->ses.ctrl->ctx, &ipv6cp->timeout, 0);
} else {
ppp_fsm_lower_up(&ipv6cp->fsm);
if (ppp_fsm_open(&ipv6cp->fsm))
@@ -202,17 +202,17 @@ static void ipv6cp_layer_finished(struct ppp_fsm_t *fsm)
if (!ipv6cp->started) {
if (conf_ipv6 == IPV6_REQUIRE)
- ppp_terminate(ipv6cp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&ipv6cp->ppp->ses, TERM_USER_ERROR, 0);
else
ppp_layer_passive(ipv6cp->ppp, &ipv6cp->ld);
- } else if (!ipv6cp->ppp->terminating)
- ppp_terminate(ipv6cp->ppp, TERM_USER_ERROR, 0);
+ } else if (!ipv6cp->ppp->ses.terminating)
+ ap_session_terminate(&ipv6cp->ppp->ses, TERM_USER_ERROR, 0);
fsm->fsm_state = FSM_Closed;
- if (ipv6cp->ppp->ipv6) {
- ipdb_put_ipv6(ipv6cp->ppp, ipv6cp->ppp->ipv6);
- ipv6cp->ppp->ipv6 = NULL;
+ if (ipv6cp->ppp->ses.ipv6) {
+ ipdb_put_ipv6(&ipv6cp->ppp->ses, ipv6cp->ppp->ses.ipv6);
+ ipv6cp->ppp->ses.ipv6 = NULL;
}
}
@@ -446,12 +446,12 @@ static int ipv6cp_recv_conf_req(struct ppp_ipv6cp_t *ipv6cp, uint8_t *data, int
}
if (r == IPV6CP_OPT_CLOSE) {
if (conf_ipv6 == IPV6_REQUIRE)
- ppp_terminate(ipv6cp->ppp, TERM_NAS_ERROR, 0);
+ ap_session_terminate(&ipv6cp->ppp->ses, TERM_NAS_ERROR, 0);
else
lcp_send_proto_rej(ipv6cp->ppp, PPP_IPV6CP);
return 0;
}
- if (ipv6cp->ppp->stop_time)
+ if (ipv6cp->ppp->ses.stop_time)
return -1;
lopt->state = r;
ropt->state = r;
@@ -660,10 +660,10 @@ static void ipv6cp_recv(struct ppp_handler_t*h)
int r;
int delay_ack = ipv6cp->delay_ack;
- if (!ipv6cp->starting || ipv6cp->fsm.fsm_state == FSM_Closed || ipv6cp->ppp->terminating || conf_ipv6 == IPV6_DENY) {
+ if (!ipv6cp->starting || ipv6cp->fsm.fsm_state == FSM_Closed || ipv6cp->ppp->ses.terminating || conf_ipv6 == IPV6_DENY) {
if (conf_ppp_verbose)
log_ppp_warn("IPV6CP: discarding packet\n");
- if (ipv6cp->ppp->terminating)
+ if (ipv6cp->ppp->ses.terminating)
return;
if (ipv6cp->fsm.fsm_state == FSM_Closed || conf_ipv6 == IPV6_DENY)
lcp_send_proto_rej(ipv6cp->ppp, PPP_IPV6CP);
@@ -689,7 +689,7 @@ static void ipv6cp_recv(struct ppp_handler_t*h)
switch(hdr->code) {
case CONFREQ:
r = ipv6cp_recv_conf_req(ipv6cp,(uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN);
- if (ipv6cp->ppp->stop_time) {
+ if (ipv6cp->ppp->ses.stop_time) {
ipv6cp_free_conf_req(ipv6cp);
return;
}
@@ -721,11 +721,11 @@ static void ipv6cp_recv(struct ppp_handler_t*h)
}
ipv6cp_free_conf_req(ipv6cp);
if (r == IPV6CP_OPT_FAIL)
- ppp_terminate(ipv6cp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&ipv6cp->ppp->ses, TERM_USER_ERROR, 0);
break;
case CONFACK:
if (ipv6cp_recv_conf_ack(ipv6cp,(uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN))
- ppp_terminate(ipv6cp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&ipv6cp->ppp->ses, TERM_USER_ERROR, 0);
else
ppp_fsm_recv_conf_ack(&ipv6cp->fsm);
break;
@@ -735,7 +735,7 @@ static void ipv6cp_recv(struct ppp_handler_t*h)
break;
case CONFREJ:
if (ipv6cp_recv_conf_rej(ipv6cp, (uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN))
- ppp_terminate(ipv6cp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&ipv6cp->ppp->ses, TERM_USER_ERROR, 0);
else
ppp_fsm_recv_conf_rej(&ipv6cp->fsm);
break;
@@ -743,13 +743,13 @@ static void ipv6cp_recv(struct ppp_handler_t*h)
if (conf_ppp_verbose)
log_ppp_info2("recv [IPV6CP TermReq id=%x]\n", hdr->id);
ppp_fsm_recv_term_req(&ipv6cp->fsm);
- ppp_terminate(ipv6cp->ppp, TERM_USER_REQUEST, 0);
+ ap_session_terminate(&ipv6cp->ppp->ses, TERM_USER_REQUEST, 0);
break;
case TERMACK:
if (conf_ppp_verbose)
log_ppp_info2("recv [IPV6CP TermAck id=%x]\n", hdr->id);
//ppp_fsm_recv_term_ack(&ipv6cp->fsm);
- //ppp_terminate(ipv6cp->ppp, 0);
+ //ap_session_terminate(&ipv6cp->ppp->ses, 0);
break;
case CODEREJ:
if (conf_ppp_verbose)
diff --git a/accel-pppd/ppp/ppp_lcp.c b/accel-pppd/ppp/ppp_lcp.c
index 5813517a..b081e875 100644
--- a/accel-pppd/ppp/ppp_lcp.c
+++ b/accel-pppd/ppp/ppp_lcp.c
@@ -138,7 +138,7 @@ void lcp_layer_finish(struct ppp_layer_data_t *ld)
stop_echo(lcp);
ppp_fsm_close(&lcp->fsm);
} else
- triton_context_call(lcp->ppp->ctrl->ctx, (triton_event_func)_lcp_layer_finished, lcp);
+ triton_context_call(lcp->ppp->ses.ctrl->ctx, (triton_event_func)_lcp_layer_finished, lcp);
}
void lcp_layer_free(struct ppp_layer_data_t *ld)
@@ -151,7 +151,7 @@ void lcp_layer_free(struct ppp_layer_data_t *ld)
ppp_unregister_handler(lcp->ppp, &lcp->hnd);
lcp_options_free(lcp);
ppp_fsm_free(&lcp->fsm);
- triton_cancel_call(lcp->ppp->ctrl->ctx, (triton_event_func)_lcp_layer_finished);
+ triton_cancel_call(lcp->ppp->ses.ctrl->ctx, (triton_event_func)_lcp_layer_finished);
_free(lcp);
}
@@ -186,12 +186,12 @@ static void lcp_layer_finished(struct ppp_fsm_t *fsm)
stop_echo(lcp);
if (lcp->started) {
lcp->started = 0;
- if (lcp->ppp->terminating)
+ if (lcp->ppp->ses.terminating)
ppp_layer_finished(lcp->ppp, &lcp->ld);
else
- ppp_terminate(lcp->ppp, TERM_NAS_ERROR, 0);
+ ap_session_terminate(&lcp->ppp->ses, TERM_NAS_ERROR, 0);
} else
- ppp_terminate(lcp->ppp, TERM_NAS_ERROR, 0);
+ ap_session_terminate(&lcp->ppp->ses, TERM_NAS_ERROR, 0);
}
static void print_ropt(struct recv_opt_t *ropt)
@@ -587,7 +587,7 @@ static void lcp_update_echo_timer(struct ppp_lcp_t *lcp)
if (lcp->echo_timer.tpd)
triton_timer_mod(&lcp->echo_timer, 0);
else
- triton_timer_add(lcp->ppp->ctrl->ctx, &lcp->echo_timer, 0);
+ triton_timer_add(lcp->ppp->ses.ctrl->ctx, &lcp->echo_timer, 0);
}
}
}
@@ -607,7 +607,7 @@ static void lcp_recv_echo_repl(struct ppp_lcp_t *lcp, uint8_t *data, int size)
if (magic == lcp->magic) {
log_ppp_error("lcp: echo: loop-back detected\n");
- ppp_terminate(lcp->ppp, TERM_NAS_ERROR, 0);
+ ap_session_terminate(&lcp->ppp->ses, TERM_NAS_ERROR, 0);
}
}
@@ -656,7 +656,7 @@ static void send_echo_request(struct triton_timer_t *t)
if (lcp->echo_sent == 2) {
memset(&ifreq, 0, sizeof(ifreq));
ifreq.stats_ptr = (void *)&ifreq.stats;
- strcpy(ifreq.ifr__name, lcp->ppp->ifname);
+ strcpy(ifreq.ifr__name, lcp->ppp->ses.ifname);
if (ioctl(sock_fd, SIOCGPPPSTATS, &ifreq) == 0)
lcp->last_ipackets = ifreq.stats.p.ppp_ipackets;
@@ -666,7 +666,7 @@ static void send_echo_request(struct triton_timer_t *t)
time(&ts);
memset(&ifreq, 0, sizeof(ifreq));
ifreq.stats_ptr = (void *)&ifreq.stats;
- strcpy(ifreq.ifr__name, lcp->ppp->ifname);
+ strcpy(ifreq.ifr__name, lcp->ppp->ses.ifname);
if (ioctl(sock_fd, SIOCGPPPSTATS, &ifreq) == 0 && lcp->last_ipackets != ifreq.stats.p.ppp_ipackets) {
lcp->echo_sent = 1;
lcp_update_echo_timer(lcp);
@@ -682,7 +682,7 @@ static void send_echo_request(struct triton_timer_t *t)
if (f) {
log_ppp_warn("lcp: no echo reply\n");
- ppp_terminate(lcp->ppp, TERM_LOST_CARRIER, 1);
+ ap_session_terminate(&lcp->ppp->ses, TERM_LOST_CARRIER, 1);
return;
}
@@ -697,7 +697,7 @@ static void start_echo(struct ppp_lcp_t *lcp)
lcp->echo_timer.period = conf_echo_interval * 1000;
lcp->echo_timer.expire = send_echo_request;
if (lcp->echo_timer.period && !lcp->echo_timer.tpd)
- triton_timer_add(lcp->ppp->ctrl->ctx, &lcp->echo_timer, 0);
+ triton_timer_add(lcp->ppp->ses.ctrl->ctx, &lcp->echo_timer, 0);
}
static void stop_echo(struct ppp_lcp_t *lcp)
{
@@ -782,7 +782,7 @@ static void lcp_recv(struct ppp_handler_t*h)
if ((hdr->code == CONFACK || hdr->code == CONFNAK || hdr->code == CONFREJ) && lcp->started)
return;
- if (lcp->fsm.fsm_state == FSM_Initial || lcp->fsm.fsm_state == FSM_Closed || (lcp->ppp->terminating && (hdr->code != TERMACK && hdr->code != TERMREQ))) {
+ if (lcp->fsm.fsm_state == FSM_Initial || lcp->fsm.fsm_state == FSM_Closed || (lcp->ppp->ses.terminating && (hdr->code != TERMACK && hdr->code != TERMREQ))) {
/*if (conf_ppp_verbose)
log_ppp_warn("LCP: discaring packet\n");
lcp_send_proto_rej(ccp->ppp, htons(PPP_CCP));*/
@@ -813,11 +813,11 @@ static void lcp_recv(struct ppp_handler_t*h)
}
lcp_free_conf_req(lcp);
if (r == LCP_OPT_FAIL)
- ppp_terminate(lcp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&lcp->ppp->ses, TERM_USER_ERROR, 0);
break;
case CONFACK:
if (lcp_recv_conf_ack(lcp,(uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN))
- ppp_terminate(lcp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&lcp->ppp->ses, TERM_USER_ERROR, 0);
else
if (lcp->fsm.recv_id != lcp->fsm.id)
break;
@@ -831,7 +831,7 @@ static void lcp_recv(struct ppp_handler_t*h)
break;
case CONFREJ:
if (lcp_recv_conf_rej(lcp,(uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN))
- ppp_terminate(lcp->ppp, TERM_USER_ERROR, 0);
+ ap_session_terminate(&lcp->ppp->ses, TERM_USER_ERROR, 0);
else
if (lcp->fsm.recv_id != lcp->fsm.id)
break;
@@ -841,7 +841,7 @@ static void lcp_recv(struct ppp_handler_t*h)
if (conf_ppp_verbose)
log_ppp_info2("recv [LCP TermReq id=%x]\n", hdr->id);
ppp_fsm_recv_term_req(&lcp->fsm);
- ppp_terminate(lcp->ppp, TERM_USER_REQUEST, 0);
+ ap_session_terminate(&lcp->ppp->ses, TERM_USER_REQUEST, 0);
break;
case TERMACK:
if (conf_ppp_verbose)