diff mbox

[3/9] gsup: Extract the new MSISDN string

Message ID 1429825244-61253-3-git-send-email-holger@freyther.de
State Changes Requested
Headers show

Commit Message

Holger Freyther April 23, 2015, 9:40 p.m. UTC
From: Holger Hans Peter Freyther <holger@moiji-mobile.com>

---
 openbsc/include/openbsc/gprs_gsup_messages.h |  4 ++++
 openbsc/src/gprs/gprs_gsup_messages.c        | 10 ++++++++++
 openbsc/tests/gprs/gprs_test.c               |  2 ++
 3 files changed, 16 insertions(+)
diff mbox

Patch

diff --git a/openbsc/include/openbsc/gprs_gsup_messages.h b/openbsc/include/openbsc/gprs_gsup_messages.h
index 9857b97..937733f 100644
--- a/openbsc/include/openbsc/gprs_gsup_messages.h
+++ b/openbsc/include/openbsc/gprs_gsup_messages.h
@@ -29,6 +29,7 @@ 
 
 #define GPRS_GSUP_MAX_NUM_PDP_INFO		10 /* GSM 09.02 limits this to 50 */
 #define GPRS_GSUP_MAX_NUM_AUTH_INFO		5
+#define GPRS_GSUP_MAX_MSISDN_LEN		9
 
 #define GPRS_GSUP_PDP_TYPE_SIZE			2
 
@@ -43,6 +44,7 @@  enum gprs_gsup_iei {
 	GPRS_GSUP_PDP_CONTEXT_ID_IE		= 0x10,
 	GPRS_GSUP_PDP_TYPE_IE			= 0x11,
 	GPRS_GSUP_ACCESS_POINT_NAME_IE		= 0x12,
+	GPRS_GSUP_MSISDN_IE			= 0x13,
 	GPRS_GSUP_RAND_IE			= 0x20,
 	GPRS_GSUP_SRES_IE			= 0x21,
 	GPRS_GSUP_KC_IE				= 0x22
@@ -102,6 +104,8 @@  struct gprs_gsup_message {
 	size_t				num_auth_tuples;
 	struct gprs_gsup_pdp_info	pdp_infos[GPRS_GSUP_MAX_NUM_PDP_INFO];
 	size_t				num_pdp_infos;
+	const uint8_t 			*msisdn_enc;
+	size_t				msisdn_enc_len;
 };
 
 int gprs_gsup_decode(const uint8_t *data, size_t data_len,
diff --git a/openbsc/src/gprs/gprs_gsup_messages.c b/openbsc/src/gprs/gprs_gsup_messages.c
index 9d9b6be..be8e823 100644
--- a/openbsc/src/gprs/gprs_gsup_messages.c
+++ b/openbsc/src/gprs/gprs_gsup_messages.c
@@ -2,6 +2,7 @@ 
 
 /*
  * (C) 2014 by Sysmocom s.f.m.c. GmbH
+ * (C) 2015 by Holger Hans Peter Freyther
  * All Rights Reserved
  *
  * Author: Jacob Erlbeck
@@ -291,6 +292,10 @@  int gprs_gsup_decode(const uint8_t *const_data, size_t data_len,
 			gsup_msg->auth_tuples[gsup_msg->num_auth_tuples++] =
 				auth_info;
 			break;
+		case GPRS_GSUP_MSISDN_IE:
+			gsup_msg->msisdn_enc = value;
+			gsup_msg->msisdn_enc_len = value_len;
+			break;
 		default:
 			LOGP(DGPRS, LOGL_NOTICE,
 			     "GSUP IE type %d unknown\n", iei);
@@ -415,4 +420,9 @@  void gprs_gsup_encode(struct msgb *msg, const struct gprs_gsup_message *gsup_msg
 
 		encode_auth_info(msg, GPRS_GSUP_AUTH_TUPLE_IE, auth_info);
 	}
+
+	if (gsup_msg->msisdn_enc)
+		msgb_tlv_put(msg, GPRS_GSUP_MSISDN_IE,
+				gsup_msg->msisdn_enc_len, gsup_msg->msisdn_enc);
+
 }
diff --git a/openbsc/tests/gprs/gprs_test.c b/openbsc/tests/gprs/gprs_test.c
index 0ae06e7..555d657 100644
--- a/openbsc/tests/gprs/gprs_test.c
+++ b/openbsc/tests/gprs/gprs_test.c
@@ -452,6 +452,8 @@  static void test_gsup_messages_dec_enc(void)
 			0x10, 0x01, 0x02,
 			0x11, 0x02, 0xf1, 0x21, /* IPv4 */
 			0x12, 0x08, 0x03, 'f', 'o', 'o', 0x03, 'a', 'p', 'n',
+		0x13, 0x07, /* MSISDN of the subscriber */
+			0x91, 0x94, 0x61, 0x46, 0x32, 0x24, 0x43,
 	};
 
 	static const uint8_t location_cancellation_req[] = {