Change in libosmocore[master]: add gsm0808_create_common_id()

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Apr 12 00:08:59 UTC 2019


Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/13611


Change subject: add gsm0808_create_common_id()
......................................................................

add gsm0808_create_common_id()

Change-Id: Id055df109cf67754854641ce6486523027f4d801
---
M include/osmocom/gsm/gsm0808.h
M src/gsm/gsm0808.c
2 files changed, 28 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/11/13611/1

diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index a4e63a9..5f3a628 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -301,6 +301,8 @@
 struct msgb *gsm0808_create_dtap(struct msgb *msg, uint8_t link_id);
 void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id);
 
+struct msgb *gsm0808_create_common_id(const char *imsi);
+
 const struct tlv_definition *gsm0808_att_tlvdef(void);
 
 /*! Parse BSSAP TLV structure using \ref tlv_parse */
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index 3c77c77..ad320da 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -1258,6 +1258,32 @@
 	return msg;
 }
 
+/*! Crate BSSMAP Common ID message.
+ * \param[in] imsi  Subscriber's IMSI to send in the Common ID message.
+ * \return allocated msgb with BSSMAP Common ID message.
+ */
+struct msgb *gsm0808_create_common_id(const char *imsi)
+{
+	uint8_t mid_buf[GSM48_MI_SIZE + 2];
+	int mid_len;
+	struct msgb *msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, "CommonID");
+	if (!msg)
+		return NULL;
+	OSMO_ASSERT(strlen(imsi) <= GSM48_MI_SIZE);
+
+	/* Message Type, 3.2.2.1 */
+	msgb_v_put(msg, BSS_MAP_MSG_COMMON_ID);
+
+	/* mandatory IMSI 3.2.2.6 */
+	mid_len = gsm48_generate_mid_from_imsi(mid_buf, imsi);
+	msgb_tlv_put(msg, GSM0808_IE_IMSI, mid_len - 2, mid_buf + 2);
+
+	/* prepend header with final length */
+	msg->l3h = msgb_tv_push(msg, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg));
+
+	return msg;
+}
+
 /* As per 3GPP TS 48.008 version 11.7.0 Release 11 */
 static const struct tlv_definition bss_att_tlvdef = {
 	.def = {

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id055df109cf67754854641ce6486523027f4d801
Gerrit-Change-Number: 13611
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190412/82af6ff4/attachment.html>


More information about the gerrit-log mailing list