aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-07-21 18:38:36 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2017-07-21 18:38:36 +0200
commitbce69325220f2af7cc0746611de30225263514d9 (patch)
tree7b60b6bb0e13ed07c4c18399ce721b61b740f16d
parent067fbaf92216e8ad8037e6d2e372476cbafb6cec (diff)
vty: Fixup sccp/ss7 configuration
The sccp/ss7 configuration is now fixed. The cs7 instance id is implicitly detected from the bsc_addr or the msc_addr. Depending on what is listed last. (I am not sure if that is wise, maybe we should only use the local/bsc address to do the lookup). Remove cs7-instance vty command Modify VTY commands, so that the fixed API is used Set msc->a.cs7_instance from the VTY to when msc/bsc addr is parsed Fix the initalization to use osmo_sccp_simple_client_on_ss7_id() and pass the cs7-instance id we determined from the vty. The whole thing is not waterproof yet. We are still not at the point where we allow to leave the local address out. This would be fine, but when it is left out, the only way to determine the cs7 instance is to use the msc_addr then. We also might want to make sure to reach a state where all cs7 related config may be left out (like with the MSC)
-rw-r--r--openbsc/include/openbsc/bsc_msc_data.h2
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_sigtran.c20
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_vty.c73
3 files changed, 32 insertions, 63 deletions
diff --git a/openbsc/include/openbsc/bsc_msc_data.h b/openbsc/include/openbsc/bsc_msc_data.h
index f5815171e..6d5ed9d5c 100644
--- a/openbsc/include/openbsc/bsc_msc_data.h
+++ b/openbsc/include/openbsc/bsc_msc_data.h
@@ -114,7 +114,7 @@ struct bsc_msc_data {
/* Sigtran connection data */
struct {
- struct osmo_ss7_instance *ss7;
+ uint32_t cs7_instance;
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 b5e394540..705a87fed 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_sigtran.c
@@ -439,28 +439,36 @@ 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 sccp-address */
+ /* Check if the sccp-address fullfill minimum requirements (SSN+PC is present) */
if (test_addr(&msc->a.bsc_addr) < 0) {
LOGP(DMSC, LOGL_ERROR,
- "A-interface: invalid local SCCP address (a.bsc_addr) %s\n",
+ "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) {
LOGP(DMSC, LOGL_ERROR,
- "A-interface: invalid remote SCCP address for the MSC (a.msc_addr) %s\n",
+ "A-interface: invalid remote SCCP address for the MSC (a.msc_addr=%s)\n",
osmo_sccp_addr_dump(&msc->a.msc_addr));
return -EINVAL;
}
- /* SCCP Protocol stack */
+ /* SS7 Protocol stack */
msc->a.sccp =
- osmo_sccp_simple_client(NULL, msc_name, msc->a.bsc_addr.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, msc->a.bsc_addr.pc,
+ OSMO_SS7_ASP_PROT_M3UA, 0, NULL, M3UA_PORT, "127.0.0.1");
+ if (!msc->a.sccp)
+ return -EINVAL;
+
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 */
msc->a.reset = a_reset_alloc(msc, msc_name, osmo_bsc_sigtran_reset_cb, msc);
+ if (!msc->a.reset)
+ return -EINVAL;
+
}
return 0;
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
index c0b25a69d..d4a87a773 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
@@ -187,16 +187,13 @@ static void write_msc(struct vty *vty, struct bsc_msc_data *msc)
write_msc_amr_options(vty, msc);
/* write sccp connection configuration */
- if (msc->a.ss7) {
- vty_out(vty, " cs7-instance %u%s", msc->a.ss7->cfg.id,
- VTY_NEWLINE);
- vty_out(vty, " bsc-addr %s%s",
- osmo_sccp_name_by_addr(&msc->a.bsc_addr,
- msc->a.ss7), VTY_NEWLINE);
- vty_out(vty, " msc-addr %s%s",
- osmo_sccp_name_by_addr(&msc->a.msc_addr,
- msc->a.ss7), VTY_NEWLINE);
- }
+ /* FIXME: This can not work, as we manipulate the address,
+ * we can not expect to find it in the addressbok. We should
+ * store the string names instead. */
+ vty_out(vty, " bsc-addr %s%s",
+ osmo_sccp_name_by_addr(&msc->a.bsc_addr), VTY_NEWLINE);
+ vty_out(vty, " msc-addr %s%s",
+ osmo_sccp_name_by_addr(&msc->a.msc_addr), VTY_NEWLINE);
}
static int config_write_msc(struct vty *vty)
@@ -698,26 +695,6 @@ DEFUN(cfg_msc_no_acc_lst_name,
return CMD_SUCCESS;
}
-DEFUN(cfg_msc_cs7_instance,
- cfg_msc_cs7_instance_cmd,
- "cs7-instance <0-15>",
- "Set Associated SS7 instance.\n" "SS7 instance reference number\n")
-{
- struct bsc_msc_data *msc = bsc_msc_data(vty);
- uint32_t inst_id = atoi(argv[0]);
- struct osmo_ss7_instance *inst;
-
- inst = osmo_ss7_instance_find(inst_id);
- if (!inst) {
- vty_out(vty, "No SS7 instance %d found%s", inst_id,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- msc->a.ss7 = inst;
- return CMD_SUCCESS;
-}
-
/* Make sure only standard SSN numbers are used. If no ssn number is
* configured, silently apply the default SSN */
static void enforce_standard_ssn(struct vty *vty, struct osmo_sccp_addr *addr)
@@ -740,24 +717,17 @@ DEFUN(cfg_msc_cs7_bsc_addr,
{
struct bsc_msc_data *msc = bsc_msc_data(vty);
const char *bsc_addr_name = argv[0];
- struct osmo_sccp_addr *bsc_addr;
+ struct osmo_ss7_instance *ss7;
- if (!msc->a.ss7) {
- vty_out(vty, "cs7-instance instance must be configured first%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- bsc_addr = osmo_sccp_addr_by_name(bsc_addr_name, msc->a.ss7);
- if (!bsc_addr) {
+ ss7 = osmo_sccp_addr_by_name(&msc->a.bsc_addr, bsc_addr_name);
+ if (!ss7) {
vty_out(vty, "No sccp address %s found%s", bsc_addr_name,
VTY_NEWLINE);
return CMD_WARNING;
}
- enforce_standard_ssn(vty, bsc_addr);
-
- memcpy(&msc->a.bsc_addr, bsc_addr, sizeof(*bsc_addr));
+ msc->a.cs7_instance = ss7->cfg.id;
+ enforce_standard_ssn(vty, &msc->a.bsc_addr);
return CMD_SUCCESS;
}
@@ -768,25 +738,17 @@ DEFUN(cfg_msc_cs7_msc_addr,
{
struct bsc_msc_data *msc = bsc_msc_data(vty);
const char *msc_addr_name = argv[0];
- struct osmo_sccp_addr *msc_addr;
+ struct osmo_ss7_instance *ss7;
- if (!msc->a.ss7) {
- vty_out(vty, "cs7-instance instance must be configured first%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- msc_addr = osmo_sccp_addr_by_name(msc_addr_name, msc->a.ss7);
- if (!msc_addr) {
+ ss7 = osmo_sccp_addr_by_name(&msc->a.msc_addr, msc_addr_name);
+ if (!ss7) {
vty_out(vty, "No sccp address %s found%s", msc_addr_name,
VTY_NEWLINE);
return CMD_WARNING;
}
- enforce_standard_ssn(vty, msc_addr);
-
- memcpy(&msc->a.msc_addr, msc_addr, sizeof(*msc_addr));
-
+ msc->a.cs7_instance = ss7->cfg.id;
+ enforce_standard_ssn(vty, &msc->a.msc_addr);
return CMD_SUCCESS;
}
@@ -1036,7 +998,6 @@ int bsc_vty_init_extra(void)
install_element(MSC_NODE, &cfg_net_msc_amr_4_75_cmd);
install_element(MSC_NODE, &cfg_msc_acc_lst_name_cmd);
install_element(MSC_NODE, &cfg_msc_no_acc_lst_name_cmd);
- install_element(MSC_NODE, &cfg_msc_cs7_instance_cmd);
install_element(MSC_NODE, &cfg_msc_cs7_bsc_addr_cmd);
install_element(MSC_NODE, &cfg_msc_cs7_msc_addr_cmd);