bsc: Allow to disable sending ping/pong to the MSC

Some switches do not like to receive the IPA PING/PONG messages.
Allow to disable the handling with "no timeout-ping" and create
test cases that verify the switching between the modes. Change the
code to trat <= 0 as an invalid timeout.

Fixes: SYS#713
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
index ed4b05e..4d5a55d 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
@@ -110,12 +110,17 @@
 		vty_out(vty, " core-mobile-country-code %d%s",
 			msc->core_mcc, VTY_NEWLINE);
 	vty_out(vty, " ip.access rtp-base %d%s", msc->rtp_base, VTY_NEWLINE);
-	vty_out(vty, " timeout-ping %d%s", msc->ping_timeout, VTY_NEWLINE);
-	vty_out(vty, " timeout-pong %d%s", msc->pong_timeout, VTY_NEWLINE);
-	if (msc->advanced_ping)
-		vty_out(vty, " timeout-ping advanced%s", VTY_NEWLINE);
-	else
-		vty_out(vty, " no timeout-ping advanced%s", VTY_NEWLINE);
+
+	if (msc->ping_timeout == -1)
+		vty_out(vty, " no timeout-ping%s", VTY_NEWLINE);
+	else {
+		vty_out(vty, " timeout-ping %d%s", msc->ping_timeout, VTY_NEWLINE);
+		vty_out(vty, " timeout-pong %d%s", msc->pong_timeout, VTY_NEWLINE);
+		if (msc->advanced_ping)
+			vty_out(vty, " timeout-ping advanced%s", VTY_NEWLINE);
+		else
+			vty_out(vty, " no timeout-ping advanced%s", VTY_NEWLINE);
+	}
 
 	if (msc->ussd_welcome_txt)
 		vty_out(vty, " bsc-welcome-text %s%s", msc->ussd_welcome_txt, VTY_NEWLINE);
@@ -355,6 +360,16 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_net_msc_no_ping_time,
+      cfg_net_msc_no_ping_time_cmd,
+      "no timeout-ping",
+      NO_STR "Disable the ping/pong handling on A-link\n")
+{
+	struct osmo_msc_data *data = osmo_msc_data(vty);
+	data->ping_timeout = -1;
+	return CMD_SUCCESS;
+}
+
 DEFUN(cfg_net_msc_ping_time,
       cfg_net_msc_ping_time_cmd,
       "timeout-ping <1-2147483647>",
@@ -382,6 +397,13 @@
       "Ping timeout handling\nEnable advanced mode during SCCP\n")
 {
 	struct osmo_msc_data *data = osmo_msc_data(vty);
+
+	if (data->ping_timeout == -1) {
+		vty_out(vty, "%%ping handling is disabled. Enable it first.%s",
+			VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
 	data->advanced_ping = 1;
 	return CMD_SUCCESS;
 }
@@ -741,6 +763,7 @@
 	install_element(MSC_NODE, &cfg_net_bsc_codec_list_cmd);
 	install_element(MSC_NODE, &cfg_net_msc_dest_cmd);
 	install_element(MSC_NODE, &cfg_net_msc_no_dest_cmd);
+	install_element(MSC_NODE, &cfg_net_msc_no_ping_time_cmd);
 	install_element(MSC_NODE, &cfg_net_msc_ping_time_cmd);
 	install_element(MSC_NODE, &cfg_net_msc_pong_time_cmd);
 	install_element(MSC_NODE, &cfg_net_msc_advanced_ping_cmd);