diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gsup/gsup_test.c | 249 | ||||
-rw-r--r-- | tests/gsup/gsup_test.err | 74 | ||||
-rw-r--r-- | tests/gsup/gsup_test.ok | 28 |
3 files changed, 347 insertions, 4 deletions
diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c index 0631a514..b84c88f0 100644 --- a/tests/gsup/gsup_test.c +++ b/tests/gsup/gsup_test.c @@ -9,9 +9,16 @@ /* Tests for osmo_gsup_messages.c */ +/* Complete IEs used multiple times (sorted alphabetically) + * 1st byte: IEI from osmo_gsup_iei, 2nd byte: length */ #define TEST_IMSI_IE 0x01, 0x08, 0x21, 0x43, 0x65, 0x87, 0x09, 0x21, 0x43, 0xf5 #define TEST_IMSI_STR "123456789012345" #define TEST_CLASS_SUBSCR_IE 0xa, 0x1, 0x1 +#define TEST_CLASS_INTER_MSC_IE 0xa, 0x1, 0x4 +#define TEST_MSISDN_IE 0x08, 0x07, 0x91, 0x94, 0x61, 0x46, 0x32, 0x24, 0x43 +#define TEST_AN_APDU_IE 0x62, 0x05, 0x01, 0x42, 0x42, 0x42, 0x42 +#define TEST_SOURCE_NAME_IE 0x60, 0x05, 'M', 'S', 'C', '-', 'A' +#define TEST_DESTINATION_NAME_IE 0x61, 0x05, 'M', 'S', 'C', '-', 'B' static void test_gsup_messages_dec_enc(void) { @@ -66,8 +73,7 @@ static void test_gsup_messages_dec_enc(void) static const uint8_t update_location_res[] = { 0x06, TEST_IMSI_IE, - 0x08, 0x07, /* MSISDN of the subscriber */ - 0x91, 0x94, 0x61, 0x46, 0x32, 0x24, 0x43, + TEST_MSISDN_IE, 0x09, 0x07, /* HLR-Number of the subscriber */ 0x91, 0x83, 0x52, 0x38, 0x48, 0x83, 0x93, 0x04, 0x00, /* PDP info complete */ @@ -312,6 +318,217 @@ static void test_gsup_messages_dec_enc(void) 0x00, /* OSMO_GSUP_IMEI_RESULT_ACK */ }; + /* Handover related test messages. Oftentimes they only differ in the + * AN_APDU_IE, which is mostly a blob in GSUP. To give a better example + * of how the messages can be used, I've added the information an_apdu + * holds in brackets (see osmo-msc.git's doc/interMSC_HO_GSUP_msgs.txt). + * The session states are from the ASCII art in this e-mail: + * https://lists.osmocom.org/pipermail/openbsc/2019-January/012653.html */ + static const uint8_t send_e_prepare_handover_req[] = { + 0x34, /* OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST */ + TEST_IMSI_IE, + + /* Session ID and state (begin) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x01, + + TEST_CLASS_INTER_MSC_IE, + TEST_SOURCE_NAME_IE, + TEST_DESTINATION_NAME_IE, + TEST_AN_APDU_IE, /* (Handover Request) */ + }; + + static const uint8_t send_e_prepare_handover_err[] = { + 0x35, /* OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_ERROR */ + TEST_IMSI_IE, + + /* Session ID and state (continue) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x02, + + TEST_CLASS_INTER_MSC_IE, + TEST_SOURCE_NAME_IE, + TEST_DESTINATION_NAME_IE, + + /* cause_bssap */ + 0x64, 0x01, + 0x51, /* GSM0808_CAUSE_INVALID_MESSAGE_CONTENTS */ + }; + + static const uint8_t send_e_prepare_handover_res[] = { + 0x36, /* OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_RESULT */ + TEST_IMSI_IE, + TEST_MSISDN_IE, /* (Handover Number) */ + + /* Session ID and state (continue) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x02, + + TEST_CLASS_INTER_MSC_IE, + TEST_SOURCE_NAME_IE, + TEST_DESTINATION_NAME_IE, + TEST_AN_APDU_IE, /* (Handover Request Ack) */ + }; + + static const uint8_t send_e_prepare_subsequent_handover_req[] = { + 0x38, /* OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_REQUEST */ + TEST_IMSI_IE, + + /* Session ID and state (begin) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x01, + + TEST_CLASS_INTER_MSC_IE, + TEST_SOURCE_NAME_IE, + TEST_DESTINATION_NAME_IE, + TEST_AN_APDU_IE, /* (Handover Required) */ + }; + + static const uint8_t send_e_prepare_subsequent_handover_err[] = { + 0x39, /* OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_ERROR */ + TEST_IMSI_IE, + + /* Session ID and state (continue) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x02, + + TEST_CLASS_INTER_MSC_IE, + TEST_SOURCE_NAME_IE, + TEST_DESTINATION_NAME_IE, + + /* cause_bssap */ + 0x64, 0x01, + 0x51, /* GSM0808_CAUSE_INVALID_MESSAGE_CONTENTS */ + }; + + static const uint8_t send_e_prepare_subsequent_handover_res[] = { + 0x3A, /* OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_RESULT */ + TEST_IMSI_IE, + + /* Session ID and state (continue) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x02, + + TEST_CLASS_INTER_MSC_IE, + TEST_SOURCE_NAME_IE, + TEST_DESTINATION_NAME_IE, + TEST_AN_APDU_IE, /* (Handover Request Ack) */ + }; + + static const uint8_t send_e_send_end_signal_req[] = { + 0x3C, /* OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_REQUEST */ + TEST_IMSI_IE, + + /* Session ID and state (end) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x03, + + TEST_CLASS_INTER_MSC_IE, + TEST_SOURCE_NAME_IE, + TEST_DESTINATION_NAME_IE, + TEST_AN_APDU_IE, /* (Handover Complete) */ + }; + + static const uint8_t send_e_send_end_signal_err[] = { + 0x3D, /* OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_ERROR */ + TEST_IMSI_IE, + + /* Session ID and state (continue) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x02, + + TEST_CLASS_INTER_MSC_IE, + TEST_SOURCE_NAME_IE, + TEST_DESTINATION_NAME_IE, + + /* cause_bssap */ + 0x64, 0x01, + 0x51, /* GSM0808_CAUSE_INVALID_MESSAGE_CONTENTS */ + }; + + static const uint8_t send_e_process_access_signalling_req[] = { + 0x40, /* OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST */ + TEST_IMSI_IE, + + /* Session ID and state (continue) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x02, + + TEST_CLASS_INTER_MSC_IE, + TEST_SOURCE_NAME_IE, + TEST_DESTINATION_NAME_IE, + TEST_AN_APDU_IE, /* (Handover Detect) */ + }; + + static const uint8_t send_e_send_end_signal_res[] = { + 0x3E, /* OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_RESULT */ + TEST_IMSI_IE, + + /* Session ID and state (end) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x03, + + TEST_CLASS_INTER_MSC_IE, + TEST_SOURCE_NAME_IE, + TEST_DESTINATION_NAME_IE, + TEST_AN_APDU_IE, /* (Handover Complete) */ + }; + + static const uint8_t send_e_forward_access_signalling_req [] = { + 0x44, /* OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST */ + TEST_IMSI_IE, + + /* Session ID and state (continue) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x02, + + TEST_CLASS_INTER_MSC_IE, + TEST_SOURCE_NAME_IE, + TEST_DESTINATION_NAME_IE, + TEST_AN_APDU_IE, /* (DTAP, e.g. CC, SMS, ...) */ + }; + + static const uint8_t send_e_close[] = { + 0x47, /* OSMO_GSUP_MSGT_E_CLOSE */ + TEST_IMSI_IE, + + /* Session ID and state (end) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x03, + + TEST_CLASS_INTER_MSC_IE, + TEST_SOURCE_NAME_IE, + TEST_DESTINATION_NAME_IE, + }; + + static const uint8_t send_e_abort[] = { + 0x4B, /* OSMO_GSUP_MSGT_E_ABORT */ + TEST_IMSI_IE, + + /* Session ID and state (end) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x03, + + TEST_CLASS_INTER_MSC_IE, + + /* cause_bssap */ + 0x64, 0x01, + 0x51, /* GSM0808_CAUSE_INVALID_MESSAGE_CONTENTS */ + }; + + static const uint8_t send_e_routing_error[] = { + 0x4E, /* OSMO_GSUP_MSGT_E_ROUTING_ERROR */ + TEST_IMSI_IE, + + /* Session ID and state (end) */ + 0x30, 0x04, 0xde, 0xad, 0xbe, 0xef, + 0x31, 0x01, 0x03, + + TEST_CLASS_INTER_MSC_IE, + TEST_SOURCE_NAME_IE, + TEST_DESTINATION_NAME_IE, + }; + static const struct test { char *name; const uint8_t *data; @@ -367,6 +584,34 @@ static void test_gsup_messages_dec_enc(void) send_check_imei_err, sizeof(send_check_imei_err)}, {"Check IMEI Result", send_check_imei_res, sizeof(send_check_imei_res)}, + {"E Prepare Handover Request", + send_e_prepare_handover_req, sizeof(send_e_prepare_handover_req)}, + {"E Prepare Handover Error", + send_e_prepare_handover_err, sizeof(send_e_prepare_handover_err)}, + {"E Prepare Handover Result", + send_e_prepare_handover_res, sizeof(send_e_prepare_handover_res)}, + {"E Prepare Subsequent Handover Request", + send_e_prepare_subsequent_handover_req, sizeof(send_e_prepare_subsequent_handover_req)}, + {"E Prepare Subsequent Handover Error", + send_e_prepare_subsequent_handover_err, sizeof(send_e_prepare_subsequent_handover_err)}, + {"E Prepare Subsequent Handover Result", + send_e_prepare_subsequent_handover_res, sizeof(send_e_prepare_subsequent_handover_res)}, + {"E Send End Signal Request", + send_e_send_end_signal_req, sizeof(send_e_send_end_signal_req)}, + {"E Send End Signal Error", + send_e_send_end_signal_err, sizeof(send_e_send_end_signal_err)}, + {"E Send End Signal Result", + send_e_send_end_signal_res, sizeof(send_e_send_end_signal_res)}, + {"E Process Access Signalling Request", + send_e_process_access_signalling_req, sizeof(send_e_process_access_signalling_req)}, + {"E Forward Access Signalling Request", + send_e_forward_access_signalling_req, sizeof(send_e_forward_access_signalling_req)}, + {"E Close", + send_e_close, sizeof(send_e_close)}, + {"E Abort", + send_e_abort, sizeof(send_e_abort)}, + {"E Routing Error", + send_e_routing_error, sizeof(send_e_routing_error)}, }; printf("Test GSUP message decoding/encoding\n"); diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err index 92838231..e5fe6ee3 100644 --- a/tests/gsup/gsup_test.err +++ b/tests/gsup/gsup_test.err @@ -73,6 +73,48 @@ 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 + generated message: 34 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 01 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + original message: 34 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 01 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + IMSI: 123456789012345 + generated message: 35 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51 + original message: 35 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51 + IMSI: 123456789012345 + generated message: 36 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 43 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + original message: 36 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 43 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + IMSI: 123456789012345 + generated message: 38 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 01 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + original message: 38 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 01 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + IMSI: 123456789012345 + generated message: 39 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51 + original message: 39 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51 + IMSI: 123456789012345 + generated message: 3a 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + original message: 3a 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + IMSI: 123456789012345 + generated message: 3c 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + original message: 3c 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + IMSI: 123456789012345 + generated message: 3d 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51 + original message: 3d 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51 + IMSI: 123456789012345 + generated message: 3e 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + original message: 3e 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + IMSI: 123456789012345 + generated message: 40 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + original message: 40 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + IMSI: 123456789012345 + generated message: 44 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + original message: 44 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 02 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 01 42 42 42 42 + IMSI: 123456789012345 + generated message: 47 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 + original message: 47 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 + IMSI: 123456789012345 + generated message: 4b 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 0a 01 04 64 01 51 + original message: 4b 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 0a 01 04 64 01 51 + IMSI: 123456789012345 + generated message: 4e 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 + original message: 4e 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 + IMSI: 123456789012345 message 0: tested 14 truncations, 13 parse failures message 1: tested 14 truncations, 13 parse failures message 2: tested 83 truncations, 81 parse failures @@ -98,19 +140,33 @@ message 22: tested 22 truncations, 21 parse failures message 23: tested 14 truncations, 13 parse failures message 24: tested 14 truncations, 13 parse failures + message 25: tested 44 truncations, 38 parse failures + message 26: tested 40 truncations, 34 parse failures + message 27: tested 53 truncations, 46 parse failures + message 28: tested 44 truncations, 38 parse failures + message 29: tested 40 truncations, 34 parse failures + message 30: tested 44 truncations, 38 parse failures + message 31: tested 44 truncations, 38 parse failures + message 32: tested 40 truncations, 34 parse failures + message 33: tested 44 truncations, 38 parse failures + message 34: tested 44 truncations, 38 parse failures + message 35: tested 44 truncations, 38 parse failures + message 36: tested 37 truncations, 32 parse failures + message 37: tested 26 truncations, 22 parse failures + message 38: tested 37 truncations, 32 parse failures DLGSUP Stopping DLGSUP logging message 0: tested 3584 modifications, 771 parse failures message 1: tested 3584 modifications, 770 parse failures message 2: tested 21248 modifications, 2575 parse failures message 3: tested 2816 modifications, 510 parse failures message 4: tested 3584 modifications, 770 parse failures - message 5: tested 20736 modifications, 4022 parse failures + message 5: tested 20736 modifications, 4023 parse failures message 6: tested 3584 modifications, 771 parse failures message 7: tested 3584 modifications, 770 parse failures message 8: tested 2816 modifications, 510 parse failures message 9: tested 2816 modifications, 510 parse failures message 10: tested 3584 modifications, 770 parse failures - message 11: tested 3328 modifications, 769 parse failures + message 11: tested 3328 modifications, 770 parse failures message 12: tested 54016 modifications, 4626 parse failures message 13: tested 11520 modifications, 1026 parse failures message 14: tested 5120 modifications, 1030 parse failures @@ -124,3 +180,17 @@ DLGSUP Stopping DLGSUP logging message 22: tested 5632 modifications, 771 parse failures message 23: tested 3584 modifications, 770 parse failures message 24: tested 3584 modifications, 771 parse failures + message 25: tested 11264 modifications, 2058 parse failures + message 26: tested 10240 modifications, 2060 parse failures + message 27: tested 13568 modifications, 2313 parse failures + message 28: tested 11264 modifications, 2058 parse failures + message 29: tested 10240 modifications, 2060 parse failures + message 30: tested 11264 modifications, 2058 parse failures + message 31: tested 11264 modifications, 2057 parse failures + message 32: tested 10240 modifications, 2060 parse failures + message 33: tested 11264 modifications, 2057 parse failures + message 34: tested 11264 modifications, 2058 parse failures + message 35: tested 11264 modifications, 2058 parse failures + message 36: tested 9472 modifications, 1803 parse failures + message 37: tested 6656 modifications, 1546 parse failures + message 38: tested 9472 modifications, 1803 parse failures diff --git a/tests/gsup/gsup_test.ok b/tests/gsup/gsup_test.ok index 70f723c0..db8bc2f6 100644 --- a/tests/gsup/gsup_test.ok +++ b/tests/gsup/gsup_test.ok @@ -49,4 +49,32 @@ Test GSUP message decoding/encoding Check IMEI Error OK Testing Check IMEI Result Check IMEI Result OK + Testing E Prepare Handover Request + E Prepare Handover Request OK + Testing E Prepare Handover Error + E Prepare Handover Error OK + Testing E Prepare Handover Result + E Prepare Handover Result OK + Testing E Prepare Subsequent Handover Request + E Prepare Subsequent Handover Request OK + Testing E Prepare Subsequent Handover Error + E Prepare Subsequent Handover Error OK + Testing E Prepare Subsequent Handover Result + E Prepare Subsequent Handover Result OK + Testing E Send End Signal Request + E Send End Signal Request OK + Testing E Send End Signal Error + E Send End Signal Error OK + Testing E Send End Signal Result + E Send End Signal Result OK + Testing E Process Access Signalling Request + E Process Access Signalling Request OK + Testing E Forward Access Signalling Request + E Forward Access Signalling Request OK + Testing E Close + E Close OK + Testing E Abort + E Abort OK + Testing E Routing Error + E Routing Error OK Done. |