Change in libosmocore[master]: libosmogsm: (re)introduce gsm48_push_l3hdr()

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
Sun Aug 5 17:41:50 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/10328 )

Change subject: libosmogsm: (re)introduce gsm48_push_l3hdr()
......................................................................

libosmogsm: (re)introduce gsm48_push_l3hdr()

There was gsm0480_l3hdr_push() declared in a header file, but
not exposed in 'libosmogsm.map'. Furthermore, for some reason
it was a part of GSM 04.80 API, what is not actually correct.

Let's rename this symbol, and properly expose it as a part of
the GSM 04.08 API. Also, let's introduce an auxiliary wrapper
for messages, where the transaction identifier is required
(see GSM 04.07, section 11.2.3.1.2).

Change-Id: I8a045efe8335d83fcbe8d43eb180972e3b1d9dda
---
M TODO-RELEASE
M include/osmocom/gsm/gsm0480.h
M include/osmocom/gsm/gsm48.h
M src/gsm/gsm0411_utils.c
M src/gsm/gsm0480.c
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
7 files changed, 49 insertions(+), 24 deletions(-)

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



diff --git a/TODO-RELEASE b/TODO-RELEASE
index 8ccfa49..64833d2 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,6 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public release: c:r:0.
 #library	what			description / commit summary line
+libosmogsm	gsm0480_l3hdr_push()	removed from gsm/gsm0480.h (was not exposed)
+libosmogsm	gsm48_push_l3hdr()	(re)introduced in gsm/gsm48.h (GSM 04.08 API)
+libosmogsm	gsm48_push_l3hdr_tid()	a wrapper around gsm48_push_l3hdr()
diff --git a/include/osmocom/gsm/gsm0480.h b/include/osmocom/gsm/gsm0480.h
index 246f4b3..827464e 100644
--- a/include/osmocom/gsm/gsm0480.h
+++ b/include/osmocom/gsm/gsm0480.h
@@ -121,6 +121,3 @@
 
 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/include/osmocom/gsm/gsm48.h b/include/osmocom/gsm/gsm48.h
index cfae83d..2b14e6c 100644
--- a/include/osmocom/gsm/gsm48.h
+++ b/include/osmocom/gsm/gsm48.h
@@ -4,6 +4,8 @@
 
 #include <stdbool.h>
 
+#include <osmocom/core/msgb.h>
+
 #include <osmocom/gsm/tlv.h>
 #include <osmocom/gsm/protocol/gsm_04_08.h>
 #include <osmocom/gsm/gsm48_ie.h>
@@ -63,3 +65,9 @@
 	OSMO_DEPRECATED("Use osmo_plmn_to_bcd() instead, to not lose leading zeros in the MNC");
 void gsm48_mcc_mnc_from_bcd(uint8_t *bcd_src, uint16_t *mcc, uint16_t *mnc)
 	OSMO_DEPRECATED("Use osmo_plmn_from_bcd() instead, to not lose leading zeros in the MNC");
+
+struct gsm48_hdr *gsm48_push_l3hdr(struct msgb *msg,
+				   uint8_t pdisc, uint8_t msg_type);
+
+#define gsm48_push_l3hdr_tid(msg, pdisc, tid, msg_type) \
+	gsm48_push_l3hdr(msg, (pdisc & 0x0f) | (tid << 4), msg_type)
diff --git a/src/gsm/gsm0411_utils.c b/src/gsm/gsm0411_utils.c
index 53d37a4..ccefe54 100644
--- a/src/gsm/gsm0411_utils.c
+++ b/src/gsm/gsm0411_utils.c
@@ -35,7 +35,6 @@
 #include <osmocom/core/logging.h>
 
 #include <osmocom/gsm/gsm48.h>
-#include <osmocom/gsm/gsm0480.h>
 #include <osmocom/gsm/gsm_utils.h>
 #include <osmocom/gsm/protocol/gsm_03_40.h>
 #include <osmocom/gsm/protocol/gsm_04_11.h>
