[MEM] fix the pkbuf problem (#1431)
This commit is contained in:
parent
fe5fd0f760
commit
37af21a88d
|
@ -64,9 +64,11 @@ typedef struct ogs_pkbuf_pool_s {
|
|||
static OGS_POOL(pkbuf_pool, ogs_pkbuf_pool_t);
|
||||
static ogs_pkbuf_pool_t *default_pool = NULL;
|
||||
|
||||
#if OGS_USE_TALLOC == 0
|
||||
static ogs_cluster_t *cluster_alloc(
|
||||
ogs_pkbuf_pool_t *pool, unsigned int size);
|
||||
static void cluster_free(ogs_pkbuf_pool_t *pool, ogs_cluster_t *cluster);
|
||||
#endif
|
||||
|
||||
void *ogs_pkbuf_put_data(
|
||||
ogs_pkbuf_t *pkbuf, const void *data, unsigned int len)
|
||||
|
@ -184,6 +186,27 @@ void ogs_pkbuf_pool_destroy(ogs_pkbuf_pool_t *pool)
|
|||
ogs_pkbuf_t *ogs_pkbuf_alloc_debug(
|
||||
ogs_pkbuf_pool_t *pool, unsigned int size, const char *file_line)
|
||||
{
|
||||
#if OGS_USE_TALLOC
|
||||
ogs_pkbuf_t *pkbuf = NULL;
|
||||
|
||||
pkbuf = ogs_talloc_zero_size(NULL, sizeof(*pkbuf) + size, file_line);
|
||||
if (!pkbuf) {
|
||||
ogs_error("ogs_pkbuf_alloc() failed [size=%d]", size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pkbuf->head = pkbuf->_data;
|
||||
pkbuf->end = pkbuf->_data + size;
|
||||
|
||||
pkbuf->len = 0;
|
||||
|
||||
pkbuf->data = pkbuf->_data;
|
||||
pkbuf->tail = pkbuf->_data;
|
||||
|
||||
pkbuf->file_line = file_line; /* For debug */
|
||||
|
||||
return pkbuf;
|
||||
#else
|
||||
ogs_pkbuf_t *pkbuf = NULL;
|
||||
ogs_cluster_t *cluster = NULL;
|
||||
|
||||
|
@ -226,10 +249,14 @@ ogs_pkbuf_t *ogs_pkbuf_alloc_debug(
|
|||
ogs_thread_mutex_unlock(&pool->mutex);
|
||||
|
||||
return pkbuf;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ogs_pkbuf_free(ogs_pkbuf_t *pkbuf)
|
||||
{
|
||||
#if OGS_USE_TALLOC
|
||||
ogs_talloc_free(pkbuf, OGS_FILE_LINE);
|
||||
#else
|
||||
ogs_pkbuf_pool_t *pool = NULL;
|
||||
ogs_cluster_t *cluster = NULL;
|
||||
ogs_assert(pkbuf);
|
||||
|
@ -249,10 +276,33 @@ void ogs_pkbuf_free(ogs_pkbuf_t *pkbuf)
|
|||
ogs_pool_free(&pool->pkbuf, pkbuf);
|
||||
|
||||
ogs_thread_mutex_unlock(&pool->mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
ogs_pkbuf_t *ogs_pkbuf_copy_debug(ogs_pkbuf_t *pkbuf, const char *file_line)
|
||||
{
|
||||
#if OGS_USE_TALLOC
|
||||
ogs_pkbuf_t *newbuf;
|
||||
int size = pkbuf->end - pkbuf->head;
|
||||
|
||||
ogs_assert(size > 0);
|
||||
newbuf = ogs_pkbuf_alloc_debug(NULL, size, file_line);
|
||||
if (!pkbuf) {
|
||||
ogs_error("ogs_pkbuf_alloc() failed [size=%d]", size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* copy data */
|
||||
memcpy(newbuf->_data, pkbuf->_data, size);
|
||||
|
||||
/* copy header */
|
||||
newbuf->len = pkbuf->len;
|
||||
|
||||
newbuf->tail += pkbuf->tail - pkbuf->_data;
|
||||
newbuf->data += pkbuf->data - pkbuf->_data;
|
||||
|
||||
return newbuf;
|
||||
#else
|
||||
ogs_pkbuf_pool_t *pool = NULL;
|
||||
ogs_pkbuf_t *newbuf = NULL;
|
||||
|
||||
|
@ -274,10 +324,12 @@ ogs_pkbuf_t *ogs_pkbuf_copy_debug(ogs_pkbuf_t *pkbuf, const char *file_line)
|
|||
newbuf->cluster->ref++;
|
||||
|
||||
ogs_thread_mutex_unlock(&pool->mutex);
|
||||
#endif
|
||||
|
||||
return newbuf;
|
||||
}
|
||||
|
||||
#if OGS_USE_TALLOC == 0
|
||||
static ogs_cluster_t *cluster_alloc(
|
||||
ogs_pkbuf_pool_t *pool, unsigned int size)
|
||||
{
|
||||
|
@ -363,3 +415,4 @@ static void cluster_free(ogs_pkbuf_pool_t *pool, ogs_cluster_t *cluster)
|
|||
|
||||
ogs_pool_free(&pool->cluster, cluster);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -54,6 +54,8 @@ typedef struct ogs_pkbuf_s {
|
|||
const char *file_line;
|
||||
|
||||
ogs_pkbuf_pool_t *pool;
|
||||
|
||||
unsigned char _data[0]; /*!< optional immediate data array */
|
||||
} ogs_pkbuf_t;
|
||||
|
||||
typedef struct ogs_pkbuf_config_s {
|
||||
|
@ -108,12 +110,12 @@ static ogs_inline void *ogs_pkbuf_put(ogs_pkbuf_t *pkbuf, unsigned int len)
|
|||
{
|
||||
void *tmp = pkbuf->tail;
|
||||
|
||||
if (ogs_unlikely(ogs_pkbuf_tailroom(pkbuf) < (int)len))
|
||||
ogs_assert_if_reached();
|
||||
|
||||
pkbuf->tail += len;
|
||||
pkbuf->len += len;
|
||||
|
||||
if (ogs_unlikely(pkbuf->tail > pkbuf->end))
|
||||
ogs_assert_if_reached();
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
@ -138,12 +140,12 @@ static ogs_inline void ogs_pkbuf_put_u32(ogs_pkbuf_t *pkbuf, uint32_t val)
|
|||
|
||||
static ogs_inline void *ogs_pkbuf_push(ogs_pkbuf_t *pkbuf, unsigned int len)
|
||||
{
|
||||
if (ogs_unlikely(ogs_pkbuf_headroom(pkbuf) < (int)len))
|
||||
ogs_assert_if_reached();
|
||||
|
||||
pkbuf->data -= len;
|
||||
pkbuf->len += len;
|
||||
|
||||
if (ogs_unlikely(pkbuf->data < pkbuf->head))
|
||||
ogs_assert_if_reached();
|
||||
|
||||
return pkbuf->data;
|
||||
}
|
||||
|
||||
|
@ -156,16 +158,30 @@ static ogs_inline void *ogs_pkbuf_pull_inline(
|
|||
|
||||
static ogs_inline void *ogs_pkbuf_pull(ogs_pkbuf_t *pkbuf, unsigned int len)
|
||||
{
|
||||
#if 0
|
||||
if (ogs_unlikely(len > pkbuf->len))
|
||||
ogs_assert_if_reached();
|
||||
|
||||
return ogs_pkbuf_pull_inline(pkbuf, len);
|
||||
#else
|
||||
return ogs_unlikely(len > pkbuf->len) ?
|
||||
NULL : ogs_pkbuf_pull_inline(pkbuf, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
static ogs_inline void ogs_pkbuf_trim(ogs_pkbuf_t *pkbuf, unsigned int len)
|
||||
static ogs_inline int ogs_pkbuf_trim(ogs_pkbuf_t *pkbuf, int len)
|
||||
{
|
||||
if (pkbuf->len > len) {
|
||||
pkbuf->tail = pkbuf->data + len;
|
||||
pkbuf->len = len;
|
||||
if (ogs_unlikely(len < 0))
|
||||
ogs_assert_if_reached();
|
||||
if (ogs_unlikely(len > pkbuf->len)) {
|
||||
ogs_error("len(%d) > pkbuf->len(%d)", len, pkbuf->len);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
pkbuf->tail = pkbuf->data + len;
|
||||
pkbuf->len = len;
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -484,8 +484,10 @@ static void session_remove(ogs_sbi_session_t *sbi_sess)
|
|||
if (sbi_sess->poll.write)
|
||||
ogs_pollset_remove(sbi_sess->poll.write);
|
||||
|
||||
ogs_list_for_each_safe(&sbi_sess->write_queue, next_pkbuf, pkbuf)
|
||||
ogs_list_for_each_safe(&sbi_sess->write_queue, next_pkbuf, pkbuf) {
|
||||
ogs_list_remove(&sbi_sess->write_queue, pkbuf);
|
||||
ogs_pkbuf_free(pkbuf);
|
||||
}
|
||||
|
||||
ogs_assert(sbi_sess->addr);
|
||||
ogs_free(sbi_sess->addr);
|
||||
|
|
|
@ -128,7 +128,9 @@ void ogs_sctp_flush_and_destroy(ogs_sctp_sock_t *sctp)
|
|||
|
||||
ogs_sctp_destroy(sctp->sock);
|
||||
|
||||
ogs_list_for_each_safe(&sctp->write_queue, next_pkbuf, pkbuf)
|
||||
ogs_list_for_each_safe(&sctp->write_queue, next_pkbuf, pkbuf) {
|
||||
ogs_list_remove(&sctp->write_queue, pkbuf);
|
||||
ogs_pkbuf_free(pkbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -955,6 +955,13 @@ void ngap_handle_initial_context_setup_response(
|
|||
ogs_error("nas_5gs_send_to_gnb() failed");
|
||||
}
|
||||
|
||||
/* n1buf is de-allocated
|
||||
* in gmm_build_dl_nas_transport() */
|
||||
sess->gsm_message.n1buf = NULL;
|
||||
/* n2buf is de-allocated
|
||||
* in ngap_build_pdu_session_resource_modify_request() */
|
||||
sess->gsm_message.n2buf = NULL;
|
||||
|
||||
AMF_SESS_CLEAR_5GSM_MESSAGE(sess);
|
||||
|
||||
break;
|
||||
|
|
|
@ -200,7 +200,7 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e)
|
|||
break;
|
||||
|
||||
case OGS_NAS_EPS_ATTACH_REQUEST:
|
||||
ogs_warn("[%s] Attach request", mme_ue->imsi_bcd);
|
||||
ogs_info("[%s] Attach request", mme_ue->imsi_bcd);
|
||||
rv = emm_handle_attach_request(
|
||||
mme_ue, &message->emm.attach_request, e->pkbuf);
|
||||
if (rv != OGS_OK) {
|
||||
|
@ -1153,14 +1153,14 @@ void emm_state_initial_context_setup(ogs_fsm_t *s, mme_event_t *e)
|
|||
emmbuf = mme_ue->t3450.pkbuf;
|
||||
ogs_expect_or_return(emmbuf);
|
||||
|
||||
rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf);
|
||||
if (rv == OGS_OK) {
|
||||
mme_ue->t3450.pkbuf = ogs_pkbuf_copy(emmbuf);
|
||||
ogs_assert(mme_ue->t3450.pkbuf);
|
||||
mme_ue->t3450.pkbuf = ogs_pkbuf_copy(emmbuf);
|
||||
ogs_assert(mme_ue->t3450.pkbuf);
|
||||
|
||||
ogs_timer_start(mme_ue->t3450.timer,
|
||||
mme_timer_cfg(MME_TIMER_T3450)->duration);
|
||||
} else {
|
||||
ogs_timer_start(mme_ue->t3450.timer,
|
||||
mme_timer_cfg(MME_TIMER_T3450)->duration);
|
||||
|
||||
rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf);
|
||||
if (rv != OGS_OK) {
|
||||
ogs_error("nas_eps_send_to_downlink_nas_transport() "
|
||||
"failed");
|
||||
OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception);
|
||||
|
|
|
@ -175,6 +175,17 @@ void mme_s11_handle_create_session_response(
|
|||
}
|
||||
}
|
||||
|
||||
if (mme_ue_from_teid && mme_ue &&
|
||||
cause_value == OGS_GTP_CAUSE_REQUEST_ACCEPTED) {
|
||||
bearer = mme_bearer_find_by_ue_ebi(mme_ue,
|
||||
rsp->bearer_contexts_created.eps_bearer_id.u8);
|
||||
}
|
||||
|
||||
if (!bearer) {
|
||||
ogs_warn("No Context");
|
||||
cause_value = OGS_GTP_CAUSE_CONTEXT_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (cause_value != OGS_GTP_CAUSE_REQUEST_ACCEPTED &&
|
||||
cause_value != OGS_GTP_CAUSE_REQUEST_ACCEPTED_PARTIALLY &&
|
||||
cause_value !=
|
||||
|
@ -193,9 +204,7 @@ void mme_s11_handle_create_session_response(
|
|||
return;
|
||||
}
|
||||
|
||||
bearer = mme_bearer_find_by_ue_ebi(mme_ue,
|
||||
rsp->bearer_contexts_created.eps_bearer_id.u8);
|
||||
ogs_expect_or_return(bearer);
|
||||
ogs_assert(bearer);
|
||||
sess = bearer->sess;
|
||||
ogs_assert(sess);
|
||||
session = sess->session;
|
||||
|
|
|
@ -169,14 +169,14 @@ int nas_eps_send_identity_request(mme_ue_t *mme_ue)
|
|||
ogs_expect_or_return_val(emmbuf, OGS_ERROR);
|
||||
}
|
||||
|
||||
rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, rv);
|
||||
|
||||
mme_ue->t3470.pkbuf = ogs_pkbuf_copy(emmbuf);
|
||||
ogs_expect_or_return_val(mme_ue->t3470.pkbuf, OGS_ERROR);
|
||||
ogs_timer_start(mme_ue->t3470.timer,
|
||||
mme_timer_cfg(MME_TIMER_T3470)->duration);
|
||||
|
||||
rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -197,14 +197,14 @@ int nas_eps_send_authentication_request(mme_ue_t *mme_ue)
|
|||
ogs_expect_or_return_val(emmbuf, OGS_ERROR);
|
||||
}
|
||||
|
||||
rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, rv);
|
||||
|
||||
mme_ue->t3460.pkbuf = ogs_pkbuf_copy(emmbuf);
|
||||
ogs_expect_or_return_val(mme_ue->t3460.pkbuf, OGS_ERROR);
|
||||
ogs_timer_start(mme_ue->t3460.timer,
|
||||
mme_timer_cfg(MME_TIMER_T3460)->duration);
|
||||
|
||||
rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -225,14 +225,14 @@ int nas_eps_send_security_mode_command(mme_ue_t *mme_ue)
|
|||
ogs_expect_or_return_val(emmbuf, OGS_ERROR);
|
||||
}
|
||||
|
||||
rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, rv);
|
||||
|
||||
mme_ue->t3460.pkbuf = ogs_pkbuf_copy(emmbuf);
|
||||
ogs_expect_or_return_val(mme_ue->t3460.pkbuf, OGS_ERROR);
|
||||
ogs_timer_start(mme_ue->t3460.timer,
|
||||
mme_timer_cfg(MME_TIMER_T3460)->duration);
|
||||
|
||||
rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -330,14 +330,14 @@ int nas_eps_send_esm_information_request(mme_bearer_t *bearer)
|
|||
ogs_expect_or_return_val(esmbuf, OGS_ERROR);
|
||||
}
|
||||
|
||||
rv = nas_eps_send_to_downlink_nas_transport(mme_ue, esmbuf);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, rv);
|
||||
|
||||
bearer->t3489.pkbuf = ogs_pkbuf_copy(esmbuf);
|
||||
ogs_expect_or_return_val(bearer->t3489.pkbuf, OGS_ERROR);
|
||||
ogs_timer_start(bearer->t3489.timer,
|
||||
mme_timer_cfg(MME_TIMER_T3489)->duration);
|
||||
|
||||
rv = nas_eps_send_to_downlink_nas_transport(mme_ue, esmbuf);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -509,6 +509,14 @@ int nas_eps_send_tau_accept(
|
|||
emmbuf = emm_build_tau_accept(mme_ue);
|
||||
ogs_expect_or_return_val(emmbuf, OGS_ERROR);
|
||||
|
||||
if (mme_ue->next.m_tmsi) {
|
||||
CLEAR_MME_UE_TIMER(mme_ue->t3450);
|
||||
mme_ue->t3450.pkbuf = ogs_pkbuf_copy(emmbuf);
|
||||
ogs_expect_or_return_val(mme_ue->t3450.pkbuf, OGS_ERROR);
|
||||
ogs_timer_start(mme_ue->t3450.timer,
|
||||
mme_timer_cfg(MME_TIMER_T3450)->duration);
|
||||
}
|
||||
|
||||
if (procedureCode == S1AP_ProcedureCode_id_InitialContextSetup) {
|
||||
ogs_pkbuf_t *s1apbuf = NULL;
|
||||
s1apbuf = s1ap_build_initial_context_setup_request(mme_ue, emmbuf);
|
||||
|
@ -522,14 +530,6 @@ int nas_eps_send_tau_accept(
|
|||
} else
|
||||
ogs_assert_if_reached();
|
||||
|
||||
if (mme_ue->next.m_tmsi) {
|
||||
CLEAR_MME_UE_TIMER(mme_ue->t3450);
|
||||
mme_ue->t3450.pkbuf = ogs_pkbuf_copy(emmbuf);
|
||||
ogs_expect_or_return_val(mme_ue->t3450.pkbuf, OGS_ERROR);
|
||||
ogs_timer_start(mme_ue->t3450.timer,
|
||||
mme_timer_cfg(MME_TIMER_T3450)->duration);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,8 +111,6 @@ void sgwc_state_operational(ogs_fsm_t *s, sgwc_event_t *e)
|
|||
e->gtp_message = NULL;
|
||||
if (pfcp_xact->gtpbuf) {
|
||||
rv = ogs_gtp_parse_msg(>p_message, pfcp_xact->gtpbuf);
|
||||
|
||||
ogs_pkbuf_free(pfcp_xact->gtpbuf);
|
||||
e->gtp_message = >p_message;
|
||||
}
|
||||
|
||||
|
@ -121,6 +119,8 @@ void sgwc_state_operational(ogs_fsm_t *s, sgwc_event_t *e)
|
|||
ogs_error("PFCP state machine exception");
|
||||
}
|
||||
|
||||
if (pfcp_xact->gtpbuf)
|
||||
ogs_pkbuf_free(pfcp_xact->gtpbuf);
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
break;
|
||||
|
||||
|
|
|
@ -631,6 +631,7 @@ static void send_router_advertisement(smf_sess_t *sess, uint8_t *ip6_dst)
|
|||
if (pdr->src_if == OGS_PFCP_INTERFACE_CP_FUNCTION && pdr->gnode) {
|
||||
ogs_gtp_header_t gtp_hdesc;
|
||||
ogs_gtp_extension_header_t ext_hdesc;
|
||||
ogs_pkbuf_t *newbuf = NULL;
|
||||
|
||||
memset(>p_hdesc, 0, sizeof(gtp_hdesc));
|
||||
memset(&ext_hdesc, 0, sizeof(ext_hdesc));
|
||||
|
@ -638,7 +639,10 @@ static void send_router_advertisement(smf_sess_t *sess, uint8_t *ip6_dst)
|
|||
gtp_hdesc.type = OGS_GTPU_MSGTYPE_GPDU;
|
||||
gtp_hdesc.teid = pdr->f_teid.teid;
|
||||
|
||||
ogs_gtp_send_user_plane(pdr->gnode, >p_hdesc, &ext_hdesc, pkbuf);
|
||||
newbuf = ogs_pkbuf_copy(pkbuf);
|
||||
ogs_assert(newbuf);
|
||||
|
||||
ogs_gtp_send_user_plane(pdr->gnode, >p_hdesc, &ext_hdesc, newbuf);
|
||||
|
||||
ogs_debug(" Send Router Advertisement");
|
||||
break;
|
||||
|
|
|
@ -26,6 +26,7 @@ abts_suite *test_idle(abts_suite *suite);
|
|||
abts_suite *test_emm_status(abts_suite *suite);
|
||||
abts_suite *test_ue_context(abts_suite *suite);
|
||||
abts_suite *test_reset(abts_suite *suite);
|
||||
abts_suite *test_issues(abts_suite *suite);
|
||||
|
||||
const struct testlist {
|
||||
abts_suite *(*func)(abts_suite *suite);
|
||||
|
@ -37,6 +38,7 @@ const struct testlist {
|
|||
{test_emm_status},
|
||||
{test_ue_context},
|
||||
{test_reset},
|
||||
{test_issues},
|
||||
{NULL},
|
||||
};
|
||||
|
||||
|
|
|
@ -850,6 +850,7 @@ static void test2_func(abts_case *tc, void *data)
|
|||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testenb_s1ap_send(s1ap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
ogs_msleep(300);
|
||||
|
||||
/********** Remove Subscriber in Database */
|
||||
|
|
|
@ -0,0 +1,388 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "test-common.h"
|
||||
|
||||
static void issues_1431_func(abts_case *tc, void *data)
|
||||
{
|
||||
int rv;
|
||||
ogs_socknode_t *s1ap;
|
||||
ogs_socknode_t *gtpu;
|
||||
ogs_pkbuf_t *emmbuf;
|
||||
ogs_pkbuf_t *esmbuf;
|
||||
ogs_pkbuf_t *sendbuf;
|
||||
ogs_pkbuf_t *recvbuf;
|
||||
ogs_s1ap_message_t message;
|
||||
|
||||
ogs_nas_5gs_mobile_identity_suci_t mobile_identity_suci;
|
||||
test_ue_t *test_ue = NULL;
|
||||
test_sess_t *sess = NULL;
|
||||
test_bearer_t *bearer = NULL;
|
||||
|
||||
uint32_t old_enb_ue_s1ap_id;
|
||||
uint64_t old_mme_ue_s1ap_id;
|
||||
uint32_t new_enb_ue_s1ap_id;
|
||||
uint64_t new_mme_ue_s1ap_id;
|
||||
|
||||
bson_t *doc = NULL;
|
||||
|
||||
/* Setup Test UE & Session Context */
|
||||
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;
|
||||
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] = 0x37;
|
||||
mobile_identity_suci.scheme_output[1] = 0x46;
|
||||
mobile_identity_suci.scheme_output[2] = 0;
|
||||
mobile_identity_suci.scheme_output[3] = 0;
|
||||
mobile_identity_suci.scheme_output[4] = 0x06;
|
||||
|
||||
test_ue = test_ue_add_by_suci(&mobile_identity_suci, 13);
|
||||
ogs_assert(test_ue);
|
||||
|
||||
test_ue->e_cgi.cell_id = 0x00003c01;
|
||||
test_ue->nas.ksi = OGS_NAS_KSI_NO_KEY_IS_AVAILABLE;
|
||||
test_ue->nas.value = OGS_NAS_ATTACH_TYPE_EPS_ATTACH;
|
||||
|
||||
test_ue->k_string = "465b5ce8b199b49faa5f0a2ee238a6bc";
|
||||
test_ue->opc_string = "e8ed289deba952e4283b54e88e6183ca";
|
||||
|
||||
sess = test_sess_add_by_apn(test_ue, "internet", OGS_GTP_RAT_TYPE_EUTRAN);
|
||||
ogs_assert(sess);
|
||||
|
||||
/* eNB connects to MME */
|
||||
s1ap = tests1ap_client(AF_INET);
|
||||
ABTS_PTR_NOTNULL(tc, s1ap);
|
||||
|
||||
/* eNB connects to SGW */
|
||||
gtpu = test_gtpu_server(1, AF_INET);
|
||||
ABTS_PTR_NOTNULL(tc, gtpu);
|
||||
|
||||
/* Send S1-Setup Reqeust */
|
||||
sendbuf = test_s1ap_build_s1_setup_request(
|
||||
S1AP_ENB_ID_PR_macroENB_ID, 0x54f64);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
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);
|
||||
tests1ap_recv(NULL, recvbuf);
|
||||
|
||||
/********** Insert Subscriber in Database */
|
||||
doc = test_db_new_simple(test_ue);
|
||||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, test_db_insert_ue(test_ue, doc));
|
||||
|
||||
/* Send Attach Request */
|
||||
memset(&sess->pdn_connectivity_param,
|
||||
0, sizeof(sess->pdn_connectivity_param));
|
||||
sess->pdn_connectivity_param.eit = 1;
|
||||
sess->pdn_connectivity_param.pco = 1;
|
||||
sess->pdn_connectivity_param.request_type =
|
||||
OGS_NAS_EPS_REQUEST_TYPE_INITIAL;
|
||||
esmbuf = testesm_build_pdn_connectivity_request(sess, false);
|
||||
ABTS_PTR_NOTNULL(tc, esmbuf);
|
||||
|
||||
memset(&test_ue->attach_request_param,
|
||||
0, sizeof(test_ue->attach_request_param));
|
||||
test_ue->attach_request_param.ue_usage_setting = 1;
|
||||
test_ue->attach_request_param.ms_network_feature_support = 1;
|
||||
emmbuf = testemm_build_attach_request(test_ue, esmbuf, false, false);
|
||||
ABTS_PTR_NOTNULL(tc, emmbuf);
|
||||
|
||||
memset(&test_ue->initial_ue_param, 0, sizeof(test_ue->initial_ue_param));
|
||||
sendbuf = test_s1ap_build_initial_ue_message(
|
||||
test_ue, emmbuf, S1AP_RRC_Establishment_Cause_mo_Signalling, false);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
rv = testenb_s1ap_send(s1ap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/*** Store eNB-UE-S1AP-ID */
|
||||
old_enb_ue_s1ap_id = test_ue->enb_ue_s1ap_id;
|
||||
|
||||
/* Receive Authentication Request */
|
||||
recvbuf = testenb_s1ap_read(s1ap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
tests1ap_recv(test_ue, recvbuf);
|
||||
|
||||
/*** Store MME-UE-S1AP-ID */
|
||||
old_mme_ue_s1ap_id = test_ue->mme_ue_s1ap_id;
|
||||
|
||||
/* Send Authentication response */
|
||||
emmbuf = testemm_build_authentication_response(test_ue);
|
||||
ABTS_PTR_NOTNULL(tc, emmbuf);
|
||||
sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, emmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
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);
|
||||
tests1ap_recv(test_ue, recvbuf);
|
||||
|
||||
/* Send Security mode complete */
|
||||
test_ue->mobile_identity_imeisv_presence = true;
|
||||
emmbuf = testemm_build_security_mode_complete(test_ue);
|
||||
ABTS_PTR_NOTNULL(tc, emmbuf);
|
||||
sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, emmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
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);
|
||||
tests1ap_recv(test_ue, recvbuf);
|
||||
|
||||
/* Send ESM Information Response */
|
||||
sess->esm_information_param.pco = 1;
|
||||
esmbuf = testesm_build_esm_information_response(sess);
|
||||
ABTS_PTR_NOTNULL(tc, esmbuf);
|
||||
sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testenb_s1ap_send(s1ap, 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);
|
||||
tests1ap_recv(test_ue, recvbuf);
|
||||
|
||||
/* Send UE Capability Info Indication */
|
||||
sendbuf = tests1ap_build_ue_radio_capability_info_indication(test_ue);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testenb_s1ap_send(s1ap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Send Attach Complete + Activate default EPS bearer cotext accept */
|
||||
test_ue->nr_cgi.cell_id = 0x1234502;
|
||||
bearer = test_bearer_find_by_ue_ebi(test_ue, 5);
|
||||
ogs_assert(bearer);
|
||||
esmbuf = testesm_build_activate_default_eps_bearer_context_accept(
|
||||
bearer, false);
|
||||
ABTS_PTR_NOTNULL(tc, esmbuf);
|
||||
emmbuf = testemm_build_attach_complete(test_ue, esmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, emmbuf);
|
||||
sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, emmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
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);
|
||||
tests1ap_recv(test_ue, recvbuf);
|
||||
|
||||
/* Send Initial Context Setup Response */
|
||||
sendbuf = test_s1ap_build_initial_context_setup_response(test_ue);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testenb_s1ap_send(s1ap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Wait for Modify Bearer Request/Response */
|
||||
ogs_msleep(100);
|
||||
|
||||
/* Send PDN Connectivity Request */
|
||||
sess = test_sess_find_by_apn(test_ue, "internet", OGS_GTP_RAT_TYPE_EUTRAN);
|
||||
ogs_assert(sess);
|
||||
sess->pti = 2;
|
||||
|
||||
memset(&sess->pdn_connectivity_param,
|
||||
0, sizeof(sess->pdn_connectivity_param));
|
||||
sess->pdn_connectivity_param.apn = 1;
|
||||
sess->pdn_connectivity_param.pco = 1;
|
||||
sess->pdn_connectivity_param.request_type =
|
||||
OGS_NAS_EPS_REQUEST_TYPE_INITIAL;
|
||||
esmbuf = testesm_build_pdn_connectivity_request(sess, true);
|
||||
ABTS_PTR_NOTNULL(tc, esmbuf);
|
||||
sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testenb_s1ap_send(s1ap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive E-RABSetupRequest +
|
||||
* Activate default EPS bearer context request */
|
||||
recvbuf = testenb_s1ap_read(s1ap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
tests1ap_recv(test_ue, recvbuf);
|
||||
ABTS_INT_EQUAL(tc,
|
||||
S1AP_ProcedureCode_id_E_RABSetup,
|
||||
test_ue->s1ap_procedure_code);
|
||||
|
||||
/* Send E-RABSetupResponse */
|
||||
bearer = test_bearer_find_by_ue_ebi(test_ue, 5);
|
||||
ogs_assert(bearer);
|
||||
sendbuf = test_s1ap_build_e_rab_failed_setup_response(
|
||||
bearer,
|
||||
S1AP_Cause_PR_radioNetwork,
|
||||
S1AP_CauseRadioNetwork_multiple_E_RAB_ID_instances);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testenb_s1ap_send(s1ap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Just Delay */
|
||||
ogs_msleep(100);
|
||||
|
||||
/* Send Attach Request - Integrity */
|
||||
sess = test_sess_find_by_apn(test_ue, "internet", OGS_GTP_RAT_TYPE_EUTRAN);
|
||||
ogs_assert(sess);
|
||||
sess->pti = 3;
|
||||
|
||||
memset(&sess->pdn_connectivity_param,
|
||||
0, sizeof(sess->pdn_connectivity_param));
|
||||
sess->pdn_connectivity_param.eit = 1;
|
||||
sess->pdn_connectivity_param.pco = 1;
|
||||
sess->pdn_connectivity_param.request_type =
|
||||
OGS_NAS_EPS_REQUEST_TYPE_INITIAL;
|
||||
esmbuf = testesm_build_pdn_connectivity_request(sess, false);
|
||||
ABTS_PTR_NOTNULL(tc, esmbuf);
|
||||
|
||||
memset(&test_ue->attach_request_param,
|
||||
0, sizeof(test_ue->attach_request_param));
|
||||
test_ue->attach_request_param.guti = 1;
|
||||
test_ue->attach_request_param.last_visited_registered_tai = 1;
|
||||
test_ue->attach_request_param.ue_usage_setting = 1;
|
||||
test_ue->attach_request_param.old_guti_type = 1;
|
||||
test_ue->attach_request_param.ms_network_feature_support = 1;
|
||||
emmbuf = testemm_build_attach_request(test_ue, esmbuf, true, false);
|
||||
ABTS_PTR_NOTNULL(tc, emmbuf);
|
||||
|
||||
sendbuf = test_s1ap_build_initial_ue_message(
|
||||
test_ue, emmbuf, S1AP_RRC_Establishment_Cause_mo_Signalling, false);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
rv = testenb_s1ap_send(s1ap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/*** Store eNB-UE-S1AP-ID */
|
||||
new_enb_ue_s1ap_id = test_ue->enb_ue_s1ap_id;
|
||||
|
||||
/* Receive OLD UE Context Release Command */
|
||||
recvbuf = testenb_s1ap_read(s1ap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
tests1ap_recv(test_ue, recvbuf);
|
||||
|
||||
/* Receive ESM Information Request */
|
||||
recvbuf = testenb_s1ap_read(s1ap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
tests1ap_recv(test_ue, recvbuf);
|
||||
|
||||
/*** Store MME-UE-S1AP-ID */
|
||||
new_mme_ue_s1ap_id = test_ue->mme_ue_s1ap_id;
|
||||
|
||||
/* Send OLD UE Context Release Complete */
|
||||
test_ue->enb_ue_s1ap_id = old_enb_ue_s1ap_id;
|
||||
test_ue->mme_ue_s1ap_id = old_mme_ue_s1ap_id;
|
||||
|
||||
sendbuf = test_s1ap_build_ue_context_release_complete(test_ue);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testenb_s1ap_send(s1ap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Just Delay */
|
||||
ogs_msleep(100);
|
||||
|
||||
/* Send ESM Information Response */
|
||||
test_ue->enb_ue_s1ap_id = new_enb_ue_s1ap_id;
|
||||
test_ue->mme_ue_s1ap_id = new_mme_ue_s1ap_id;
|
||||
|
||||
sess->esm_information_param.pco = 0;
|
||||
esmbuf = testesm_build_esm_information_response(sess);
|
||||
ABTS_PTR_NOTNULL(tc, esmbuf);
|
||||
sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testenb_s1ap_send(s1ap, 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);
|
||||
tests1ap_recv(test_ue, recvbuf);
|
||||
|
||||
/* Send Attach Complete + Activate default EPS bearer cotext accept */
|
||||
test_ue->nr_cgi.cell_id = 0x1234502;
|
||||
bearer = test_bearer_find_by_ue_ebi(test_ue, 5);
|
||||
ogs_assert(bearer);
|
||||
esmbuf = testesm_build_activate_default_eps_bearer_context_accept(
|
||||
bearer, false);
|
||||
ABTS_PTR_NOTNULL(tc, esmbuf);
|
||||
emmbuf = testemm_build_attach_complete(test_ue, esmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, emmbuf);
|
||||
sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, emmbuf);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
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);
|
||||
tests1ap_recv(test_ue, recvbuf);
|
||||
|
||||
/* Send UE Context Release Request */
|
||||
sendbuf = test_s1ap_build_ue_context_release_request(test_ue,
|
||||
S1AP_Cause_PR_radioNetwork, S1AP_CauseRadioNetwork_user_inactivity);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
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);
|
||||
tests1ap_recv(test_ue, recvbuf);
|
||||
|
||||
/* Send UE Context Release Complete */
|
||||
sendbuf = test_s1ap_build_ue_context_release_complete(test_ue);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testenb_s1ap_send(s1ap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
ogs_msleep(300);
|
||||
|
||||
/********** Remove Subscriber in Database */
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, test_db_remove_ue(test_ue));
|
||||
|
||||
/* eNB disonncect from MME */
|
||||
testenb_s1ap_close(s1ap);
|
||||
|
||||
/* eNB disonncect from SGW */
|
||||
test_gtpu_close(gtpu);
|
||||
|
||||
test_ue_remove(test_ue);
|
||||
}
|
||||
|
||||
abts_suite *test_issues(abts_suite *suite)
|
||||
{
|
||||
suite = ADD_SUITE(suite)
|
||||
|
||||
abts_run_test(suite, issues_1431_func, NULL);
|
||||
|
||||
return suite;
|
||||
}
|
|
@ -24,6 +24,7 @@ testapp_attach_sources = files('''
|
|||
emm-status-test.c
|
||||
reset-test.c
|
||||
ue-context-test.c
|
||||
issues-test.c
|
||||
'''.split())
|
||||
|
||||
testapp_attach_exe = executable('attach',
|
||||
|
|
|
@ -56,8 +56,6 @@ static void s1setup_test1(abts_case *tc, void *data)
|
|||
for (i = 0; i < NUM_OF_TEST_DUPLICATED_ENB; i++) {
|
||||
testenb_s1ap_close(node[i]);
|
||||
}
|
||||
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
}
|
||||
|
||||
#define NUM_OF_TEST_ENB 4
|
||||
|
@ -97,8 +95,6 @@ static void s1setup_test2(abts_case *tc, void *data)
|
|||
for (i = 0; i < NUM_OF_TEST_ENB; i++) {
|
||||
testenb_s1ap_close(node[i]);
|
||||
}
|
||||
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
}
|
||||
|
||||
static void s1setup_test3(abts_case *tc, void *data)
|
||||
|
|
|
@ -25,6 +25,7 @@ ogs_pkbuf_t *testemm_build_attach_request(
|
|||
{
|
||||
int i;
|
||||
uint16_t psimask = 0;
|
||||
ogs_pkbuf_t *pkbuf = NULL;
|
||||
|
||||
ogs_nas_eps_message_t message;
|
||||
ogs_nas_eps_attach_request_t *attach_request = &message.emm.attach_request;
|
||||
|
@ -86,7 +87,6 @@ ogs_pkbuf_t *testemm_build_attach_request(
|
|||
|
||||
esm_message_container->length = esmbuf->len;
|
||||
esm_message_container->buffer = esmbuf->data;
|
||||
ogs_pkbuf_free(esmbuf);
|
||||
|
||||
memcpy(eps_attach_type, &test_ue->nas.data, sizeof(*eps_attach_type));
|
||||
|
||||
|
@ -238,9 +238,13 @@ ogs_pkbuf_t *testemm_build_attach_request(
|
|||
}
|
||||
|
||||
if (integrity_protected)
|
||||
return test_nas_eps_security_encode(test_ue, &message);
|
||||
pkbuf = test_nas_eps_security_encode(test_ue, &message);
|
||||
else
|
||||
return ogs_nas_eps_plain_encode(&message);
|
||||
pkbuf = ogs_nas_eps_plain_encode(&message);
|
||||
|
||||
ogs_pkbuf_free(esmbuf);
|
||||
|
||||
return pkbuf;
|
||||
}
|
||||
|
||||
ogs_pkbuf_t *testemm_build_identity_response(test_ue_t *test_ue)
|
||||
|
@ -397,6 +401,7 @@ ogs_pkbuf_t *testemm_build_security_mode_complete(test_ue_t *test_ue)
|
|||
ogs_pkbuf_t *testemm_build_attach_complete(
|
||||
test_ue_t *test_ue, ogs_pkbuf_t *esmbuf)
|
||||
{
|
||||
ogs_pkbuf_t *pkbuf = NULL;
|
||||
ogs_nas_eps_message_t message;
|
||||
ogs_nas_eps_attach_complete_t *attach_complete =
|
||||
&message.emm.attach_complete;
|
||||
|
@ -417,9 +422,12 @@ ogs_pkbuf_t *testemm_build_attach_complete(
|
|||
|
||||
esm_message_container->length = esmbuf->len;
|
||||
esm_message_container->buffer = esmbuf->data;
|
||||
|
||||
pkbuf = test_nas_eps_security_encode(test_ue, &message);
|
||||
|
||||
ogs_pkbuf_free(esmbuf);
|
||||
|
||||
return test_nas_eps_security_encode(test_ue, &message);
|
||||
return pkbuf;
|
||||
}
|
||||
|
||||
ogs_pkbuf_t *testemm_build_tau_complete(test_ue_t *test_ue)
|
||||
|
|
|
@ -214,13 +214,17 @@ ogs_pkbuf_t *testgmm_build_registration_request(
|
|||
|
||||
nas_message_container->length = nasbuf->len;
|
||||
nas_message_container->buffer = nasbuf->data;
|
||||
ogs_pkbuf_free(nasbuf);
|
||||
}
|
||||
|
||||
if (integrity_protected)
|
||||
return test_nas_5gs_security_encode(test_ue, &message);
|
||||
pkbuf = test_nas_5gs_security_encode(test_ue, &message);
|
||||
else
|
||||
return ogs_nas_5gs_plain_encode(&message);
|
||||
pkbuf = ogs_nas_5gs_plain_encode(&message);
|
||||
|
||||
if (nasbuf)
|
||||
ogs_pkbuf_free(nasbuf);
|
||||
|
||||
return pkbuf;
|
||||
}
|
||||
|
||||
ogs_pkbuf_t *testgmm_build_registration_complete(test_ue_t *test_ue)
|
||||
|
@ -333,7 +337,6 @@ ogs_pkbuf_t *testgmm_build_service_request(
|
|||
|
||||
nas_message_container->length = nasbuf->len;
|
||||
nas_message_container->buffer = nasbuf->data;
|
||||
ogs_pkbuf_free(nasbuf);
|
||||
}
|
||||
|
||||
if (test_ue->service_request_param.uplink_data_status) {
|
||||
|
@ -367,9 +370,14 @@ ogs_pkbuf_t *testgmm_build_service_request(
|
|||
}
|
||||
|
||||
if (integrity_protected)
|
||||
return test_nas_5gs_security_encode(test_ue, &message);
|
||||
pkbuf = test_nas_5gs_security_encode(test_ue, &message);
|
||||
else
|
||||
return ogs_nas_5gs_plain_encode(&message);
|
||||
pkbuf = ogs_nas_5gs_plain_encode(&message);
|
||||
|
||||
if (nasbuf)
|
||||
ogs_pkbuf_free(nasbuf);
|
||||
|
||||
return pkbuf;
|
||||
}
|
||||
|
||||
ogs_pkbuf_t *testgmm_build_de_registration_request(
|
||||
|
@ -594,10 +602,14 @@ ogs_pkbuf_t *testgmm_build_security_mode_complete(
|
|||
OGS_NAS_5GS_SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_PRESENT;
|
||||
nas_message_container->length = nasbuf->len;
|
||||
nas_message_container->buffer = nasbuf->data;
|
||||
ogs_pkbuf_free(nasbuf);
|
||||
}
|
||||
|
||||
return test_nas_5gs_security_encode(test_ue, &message);
|
||||
pkbuf = test_nas_5gs_security_encode(test_ue, &message);
|
||||
|
||||
if (nasbuf)
|
||||
ogs_pkbuf_free(nasbuf);
|
||||
|
||||
return pkbuf;
|
||||
}
|
||||
|
||||
ogs_pkbuf_t *testgmm_build_configuration_update_complete(test_ue_t *test_ue)
|
||||
|
|
|
@ -907,6 +907,91 @@ ogs_pkbuf_t *test_s1ap_build_e_rab_setup_response(test_bearer_t *bearer)
|
|||
return ogs_s1ap_encode(&pdu);
|
||||
}
|
||||
|
||||
ogs_pkbuf_t *test_s1ap_build_e_rab_failed_setup_response(
|
||||
test_bearer_t *bearer, S1AP_Cause_PR group, long cause)
|
||||
{
|
||||
int rv;
|
||||
|
||||
test_ue_t *test_ue = NULL;
|
||||
test_sess_t *sess = NULL;
|
||||
|
||||
S1AP_S1AP_PDU_t pdu;
|
||||
S1AP_SuccessfulOutcome_t *successfulOutcome = NULL;
|
||||
S1AP_E_RABSetupResponse_t *E_RABSetupResponse = NULL;
|
||||
|
||||
S1AP_E_RABSetupResponseIEs_t *ie = NULL;
|
||||
S1AP_MME_UE_S1AP_ID_t *MME_UE_S1AP_ID = NULL;
|
||||
S1AP_ENB_UE_S1AP_ID_t *ENB_UE_S1AP_ID = NULL;
|
||||
S1AP_E_RABList_t *E_RABList = NULL;
|
||||
|
||||
S1AP_E_RABItemIEs_t *item = NULL;
|
||||
S1AP_E_RABItem_t *e_rab = NULL;
|
||||
|
||||
ogs_assert(bearer);
|
||||
sess = bearer->sess;
|
||||
ogs_assert(sess);
|
||||
test_ue = sess->test_ue;
|
||||
ogs_assert(test_ue);
|
||||
|
||||
memset(&pdu, 0, sizeof (S1AP_S1AP_PDU_t));
|
||||
pdu.present = S1AP_S1AP_PDU_PR_successfulOutcome;
|
||||
pdu.choice.successfulOutcome = CALLOC(1, sizeof(S1AP_SuccessfulOutcome_t));
|
||||
|
||||
successfulOutcome = pdu.choice.successfulOutcome;
|
||||
successfulOutcome->procedureCode = S1AP_ProcedureCode_id_E_RABSetup;
|
||||
successfulOutcome->criticality = S1AP_Criticality_reject;
|
||||
successfulOutcome->value.present =
|
||||
S1AP_SuccessfulOutcome__value_PR_E_RABSetupResponse;
|
||||
|
||||
E_RABSetupResponse = &successfulOutcome->value.choice.E_RABSetupResponse;
|
||||
|
||||
ie = CALLOC(1, sizeof(S1AP_E_RABSetupResponseIEs_t));
|
||||
ASN_SEQUENCE_ADD(&E_RABSetupResponse->protocolIEs, ie);
|
||||
|
||||
ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
|
||||
ie->criticality = S1AP_Criticality_ignore;
|
||||
ie->value.present = S1AP_E_RABSetupResponseIEs__value_PR_MME_UE_S1AP_ID;
|
||||
|
||||
MME_UE_S1AP_ID = &ie->value.choice.MME_UE_S1AP_ID;
|
||||
|
||||
*MME_UE_S1AP_ID = test_ue->mme_ue_s1ap_id;
|
||||
|
||||
ie = CALLOC(1, sizeof(S1AP_E_RABSetupResponseIEs_t));
|
||||
ASN_SEQUENCE_ADD(&E_RABSetupResponse->protocolIEs, ie);
|
||||
|
||||
ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
|
||||
ie->criticality = S1AP_Criticality_ignore;
|
||||
ie->value.present = S1AP_E_RABSetupResponseIEs__value_PR_ENB_UE_S1AP_ID;
|
||||
|
||||
ENB_UE_S1AP_ID = &ie->value.choice.ENB_UE_S1AP_ID;
|
||||
|
||||
*ENB_UE_S1AP_ID = test_ue->enb_ue_s1ap_id;
|
||||
|
||||
ie = CALLOC(1, sizeof(S1AP_E_RABSetupResponseIEs_t));
|
||||
ASN_SEQUENCE_ADD(&E_RABSetupResponse->protocolIEs, ie);
|
||||
|
||||
ie->id = S1AP_ProtocolIE_ID_id_E_RABFailedToSetupListBearerSURes;
|
||||
ie->criticality = S1AP_Criticality_ignore;
|
||||
ie->value.present = S1AP_E_RABSetupResponseIEs__value_PR_E_RABList;
|
||||
|
||||
E_RABList = &ie->value.choice.E_RABList;
|
||||
|
||||
item = CALLOC(1, sizeof(S1AP_E_RABItemIEs_t));
|
||||
ASN_SEQUENCE_ADD(&E_RABList->list, item);
|
||||
|
||||
item->id = S1AP_ProtocolIE_ID_id_E_RABItem;
|
||||
item->criticality = S1AP_Criticality_reject;
|
||||
item->value.present = S1AP_E_RABItemIEs__value_PR_E_RABItem;
|
||||
|
||||
e_rab = &item->value.choice.E_RABItem;
|
||||
|
||||
e_rab->e_RAB_ID = bearer->ebi;
|
||||
e_rab->cause.present = group;
|
||||
e_rab->cause.choice.radioNetwork = cause;
|
||||
|
||||
return ogs_s1ap_encode(&pdu);
|
||||
}
|
||||
|
||||
ogs_pkbuf_t *test_s1ap_build_e_rab_modify_response(test_bearer_t *bearer)
|
||||
{
|
||||
int rv;
|
||||
|
|
|
@ -44,6 +44,8 @@ ogs_pkbuf_t *test_s1ap_build_ue_context_release_request(test_ue_t *test_ue,
|
|||
|
||||
ogs_pkbuf_t *test_s1ap_build_ue_context_release_complete(test_ue_t *test_ue);
|
||||
ogs_pkbuf_t *test_s1ap_build_e_rab_setup_response(test_bearer_t *bearer);
|
||||
ogs_pkbuf_t *test_s1ap_build_e_rab_failed_setup_response(
|
||||
test_bearer_t *bearer, S1AP_Cause_PR group, long cause);
|
||||
ogs_pkbuf_t *test_s1ap_build_e_rab_modify_response(test_bearer_t *bearer);
|
||||
ogs_pkbuf_t *test_s1ap_build_e_rab_release_response(test_bearer_t *bearer);
|
||||
|
||||
|
|
Loading…
Reference in New Issue