summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/gsm/gsup.h16
-rw-r--r--src/gsm/gsup.c23
-rw-r--r--tests/gsup/gsup_test.c33
-rw-r--r--tests/gsup/gsup_test.err15
-rw-r--r--tests/gsup/gsup_test.ok6
5 files changed, 93 insertions, 0 deletions
diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h
index 37e474c2..6adb0bfd 100644
--- a/include/osmocom/gsm/gsup.h
+++ b/include/osmocom/gsm/gsup.h
@@ -99,6 +99,9 @@ enum osmo_gsup_iei {
OSMO_GSUP_SM_RP_MMS_IE = 0x45,
OSMO_GSUP_SM_ALERT_RSN_IE = 0x46,
+ OSMO_GSUP_IMEI_IE = 0x50,
+ OSMO_GSUP_IMEI_RESULT_IE = 0x51,
+
_OSMO_GSUP_IEI_END_MARKER
};
@@ -145,6 +148,10 @@ enum osmo_gsup_message_type {
OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST = 0b00101100,
OSMO_GSUP_MSGT_READY_FOR_SM_ERROR = 0b00101101,
OSMO_GSUP_MSGT_READY_FOR_SM_RESULT = 0b00101110,
+
+ OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST = 0b00110000,
+ OSMO_GSUP_MSGT_CHECK_IMEI_ERROR = 0b00110001,
+ OSMO_GSUP_MSGT_CHECK_IMEI_RESULT = 0b00110010,
};
#define OSMO_GSUP_IS_MSGT_REQUEST(msgt) (((msgt) & 0b00000011) == 0b00)
@@ -166,6 +173,11 @@ enum osmo_gsup_cn_domain {
OSMO_GSUP_CN_DOMAIN_CS = 2,
};
+enum osmo_gsup_imei_result {
+ OSMO_GSUP_IMEI_RESULT_ACK = 1,
+ OSMO_GSUP_IMEI_RESULT_NACK = 2,
+};
+
/*! TCAP-like session state */
enum osmo_gsup_session_state {
/*! Undefined session state */
@@ -259,6 +271,10 @@ struct osmo_gsup_message {
const uint8_t *sm_rp_mms;
/*! Alert reason (see 3GPP TS 29.002, 7.6.8.8) */
enum osmo_gsup_sms_sm_alert_rsn_t sm_alert_rsn;
+
+ const uint8_t *imei_enc;
+ size_t imei_enc_len;
+ enum osmo_gsup_imei_result imei_result;
};
int osmo_gsup_decode(const uint8_t *data, size_t data_len,
diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c
index 3b31d03c..3d2a8e2e 100644
--- a/src/gsm/gsup.c
+++ b/src/gsm/gsup.c
@@ -79,6 +79,10 @@ const struct value_string osmo_gsup_message_type_names[] = {
OSMO_VALUE_STRING(OSMO_GSUP_MSGT_READY_FOR_SM_ERROR),
OSMO_VALUE_STRING(OSMO_GSUP_MSGT_READY_FOR_SM_RESULT),
+ OSMO_VALUE_STRING(OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST),
+ OSMO_VALUE_STRING(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR),
+ OSMO_VALUE_STRING(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT),
+
{ 0, NULL }
};
@@ -116,6 +120,8 @@ int osmo_gsup_get_err_msg_type(enum osmo_gsup_message_type type_in)
return OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR;
case OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST:
return OSMO_GSUP_MSGT_READY_FOR_SM_ERROR;
+ case OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST:
+ return OSMO_GSUP_MSGT_CHECK_IMEI_ERROR;
default:
return -1;
}
@@ -487,6 +493,15 @@ int osmo_gsup_decode(const uint8_t *const_data, size_t data_len,
gsup_msg->sm_alert_rsn = *value;
break;
+ case OSMO_GSUP_IMEI_IE:
+ gsup_msg->imei_enc = value;
+ gsup_msg->imei_enc_len = value_len;
+ break;
+
+ case OSMO_GSUP_IMEI_RESULT_IE:
+ gsup_msg->imei_result = osmo_decode_big_endian(value, value_len) + 1;
+ break;
+
default:
LOGP(DLGSUP, LOGL_NOTICE,
"GSUP IE type %d unknown\n", iei);
@@ -720,6 +735,14 @@ int osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message *gsup_msg)
sizeof(u8), &u8);
}
+ if (gsup_msg->imei_enc)
+ msgb_tlv_put(msg, OSMO_GSUP_IMEI_IE, gsup_msg->imei_enc_len, gsup_msg->imei_enc);
+
+ if ((u8 = gsup_msg->imei_result)) {
+ u8 -= 1;
+ msgb_tlv_put(msg, OSMO_GSUP_IMEI_RESULT_IE, sizeof(u8), &u8);
+ }
+
return 0;
}
diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c
index 079a7031..f1945735 100644
--- a/tests/gsup/gsup_test.c
+++ b/tests/gsup/gsup_test.c
@@ -289,6 +289,33 @@ static void test_gsup_messages_dec_enc(void)
0x02, /* Memory Available (SMMA) */
};
+ static const uint8_t send_check_imei_req[] = {
+ 0x30, /* OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST */
+ TEST_IMSI_IE,
+
+ /* imei */
+ 0x50, 0x09,
+ 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
+ };
+
+ static const uint8_t send_check_imei_err[] = {
+ 0x31, /* OSMO_GSUP_MSGT_CHECK_IMEI_ERROR */
+ TEST_IMSI_IE,
+
+ /* cause */
+ 0x02, 0x01,
+ 0x60, /* GMM_CAUSE_INV_MAND_INFO */
+ };
+
+ static const uint8_t send_check_imei_res[] = {
+ 0x32, /* OSMO_GSUP_MSGT_CHECK_IMEI_RESULT */
+ TEST_IMSI_IE,
+
+ /* imei_result */
+ 0x51, 0x01,
+ 0x00, /* OSMO_GSUP_IMEI_RESULT_ACK */
+ };
+
static const struct test {
char *name;
const uint8_t *data;
@@ -338,6 +365,12 @@ static void test_gsup_messages_dec_enc(void)
send_mo_mt_forward_sm_err, sizeof(send_mo_mt_forward_sm_err)},
{"ReadyForSM (MSC -> SMSC) Indication",
send_ready_for_sm_ind, sizeof(send_ready_for_sm_ind)},
+ {"Check IMEI Request",
+ send_check_imei_req, sizeof(send_check_imei_req)},
+ {"Check IMEI Error",
+ send_check_imei_err, sizeof(send_check_imei_err)},
+ {"Check IMEI Result",
+ send_check_imei_res, sizeof(send_check_imei_res)},
};
printf("Test GSUP message decoding/encoding\n");
diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err
index 236c38a9..73b35fc5 100644
--- a/tests/gsup/gsup_test.err
+++ b/tests/gsup/gsup_test.err
@@ -64,6 +64,15 @@
generated message: 2c 01 08 21 43 65 87 09 21 43 f5 46 01 02
original message: 2c 01 08 21 43 65 87 09 21 43 f5 46 01 02
IMSI: 123456789012345
+ generated message: 30 01 08 21 43 65 87 09 21 43 f5 50 09 42 42 42 42 42 42 42 42 42
+ original message: 30 01 08 21 43 65 87 09 21 43 f5 50 09 42 42 42 42 42 42 42 42 42
+ IMSI: 123456789012345
+ generated message: 31 01 08 21 43 65 87 09 21 43 f5 02 01 60
+ original message: 31 01 08 21 43 65 87 09 21 43 f5 02 01 60
+ IMSI: 123456789012345
+ generated message: 32 01 08 21 43 65 87 09 21 43 f5 51 01 00
+ original message: 32 01 08 21 43 65 87 09 21 43 f5 51 01 00
+ IMSI: 123456789012345
message 0: tested 11 truncations, 11 parse failures
message 1: tested 14 truncations, 13 parse failures
message 2: tested 83 truncations, 81 parse failures
@@ -86,6 +95,9 @@
message 19: tested 20 truncations, 18 parse failures
message 20: tested 26 truncations, 22 parse failures
message 21: tested 14 truncations, 13 parse failures
+ message 22: tested 22 truncations, 21 parse failures
+ message 23: tested 14 truncations, 13 parse failures
+ message 24: tested 14 truncations, 13 parse failures
DLGSUP Stopping DLGSUP logging
message 0: tested 2816 modifications, 510 parse failures
message 1: tested 3584 modifications, 770 parse failures
@@ -109,3 +121,6 @@ DLGSUP Stopping DLGSUP logging
message 19: tested 5120 modifications, 1031 parse failures
message 20: tested 6656 modifications, 1546 parse failures
message 21: tested 3584 modifications, 771 parse failures
+ message 22: tested 5632 modifications, 771 parse failures
+ message 23: tested 3584 modifications, 770 parse failures
+ message 24: tested 3584 modifications, 771 parse failures
diff --git a/tests/gsup/gsup_test.ok b/tests/gsup/gsup_test.ok
index 36e35c8b..70f723c0 100644
--- a/tests/gsup/gsup_test.ok
+++ b/tests/gsup/gsup_test.ok
@@ -43,4 +43,10 @@ Test GSUP message decoding/encoding
MO-/MT-ForwardSM Error OK
Testing ReadyForSM (MSC -> SMSC) Indication
ReadyForSM (MSC -> SMSC) Indication OK
+ Testing Check IMEI Request
+ Check IMEI Request OK
+ Testing Check IMEI Error
+ Check IMEI Error OK
+ Testing Check IMEI Result
+ Check IMEI Result OK
Done.