aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-06-30 13:28:03 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-07-12 23:42:47 +0200
commit67c7356ba5e7490554cf462d2f812eb41d845b56 (patch)
tree7e91084551e5454cf5a50dbee839d3ec68261150
parentddf27a54bdd4f8500819fe8324491d4d56708769 (diff)
osmo-msc: finish msc-sided reset
finish the implementation for msc sided reset, automatically register connecting BSCs. Ensure that all sccp connections are cleared when the reset procedure executes. Change-Id: Iba3f5523795c6972600bbfda2a02b06ba84ea12d
-rw-r--r--include/openbsc/a_iface.h38
-rw-r--r--include/openbsc/a_iface_bssap.h13
-rw-r--r--include/openbsc/gsm_data.h16
-rw-r--r--src/libcommon-cs/common_cs.c2
-rw-r--r--src/libmsc/a_iface.c214
-rw-r--r--src/libmsc/a_iface_bssap.c89
6 files changed, 280 insertions, 92 deletions
diff --git a/include/openbsc/a_iface.h b/include/openbsc/a_iface.h
index b27c3db8..4a9eaf62 100644
--- a/include/openbsc/a_iface.h
+++ b/include/openbsc/a_iface.h
@@ -18,6 +18,36 @@
*
*/
+#pragma once
+
+#include <openbsc/a_reset.h>
+
+/* A struct to keep a context information about the BSCs we are associated with */
+struct bsc_context {
+ struct llist_head list;
+
+ /* Holds a copy of the sccp address of the BSC,
+ * this address will become known as soon as
+ * a remote BSC tries to make a connection or
+ * sends a RESET request via UNIDATA */
+ struct osmo_sccp_addr bsc_addr;
+
+ /* Holds a copy of the our local MSC address,
+ * this will be the sccp-address that is associated
+ * with the A interface */
+ struct osmo_sccp_addr msc_addr;
+
+ /* A pointer to the reset handler FSM, the
+ * state machine is allocated when the BSC
+ * is registerd. */
+ struct a_reset_ctx *reset;
+
+ /* A pointer to the sccp_user that is associated
+ * with the A interface. We need this information
+ * to send the resets and to send paging requests */
+ struct osmo_sccp_user *sccp_user;
+};
+
/* Initalize A interface connection between to MSC and BSC */
int a_init(void *ctx, struct osmo_sccp_instance *sccp, struct gsm_network *network);
@@ -34,4 +64,10 @@ int a_iface_tx_paging(const char *imsi, uint32_t tmsi, uint16_t lac);
/* Send assignment request via A-interface */
int a_iface_tx_assignment(struct gsm_trans *trans);
-#pragma once
+/* Clear all subscriber connections on a specified BSC
+ * (Helper function for a_iface_bssap.c) */
+void a_clear_all(struct osmo_sccp_user *scu, struct osmo_sccp_addr *bsc_addr);
+
+/* Delete info of a closed connection from the active connection list
+ * (Helper function for a_iface_bssap.c) */
+void a_delete_bsc_con(uint32_t conn_id);
diff --git a/include/openbsc/a_iface_bssap.h b/include/openbsc/a_iface_bssap.h
index 211bcf2d..f0a2187e 100644
--- a/include/openbsc/a_iface_bssap.h
+++ b/include/openbsc/a_iface_bssap.h
@@ -28,16 +28,9 @@
struct a_conn_info {
struct osmo_sccp_addr *called_addr;
struct osmo_sccp_addr *calling_addr;
- int conn_id;
+ uint32_t conn_id;
struct gsm_network *network;
-};
-
-/* A structure to pack BSC calling addresses into a list */
-struct a_bsc_addr {
- struct llist_head list;
- struct osmo_sccp_addr called_addr;
- struct osmo_sccp_addr calling_addr;
- struct osmo_sccp_user *scu;
+ struct a_reset_ctx *reset;
};
/* Receive incoming connection less data messages via sccp */
@@ -46,5 +39,3 @@ void sccp_rx_udt(struct osmo_sccp_user *scu, struct a_conn_info *a_conn_info, st
/* Receive incoming connection oriented data messages via sccp */
int sccp_rx_dt(struct osmo_sccp_user *scu, struct a_conn_info *a_conn_info, struct msgb *msg);
-/* Get a list with all known BSCs */
-struct llist_head *get_bsc_addr_list(void);
diff --git a/include/openbsc/gsm_data.h b/include/openbsc/gsm_data.h
index 13178ae6..283b5498 100644
--- a/include/openbsc/gsm_data.h
+++ b/include/openbsc/gsm_data.h
@@ -209,8 +209,18 @@ struct gsm_subscriber_connection {
} iu;
struct {
+ /* A pointer to the SCCP user that handles
+ * the SCCP connections for this subscriber
+ * connection */
struct osmo_sccp_user *scu;
+
+ /* The address of the BSC that is associated
+ * with this subscirber connection */
struct osmo_sccp_addr bsc_addr;
+
+ /* The connection identifier that is used
+ * to reference the SCCP connection that is
+ * associated with this subscriber connection */
int conn_id;
} a;
};
@@ -482,6 +492,12 @@ struct gsm_network {
enum nsap_addr_enc rab_assign_addr_enc;
} iu;
+ struct {
+ /* A list with the context information about
+ * all BSCs we have connections with */
+ struct llist_head bscs;
+ } a;
+
struct osmo_sccp_instance *sccp;
};
diff --git a/src/libcommon-cs/common_cs.c b/src/libcommon-cs/common_cs.c
index d94381b4..ad3fb54b 100644
--- a/src/libcommon-cs/common_cs.c
+++ b/src/libcommon-cs/common_cs.c
@@ -79,6 +79,8 @@ struct gsm_network *gsm_network_init(void *ctx,
net->dyn_ts_allow_tch_f = true;
+ INIT_LLIST_HEAD(&net->a.bscs);
+
return net;
}
diff --git a/src/libmsc/a_iface.c b/src/libmsc/a_iface.c
index 869cd788..dcbb5aad 100644
--- a/src/libmsc/a_iface.c
+++ b/src/libmsc/a_iface.c
@@ -37,12 +37,94 @@
#include <openbsc/mgcpgw_client.h>
#include <osmocom/core/byteswap.h>
#include <osmocom/sccp/sccp_types.h>
+#include <openbsc/a_reset.h>
+#include <openbsc/osmo_msc.h>
/* A pointer to the GSM network we work with. By the current paradigm,
* there can only be one gsm_network per MSC. The pointer is set once
* when calling a_init() */
static struct gsm_network *gsm_network = NULL;
+/* A struct to track currently active connections. We need that information
+ * to handle failure sitautions. In case of a problem, we must know which
+ * connections are currently open and which BSC is responsible. We also need
+ * the data to perform our connection checks (a_reset). All other logic will
+ * look at the connection ids and addresses that are supplied by the
+ * primitives */
+struct bsc_conn {
+ struct llist_head list;
+ struct osmo_sccp_addr called_addr; /* BSC (remote) */
+ struct osmo_sccp_addr calling_addr; /* MSC (local) */
+ uint32_t conn_id; /* Connection identifier */
+};
+
+/* Internal list with connections we currently maintain. This
+ * list is of type struct bsc_conn (see above) */
+static LLIST_HEAD(active_connections);
+
+/* Record info of a new active connection in the active connection list */
+static void record_bsc_con(void *ctx, struct osmo_sccp_addr *called_addr, struct osmo_sccp_addr *calling_addr,
+ uint32_t conn_id)
+{
+ struct bsc_conn *conn;
+
+ conn = talloc_zero(ctx, struct bsc_conn);
+ OSMO_ASSERT(conn);
+
+ memcpy(&conn->called_addr, called_addr, sizeof(*called_addr));
+ memcpy(&conn->calling_addr, calling_addr, sizeof(*calling_addr));
+ conn->conn_id = conn_id;
+
+ llist_add_tail(&conn->list, &active_connections);
+}
+
+/* Delete info of a closed connection from the active connection list */
+void a_delete_bsc_con(uint32_t conn_id)
+{
+ struct bsc_conn *conn;
+ struct bsc_conn *conn_temp;
+
+ llist_for_each_entry_safe(conn, conn_temp, &active_connections, list) {
+ if (conn->conn_id == conn_id) {
+ llist_del(&conn->list);
+ talloc_free(conn);
+ }
+ }
+}
+
+/* Check if a specified connection id has an active SCCP connection */
+static bool check_connection_active(uint32_t conn_id)
+{
+ struct bsc_conn *conn;
+
+ /* Find the address for the current connection id */
+ llist_for_each_entry(conn, &active_connections, list) {
+ if (conn->conn_id == conn_id) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/* Get the reset context for a specifiec calling (BSC) address */
+static struct a_reset_ctx *get_reset_ctx_by_sccp_addr(struct osmo_sccp_addr *addr)
+{
+ struct bsc_context *bsc_ctx;
+
+ if (!addr)
+ return NULL;
+
+ llist_for_each_entry(bsc_ctx, &gsm_network->a.bscs, list) {
+ if (memcmp(&bsc_ctx->bsc_addr, addr, sizeof(*addr)) == 0)
+ return bsc_ctx->reset;
+ }
+
+ LOGP(DMSC, LOGL_ERROR, "The calling BSC (%s) is unknown to this MSC ...\n",
+ osmo_sccp_addr_dump(addr));
+ return NULL;
+}
+
/* Send DTAP message via A-interface */
int a_iface_tx_dtap(struct msgb *msg)
{
@@ -107,9 +189,9 @@ int a_iface_tx_cipher_mode(struct gsm_subscriber_connection *conn,
/* Page a subscriber via A-interface */
int a_iface_tx_paging(const char *imsi, uint32_t tmsi, uint16_t lac)
{
- struct a_bsc_addr *addr;
- struct llist_head *bsc_addr_list = get_bsc_addr_list();
+ struct bsc_context *bsc_ctx;
struct gsm0808_cell_id_list cil;
+ struct msgb *msg;
int page_count = 0;
cil.id_discr = CELL_IDENT_LAC;
@@ -117,16 +199,26 @@ int a_iface_tx_paging(const char *imsi, uint32_t tmsi, uint16_t lac)
cil.id_list_len = 1;
/* Deliver paging request to all known BSCs */
- llist_for_each_entry(addr, bsc_addr_list, list) {
- LOGP(DMSC, LOGL_DEBUG, "Passing paging message from MSC to BSC %s (imsi=%s, tmsi=0x%08x, lac=%u)\n",
- osmo_sccp_addr_dump(&addr->calling_addr), imsi, tmsi, lac);
- osmo_sccp_tx_unitdata_msg(addr->scu, &addr->called_addr, &addr->calling_addr,
- gsm0808_create_paging(imsi, &tmsi, &cil, NULL));
- page_count++;
+ llist_for_each_entry(bsc_ctx, &gsm_network->a.bscs, list) {
+ if (a_reset_conn_ready(bsc_ctx->reset)) {
+ LOGP(DMSC, LOGL_DEBUG,
+ "Passing paging message from MSC %s to BSC %s (imsi=%s, tmsi=0x%08x, lac=%u)\n",
+ osmo_sccp_addr_dump(&bsc_ctx->msc_addr),
+ osmo_sccp_addr_dump(&bsc_ctx->bsc_addr), imsi, tmsi, lac);
+ msg = gsm0808_create_paging(imsi, &tmsi, &cil, NULL);
+ osmo_sccp_tx_unitdata_msg(bsc_ctx->sccp_user,
+ &bsc_ctx->msc_addr, &bsc_ctx->bsc_addr, msg);
+ page_count++;
+ } else {
+ LOGP(DMSC, LOGL_DEBUG,
+ "Connection down, dropping paging from MSC %s to BSC %s (imsi=%s, tmsi=0x%08x, lac=%u)\n",
+ osmo_sccp_addr_dump(&bsc_ctx->msc_addr),
+ osmo_sccp_addr_dump(&bsc_ctx->bsc_addr), imsi, tmsi, lac);
+ }
}
if (page_count <= 0)
- LOGP(DMSC, LOGL_ERROR, "Could not deliver paging because no BSC is available!\n");
+ LOGP(DMSC, LOGL_ERROR, "Could not deliver paging because none of the associated BSCs is available!\n");
return page_count;
}
@@ -303,24 +395,51 @@ int a_iface_tx_assignment(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)
+/* Callback function: Close all open connections */
+static void a_reset_cb(void *priv)
{
- 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;
- }
- }
+ struct msgb *msg;
+ struct bsc_context *bsc_ctx = (struct bsc_context*) priv;
- LOGP(DMSC, LOGL_ERROR, "The calling BSC (%s) is unknown to this MSC, rejecting...\n",
- osmo_sccp_addr_dump(bsc_addr));
- return false;
+ /* Skip if the A interface is not properly initalized yet */
+ if (!gsm_network)
+ return;
+
+ /* Clear all now orphaned subscriber connections */
+ a_clear_all(bsc_ctx->sccp_user, &bsc_ctx->bsc_addr);
+
+ /* Send reset to the remote BSC */
+ LOGP(DMSC, LOGL_NOTICE, "Sending RESET to BSC %s\n", osmo_sccp_addr_dump(&bsc_ctx->bsc_addr));
+ msg = gsm0808_create_reset();
+ osmo_sccp_tx_unitdata_msg(bsc_ctx->sccp_user, &bsc_ctx->msc_addr,
+ &bsc_ctx->bsc_addr, msg);
+}
+
+/* Add a new BSC connection to our internal list with known BSCs */
+static void add_bsc(struct osmo_sccp_addr *msc_addr, struct osmo_sccp_addr *bsc_addr, struct osmo_sccp_user *scu)
+{
+ struct bsc_context *bsc_ctx;
+
+ OSMO_ASSERT(bsc_addr);
+ OSMO_ASSERT(msc_addr);
+ OSMO_ASSERT(scu);
+
+ /* Check if we already know this BSC, if yes, skip adding it. */
+ if (get_reset_ctx_by_sccp_addr(bsc_addr))
+ return;
+
+ LOGP(DMSC, LOGL_NOTICE, "Adding new BSC connection for BSC %s...\n", osmo_sccp_addr_dump(bsc_addr));
+
+ /* Generate and fill up a new bsc context */
+ bsc_ctx = talloc_zero(gsm_network, struct bsc_context);
+ OSMO_ASSERT(bsc_ctx);
+ memcpy(&bsc_ctx->bsc_addr, bsc_addr, sizeof(*bsc_addr));
+ memcpy(&bsc_ctx->msc_addr, msc_addr, sizeof(*msc_addr));
+ bsc_ctx->sccp_user = scu;
+ llist_add_tail(&bsc_ctx->list, &gsm_network->a.bscs);
+
+ /* Start reset procedure to make the new connection active */
+ bsc_ctx->reset = a_reset_alloc(bsc_ctx, osmo_sccp_addr_dump(bsc_addr), a_reset_cb, bsc_ctx);
}
/* Callback function, called by the SSCP stack when data arrives */
@@ -332,15 +451,18 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *_scu)
struct a_conn_info a_conn_info;
memset(&a_conn_info, 0, sizeof(a_conn_info));
a_conn_info.network = gsm_network;
+ a_conn_info.reset = NULL;
switch (OSMO_PRIM_HDR(&scu_prim->oph)) {
case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_INDICATION):
/* Handle inbound connection indication */
+ add_bsc(&scu_prim->u.connect.called_addr, &scu_prim->u.connect.calling_addr, 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;
+ a_conn_info.reset = get_reset_ctx_by_sccp_addr(&scu_prim->u.unitdata.calling_addr);
- if (test_bsc_known(a_conn_info.calling_addr) == false) {
+ if (a_reset_conn_ready(a_conn_info.reset) == false) {
rc = osmo_sccp_tx_disconn(scu, a_conn_info.conn_id, a_conn_info.called_addr,
SCCP_RETURN_CAUSE_UNQUALIFIED);
break;
@@ -353,6 +475,9 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *_scu)
rc = sccp_rx_dt(scu, &a_conn_info, oph->msg);
} else
LOGP(DMSC, LOGL_DEBUG, "N-CONNECT.ind(%u)\n", scu_prim->u.connect.conn_id);
+
+ record_bsc_con(scu, &scu_prim->u.connect.calling_addr, &scu_prim->u.connect.called_addr,
+ scu_prim->u.connect.conn_id);
break;
case OSMO_PRIM(OSMO_SCU_PRIM_N_DATA, PRIM_OP_INDICATION):
@@ -365,8 +490,10 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *_scu)
case OSMO_PRIM(OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_INDICATION):
/* Handle inbound UNITDATA */
+ add_bsc(&scu_prim->u.unitdata.called_addr, &scu_prim->u.unitdata.calling_addr, scu);
a_conn_info.called_addr = &scu_prim->u.unitdata.called_addr;
a_conn_info.calling_addr = &scu_prim->u.unitdata.calling_addr;
+ a_conn_info.reset = get_reset_ctx_by_sccp_addr(&scu_prim->u.unitdata.calling_addr);
DEBUGP(DMSC, "N-UNITDATA.ind(%s)\n", osmo_hexdump(msgb_l2(oph->msg), msgb_l2len(oph->msg)));
sccp_rx_udt(scu, &a_conn_info, oph->msg);
break;
@@ -379,13 +506,46 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *_scu)
return rc;
}
+/* Clear all subscriber connections on a specified BSC */
+void a_clear_all(struct osmo_sccp_user *scu, struct osmo_sccp_addr *bsc_addr)
+{
+ struct gsm_subscriber_connection *conn;
+ struct gsm_subscriber_connection *conn_temp;
+ struct gsm_network *network = gsm_network;
+
+ llist_for_each_entry_safe(conn, conn_temp, &network->subscr_conns, entry) {
+ /* Clear only A connections and connections that actually
+ * belong to the specified BSC */
+ if (conn->via_ran == RAN_GERAN_A && memcmp(bsc_addr, &conn->a.bsc_addr, sizeof(conn->a.bsc_addr)) == 0) {
+ LOGP(DMSC, LOGL_NOTICE, "Dropping orphaned subscriber connection (conn_id %i)\n",
+ conn->a.conn_id);
+ msc_clear_request(conn, GSM48_CC_CAUSE_SWITCH_CONG);
+
+ /* If there is still an SCCP connection active, remove it now */
+ if (check_connection_active(conn->a.conn_id)) {
+ osmo_sccp_tx_disconn(scu, conn->a.conn_id, bsc_addr,
+ SCCP_RELEASE_CAUSE_END_USER_ORIGINATED);
+ a_delete_bsc_con(conn->a.conn_id);
+ }
+ }
+ }
+}
+
/* Initalize A interface connection between to MSC and BSC */
int a_init(void *ctx, struct osmo_sccp_instance *sccp, struct gsm_network *network)
{
+ OSMO_ASSERT(sccp);
+ OSMO_ASSERT(network);
+
/* FIXME: Remove hardcoded parameters, use parameters in parameter list */
LOGP(DMSC, LOGL_NOTICE, "Initalizing SCCP connection to stp...\n");
- gsm_network = network;
+ /* Set GSM network variable, there can only be
+ * one network by design */
+ if (gsm_network != NULL) {
+ OSMO_ASSERT(gsm_network == network);
+ } else
+ gsm_network = network;
/* SCCP Protocol stack */
osmo_sccp_user_bind(sccp, "OsmoMSC-A", sccp_sap_up, SCCP_SSN_BSSAP);
diff --git a/src/libmsc/a_iface_bssap.c b/src/libmsc/a_iface_bssap.c
index cdddac7e..d00ad3f3 100644
--- a/src/libmsc/a_iface_bssap.c
+++ b/src/libmsc/a_iface_bssap.c
@@ -28,34 +28,35 @@
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/a_iface_bssap.h>
+#include <openbsc/a_iface.h>
#include <openbsc/iu.h>
#include <openbsc/osmo_msc.h>
#include <osmocom/core/byteswap.h>
+#include <openbsc/a_reset.h>
#define IP_V4_ADDR_LEN 4
-/* Addresses of all BSCs which have been registered to this MSC */
-static LLIST_HEAD(bsc_addr_list);
-
/*
* Helper functions to lookup and allocate subscribers
*/
/* Allocate a new subscriber connection */
static struct gsm_subscriber_connection *subscr_conn_allocate_a(struct a_conn_info *a_conn_info,
- struct gsm_network *network,
+ struct gsm_network *network, struct ue_conn_ctx *ue,
uint16_t lac, struct osmo_sccp_user *scu, int conn_id)
{
struct gsm_subscriber_connection *conn;
- LOGP(DMSC, LOGL_NOTICE, "Allocating A-Interface subscriber conn: lac %i, conn_id %i\n", lac, conn_id);
+ LOGP(DMSC, LOGL_NOTICE, "Allocating A-Interface subscriber conn: lac %i, conn_id %i\n", lac, ue->conn_id);
- conn = talloc_zero(network, struct gsm_subscriber_connection);
+ conn = talloc_zero(ue, struct gsm_subscriber_connection);
if (!conn)
return NULL;
conn->network = network;
conn->via_ran = RAN_GERAN_A;
+ conn->iu.ue_ctx = ue;
+ conn->iu.ue_ctx->rab_assign_addr_enc = network->iu.rab_assign_addr_enc;
conn->lac = lac;
conn->a.conn_id = conn_id;
@@ -92,22 +93,6 @@ struct gsm_subscriber_connection *subscr_conn_lookup_a(struct gsm_network *netwo
return NULL;
}
-/* Clear oprphand subscriber connections (called by bssmap_rx_reset()) */
-static void subscr_conn_clear_all(struct a_conn_info *a_conn_info)
-{
- struct gsm_subscriber_connection *conn;
- struct gsm_subscriber_connection *conn_temp;
- struct gsm_network *network = a_conn_info->network;
-
- llist_for_each_entry_safe(conn, conn_temp, &network->subscr_conns, entry) {
- if (conn->via_ran == RAN_GERAN_A
- && memcmp(a_conn_info->calling_addr, &conn->a.bsc_addr, sizeof(conn->a.bsc_addr)) == 0) {
- LOGP(DMSC, LOGL_NOTICE, "Dropping old subscriber connection (conn_id %i)\n", conn->a.conn_id);
- msc_clear_request(conn, GSM48_CC_CAUSE_SWITCH_CONG);
- }
- }
-}
-
/*
* BSSMAP handling for UNITDATA
*/
@@ -115,36 +100,32 @@ static void subscr_conn_clear_all(struct a_conn_info *a_conn_info)
/* Endpoint to handle BSSMAP reset */
static void bssmap_rx_reset(struct osmo_sccp_user *scu, struct a_conn_info *a_conn_info, struct msgb *msg)
{
- struct a_bsc_addr *addr;
- struct a_bsc_addr *known_addr;
- bool addr_unknown = true;
-
- LOGP(DMSC, LOGL_NOTICE, "Rx RESET from BSC %s\n", osmo_sccp_addr_dump(a_conn_info->calling_addr));
+ LOGP(DMSC, LOGL_NOTICE, "Rx RESET from BSC %s, sending RESET ACK\n", osmo_sccp_addr_dump(a_conn_info->calling_addr));
osmo_sccp_tx_unitdata_msg(scu, a_conn_info->called_addr, a_conn_info->calling_addr, gsm0808_create_reset_ack());
/* Make sure all orphand subscriber connections will be cleard */
- subscr_conn_clear_all(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) {
- 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);
- addr_unknown = false;
- break;
- }
+ a_clear_all(scu, a_conn_info->calling_addr);
+
+ msgb_free(msg);
+}
+
+/* Endpoint to handle BSSMAP reset acknowlegement */
+static void bssmap_rx_reset_ack(struct osmo_sccp_user *scu, struct a_conn_info *a_conn_info, struct msgb *msg)
+{
+ if (a_conn_info->reset == NULL) {
+ LOGP(DMSC, LOGL_ERROR, "Received RESET ACK from an unknown BSC %s, ignoring...\n",
+ osmo_sccp_addr_dump(a_conn_info->calling_addr));
+ goto fail;
}
- if (addr_unknown)
- LOGP(DMSC, LOGL_NOTICE, "This BSC is not known to this MSC yet, adding it to list\n");
- addr = talloc_zero(NULL, struct a_bsc_addr);
- memcpy(&addr->calling_addr, a_conn_info->calling_addr, sizeof(addr->calling_addr));
- memcpy(&addr->called_addr, a_conn_info->called_addr, sizeof(addr->called_addr));
- addr->scu = scu;
- llist_add(&addr->list, &bsc_addr_list);
+ LOGP(DMSC, LOGL_NOTICE, "Received RESET ACK from BSC %s\n",
+ osmo_sccp_addr_dump(a_conn_info->calling_addr));
+
+ /* Confirm that we managed to get the reset ack message
+ * towards the connection reset logic */
+ a_reset_ack_confirm(a_conn_info->reset);
+fail:
msgb_free(msg);
}
@@ -165,6 +146,9 @@ static void bssmap_rcvmsg_udt(struct osmo_sccp_user *scu, struct a_conn_info *a_
case BSS_MAP_MSG_RESET:
bssmap_rx_reset(scu, a_conn_info, msg);
break;
+ case BSS_MAP_MSG_RESET_ACKNOWLEDGE:
+ bssmap_rx_reset_ack(scu, a_conn_info, msg);
+ break;
default:
LOGP(DMSC, LOGL_NOTICE, "Unimplemented message format: %s -- message discarded!\n",
gsm0808_bssmap_name(msg->l3h[0]));
@@ -256,6 +240,9 @@ static int bssmap_rx_clear_complete(struct osmo_sccp_user *scu, struct a_conn_in
rc = osmo_sccp_tx_disconn(scu, a_conn_info->conn_id,
a_conn_info->called_addr, SCCP_RELEASE_CAUSE_END_USER_ORIGINATED);
+ /* Remove the record from the list with active connections. */
+ a_delete_bsc_con(a_conn_info->conn_id);
+
msgb_free(msg);
return rc;
}
@@ -277,6 +264,7 @@ static int bssmap_rx_l3_compl(struct osmo_sccp_user *scu, struct a_conn_info *a_
int rc;
struct gsm_network *network = a_conn_info->network;
+ struct ue_conn_ctx *ue;
struct gsm_subscriber_connection *conn;
LOGP(DMSC, LOGL_NOTICE, "BSC has completed layer 3 connection (conn_id=%i)\n", a_conn_info->conn_id);
@@ -320,7 +308,8 @@ static int bssmap_rx_l3_compl(struct osmo_sccp_user *scu, struct a_conn_info *a_
msg->tail = msg->l3h + TLVP_LEN(&tp, GSM0808_IE_LAYER_3_INFORMATION);
/* Create new subscriber context */
- conn = subscr_conn_allocate_a(a_conn_info, network, lac, scu, a_conn_info->conn_id);
+ ue = ue_conn_ctx_alloc(a_conn_info->calling_addr, a_conn_info->conn_id);
+ conn = subscr_conn_allocate_a(a_conn_info, network, ue, lac, scu, a_conn_info->conn_id);
/* Handover location update to the MSC code */
/* msc_compl_l3() takes ownership of dtap_msg
@@ -701,9 +690,3 @@ int sccp_rx_dt(struct osmo_sccp_user *scu, struct a_conn_info *a_conn_info, stru
return -EINVAL;
}
-
-/* Get a list with all known BSCs */
-struct llist_head *get_bsc_addr_list(void)
-{
- return &bsc_addr_list;
-}