diff options
author | Philipp Maier <pmaier@sysmocom.de> | 2017-06-06 14:31:36 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2017-07-25 15:14:13 +0200 |
commit | 88e9ecbfb5e8c8f0438bf6569975ebd407a0fb2f (patch) | |
tree | 6eacf29366a2893091f9146929d81c9aa3c7f81c /src/libmsc | |
parent | 3386a8791e71d2c55c4e1e42e3aabc01b007d3a2 (diff) |
osmo-bsc: Handle RESET/RESET-ACK properly
Improve the way the BSC executes its RESET/RESET-ACK sequence.
Currently only a simple bool variable serves as a state holder.
We set this variable to true when we receive the RESET-ACK
message. Unfortunately no further checking is done. This
patch replaces the old mechanism with a more elaborated
implementation which also detects a loss of the connection
and makes sure to reconnect properly afterwards. Also the
all open connections are closed on connection loss
Change-Id: I876319b15103cc395e74597a52ce4d1a934915f4
Diffstat (limited to 'src/libmsc')
-rw-r--r-- | src/libmsc/a_iface.c | 28 | ||||
-rw-r--r-- | src/libmsc/a_iface_bssap.c | 3 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/libmsc/a_iface.c b/src/libmsc/a_iface.c index 9ff1b48f8..ffde21d85 100644 --- a/src/libmsc/a_iface.c +++ b/src/libmsc/a_iface.c @@ -36,6 +36,7 @@ #include <openbsc/transaction.h> #include <openbsc/mgcpgw_client.h> #include <osmocom/core/byteswap.h> +#include <osmocom/sccp/sccp_types.h> #define SSN_BSSAP 254 /* SCCP_SSN_BSSAP */ #define SENDER_PC 1 /* Our local point code */ @@ -292,6 +293,26 @@ int a_assign(struct gsm_trans *trans) return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg); } +/* Check if we already know this BSC from a successfuly executed reset procedure. */ +static bool test_bsc_known(struct osmo_sccp_addr *bsc_addr) +{ + struct a_bsc_addr *addr; + struct llist_head *bsc_addr_list = get_bsc_addr_list(); + + /* Check if the given address is */ + llist_for_each_entry(addr, bsc_addr_list, list) { + if (memcmp(&addr->calling_addr, bsc_addr, sizeof(*bsc_addr)) == 0) { + LOGP(DMSC, LOGL_ERROR, "The calling BSC (%s) is known by this MSC, proceeding...\n", + osmo_sccp_addr_dump(bsc_addr)); + return true; + } + } + + LOGP(DMSC, LOGL_ERROR, "The calling BSC (%s) is unknown to this MSC, rejecting...\n", + osmo_sccp_addr_dump(bsc_addr)); + return false; +} + /* Callback function, called by the SSCP stack when data arrives */ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *_scu) { @@ -308,6 +329,13 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *_scu) a_conn_info.conn_id = scu_prim->u.connect.conn_id; a_conn_info.called_addr = &scu_prim->u.connect.called_addr; a_conn_info.calling_addr = &scu_prim->u.connect.calling_addr; + + if (test_bsc_known(a_conn_info.calling_addr) == false) { + rc = osmo_sccp_tx_disconn(scu, a_conn_info.conn_id, a_conn_info.called_addr, + SCCP_RETURN_CAUSE_UNQUALIFIED); + break; + } + osmo_sccp_tx_conn_resp(scu, scu_prim->u.connect.conn_id, &scu_prim->u.connect.called_addr, NULL, 0); if (msgb_l2len(oph->msg) > 0) { LOGP(DMSC, LOGL_DEBUG, "N-CONNECT.ind(%u, %s)\n", diff --git a/src/libmsc/a_iface_bssap.c b/src/libmsc/a_iface_bssap.c index eafc4e418..9a0706d8a 100644 --- a/src/libmsc/a_iface_bssap.c +++ b/src/libmsc/a_iface_bssap.c @@ -105,7 +105,8 @@ static void bssmap_handle_reset(struct osmo_sccp_user *scu, struct a_conn_info * /* Check if we know this BSC already, if yes, refresh its item */ llist_for_each_entry(known_addr, &bsc_addr_list, list) { - if (memcmp(&known_addr->calling_addr, a_conn_info->calling_addr, sizeof(*a_conn_info->calling_addr)) == 0) { + if (memcmp(&known_addr->calling_addr, a_conn_info->calling_addr, sizeof(*a_conn_info->calling_addr)) == + 0) { LOGP(DMSC, LOGL_NOTICE, "This BSC is already known to this MSC, refreshing its list item\n"); llist_del(&known_addr->list); talloc_free(known_addr); |