[MERGED] osmo-iuh[master]: cosmetic: move callers' common switch() into rua_to_scu()

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
Thu Jul 6 13:53:19 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

Change subject: cosmetic: move callers' common switch() into rua_to_scu()
......................................................................


cosmetic: move callers' common switch() into rua_to_scu()

Change-Id: If6274e3738dc04646d0dc18332c12237e6910d18
---
M src/hnbgw_rua.c
1 file changed, 25 insertions(+), 57 deletions(-)

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



diff --git a/src/hnbgw_rua.c b/src/hnbgw_rua.c
index 47d33f0..6190fd0 100644
--- a/src/hnbgw_rua.c
+++ b/src/hnbgw_rua.c
@@ -37,6 +37,7 @@
 #include <osmocom/rua/rua_common.h>
 #include <osmocom/rua/rua_ies_defs.h>
 #include <osmocom/iuh/context_map.h>
+#include <osmocom/hnbap/CN-DomainIndicator.h>
 
 static int hnbgw_rua_tx(struct hnb_context *ctx, struct msgb *msg)
 {
@@ -159,16 +160,31 @@
 
 
 
-/* forward a RUA message to the SCCP User API to SCCP/SUA */
-static int rua_to_scu(struct hnb_context *hnb, struct hnbgw_cnlink *cn,
+/* forward a RUA message to the SCCP User API to SCCP */
+static int rua_to_scu(struct hnb_context *hnb,
+		      CN_DomainIndicator_t cN_DomainIndicator,
 		      enum osmo_scu_prim_type type,
 		      uint32_t context_id, uint32_t cause,
 		      const uint8_t *data, unsigned int len)
 {
-	struct msgb *msg = msgb_alloc(1500, "rua_to_sua");
+	struct msgb *msg;
 	struct osmo_scu_prim *prim;
 	struct hnbgw_context_map *map;
+	struct hnbgw_cnlink *cn;
 	int rc;
+
+	switch (cN_DomainIndicator) {
+	case RUA_CN_DomainIndicator_cs_domain:
+		cn = hnb->gw->cnlink_cs;
+		break;
+	case RUA_CN_DomainIndicator_ps_domain:
+		cn = hnb->gw->cnlink_ps;
+		break;
+	default:
+		LOGP(DRUA, LOGL_ERROR, "Unsupported Domain %u\n",
+		     cN_DomainIndicator);
+		return -1;
+	}
 
 	if (!cn) {
 		DEBUGP(DRUA, "CN=NULL, discarding message\n");
@@ -280,7 +296,6 @@
 {
 	RUA_ConnectIEs_t ies;
 	struct hnb_context *hnb = msg->dst;
-	struct hnbgw_cnlink *cn;
 	uint32_t context_id;
 	int rc;
 
@@ -290,26 +305,11 @@
 
 	context_id = asn1bitstr_to_u24(&ies.context_ID);
 
-	/* route to CS (MSC) or PS (SGSN) domain */
-	switch (ies.cN_DomainIndicator) {
-	case RUA_CN_DomainIndicator_cs_domain:
-		cn = hnb->gw->cnlink_cs;
-		break;
-	case RUA_CN_DomainIndicator_ps_domain:
-		cn = hnb->gw->cnlink_ps;
-		break;
-	default:
-		LOGP(DRUA, LOGL_ERROR, "Unsupported Domain %u\n",
-			ies.cN_DomainIndicator);
-		rua_free_connecties(&ies);
-		return -1;
-	}
-
 	DEBUGP(DRUA, "RUA Connect.req(ctx=0x%x, %s)\n", context_id,
 		ies.establishment_Cause == RUA_Establishment_Cause_emergency_call
 		? "emergency" : "normal");
 
-	rc = rua_to_scu(hnb, cn, OSMO_SCU_PRIM_N_CONNECT,
+	rc = rua_to_scu(hnb, ies.cN_DomainIndicator, OSMO_SCU_PRIM_N_CONNECT,
 			context_id, 0, ies.ranaP_Message.buf,
 			ies.ranaP_Message.size);
 	/* FIXME: what to do with the asn1c-allocated memory */
@@ -322,7 +322,6 @@
 {
 	RUA_DisconnectIEs_t ies;
 	struct hnb_context *hnb = msg->dst;
-	struct hnbgw_cnlink *cn;
 	uint32_t context_id;
 	uint32_t scu_cause;
 	uint8_t *ranap_data = NULL;
@@ -339,30 +338,15 @@
 	DEBUGP(DRUA, "RUA Disconnect.req(ctx=0x%x,cause=%s)\n", context_id,
 		rua_cause_str(&ies.cause));
 
-	/* route to CS (MSC) or PS (SGSN) domain */
-	switch (ies.cN_DomainIndicator) {
-	case RUA_CN_DomainIndicator_cs_domain:
-		cn = hnb->gw->cnlink_cs;
-		break;
-	case RUA_CN_DomainIndicator_ps_domain:
-		cn = hnb->gw->cnlink_ps;
-		break;
-	default:
-		LOGP(DRUA, LOGL_ERROR, "Invalid CN_DomainIndicator: %l\n",
-		     ies.cN_DomainIndicator);
-		rc = -1;
-		goto error_free;
-	}
-
 	if (ies.presenceMask & DISCONNECTIES_RUA_RANAP_MESSAGE_PRESENT) {
 		ranap_data = ies.ranaP_Message.buf;
 		ranap_len = ies.ranaP_Message.size;
 	}
 
-	rc = rua_to_scu(hnb, cn, OSMO_SCU_PRIM_N_DISCONNECT,
+	rc = rua_to_scu(hnb, ies.cN_DomainIndicator,
+			OSMO_SCU_PRIM_N_DISCONNECT,
 			context_id, scu_cause, ranap_data, ranap_len);
 
-error_free:
 	/* FIXME: what to do with the asn1c-allocated memory */
 	rua_free_disconnecties(&ies);
 
@@ -373,7 +357,6 @@
 {
 	RUA_DirectTransferIEs_t ies;
 	struct hnb_context *hnb = msg->dst;
-	struct hnbgw_cnlink *cn;
 	uint32_t context_id;
 	int rc;
 
@@ -385,31 +368,16 @@
 
 	DEBUGP(DRUA, "RUA Data.req(ctx=0x%x)\n", context_id);
 
-	/* route to CS (MSC) or PS (SGSN) domain */
-	switch (ies.cN_DomainIndicator) {
-	case RUA_CN_DomainIndicator_cs_domain:
-		cn = hnb->gw->cnlink_cs;
-		break;
-	case RUA_CN_DomainIndicator_ps_domain:
-		cn = hnb->gw->cnlink_ps;
-		break;
-	default:
-		LOGP(DRUA, LOGL_ERROR, "Invalid CN_DomainIndicator: %l\n",
-		     ies.cN_DomainIndicator);
-		rc = -1;
-		goto error_free;
-	}
-
-	rc = rua_to_scu(hnb, cn, OSMO_SCU_PRIM_N_DATA,
+	rc = rua_to_scu(hnb,
+			ies.cN_DomainIndicator,
+			OSMO_SCU_PRIM_N_DATA,
 			context_id, 0, ies.ranaP_Message.buf,
 			ies.ranaP_Message.size);
 
-error_free:
 	/* FIXME: what to do with the asn1c-allocated memory */
 	rua_free_directtransferies(&ies);
 
 	return rc;
-
 }
 
 static int rua_rx_init_udt(struct msgb *msg, ANY_t *in)

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

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



More information about the gerrit-log mailing list