aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-08-08 18:55:53 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2017-08-08 18:55:53 +0200
commite94d11925152eee995a89d5c5b03a4470693e8e6 (patch)
tree8c5cce0eaf76b1f621b0091babd24751b82f1abb
parent1e61f9e13cc6a80707aaab1d1ad86c2fe0f303ac (diff)
osmo-bsc: full auto configuration for SS7/CS7
If invalid addresses, or a missing CS7 instance is detected during startup, the BSC will assume safe defaults. The defaults picked are complementary to osmo-msc, so in case the user just wants to run the osmo-msc and osmo-bsc + the STP on one machine, no CS7 configuration is needed at all.
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_sigtran.c64
1 files changed, 44 insertions, 20 deletions
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c b/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c
index 3d8aecd6f..de9416df8 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c
@@ -40,6 +40,7 @@ static struct llist_head *msc_list;
#define RESET_INTERVAL 1 /* sek */
#define SCCP_MSG_MAXSIZE 1024
+#define CS7_POINTCODE_DEFAULT_OFFSET 2
/* Internal list with connections we currently maintain. This
* list is of type struct osmo_bsc_sccp_con */
@@ -410,18 +411,25 @@ static void osmo_bsc_sigtran_reset_cb(const void *priv)
osmo_bsc_sigtran_tx_reset(msc);
}
-
/* Initalize osmo sigtran backhaul */
int osmo_bsc_sigtran_init(struct llist_head *mscs)
{
/* FIXME: Remove hardcoded IP-Addresses */
struct bsc_msc_data *msc;
char msc_name[256];
+ uint32_t bsc_default_pc = CS7_POINTCODE_DEFAULT_OFFSET;
+ uint8_t cs7_default_inst = 0;
- OSMO_ASSERT(mscs);
+ /* 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 */
+ OSMO_ASSERT(mscs);
msc_list = mscs;
-
conn_id_counter = 0;
llist_for_each_entry(msc, msc_list, entry) {
@@ -431,40 +439,56 @@ int osmo_bsc_sigtran_init(struct llist_head *mscs)
/* 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;
+ 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;
}
+ cs7_default_inst++;
+
+ /* SS7 Protocol stack */
+ 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");
+ 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 fullfill 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)) {
- LOGP(DMSC, LOGL_ERROR,
- "A-interface: invalid local SCCP address (a.bsc_addr=%s)\n",
+ /* In case a valid address is not set, derive the address from the SCCP
+ * instance that has just been created */
+ 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));
+ 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));
- return -EINVAL;
}
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 remote SCCP address for the MSC (a.msc_addr=%s)\n",
+ "A-interface: invalid or missing remote SCCP address for the MSC (a.msc_addr=%s)\n",
+ osmo_sccp_addr_dump(&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;
+ LOGP(DMSC, LOGL_NOTICE,
+ "A-interface: using automatically generated SCCP address (a.msc_addr=%s)\n",
osmo_sccp_addr_dump(&msc->a.msc_addr));
- return -EINVAL;
}
- /* SS7 Protocol stack */
- msc->a.sccp =
- osmo_sccp_simple_client_on_ss7_id(msc, msc->a.cs7_instance, msc_name, msc->a.bsc_addr.pc,
- OSMO_SS7_ASP_PROT_M3UA, 0, NULL, M3UA_PORT, "127.0.0.1");
- if (!msc->a.sccp)
- return -EINVAL;
-
+ /* Bind SCCP user */
msc->a.sccp_user = osmo_sccp_user_bind(msc->a.sccp, msc_name, sccp_sap_up, msc->a.bsc_addr.ssn);
if (!msc->a.sccp_user)
return -EINVAL;
- /* Start MSC reset procedure */
+ /* Start MSC-Reset procedure */
msc->a.reset = a_reset_alloc(msc, msc_name, osmo_bsc_sigtran_reset_cb, msc);
if (!msc->a.reset)
return -EINVAL;
-
}
return 0;