aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2019-01-04 02:50:04 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2019-05-08 21:19:40 +0200
commit737f563e6f664d99e20aafb4772d358103433b63 (patch)
tree1f1113328a8ac44aca79cd42cc6acb849758896d
parentce91c997cf2422680739b0380ed1b1eda2fa8c58 (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 373b434..461e5b8 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -302,6 +302,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 = {