summaryrefslogtreecommitdiff
path: root/accel-pptpd/ctrl
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2010-12-19 10:35:14 +0300
committerDmitry Kozlov <xeb@mail.ru>2010-12-19 10:35:14 +0300
commitaff9ec94d82bb46235da0b4be1b2e5e9c9dafbc2 (patch)
treeabda301fed7d9851727e5fdd10d7635b6eb3d6cb /accel-pptpd/ctrl
parente8507d40aa9d55eb3af6196584bf3118d4f08050 (diff)
downloadaccel-ppp-aff9ec94d82bb46235da0b4be1b2e5e9c9dafbc2.tar.gz
accel-ppp-aff9ec94d82bb46235da0b4be1b2e5e9c9dafbc2.zip
cli: shutdown cancel command
Diffstat (limited to 'accel-pptpd/ctrl')
-rw-r--r--accel-pptpd/ctrl/l2tp/l2tp.c47
-rw-r--r--accel-pptpd/ctrl/pppoe/pppoe.c15
-rw-r--r--accel-pptpd/ctrl/pptp/pptp.c17
3 files changed, 26 insertions, 53 deletions
diff --git a/accel-pptpd/ctrl/l2tp/l2tp.c b/accel-pptpd/ctrl/l2tp/l2tp.c
index 2a48aa1..e5bc96e 100644
--- a/accel-pptpd/ctrl/l2tp/l2tp.c
+++ b/accel-pptpd/ctrl/l2tp/l2tp.c
@@ -50,10 +50,8 @@ int conf_retransmit = 5;
int conf_hello_interval = 60;
const char *conf_host_name = "accel-pptp";
-static int shutdown_soft;
-
-static uint32_t stat_active;
-static uint32_t stat_starting;
+static unsigned int stat_active;
+static unsigned int stat_starting;
struct l2tp_serv_t
{
@@ -640,7 +638,7 @@ static int l2tp_recv_SCCRQ(struct l2tp_serv_t *serv, struct l2tp_packet_t *pack)
struct l2tp_attr_t *framing_cap = NULL;
struct l2tp_attr_t *router_id = NULL;
- if (shutdown_soft)
+ if (ppp_shutdown)
return 0;
list_for_each_entry(attr, &pack->attrs, entry) {
@@ -1061,38 +1059,38 @@ static struct l2tp_serv_t udp_serv =
static void start_udp_server(void)
{
- struct sockaddr_in addr;
+ struct sockaddr_in addr;
char *opt;
udp_serv.hnd.fd = socket(PF_INET, SOCK_DGRAM, 0);
- if (udp_serv.hnd.fd < 0) {
- log_emerg("l2tp: socket: %s\n", strerror(errno));
- return;
- }
+ if (udp_serv.hnd.fd < 0) {
+ log_emerg("l2tp: socket: %s\n", strerror(errno));
+ return;
+ }
memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_port = htons(L2TP_PORT);
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(L2TP_PORT);
opt = conf_get_opt("l2tp", "bind");
if (opt)
addr.sin_addr.s_addr = inet_addr(opt);
else
addr.sin_addr.s_addr = htonl(INADDR_ANY);
-
- setsockopt(udp_serv.hnd.fd, SOL_SOCKET, SO_REUSEADDR, &udp_serv.hnd.fd, sizeof(udp_serv.hnd.fd));
- setsockopt(udp_serv.hnd.fd, SOL_SOCKET, SO_NO_CHECK, &udp_serv.hnd.fd, sizeof(udp_serv.hnd.fd));
- if (bind (udp_serv.hnd.fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
- log_emerg("l2tp: failed to bind socket: %s\n", strerror(errno));
+ setsockopt(udp_serv.hnd.fd, SOL_SOCKET, SO_REUSEADDR, &udp_serv.hnd.fd, sizeof(udp_serv.hnd.fd));
+ setsockopt(udp_serv.hnd.fd, SOL_SOCKET, SO_NO_CHECK, &udp_serv.hnd.fd, sizeof(udp_serv.hnd.fd));
+
+ if (bind (udp_serv.hnd.fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
+ log_emerg("l2tp: failed to bind socket: %s\n", strerror(errno));
close(udp_serv.hnd.fd);
- return;
- }
+ return;
+ }
if (fcntl(udp_serv.hnd.fd, F_SETFL, O_NONBLOCK)) {
- log_emerg("pptp: failed to set nonblocking mode: %s\n", strerror(errno));
+ log_emerg("pptp: failed to set nonblocking mode: %s\n", strerror(errno));
close(udp_serv.hnd.fd);
- return;
+ return;
}
memcpy(&udp_serv.addr, &addr, sizeof(addr));
@@ -1112,11 +1110,6 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt,
return CLI_CMD_OK;
}
-static void ev_shutdown_soft(void)
-{
- shutdown_soft = 1;
-}
-
static void __init l2tp_init(void)
{
char *opt;
@@ -1153,7 +1146,5 @@ static void __init l2tp_init(void)
start_udp_server();
cli_register_simple_cmd2(&show_stat_exec, NULL, 2, "show", "stat");
-
- triton_event_register_handler(EV_SHUTDOWN_SOFT, (triton_event_func)ev_shutdown_soft);
}
diff --git a/accel-pptpd/ctrl/pppoe/pppoe.c b/accel-pptpd/ctrl/pppoe/pppoe.c
index 89525bc..8d79ea9 100644
--- a/accel-pptpd/ctrl/pppoe/pppoe.c
+++ b/accel-pptpd/ctrl/pppoe/pppoe.c
@@ -62,8 +62,6 @@ char *conf_ac_name;
int conf_ifname_in_sid;
char *conf_pado_delay;
-static int shutdown_soft;
-
static mempool_t conn_pool;
static mempool_t pado_pool;
@@ -631,7 +629,7 @@ static void pado_timer(struct triton_timer_t *t)
{
struct delayed_pado_t *pado = container_of(t, typeof(*pado), timer);
- if (!shutdown_soft)
+ if (!ppp_shutdown)
pppoe_send_PADO(pado->serv, pado->addr, pado->host_uniq, pado->relay_sid, pado->service_name);
free_delayed_pado(pado);
@@ -648,7 +646,7 @@ 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 || pado_delay == -1)
+ if (ppp_shutdown || pado_delay == -1)
return;
if (hdr->sid) {
@@ -744,7 +742,7 @@ 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)
+ if (ppp_shutdown)
return;
if (!memcmp(ethhdr->h_dest, bc_addr, ETH_ALEN)) {
@@ -1112,11 +1110,6 @@ 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;
@@ -1221,7 +1214,5 @@ 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);
}
diff --git a/accel-pptpd/ctrl/pptp/pptp.c b/accel-pptpd/ctrl/pptp/pptp.c
index 887db37..c1513a0 100644
--- a/accel-pptpd/ctrl/pptp/pptp.c
+++ b/accel-pptpd/ctrl/pptp/pptp.c
@@ -56,12 +56,10 @@ static int conf_timeout = 5;
static int conf_echo_interval = 0;
static int conf_echo_failure = 3;
static int conf_verbose = 0;
-static int shutdown_soft;
-
static mempool_t conn_pool;
-static uint32_t stat_starting;
-static uint32_t stat_active;
+static unsigned int stat_starting;
+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);
@@ -618,7 +616,7 @@ static int pptp_connect(struct triton_md_handler_t *h)
continue;
}
- if (shutdown_soft) {
+ if (ppp_shutdown) {
close(sock);
continue;
}
@@ -700,14 +698,9 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt,
return CLI_CMD_OK;
}
-static void ev_shutdown_soft(void)
-{
- shutdown_soft = 1;
-}
-
static void __init pptp_init(void)
{
- struct sockaddr_in addr;
+ struct sockaddr_in addr;
char *opt;
serv.hnd.fd = socket(PF_INET, SOCK_STREAM, 0);
@@ -767,7 +760,5 @@ static void __init pptp_init(void)
triton_context_wakeup(&serv.ctx);
cli_register_simple_cmd2(show_stat_exec, NULL, 2, "show", "stat");
-
- triton_event_register_handler(EV_SHUTDOWN_SOFT, (triton_event_func)ev_shutdown_soft);
}