Change in osmo-hlr[master]: add osmo_gsup_msgb_alloc()

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

osmith gerrit-no-reply at lists.osmocom.org
Mon Nov 25 13:02:02 UTC 2019


osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/15915 )

Change subject: add osmo_gsup_msgb_alloc()
......................................................................

add osmo_gsup_msgb_alloc()

Throughout osmo-hlr's code, the GSUP msgb allocation is duplicated as:

  msgb_alloc_headroom(1024+16, 16, "foo");

Instead, use one common function to keep the magic numbers in one place.

Change-Id: I40e99b5bc4fd8f750da7643c03b2119ac3bfd95e
---
M include/osmocom/hlr/gsup_server.h
M src/gsup_server.c
M src/hlr.c
M src/hlr_ussd.c
M src/luop.c
5 files changed, 17 insertions(+), 14 deletions(-)

Approvals:
  Jenkins Builder: Verified
  osmith: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved



diff --git a/include/osmocom/hlr/gsup_server.h b/include/osmocom/hlr/gsup_server.h
index 9c4d483..14f5013 100644
--- a/include/osmocom/hlr/gsup_server.h
+++ b/include/osmocom/hlr/gsup_server.h
@@ -47,6 +47,7 @@
 	bool supports_ps; /* client supports OSMO_GSUP_CN_DOMAIN_PS */
 };
 
+struct msgb *osmo_gsup_msgb_alloc(const char *label);
 
 int osmo_gsup_conn_send(struct osmo_gsup_conn *conn, struct msgb *msg);
 int osmo_gsup_conn_ccm_get(const struct osmo_gsup_conn *clnt, uint8_t **addr,
diff --git a/src/gsup_server.c b/src/gsup_server.c
index bee6aef..ed1b285 100644
--- a/src/gsup_server.c
+++ b/src/gsup_server.c
@@ -30,6 +30,13 @@
 #include <osmocom/hlr/gsup_server.h>
 #include <osmocom/hlr/gsup_router.h>
 
+struct msgb *osmo_gsup_msgb_alloc(const char *label)
+{
+	struct msgb *msg = msgb_alloc_headroom(1024+16, 16, label);
+	OSMO_ASSERT(msg);
+	return msg;
+}
+
 static void osmo_gsup_server_send(struct osmo_gsup_conn *conn,
 			     int proto_ext, struct msgb *msg_tx)
 {
diff --git a/src/hlr.c b/src/hlr.c
index 0970bb1..1638e67 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -128,7 +128,7 @@
 		}
 
 		/* Send ISD to MSC/SGSN */
-		msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP ISD UPDATE");
+		msg_out = osmo_gsup_msgb_alloc("GSUP ISD UPDATE");
 		if (msg_out == NULL) {
 			LOGP(DLGSUP, LOGL_ERROR,
 			       "IMSI='%s': Cannot notify GSUP client; could not allocate msg buffer "
@@ -271,7 +271,7 @@
 		gsup_out.num_auth_vectors = rc;
 	}
 
-	msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP AUC response");
+	msg_out = osmo_gsup_msgb_alloc("GSUP AUC response");
 	osmo_gsup_encode(msg_out, &gsup_out);
 	return osmo_gsup_conn_send(conn, msg_out);
 }
@@ -451,7 +451,7 @@
 		gsup_reply.cause = GMM_CAUSE_NET_FAIL;
 	}
 
-	msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP AUC response");
+	msg_out = osmo_gsup_msgb_alloc("GSUP AUC response");
 	osmo_gsup_encode(msg_out, &gsup_reply);
 	return osmo_gsup_conn_send(conn, msg_out);
 }
@@ -466,8 +466,7 @@
 	OSMO_STRLCPY_ARRAY(gsup_reply.imsi, imsi);
 	gsup_reply.message_type = type_err;
 	gsup_reply.cause = err_cause;
-	msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP ERR response");
-	OSMO_ASSERT(msg_out);
+	msg_out = osmo_gsup_msgb_alloc("GSUP ERR response");
 	osmo_gsup_encode(msg_out, &gsup_reply);
 	LOGP(DMAIN, LOGL_NOTICE, "Tx %s\n", osmo_gsup_message_type_name(type_err));
 	return osmo_gsup_conn_send(conn, msg_out);
@@ -525,7 +524,7 @@
 	/* Accept all IMEIs */
 	gsup_reply.imei_result = OSMO_GSUP_IMEI_RESULT_ACK;
 	gsup_reply.message_type = OSMO_GSUP_MSGT_CHECK_IMEI_RESULT;
-	msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP Check_IMEI response");
+	msg_out = osmo_gsup_msgb_alloc("GSUP Check_IMEI response");
 	memcpy(gsup_reply.imsi, gsup->imsi, sizeof(gsup_reply.imsi));
 	osmo_gsup_encode(msg_out, &gsup_reply);
 	return osmo_gsup_conn_send(conn, msg_out);
@@ -591,8 +590,7 @@
 end:
 	/* Send error back to source */
 	if (ret) {
-		struct msgb *msg_err = msgb_alloc_headroom(1024+16, 16, "GSUP forward ERR response");
-		OSMO_ASSERT(msg_err);
+		struct msgb *msg_err = osmo_gsup_msgb_alloc("GSUP forward ERR response");
 		gsup_err->message_type = OSMO_GSUP_MSGT_E_ROUTING_ERROR;
 		osmo_gsup_encode(msg_err, gsup_err);
 		LOGP_GSUP_FWD(gsup_err, LOGL_NOTICE, "Tx %s\n", osmo_gsup_message_type_name(gsup_err->message_type));
diff --git a/src/hlr_ussd.c b/src/hlr_ussd.c
index 00023ba..8cdc15c 100644
--- a/src/hlr_ussd.c
+++ b/src/hlr_ussd.c
@@ -464,8 +464,7 @@
 	}
 
 	if (is_euse_originated) {
-		msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP USSD FW");
-		OSMO_ASSERT(msg_out);
+		msg_out = osmo_gsup_msgb_alloc("GSUP USSD FW");
 		/* Received from EUSE, Forward to VLR */
 		osmo_gsup_encode(msg_out, gsup);
 		ss_gsup_send(ss, conn->server, msg_out);
@@ -481,8 +480,7 @@
 				LOGPSS(ss, LOGL_ERROR, "Cannot find conn for EUSE %s\n", addr);
 				ss_tx_error(ss, req->invoke_id, GSM0480_ERR_CODE_SYSTEM_FAILURE);
 			} else {
-				msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP USSD FW");
-				OSMO_ASSERT(msg_out);
+				msg_out = osmo_gsup_msgb_alloc("GSUP USSD FW");
 				osmo_gsup_encode(msg_out, gsup);
 				osmo_gsup_conn_send(conn, msg_out);
 			}
diff --git a/src/luop.c b/src/luop.c
index 652ce0d..1a2f854 100644
--- a/src/luop.c
+++ b/src/luop.c
@@ -50,8 +50,7 @@
 {
 	struct msgb *msg_out;
 
-	msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP");
-	OSMO_ASSERT(msg_out);
+	msg_out = osmo_gsup_msgb_alloc("GSUP LUOP");
 	osmo_gsup_encode(msg_out, gsup);
 
 	osmo_gsup_addr_send(luop->gsup_server, luop->peer,

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/15915
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I40e99b5bc4fd8f750da7643c03b2119ac3bfd95e
Gerrit-Change-Number: 15915
Gerrit-PatchSet: 11
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191125/2871ef66/attachment.htm>


More information about the gerrit-log mailing list