[Done] SMS over SGs

This commit is contained in:
Sukchan Lee 2019-07-13 22:52:50 +09:00
parent 8e37f64c33
commit 7d42465f4e
21 changed files with 533 additions and 21 deletions

View File

@ -543,3 +543,30 @@ int emm_build_cs_service_notification(ogs_pkbuf_t **emmbuf, mme_ue_t *mme_ue)
return OGS_OK;
}
int emm_build_downlink_nas_transport(ogs_pkbuf_t **emmbuf, mme_ue_t *mme_ue,
uint8_t *buffer, uint8_t length)
{
nas_message_t message;
nas_downlink_nas_transport_t *downlink_nas_transport =
&message.emm.downlink_nas_transport;
nas_message_container_t *nas_message_container =
&downlink_nas_transport->nas_message_container;
ogs_assert(mme_ue);
memset(&message, 0, sizeof(message));
message.h.security_header_type =
NAS_SECURITY_HEADER_INTEGRITY_PROTECTED_AND_CIPHERED;
message.h.protocol_discriminator = NAS_PROTOCOL_DISCRIMINATOR_EMM;
message.emm.h.protocol_discriminator = NAS_PROTOCOL_DISCRIMINATOR_EMM;
message.emm.h.message_type = NAS_DOWNLINK_NAS_TRANSPORT;
nas_message_container->length = length;
memcpy(nas_message_container->buffer, buffer, length);
ogs_assert(nas_security_encode(emmbuf, mme_ue, &message) == OGS_OK &&
*emmbuf);
return OGS_OK;
}

View File

@ -51,6 +51,8 @@ int emm_build_service_reject(ogs_pkbuf_t **emmbuf,
nas_emm_cause_t emm_cause, mme_ue_t *mme_ue);
int emm_build_cs_service_notification(ogs_pkbuf_t **emmbuf, mme_ue_t *mme_ue);
int emm_build_downlink_nas_transport(ogs_pkbuf_t **emmbuf, mme_ue_t *mme_ue,
uint8_t *buffer, uint8_t length);
#ifdef __cplusplus
}

View File

@ -86,6 +86,7 @@ int emm_handle_attach_request(
*/
CLEAR_EPS_BEARER_ID(mme_ue);
CLEAR_PAGING_INFO(mme_ue);
CLEAR_SERVICE_INDICATOR(mme_ue);
if (SECURITY_CONTEXT_IS_VALID(mme_ue)) {
mme_kdf_enb(mme_ue->kasme, mme_ue->ul_count.i32, mme_ue->kenb);
mme_kdf_nh(mme_ue->kasme, mme_ue->kenb, mme_ue->nh);
@ -438,6 +439,7 @@ int emm_handle_tau_request(
* Update KeNB
*/
CLEAR_PAGING_INFO(mme_ue);
CLEAR_SERVICE_INDICATOR(mme_ue);
if (BEARER_CONTEXT_IS_ACTIVE(mme_ue))
ogs_debug(" Bearer-Active");
else

View File

@ -391,8 +391,10 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e)
OGS_FSM_TRAN(s, &emm_state_exception);
return;
}
rv = s1ap_send_initial_context_setup_request(mme_ue);
ogs_assert(rv == OGS_OK);
} else if (procedureCode == S1AP_ProcedureCode_id_uplinkNASTransport) {
ogs_debug(" Uplink NAS Transport");
if (mme_ue->nas_eps.service.service_type ==
@ -423,6 +425,8 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e)
ogs_fatal("Invalid Procedure Code[%d]", (int)procedureCode);
ogs_assert_if_reached();
}
CLEAR_SERVICE_INDICATOR(mme_ue);
break;
default:
ogs_fatal("Invalid NAS-EPS[%d]", mme_ue->nas_eps.type);

View File

