nat: Make ping/pong timeout configurable.
This commit is contained in:
parent
5078871611
commit
da35a8da7f
|
@ -214,6 +214,11 @@ struct bsc_nat {
|
|||
int msc_port;
|
||||
int first_contact;
|
||||
|
||||
/* timeouts */
|
||||
int auth_timeout;
|
||||
int ping_timeout;
|
||||
int pong_timeout;
|
||||
|
||||
struct bsc_endpoint *bsc_endpoints;
|
||||
|
||||
/* filter */
|
||||
|
|
|
@ -138,13 +138,16 @@ static void bsc_ping_timeout(void *_bsc)
|
|||
{
|
||||
struct bsc_connection *bsc = _bsc;
|
||||
|
||||
if (bsc->nat->ping_timeout < 0)
|
||||
return;
|
||||
|
||||
send_ping(bsc);
|
||||
|
||||
/* send another ping in 20 seconds */
|
||||
bsc_schedule_timer(&bsc->ping_timeout, 20, 0);
|
||||
bsc_schedule_timer(&bsc->ping_timeout, bsc->nat->ping_timeout, 0);
|
||||
|
||||
/* also start a pong timer */
|
||||
bsc_schedule_timer(&bsc->pong_timeout, 5, 0);
|
||||
bsc_schedule_timer(&bsc->pong_timeout, bsc->nat->pong_timeout, 0);
|
||||
}
|
||||
|
||||
static void start_ping_pong(struct bsc_connection *bsc)
|
||||
|
@ -772,7 +775,7 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
|
|||
*/
|
||||
bsc->id_timeout.data = bsc;
|
||||
bsc->id_timeout.cb = ipaccess_close_bsc;
|
||||
bsc_schedule_timer(&bsc->id_timeout, 2, 0);
|
||||
bsc_schedule_timer(&bsc->id_timeout, nat->auth_timeout, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ struct bsc_nat *bsc_nat_alloc(void)
|
|||
nat->stats.msc.reconn = counter_alloc("nat.msc.conn");
|
||||
nat->msc_ip = talloc_strdup(nat, "127.0.0.1");
|
||||
nat->msc_port = 5000;
|
||||
nat->auth_timeout = 2;
|
||||
nat->ping_timeout = 20;
|
||||
nat->pong_timeout = 5;
|
||||
return nat;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,9 @@ static int config_write_nat(struct vty *vty)
|
|||
vty_out(vty, " insi deny %s%s", _nat->imsi_deny, VTY_NEWLINE);
|
||||
vty_out(vty, " msc ip %s%s", _nat->msc_ip, VTY_NEWLINE);
|
||||
vty_out(vty, " msc port %d%s", _nat->msc_port, VTY_NEWLINE);
|
||||
vty_out(vty, " timeout auth %d%s", _nat->auth_timeout, VTY_NEWLINE);
|
||||
vty_out(vty, " timeout ping %d%s", _nat->ping_timeout, VTY_NEWLINE);
|
||||
vty_out(vty, " timeout pong %d%s", _nat->pong_timeout, VTY_NEWLINE);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -256,6 +259,33 @@ DEFUN(cfg_nat_msc_port,
|
|||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_nat_auth_time,
|
||||
cfg_nat_auth_time_cmd,
|
||||
"timeout auth <1-256>",
|
||||
"The time to wait for an auth response.")
|
||||
{
|
||||
_nat->auth_timeout = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_nat_ping_time,
|
||||
cfg_nat_ping_time_cmd,
|
||||
"timeout ping NR",
|
||||
"Send a ping every NR seconds. Negative to disable.")
|
||||
{
|
||||
_nat->ping_timeout = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_nat_pong_time,
|
||||
cfg_nat_pong_time_cmd,
|
||||
"timeout pong NR",
|
||||
"Wait NR seconds for the PONG response. Should be smaller than ping.")
|
||||
{
|
||||
_nat->pong_timeout = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* per BSC configuration */
|
||||
DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", "Select a BSC to configure")
|
||||
{
|
||||
|
@ -387,6 +417,9 @@ int bsc_nat_vty_init(struct bsc_nat *nat)
|
|||
install_element(NAT_NODE, &cfg_nat_imsi_deny_cmd);
|
||||
install_element(NAT_NODE, &cfg_nat_msc_ip_cmd);
|
||||
install_element(NAT_NODE, &cfg_nat_msc_port_cmd);
|
||||
install_element(NAT_NODE, &cfg_nat_auth_time_cmd);
|
||||
install_element(NAT_NODE, &cfg_nat_ping_time_cmd);
|
||||
install_element(NAT_NODE, &cfg_nat_pong_time_cmd);
|
||||
|
||||
/* BSC subgroups */
|
||||
install_element(NAT_NODE, &cfg_bsc_cmd);
|
||||
|
|
Loading…
Reference in New Issue