aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmsc/a_iface.c
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-06-06 14:31:36 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-07-12 23:42:46 +0200
commit615db796d3bc487dae3c74e3f25beb0b997c83f1 (patch)
treef6d0ba225d5b459d0fb2804c37b0d07a74f893de /src/libmsc/a_iface.c
parent813a230b551a88412981e738184b170a36168041 (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/a_iface.c')
-rw-r--r--src/libmsc/a_iface.c28
1 files changed, 28 insertions, 0 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",