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.c10
-rw-r--r--accel-pppd/ctrl/l2tp/l2tp.c12
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c25
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.h2
-rw-r--r--accel-pppd/ctrl/pptp/pptp.c10
5 files changed, 46 insertions, 13 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 536fb25..46f1cac 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -196,6 +196,12 @@ static void __ipoe_session_start(struct ipoe_session *ses);
static int ipoe_rad_send_auth_request(struct rad_plugin_t *rad, struct rad_packet_t *pack);
static int ipoe_rad_send_acct_request(struct rad_plugin_t *rad, struct rad_packet_t *pack);
+static void ipoe_ctx_switch(struct triton_context_t *ctx, void *arg)
+{
+ net = &def_net;
+ ipoe_ctx_switch(ctx, arg);
+}
+
static struct ipoe_session *ipoe_session_lookup(struct ipoe_serv *serv, struct dhcpv4_packet *pack, struct ipoe_session **opt82_ses)
{
struct ipoe_session *ses, *res = NULL;
@@ -1873,7 +1879,7 @@ struct ipoe_session *ipoe_session_alloc(void)
ses->ifindex = -1;
- ses->ctx.before_switch = log_switch;
+ ses->ctx.before_switch = ipoe_ctx_switch;
ses->ctx.close = ipoe_session_close;
ses->ctrl.ctx = &ses->ctx;
ses->ctrl.started = ipoe_session_started;
@@ -2575,7 +2581,7 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
serv = _malloc(sizeof(*serv));
memset(serv, 0, sizeof(*serv));
serv->ctx.close = ipoe_serv_close;
- serv->ctx.before_switch = log_switch;
+ serv->ctx.before_switch = ipoe_ctx_switch;
pthread_mutex_init(&serv->lock, NULL);
serv->ifname = _strdup(ifname);
serv->ifindex = ifindex;
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c
index befe0c9..6350e8e 100644
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -253,6 +253,12 @@ static inline int nsnr_cmp(uint16_t ns, uint16_t nr)
return (sub_nsnr != 0 && sub_nsnr < ref) - (sub_nsnr >= ref);
}
+static void l2tp_ctx_switch(struct triton_context_t *ctx, void *arg)
+{
+ net = &def_net;
+ log_switch(ctx, arg);
+}
+
static inline struct l2tp_conn_t *l2tp_tunnel_self(void)
{
return container_of(triton_context_self(), struct l2tp_conn_t, ctx);
@@ -1684,7 +1690,7 @@ static struct l2tp_conn_t *l2tp_tunnel_alloc(const struct sockaddr_in *peer,
conn->state = STATE_INIT;
conn->framing_cap = framing_cap;
- conn->ctx.before_switch = log_switch;
+ conn->ctx.before_switch = l2tp_ctx_switch;
conn->ctx.close = l2tp_conn_close;
conn->hnd.read = l2tp_conn_read;
conn->timeout_timer.expire = l2tp_tunnel_timeout;
@@ -1741,7 +1747,7 @@ static inline int l2tp_tunnel_update_peerport(struct l2tp_conn_t *conn,
static int l2tp_session_start_data_channel(struct l2tp_sess_t *sess)
{
- sess->apses_ctx.before_switch = log_switch;
+ sess->apses_ctx.before_switch = l2tp_ctx_switch;
sess->apses_ctx.close = apses_ctx_stop;
sess->ctrl.ctx = &sess->apses_ctx;
@@ -4436,7 +4442,7 @@ static struct l2tp_serv_t udp_serv =
{
.hnd.read = l2tp_udp_read,
.ctx.close = l2tp_udp_close,
- .ctx.before_switch = log_switch,
+ .ctx.before_switch = l2tp_ctx_switch,
};
/*static struct l2tp_serv_t ip_serv =
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index fc8a032..a9cbfbe 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -252,6 +252,13 @@ static int pppoe_rad_send_accounting_request(struct rad_plugin_t *rad, struct ra
}
#endif
+static void pppoe_conn_ctx_switch(struct triton_context_t *ctx, void *arg)
+{
+ struct pppoe_conn_t *conn = arg;
+ net = conn->serv->net;
+ log_switch(ctx, &conn->ppp.ses);
+}
+
static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const uint8_t *addr, const struct pppoe_tag *host_uniq, const struct pppoe_tag *relay_sid, const struct pppoe_tag *service_name, const struct pppoe_tag *tr101, const uint8_t *cookie)
{
struct pppoe_conn_t *conn;
@@ -318,7 +325,7 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
memcpy(conn->cookie, cookie, COOKIE_LENGTH - 4);
- conn->ctx.before_switch = log_switch;
+ conn->ctx.before_switch = pppoe_conn_ctx_switch;
conn->ctx.close = pppoe_conn_close;
conn->ctrl.ctx = &conn->ctx;
conn->ctrl.started = ppp_started;
@@ -386,7 +393,7 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
if (conf_ip_pool)
conn->ppp.ses.ipv4_pool_name = _strdup(conf_ip_pool);
- triton_context_register(&conn->ctx, &conn->ppp.ses);
+ triton_context_register(&conn->ctx, conn);
pthread_mutex_lock(&serv->lock);
list_add_tail(&conn->entry, &serv->conn_list);
@@ -1301,6 +1308,13 @@ void pppoe_server_start(const char *opt, void *cli)
__pppoe_server_start(opt, opt, cli, 0, 0);
}
+static void pppoe_serv_ctx_switch(struct triton_context_t *ctx, void *arg)
+{
+ struct pppoe_serv_t *serv = arg;
+ net = serv->net;
+ log_switch(ctx, NULL);
+}
+
static void __pppoe_server_start(const char *ifname, const char *opt, void *cli, int parent_ifindex, int vid)
{
struct pppoe_serv_t *serv;
@@ -1380,9 +1394,10 @@ static void __pppoe_server_start(const char *ifname, const char *opt, void *cli,
}
serv->ctx.close = pppoe_serv_close;
- serv->ctx.before_switch = log_switch;
+ serv->ctx.before_switch = pppoe_serv_ctx_switch;
serv->ifname = _strdup(ifname);
serv->ifindex = ifr.ifr_ifindex;
+ serv->net = &def_net;
pthread_mutex_init(&serv->lock, NULL);
INIT_LIST_HEAD(&serv->conn_list);
@@ -1390,7 +1405,7 @@ static void __pppoe_server_start(const char *ifname, const char *opt, void *cli,
INIT_LIST_HEAD(&serv->padi_list);
serv->padi_limit = padi_limit;
- triton_context_register(&serv->ctx, NULL);
+ triton_context_register(&serv->ctx, serv);
if (vid) {
serv->parent_ifindex = parent_ifindex;
@@ -1408,8 +1423,6 @@ static void __pppoe_server_start(const char *ifname, const char *opt, void *cli,
triton_context_wakeup(&serv->ctx);
- pppoe_disc_start(serv);
-
return;
out_err:
diff --git a/accel-pppd/ctrl/pppoe/pppoe.h b/accel-pppd/ctrl/pppoe/pppoe.h
index d044e4c..c28d96e 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.h
+++ b/accel-pppd/ctrl/pppoe/pppoe.h
@@ -69,6 +69,8 @@ struct pppoe_serv_t
struct triton_context_t ctx;
struct rb_node node;
+ struct ap_net *net;
+
uint8_t hwaddr[ETH_ALEN];
char *ifname;
int ifindex;
diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c
index 94cfd7f..4a3090e 100644
--- a/accel-pppd/ctrl/pptp/pptp.c
+++ b/accel-pppd/ctrl/pptp/pptp.c
@@ -73,6 +73,12 @@ static void pptp_timeout(struct triton_timer_t *);
static void ppp_started(struct ap_session *);
static void ppp_finished(struct ap_session *);
+static void pptp_ctx_switch(struct triton_context_t *ctx, void *arg)
+{
+ net = &def_net;
+ pptp_ctx_switch(ctx, arg);
+}
+
static void disconnect(struct pptp_conn_t *conn)
{
log_ppp_debug("pptp: disconnect\n");
@@ -663,7 +669,7 @@ static int pptp_connect(struct triton_md_handler_t *h)
conn->hnd.read = pptp_read;
conn->hnd.write = pptp_write;
conn->ctx.close = pptp_close;
- conn->ctx.before_switch = log_switch;
+ conn->ctx.before_switch = pptp_ctx_switch;
conn->in_buf = _malloc(PPTP_CTRL_SIZE_MAX);
conn->out_buf = _malloc(PPTP_CTRL_SIZE_MAX);
conn->timeout_timer.expire = pptp_timeout;
@@ -714,7 +720,7 @@ static struct pptp_serv_t serv=
{
.hnd.read = pptp_connect,
.ctx.close = pptp_serv_close,
- .ctx.before_switch = log_switch,
+ .ctx.before_switch = pptp_ctx_switch,
};
static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt, void *client)