@ -416,9 +416,14 @@ struct mme_ue_s {
#define MAX_NUM_OF_PAGING 2
uint32_t max_paging_retry;
#define CLEAR_SERVICE_INDICATOR(__mME) \
do { \
ogs_assert((__mME)); \
(__mME)->service_indicator = 0; \
} while(0);
#define SGSAP_CS_CALL_SERVICE_INDICATOR 1
#define SGSAP_SMS_SERVICE_INDICATOR 2
uint8_t service_indicator;
uint8_t service_indicator;
/* UE Radio Capability */
OCTET_STRING_t ueRadioCapability;

View File

@ -264,6 +264,8 @@ void mme_state_operational(ogs_fsm_t *s, mme_event_t *e)
ogs_fsm_dispatch(&mme_ue->sm, e);
if (OGS_FSM_CHECK(&mme_ue->sm, emm_state_exception)) {
CLEAR_SERVICE_INDICATOR(mme_ue);
rv = mme_send_delete_session_or_ue_context_release(
mme_ue, enb_ue);
ogs_assert(rv == OGS_OK);

View File

@ -474,3 +474,25 @@ int nas_send_cs_service_notification(mme_ue_t *mme_ue)
return OGS_OK;
}
int nas_send_downlink_nas_transport(
mme_ue_t *mme_ue, uint8_t *buffer, uint8_t length)
{
int rv;
ogs_pkbuf_t *emmbuf = NULL;
ogs_assert(mme_ue);
ogs_assert(buffer);
ogs_assert(length);
ogs_debug("[EMM] Downlink NAS transport");
ogs_debug(" IMSI[%s]", mme_ue->imsi_bcd);
rv = emm_build_downlink_nas_transport(&emmbuf, mme_ue, buffer, length);
ogs_assert(rv == OGS_OK && emmbuf);
rv = nas_send_to_downlink_nas_transport(mme_ue, emmbuf);
ogs_assert(rv == OGS_OK);
return OGS_OK;
}

View File

@ -59,6 +59,8 @@ int nas_send_tau_reject(mme_ue_t *mme_ue, nas_esm_cause_t emm_cause);
int nas_send_service_reject(mme_ue_t *mme_ue, nas_emm_cause_t emm_cause);
int nas_send_cs_service_notification(mme_ue_t *mme_ue);
int nas_send_downlink_nas_transport(
mme_ue_t *mme_ue, uint8_t *buffer, uint8_t length);
#ifdef __cplusplus
}

View File

@ -156,7 +156,11 @@ int nas_security_decode(mme_ue_t *mme_ue,
ogs_pkbuf_put_data(pkbuf, original_mac, SHORT_MAC_SIZE);
if (memcmp(mac + 2, pkbuf->data + 2, 2) != 0) {
ogs_warn("NAS MAC verification failed");
ogs_warn("NAS MAC verification failed(%x%x != %x%x)",
mac[2], mac[3],
((unsigned char *)pkbuf->data)[2],
((unsigned char *)pkbuf->data)[3]);
mme_ue->mac_failed = 1;
}

View File

@ -206,7 +206,7 @@ int s1ap_build_downlink_nas_transport(
ogs_assert(emmbuf);
ogs_assert(enb_ue);
ogs_debug("[MME] Downlink NAS transport");
ogs_debug("[MME] DownlinkNASTransport");
memset(&pdu, 0, sizeof (S1AP_S1AP_PDU_t));
pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
@ -1319,6 +1319,9 @@ int s1ap_build_paging(ogs_pkbuf_t **s1apbuf,
ogs_debug(" MME_CODE[%d] M_TMSI[0x%x]",
mme_ue->guti.mme_code, mme_ue->guti.m_tmsi);
ogs_debug(" CN_DOMAIN[%s]",
cn_domain == S1AP_CNDomain_cs ? "CS" :
cn_domain == S1AP_CNDomain_ps ? "PS" : "Unknown");
*CNDomain = cn_domain;

View File

@ -24,6 +24,8 @@
#include "s1ap-path.h"
#include "nas-path.h"
#include "mme-gtp-path.h"
#include "sgsap-types.h"
#include "sgsap-path.h"
#include "mme-s11-build.h"
#include "s1ap-build.h"
@ -514,6 +516,12 @@ void s1ap_handle_initial_context_setup_response(
ogs_assert(rv == OGS_OK);
}
}
if (mme_ue->service_indicator == SGSAP_SMS_SERVICE_INDICATOR) {
sgsap_send_service_request(mme_ue, SGSAP_EMM_CONNECTED_MODE);
}
CLEAR_SERVICE_INDICATOR(mme_ue);
}
void s1ap_handle_initial_context_setup_failure(

View File

@ -318,21 +318,102 @@ void sgsap_handle_paging_request(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf)
plmn_id_hexdump(&lai->nas_plmn_id), lai->lac);
}
if (ECM_IDLE(mme_ue))
s1ap_send_paging(mme_ue, S1AP_CNDomain_cs);
else
nas_send_cs_service_notification(mme_ue);
} else {
ogs_debug("[SGSAP] PAGING-REJECT");
ogs_debug(" IMSI[%s]", imsi_bcd);
if (ECM_IDLE(mme_ue)) {
if (mme_ue->service_indicator ==
SGSAP_CS_CALL_SERVICE_INDICATOR) {
/* UE will respond Extended Service Request in PS CNDomain*/
s1ap_send_paging(mme_ue, S1AP_CNDomain_cs);
sgsap_send_to_vlr_with_sid(
vlr,
sgsap_build_paging_reject(
nas_mobile_identity_imsi, nas_mobile_identity_imsi_len,
SGSAP_SGS_CAUSE_IMSI_UNKNOWN),
0);
} else if (mme_ue->service_indicator ==
SGSAP_SMS_SERVICE_INDICATOR) {
/* UE will respond Service Request in PS CNDomain*/
s1ap_send_paging(mme_ue, S1AP_CNDomain_ps);
} else
goto paging_reject;
} else {
nas_send_cs_service_notification(mme_ue);
}
return;
}
paging_reject:
ogs_debug("[SGSAP] PAGING-REJECT");
ogs_debug(" IMSI[%s]", imsi_bcd);
sgsap_send_to_vlr_with_sid(
vlr,
sgsap_build_paging_reject(
nas_mobile_identity_imsi, nas_mobile_identity_imsi_len,
SGSAP_SGS_CAUSE_IMSI_UNKNOWN),
0);
}
void sgsap_handle_downlink_unitdata(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf)
{
ogs_tlv_t *root = NULL, *iter = NULL;
mme_ue_t *mme_ue = NULL;
char imsi_bcd[MAX_IMSI_BCD_LEN+1];
nas_mobile_identity_imsi_t *nas_mobile_identity_imsi = NULL;
int nas_mobile_identity_imsi_len = 0;
uint8_t *nas_message_container_buffer = NULL;
uint8_t nas_message_container_length = 0;
ogs_assert(vlr);
ogs_assert(pkbuf);
ogs_debug("[SGSAP] DOWNLINK-UNITDATA");
ogs_pkbuf_pull(pkbuf, 1);
root = ogs_tlv_parse_block(pkbuf->len, pkbuf->data, OGS_TLV_MODE_T1_L1);
ogs_assert(root);
iter = root;
while (iter) {
switch (iter->type) {
case SGSAP_IE_IMSI_TYPE:
nas_mobile_identity_imsi = iter->value;
nas_mobile_identity_imsi_len = iter->length;
break;
case SGSAP_IE_NAS_MESSAGE_CONTAINER_TYPE:
nas_message_container_buffer = iter->value;
nas_message_container_length = iter->length;
break;
default:
ogs_warn("Invalid Type [%d]", iter->type);
break;
}
iter = iter->next;
}
ogs_tlv_free_all(root);
ogs_assert(nas_mobile_identity_imsi);
ogs_assert(nas_mobile_identity_imsi_len == SGSAP_IE_IMSI_LEN);
ogs_assert(nas_message_container_buffer);
ogs_assert(nas_message_container_length);
if (nas_mobile_identity_imsi->type == NAS_MOBILE_IDENTITY_IMSI) {
nas_imsi_to_bcd(nas_mobile_identity_imsi,
nas_mobile_identity_imsi_len, imsi_bcd);
mme_ue = mme_ue_find_by_imsi_bcd(imsi_bcd);
} else
ogs_assert_if_reached();
ogs_assert(mme_ue);
ogs_debug(" IMSI[%s]", mme_ue->imsi_bcd);
ogs_log_hexdump(OGS_LOG_DEBUG,
nas_message_container_buffer,
nas_message_container_length);
nas_send_downlink_nas_transport(mme_ue,
nas_message_container_buffer, nas_message_container_length);
}
void sgsap_handle_reset_indication(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf)

