diff options
author | Daniel Willmann <dwillmann@sysmocom.de> | 2017-03-02 17:13:03 +0100 |
---|---|---|
committer | Daniel Willmann <dwillmann@sysmocom.de> | 2017-03-15 14:14:06 +0100 |
commit | b5b68f02f76d4663bac2b788a46424b866e816af (patch) | |
tree | ef4cacc3289fbf079724913b35781f3a65bbbec8 /openbsc | |
parent | 75152e662f0ace393505314b8b727a8cda6619b9 (diff) |
osmo-bsc_nat: Change the way bsc_nat_msc_is_connected() works
The function now takes a struct msc_config and returns true if that MSC is
connected. The vty command show msc connection now shows a line per connected
MSC.
In bsc_nat.c where osmo-bsc_nat previously hung up on a BSC connection if the
(one) MSC was not connected it now checks for the default MSC connection.
Change-Id: I95fbe1b8ad6621aba9b4bd6b581abfde0cb31fd0
Ticket: SYS#3208
Sponsored-by: On-Waves ehf.
Diffstat (limited to 'openbsc')
-rw-r--r-- | openbsc/include/openbsc/bsc_nat.h | 2 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_nat.c | 4 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 9 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 17 |
4 files changed, 19 insertions, 13 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index f6c1aaa9f..435c5f460 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -412,7 +412,7 @@ int bsc_do_write(struct osmo_wqueue *queue, struct msgb *msg, int id); int bsc_write_msg(struct osmo_wqueue *queue, struct msgb *msg); int bsc_write_cb(struct osmo_fd *bfd, struct msgb *msg); -int bsc_nat_msc_is_connected(struct bsc_nat *nat); +int bsc_nat_msc_is_connected(struct msc_config *msc_conf); int bsc_conn_type_to_ctr(struct nat_sccp_connection *conn); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index 7936e0dab..a987f304c 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -1374,6 +1374,7 @@ static int ipaccess_bsc_read_cb(struct osmo_fd *bfd) static int ipaccess_listen_bsc_cb(struct osmo_fd *bfd, unsigned int what) { struct bsc_connection *bsc; + struct msc_config *msc_conf; int fd, rc, on; struct sockaddr_in sa; socklen_t sa_len = sizeof(sa); @@ -1393,7 +1394,8 @@ static int ipaccess_listen_bsc_cb(struct osmo_fd *bfd, unsigned int what) /* * if we are not connected to a msc... just close the socket */ - if (!bsc_nat_msc_is_connected(nat)) { + msc_conf = msc_config_num(nat, nat->default_msc); + if (!msc_conf || !bsc_nat_msc_is_connected(msc_conf)) { LOGP(DNAT, LOGL_NOTICE, "Disconnecting BSC due lack of MSC connection.\n"); close(fd); return 0; diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c index bed5af66c..89655923b 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c @@ -521,13 +521,10 @@ const char *bsc_con_type_to_string(int type) return con_types[type]; } -int bsc_nat_msc_is_connected(struct bsc_nat *nat) +int bsc_nat_msc_is_connected(struct msc_config *msc_conf) { - struct msc_config *msc_conf; - llist_for_each_entry(msc_conf, &nat->msc_configs, entry) { - if (msc_conf->msc_con->is_connected) - return 1; - } + if (msc_conf->msc_con->is_connected) + return 1; return 0; } diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index 5d37b521e..4dba1f3fb 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -303,14 +303,17 @@ DEFUN(show_bsc_cfg, show_bsc_cfg_cmd, "show bsc config", static void dump_stat_total(struct vty *vty, struct bsc_nat *nat) { + struct msc_config *conf; vty_out(vty, "NAT statistics%s", VTY_NEWLINE); vty_out(vty, " SCCP Connections %lu total, %lu calls%s", osmo_counter_get(nat->stats.sccp.conn), osmo_counter_get(nat->stats.sccp.calls), VTY_NEWLINE); vty_out(vty, " MSC Connections %lu%s", osmo_counter_get(nat->stats.msc.reconn), VTY_NEWLINE); - vty_out(vty, " MSC Connected: %d%s", - bsc_nat_msc_is_connected(nat), VTY_NEWLINE); + llist_for_each_entry(conf, &_nat->msc_configs, entry) { + vty_out(vty, "MSC %i Connected: %d%s", conf->nr, + bsc_nat_msc_is_connected(conf), VTY_NEWLINE); + } vty_out(vty, " BSC Connections %lu total, %lu auth failed.%s", osmo_counter_get(nat->stats.bsc.reconn), osmo_counter_get(nat->stats.bsc.auth_fail), VTY_NEWLINE); @@ -385,13 +388,17 @@ DEFUN(show_msc, SHOW_STR "MSC related information\n" "Status of the A-link connection\n") { - if (!_nat->msc_con) { + struct msc_config *conf; + + if (llist_empty(&_nat->msc_configs)) { vty_out(vty, "The MSC is not yet configured.%s", VTY_NEWLINE); return CMD_WARNING; } - vty_out(vty, "MSC is connected: %d%s", - bsc_nat_msc_is_connected(_nat), VTY_NEWLINE); + llist_for_each_entry(conf, &_nat->msc_configs, entry) { + vty_out(vty, "MSC %i is connected: %d%s", conf->nr, + bsc_nat_msc_is_connected(conf), VTY_NEWLINE); + } return CMD_SUCCESS; } |