From 8b0d8a97fb5cddb718c0b35af02bbcfe4599bdc5 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Tue, 6 Jun 2017 14:31:36 +0200 Subject: 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 --- openbsc/src/libmsc/a_iface.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'openbsc/src/libmsc/a_iface.c') diff --git a/openbsc/src/libmsc/a_iface.c b/openbsc/src/libmsc/a_iface.c index 9ff1b48f8..ffde21d85 100644 --- a/openbsc/src/libmsc/a_iface.c +++ b/openbsc/src/libmsc/a_iface.c @@ -36,6 +36,7 @@ #include #include #include +#include #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", -- cgit v1.2.3