diff options
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r-- | accel-pppd/ctrl/l2tp/l2tp.c | 26 | ||||
-rw-r--r-- | accel-pppd/ctrl/pppoe/pppoe.c | 30 | ||||
-rw-r--r-- | accel-pppd/ctrl/pptp/pptp.c | 30 |
3 files changed, 46 insertions, 40 deletions
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index d8a98f8d..e3db614a 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -94,7 +94,7 @@ struct l2tp_conn_t int state1; int state2; - struct ppp_ctrl_t ctrl; + struct ap_ctrl ctrl; struct ppp_t ppp; }; @@ -130,7 +130,7 @@ static void l2tp_disconnect(struct l2tp_conn_t *conn) if (conn->state == STATE_PPP) { __sync_sub_and_fetch(&stat_active, 1); conn->state = STATE_FIN; - ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1); + ap_session_terminate(&conn->ppp.ses, TERM_USER_REQUEST, 1); } else if (conn->state != STATE_FIN) __sync_sub_and_fetch(&stat_starting, 1); @@ -156,8 +156,8 @@ static void l2tp_disconnect(struct l2tp_conn_t *conn) l2tp_packet_free(pack); } - if (conn->ppp.chan_name) - _free(conn->ppp.chan_name); + if (conn->ppp.ses.chan_name) + _free(conn->ppp.ses.chan_name); if (conn->challenge_len) _free(conn->challenge.octets); _free(conn->ctrl.calling_station_id); @@ -193,8 +193,9 @@ out_err: return -1; } -static void l2tp_ppp_started(struct ppp_t *ppp) +static void l2tp_ppp_started(struct ap_session *ses) { + struct ppp_t *ppp = container_of(ses, typeof(*ppp), ses); struct l2tp_conn_t *conn = container_of(ppp, typeof(*conn), ppp); log_ppp_debug("l2tp: ppp started\n"); @@ -203,8 +204,9 @@ static void l2tp_ppp_started(struct ppp_t *ppp) triton_timer_add(&conn->ctx, &conn->hello_timer, 0); } -static void l2tp_ppp_finished(struct ppp_t *ppp) +static void l2tp_ppp_finished(struct ap_session *ses) { + struct ppp_t *ppp = container_of(ses, typeof(*ppp), ses); struct l2tp_conn_t *conn = container_of(ppp, typeof(*conn), ppp); log_ppp_debug("l2tp: ppp finished\n"); @@ -223,7 +225,7 @@ static void l2tp_conn_close(struct triton_context_t *ctx) if (conn->state == STATE_PPP) { __sync_sub_and_fetch(&stat_active, 1); conn->state = STATE_FIN; - ppp_terminate(&conn->ppp, TERM_ADMIN_RESET, 1); + ap_session_terminate(&conn->ppp.ses, TERM_ADMIN_RESET, 1); } if (l2tp_terminate(conn, 0, 0)) @@ -343,11 +345,11 @@ static int l2tp_tunnel_alloc(struct l2tp_serv_t *serv, struct l2tp_packet_t *pac u_inet_ntoa(addr.sin_addr.s_addr, conn->ctrl.called_station_id); ppp_init(&conn->ppp); - conn->ppp.ctrl = &conn->ctrl; + conn->ppp.ses.ctrl = &conn->ctrl; conn->ppp.fd = -1; conn->tunnel_fd = -1; - triton_context_register(&conn->ctx, &conn->ppp); + 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); triton_context_wakeup(&conn->ctx); @@ -419,7 +421,7 @@ static int l2tp_connect(struct l2tp_conn_t *conn) return -1; } - conn->ppp.chan_name = _strdup(inet_ntoa(conn->addr.sin_addr)); + conn->ppp.ses.chan_name = _strdup(inet_ntoa(conn->addr.sin_addr)); triton_event_fire(EV_CTRL_STARTED, &conn->ppp); @@ -654,7 +656,7 @@ static int l2tp_recv_SCCRQ(struct l2tp_serv_t *serv, struct l2tp_packet_t *pack, struct l2tp_attr_t *router_id = NULL; struct l2tp_attr_t *challenge = NULL; - if (ppp_shutdown) + if (ap_shutdown) return 0; if (triton_module_loaded("connlimit") && connlimit_check(cl_key_from_ipv4(pack->addr.sin_addr.s_addr))) @@ -863,7 +865,7 @@ static int l2tp_recv_CDN(struct l2tp_conn_t *conn, struct l2tp_packet_t *pack) if (conn->state == STATE_PPP) { __sync_sub_and_fetch(&stat_active, 1); conn->state = STATE_FIN; - ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1); + ap_session_terminate(&conn->ppp.ses, TERM_USER_REQUEST, 1); } if (l2tp_terminate(conn, 0, 0)) diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c index f616ade4..7981eba1 100644 --- a/accel-pppd/ctrl/pppoe/pppoe.c +++ b/accel-pppd/ctrl/pppoe/pppoe.c @@ -48,7 +48,7 @@ struct pppoe_conn_t struct pppoe_tag *tr101; uint8_t cookie[COOKIE_LENGTH]; - struct ppp_ctrl_t ctrl; + struct ap_ctrl ctrl; struct ppp_t ppp; #ifdef RADIUS struct rad_plugin_t radius; @@ -112,7 +112,7 @@ static void disconnect(struct pppoe_conn_t *conn) if (conn->ppp_started) { dpado_check_prev(__sync_fetch_and_sub(&stat_active, 1)); conn->ppp_started = 0; - ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1); + ap_session_terminate(&conn->ppp.ses, TERM_USER_REQUEST, 1); } pppoe_send_PADT(conn); @@ -149,13 +149,14 @@ static void disconnect(struct pppoe_conn_t *conn) mempool_free(conn); } -static void ppp_started(struct ppp_t *ppp) +static void ppp_started(struct ap_session *ses) { log_ppp_debug("pppoe: ppp started\n"); } -static void ppp_finished(struct ppp_t *ppp) +static void ppp_finished(struct ap_session *ses) { + struct ppp_t *ppp = container_of(ses, typeof(*ppp), ses); struct pppoe_conn_t *conn = container_of(ppp, typeof(*conn), ppp); log_ppp_debug("pppoe: ppp finished\n"); @@ -172,7 +173,7 @@ static void pppoe_conn_close(struct triton_context_t *ctx) struct pppoe_conn_t *conn = container_of(ctx, typeof(*conn), ctx); if (conn->ppp_started) - ppp_terminate(&conn->ppp, TERM_ADMIN_RESET, 0); + ap_session_terminate(&conn->ppp.ses, TERM_ADMIN_RESET, 0); else disconnect(conn); } @@ -261,6 +262,7 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui conn->ctrl.ctx = &conn->ctx; conn->ctrl.started = ppp_started; conn->ctrl.finished = ppp_finished; + conn->ctrl.terminate = ppp_terminate; conn->ctrl.max_mtu = MAX_PPPOE_MTU; conn->ctrl.type = CTRL_TYPE_PPPOE; conn->ctrl.name = "pppoe"; @@ -285,10 +287,10 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui ppp_init(&conn->ppp); - conn->ppp.ctrl = &conn->ctrl; - conn->ppp.chan_name = conn->ctrl.calling_station_id; + conn->ppp.ses.ctrl = &conn->ctrl; + conn->ppp.ses.chan_name = conn->ctrl.calling_station_id; - triton_context_register(&conn->ctx, &conn->ppp); + triton_context_register(&conn->ctx, &conn->ppp.ses); triton_context_wakeup(&conn->ctx); triton_event_fire(EV_CTRL_STARTING, &conn->ppp); @@ -334,7 +336,7 @@ static void connect_channel(struct pppoe_conn_t *conn) if (conn->tr101 && triton_module_loaded("radius")) { conn->radius.send_access_request = pppoe_rad_send_access_request; conn->radius.send_accounting_request = pppoe_rad_send_accounting_request; - rad_register_plugin(&conn->ppp, &conn->radius); + rad_register_plugin(&conn->ppp.ses, &conn->radius); } #endif @@ -704,7 +706,7 @@ static void pado_timer(struct triton_timer_t *t) { struct delayed_pado_t *pado = container_of(t, typeof(*pado), timer); - if (!ppp_shutdown) + if (!ap_shutdown) pppoe_send_PADO(pado->serv, pado->addr, pado->host_uniq, pado->relay_sid, pado->service_name); free_delayed_pado(pado); @@ -774,7 +776,7 @@ static void pppoe_recv_PADI(struct pppoe_serv_t *serv, uint8_t *pack, int size) __sync_add_and_fetch(&stat_PADI_recv, 1); - if (ppp_shutdown || pado_delay == -1) + if (ap_shutdown || pado_delay == -1) return; if (check_padi_limit(serv, ethhdr->h_source)) { @@ -886,7 +888,7 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size) __sync_add_and_fetch(&stat_PADR_recv, 1); - if (ppp_shutdown) + if (ap_shutdown) return; if (!memcmp(ethhdr->h_dest, bc_addr, ETH_ALEN)) { @@ -972,7 +974,7 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size) pthread_mutex_lock(&serv->lock); conn = find_channel(serv, (uint8_t *)ac_cookie_tag->tag_data); - if (conn && !conn->ppp.username) { + if (conn && !conn->ppp.ses.username) { __sync_add_and_fetch(&stat_PADR_dup_recv, 1); pppoe_send_PADS(conn); } @@ -1277,7 +1279,7 @@ out_err: static void _conn_stop(struct pppoe_conn_t *conn) { - ppp_terminate(&conn->ppp, TERM_ADMIN_RESET, 0); + ap_session_terminate(&conn->ppp.ses, TERM_ADMIN_RESET, 0); } static void _server_stop(struct pppoe_serv_t *serv) diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c index 2f0c5efd..59d50984 100644 --- a/accel-pppd/ctrl/pptp/pptp.c +++ b/accel-pppd/ctrl/pptp/pptp.c @@ -50,7 +50,7 @@ struct pptp_conn_t int out_size; int out_pos; - struct ppp_ctrl_t ctrl; + struct ap_ctrl ctrl; struct ppp_t ppp; }; @@ -68,8 +68,8 @@ static unsigned int stat_active; static int pptp_read(struct triton_md_handler_t *h); static int pptp_write(struct triton_md_handler_t *h); static void pptp_timeout(struct triton_timer_t *); -static void ppp_started(struct ppp_t *); -static void ppp_finished(struct ppp_t *); +static void ppp_started(struct ap_session *); +static void ppp_finished(struct ap_session *); static void disconnect(struct pptp_conn_t *conn) { @@ -87,7 +87,7 @@ static void disconnect(struct pptp_conn_t *conn) if (conn->state == STATE_PPP) { __sync_sub_and_fetch(&stat_active, 1); conn->state = STATE_CLOSE; - ppp_terminate(&conn->ppp, TERM_LOST_CARRIER, 1); + ap_session_terminate(&conn->ppp.ses, TERM_LOST_CARRIER, 1); } else if (conn->state != STATE_CLOSE) __sync_sub_and_fetch(&stat_starting, 1); @@ -97,8 +97,8 @@ static void disconnect(struct pptp_conn_t *conn) triton_context_unregister(&conn->ctx); - if (conn->ppp.chan_name) - _free(conn->ppp.chan_name); + if (conn->ppp.ses.chan_name) + _free(conn->ppp.ses.chan_name); _free(conn->in_buf); _free(conn->out_buf); @@ -325,7 +325,7 @@ static int pptp_out_call_rqst(struct pptp_conn_t *conn) conn->call_id = src_addr.sa_addr.pptp.call_id; conn->peer_call_id = msg->call_id; conn->ppp.fd = pptp_sock; - conn->ppp.chan_name = _strdup(inet_ntoa(dst_addr.sa_addr.pptp.sin_addr)); + conn->ppp.ses.chan_name = _strdup(inet_ntoa(dst_addr.sa_addr.pptp.sin_addr)); triton_event_fire(EV_CTRL_STARTED, &conn->ppp); @@ -379,7 +379,7 @@ static int pptp_call_clear_rqst(struct pptp_conn_t *conn) if (conn->state == STATE_PPP) { __sync_sub_and_fetch(&stat_active, 1); conn->state = STATE_CLOSE; - ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1); + ap_session_terminate(&conn->ppp.ses, TERM_USER_REQUEST, 1); } return send_pptp_call_disconnect_notify(conn, 4); @@ -561,7 +561,7 @@ static void pptp_close(struct triton_context_t *ctx) if (conn->state == STATE_PPP) { __sync_sub_and_fetch(&stat_active, 1); conn->state = STATE_CLOSE; - ppp_terminate(&conn->ppp, TERM_ADMIN_RESET, 1); + ap_session_terminate(&conn->ppp.ses, TERM_ADMIN_RESET, 1); if (send_pptp_call_disconnect_notify(conn, 3)) { triton_context_call(&conn->ctx, (void (*)(void*))disconnect, conn); return; @@ -578,12 +578,13 @@ static void pptp_close(struct triton_context_t *ctx) else triton_timer_add(ctx, &conn->timeout_timer, 0); } -static void ppp_started(struct ppp_t *ppp) +static void ppp_started(struct ap_session *ses) { log_ppp_debug("pptp: ppp started\n"); } -static void ppp_finished(struct ppp_t *ppp) +static void ppp_finished(struct ap_session *ses) { + struct ppp_t *ppp = container_of(ses, typeof(*ppp), ses); struct pptp_conn_t *conn = container_of(ppp, typeof(*conn), ppp); if (conn->state != STATE_CLOSE) { @@ -628,7 +629,7 @@ static int pptp_connect(struct triton_md_handler_t *h) continue; } - if (ppp_shutdown) { + if (ap_shutdown) { close(sock); continue; } @@ -667,6 +668,7 @@ static int pptp_connect(struct triton_md_handler_t *h) conn->ctrl.ctx = &conn->ctx; conn->ctrl.started = ppp_started; conn->ctrl.finished = ppp_finished; + conn->ctrl.terminate = ppp_terminate; conn->ctrl.max_mtu = PPTP_MAX_MTU; conn->ctrl.type = CTRL_TYPE_PPTP; conn->ctrl.name = "pptp"; @@ -679,9 +681,9 @@ static int pptp_connect(struct triton_md_handler_t *h) u_inet_ntoa(addr.sin_addr.s_addr, conn->ctrl.called_station_id); ppp_init(&conn->ppp); - conn->ppp.ctrl = &conn->ctrl; + conn->ppp.ses.ctrl = &conn->ctrl; - triton_context_register(&conn->ctx, &conn->ppp); + 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); triton_timer_add(&conn->ctx, &conn->timeout_timer, 0); |