aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-05-05 16:57:38 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-05-05 16:57:38 +0800
commit08db178271fe342771d6ac0a7ed65e44a500d772 (patch)
tree94553139b8a0f56e6ce0ba7578f774095d3ea0b8
parent936d8c1b6401a329744f5b926b7df87299af3b39 (diff)
nat: Make ping/pong timeout configurable.
-rw-r--r--openbsc/include/openbsc/bsc_nat.h5
-rw-r--r--openbsc/src/nat/bsc_nat.c9
-rw-r--r--openbsc/src/nat/bsc_nat_utils.c3
-rw-r--r--openbsc/src/nat/bsc_nat_vty.c33
4 files changed, 47 insertions, 3 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index d72e3b4ba..2d5e2287e 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -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 */
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index a60efd07c..b918e0931 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -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;
}
diff --git a/openbsc/src/nat/bsc_nat_utils.c b/openbsc/src/nat/bsc_nat_utils.c
index 1e51737f1..c608a7c2b 100644
--- a/openbsc/src/nat/bsc_nat_utils.c
+++ b/openbsc/src/nat/bsc_nat_utils.c
@@ -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;
}
diff --git a/openbsc/src/nat/bsc_nat_vty.c b/openbsc/src/nat/bsc_nat_vty.c
index e432325df..ff6a5ecc0 100644
--- a/openbsc/src/nat/bsc_nat_vty.c
+++ b/openbsc/src/nat/bsc_nat_vty.c
@@ -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);