summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c62
-rw-r--r--accel-pppd/ctrl/l2tp/l2tp.c6
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c6
-rw-r--r--accel-pppd/ctrl/pptp/pptp.c6
4 files changed, 35 insertions, 45 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 7059e2a..6835fc6 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -98,7 +98,7 @@ static int conf_ifcfg = 1;
static int conf_nat = 0;
static int conf_arp = 0;
static uint32_t conf_src;
-
+static const char *conf_ip_pool;
//static int conf_dhcpv6;
static int conf_username;
static const char *conf_password;
@@ -974,18 +974,11 @@ static struct ipoe_session *ipoe_session_create_dhcpv4(struct ipoe_serv *serv, s
int dlen = 0;
uint8_t *ptr = NULL;
- ses = mempool_alloc(ses_pool);
- if (!ses) {
- log_emerg("out of memery\n");
+ ses = ipoe_session_alloc();
+ if (!ses)
return NULL;
- }
-
- memset(ses, 0, sizeof(*ses));
-
- ap_session_init(&ses->ses);
ses->serv = serv;
- ses->ifindex = -1;
ses->dhcpv4_request = pack;
ses->xid = pack->hdr->xid;
@@ -1027,14 +1020,6 @@ static struct ipoe_session *ipoe_session_create_dhcpv4(struct ipoe_serv *serv, s
ses->relay_agent = NULL;
}
- ses->ctx.before_switch = log_switch;
- ses->ctx.close = ipoe_session_close;
- ses->ctrl.ctx = &ses->ctx;
- ses->ctrl.started = ipoe_session_started;
- ses->ctrl.finished = ipoe_session_finished;
- ses->ctrl.terminate = ipoe_session_terminate;
- ses->ctrl.type = CTRL_TYPE_IPOE;
- ses->ctrl.name = "ipoe";
ses->ctrl.dont_ifcfg = 1;
ses->ctrl.calling_station_id = _malloc(19);
@@ -1047,6 +1032,9 @@ static struct ipoe_session *ipoe_session_create_dhcpv4(struct ipoe_serv *serv, s
ses->ses.ctrl = &ses->ctrl;
ses->ses.chan_name = ses->ctrl.calling_station_id;
+ if (conf_ip_pool)
+ ses->ses.ipv4_pool_name = _strdup(conf_ip_pool);
+
triton_context_register(&ses->ctx, &ses->ses);
triton_context_wakeup(&ses->ctx);
@@ -1497,44 +1485,27 @@ static struct ipoe_session *ipoe_session_create_up(struct ipoe_serv *serv, struc
if (l4_redirect_list_check(iph->saddr))
return NULL;
- ses = mempool_alloc(ses_pool);
- if (!ses) {
- log_emerg("out of memery\n");
+ ses = ipoe_session_alloc();
+ if (!ses)
return NULL;
- }
-
- memset(ses, 0, sizeof(*ses));
-
- ap_session_init(&ses->ses);
ses->serv = serv;
- ses->ifindex = -1;
-
memcpy(ses->hwaddr, eth->h_source, 6);
-
- ses->ctx.before_switch = log_switch;
- ses->ctx.close = ipoe_session_close;
- ses->ctrl.ctx = &ses->ctx;
- ses->ctrl.started = ipoe_session_started;
- ses->ctrl.finished = ipoe_session_finished;
- ses->ctrl.terminate = ipoe_session_terminate;
- ses->ctrl.type = CTRL_TYPE_IPOE;
- ses->ctrl.name = "ipoe";
-
ses->yiaddr = iph->saddr;
ses->ctrl.calling_station_id = _malloc(17);
- ses->ctrl.called_station_id = _malloc(17);
+ ses->ctrl.called_station_id = _strdup(serv->ifname);
u_inet_ntoa(iph->saddr, ses->ctrl.calling_station_id);
- u_inet_ntoa(iph->daddr, ses->ctrl.called_station_id);
+
+ ses->ses.chan_name = ses->ctrl.calling_station_id;
if (conf_username == USERNAME_UNSET)
ses->ses.username = _strdup(ses->ctrl.calling_station_id);
- ses->ses.ctrl = &ses->ctrl;
- ses->ses.chan_name = ses->ctrl.calling_station_id;
-
+ if (conf_ip_pool)
+ ses->ses.ipv4_pool_name = _strdup(conf_ip_pool);
+
triton_context_register(&ses->ctx, &ses->ses);
triton_context_wakeup(&ses->ctx);
@@ -1577,8 +1548,7 @@ struct ipoe_session *ipoe_session_alloc(void)
ses->ctrl.name = "ipoe";
ses->ses.ctrl = &ses->ctrl;
- ses->ses.chan_name = ses->ctrl.calling_station_id;
-
+
return ses;
}
@@ -2858,6 +2828,8 @@ static void load_config(void)
else
conf_offer_timeout = 10;
+ conf_ip_pool = conf_get_opt("ipoe", "ip-pool");
+
#ifdef RADIUS
if (triton_module_loaded("radius"))
load_radius_attrs();
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c
index e6fae4d..e14bab8 100644
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -67,6 +67,7 @@ static size_t conf_secret_len = 0;
static int conf_mppe = MPPE_UNSET;
static int conf_dataseq = L2TP_DATASEQ_ALLOW;
static int conf_reorder_timeout = 0;
+static const char *conf_ip_pool;
static unsigned int stat_active;
static unsigned int stat_starting;
@@ -905,6 +906,9 @@ static struct l2tp_sess_t *l2tp_tunnel_alloc_session(struct l2tp_conn_t *conn)
sess->ppp.ses.ctrl = &sess->ctrl;
sess->ppp.fd = -1;
+ if (conf_ip_pool)
+ sess->ppp.ses.ipv4_pool_name = _strdup(conf_ip_pool);
+
return sess;
}
@@ -3963,6 +3967,8 @@ static void load_config(void)
else if (strcmp(opt, "require") == 0)
conf_mppe = MPPE_REQUIRE;
}
+
+ conf_ip_pool = conf_get_opt("l2tp", "ip-pool");
}
static void l2tp_init(void)
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index 21051ed..c254c7a 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -89,6 +89,7 @@ char *conf_pado_delay;
int conf_tr101 = 1;
int conf_padi_limit = 0;
int conf_mppe = MPPE_UNSET;
+static const char *conf_ip_pool;
static mempool_t conn_pool;
static mempool_t pado_pool;
@@ -299,6 +300,9 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
conn->ppp.ses.ctrl = &conn->ctrl;
conn->ppp.ses.chan_name = conn->ctrl.calling_station_id;
+
+ if (conf_ip_pool)
+ conn->ppp.ses.ipv4_pool_name = _strdup(conf_ip_pool);
triton_context_register(&conn->ctx, &conn->ppp.ses);
triton_context_wakeup(&conn->ctx);
@@ -1489,6 +1493,8 @@ static void load_config(void)
else if (strcmp(opt, "require") == 0)
conf_mppe = MPPE_REQUIRE;
}
+
+ conf_ip_pool = conf_get_opt("pppoe", "ip-pool");
}
static void pppoe_init(void)
diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c
index d5b96c1..31ffd00 100644
--- a/accel-pppd/ctrl/pptp/pptp.c
+++ b/accel-pppd/ctrl/pptp/pptp.c
@@ -60,6 +60,7 @@ static int conf_echo_interval = 0;
static int conf_echo_failure = 3;
static int conf_verbose = 0;
static int conf_mppe = MPPE_UNSET;
+static const char *conf_ip_pool;
static mempool_t conn_pool;
@@ -685,6 +686,9 @@ static int pptp_connect(struct triton_md_handler_t *h)
ppp_init(&conn->ppp);
conn->ppp.ses.ctrl = &conn->ctrl;
+ if (conf_ip_pool)
+ conn->ppp.ses.ipv4_pool_name = _strdup(conf_ip_pool);
+
triton_context_register(&conn->ctx, &conn->ppp.ses);
triton_md_register_handler(&conn->ctx, &conn->hnd);
triton_md_enable_handler(&conn->hnd,MD_MODE_READ);
@@ -759,6 +763,8 @@ static void load_config(void)
else if (strcmp(opt, "require") == 0)
conf_mppe = MPPE_REQUIRE;
}
+
+ conf_ip_pool = conf_get_opt("pptp", "ip-pool");
}
static void pptp_init(void)