aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2019-01-04 02:50:04 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2019-04-15 16:27:19 +0200
commit3a471ce8527e691c77550f3ebe115e66bae9c38e (patch)
treee752b9549e3f4202661fabe7e178dee199680bd9
parent8cac79e2f637015968866521a88ff5fa69f42467 (diff)
add gsm0808_create_common_id()neels/gsup_router
-rw-r--r--include/osmocom/gsm/gsm0808.h2
-rw-r--r--src/gsm/gsm0808.c26
2 files changed, 28 insertions, 0 deletions
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_handover_performed(const struct gsm0808_handover_per
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 @@ struct msgb *gsm0808_create_dtap(struct msgb *msg_l3, uint8_t link_id)
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 = {