[PATCH] libosmocore[master]: gsm0480: code dup: introduce and use gsm0480_l3hdr_push()

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
Mon Nov 28 13:39:35 UTC 2016


Review at  https://gerrit.osmocom.org/1339

gsm0480: code dup: introduce and use gsm0480_l3hdr_push()

Add function gsm0480_l3hdr_push() to push a struct gsm48_hdr to the start of a
msgb. Use in gsm0480.c and gsm0411_utils.c. Further callers of the new function
will follow in openbsc as well as another libosmocore patch for ussd.

Change-Id: I54fce6053ab8362015686fe22dbcd38bf1366700
---
M include/osmocom/gsm/gsm0480.h
M src/gsm/gsm0411_utils.c
M src/gsm/gsm0480.c
3 files changed, 19 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/39/1339/1

diff --git a/include/osmocom/gsm/gsm0480.h b/include/osmocom/gsm/gsm0480.h
index deac322..f49ca6b 100644
--- a/include/osmocom/gsm/gsm0480.h
+++ b/include/osmocom/gsm/gsm0480.h
@@ -35,3 +35,6 @@
 
 int gsm0480_wrap_invoke(struct msgb *msg, int op, int link_id);
 int gsm0480_wrap_facility(struct msgb *msg);
+
+struct gsm48_hdr *gsm0480_l3hdr_push(struct msgb *msg, uint8_t proto_discr,
+				     uint8_t msg_type);
diff --git a/src/gsm/gsm0411_utils.c b/src/gsm/gsm0411_utils.c
index af57963..5d18b12 100644
--- a/src/gsm/gsm0411_utils.c
+++ b/src/gsm/gsm0411_utils.c
@@ -315,12 +315,7 @@
 int gsm411_push_cp_header(struct msgb *msg, uint8_t proto, uint8_t trans,
 			     uint8_t msg_type)
 {
-	struct gsm48_hdr *gh;
-
-	gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
-	/* Outgoing needs the highest bit set */
-	gh->proto_discr = proto | (trans << 4);
-	gh->msg_type = msg_type;
-
+	/* Outgoing proto_discr needs the highest bit set */
+	gsm0480_l3hdr_push(msg, proto | (trans << 4), msg_type);
 	return 0;
 }
diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index d628d92..cab4d01 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -486,7 +486,6 @@
 struct msgb *gsm0480_create_ussd_resp(uint8_t invoke_id, uint8_t trans_id, const char *text)
 {
 	struct msgb *msg;
-	struct gsm48_hdr *gh;
 	uint8_t *ptr8;
 	int response_len;
 
@@ -525,10 +524,19 @@
 	msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);
 
 	/* And finally pre-pend the L3 header */
-	gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
-	gh->proto_discr = GSM48_PDISC_NC_SS | trans_id
-					| (1<<7);  /* TI direction = 1 */
-	gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
-
+	gsm0480_l3hdr_push(msg,
+			   GSM48_PDISC_NC_SS | trans_id
+			   | (1<<7) /* TI direction = 1 */,
+			   GSM0480_MTYPE_RELEASE_COMPLETE);
 	return msg;
 }
+
+struct gsm48_hdr *gsm0480_l3hdr_push(struct msgb *msg, uint8_t proto_discr,
+				     uint8_t msg_type)
+{
+	struct gsm48_hdr *gh;
+	gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
+	gh->proto_discr = proto_discr;
+	gh->msg_type = msg_type;
+	return gh;
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I54fce6053ab8362015686fe22dbcd38bf1366700
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list