[PATCH] osmo-msc[master]: unify allocation of gsm_subscriber_connection

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Apr 4 23:23:25 UTC 2018


Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/7616

to look at the new patch set (#2).

unify allocation of gsm_subscriber_connection

The current msc_subscr_con_allocate() was in fact only used by msc_vlr_tests,
while both a_iface_bssap.c and iucs.c did their own duplicate code of
allocating the gsm_subscriber_connection struct. Unify.

Drop the old msc_subscr_con_allocate(), instead add msc_subscr_conn_alloc().
The new function also takes via_ran and lac arguments directly.

The conn allocation will soon be closely tied to the subscr_conn_fsm instance
allocation, so place the new function definition alongside the other
subscr_conn_fsm API, and match its naming ("conn").

Related: OS#3122
Change-Id: Ia57b42a149a43f9c370b1310e2e1f512183993ea
---
M include/osmocom/msc/gsm_data.h
M include/osmocom/msc/osmo_msc.h
M src/libmsc/a_iface_bssap.c
M src/libmsc/iucs.c
M src/libmsc/subscr_conn.c
M tests/msc_vlr/msc_vlr_test_rest.c
M tests/msc_vlr/msc_vlr_tests.c
7 files changed, 27 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/16/7616/2

diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h
index 29abd5d..f3e1b94 100644
--- a/include/osmocom/msc/gsm_data.h
+++ b/include/osmocom/msc/gsm_data.h
@@ -374,7 +374,6 @@
 	char text[SMS_TEXT_SIZE];
 };
 
-struct gsm_subscriber_connection *msc_subscr_con_allocate(struct gsm_network *network);
 void msc_subscr_con_free(struct gsm_subscriber_connection *conn);
 
 /* control interface handling */
diff --git a/include/osmocom/msc/osmo_msc.h b/include/osmocom/msc/osmo_msc.h
index fb525e0..1334138 100644
--- a/include/osmocom/msc/osmo_msc.h
+++ b/include/osmocom/msc/osmo_msc.h
@@ -41,6 +41,9 @@
 	MSC_CONN_REJECT = 1,
 };
 
+struct gsm_subscriber_connection *msc_subscr_conn_alloc(struct gsm_network *network,
+							enum ran_type via_ran, uint16_t lac);
+
 void msc_subscr_conn_update_id(struct gsm_subscriber_connection *conn,
 			       enum complete_layer3_type from, const char *id);
 char *msc_subscr_conn_get_conn_id(struct gsm_subscriber_connection *conn);
diff --git a/src/libmsc/a_iface_bssap.c b/src/libmsc/a_iface_bssap.c
index 743814c..1665e23 100644
--- a/src/libmsc/a_iface_bssap.c
+++ b/src/libmsc/a_iface_bssap.c
@@ -54,13 +54,9 @@
 
 	LOGP(DMSC, LOGL_DEBUG, "Allocating A-Interface subscriber conn: lac %i, conn_id %i\n", lac, conn_id);
 
-	conn = talloc_zero(network, struct gsm_subscriber_connection);
+	conn = msc_subscr_conn_alloc(network, RAN_GERAN_A, lac);
 	if (!conn)
 		return NULL;
-
-	conn->network = network;
-	conn->via_ran = RAN_GERAN_A;
-	conn->lac = lac;
 
 	conn->a.conn_id = conn_id;
 	conn->a.scu = scu;
@@ -69,7 +65,6 @@
 	 * identify later which BSC is responsible for this subscriber connection */
 	memcpy(&conn->a.bsc_addr, &a_conn_info->bsc->bsc_addr, sizeof(conn->a.bsc_addr));
 
-	llist_add_tail(&conn->entry, &network->subscr_conns);
 	LOGPCONN(conn, LOGL_DEBUG, "A-Interface subscriber connection successfully allocated!\n");
 	return conn;
 }