View File

@ -30,6 +30,7 @@ void sgsap_handle_location_update_accept(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf);
void sgsap_handle_location_update_reject(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf);
void sgsap_handle_detach_ack(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf);
void sgsap_handle_paging_request(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf);
void sgsap_handle_downlink_unitdata(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf);
void sgsap_handle_reset_indication(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf);
void sgsap_handle_release_request(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf);

View File

@ -130,6 +130,9 @@ void sgsap_state_connected(ogs_fsm_t *s, mme_event_t *e)
case SGSAP_PAGING_REQUEST:
sgsap_handle_paging_request(vlr, pkbuf);
break;
case SGSAP_DOWNLINK_UNITDATA:
sgsap_handle_downlink_unitdata(vlr, pkbuf);
break;
case SGSAP_RESET_INDICATION:
sgsap_handle_reset_indication(vlr, pkbuf);

View File

@ -45,7 +45,7 @@ testcsfb_SOURCES = \
csfb/abts-main.c csfb/test-app.c \
csfb/mo-idle-test.c csfb/mt-idle-test.c \
csfb/mo-active-test.c csfb/mt-active-test.c \
csfb/mo-sms-test.c \
csfb/mo-sms-test.c csfb/mt-sms-test.c \
$(NULL)
testcsfb_LDADD = $(top_srcdir)/src/libepc.la

View File

