Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Achou.Wang
accel-ppp
提交
aff9ec94
A
accel-ppp
项目概览
Achou.Wang
/
accel-ppp
通知
6
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
accel-ppp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aff9ec94
编写于
12月 19, 2010
作者:
D
Dmitry Kozlov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cli: shutdown cancel command
上级
e8507d40
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
64 addition
and
78 deletion
+64
-78
accel-pptpd/cli/std_cmd.c
accel-pptpd/cli/std_cmd.c
+8
-4
accel-pptpd/cli/telnet.c
accel-pptpd/cli/telnet.c
+12
-1
accel-pptpd/ctrl/l2tp/l2tp.c
accel-pptpd/ctrl/l2tp/l2tp.c
+19
-28
accel-pptpd/ctrl/pppoe/pppoe.c
accel-pptpd/ctrl/pppoe/pppoe.c
+3
-12
accel-pptpd/ctrl/pptp/pptp.c
accel-pptpd/ctrl/pptp/pptp.c
+4
-13
accel-pptpd/include/events.h
accel-pptpd/include/events.h
+0
-1
accel-pptpd/log.c
accel-pptpd/log.c
+1
-1
accel-pptpd/ppp/ppp.c
accel-pptpd/ppp/ppp.c
+2
-4
accel-pptpd/ppp/ppp.h
accel-pptpd/ppp/ppp.h
+4
-3
accel-pptpd/triton/triton.h
accel-pptpd/triton/triton.h
+11
-11
未找到文件。
accel-pptpd/cli/std_cmd.c
浏览文件 @
aff9ec94
...
...
@@ -299,10 +299,11 @@ static void terminate_help(char * const *fields, int fields_cnt, void *client)
static
void
shutdown_help
(
char
*
const
*
fields
,
int
fields_cnt
,
void
*
client
)
{
cli_send
(
client
,
"shutdown [soft|hard]- shutdown daemon
\r\n
"
);
cli_send
(
client
,
"shutdown [soft|hard
|cancel
]- shutdown daemon
\r\n
"
);
cli_send
(
client
,
"
\t\t
default action - send termination signals to all clients and wait everybody disconnects
\r\n
"
);
cli_send
(
client
,
"
\t\t
soft - wait until all clients disconnects, don't accept new connections
\r\n
"
);
cli_send
(
client
,
"
\t\t
hard - shutdown now, don't wait anything
\r\n
"
);
cli_send
(
client
,
"
\t\t
cancel - cancel 'shutdown soft' and return to normal operation
\r\n
"
);
}
static
int
shutdown_exec
(
const
char
*
cmd
,
char
*
const
*
f
,
int
f_cnt
,
void
*
cli
)
...
...
@@ -312,15 +313,18 @@ static int shutdown_exec(const char *cmd, char * const *f, int f_cnt, void *cli)
if
(
f_cnt
==
2
)
{
if
(
!
strcmp
(
f
[
1
],
"soft"
))
{
triton_event_fire
(
EV_SHUTDOWN_SOFT
,
NULL
);
ppp_shutdown_soft
(
);
return
CLI_CMD_OK
;
}
else
if
(
!
strcmp
(
f
[
1
],
"hard"
))
hard
=
1
;
else
else
if
(
!
strcmp
(
f
[
1
],
"cancel"
))
{
ppp_shutdown
=
0
;
return
CLI_CMD_OK
;
}
else
return
CLI_CMD_SYNTAX
;
}
triton_event_fire
(
EV_SHUTDOWN_SOFT
,
NULL
);
ppp_shutdown_soft
(
);
pthread_rwlock_rdlock
(
&
ppp_lock
);
list_for_each_entry
(
ppp
,
&
ppp_list
,
entry
)
{
...
...
accel-pptpd/cli/telnet.c
浏览文件 @
aff9ec94
...
...
@@ -14,6 +14,7 @@
#include "triton.h"
#include "log.h"
#include "ppp.h"
#include "list.h"
#include "memdebug.h"
...
...
@@ -166,7 +167,13 @@ static int cli_client_sendv(struct cli_client_t *tcln, const char *fmt, va_list
static
int
send_banner
(
struct
telnet_client_t
*
cln
)
{
return
telnet_send
(
cln
,
"accel-pptp version "
ACCEL_PPTP_VERSION
"
\r\n
"
,
sizeof
(
"accel-pptp version "
ACCEL_PPTP_VERSION
"
\r\n
"
));
if
(
telnet_send
(
cln
,
"accel-pptp version "
ACCEL_PPTP_VERSION
"
\r\n
"
,
sizeof
(
"accel-pptp version "
ACCEL_PPTP_VERSION
"
\r\n
"
)))
return
-
1
;
if
(
cln
->
auth
&&
ppp_shutdown
)
{
if
(
telnet_send
(
cln
,
"warning: 'shutdown soft' is in progress...
\r\n
"
,
sizeof
(
"warning: 'shutdown soft' is in progress...
\r\n
"
)))
return
-
1
;
}
return
0
;
}
static
int
send_config
(
struct
telnet_client_t
*
cln
)
...
...
@@ -262,6 +269,10 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c)
return
-
1
;
}
cln
->
auth
=
1
;
if
(
ppp_shutdown
)
{
if
(
telnet_send
(
cln
,
"warning: 'shutdown soft' is in progress...
\r\n
"
,
sizeof
(
"warning: 'shutdown soft' is in progress...
\r\n
"
)))
return
-
1
;
}
}
else
if
(
cln
->
cmdline_len
)
{
b
=
_malloc
(
sizeof
(
*
b
)
+
cln
->
cmdline_len
);
memcpy
(
b
->
buf
,
cln
->
cmdline
,
cln
->
cmdline_len
);
...
...
accel-pptpd/ctrl/l2tp/l2tp.c
浏览文件 @
aff9ec94
...
...
@@ -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
);
}
accel-pptpd/ctrl/pppoe/pppoe.c
浏览文件 @
aff9ec94
...
...
@@ -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
);
}
accel-pptpd/ctrl/pptp/pptp.c
浏览文件 @
aff9ec94
...
...
@@ -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
u
int32_
t
stat_starting
;
static
u
int32_
t
stat_active
;
static
u
nsigned
in
t
stat_starting
;
static
u
nsigned
in
t
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
);
}
accel-pptpd/include/events.h
浏览文件 @
aff9ec94
...
...
@@ -13,7 +13,6 @@
#define EV_CTRL_FINISHED 8
#define EV_PPP_PRE_UP 9
#define EV_PPP_ACCT_START 10
#define EV_SHUTDOWN_SOFT 11
#define EV_IP_CHANGED 100
#define EV_SHAPER 101
#define EV_MPPE_KEYS 102
...
...
accel-pptpd/log.c
浏览文件 @
aff9ec94
...
...
@@ -31,7 +31,7 @@ struct _log_msg_t
int
level
;
struct
timeval
timestamp
;
struct
list_head
chunks
;
u
int8_
t
refs
;
u
nsigned
in
t
refs
;
};
static
int
log_level
;
...
...
accel-pptpd/ppp/ppp.c
浏览文件 @
aff9ec94
...
...
@@ -32,7 +32,7 @@ __export LIST_HEAD(ppp_list);
static
LIST_HEAD
(
layers
);
int
__export
sock_fd
;
static
in
t
ppp_shutdown
;
int
__expor
t
ppp_shutdown
;
static
unsigned
long
long
seq
;
#if __WORDSIZE == 32
...
...
@@ -602,7 +602,7 @@ struct ppp_layer_data_t *ppp_find_layer_data(struct ppp_t *ppp, struct ppp_layer
return
NULL
;
}
static
void
ev
_shutdown_soft
(
void
)
void
ppp
_shutdown_soft
(
void
)
{
ppp_shutdown
=
1
;
...
...
@@ -659,8 +659,6 @@ static void __init init(void)
//log_emerg("ppp: failed to open seq-file (%s): %s\n", opt, strerror(errno));
seq
=
(
unsigned
long
long
)
random
()
*
(
unsigned
long
long
)
random
();
triton_event_register_handler
(
EV_SHUTDOWN_SOFT
,
(
triton_event_func
)
ev_shutdown_soft
);
atexit
(
save_seq
);
}
accel-pptpd/ppp/ppp.h
浏览文件 @
aff9ec94
...
...
@@ -147,9 +147,9 @@ struct ppp_handler_t
struct
ppp_stat_t
{
u
int32_
t
active
;
u
int32_
t
starting
;
u
int32_
t
finishing
;
u
nsigned
in
t
active
;
u
nsigned
in
t
starting
;
u
nsigned
in
t
finishing
;
};
struct
ppp_t
*
alloc_ppp
(
void
);
...
...
@@ -173,6 +173,7 @@ int ppp_register_layer(const char *name, struct ppp_layer_t *);
void
ppp_unregister_layer
(
struct
ppp_layer_t
*
);
struct
ppp_layer_data_t
*
ppp_find_layer_data
(
struct
ppp_t
*
,
struct
ppp_layer_t
*
);
extern
int
ppp_shutdown
;
void
ppp_shutdown_soft
(
void
);
extern
int
conf_ppp_verbose
;
...
...
accel-pptpd/triton/triton.h
浏览文件 @
aff9ec94
...
...
@@ -52,17 +52,17 @@ struct conf_sect_t
struct
triton_stat_t
{
u
int32_
t
mempool_allocated
;
u
int32_
t
mempool_available
;
u
int32_
t
thread_count
;
u
int32_
t
thread_active
;
u
int32_
t
context_count
;
u
int32_
t
context_sleeping
;
u
int32_
t
context_pending
;
u
int32_
t
md_handler_count
;
u
int32_
t
md_handler_pending
;
u
int32_
t
timer_count
;
u
int32_
t
timer_pending
;
u
nsigned
in
t
mempool_allocated
;
u
nsigned
in
t
mempool_available
;
u
nsigned
in
t
thread_count
;
u
nsigned
in
t
thread_active
;
u
nsigned
in
t
context_count
;
u
nsigned
in
t
context_sleeping
;
u
nsigned
in
t
context_pending
;
u
nsigned
in
t
md_handler_count
;
u
nsigned
in
t
md_handler_pending
;
u
nsigned
in
t
timer_count
;
u
nsigned
in
t
timer_pending
;
time_t
start_time
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录