@@ -354,7 +353,7 @@
 			     uint8_t msg_type)
 {
 	/* Outgoing proto_discr needs the highest bit set */
-	gsm0480_l3hdr_push(msg, proto | (trans << 4), msg_type);
+	gsm48_push_l3hdr_tid(msg, proto, trans, msg_type);
 	return 0;
 }
 
diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index df640b8..7756ecb 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -25,6 +25,7 @@
  *
  */
 
+#include <osmocom/gsm/gsm48.h>
 #include <osmocom/gsm/gsm0480.h>
 #include <osmocom/gsm/gsm_utils.h>
 
@@ -863,10 +864,11 @@
 	msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);
 
 	/* And finally pre-pend the L3 header */
-	gsm0480_l3hdr_push(msg,
-			   GSM48_PDISC_NC_SS | trans_id
-			   | (1<<7) /* TI direction = 1 */,
-			   GSM0480_MTYPE_RELEASE_COMPLETE);
+	gsm48_push_l3hdr_tid(msg, GSM48_PDISC_NC_SS,
+			     /* FIXME: TI direction is always 1 ?!? */
+			     trans_id | (1 << 7),
+			     GSM0480_MTYPE_RELEASE_COMPLETE);
+
 	return msg;
 }
 
@@ -932,17 +934,6 @@
 	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;
-}
-
 struct msgb *gsm0480_create_ussd_notify(int level, const char *text)
 {
 	struct msgb *msg;
@@ -954,7 +945,11 @@
 	gsm0480_wrap_invoke(msg, GSM0480_OP_CODE_USS_NOTIFY, 0);
 	gsm0480_wrap_facility(msg);
 
-	gsm0480_l3hdr_push(msg, GSM48_PDISC_NC_SS, GSM0480_MTYPE_REGISTER);
+	/* And finally pre-pend the L3 header */
+	gsm48_push_l3hdr(msg, GSM48_PDISC_NC_SS,
+			 /* FIXME: no transactionID?!? */
+			 GSM0480_MTYPE_REGISTER);
+
 	return msg;
 }
 
@@ -966,8 +961,10 @@
 	if (!msg)
 		return NULL;
 
-	/* FIXME: should this set trans_id and TI direction flag? */
-	gsm0480_l3hdr_push(msg, GSM48_PDISC_NC_SS,
-			   GSM0480_MTYPE_RELEASE_COMPLETE);
+	/* And finally pre-pend the L3 header */
+	gsm48_push_l3hdr(msg, GSM48_PDISC_NC_SS,
+			 /* FIXME: no transactionID?!? */
+			 GSM0480_MTYPE_RELEASE_COMPLETE);
+
 	return msg;
 }
diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index b4892de..136b937 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -1024,4 +1024,24 @@
 	 { 0, NULL }
 };
 
+/*! Wrap a given \ref msg with \ref gsm48_hdr structure
+ * \param[out] msg      A message to be wrapped
+ * \param[in]  pdisc    GSM TS 04.07 protocol discriminator 1/2,
+ *                      sub-pdisc, trans_id or skip_ind 1/2,
+ *                      see section 11.2.3.1 for details
+ * \param[in]  msg_type GSM TS 04.08 message type
+ * @return              pointer to pushed header within \ref msg
+ */
+struct gsm48_hdr *gsm48_push_l3hdr(struct msgb *msg,
+				   uint8_t pdisc, uint8_t msg_type)
+{
+	struct gsm48_hdr *gh;
+
+	gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
+	gh->proto_discr = pdisc;
+	gh->msg_type = msg_type;
+
+	return gh;
+}
+
 /*! @} */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 2bb9d97..1da398c 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -241,6 +241,7 @@
 
 gsm414_msgt_names;
 
+gsm48_push_l3hdr;
 gsm48_att_tlvdef;
 gsm48_cc_msg_name;
 gsm48_rr_msg_name;

-- 
To view, visit https://gerrit.osmocom.org/10328
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8a045efe8335d83fcbe8d43eb180972e3b1d9dda
Gerrit-Change-Number: 10328
Gerrit-PatchSet: 3
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180805/03e319e2/attachment.htm>


More information about the gerrit-log mailing list