add initial test code for idle-mode
This commit is contained in:
parent
10096d2a3c
commit
b96f06b63a
|
@ -51,7 +51,7 @@ static void nas_sm_test1(abts_case *tc, void *data)
|
|||
|
||||
mongoc_collection_t *collection = NULL;
|
||||
bson_error_t error;
|
||||
const char *json =
|
||||
const char *json =
|
||||
"{"
|
||||
"\"_id\" : { \"$oid\" : \"597223158b8861d7605378c6\" }, "
|
||||
"\"imsi\" : \"001010123456819\", "
|
||||
|
@ -95,7 +95,7 @@ static void nas_sm_test1(abts_case *tc, void *data)
|
|||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
|
||||
collection = mongoc_client_get_collection(
|
||||
context_self()->db_client,
|
||||
context_self()->db_client,
|
||||
context_self()->db_name, "subscribers");
|
||||
ABTS_PTR_NOTNULL(tc, collection);
|
||||
|
||||
|
@ -151,7 +151,7 @@ static void nas_sm_test1(abts_case *tc, void *data)
|
|||
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
rc = tests1ap_enb_read(sock, recvbuf);
|
||||
recvbuf->len = 43;
|
||||
ABTS_TRUE(tc, memcmp(recvbuf->payload,
|
||||
ABTS_TRUE(tc, memcmp(recvbuf->payload,
|
||||
CORE_HEX(_security_mode_command, strlen(_security_mode_command), tmp),
|
||||
recvbuf->len) == 0);
|
||||
ABTS_INT_NEQUAL(tc, 0, rc);
|
||||
|
@ -252,7 +252,7 @@ static void nas_sm_test2(abts_case *tc, void *data)
|
|||
|
||||
mongoc_collection_t *collection = NULL;
|
||||
bson_error_t error;
|
||||
const char *json =
|
||||
const char *json =
|
||||
"{"
|
||||
"\"_id\" : { \"$oid\" : \"597223158b8861d7605378c6\" }, "
|
||||
"\"imsi\" : \"001010123456826\", "
|
||||
|
@ -296,7 +296,7 @@ static void nas_sm_test2(abts_case *tc, void *data)
|
|||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
|
||||
collection = mongoc_client_get_collection(
|
||||
context_self()->db_client,
|
||||
context_self()->db_client,
|
||||
context_self()->db_name, "subscribers");
|
||||
ABTS_PTR_NOTNULL(tc, collection);
|
||||
|
||||
|
@ -416,12 +416,241 @@ static void nas_sm_test2(abts_case *tc, void *data)
|
|||
mongoc_collection_destroy(collection);
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
* Attach -> Release -> Service Request */
|
||||
static void nas_sm_test3(abts_case *tc, void *data)
|
||||
{
|
||||
status_t rv;
|
||||
net_sock_t *sock;
|
||||
pkbuf_t *sendbuf;
|
||||
pkbuf_t *recvbuf;
|
||||
s1ap_message_t message;
|
||||
int rc;
|
||||
int i;
|
||||
int msgindex = 2;
|
||||
|
||||
c_uint8_t tmp[MAX_SDU_LEN];
|
||||
char *_authentication_request =
|
||||
"000b"
|
||||
"403b000003000000 05c0020000c80008 00020002001a0025 2407520042200639"
|
||||
"1c0021554d444928 4a1a062e10e543cb 257f1f800021f4f9 2d522a5b87";
|
||||
char *_security_mode_command =
|
||||
"000b"
|
||||
"4027000003000000 05c0020000c80008 00020002001a0011 103744bcbbd20007"
|
||||
"5d010005f0f00000 00";
|
||||
|
||||
char *_esm_information_request =
|
||||
"000b"
|
||||
"4020000003000000 05c0020000c80008 00020002001a000a 09277330e06c0102"
|
||||
"01d9";
|
||||
|
||||
char *_initial_context_setup_request =
|
||||
"00090080c8000006 00000005c0020000 c800080002000200 42000a183e800000"
|
||||
"603e800000001800 7700003400724540 0920000000000000 00000f800a0123d8"
|
||||
"000000035b27a23a 27b4020742024906 4000f1102b670032 5201c10509ffffff"
|
||||
"ff0908696e746572 6e657405012d2d2d 035e060000000004 04270f80000d0408"
|
||||
"080808000d040404 0404500bf600f110 0002010000000353 12172c5949640125"
|
||||
"006b00051e000e00 000049002040964d eb63a0afb5d0d374 c1da505f6252d1f9"
|
||||
"05ff9c6791b8503a 032c6effa7";
|
||||
|
||||
char *_emm_information =
|
||||
"000b"
|
||||
"402a000003000000 05c0020000c80008 00020002001a0014 1327dc833e850307"
|
||||
"6147717042911120 8a490100";
|
||||
|
||||
mongoc_collection_t *collection = NULL;
|
||||
bson_error_t error;
|
||||
const char *json =
|
||||
"{"
|
||||
"\"_id\" : { \"$oid\" : \"597223158b8861d7605378c6\" }, "
|
||||
"\"imsi\" : \"001010123456797\", "
|
||||
"\"pdn\" : ["
|
||||
"{"
|
||||
"\"apn\" : \"internet\", "
|
||||
"\"_id\" : { \"$oid\" : \"597223158b8861d7605378c7\" }, "
|
||||
"\"pdn_ambr\" : {"
|
||||
"\"max_bandwidth_ul\" : 1024000, "
|
||||
"\"max_bandwidth_dl\" : 1024000 "
|
||||
"},"
|
||||
"\"qos\" : { "
|
||||
"\"qci\" : 9, "
|
||||
"\"arp\" : { "
|
||||
"\"priority_level\" : 8,"
|
||||
"\"pre_emption_vulnerability\" : 1, "
|
||||
"\"pre_emption_capability\" : 1"
|
||||
"} "
|
||||
"}, "
|
||||
"\"type\" : 0"
|
||||
"}"
|
||||
"],"
|
||||
"\"ue_ambr\" : { "
|
||||
"\"max_bandwidth_ul\" : 1024000, "
|
||||
"\"max_bandwidth_dl\" : 1024000 "
|
||||
"},"
|
||||
"\"subscribed_rau_tau_timer\" : 12,"
|
||||
"\"network_access_mode\" : 2, "
|
||||
"\"subscriber_status\" : 0, "
|
||||
"\"access_restriction_data\" : 32, "
|
||||
"\"security\" : { "
|
||||
"\"k\" : \"465B5CE8 B199B49F AA5F0A2E E238A6BC\", "
|
||||
"\"op\" : \"5F1D289C 5D354D0A 140C2548 F5F3E3BA\", "
|
||||
"\"amf\" : \"8000\", "
|
||||
"\"sqn\" : { \"$numberLong\" : \"64\" }, "
|
||||
"\"rand\" : \"42200639 1c002155 4d444928 4a1a062e\" "
|
||||
"}, "
|
||||
"\"__v\" : 0 "
|
||||
"}";
|
||||
bson_t *doc = bson_new_from_json((const uint8_t *)json, -1, &error);;
|
||||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
|
||||
collection = mongoc_client_get_collection(
|
||||
context_self()->db_client,
|
||||
context_self()->db_name, "subscribers");
|
||||
ABTS_PTR_NOTNULL(tc, collection);
|
||||
|
||||
ABTS_TRUE(tc, mongoc_collection_insert(collection,
|
||||
MONGOC_INSERT_NONE, doc, NULL, &error));
|
||||
bson_destroy(doc);
|
||||
|
||||
d_log_set_level(D_MSG_TO_STDOUT, D_LOG_LEVEL_ERROR);
|
||||
|
||||
/* eNB connects to MME */
|
||||
sock = tests1ap_enb_connect();
|
||||
ABTS_PTR_NOTNULL(tc, sock);
|
||||
|
||||
/* Send S1-Setup Reqeust */
|
||||
rv = tests1ap_build_setup_req(&sendbuf, 0x54f64);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* Receive S1-Setup Response */
|
||||
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
rc = tests1ap_enb_read(sock, recvbuf);
|
||||
ABTS_INT_NEQUAL(tc, 0, rc);
|
||||
rv = s1ap_decode_pdu(&message, recvbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
s1ap_free_pdu(&message);
|
||||
pkbuf_free(recvbuf);
|
||||
|
||||
/* Send Initial-UE Message */
|
||||
mme_self()->mme_ue_s1ap_id = 33554631;
|
||||
rv = tests1ap_build_initial_ue_msg(&sendbuf, msgindex);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* Receive Authentication Request */
|
||||
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
rc = tests1ap_enb_read(sock, recvbuf);
|
||||
ABTS_INT_NEQUAL(tc, 0, rc);
|
||||
recvbuf->len = 63;
|
||||
ABTS_TRUE(tc, memcmp(recvbuf->payload,
|
||||
CORE_HEX(_authentication_request, strlen(_authentication_request), tmp),
|
||||
recvbuf->len) == 0);
|
||||
pkbuf_free(recvbuf);
|
||||
|
||||
/* Send Authentication Response */
|
||||
rv = tests1ap_build_authentication_response(&sendbuf, msgindex);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* Receive Security mode Command */
|
||||
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
rc = tests1ap_enb_read(sock, recvbuf);
|
||||
recvbuf->len = 43;
|
||||
ABTS_TRUE(tc, memcmp(recvbuf->payload,
|
||||
CORE_HEX(_security_mode_command, strlen(_security_mode_command), tmp),
|
||||
recvbuf->len) == 0);
|
||||
ABTS_INT_NEQUAL(tc, 0, rc);
|
||||
pkbuf_free(recvbuf);
|
||||
|
||||
/* Send Security mode Complete */
|
||||
rv = tests1ap_build_security_mode_complete(&sendbuf, msgindex);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* Receive ESM Information Request */
|
||||
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
rc = tests1ap_enb_read(sock, recvbuf);
|
||||
recvbuf->len = 36;
|
||||
ABTS_TRUE(tc, memcmp(recvbuf->payload,
|
||||
CORE_HEX(_esm_information_request, strlen(_security_mode_command), tmp),
|
||||
recvbuf->len) == 0);
|
||||
pkbuf_free(recvbuf);
|
||||
|
||||
/* Send ESM Information Response */
|
||||
rv = tests1ap_build_esm_information_response(&sendbuf, msgindex);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* Receive Initial Context Setup Request +
|
||||
* Attach Accept +
|
||||
* Activate Default Bearer Context Request */
|
||||
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
rc = tests1ap_enb_read(sock, recvbuf);
|
||||
recvbuf->len = 205;
|
||||
ABTS_TRUE(tc, memcmp(recvbuf->payload,
|
||||
CORE_HEX(_initial_context_setup_request,
|
||||
strlen(_initial_context_setup_request), tmp),
|
||||
recvbuf->len) == 0);
|
||||
pkbuf_free(recvbuf);
|
||||
|
||||
/* Send UE Capability Info Indication */
|
||||
rv = tests1ap_build_ue_capability_info_indication(&sendbuf, msgindex);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
core_sleep(time_from_msec(300));
|
||||
|
||||
/* Send Initial Context Setup Response */
|
||||
rv = tests1ap_build_initial_context_setup_response(&sendbuf, msgindex);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* Send Attach Complete + Activate default EPS bearer cotext accept */
|
||||
rv = tests1ap_build_attach_complete(&sendbuf, msgindex);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* Receive EMM information */
|
||||
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
rc = tests1ap_enb_read(sock, recvbuf);
|
||||
recvbuf->len = 46;
|
||||
CORE_HEX(_emm_information, strlen(_emm_information), tmp);
|
||||
ABTS_TRUE(tc, memcmp(recvbuf->payload, tmp, 28) == 0);
|
||||
ABTS_TRUE(tc, memcmp(recvbuf->payload+43, tmp+43, 3) == 0);
|
||||
pkbuf_free(recvbuf);
|
||||
|
||||
/* eNB disonncect from MME */
|
||||
rv = tests1ap_enb_close(sock);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
core_sleep(time_from_msec(300));
|
||||
d_log_set_level(D_MSG_TO_STDOUT, D_LOG_LEVEL_FULL);
|
||||
|
||||
doc = BCON_NEW("imsi", BCON_UTF8("001010123456797"));
|
||||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
ABTS_TRUE(tc, mongoc_collection_remove(collection,
|
||||
MONGOC_REMOVE_SINGLE_REMOVE, doc, NULL, &error))
|
||||
bson_destroy(doc);
|
||||
|
||||
mongoc_collection_destroy(collection);
|
||||
}
|
||||
|
||||
abts_suite *test_nas_sm(abts_suite *suite)
|
||||
{
|
||||
suite = ADD_SUITE(suite)
|
||||
|
||||
abts_run_test(suite, nas_sm_test1, NULL);
|
||||
abts_run_test(suite, nas_sm_test2, NULL);
|
||||
abts_run_test(suite, nas_sm_test3, NULL);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -125,10 +125,16 @@ status_t tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i)
|
|||
"600021023cd011d1 271a808021100100 0010810600000000 830600000000000d"
|
||||
"00000a005c0a0090 11034f18a6f15d01 00004300060000f1 1030390064400800"
|
||||
"00f110002343d000 86400130",
|
||||
|
||||
"000c"
|
||||
"404c000005000800 020002001a002423 0741710809101010 3254767905f0f000"
|
||||
"0000000e0201d011 d1270780000a0000 0d00c10043000600 00f1102b67006440"
|
||||
"080000f11054f640 100086400130",
|
||||
};
|
||||
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
|
||||
92,
|
||||
108,
|
||||
80,
|
||||
};
|
||||
char hexbuf[MAX_SDU_LEN];
|
||||
|
||||
|
@ -150,12 +156,17 @@ status_t tests1ap_build_authentication_response(pkbuf_t **pkbuf, int i)
|
|||
"5ba0",
|
||||
|
||||
"000d403500000500 0000020001000800 02001f001a000c0b 07530831c964f076"
|
||||
"1378760064400800 00f110002343d000 4340060000f11030 39"
|
||||
"1378760064400800 00f110002343d000 4340060000f11030 39",
|
||||
|
||||
"000d"
|
||||
"4038000005000000 05c0020000c80008 00020002001a000c 0b0753087dc78e7c"
|
||||
"421f9eb900644008 0000f11054f64010 004340060000f110 2b67",
|
||||
};
|
||||
|
||||
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
|
||||
66,
|
||||
57,
|
||||
60,
|
||||
};
|
||||
char hexbuf[MAX_SDU_LEN];
|
||||
|
||||
|
@ -178,10 +189,15 @@ status_t tests1ap_build_security_mode_complete(pkbuf_t **pkbuf, int i)
|
|||
"000d403200000500 0000020001000800 02001f001a000908 473c0c819e00075e"
|
||||
"006440080000f110 002343d000434006 0000f1103039",
|
||||
|
||||
"000d"
|
||||
"4035000005000000 05c0020000c80008 00020002001a0009 0847c0eb1eb80007"
|
||||
"5e006440080000f1 1054f64010004340 060000f1102b67",
|
||||
|
||||
};
|
||||
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
|
||||
57,
|
||||
54,
|
||||
57,
|
||||
};
|
||||
char hexbuf[MAX_SDU_LEN];
|
||||
|
||||
|
@ -206,11 +222,17 @@ status_t tests1ap_build_esm_information_response(pkbuf_t **pkbuf, int i)
|
|||
|
||||
"000d403e00000500 0000020001000800 02001f001a001514 27505a0b5301023c"
|
||||
"da280908696e7465 726e657400644008 0000f110002343d0 004340060000f110"
|
||||
"3039"
|
||||
"3039",
|
||||
|
||||
"000d"
|
||||
"4041000005000000 05c0020000c80008 00020002001a0015 142793b2bedc0102"
|
||||
"01da280908696e74 65726e6574006440 080000f11054f640 10004340060000f1"
|
||||
"102b67"
|
||||
};
|
||||
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
|
||||
146,
|
||||
66,
|
||||
69,
|
||||
};
|
||||
char hexbuf[MAX_SDU_LEN];
|
||||
|
||||
|
@ -235,11 +257,17 @@ status_t tests1ap_build_ue_capability_info_indication(pkbuf_t **pkbuf, int i)
|
|||
"0831c1a53432b259 ef989007000cdd9c 6331200e0019a332 c662401c003200",
|
||||
|
||||
"0016402d00000300 0000020001000800 02001f004a401a19 00b801014c598080"
|
||||
"9c000bf06ec4d001 40302c0000000000 000000"
|
||||
"9c000bf06ec4d001 40302c0000000000 000000",
|
||||
|
||||
"0016"
|
||||
"403f000003000000 05c0020000c80008 00020002004a4029 28013001023cd980"
|
||||
"00bc000ff06ec4d0 0141b82c00000000 07d404000ef08020 00012a0300008800"
|
||||
"00",
|
||||
};
|
||||
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
|
||||
161,
|
||||
51,
|
||||
67,
|
||||
};
|
||||
char hexbuf[MAX_SDU_LEN];
|
||||
|
||||
|
@ -262,10 +290,16 @@ status_t tests1ap_build_initial_context_setup_response(pkbuf_t **pkbuf, int i)
|
|||
|
||||
"2009002200000300 0040020001000840 02001f0033400f00 0032400a0a1f0a01"
|
||||
"23c501000508",
|
||||
|
||||
"2009"
|
||||
"0025000003000040 05c0020000c80008 400200020033400f 000032400a0a1f0a"
|
||||
"0123a701000008",
|
||||
|
||||
};
|
||||
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
|
||||
41,
|
||||
38,
|
||||
41,
|
||||
};
|
||||
char hexbuf[MAX_SDU_LEN];
|
||||
|
||||
|
@ -281,14 +315,20 @@ status_t tests1ap_build_initial_context_setup_response(pkbuf_t **pkbuf, int i)
|
|||
|
||||
status_t tests1ap_build_attach_complete(pkbuf_t **pkbuf, int i)
|
||||
{
|
||||
char *payload[TESTS1AP_MAX_MESSAGE] = { "000d"
|
||||
char *payload[TESTS1AP_MAX_MESSAGE] = {
|
||||
"000d"
|
||||
"403a000005000000 05c00100009d0008 00020001001a000e 0d27c183eb950207"
|
||||
"4300035200c20064 40080000f1101079 baf0004340060000 f1105ba0",
|
||||
"",
|
||||
|
||||
"000d"
|
||||
"403a000005000000 05c0020000c80008 00020002001a000e 0d27f190fc2b0207"
|
||||
"4300035200c20064 40080000f11054f6 4010004340060000 f1102b67",
|
||||
};
|
||||
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
|
||||
62,
|
||||
0,
|
||||
62,
|
||||
};
|
||||
char hexbuf[MAX_SDU_LEN];
|
||||
|
||||
|
|
Loading…
Reference in New Issue