[MERGED] openbsc[master]: split subscr_con_allocate()/_free() in bsc_ and msc_

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Dec 2 12:09:18 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: split subscr_con_allocate()/_free() in bsc_ and msc_
......................................................................


split subscr_con_allocate()/_free() in bsc_ and msc_

Rename current subscr_con_allocate() and subscr_con_free to bsc_*,
and add two separate msc_subscr_con_allocate() and _free().
The msc_subscr_con_free() ignores all lchan members.

In libbsc use bsc_*, in libmsc use msc_*.

Change-Id: I3cf7c7cafdf4672ec7b26058bba8a77159855257
Future: there will be distinct subscr conns for libbsc and libmsc.
---
M openbsc/include/openbsc/gsm_data.h
M openbsc/src/libbsc/bsc_api.c
M openbsc/src/libmsc/gsm_04_08.c
M openbsc/src/libmsc/osmo_msc.c
M openbsc/src/osmo-bsc/osmo_bsc_api.c
M openbsc/src/osmo-bsc/osmo_bsc_bssap.c
M openbsc/src/osmo-bsc/osmo_bsc_sccp.c
7 files changed, 42 insertions(+), 13 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index f820ba3..04d1126 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -522,8 +522,11 @@
 int gsm_btsmodel_set_feature(struct gsm_bts_model *model, enum gsm_bts_features feat);
 int gsm_bts_model_register(struct gsm_bts_model *model);
 
-struct gsm_subscriber_connection *subscr_con_allocate(struct gsm_lchan *lchan);
-void subscr_con_free(struct gsm_subscriber_connection *conn);
+struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_lchan *lchan);
+void bsc_subscr_con_free(struct gsm_subscriber_connection *conn);
+
+struct gsm_subscriber_connection *msc_subscr_con_allocate(struct gsm_network *network);
+void msc_subscr_con_free(struct gsm_subscriber_connection *conn);
 
 struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net,
 					enum gsm_bts_type type,
diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c
index 207e12a..395002a 100644
--- a/openbsc/src/libbsc/bsc_api.c
+++ b/openbsc/src/libbsc/bsc_api.c
@@ -239,7 +239,7 @@
 	return 0;
 }
 
-struct gsm_subscriber_connection *subscr_con_allocate(struct gsm_lchan *lchan)
+struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_lchan *lchan)
 {
 	struct gsm_subscriber_connection *conn;
 	struct gsm_network *net = lchan->ts->trx->bts->network;
@@ -256,8 +256,7 @@
 	return conn;
 }
 
-/* TODO: move subscriber put here... */
-void subscr_con_free(struct gsm_subscriber_connection *conn)
+void bsc_subscr_con_free(struct gsm_subscriber_connection *conn)
 {
 	if (!conn)
 		return;
@@ -682,7 +681,7 @@
 	} else {
 		/* allocate a new connection */
 		rc = BSC_API_CONN_POL_REJECT;
-		lchan->conn = subscr_con_allocate(msg->lchan);
+		lchan->conn = bsc_subscr_con_allocate(msg->lchan);
 		if (!lchan->conn) {
 			lchan_release(lchan, 1, RSL_REL_NORMAL);
 			return -1;
@@ -693,7 +692,7 @@
 
 		if (rc != BSC_API_CONN_POL_ACCEPT) {
 			lchan->conn->lchan = NULL;
-			subscr_con_free(lchan->conn);
+			bsc_subscr_con_free(lchan->conn);
 			lchan_release(lchan, 1, RSL_REL_NORMAL);
 		}
 	}
@@ -852,7 +851,7 @@
 	gsm0808_clear(conn);
 
 	if (destruct)
-		subscr_con_free(conn);
+		bsc_subscr_con_free(conn);
 }
 
 static void handle_chan_ack(struct gsm_subscriber_connection *conn,
diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c
index d10f8cf..34492bb 100644
--- a/openbsc/src/libmsc/gsm_04_08.c
+++ b/openbsc/src/libmsc/gsm_04_08.c
@@ -3683,6 +3683,33 @@
 	return 0;
 }
 
+struct gsm_subscriber_connection *msc_subscr_con_allocate(struct gsm_network *network)
+{
+	struct gsm_subscriber_connection *conn;
+
+	conn = talloc_zero(network, struct gsm_subscriber_connection);
+	if (!conn)
+		return NULL;
+
+	conn->network = network;
+	llist_add_tail(&conn->entry, &network->subscr_conns);
+	return conn;
+}
+
+void msc_subscr_con_free(struct gsm_subscriber_connection *conn)
+{
+	if (!conn)
+		return;
+
+	if (conn->subscr) {
+		subscr_put(conn->subscr);
+		conn->subscr = NULL;
+	}
+
+	llist_del(&conn->entry);
+	talloc_free(conn);
+}
+
 /* Main entry point for GSM 04.08/44.008 Layer 3 data (e.g. from the BSC). */
 int gsm0408_dispatch(struct gsm_subscriber_connection *conn, struct msgb *msg)
 {
diff --git a/openbsc/src/libmsc/osmo_msc.c b/openbsc/src/libmsc/osmo_msc.c
index 604c100..12a5117 100644
--- a/openbsc/src/libmsc/osmo_msc.c
+++ b/openbsc/src/libmsc/osmo_msc.c
@@ -173,5 +173,5 @@
 
 	conn->in_release = 1;
 	gsm0808_clear(conn);
-	subscr_con_free(conn);
+	msc_subscr_con_free(conn);
 }
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c
index 7a3ef70..49e5796 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_api.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c
@@ -330,7 +330,7 @@
 	_conn->sccp_con = NULL;
 	if (complete_layer3(_conn, msg, msc) != BSC_API_CONN_POL_ACCEPT) {
 		gsm0808_clear(_conn);
-		subscr_con_free(_conn);
+		bsc_subscr_con_free(_conn);
 		return 1;
 	}
 
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c
index a60940d..f38c97f 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c
@@ -185,7 +185,7 @@
 	if (conn->conn) {
 		LOGP(DMSC, LOGL_INFO, "Releasing all transactions on %p\n", conn);
 		gsm0808_clear(conn->conn);
-		subscr_con_free(conn->conn);
+		bsc_subscr_con_free(conn->conn);
 		conn->conn = NULL;
 	}
 
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c
index 2fafed6..a571438 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c
@@ -84,7 +84,7 @@
 			LOGP(DMSC, LOGL_ERROR,
 				"ERROR: The lchan is still associated.\n");
 			gsm0808_clear(con_data->conn);
-			subscr_con_free(con_data->conn);
+			bsc_subscr_con_free(con_data->conn);
 			con_data->conn = NULL;
 		}
 
@@ -107,7 +107,7 @@
 {
 	if (data->conn) {
 		gsm0808_clear(data->conn);
-		subscr_con_free(data->conn);
+		bsc_subscr_con_free(data->conn);
 		data->conn = NULL;
 	}
 

-- 
To view, visit https://gerrit.osmocom.org/1139
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3cf7c7cafdf4672ec7b26058bba8a77159855257
Gerrit-PatchSet: 9
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list