forked from acouzens/open5gs
refine test program for testing dual ipv4/v6 stack
This commit is contained in:
parent
969dc789df
commit
d70701361f
|
@ -27,6 +27,8 @@ static inline int s1ap_encode_initial_context_setup_response(
|
|||
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
||||
static inline int s1ap_encode_e_rab_setup_request(
|
||||
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
||||
static inline int s1ap_encode_e_rab_setup_response(
|
||||
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
||||
static inline int s1ap_encode_e_rab_release_command(
|
||||
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
||||
static inline int s1ap_encode_ue_context_release_command(
|
||||
|
@ -189,6 +191,13 @@ static inline int s1ap_encode_successfull_outcome(
|
|||
ret = s1ap_encode_initial_context_setup_response(message_p, pkbuf);
|
||||
break;
|
||||
|
||||
case S1ap_ProcedureCode_id_E_RABSetup:
|
||||
s1ap_encode_xer_print_message(
|
||||
s1ap_xer_print_s1ap_e_rabsetupresponse,
|
||||
s1ap_xer__print2sp, message_p);
|
||||
ret = s1ap_encode_e_rab_setup_response(message_p, pkbuf);
|
||||
break;
|
||||
|
||||
case S1ap_ProcedureCode_id_PathSwitchRequest:
|
||||
s1ap_encode_xer_print_message(
|
||||
s1ap_xer_print_s1ap_pathswitchrequestacknowledge,
|
||||
|
@ -467,8 +476,8 @@ static inline int s1ap_encode_initial_context_setup_response(
|
|||
|
||||
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
||||
pdu.present = S1AP_PDU_PR_successfulOutcome;
|
||||
pdu.choice.initiatingMessage.procedureCode = message_p->procedureCode;
|
||||
pdu.choice.initiatingMessage.criticality = S1ap_Criticality_reject;
|
||||
pdu.choice.successfulOutcome.procedureCode = message_p->procedureCode;
|
||||
pdu.choice.successfulOutcome.criticality = S1ap_Criticality_reject;
|
||||
ANY_fromType_aper(&pdu.choice.successfulOutcome.value,
|
||||
td, &initialContextSetupResponse);
|
||||
|
||||
|
@ -523,6 +532,43 @@ static inline int s1ap_encode_e_rab_setup_request(
|
|||
return enc_ret.encoded;
|
||||
}
|
||||
|
||||
static inline int s1ap_encode_e_rab_setup_response(
|
||||
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
||||
{
|
||||
asn_enc_rval_t enc_ret = {0};
|
||||
|
||||
S1AP_PDU_t pdu;
|
||||
S1ap_E_RABSetupResponse_t rsp;
|
||||
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_E_RABSetupResponse;
|
||||
|
||||
memset(&rsp, 0, sizeof(S1ap_E_RABSetupResponse_t));
|
||||
if (s1ap_encode_s1ap_e_rabsetupresponseies(
|
||||
&rsp, &message_p->s1ap_E_RABSetupResponseIEs) < 0)
|
||||
{
|
||||
d_error("Encoding of %s failed", td->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
||||
pdu.present = S1AP_PDU_PR_successfulOutcome;
|
||||
pdu.choice.successfulOutcome.procedureCode = message_p->procedureCode;
|
||||
pdu.choice.successfulOutcome.criticality = S1ap_Criticality_reject;
|
||||
ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, &rsp);
|
||||
|
||||
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
||||
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
||||
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &rsp);
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
||||
|
||||
if (enc_ret.encoded < 0)
|
||||
{
|
||||
d_error("Encoding of %s failed", td->name);
|
||||
}
|
||||
|
||||
return enc_ret.encoded;
|
||||
}
|
||||
|
||||
static inline int s1ap_encode_e_rab_release_command(
|
||||
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
||||
{
|
||||
|
|
|
@ -604,8 +604,8 @@ static void attach_test2(abts_case *tc, void *data)
|
|||
core_sleep(time_from_msec(300));
|
||||
|
||||
/* Send Initial Context Setup Response */
|
||||
rv = tests1ap_build_initial_context_setup_response_static(
|
||||
&sendbuf, msgindex);
|
||||
rv = tests1ap_build_initial_context_setup_response(&sendbuf,
|
||||
1, 31, 5, 1);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
@ -896,8 +896,8 @@ static void attach_test3(abts_case *tc, void *data)
|
|||
core_sleep(time_from_msec(300));
|
||||
|
||||
/* Send Initial Context Setup Response */
|
||||
rv = tests1ap_build_initial_context_setup_response_static(
|
||||
&sendbuf, msgindex);
|
||||
rv = tests1ap_build_initial_context_setup_response(&sendbuf,
|
||||
33554632, 2, 5, 1);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
@ -964,8 +964,8 @@ static void attach_test3(abts_case *tc, void *data)
|
|||
core_sleep(time_from_msec(300));
|
||||
|
||||
/* Send Initial Context Setup Response */
|
||||
rv = tests1ap_build_initial_context_setup_response_static(
|
||||
&sendbuf, msgindex+1);
|
||||
rv = tests1ap_build_initial_context_setup_response(&sendbuf,
|
||||
33554631, 4, 5, 1);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
|
|
@ -248,7 +248,7 @@ static void handover_test1(abts_case *tc, void *data)
|
|||
pkbuf_free(recvbuf);
|
||||
|
||||
/* Send E-RAB Setup Response */
|
||||
rv = tests1ap_build_e_rab_setup_response(&sendbuf, msgindex);
|
||||
rv = tests1ap_build_e_rab_setup_response(&sendbuf, 33554492, 1, 6, 2);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock1, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
@ -581,7 +581,7 @@ static void handover_test2(abts_case *tc, void *data)
|
|||
pkbuf_free(recvbuf);
|
||||
|
||||
/* Send E-RAB Setup Response */
|
||||
rv = tests1ap_build_e_rab_setup_response(&sendbuf, msgindex);
|
||||
rv = tests1ap_build_e_rab_setup_response(&sendbuf, 33554628, 12, 6, 2);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock1, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
|
|
@ -1199,7 +1199,63 @@ status_t tests1ap_build_pdn_disconnectivity_request(
|
|||
return CORE_OK;
|
||||
}
|
||||
|
||||
status_t tests1ap_build_e_rab_setup_response(pkbuf_t **pkbuf, int i)
|
||||
status_t tests1ap_build_e_rab_setup_response(
|
||||
pkbuf_t **pkbuf,
|
||||
c_uint32_t mme_ue_s1ap_id, c_uint32_t enb_ue_s1ap_id,
|
||||
c_uint8_t ebi, c_uint32_t teid)
|
||||
{
|
||||
int erval = -1;
|
||||
|
||||
status_t rv;
|
||||
gtp_f_teid_t f_teid;
|
||||
ip_t ip;
|
||||
int len;
|
||||
|
||||
s1ap_message_t message;
|
||||
S1ap_E_RABSetupResponseIEs_t *ies = NULL;
|
||||
S1ap_E_RABSetupItemBearerSURes_t *e_rab = NULL;
|
||||
|
||||
memset(&message, 0, sizeof(s1ap_message_t));
|
||||
|
||||
ies = &message.s1ap_E_RABSetupResponseIEs;
|
||||
|
||||
message.direction = S1AP_PDU_PR_successfulOutcome;
|
||||
message.procedureCode = S1ap_ProcedureCode_id_E_RABSetup;
|
||||
|
||||
ies->mme_ue_s1ap_id = mme_ue_s1ap_id;
|
||||
ies->eNB_UE_S1AP_ID = enb_ue_s1ap_id;
|
||||
|
||||
e_rab = (S1ap_E_RABSetupItemBearerSURes_t *)
|
||||
core_calloc(1, sizeof(S1ap_E_RABSetupItemBearerSURes_t));
|
||||
e_rab->e_RAB_ID = ebi;
|
||||
|
||||
rv = gtp_sockaddr_to_f_teid(
|
||||
mme_self()->gtpc_addr, mme_self()->gtpc_addr6, &f_teid, &len);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR,);
|
||||
rv = gtp_f_teid_to_ip(&f_teid, &ip);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR,);
|
||||
|
||||
rv = s1ap_ip_to_BIT_STRING(&ip, &e_rab->transportLayerAddress);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR,);
|
||||
s1ap_uint32_to_OCTET_STRING(teid, &e_rab->gTP_TEID);
|
||||
|
||||
ies->presenceMask |=
|
||||
S1AP_E_RABSETUPRESPONSEIES_E_RABSETUPLISTBEARERSURES_PRESENT;
|
||||
ASN_SEQUENCE_ADD(&ies->e_RABSetupListBearerSURes, e_rab);
|
||||
|
||||
erval = s1ap_encode_pdu(pkbuf, &message);
|
||||
s1ap_free_pdu(&message);
|
||||
|
||||
if (erval < 0)
|
||||
{
|
||||
d_error("s1ap_encode_error : (%d)", erval);
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
status_t tests1ap_build_e_rab_setup_response_static(pkbuf_t **pkbuf, int i)
|
||||
{
|
||||
char *payload[TESTS1AP_MAX_MESSAGE] = {
|
||||
"2005002600000300 004005c00200003c 0008400300010000 1c400f000027400a"
|
||||
|
|
|
@ -21,10 +21,6 @@ CORE_DECLARE(status_t) tests1ap_build_setup_req(
|
|||
pkbuf_t **pkbuf, S1ap_ENB_ID_PR present, c_uint32_t enb_id);
|
||||
CORE_DECLARE(status_t) tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i);
|
||||
CORE_DECLARE(status_t) tests1ap_build_identity_response(pkbuf_t **pkbuf, int i);
|
||||
CORE_DECLARE(status_t) tests1ap_build_initial_context_setup_response(
|
||||
pkbuf_t **pkbuf,
|
||||
c_uint32_t mme_ue_s1ap_id, c_uint32_t enb_ue_s1ap_id,
|
||||
c_uint8_t ebi, c_uint32_t teid);
|
||||
CORE_DECLARE(status_t) tests1ap_build_authentication_response(
|
||||
pkbuf_t **pkbuf, int i);
|
||||
CORE_DECLARE(status_t) tests1ap_build_security_mode_complete(
|
||||
|
@ -53,6 +49,10 @@ CORE_DECLARE(status_t) tests1ap_build_pdn_connectivity_request(
|
|||
CORE_DECLARE(status_t) tests1ap_build_pdn_disconnectivity_request(
|
||||
pkbuf_t **pkbuf, int i);
|
||||
CORE_DECLARE(status_t) tests1ap_build_e_rab_setup_response(
|
||||
pkbuf_t **pkbuf,
|
||||
c_uint32_t mme_ue_s1ap_id, c_uint32_t enb_ue_s1ap_id,
|
||||
c_uint8_t ebi, c_uint32_t teid);
|
||||
CORE_DECLARE(status_t) tests1ap_build_e_rab_setup_response_static(
|
||||
pkbuf_t **pkbuf, int i);
|
||||
CORE_DECLARE(status_t) tests1ap_build_e_rab_release_response(
|
||||
pkbuf_t **pkbuf, int i);
|
||||
|
|
|
@ -197,8 +197,8 @@ static void volte_test1(abts_case *tc, void *data)
|
|||
core_sleep(time_from_msec(300));
|
||||
|
||||
/* Send Initial Context Setup Response */
|
||||
rv = tests1ap_build_initial_context_setup_response_static(
|
||||
&sendbuf, msgindex);
|
||||
rv = tests1ap_build_initial_context_setup_response(&sendbuf,
|
||||
16777373, 1, 5, 1);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
@ -231,7 +231,7 @@ static void volte_test1(abts_case *tc, void *data)
|
|||
pkbuf_free(recvbuf);
|
||||
|
||||
/* Send E-RAB Setup Response */
|
||||
rv = tests1ap_build_e_rab_setup_response(&sendbuf, msgindex);
|
||||
rv = tests1ap_build_e_rab_setup_response(&sendbuf, 33554492, 1, 6, 2);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
@ -260,7 +260,7 @@ static void volte_test1(abts_case *tc, void *data)
|
|||
core_sleep(time_from_msec(300));
|
||||
|
||||
/* Send E-RAB Setup Response */
|
||||
rv = tests1ap_build_e_rab_setup_response(&sendbuf, msgindex+1);
|
||||
rv = tests1ap_build_e_rab_setup_response(&sendbuf, 33554492, 1, 7, 3);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
@ -508,8 +508,8 @@ static void volte_test2(abts_case *tc, void *data)
|
|||
core_sleep(time_from_msec(300));
|
||||
|
||||
/* Send Initial Context Setup Response */
|
||||
rv = tests1ap_build_initial_context_setup_response_static(
|
||||
&sendbuf, msgindex);
|
||||
rv = tests1ap_build_initial_context_setup_response(&sendbuf,
|
||||
16777373, 1, 5, 1);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
@ -534,7 +534,7 @@ static void volte_test2(abts_case *tc, void *data)
|
|||
pkbuf_free(recvbuf);
|
||||
|
||||
/* Send E-RAB Setup Response */
|
||||
rv = tests1ap_build_e_rab_setup_response(&sendbuf, msgindex);
|
||||
rv = tests1ap_build_e_rab_setup_response(&sendbuf, 33554492, 1, 6, 2);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
|
Loading…
Reference in New Issue