diff --git a/src/libmsc/iucs.c b/src/libmsc/iucs.c
index d6da1f7..a3092f8 100644
--- a/src/libmsc/iucs.c
+++ b/src/libmsc/iucs.c
@@ -57,17 +57,12 @@
 	DEBUGP(DIUCS, "Allocating IuCS subscriber conn: lac %d, conn_id %" PRIx32 "\n",
 	       lac, ue->conn_id);
 
-	conn = talloc_zero(network, struct gsm_subscriber_connection);
+	conn = msc_subscr_conn_alloc(network, RAN_UTRAN_IU, lac);
 	if (!conn)
 		return NULL;
 
-	conn->network = network;
-	conn->via_ran = RAN_UTRAN_IU;
 	conn->iu.ue_ctx = ue;
 	conn->iu.ue_ctx->rab_assign_addr_enc = network->iu.rab_assign_addr_enc;
-	conn->lac = lac;
-
-	llist_add_tail(&conn->entry, &network->subscr_conns);
 	return conn;
 }
 
diff --git a/src/libmsc/subscr_conn.c b/src/libmsc/subscr_conn.c
index fc89a66..5629d26 100644
--- a/src/libmsc/subscr_conn.c
+++ b/src/libmsc/subscr_conn.c
@@ -369,6 +369,26 @@
 	osmo_fsm_register(&subscr_conn_fsm);
 }
 
+/* Allocate a new subscriber conn. */
+struct gsm_subscriber_connection *msc_subscr_conn_alloc(struct gsm_network *network,
+							enum ran_type via_ran, uint16_t lac)
+{
+	struct gsm_subscriber_connection *conn;
+
+	conn = talloc_zero(network, struct gsm_subscriber_connection);
+	if (!conn)
+		return NULL;
+
+	*conn = (struct gsm_subscriber_connection){
+		.network = network,
+		.via_ran = via_ran,
+		.lac = lac,
+	};
+
+	llist_add_tail(&conn->entry, &network->subscr_conns);
+	return conn;
+}
+
 const struct value_string complete_layer3_type_names[] = {
 	{ COMPLETE_LAYER3_NONE, "NONE" },
 	{ COMPLETE_LAYER3_LU, "LU" },
diff --git a/tests/msc_vlr/msc_vlr_test_rest.c b/tests/msc_vlr/msc_vlr_test_rest.c
index 3f843f0..7fd7bae 100644
--- a/tests/msc_vlr/msc_vlr_test_rest.c
+++ b/tests/msc_vlr/msc_vlr_test_rest.c
@@ -31,7 +31,7 @@
 	EXPECT_ACCEPTED(false);
 
 	btw("freshly allocated conn");
-	g_conn = msc_subscr_con_allocate(net);
+	g_conn = msc_subscr_conn_alloc(net, RAN_GERAN_A, 123);
 	EXPECT_ACCEPTED(false);
 
 	btw("conn_fsm present, in state NEW");
diff --git a/tests/msc_vlr/msc_vlr_tests.c b/tests/msc_vlr/msc_vlr_tests.c
index 523f74f..7c54057 100644
--- a/tests/msc_vlr/msc_vlr_tests.c
+++ b/tests/msc_vlr/msc_vlr_tests.c
@@ -191,9 +191,7 @@
 struct gsm_subscriber_connection *conn_new(void)
 {
 	struct gsm_subscriber_connection *conn;
-	conn = msc_subscr_con_allocate(net);
-	conn->via_ran = rx_from_ran;
-	conn->lac = 23;
+	conn = msc_subscr_conn_alloc(net, rx_from_ran, 23);
 	if (conn->via_ran == RAN_UTRAN_IU) {
 		struct ranap_ue_conn_ctx *ue_ctx = talloc_zero(conn, struct ranap_ue_conn_ctx);
 		*ue_ctx = (struct ranap_ue_conn_ctx){

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ia57b42a149a43f9c370b1310e2e1f512183993ea
Gerrit-PatchSet: 2
Gerrit-Project: osmo-msc
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