aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmsc
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-06-06 14:31:36 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-06-18 17:50:08 +0200
commit8b0d8a97fb5cddb718c0b35af02bbcfe4599bdc5 (patch)
treed81ce0f11db4ae55542fd702132f3b89c4b3cef8 /openbsc/src/libmsc
parentfabe468dd47ffd72a3ff2b6387422d304b178665 (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
Diffstat (limited to 'openbsc/src/libmsc')
-rw-r--r--openbsc/src/libmsc/a_iface.c28
-rw-r--r--openbsc/src/libmsc/a_iface_bssap.c3
2 files changed, 30 insertions, 1 deletions
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 <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/openbsc/src/libmsc/a_iface_bssap.c b/openbsc/src/libmsc/a_iface_bssap.c
index eafc4e418..9a0706d8a 100644
--- a/openbsc/src/libmsc/a_iface_bssap.c
+++ b/openbsc/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);