@ -3308,14 +3308,15 @@ int testsgsap_paging_request(ogs_pkbuf_t **pkbuf, int i)
"0101082926240000 111893021003766c 72076578616d706c 65036e6574200101"
"040509f1070926",
"0101082926240000 111892021003766c 72076578616d706c 65036e6574200101"
"040509f1070926",
"",
"040509f1070926", /* Paging-Reject */
"0101082926240000 111893021003766c 72076578616d706c 65036e6574200102"
"040509f1070926", /* Paging-Request with SMS */
};
uint16_t len[TESTS1AP_MAX_MESSAGE] = {
39,
39,
0,
39,
};
char hexbuf[MAX_SDU_LEN];
@ -3369,3 +3370,26 @@ int testsgsap_release_request(ogs_pkbuf_t **pkbuf, int i)
return OGS_OK;
}
int testsgsap_downlink_unitdata(ogs_pkbuf_t **pkbuf, int i)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"0701082926240000 1118931626090123 0100079144775810 0650001700048032"
"2400009160404044 150009c8329bfd06 4d9b53",
"",
"",
};
uint16_t len[TESTS1AP_MAX_MESSAGE] = {
51,
0,
0,
};
char hexbuf[MAX_SDU_LEN];
*pkbuf = ogs_pkbuf_alloc(NULL, MAX_SDU_LEN);
ogs_pkbuf_put_data(*pkbuf,
OGS_HEX(payload[i], strlen(payload[i]), hexbuf), len[i]);
return OGS_OK;
}

View File

@ -144,6 +144,7 @@ int testsgsap_imsi_detach_ack(ogs_pkbuf_t **pkbuf, int i);
int testsgsap_paging_request(ogs_pkbuf_t **pkbuf, int i);
int testsgsap_reset_indication(ogs_pkbuf_t **pkbuf, int i);
int testsgsap_release_request(ogs_pkbuf_t **pkbuf, int i);
int testsgsap_downlink_unitdata(ogs_pkbuf_t **pkbuf, int i);
#ifdef __cplusplus
}

View File

@ -34,6 +34,7 @@ abts_suite *test_mt_idle(abts_suite *suite);
abts_suite *test_mo_active(abts_suite *suite);
abts_suite *test_mt_active(abts_suite *suite);
abts_suite *test_mo_sms(abts_suite *suite);
abts_suite *test_mt_sms(abts_suite *suite);
const struct testlist {
abts_suite *(*func)(abts_suite *suite);
@ -43,6 +44,7 @@ const struct testlist {
{test_mo_active},
{test_mt_active},
{test_mo_sms},
{test_mt_sms},
{NULL},
};

View File

@ -254,7 +254,7 @@ static void test1_func(abts_case *tc, void *data)
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive Service Request */
/* Receive SGsAP-Service-Request */
recvbuf = testvlr_sgsap_read(sgsap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);

318
tests/csfb/mt-sms-test.c Normal file
View File

@ -0,0 +1,318 @@
#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"
extern ogs_socknode_t *sgsap;
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;
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);
/* Send SGsAP-Location-Update-Accept */
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);
/* Receive Initial Context Setup Request +
* Attach Accept +
* Activate Default Bearer Context 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,
1, 1, 5, 0x00460003, "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 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_pkbuf_free(recvbuf);
/* Receive SGsAP TMSI-REALLOCATION-COMPLETE */
recvbuf = testvlr_sgsap_read(sgsap);
ABTS_PTR_NOTNULL(tc, recvbuf);
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;
/* 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);
/* Send SGsAP-Paging-Request */
rv = testsgsap_paging_request(&sendbuf, 2);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testvlr_sgsap_send(sgsap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive S1AP Paging */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send Service Request */
rv = tests1ap_build_service_request(&sendbuf, 0x000200, 4, 0x6033, 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);
/* Receive SGsAP-Service-Request */
recvbuf = testvlr_sgsap_read(sgsap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send SGsAP-Downlink-Unitdata */
rv = testsgsap_downlink_unitdata(&sendbuf, 0);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testvlr_sgsap_send(sgsap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive Downlink NAS Transport */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send SGsAP-RELEASE-REQUEST */
rv = testsgsap_release_request(&sendbuf, 0);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testvlr_sgsap_send(sgsap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Send UE Context Release Request */
rv = tests1ap_build_ue_context_release_request(&sendbuf, msgindex+1);
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+1);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
ogs_msleep(300);
/********** 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);
}
abts_suite *test_mt_sms(abts_suite *suite)
{
suite = ADD_SUITE(suite)
abts_run_test(suite, test1_func, NULL);
return suite;
}

View File

@ -59,6 +59,7 @@ mt-idle-test : SUCCESS
mo-active-test : SUCCESS
mt-active-test : SUCCESS
mo-sms-test : SUCCESS
mt-sms-test : SUCCESS
All tests passed.
])
AT_CLEANUP