aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-08-11 13:59:29 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-08-23 02:08:36 +0200
commit400ae8088643b32caeba05a51bc95ccb80f13f89 (patch)
tree437c65095533bde3f204b8d309f3f41148d28dda
parenta277769b657ad2065f8625626e0f81842f7e91b3 (diff)
osmo-bsc: cleanup osmo_bsc_sigtran_init()
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_sigtran.c115
1 files changed, 76 insertions, 39 deletions
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c b/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c
index de9416df8..2007689d8 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c
@@ -411,73 +411,92 @@ static void osmo_bsc_sigtran_reset_cb(const void *priv)
osmo_bsc_sigtran_tx_reset(msc);
}
+/* Default point-code to be used as local address (BSC) */
+#define BSC_DEFAULT_PC "0.23.3"
+
+/* Default point-code to be used as remote address (MSC) */
+#define MSC_DEFAULT_PC "0.23.1"
+
/* Initalize osmo sigtran backhaul */
int osmo_bsc_sigtran_init(struct llist_head *mscs)
{
- /* FIXME: Remove hardcoded IP-Addresses */
+ bool free_attempt_used = false;
+ bool fail_on_next_invalid_cfg = false;
+
struct bsc_msc_data *msc;
- char msc_name[256];
- uint32_t bsc_default_pc = CS7_POINTCODE_DEFAULT_OFFSET;
- uint8_t cs7_default_inst = 0;
-
- /* FIXME: The way this code derives the default parameters is not safe when
- * mixing proper configuration with incomplete configuration. When multiple
- * MSCs are connected, the autogenerated pointcodes may colide with the
- * ones that are properly set. However, this is a very unlikely situation.
- * in most cases it will be exactly one MSC<->BSC connection and either no
- * configuration done by the user or the user knows how to properly set
- * up the configuration */
+ char msc_name[32];
+ uint32_t default_pc;
OSMO_ASSERT(mscs);
msc_list = mscs;
- conn_id_counter = 0;
llist_for_each_entry(msc, msc_list, entry) {
snprintf(msc_name, sizeof(msc_name), "msc-%u", msc->nr);
- LOGP(DMSC, LOGL_NOTICE, "Initializing SCCP connection to MSC %s (%s)\n",
- osmo_sccp_addr_dump(&msc->a.msc_addr), msc_name);
+ LOGP(DMSC, LOGL_NOTICE, "Initializing SCCP connection to MSC %s\n", msc_name);
- /* Check if the VTY could determine a valid CS7 instance */
+ /* Check if the VTY could determine a valid CS7 instance,
+ * use safe default in case none is set */
if (msc->a.cs7_instance_valid == false) {
- LOGP(DMSC, LOGL_NOTICE,
- "A-interface: Unable to detect CS7 instance, assuming instance ID: %u\n",
- cs7_default_inst);
- msc->a.cs7_instance = cs7_default_inst;
+ msc->a.cs7_instance = 0;
+ if (fail_on_next_invalid_cfg)
+ goto fail_auto_cofiguration;
+ free_attempt_used = true;
+ }
+ LOGP(DMSC, LOGL_NOTICE, "CS7 Instance identifier, A-Interface: %u\n", msc->a.cs7_instance);
+
+ /* Pre-Check if there is an ss7 instance present */
+ if (osmo_ss7_instance_find(msc->a.cs7_instance) == NULL) {
+ if (fail_on_next_invalid_cfg)
+ goto fail_auto_cofiguration;
+ free_attempt_used = true;
}
- cs7_default_inst++;
/* SS7 Protocol stack */
+ default_pc = osmo_ss7_pointcode_parse(NULL, BSC_DEFAULT_PC);
msc->a.sccp =
- osmo_sccp_simple_client_on_ss7_id(msc, msc->a.cs7_instance, msc_name, bsc_default_pc,
- OSMO_SS7_ASP_PROT_M3UA, 0, NULL, M3UA_PORT, "127.0.0.1");
+ osmo_sccp_simple_client_on_ss7_id(msc, msc->a.cs7_instance, msc_name, default_pc,
+ OSMO_SS7_ASP_PROT_M3UA, 0, NULL, 0, NULL);
if (!msc->a.sccp)
return -EINVAL;
- bsc_default_pc++;
- /* Check if the sccp-address fullfill minimum requirements (SSN+PC is present,
+ /* Check if the sccp-address fullfills minimum requirements (SSN+PC is present,
* automatically recover addresses if the addresses are not set up properly) */
if (!osmo_sccp_check_addr(&msc->a.bsc_addr, OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC)) {
- /* In case a valid address is not set, derive the address from the SCCP
- * instance that has just been created */
+ if (fail_on_next_invalid_cfg)
+ goto fail_auto_cofiguration;
+ free_attempt_used = true;
+
LOGP(DMSC, LOGL_NOTICE,
- "A-interface: invalid or missing local SCCP address (a.bsc_addr=%s)\n",
- osmo_sccp_addr_dump(&msc->a.bsc_addr));
+ "A-interface: invalid or missing local (BSC) SCCP address (a.bsc_addr=%s)\n",
+ osmo_sccp_addr_name(osmo_ss7_instance_find(msc->a.cs7_instance), &msc->a.bsc_addr));
osmo_sccp_local_addr_by_instance(&msc->a.bsc_addr, msc->a.sccp, SCCP_SSN_BSSAP);
LOGP(DMSC, LOGL_NOTICE,
- "A-interface: using automatically generated SCCP address (a.bsc_addr=%s)\n",
- osmo_sccp_addr_dump(&msc->a.bsc_addr));
+ "A-interface: using automatically generated local (BSC) SCCP address (a.bsc_addr=%s)\n",
+ osmo_sccp_addr_name(osmo_ss7_instance_find(msc->a.cs7_instance), &msc->a.bsc_addr));
+ } else {
+ LOGP(DMSC, LOGL_NOTICE,
+ "A-interface: using local (BSC) automatically SCCP address (a.msc_addr=%s)\n",
+ osmo_sccp_addr_name(osmo_ss7_instance_find(msc->a.cs7_instance), &msc->a.bsc_addr));
}
+
if (!osmo_sccp_check_addr(&msc->a.msc_addr, OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC)) {
- /* In case a valid address is not set, use the SCCP instance to query a local
- * address and subtract one from the pointcode */
- LOGP(DMSC, LOGL_ERROR,
- "A-interface: invalid or missing remote SCCP address for the MSC (a.msc_addr=%s)\n",
- osmo_sccp_addr_dump(&msc->a.msc_addr));
+ if (fail_on_next_invalid_cfg)
+ goto fail_auto_cofiguration;
+ free_attempt_used = true;
+
+ LOGP(DMSC, LOGL_NOTICE,
+ "A-interface: invalid or missing remote (MSC) SCCP address for the MSC (a.msc_addr=%s)\n",
+ osmo_sccp_addr_name(osmo_ss7_instance_find(msc->a.cs7_instance), &msc->a.msc_addr));
osmo_sccp_local_addr_by_instance(&msc->a.msc_addr, msc->a.sccp, SCCP_SSN_BSSAP);
- msc->a.msc_addr.pc -= 1;
+ msc->a.msc_addr.pc = osmo_ss7_pointcode_parse(NULL, MSC_DEFAULT_PC);
LOGP(DMSC, LOGL_NOTICE,
- "A-interface: using automatically generated SCCP address (a.msc_addr=%s)\n",
- osmo_sccp_addr_dump(&msc->a.msc_addr));
+ "A-interface: using automatically generated remote (MSC) SCCP address (a.msc_addr=%s)\n",
+ osmo_sccp_addr_name(osmo_ss7_instance_find(msc->a.cs7_instance), &msc->a.msc_addr));
+ free_attempt_used = true;
+ } else {
+ LOGP(DMSC, LOGL_NOTICE,
+ "A-interface: using remote (MSC) automatically SCCP address (a.msc_addr=%s)\n",
+ osmo_sccp_addr_name(osmo_ss7_instance_find(msc->a.cs7_instance), &msc->a.msc_addr));
}
/* Bind SCCP user */
@@ -489,7 +508,25 @@ int osmo_bsc_sigtran_init(struct llist_head *mscs)
msc->a.reset = a_reset_alloc(msc, msc_name, osmo_bsc_sigtran_reset_cb, msc);
if (!msc->a.reset)
return -EINVAL;
+
+ /* If we have detected that the SS7 configuration of the MSC we have just initalized
+ * was incomplete or completely missing, we can not tolerate another incomplete
+ * configuration. The reson for this is that we do only specify exactly one default
+ * pointcode pair. We also specify localhost as default IP-Address. If we have wanted
+ * to support multiple MSCs with automatic configuration we would be forced to invent
+ * a complex ruleset how to allocate the pointcodes and respective IP-Addresses.
+ * Furthermore, the situation where a single BSC is connected to multiple MSCs
+ * is a very rare situation anyway. In this case we expect the user to experienced
+ * enough to create a valid SS7/CS7 VTY configuration that does not lack any
+ * components */
+ if (free_attempt_used)
+ fail_on_next_invalid_cfg = true;
}
return 0;
+
+fail_auto_cofiguration:
+ LOGP(DMSC, LOGL_ERROR,
+ "A-interface: More than one invalid/inclomplete configuration detected, unable to revover - check config file!\n");
+ return -EINVAL;
}