summaryrefslogtreecommitdiff
path: root/accel-pptpd/ctrl/pppoe/pppoe.c
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-12-06 18:59:54 +0300
committerKozlov Dmitry <dima@server>2010-12-06 18:59:54 +0300
commitf73cb9f4457c40edf787efcf30ea80822381a732 (patch)
tree059752a75e0fd4847c386db73ffd295065c82516 /accel-pptpd/ctrl/pppoe/pppoe.c
parentdeecc72f6a96153d93dccd547177676bc878a3f3 (diff)
downloadaccel-ppp-f73cb9f4457c40edf787efcf30ea80822381a732.tar.gz
accel-ppp-f73cb9f4457c40edf787efcf30ea80822381a732.zip
cli: implemented shutdown command to shutdown daemon
Diffstat (limited to 'accel-pptpd/ctrl/pppoe/pppoe.c')
-rw-r--r--accel-pptpd/ctrl/pppoe/pppoe.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/accel-pptpd/ctrl/pppoe/pppoe.c b/accel-pptpd/ctrl/pppoe/pppoe.c
index b5a9189..57342ba 100644
--- a/accel-pptpd/ctrl/pppoe/pppoe.c
+++ b/accel-pptpd/ctrl/pppoe/pppoe.c
@@ -62,6 +62,8 @@ char *conf_ac_name;
int conf_pado_delay;
int conf_ifname_in_sid;
+static int shutdown_soft;
+
static mempool_t conn_pool;
static mempool_t pado_pool;
@@ -628,7 +630,8 @@ static void pado_timer(struct triton_timer_t *t)
{
struct delayed_pado_t *pado = container_of(t, typeof(*pado), timer);
- pppoe_send_PADO(pado->serv, pado->addr, pado->host_uniq, pado->relay_sid, pado->service_name);
+ if (!shutdown_soft)
+ pppoe_send_PADO(pado->serv, pado->addr, pado->host_uniq, pado->relay_sid, pado->service_name);
free_delayed_pado(pado);
}
@@ -644,6 +647,9 @@ static void pppoe_recv_PADI(struct pppoe_serv_t *serv, uint8_t *pack, int size)
int n, service_match = 0;
struct delayed_pado_t *pado;
+ if (shutdown_soft)
+ return;
+
if (hdr->sid) {
log_warn("pppoe: discarding PADI packet (sid is not zero)\n");
return;
@@ -737,6 +743,9 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size)
int n, service_match = 0;
struct pppoe_conn_t *conn;
+ if (shutdown_soft)
+ return;
+
if (!memcmp(ethhdr->h_dest, bc_addr, ETH_ALEN)) {
if (conf_verbose)
log_warn("pppoe: discard PADR (destination address is broadcast)\n");
@@ -1102,6 +1111,11 @@ static void _server_stop(struct pppoe_serv_t *serv)
pthread_mutex_unlock(&serv->lock);
}
+static void ev_shutdown_soft(void)
+{
+ shutdown_soft = 1;
+}
+
void pppoe_server_free(struct pppoe_serv_t *serv)
{
struct delayed_pado_t *pado;
@@ -1206,5 +1220,7 @@ static void __init pppoe_init(void)
if (!conf_ac_name)
conf_ac_name = _strdup("accel-pptp");
+
+ triton_event_register_handler(EV_SHUTDOWN_SOFT, (triton_event_func)ev_shutdown_soft);
}