summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-08-07 17:23:16 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2017-08-07 17:25:16 +0200
commit2515fb8c598ed5ede26f9f3cf4b42d662b531154 (patch)
tree959d7539f47bd791bf9d21ca57f95bed7fef61e5
parentc54a5f3d69c18b7b9cc236eca5b8ef8ad7481f34 (diff)
osmo-bsc: improve checking of sccp addresses
Use the check functionality of libosmo-sigtran to test if the sccp addresses are smantically correct.
-rw-r--r--openbsc/include/openbsc/bsc_msc_data.h1
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_sigtran.c20
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_vty.c22
3 files changed, 31 insertions, 12 deletions
diff --git a/openbsc/include/openbsc/bsc_msc_data.h b/openbsc/include/openbsc/bsc_msc_data.h
index 6d5ed9d5c..1ffe2a9c5 100644
--- a/openbsc/include/openbsc/bsc_msc_data.h
+++ b/openbsc/include/openbsc/bsc_msc_data.h
@@ -115,6 +115,7 @@ struct bsc_msc_data {
/* Sigtran connection data */
struct {
uint32_t cs7_instance;
+ bool cs7_instance_valid;
struct osmo_sccp_instance *sccp;
struct osmo_sccp_user *sccp_user;
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c b/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c
index 705a87fed..3d8aecd6f 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c
@@ -410,16 +410,6 @@ static void osmo_bsc_sigtran_reset_cb(const void *priv)
osmo_bsc_sigtran_tx_reset(msc);
}
-/* Check if a given sccp address fulfills minimum requirements */
-static int test_addr(const struct osmo_sccp_addr *addr)
-{
- if (!(addr->presence & OSMO_SCCP_ADDR_T_SSN))
- return -EINVAL;
- if (!(addr->presence & OSMO_SCCP_ADDR_T_PC))
- return -EINVAL;
-
- return 0;
-}
/* Initalize osmo sigtran backhaul */
int osmo_bsc_sigtran_init(struct llist_head *mscs)
@@ -439,14 +429,20 @@ int osmo_bsc_sigtran_init(struct llist_head *mscs)
LOGP(DMSC, LOGL_NOTICE, "Initializing SCCP connection to MSC %s (%s)\n",
osmo_sccp_addr_dump(&msc->a.msc_addr), msc_name);
+ /* Check if the VTY could determine a valid CS7 instance */
+ if (msc->a.cs7_instance_valid == false) {
+ LOGP(DMSC, LOGL_ERROR, "A-interface: Invalid CS7 instance\n");
+ return -EINVAL;
+ }
+
/* Check if the sccp-address fullfill minimum requirements (SSN+PC is present) */
- if (test_addr(&msc->a.bsc_addr) < 0) {
+ if (!osmo_sccp_check_addr(&msc->a.bsc_addr, OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC)) {
LOGP(DMSC, LOGL_ERROR,
"A-interface: invalid local SCCP address (a.bsc_addr=%s)\n",
osmo_sccp_addr_dump(&msc->a.bsc_addr));
return -EINVAL;
}
- if (test_addr(&msc->a.msc_addr) < 0) {
+ if (!osmo_sccp_check_addr(&msc->a.msc_addr, OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC)) {
LOGP(DMSC, LOGL_ERROR,
"A-interface: invalid remote SCCP address for the MSC (a.msc_addr=%s)\n",
osmo_sccp_addr_dump(&msc->a.msc_addr));
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
index d4a87a773..4d94af45e 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
@@ -726,7 +726,18 @@ DEFUN(cfg_msc_cs7_bsc_addr,
return CMD_WARNING;
}
+ /* Prevent mixing addresses from different CS7/SS7 instances */
+ if (msc->a.cs7_instance_valid) {
+ if (msc->a.cs7_instance != ss7->cfg.id) {
+ vty_out(vty,
+ "SCCP address %s from different CS7 instance%s",
+ bsc_addr_name, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
+
msc->a.cs7_instance = ss7->cfg.id;
+ msc->a.cs7_instance_valid = true;
enforce_standard_ssn(vty, &msc->a.bsc_addr);
return CMD_SUCCESS;
}
@@ -747,7 +758,18 @@ DEFUN(cfg_msc_cs7_msc_addr,
return CMD_WARNING;
}
+ /* Prevent mixing addresses from different CS7/SS7 instances */
+ if (msc->a.cs7_instance_valid) {
+ if (msc->a.cs7_instance != ss7->cfg.id) {
+ vty_out(vty,
+ "SCCP address %s from different CS7 instance%s",
+ msc_addr_name, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
+
msc->a.cs7_instance = ss7->cfg.id;
+ msc->a.cs7_instance_valid = true;
enforce_standard_ssn(vty, &msc->a.msc_addr);
return CMD_SUCCESS;
}