open5gs/tests/csfb/csfb-test.c

565 lines
19 KiB
C
Raw Normal View History

2019-06-15 10:37:34 +00:00
#include <mongoc.h>
#include "core/abts.h"
#include "app/context.h"
#include "mme/mme-context.h"
#include "mme/s1ap-build.h"
#include "asn1c/s1ap-message.h"
#include "test-packet.h"
2019-06-20 09:20:32 +00:00
extern ogs_socknode_t *sgsap;
2019-06-15 10:37:34 +00:00
static void test1_func(abts_case *tc, void *data)
{
int rv;
ogs_socknode_t *s1ap;
ogs_pkbuf_t *sendbuf;
ogs_pkbuf_t *recvbuf;
s1ap_message_t message;
int i;
2019-06-15 12:18:16 +00:00
int msgindex = 18;
2019-06-15 10:37:34 +00:00
enb_ue_t *enb_ue = NULL;
mme_ue_t *mme_ue = NULL;
uint32_t m_tmsi = 0;
uint8_t tmp[MAX_SDU_LEN];
2019-06-15 12:18:16 +00:00
char *_identity_request =
"000b401700000300 0000020001000800 020001001a000403 075501";
2019-06-15 10:37:34 +00:00
char *_authentication_request =
2019-06-15 12:18:16 +00:00
"000b403800000300 0000020001000800 020001001a002524 075200aa266700bc"
"2887354e9f87368d 5d0ae710ab857af5 5f1a8000d71e5537 4ee176e9";
2019-06-15 10:37:34 +00:00
char *_security_mode_command =
2019-06-15 12:18:16 +00:00
"000b402400000300 0000020001000800 020001001a001110 378ccbca6000075d"
"010005f0f0c04070";
2019-06-15 10:37:34 +00:00
char *_esm_information_request =
2019-06-15 12:18:16 +00:00
"000b401d00000300 0000020001000800 020001001a000a09 27d1237969010234"
"d9";
2019-06-21 09:23:29 +00:00
char *_sgsap_location_update_request =
"0901082926240000 1118930937066d6d 65633031096d6d65 676930303032036d"
"6d6503657063066d 6e63303730066d63 633930310b336770 706e6574776f726b"
"036f72670a010104 0509f1070926";
2019-06-15 10:37:34 +00:00
char *_initial_context_setup_request =
"00090080d7000006 0000000200010008 000200010042000a 183d090000603d09"
"0000001800808800 0034008082450009 230f807f00000200 0000017327283f4c"
"6102074202490620 09f1070007004152 34c101090908696e 7465726e65740501"
"2d2d00025e06fefe e2e2030327228080 2110020000108106 0808080883060808"
"0404000d04080808 08000d0408080404 500bf609f1070002 01d20064c31309f1"
"0709262305f49ee8 8e64594964010100 6b00051c000e0000 00490020f9f4f80b"
"206c33ae286c6daf f4c253585174c3a0 a12a661967f5e1ba 0a686c8c";
2019-06-15 10:37:34 +00:00
char *_emm_information =
2019-06-15 12:18:16 +00:00
"000b403800000300 0000020001000800 020001001a002524 2751034124030761"
"430f10004e006500 7800740045005000 4347916051216124 63490100";
2019-06-22 03:11:07 +00:00
char *_sgsap_tmsi_reallocation_complete =
"0c01082926240000 111893";
2019-06-15 10:37:34 +00:00
mongoc_collection_t *collection = NULL;
bson_t *doc = NULL;
int64_t count = 0;
bson_error_t error;
const char *json =
"{"
"\"_id\" : { \"$oid\" : \"310014158b8861d7605378c6\" }, "
"\"imsi\" : \"262420000118139\", "
2019-06-15 10:37:34 +00:00
"\"pdn\" : ["
"{"
2019-06-15 12:18:16 +00:00
"\"apn\" : \"internet\", "
2019-06-15 10:37:34 +00:00
"\"_id\" : { \"$oid\" : \"310014158b8861d7605378c7\" }, "
"\"ambr\" : {"
"\"uplink\" : { \"$numberLong\" : \"1000000\" }, "
"\"downlink\" : { \"$numberLong\" : \"1000000\" } "
"},"
"\"qos\" : { "
"\"qci\" : 9, "
"\"arp\" : { "
2019-06-15 12:18:16 +00:00
"\"priority_level\" : 8,"
2019-06-15 10:37:34 +00:00
"\"pre_emption_vulnerability\" : 0, "
2019-06-15 12:18:16 +00:00
"\"pre_emption_capability\" : 0"
2019-06-15 10:37:34 +00:00
"} "
"}, "
"\"type\" : 2"
"}"
"],"
"\"ambr\" : { "
"\"uplink\" : { \"$numberLong\" : \"1000000\" }, "
"\"downlink\" : { \"$numberLong\" : \"1000000\" } "
"},"
"\"subscribed_rau_tau_timer\" : 12,"
"\"network_access_mode\" : 2, "
"\"subscriber_status\" : 0, "
"\"access_restriction_data\" : 32, "
"\"security\" : { "
2019-06-15 12:18:16 +00:00
"\"k\" : \"70D49A71DD1A2B806A25ABE0EF749F1E\", "
"\"opc\" : \"6F1BF53D624B3A43AF6592854E2444C7\", "
2019-06-15 10:37:34 +00:00
"\"amf\" : \"8000\", "
2019-06-15 12:18:16 +00:00
"\"sqn\" : { \"$numberLong\" : \"2374\" }, "
"\"rand\" : \"aa266700bc2887354e9f87368d5d0ae7\" "
2019-06-15 10:37:34 +00:00
"}, "
"\"__v\" : 0 "
"}";
/* eNB connects to MME */
s1ap = testenb_s1ap_client("127.0.0.1");
ABTS_PTR_NOTNULL(tc, s1ap);
/* Send S1-Setup Reqeust */
rv = tests1ap_build_setup_req(
2019-06-15 12:18:16 +00:00
&sendbuf, S1AP_ENB_ID_PR_macroENB_ID, 0x0019b0, 7, 901, 70, 2);
2019-06-15 10:37:34 +00:00
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive S1-Setup Response */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
rv = s1ap_decode_pdu(&message, recvbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
s1ap_free_pdu(&message);
ogs_pkbuf_free(recvbuf);
collection = mongoc_client_get_collection(
context_self()->db.client,
context_self()->db.name, "subscribers");
ABTS_PTR_NOTNULL(tc, collection);
/********** Insert Subscriber in Database */
doc = bson_new_from_json((const uint8_t *)json, -1, &error);;
ABTS_PTR_NOTNULL(tc, doc);
ABTS_TRUE(tc, mongoc_collection_insert(collection,
MONGOC_INSERT_NONE, doc, NULL, &error));
bson_destroy(doc);
doc = BCON_NEW("imsi", BCON_UTF8("262420000118139"));
2019-06-15 10:37:34 +00:00
ABTS_PTR_NOTNULL(tc, doc);
2019-06-21 09:23:29 +00:00
do {
2019-06-15 10:37:34 +00:00
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
bson_destroy(doc);
2019-06-15 12:18:16 +00:00
/* Send Attach Request */
2019-07-05 06:55:07 +00:00
mme_self()->mme_ue_s1ap_id = 0;
2019-06-15 10:37:34 +00:00
rv = tests1ap_build_initial_ue_msg(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
2019-06-15 12:18:16 +00:00
/* Receive Identity-Request */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ABTS_TRUE(tc, memcmp(recvbuf->data,
OGS_HEX(_identity_request, strlen(_identity_request), tmp),
recvbuf->len) == 0);
ogs_pkbuf_free(recvbuf);
/* Send Identity Response */
rv = tests1ap_build_identity_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
2019-06-15 10:37:34 +00:00
/* Receive Authentication Request */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ABTS_TRUE(tc, memcmp(recvbuf->data,
OGS_HEX(_authentication_request, strlen(_authentication_request), tmp),
recvbuf->len) == 0);
ogs_pkbuf_free(recvbuf);
/* Send Authentication Response */
rv = tests1ap_build_authentication_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive Security mode Command */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ABTS_TRUE(tc, memcmp(recvbuf->data,
OGS_HEX(_security_mode_command, strlen(_security_mode_command), tmp),
recvbuf->len) == 0);
ogs_pkbuf_free(recvbuf);
/* Send Security mode Complete */
rv = tests1ap_build_security_mode_complete(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive ESM Information Request */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ABTS_TRUE(tc, memcmp(recvbuf->data,
OGS_HEX(_esm_information_request, strlen(_security_mode_command), tmp),
recvbuf->len) == 0);
ogs_pkbuf_free(recvbuf);
/* Send ESM Information Response */
rv = tests1ap_build_esm_information_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
2019-06-20 12:22:51 +00:00
/* Receive SGsAP-Location-Update-Request */
2019-06-20 09:20:32 +00:00
recvbuf = testvlr_sgsap_read(sgsap);
ABTS_PTR_NOTNULL(tc, recvbuf);
2019-06-21 09:23:29 +00:00
ABTS_TRUE(tc, memcmp(recvbuf->data,
OGS_HEX(_sgsap_location_update_request,
strlen(_sgsap_location_update_request), tmp),
recvbuf->len) == 0);
2019-06-20 09:20:32 +00:00
ogs_pkbuf_free(recvbuf);
2019-06-20 12:22:51 +00:00
2019-06-21 09:23:29 +00:00
/* Send SGsAP-Location-Update-Accept */
2019-06-21 15:28:21 +00:00
rv = testsgsap_location_update_accept(&sendbuf, 0);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testvlr_sgsap_send(sgsap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
2019-06-21 09:23:29 +00:00
2019-06-15 10:37:34 +00:00
/* Receive Initial Context Setup Request +
* Attach Accept +
* Activate Default Bearer Context Request */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
OGS_HEX(_initial_context_setup_request,
strlen(_initial_context_setup_request), tmp);
ABTS_TRUE(tc, memcmp(recvbuf->data, tmp, 61) == 0);
ABTS_TRUE(tc, memcmp(recvbuf->data+65, tmp+65, 88) == 0);
ABTS_TRUE(tc, memcmp(recvbuf->data+157, tmp+157, 63) == 0);
2019-06-15 10:37:34 +00:00
ogs_pkbuf_free(recvbuf);
/* Send Initial Context Setup Response */
rv = tests1ap_build_initial_context_setup_response(&sendbuf,
2019-06-15 12:18:16 +00:00
1, 1, 5, 0x00460003, "127.0.0.5");
2019-06-15 10:37:34 +00:00
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Send Attach Complete + Activate default EPS bearer cotext accept */
rv = tests1ap_build_attach_complete(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive EMM information */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
OGS_HEX(_emm_information, strlen(_emm_information), tmp);
2019-06-15 14:28:52 +00:00
ABTS_TRUE(tc, memcmp(recvbuf->data, tmp, 25) == 0);
2019-07-01 01:00:50 +00:00
ABTS_TRUE(tc, memcmp(recvbuf->data+29, tmp+29, 21) == 0);
2019-06-22 03:11:07 +00:00
ogs_pkbuf_free(recvbuf);
/* Receive SGsAP TMSI-REALLOCATION-COMPLETE */
recvbuf = testvlr_sgsap_read(sgsap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ABTS_TRUE(tc, memcmp(recvbuf->data,
OGS_HEX(_sgsap_tmsi_reallocation_complete,
strlen(_sgsap_tmsi_reallocation_complete), tmp),
recvbuf->len) == 0);
2019-06-15 10:37:34 +00:00
ogs_pkbuf_free(recvbuf);
/* Retreive M-TMSI */
enb_ue = enb_ue_find_by_mme_ue_s1ap_id(1);
ogs_assert(enb_ue);
mme_ue = enb_ue->mme_ue;
ogs_assert(mme_ue);
m_tmsi = mme_ue->guti.m_tmsi;
2019-06-15 14:28:52 +00:00
/* Send UE Context Release Request */
rv = tests1ap_build_ue_context_release_request(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive UE Context Release Command */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send UE Context Release Complete */
rv = tests1ap_build_ue_context_release_complete(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
2019-07-06 13:16:13 +00:00
/* Send Extended Service Request */
rv = tests1ap_build_extended_service_request(&sendbuf,
msgindex, m_tmsi, 4, mme_ue->knas_int);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Initial Context Setup Request */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send Initial Context Setup Response */
rv = tests1ap_build_initial_context_setup_response(&sendbuf,
2, 2, 5, 0x00470003, "127.0.0.5");
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
#if 0
2019-06-15 14:28:52 +00:00
/* Send Service Request */
rv = tests1ap_build_service_request(&sendbuf, 0x000200, 3, 0xc340, m_tmsi);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive Initial Context Setup Request */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send Initial Context Setup Response */
rv = tests1ap_build_initial_context_setup_response(&sendbuf,
2, 2, 5, 0x00470003, "127.0.0.5");
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Send Detach Request */
rv = tests1ap_build_detach_request(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
2019-07-05 09:13:32 +00:00
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive SGsAP IMSI-DETACH-INDICATION */
recvbuf = testvlr_sgsap_read(sgsap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send SGsAP IMSI-DETACH-ACK */
rv = testsgsap_imsi_detach_ack(&sendbuf, 0);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testvlr_sgsap_send(sgsap, sendbuf);
2019-06-15 14:28:52 +00:00
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive UE Context Release Command */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send UE Context Release Complete */
rv = tests1ap_build_ue_context_release_complete(&sendbuf, msgindex+1);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
2019-07-06 13:16:13 +00:00
#endif
2019-06-15 10:37:34 +00:00
/********** Remove Subscriber in Database */
doc = BCON_NEW("imsi", BCON_UTF8("262420000118139"));
2019-06-15 10:37:34 +00:00
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);
/* eNB disonncect from MME */
testenb_s1ap_close(s1ap);
2019-07-05 06:55:07 +00:00
}
static void test2_func(abts_case *tc, void *data)
{
int rv;
ogs_socknode_t *s1ap;
ogs_pkbuf_t *sendbuf;
ogs_pkbuf_t *recvbuf;
s1ap_message_t message;
int i;
int msgindex = 18;
enb_ue_t *enb_ue = NULL;
mme_ue_t *mme_ue = NULL;
uint32_t m_tmsi = 0;
mongoc_collection_t *collection = NULL;
bson_t *doc = NULL;
int64_t count = 0;
bson_error_t error;
const char *json =
"{"
"\"_id\" : { \"$oid\" : \"310014158b8861d7605378c6\" }, "
"\"imsi\" : \"262420000118139\", "
"\"pdn\" : ["
"{"
"\"apn\" : \"internet\", "
"\"_id\" : { \"$oid\" : \"310014158b8861d7605378c7\" }, "
"\"ambr\" : {"
"\"uplink\" : { \"$numberLong\" : \"1000000\" }, "
"\"downlink\" : { \"$numberLong\" : \"1000000\" } "
"},"
"\"qos\" : { "
"\"qci\" : 9, "
"\"arp\" : { "
"\"priority_level\" : 8,"
"\"pre_emption_vulnerability\" : 0, "
"\"pre_emption_capability\" : 0"
"} "
"}, "
"\"type\" : 2"
"}"
"],"
"\"ambr\" : { "
"\"uplink\" : { \"$numberLong\" : \"1000000\" }, "
"\"downlink\" : { \"$numberLong\" : \"1000000\" } "
"},"
"\"subscribed_rau_tau_timer\" : 12,"
"\"network_access_mode\" : 2, "
"\"subscriber_status\" : 0, "
"\"access_restriction_data\" : 32, "
"\"security\" : { "
"\"k\" : \"70D49A71DD1A2B806A25ABE0EF749F1E\", "
"\"opc\" : \"6F1BF53D624B3A43AF6592854E2444C7\", "
"\"amf\" : \"8000\", "
"\"sqn\" : { \"$numberLong\" : \"2374\" }, "
"\"rand\" : \"aa266700bc2887354e9f87368d5d0ae7\" "
"}, "
"\"__v\" : 0 "
"}";
/* eNB connects to MME */
s1ap = testenb_s1ap_client("127.0.0.1");
ABTS_PTR_NOTNULL(tc, s1ap);
/* Send S1-Setup Reqeust */
rv = tests1ap_build_setup_req(
&sendbuf, S1AP_ENB_ID_PR_macroENB_ID, 0x0019b0, 7, 901, 70, 2);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive S1-Setup Response */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
rv = s1ap_decode_pdu(&message, recvbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
s1ap_free_pdu(&message);
ogs_pkbuf_free(recvbuf);
collection = mongoc_client_get_collection(
context_self()->db.client,
context_self()->db.name, "subscribers");
ABTS_PTR_NOTNULL(tc, collection);
/********** Insert Subscriber in Database */
doc = bson_new_from_json((const uint8_t *)json, -1, &error);;
ABTS_PTR_NOTNULL(tc, doc);
ABTS_TRUE(tc, mongoc_collection_insert(collection,
MONGOC_INSERT_NONE, doc, NULL, &error));
bson_destroy(doc);
doc = BCON_NEW("imsi", BCON_UTF8("262420000118139"));
ABTS_PTR_NOTNULL(tc, doc);
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
bson_destroy(doc);
/* Send Attach Request */
mme_self()->mme_ue_s1ap_id = 0;
rv = tests1ap_build_initial_ue_msg(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive Identity-Request */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send Identity Response */
rv = tests1ap_build_identity_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive Authentication Request */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send Authentication Response */
rv = tests1ap_build_authentication_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive Security mode Command */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send Security mode Complete */
rv = tests1ap_build_security_mode_complete(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive ESM Information Request */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send ESM Information Response */
rv = tests1ap_build_esm_information_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive SGsAP-Location-Update-Request */
recvbuf = testvlr_sgsap_read(sgsap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
2019-06-15 10:37:34 +00:00
2019-07-05 06:55:07 +00:00
/* Send SGsAP-Location-Update-Reject */
rv = testsgsap_location_update_reject(&sendbuf, 0);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testvlr_sgsap_send(sgsap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive Attach Reject */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Receive UE Release Command */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send UE Context Release Complete */
rv = tests1ap_build_ue_context_release_complete(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/********** Remove Subscriber in Database */
doc = BCON_NEW("imsi", BCON_UTF8("262420000118139"));
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);
/* eNB disonncect from MME */
testenb_s1ap_close(s1ap);
2019-06-15 10:37:34 +00:00
}
abts_suite *test_csfb(abts_suite *suite)
{
suite = ADD_SUITE(suite)
abts_run_test(suite, test1_func, NULL);
2019-07-06 13:16:13 +00:00
#if 0
2019-07-05 06:55:07 +00:00
abts_run_test(suite, test2_func, NULL);
2019-07-06 13:16:13 +00:00
#endif
2019-06-15 10:37:34 +00:00
return suite;
}