forked from acouzens/open5gs
Fix the AMF bug for double free
This commit is contained in:
parent
7afb914b9a
commit
94b44a3dd0
|
@ -3,6 +3,13 @@ db_uri: mongodb://localhost/open5gs
|
|||
logger:
|
||||
|
||||
parameter:
|
||||
# no_nrf: true
|
||||
# no_amf: true
|
||||
# no_smf: true
|
||||
# no_upf: true
|
||||
# no_ausf: true
|
||||
# no_udm: true
|
||||
# no_udr: true
|
||||
|
||||
amf:
|
||||
sbi:
|
||||
|
|
|
@ -4,6 +4,13 @@ logger:
|
|||
|
||||
parameter:
|
||||
no_ipv6: true
|
||||
# no_nrf: true
|
||||
# no_amf: true
|
||||
# no_smf: true
|
||||
# no_upf: true
|
||||
# no_ausf: true
|
||||
# no_udm: true
|
||||
# no_udr: true
|
||||
|
||||
mme:
|
||||
freeDiameter:
|
||||
|
|
|
@ -3,6 +3,13 @@ db_uri: mongodb://localhost/open5gs
|
|||
logger:
|
||||
|
||||
parameter:
|
||||
# no_nrf: true
|
||||
# no_amf: true
|
||||
# no_smf: true
|
||||
# no_upf: true
|
||||
# no_ausf: true
|
||||
# no_udm: true
|
||||
# no_udr: true
|
||||
|
||||
amf:
|
||||
sbi:
|
||||
|
|
|
@ -98,6 +98,8 @@ ogs_sbi_client_t *ogs_sbi_client_add(ogs_sockaddr_t *addr)
|
|||
ogs_assert(client);
|
||||
memset(client, 0, sizeof(ogs_sbi_client_t));
|
||||
|
||||
ogs_trace("ogs_sbi_client_add()");
|
||||
|
||||
ogs_copyaddrinfo(&client->addr, addr);
|
||||
|
||||
ogs_list_init(&client->connection_list);
|
||||
|
@ -124,10 +126,12 @@ void ogs_sbi_client_remove(ogs_sbi_client_t *client)
|
|||
/* ogs_sbi_client_t is always created with reference context */
|
||||
ogs_assert(client->reference_count > 0);
|
||||
|
||||
ogs_trace("client->reference_count = %d", client->reference_count);
|
||||
client->reference_count--;
|
||||
if (client->reference_count > 0)
|
||||
return;
|
||||
|
||||
ogs_trace("ogs_sbi_client_remove()");
|
||||
ogs_list_remove(&ogs_sbi_self()->client_list, client);
|
||||
|
||||
connection_remove_all(client);
|
||||
|
|
|
@ -35,6 +35,7 @@ extern "C" {
|
|||
if ((__cTX)->client != __pCLIENT) \
|
||||
__pCLIENT->reference_count++; \
|
||||
(__cTX)->client = __pCLIENT; \
|
||||
ogs_trace("client->reference_count = %d", __pCLIENT->reference_count); \
|
||||
} while(0)
|
||||
|
||||
typedef int (*ogs_sbi_client_cb_f)(ogs_sbi_response_t *response, void *data);
|
||||
|
|
|
@ -436,6 +436,7 @@ ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(char *id)
|
|||
memset(nf_instance, 0, sizeof(ogs_sbi_nf_instance_t));
|
||||
|
||||
nf_instance->reference_count++;
|
||||
ogs_trace("ogs_sbi_nf_instance_add()");
|
||||
|
||||
nf_instance->id = ogs_strdup(id);
|
||||
ogs_assert(nf_instance->id);
|
||||
|
@ -486,10 +487,13 @@ void ogs_sbi_nf_instance_remove(ogs_sbi_nf_instance_t *nf_instance)
|
|||
{
|
||||
ogs_assert(nf_instance);
|
||||
|
||||
ogs_trace("nf_instance->reference_count = %d",
|
||||
nf_instance->reference_count);
|
||||
nf_instance->reference_count--;
|
||||
if (nf_instance->reference_count > 0)
|
||||
return;
|
||||
|
||||
ogs_trace("ogs_sbi_nf_instance_remove()");
|
||||
ogs_list_remove(&ogs_sbi_self()->nf_instance_list, nf_instance);
|
||||
|
||||
ogs_sbi_subscription_remove_all_by_nf_instance_id(nf_instance->id);
|
||||
|
|
|
@ -57,6 +57,8 @@ typedef struct ogs_sbi_context_s {
|
|||
if ((__cTX)->nf_instance != __pNF_INSTANCE) \
|
||||
__pNF_INSTANCE->reference_count++; \
|
||||
(__cTX)->nf_instance = __pNF_INSTANCE; \
|
||||
ogs_trace("nf_instance->reference_count = %d", \
|
||||
__pNF_INSTANCE->reference_count); \
|
||||
} while(0)
|
||||
typedef struct ogs_sbi_nf_instance_s {
|
||||
ogs_lnode_t lnode;
|
||||
|
|
|
@ -524,7 +524,8 @@ int ogs_sbi_parse_header(
|
|||
message->h.method = header->method;
|
||||
message->h.uri = header->uri;
|
||||
ogs_assert(message->h.uri);
|
||||
ogs_debug("[%s] %s", message->h.method, message->h.uri);
|
||||
ogs_debug("[%s] %s", message->h.method ? message->h.method : "Notify",
|
||||
message->h.uri);
|
||||
|
||||
uri = ogs_strdup(header->uri);
|
||||
ogs_assert(uri);
|
||||
|
|
|
@ -395,7 +395,10 @@ void ogs_sbi_server_send_response(
|
|||
ogs_assert(request->poll);
|
||||
|
||||
ret = MHD_queue_response(connection, response->status, mhd_response);
|
||||
ogs_assert(ret == MHD_YES);
|
||||
if (ret != MHD_YES) {
|
||||
ogs_fatal("MHD_queue_response_error [%d]", ret);
|
||||
ogs_assert_if_reached();
|
||||
}
|
||||
MHD_destroy_response(mhd_response);
|
||||
}
|
||||
|
||||
|
|
|
@ -406,8 +406,16 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
|
|||
break;
|
||||
|
||||
CASE(OGS_SBI_RESOURCE_NAME_RELEASE)
|
||||
amf_nsmf_pdu_session_handle_release_sm_context(
|
||||
sess, &sbi_message);
|
||||
if (sbi_message.res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT ||
|
||||
sbi_message.res_status == OGS_SBI_HTTP_STATUS_OK) {
|
||||
ogs_info("[%s:%d] Release SM context [%d]",
|
||||
amf_ue->supi, sess->psi, sbi_message.res_status);
|
||||
} else {
|
||||
ogs_error("[%s] HTTP response error [%d]",
|
||||
amf_ue->supi, sbi_message.res_status);
|
||||
}
|
||||
|
||||
amf_nsmf_pdu_session_handle_release_sm_context(sess);
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
|
|
|
@ -389,6 +389,13 @@ typedef struct amf_sess_s {
|
|||
|
||||
#define SESSION_CONTEXT_IN_SMF(__sESS) \
|
||||
((__sESS) && (__sESS)->sm_context_ref)
|
||||
#define CLEAR_SM_CONTEXT_REF(__sESS) \
|
||||
do { \
|
||||
ogs_assert(__sESS); \
|
||||
ogs_assert((__sESS)->sm_context_ref); \
|
||||
ogs_free((__sESS)->sm_context_ref); \
|
||||
(__sESS)->sm_context_ref = NULL; \
|
||||
} while(0);
|
||||
char *sm_context_ref; /* smContextRef from SMF */
|
||||
|
||||
#define SESSION_SYNC_DONE(__aMF) \
|
||||
|
|
|
@ -958,6 +958,10 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue,
|
|||
OpenAPI_nf_type_SMF, sess, ¶m,
|
||||
amf_nsmf_pdu_session_build_update_sm_context);
|
||||
|
||||
if (gsm_header->message_type ==
|
||||
OGS_NAS_5GS_PDU_SESSION_RELEASE_COMPLETE) {
|
||||
CLEAR_SM_CONTEXT_REF(sess);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "namf-handler.h"
|
||||
#include "nsmf-handler.h"
|
||||
|
||||
#include "nas-path.h"
|
||||
#include "gmm-build.h"
|
||||
|
@ -227,8 +228,8 @@ int amf_namf_callback_handle_sm_context_status(
|
|||
}
|
||||
|
||||
if (StatusInfo->resource_status == OpenAPI_resource_status_RELEASED) {
|
||||
ogs_info("[%s:%d] Session Released", amf_ue->supi, sess->psi);
|
||||
amf_sess_remove(sess);
|
||||
ogs_info("[%s:%d] SM context status released", amf_ue->supi, sess->psi);
|
||||
amf_nsmf_pdu_session_handle_release_sm_context(sess);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
|
|
@ -358,19 +358,17 @@ int amf_nsmf_pdu_session_handle_update_sm_context(
|
|||
return OGS_OK;
|
||||
}
|
||||
|
||||
int amf_nsmf_pdu_session_handle_release_sm_context(
|
||||
amf_sess_t *sess, ogs_sbi_message_t *recvmsg)
|
||||
int amf_nsmf_pdu_session_handle_release_sm_context(amf_sess_t *sess)
|
||||
{
|
||||
amf_ue_t *amf_ue = NULL;
|
||||
|
||||
ogs_assert(sess);
|
||||
amf_ue = sess->amf_ue;
|
||||
ogs_assert(amf_ue);
|
||||
ogs_assert(recvmsg);
|
||||
|
||||
ogs_debug("Release SM Context [%d]", recvmsg->res_status);
|
||||
amf_sess_remove(sess);
|
||||
|
||||
if (SESSION_SYNC_DONE(amf_ue)) {
|
||||
if (ogs_list_count(&amf_ue->sess_list) == 0) {
|
||||
|
||||
if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_authentication)) {
|
||||
|
||||
|
@ -421,7 +419,5 @@ int amf_nsmf_pdu_session_handle_release_sm_context(
|
|||
}
|
||||
}
|
||||
|
||||
amf_sess_remove(sess);
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,7 @@ int amf_nsmf_pdu_session_handle_create_sm_context(
|
|||
amf_sess_t *sess, ogs_sbi_message_t *message);
|
||||
int amf_nsmf_pdu_session_handle_update_sm_context(
|
||||
amf_sess_t *sess, ogs_sbi_message_t *message);
|
||||
int amf_nsmf_pdu_session_handle_release_sm_context(
|
||||
amf_sess_t *sess, ogs_sbi_message_t *message);
|
||||
int amf_nsmf_pdu_session_handle_release_sm_context(amf_sess_t *sess);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -195,6 +195,8 @@ static void timeout(ogs_pfcp_xact_t *xact, void *data)
|
|||
smf_event_free(e);
|
||||
}
|
||||
break;
|
||||
case OGS_PFCP_ASSOCIATION_SETUP_REQUEST_TYPE:
|
||||
break;
|
||||
default:
|
||||
ogs_error("Not implemented [type:%d]", type);
|
||||
break;
|
||||
|
|
|
@ -724,8 +724,6 @@ static void test2_func(abts_case *tc, void *data)
|
|||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
ogs_msleep(100);
|
||||
|
||||
/* Send PDU session resource release complete */
|
||||
test_sess.ul_nas_transport_param.request_type = 0;
|
||||
test_sess.ul_nas_transport_param.dnn = 0;
|
||||
|
@ -741,8 +739,6 @@ static void test2_func(abts_case *tc, void *data)
|
|||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
ogs_msleep(100);
|
||||
|
||||
/* Send De-registration request */
|
||||
gmmbuf = testgmm_build_de_registration_request(&test_ue, 1);
|
||||
ABTS_PTR_NOTNULL(tc, gmmbuf);
|
||||
|
@ -874,12 +870,415 @@ static void test2_func(abts_case *tc, void *data)
|
|||
test_ue_remove(&test_ue);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void test3_func(abts_case *tc, void *data)
|
||||
{
|
||||
int rv;
|
||||
ogs_socknode_t *ngap;
|
||||
ogs_socknode_t *gtpu;
|
||||
ogs_pkbuf_t *gmmbuf;
|
||||
ogs_pkbuf_t *gsmbuf;
|
||||
ogs_pkbuf_t *nasbuf;
|
||||
ogs_pkbuf_t *sendbuf;
|
||||
ogs_pkbuf_t *recvbuf;
|
||||
ogs_ngap_message_t message;
|
||||
int i;
|
||||
int msgindex = 0;
|
||||
|
||||
ogs_nas_5gs_mobile_identity_suci_t mobile_identity_suci;
|
||||
test_ue_t test_ue;
|
||||
test_sess_t test_sess;
|
||||
|
||||
uint8_t tmp[OGS_MAX_SDU_LEN];
|
||||
|
||||
const char *_k_string = "70d49a71dd1a2b806a25abe0ef749f1e";
|
||||
uint8_t k[OGS_KEY_LEN];
|
||||
const char *_opc_string = "6f1bf53d624b3a43af6592854e2444c7";
|
||||
uint8_t opc[OGS_KEY_LEN];
|
||||
|
||||
mongoc_collection_t *collection = NULL;
|
||||
bson_t *doc = NULL;
|
||||
int64_t count = 0;
|
||||
bson_error_t error;
|
||||
const char *json =
|
||||
"{"
|
||||
"\"_id\" : { \"$oid\" : \"597223158b8861d7605378c6\" }, "
|
||||
"\"imsi\" : \"901700000021309\","
|
||||
"\"ambr\" : { "
|
||||
"\"uplink\" : { \"$numberLong\" : \"1024000\" }, "
|
||||
"\"downlink\" : { \"$numberLong\" : \"1024000\" } "
|
||||
"},"
|
||||
"\"pdn\" : ["
|
||||
"{"
|
||||
"\"apn\" : \"internet\", "
|
||||
"\"_id\" : { \"$oid\" : \"597223158b8861d7605378c7\" }, "
|
||||
"\"ambr\" : {"
|
||||
"\"uplink\" : { \"$numberLong\" : \"1024000\" }, "
|
||||
"\"downlink\" : { \"$numberLong\" : \"1024000\" } "
|
||||
"},"
|
||||
"\"qos\" : { "
|
||||
"\"qci\" : 9, "
|
||||
"\"arp\" : { "
|
||||
"\"priority_level\" : 8,"
|
||||
"\"pre_emption_vulnerability\" : 1, "
|
||||
"\"pre_emption_capability\" : 1"
|
||||
"} "
|
||||
"}, "
|
||||
"\"type\" : 2"
|
||||
"}"
|
||||
"],"
|
||||
"\"security\" : { "
|
||||
"\"k\" : \"70d49a71dd1a2b806a25abe0ef749f1e\", "
|
||||
"\"opc\" : \"6f1bf53d624b3a43af6592854e2444c7\", "
|
||||
"\"amf\" : \"8000\", "
|
||||
"\"sqn\" : { \"$numberLong\" : \"25235952177090\" } "
|
||||
"}, "
|
||||
"\"subscribed_rau_tau_timer\" : 12,"
|
||||
"\"network_access_mode\" : 2, "
|
||||
"\"subscriber_status\" : 0, "
|
||||
"\"access_restriction_data\" : 32, "
|
||||
"\"__v\" : 0 "
|
||||
"}";
|
||||
|
||||
/* Setup Test UE & Session Context */
|
||||
memset(&test_ue, 0, sizeof(test_ue));
|
||||
memset(&test_sess, 0, sizeof(test_sess));
|
||||
test_sess.test_ue = &test_ue;
|
||||
test_ue.sess = &test_sess;
|
||||
|
||||
test_ue.nas.registration.type = OGS_NAS_KSI_NO_KEY_IS_AVAILABLE;
|
||||
test_ue.nas.registration.follow_on_request = 1;
|
||||
test_ue.nas.registration.value = OGS_NAS_5GS_REGISTRATION_TYPE_INITIAL;
|
||||
|
||||
memset(&mobile_identity_suci, 0, sizeof(mobile_identity_suci));
|
||||
|
||||
mobile_identity_suci.h.supi_format = OGS_NAS_5GS_SUPI_FORMAT_IMSI;
|
||||
mobile_identity_suci.h.type = OGS_NAS_5GS_MOBILE_IDENTITY_SUCI;
|
||||
ogs_nas_from_plmn_id(&mobile_identity_suci.nas_plmn_id,
|
||||
&test_self()->tai.plmn_id);
|
||||
mobile_identity_suci.routing_indicator1 = 0;
|
||||
mobile_identity_suci.routing_indicator2 = 0xf;
|
||||
mobile_identity_suci.routing_indicator3 = 0xf;
|
||||
mobile_identity_suci.routing_indicator4 = 0xf;
|
||||
mobile_identity_suci.protection_scheme_id = OGS_NAS_5GS_NULL_SCHEME;
|
||||
mobile_identity_suci.home_network_pki_value = 0;
|
||||
mobile_identity_suci.scheme_output[0] = 0;
|
||||
mobile_identity_suci.scheme_output[1] = 0;
|
||||
mobile_identity_suci.scheme_output[2] = 0x20;
|
||||
mobile_identity_suci.scheme_output[3] = 0x31;
|
||||
mobile_identity_suci.scheme_output[4] = 0x90;
|
||||
|
||||
test_ue_set_mobile_identity_suci(&test_ue, &mobile_identity_suci, 13);
|
||||
|
||||
memset(&test_ue.mobile_identity_imeisv, 0,
|
||||
sizeof(ogs_nas_mobile_identity_imeisv_t));
|
||||
test_ue.mobile_identity_imeisv.type = OGS_NAS_5GS_MOBILE_IDENTITY_IMEISV;
|
||||
test_ue.mobile_identity_imeisv.odd_even = OGS_NAS_MOBILE_IDENTITY_EVEN;
|
||||
test_ue.mobile_identity_imeisv.digit1 = 8;
|
||||
test_ue.mobile_identity_imeisv.digit2 = 6;
|
||||
test_ue.mobile_identity_imeisv.digit3 = 6;
|
||||
test_ue.mobile_identity_imeisv.digit4 = 5;
|
||||
test_ue.mobile_identity_imeisv.digit5 = 0;
|
||||
test_ue.mobile_identity_imeisv.digit6 = 7;
|
||||
test_ue.mobile_identity_imeisv.digit7 = 0;
|
||||
test_ue.mobile_identity_imeisv.digit8 = 4;
|
||||
test_ue.mobile_identity_imeisv.digit9 = 0;
|
||||
test_ue.mobile_identity_imeisv.digit10 = 0;
|
||||
test_ue.mobile_identity_imeisv.digit11 = 4;
|
||||
test_ue.mobile_identity_imeisv.digit12 = 0;
|
||||
test_ue.mobile_identity_imeisv.digit13 = 5;
|
||||
test_ue.mobile_identity_imeisv.digit14 = 3;
|
||||
test_ue.mobile_identity_imeisv.digit15 = 0;
|
||||
test_ue.mobile_identity_imeisv.digit16 = 1;
|
||||
test_ue.mobile_identity_imeisv.digit17 = 0xf;
|
||||
|
||||
test_ue.nas.access_type = OGS_ACCESS_TYPE_3GPP;
|
||||
test_ue.abba_len = 2;
|
||||
|
||||
OGS_HEX(_k_string, strlen(_k_string), test_ue.k);
|
||||
OGS_HEX(_opc_string, strlen(_opc_string), test_ue.opc);
|
||||
|
||||
test_sess.psi = 5;
|
||||
test_sess.pti = 1;
|
||||
test_sess.pdu_session_type = OGS_PDU_SESSION_TYPE_IPV4V6;
|
||||
test_sess.dnn = (char *)"internet";
|
||||
|
||||
memset(&test_sess.gnb_n3_ip, 0, sizeof(test_sess.gnb_n3_ip));
|
||||
test_sess.gnb_n3_ip.ipv4 = true;
|
||||
test_sess.gnb_n3_ip.addr = inet_addr("127.0.0.5");
|
||||
test_sess.gnb_n3_teid = 0;
|
||||
|
||||
/* gNB connects to AMF */
|
||||
ngap = testgnb_ngap_client("127.0.0.2");
|
||||
ABTS_PTR_NOTNULL(tc, ngap);
|
||||
|
||||
/* gNB connects to UPF */
|
||||
gtpu = testgnb_gtpu_server("127.0.0.5");
|
||||
ABTS_PTR_NOTNULL(tc, gtpu);
|
||||
|
||||
/* Send NG-Setup Reqeust */
|
||||
sendbuf = testngap_build_ng_setup_request(0x4000, 26);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive NG-Setup Response */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/********** Insert Subscriber in Database */
|
||||
collection = mongoc_client_get_collection(
|
||||
ogs_mongoc()->client, ogs_mongoc()->name, "subscribers");
|
||||
ABTS_PTR_NOTNULL(tc, collection);
|
||||
doc = BCON_NEW("imsi", BCON_UTF8(test_ue.imsi));
|
||||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
|
||||
count = mongoc_collection_count (
|
||||
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
|
||||
if (count) {
|
||||
ABTS_TRUE(tc, mongoc_collection_remove(collection,
|
||||
MONGOC_REMOVE_SINGLE_REMOVE, doc, NULL, &error))
|
||||
}
|
||||
bson_destroy(doc);
|
||||
|
||||
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(test_ue.imsi));
|
||||
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);
|
||||
|
||||
for (i = 0; i < 1; i++) {
|
||||
/* Send Registration request */
|
||||
test_ue.registration_request_param.gmm_capability = 0;
|
||||
gmmbuf = testgmm_build_registration_request(&test_ue, NULL);
|
||||
ABTS_PTR_NOTNULL(tc, gmmbuf);
|
||||
|
||||
test_ue.registration_request_param.gmm_capability = 1;
|
||||
test_ue.registration_request_param.requested_nssai = 1;
|
||||
test_ue.registration_request_param.last_visited_registered_tai = 1;
|
||||
test_ue.registration_request_param.ue_usage_setting = 1;
|
||||
nasbuf = testgmm_build_registration_request(&test_ue, NULL);
|
||||
ABTS_PTR_NOTNULL(tc, nasbuf);
|
||||
|
||||
sendbuf = testngap_build_initial_ue_message(&test_ue, gmmbuf, false);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive Authentication request */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/* Send Authentication response */
|
||||
gmmbuf = testgmm_build_authentication_response(&test_ue);
|
||||
ABTS_PTR_NOTNULL(tc, gmmbuf);
|
||||
sendbuf = testngap_build_uplink_nas_transport(&test_ue, gmmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive Security mode command */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/* Send Security mode complete */
|
||||
gmmbuf = testgmm_build_security_mode_complete(&test_ue, nasbuf);
|
||||
ABTS_PTR_NOTNULL(tc, gmmbuf);
|
||||
sendbuf = testngap_build_uplink_nas_transport(&test_ue, gmmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive Initial context setup request */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/* Send UE radio capability info indication */
|
||||
sendbuf = testngap_build_ue_radio_capability_info_indication(&test_ue);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Send Initial context setup response */
|
||||
sendbuf = testngap_build_initial_context_setup_response(&test_ue, NULL);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
ogs_msleep(100);
|
||||
|
||||
/* Send Registration complete */
|
||||
gmmbuf = testgmm_build_registration_complete(&test_ue);
|
||||
ABTS_PTR_NOTNULL(tc, gmmbuf);
|
||||
sendbuf = testngap_build_uplink_nas_transport(&test_ue, gmmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive Configuration update command */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/* Send PDU session establishment request */
|
||||
test_sess.ul_nas_transport_param.request_type =
|
||||
OGS_NAS_5GS_REQUEST_TYPE_INITIAL;
|
||||
test_sess.ul_nas_transport_param.dnn = 1;
|
||||
test_sess.ul_nas_transport_param.s_nssai = 1;
|
||||
|
||||
gsmbuf = testgsm_build_pdu_session_establishment_request(&test_sess);
|
||||
ABTS_PTR_NOTNULL(tc, gsmbuf);
|
||||
gmmbuf = testgmm_build_ul_nas_transport(&test_sess,
|
||||
OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, gsmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, gmmbuf);
|
||||
sendbuf = testngap_build_uplink_nas_transport(&test_ue, gmmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive PDU session establishment accept */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/* Send GTP-U ICMP Packet */
|
||||
rv = test_gtpu_build_ping(&sendbuf, &test_sess, "10.45.0.1");
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
rv = testgnb_gtpu_send(gtpu, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Send PDU session resource setup response */
|
||||
ogs_msleep(100);
|
||||
|
||||
sendbuf =
|
||||
testngap_build_pdu_session_resource_setup_response(&test_sess);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive GTP-U ICMP Packet */
|
||||
recvbuf = testgnb_gtpu_read(gtpu);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
|
||||
/* Send GTP-U ICMP Packet */
|
||||
rv = test_gtpu_build_ping(&sendbuf, &test_sess, "10.45.0.1");
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
rv = testgnb_gtpu_send(gtpu, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive GTP-U ICMP Packet */
|
||||
recvbuf = testgnb_gtpu_read(gtpu);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
|
||||
ogs_msleep(100);
|
||||
|
||||
/* Send PDU Session release request */
|
||||
test_sess.ul_nas_transport_param.request_type = 0;
|
||||
test_sess.ul_nas_transport_param.dnn = 0;
|
||||
test_sess.ul_nas_transport_param.s_nssai = 0;
|
||||
|
||||
gsmbuf = testgsm_build_pdu_session_release_request(&test_sess);
|
||||
ABTS_PTR_NOTNULL(tc, gsmbuf);
|
||||
gmmbuf = testgmm_build_ul_nas_transport(&test_sess,
|
||||
OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, gsmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, gmmbuf);
|
||||
sendbuf = testngap_build_uplink_nas_transport(&test_ue, gmmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive PDU session release command */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/* Send PDU session resource release response */
|
||||
sendbuf =
|
||||
testngap_build_pdu_session_resource_release_response(&test_sess);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Send PDU session resource release complete */
|
||||
test_sess.ul_nas_transport_param.request_type = 0;
|
||||
test_sess.ul_nas_transport_param.dnn = 0;
|
||||
test_sess.ul_nas_transport_param.s_nssai = 0;
|
||||
|
||||
gsmbuf = testgsm_build_pdu_session_release_complete(&test_sess);
|
||||
ABTS_PTR_NOTNULL(tc, gsmbuf);
|
||||
gmmbuf = testgmm_build_ul_nas_transport(&test_sess,
|
||||
OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, gsmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, gmmbuf);
|
||||
sendbuf = testngap_build_uplink_nas_transport(&test_ue, gmmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Send De-registration request */
|
||||
gmmbuf = testgmm_build_de_registration_request(&test_ue, 1);
|
||||
ABTS_PTR_NOTNULL(tc, gmmbuf);
|
||||
sendbuf = testngap_build_uplink_nas_transport(&test_ue, gmmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive UE context release command */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/* Send UE context release complete */
|
||||
sendbuf = testngap_build_ue_context_release_complete(&test_ue);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
ogs_msleep(100);
|
||||
}
|
||||
|
||||
/********** Remove Subscriber in Database */
|
||||
doc = BCON_NEW("imsi", BCON_UTF8(test_ue.imsi));
|
||||
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);
|
||||
|
||||
/* gNB disonncect from UPF */
|
||||
testgnb_gtpu_close(gtpu);
|
||||
|
||||
/* gNB disonncect from AMF */
|
||||
testgnb_ngap_close(ngap);
|
||||
|
||||
/* Clear Test UE Context */
|
||||
test_ue_remove(&test_ue);
|
||||
}
|
||||
#endif
|
||||
|
||||
abts_suite *test_dereg(abts_suite *suite)
|
||||
{
|
||||
suite = ADD_SUITE(suite)
|
||||
|
||||
abts_run_test(suite, test1_func, NULL);
|
||||
abts_run_test(suite, test2_func, NULL);
|
||||
#if 0
|
||||
abts_run_test(suite, test3_func, NULL);
|
||||
#endif
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue