[nat] Add option to forbid the paging to the BSC.

This can be done for testing purposes and to allow making
a BTS crash that can not handle paging requests properly.
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index 040d393..353cf08 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -146,6 +146,8 @@
 	char *imsi_deny;
 	regex_t imsi_deny_re;
 
+	int forbid_paging;
+
 	/* backpointer */
 	struct bsc_nat *nat;
 
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index eaa9d30..d5a5d2b 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -311,7 +311,9 @@
 	if (parsed->ipa_proto == IPAC_PROTO_SCCP && parsed->gsm_type == BSS_MAP_MSG_PAGING) {
 		int lac;
 		bsc = bsc_nat_find_bsc(nat, msg, &lac);
-		if (bsc)
+		if (bsc && bsc->cfg->forbid_paging)
+			LOGP(DNAT, LOGL_NOTICE, "Paging forbidden for BTS: %d\n", bsc->cfg->nr);
+		else if (bsc)
 			bsc_send_data(bsc, msg->l2h, msgb_l2len(msg), parsed->ipa_proto);
 		else
 			LOGP(DNAT, LOGL_ERROR, "Could not determine BSC for paging on lac: %d/0x%x\n",
diff --git a/openbsc/src/nat/bsc_nat_vty.c b/openbsc/src/nat/bsc_nat_vty.c
index a03b5d1..d8b6040 100644
--- a/openbsc/src/nat/bsc_nat_vty.c
+++ b/openbsc/src/nat/bsc_nat_vty.c
@@ -69,6 +69,7 @@
 		vty_out(vty, "   imsi allow %s%s", bsc->imsi_allow, VTY_NEWLINE);
 	if (bsc->imsi_deny)
 		vty_out(vty, "   imsi deny %s%s", bsc->imsi_deny, VTY_NEWLINE);
+	vty_out(vty, "  paging forbidden %d%s", bsc->forbid_paging, VTY_NEWLINE);
 }
 
 static int config_write_bsc(struct vty *vty)
@@ -128,6 +129,8 @@
 			conf->imsi_allow ? conf->imsi_allow: "any",
 			conf->imsi_deny  ? conf->imsi_deny : "none",
 			VTY_NEWLINE);
+		vty_out(vty, " paging forbidden: %d%s",
+			conf->forbid_paging, VTY_NEWLINE);
 	}
 
 	return CMD_SUCCESS;
@@ -315,6 +318,21 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_bsc_paging,
+      cfg_bsc_paging_cmd,
+      "paging forbidden (0|1)",
+      "Forbid sending PAGING REQUESTS to the BSC.")
+{
+	struct bsc_config *conf = vty->index;
+
+	if (strcmp("1", argv[1]) == 0)
+		conf->forbid_paging = 1;
+	else
+		conf->forbid_paging = 0;
+
+	return CMD_SUCCESS;
+}
+
 int bsc_nat_vty_init(struct bsc_nat *nat)
 {
 	_nat = nat;
@@ -347,6 +365,7 @@
 	install_element(BSC_NODE, &cfg_bsc_lac_cmd);
 	install_element(BSC_NODE, &cfg_bsc_imsi_allow_cmd);
 	install_element(BSC_NODE, &cfg_bsc_imsi_deny_cmd);
+	install_element(BSC_NODE, &cfg_bsc_paging_cmd);
 
 	mgcp_vty_init();