Refactor for the UERANSIM 500 test (#1652)
This commit is contained in:
parent
f35afa2ff7
commit
9aa5559c5f
|
@ -1448,12 +1448,6 @@ void ogs_sbi_xact_remove(ogs_sbi_xact_t *xact)
|
|||
|
||||
ogs_assert(xact);
|
||||
|
||||
xact = ogs_pool_cycle(&xact_pool, xact);
|
||||
if (!xact) {
|
||||
ogs_error("SBI transaction has already been removed");
|
||||
return;
|
||||
}
|
||||
|
||||
sbi_object = xact->sbi_object;
|
||||
ogs_assert(sbi_object);
|
||||
|
||||
|
@ -1477,6 +1471,11 @@ void ogs_sbi_xact_remove_all(ogs_sbi_object_t *sbi_object)
|
|||
ogs_sbi_xact_remove(xact);
|
||||
}
|
||||
|
||||
ogs_sbi_xact_t *ogs_sbi_xact_cycle(ogs_sbi_xact_t *xact)
|
||||
{
|
||||
return ogs_pool_cycle(&xact_pool, xact);
|
||||
}
|
||||
|
||||
ogs_sbi_subscription_t *ogs_sbi_subscription_add(void)
|
||||
{
|
||||
ogs_sbi_subscription_t *subscription = NULL;
|
||||
|
|
|
@ -348,6 +348,7 @@ ogs_sbi_xact_t *ogs_sbi_xact_add(
|
|||
void (*timer_cb)(void *data));
|
||||
void ogs_sbi_xact_remove(ogs_sbi_xact_t *xact);
|
||||
void ogs_sbi_xact_remove_all(ogs_sbi_object_t *sbi_object);
|
||||
ogs_sbi_xact_t *ogs_sbi_xact_cycle(ogs_sbi_xact_t *xact);
|
||||
|
||||
ogs_sbi_subscription_t *ogs_sbi_subscription_add(void);
|
||||
void ogs_sbi_subscription_set_id(
|
||||
|
|
|
@ -357,6 +357,14 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
|
|||
sbi_xact = e->sbi.data;
|
||||
ogs_assert(sbi_xact);
|
||||
|
||||
sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
|
||||
if (!sbi_xact) {
|
||||
/* CLIENT_WAIT timer could remove SBI transaction
|
||||
* before receiving SBI message */
|
||||
ogs_error("SBI transaction has already been removed");
|
||||
break;
|
||||
}
|
||||
|
||||
amf_ue = (amf_ue_t *)sbi_xact->sbi_object;
|
||||
ogs_assert(amf_ue);
|
||||
|
||||
|
@ -380,6 +388,14 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
|
|||
sbi_xact = e->sbi.data;
|
||||
ogs_assert(sbi_xact);
|
||||
|
||||
sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
|
||||
if (!sbi_xact) {
|
||||
/* CLIENT_WAIT timer could remove SBI transaction
|
||||
* before receiving SBI message */
|
||||
ogs_error("SBI transaction has already been removed");
|
||||
break;
|
||||
}
|
||||
|
||||
state = sbi_xact->state;
|
||||
|
||||
ogs_sbi_xact_remove(sbi_xact);
|
||||
|
@ -489,6 +505,14 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
|
|||
sbi_xact = e->sbi.data;
|
||||
ogs_assert(sbi_xact);
|
||||
|
||||
sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
|
||||
if (!sbi_xact) {
|
||||
/* CLIENT_WAIT timer could remove SBI transaction
|
||||
* before receiving SBI message */
|
||||
ogs_error("SBI transaction has already been removed");
|
||||
break;
|
||||
}
|
||||
|
||||
sess = (amf_sess_t *)sbi_xact->sbi_object;
|
||||
ogs_assert(sess);
|
||||
|
||||
|
@ -584,7 +608,7 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
|
|||
}
|
||||
|
||||
ogs_error("[%s] Cannot receive SBI message", amf_ue->suci);
|
||||
ogs_assert(OGS_OK ==
|
||||
ogs_expect(OGS_OK ==
|
||||
nas_5gs_send_gmm_reject_from_sbi(amf_ue,
|
||||
OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT));
|
||||
break;
|
||||
|
@ -601,12 +625,12 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
|
|||
ogs_error("[%d:%d] Cannot receive SBI message",
|
||||
sess->psi, sess->pti);
|
||||
if (sess->payload_container_type) {
|
||||
ogs_assert(OGS_OK ==
|
||||
ogs_expect(OGS_OK ==
|
||||
nas_5gs_send_back_gsm_message(sess,
|
||||
OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED,
|
||||
AMF_NAS_BACKOFF_TIME));
|
||||
} else {
|
||||
ogs_assert(OGS_OK ==
|
||||
ogs_expect(OGS_OK ==
|
||||
ngap_send_error_indication2(amf_ue,
|
||||
NGAP_Cause_PR_transport,
|
||||
NGAP_CauseTransport_transport_resource_unavailable)
|
||||
|
@ -825,7 +849,7 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
|
|||
/* De-associate NG with NAS/EMM */
|
||||
ran_ue_deassociate(amf_ue->ran_ue);
|
||||
|
||||
ogs_assert(OGS_OK ==
|
||||
ogs_expect(OGS_OK ==
|
||||
ngap_send_ran_ue_context_release_command(amf_ue->ran_ue,
|
||||
NGAP_Cause_PR_nas, NGAP_CauseNas_normal_release,
|
||||
NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0));
|
||||
|
|
|
@ -21,23 +21,28 @@
|
|||
#include "context.h"
|
||||
|
||||
static OGS_POOL(pool, amf_event_t);
|
||||
static ogs_thread_mutex_t amf_event_alloc_mutex;
|
||||
|
||||
void amf_event_init(void)
|
||||
{
|
||||
ogs_pool_init(&pool, ogs_app()->pool.event);
|
||||
ogs_thread_mutex_init(&amf_event_alloc_mutex);
|
||||
}
|
||||
|
||||
void amf_event_final(void)
|
||||
{
|
||||
ogs_pool_final(&pool);
|
||||
ogs_thread_mutex_destroy(&amf_event_alloc_mutex);
|
||||
}
|
||||
|
||||
amf_event_t *amf_event_new(amf_event_e id)
|
||||
{
|
||||
amf_event_t *e = NULL;
|
||||
|
||||
ogs_thread_mutex_lock(&amf_event_alloc_mutex);
|
||||
ogs_pool_alloc(&pool, &e);
|
||||
if (!e) return NULL;
|
||||
ogs_thread_mutex_unlock(&amf_event_alloc_mutex);
|
||||
ogs_assert(e);
|
||||
memset(e, 0, sizeof(*e));
|
||||
|
||||
e->id = id;
|
||||
|
@ -48,7 +53,9 @@ amf_event_t *amf_event_new(amf_event_e id)
|
|||
void amf_event_free(amf_event_t *e)
|
||||
{
|
||||
ogs_assert(e);
|
||||
ogs_thread_mutex_lock(&amf_event_alloc_mutex);
|
||||
ogs_pool_free(&pool, e);
|
||||
ogs_thread_mutex_unlock(&amf_event_alloc_mutex);
|
||||
}
|
||||
|
||||
const char *amf_event_get_name(amf_event_t *e)
|
||||
|
|
|
@ -24,38 +24,40 @@
|
|||
|
||||
int nas_5gs_send_to_gnb(amf_ue_t *amf_ue, ogs_pkbuf_t *pkbuf)
|
||||
{
|
||||
ran_ue_t *ran_ue = NULL;
|
||||
ogs_assert(pkbuf);
|
||||
|
||||
ogs_assert(amf_ue);
|
||||
ran_ue = ran_ue_cycle(amf_ue->ran_ue);
|
||||
ogs_expect_or_return_val(ran_ue, OGS_ERROR);
|
||||
amf_ue = amf_ue_cycle(amf_ue);
|
||||
if (!amf_ue) {
|
||||
ogs_warn("UE(amf-ue) context has already been removed");
|
||||
ogs_pkbuf_free(pkbuf);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return ngap_send_to_ran_ue(ran_ue, pkbuf);
|
||||
return ngap_send_to_ran_ue(amf_ue->ran_ue, pkbuf);
|
||||
}
|
||||
|
||||
int nas_5gs_send_to_downlink_nas_transport(amf_ue_t *amf_ue, ogs_pkbuf_t *pkbuf)
|
||||
{
|
||||
int rv;
|
||||
ogs_pkbuf_t *ngapbuf = NULL;
|
||||
ran_ue_t *ran_ue = NULL;
|
||||
|
||||
ogs_assert(pkbuf);
|
||||
ogs_assert(amf_ue);
|
||||
ran_ue = ran_ue_cycle(amf_ue->ran_ue);
|
||||
if (!ran_ue) {
|
||||
ogs_warn("NG context has already been removed");
|
||||
|
||||
amf_ue = amf_ue_cycle(amf_ue);
|
||||
if (!amf_ue) {
|
||||
ogs_warn("UE(amf-ue) context has already been removed");
|
||||
ogs_pkbuf_free(pkbuf);
|
||||
return OGS_OK;
|
||||
} else {
|
||||
ngapbuf = ngap_build_downlink_nas_transport(
|
||||
ran_ue, pkbuf, false, false);
|
||||
ogs_expect_or_return_val(ngapbuf, OGS_ERROR);
|
||||
|
||||
rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf);
|
||||
ogs_expect(rv == OGS_OK);
|
||||
|
||||
return rv;
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
ngapbuf = ngap_build_downlink_nas_transport(
|
||||
amf_ue->ran_ue, pkbuf, false, false);
|
||||
ogs_expect_or_return_val(ngapbuf, OGS_ERROR);
|
||||
|
||||
rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf);
|
||||
ogs_expect(rv == OGS_OK);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int nas_5gs_send_registration_accept(amf_ue_t *amf_ue)
|
||||
|
|
|
@ -4022,7 +4022,8 @@ void ngap_handle_ng_reset(
|
|||
* where PartOfNG_interface was requested
|
||||
* REMOVED */
|
||||
ogs_assert(gnb->ng_reset_ack);
|
||||
ngap_send_to_gnb(gnb, gnb->ng_reset_ack, NGAP_NON_UE_SIGNALLING);
|
||||
ogs_expect(OGS_OK ==
|
||||
ngap_send_to_gnb(gnb, gnb->ng_reset_ack, NGAP_NON_UE_SIGNALLING));
|
||||
|
||||
/* Clear NG-Reset Ack Buffer */
|
||||
gnb->ng_reset_ack = NULL;
|
||||
|
|
|
@ -50,15 +50,15 @@ int ngap_send_to_gnb(amf_gnb_t *gnb, ogs_pkbuf_t *pkbuf, uint16_t stream_no)
|
|||
{
|
||||
char buf[OGS_ADDRSTRLEN];
|
||||
|
||||
ogs_assert(gnb);
|
||||
ogs_assert(pkbuf);
|
||||
|
||||
gnb = amf_gnb_cycle(gnb);
|
||||
if (!gnb) {
|
||||
ogs_warn("gNB has already been removed");
|
||||
ogs_pkbuf_free(pkbuf);
|
||||
return OGS_OK;
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
ogs_assert(pkbuf);
|
||||
ogs_assert(gnb->sctp.sock);
|
||||
if (gnb->sctp.sock->fd == INVALID_SOCKET) {
|
||||
ogs_fatal("gNB SCTP socket has already been destroyed");
|
||||
|
@ -83,13 +83,16 @@ int ngap_send_to_gnb(amf_gnb_t *gnb, ogs_pkbuf_t *pkbuf, uint16_t stream_no)
|
|||
|
||||
int ngap_send_to_ran_ue(ran_ue_t *ran_ue, ogs_pkbuf_t *pkbuf)
|
||||
{
|
||||
amf_gnb_t *gnb = NULL;
|
||||
ogs_assert(pkbuf);
|
||||
|
||||
ogs_assert(ran_ue);
|
||||
gnb = ran_ue->gnb;
|
||||
ogs_assert(gnb);
|
||||
ran_ue = ran_ue_cycle(ran_ue);
|
||||
if (!ran_ue) {
|
||||
ogs_warn("NG context has already been removed");
|
||||
ogs_pkbuf_free(pkbuf);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return ngap_send_to_gnb(gnb, pkbuf, ran_ue->gnb_ostream_id);
|
||||
return ngap_send_to_gnb(ran_ue->gnb, pkbuf, ran_ue->gnb_ostream_id);
|
||||
}
|
||||
|
||||
int ngap_delayed_send_to_ran_ue(
|
||||
|
|
|
@ -667,8 +667,9 @@ int amf_nsmf_pdusession_handle_update_sm_context(
|
|||
* where PartOfNG_interface was requested
|
||||
* REMOVED */
|
||||
ogs_assert(gnb->ng_reset_ack);
|
||||
ngap_send_to_gnb(
|
||||
gnb, gnb->ng_reset_ack, NGAP_NON_UE_SIGNALLING);
|
||||
ogs_expect(OGS_OK ==
|
||||
ngap_send_to_gnb(gnb,
|
||||
gnb->ng_reset_ack, NGAP_NON_UE_SIGNALLING));
|
||||
|
||||
/* Clear NG-Reset Ack Buffer */
|
||||
gnb->ng_reset_ack = NULL;
|
||||
|
|
|
@ -279,6 +279,14 @@ void ausf_state_operational(ogs_fsm_t *s, ausf_event_t *e)
|
|||
sbi_xact = e->sbi.data;
|
||||
ogs_assert(sbi_xact);
|
||||
|
||||
sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
|
||||
if (!sbi_xact) {
|
||||
/* CLIENT_WAIT timer could remove SBI transaction
|
||||
* before receiving SBI message */
|
||||
ogs_error("SBI transaction has already been removed");
|
||||
break;
|
||||
}
|
||||
|
||||
ausf_ue = (ausf_ue_t *)sbi_xact->sbi_object;
|
||||
ogs_assert(ausf_ue);
|
||||
|
||||
|
|
|
@ -395,6 +395,14 @@ void pcf_state_operational(ogs_fsm_t *s, pcf_event_t *e)
|
|||
sbi_xact = e->sbi.data;
|
||||
ogs_assert(sbi_xact);
|
||||
|
||||
sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
|
||||
if (!sbi_xact) {
|
||||
/* CLIENT_WAIT timer could remove SBI transaction
|
||||
* before receiving SBI message */
|
||||
ogs_error("SBI transaction has already been removed");
|
||||
break;
|
||||
}
|
||||
|
||||
pcf_ue = (pcf_ue_t *)sbi_xact->sbi_object;
|
||||
ogs_assert(pcf_ue);
|
||||
|
||||
|
@ -423,6 +431,14 @@ void pcf_state_operational(ogs_fsm_t *s, pcf_event_t *e)
|
|||
sbi_xact = e->sbi.data;
|
||||
ogs_assert(sbi_xact);
|
||||
|
||||
sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
|
||||
if (!sbi_xact) {
|
||||
/* CLIENT_WAIT timer could remove SBI transaction
|
||||
* before receiving SBI message */
|
||||
ogs_error("SBI transaction has already been removed");
|
||||
break;
|
||||
}
|
||||
|
||||
sess = (pcf_sess_t *)sbi_xact->sbi_object;
|
||||
ogs_assert(sess);
|
||||
|
||||
|
@ -474,6 +490,14 @@ void pcf_state_operational(ogs_fsm_t *s, pcf_event_t *e)
|
|||
sbi_xact = e->sbi.data;
|
||||
ogs_assert(sbi_xact);
|
||||
|
||||
sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
|
||||
if (!sbi_xact) {
|
||||
/* CLIENT_WAIT timer could remove SBI transaction
|
||||
* before receiving SBI message */
|
||||
ogs_error("SBI transaction has already been removed");
|
||||
break;
|
||||
}
|
||||
|
||||
sess = (pcf_sess_t *)sbi_xact->sbi_object;
|
||||
ogs_assert(sess);
|
||||
|
||||
|
|
|
@ -739,6 +739,14 @@ void smf_state_operational(ogs_fsm_t *s, smf_event_t *e)
|
|||
sbi_xact = e->sbi.data;
|
||||
ogs_assert(sbi_xact);
|
||||
|
||||
sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
|
||||
if (!sbi_xact) {
|
||||
/* CLIENT_WAIT timer could remove SBI transaction
|
||||
* before receiving SBI message */
|
||||
ogs_error("SBI transaction has already been removed");
|
||||
break;
|
||||
}
|
||||
|
||||
sess = (smf_sess_t *)sbi_xact->sbi_object;
|
||||
ogs_assert(sess);
|
||||
|
||||
|
|
|
@ -313,6 +313,14 @@ void udm_state_operational(ogs_fsm_t *s, udm_event_t *e)
|
|||
sbi_xact = e->sbi.data;
|
||||
ogs_assert(sbi_xact);
|
||||
|
||||
sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
|
||||
if (!sbi_xact) {
|
||||
/* CLIENT_WAIT timer could remove SBI transaction
|
||||
* before receiving SBI message */
|
||||
ogs_error("SBI transaction has already been removed");
|
||||
break;
|
||||
}
|
||||
|
||||
udm_ue = (udm_ue_t *)sbi_xact->sbi_object;
|
||||
ogs_assert(udm_ue);
|
||||
|
||||
|
|
|
@ -294,6 +294,14 @@ void af_state_operational(ogs_fsm_t *s, af_event_t *e)
|
|||
sbi_xact = e->sbi.data;
|
||||
ogs_assert(sbi_xact);
|
||||
|
||||
sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
|
||||
if (!sbi_xact) {
|
||||
/* CLIENT_WAIT timer could remove SBI transaction
|
||||
* before receiving SBI message */
|
||||
ogs_error("SBI transaction has already been removed");
|
||||
break;
|
||||
}
|
||||
|
||||
sess = (af_sess_t *)sbi_xact->sbi_object;
|
||||
ogs_assert(sess);
|
||||
|
||||
|
|
Loading…
Reference in New Issue