[SGsAP] contine to test code
This commit is contained in:
parent
6b0561681f
commit
5ce95f94ee
|
@ -213,14 +213,14 @@ int epc_initialize(app_param_t *param)
|
|||
if (hss_sem1) ogs_proc_mutex_wait(hss_sem1);
|
||||
}
|
||||
|
||||
rv = app_did_initialize();
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
ogs_info("MME try to initialize");
|
||||
rv = mme_initialize();
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_info("MME initialize...done");
|
||||
|
||||
rv = app_did_initialize();
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
return OGS_OK;;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,23 +70,6 @@ int sgsap_send(ogs_sock_t *sock, ogs_pkbuf_t *pkbuf,
|
|||
return OGS_OK;
|
||||
}
|
||||
|
||||
int sgsap_recv(ogs_sock_t *sock, ogs_pkbuf_t *pkbuf)
|
||||
{
|
||||
int size;
|
||||
|
||||
ogs_assert(sock);
|
||||
ogs_assert(pkbuf);
|
||||
|
||||
size = ogs_sctp_recvdata(sock, pkbuf->data, MAX_SDU_LEN, NULL, NULL);
|
||||
if (size <= 0) {
|
||||
ogs_error("sgsap_recv() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
ogs_pkbuf_trim(pkbuf, size);
|
||||
return OGS_OK;;
|
||||
}
|
||||
|
||||
int sgsap_send_to_vlr_with_sid(
|
||||
mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf, uint16_t stream_no)
|
||||
{
|
||||
|
@ -112,7 +95,7 @@ int sgsap_send_to_vlr_with_sid(
|
|||
vlr->lai.plmn_id.mnc1, vlr->lai.plmn_id.mnc2, vlr->lai.plmn_id.mnc3,
|
||||
vlr->lai.lac);
|
||||
|
||||
rv = sgsap_send(sock, pkbuf, NULL, stream_no);
|
||||
rv = sgsap_send(sock, pkbuf, node->addr, stream_no);
|
||||
if (rv != OGS_OK) {
|
||||
ogs_error("sgsap_send() failed");
|
||||
ogs_pkbuf_free(pkbuf);
|
||||
|
|
|
@ -34,7 +34,6 @@ void sgsap_recv_handler(short when, ogs_socket_t fd, void *data);
|
|||
|
||||
int sgsap_send(ogs_sock_t *sock,
|
||||
ogs_pkbuf_t *pkbuf, ogs_sockaddr_t *addr, uint16_t stream_no);
|
||||
int sgsap_recv(ogs_sock_t *sock, ogs_pkbuf_t *pkbuf);
|
||||
|
||||
int sgsap_send_to_vlr_with_sid(
|
||||
mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf, uint16_t stream_no);
|
||||
|
|
|
@ -31,8 +31,8 @@ testcomplex_LDADD = $(top_srcdir)/src/libepc.la
|
|||
|
||||
testvolte_SOURCES = \
|
||||
common/test-packet.h common/test-packet.c \
|
||||
volte/abts-main.c \
|
||||
volte/testapp.h volte/testapp.c \
|
||||
common/test-app.h \
|
||||
volte/abts-main.c volte/test-app.c \
|
||||
volte/pcscf-fd-path.h volte/pcscf-fd-path.c \
|
||||
volte/volte-test.c \
|
||||
$(NULL)
|
||||
|
@ -40,7 +40,8 @@ testvolte_LDADD = $(top_srcdir)/src/libepc.la
|
|||
|
||||
testcsfb_SOURCES = \
|
||||
common/test-packet.h common/test-packet.c \
|
||||
csfb/abts-main.c \
|
||||
common/test-app.h \
|
||||
csfb/abts-main.c csfb/test-app.c \
|
||||
csfb/csfb-test.c \
|
||||
$(NULL)
|
||||
testcsfb_LDADD = $(top_srcdir)/src/libepc.la
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
/*
|
||||
* 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 "base/base.h"
|
||||
|
||||
|
@ -16,9 +34,6 @@
|
|||
#if HAVE_NETINET_ICMP6_H
|
||||
#include <netinet/icmp6.h>
|
||||
#endif
|
||||
#include "mme/s1ap-build.h"
|
||||
#include "mme/s1ap-conv.h"
|
||||
#include "mme/s1ap-path.h"
|
||||
#include "mme/snow-3g.h"
|
||||
|
||||
#include "gtp/gtp-message.h"
|
||||
|
@ -29,6 +44,12 @@
|
|||
#include "mme/ogs-sctp.h"
|
||||
#include "app/context.h"
|
||||
|
||||
#include "mme/s1ap-build.h"
|
||||
#include "mme/s1ap-conv.h"
|
||||
#include "mme/s1ap-path.h"
|
||||
|
||||
#include "mme/sgsap-path.h"
|
||||
|
||||
int testpacket_init()
|
||||
{
|
||||
return OGS_OK;
|
||||
|
@ -39,7 +60,26 @@ int testpacket_final()
|
|||
return OGS_OK;
|
||||
}
|
||||
|
||||
ogs_socknode_t *testenb_s1ap_client(const char *ipstr)
|
||||
ogs_socknode_t *testsctp_server(const char *ipstr)
|
||||
{
|
||||
int rv;
|
||||
ogs_sockaddr_t *addr = NULL;
|
||||
ogs_socknode_t *node = NULL;
|
||||
|
||||
rv = ogs_getaddrinfo(&addr, AF_UNSPEC, ipstr, SGSAP_SCTP_PORT, 0);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
|
||||
node = ogs_socknode_new(addr);
|
||||
ogs_assert(node);
|
||||
ogs_socknode_nodelay(node, true);
|
||||
|
||||
ogs_sctp_server(SOCK_SEQPACKET, node);
|
||||
ogs_assert(node->sock);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
ogs_socknode_t *testsctp_client(const char *ipstr)
|
||||
{
|
||||
int rv;
|
||||
ogs_sockaddr_t *addr = NULL;
|
||||
|
@ -58,7 +98,7 @@ ogs_socknode_t *testenb_s1ap_client(const char *ipstr)
|
|||
return node;
|
||||
}
|
||||
|
||||
ogs_pkbuf_t *testenb_s1ap_read(ogs_socknode_t *node)
|
||||
ogs_pkbuf_t *testsctp_read(ogs_socknode_t *node)
|
||||
{
|
||||
int size;
|
||||
ogs_pkbuf_t *recvbuf = NULL;
|
||||
|
@ -72,7 +112,7 @@ ogs_pkbuf_t *testenb_s1ap_read(ogs_socknode_t *node)
|
|||
size = ogs_sctp_recvdata(node->sock,
|
||||
recvbuf->data, MAX_SDU_LEN, NULL, NULL);
|
||||
if (size <= 0) {
|
||||
ogs_error("s1ap_recv() failed");
|
||||
ogs_error("sgsap_recv() failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -85,9 +125,9 @@ int testenb_s1ap_send(ogs_socknode_t *node, ogs_pkbuf_t *sendbuf)
|
|||
return s1ap_send(node->sock, sendbuf, NULL, 0);
|
||||
}
|
||||
|
||||
void testenb_s1ap_close(ogs_socknode_t *node)
|
||||
int testvlr_sgsap_send(ogs_socknode_t *node, ogs_pkbuf_t *sendbuf)
|
||||
{
|
||||
ogs_socknode_free(node);
|
||||
return sgsap_send(node->sock, sendbuf, NULL, 0);
|
||||
}
|
||||
|
||||
ogs_socknode_t *testenb_gtpu_server(const char *ipstr)
|
||||
|
@ -118,23 +158,14 @@ ogs_pkbuf_t *testenb_gtpu_read(ogs_socknode_t *node)
|
|||
ogs_assert(node);
|
||||
ogs_assert(node->sock);
|
||||
|
||||
while(1)
|
||||
{
|
||||
while (1) {
|
||||
rc = ogs_recv(node->sock->fd, recvbuf->data, recvbuf->len, 0);
|
||||
if (rc == -2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (rc <= 0)
|
||||
{
|
||||
if (errno == EAGAIN)
|
||||
{
|
||||
if (rc <= 0) {
|
||||
if (errno == EAGAIN) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -168,8 +199,7 @@ int testenb_gtpu_send(ogs_socknode_t *node, ogs_pkbuf_t *sendbuf)
|
|||
|
||||
memset(&sgw, 0, sizeof(ogs_sockaddr_t));
|
||||
sgw.ogs_sin_port = htons(GTPV1_U_UDP_PORT);
|
||||
if (bearer->sgw_s1u_ip.ipv6)
|
||||
{
|
||||
if (bearer->sgw_s1u_ip.ipv6) {
|
||||
sgw.ogs_sa_family = AF_INET6;
|
||||
if (bearer->sgw_s1u_ip.ipv4)
|
||||
memcpy(sgw.sin6.sin6_addr.s6_addr,
|
||||
|
@ -179,9 +209,7 @@ int testenb_gtpu_send(ogs_socknode_t *node, ogs_pkbuf_t *sendbuf)
|
|||
bearer->sgw_s1u_ip.addr6, IPV6_LEN);
|
||||
rv = ogs_socknode_fill_scope_id_in_local(&sgw);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sgw.ogs_sa_family = AF_INET;
|
||||
sgw.sin.sin_addr.s_addr = bearer->sgw_s1u_ip.addr;
|
||||
}
|
||||
|
@ -199,7 +227,6 @@ void testenb_gtpu_close(ogs_socknode_t *node)
|
|||
ogs_socknode_free(node);
|
||||
}
|
||||
|
||||
|
||||
int tests1ap_build_setup_req(
|
||||
ogs_pkbuf_t **pkbuf, S1AP_ENB_ID_PR present, uint32_t enb_id,
|
||||
int tac, uint16_t mcc, uint16_t mnc, uint16_t mnc_len)
|
||||
|
@ -281,8 +308,7 @@ int tests1ap_build_setup_req(
|
|||
rv = s1ap_encode_pdu(pkbuf, &pdu);
|
||||
s1ap_free_pdu(&pdu);
|
||||
|
||||
if (rv != OGS_OK)
|
||||
{
|
||||
if (rv != OGS_OK) {
|
||||
ogs_error("s1ap_encode_pdu() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
@ -1027,8 +1053,7 @@ int tests1ap_build_initial_context_setup_response(
|
|||
rv = s1ap_encode_pdu(pkbuf, &pdu);
|
||||
s1ap_free_pdu(&pdu);
|
||||
|
||||
if (rv != OGS_OK)
|
||||
{
|
||||
if (rv != OGS_OK) {
|
||||
ogs_error("s1ap_encode_pdu() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
@ -1517,12 +1542,10 @@ int tests1ap_build_tau_request(ogs_pkbuf_t **pkbuf, int i,
|
|||
ogs_pkbuf_put_data(*pkbuf,
|
||||
OGS_HEX(payload[i], strlen(payload[i]), hexbuf), len[i]);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
if (i == 0) {
|
||||
enb_ue_s1ap_id = htonl(enb_ue_s1ap_id << 8);
|
||||
memcpy((*pkbuf)->data + 11, &enb_ue_s1ap_id, 3);
|
||||
if (active_flag)
|
||||
{
|
||||
if (active_flag) {
|
||||
char *active_buf = (*pkbuf)->data + 26;
|
||||
*active_buf |= 0x08;
|
||||
}
|
||||
|
@ -1531,9 +1554,7 @@ int tests1ap_build_tau_request(ogs_pkbuf_t **pkbuf, int i,
|
|||
memcpy((*pkbuf)->data + 23, &seq, 1);
|
||||
m_tmsi = htonl(m_tmsi);
|
||||
memcpy((*pkbuf)->data + 109, &m_tmsi, 4);
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
} else if (i == 1) {
|
||||
ogs_assert(knas_int);
|
||||
|
||||
mme_ue_s1ap_id = htonl(mme_ue_s1ap_id << 8);
|
||||
|
@ -1549,8 +1570,7 @@ int tests1ap_build_tau_request(ogs_pkbuf_t **pkbuf, int i,
|
|||
snow_3g_f9(knas_int, seq, (0 << 27), 0,
|
||||
(*pkbuf)->data + 29, (52 << 3),
|
||||
(*pkbuf)->data + 25);
|
||||
}
|
||||
else
|
||||
} else
|
||||
ogs_assert_if_reached();
|
||||
|
||||
return OGS_OK;
|
||||
|
@ -1740,8 +1760,7 @@ int tests1ap_build_e_rab_setup_response(
|
|||
rv = s1ap_encode_pdu(pkbuf, &pdu);
|
||||
s1ap_free_pdu(&pdu);
|
||||
|
||||
if (rv != OGS_OK)
|
||||
{
|
||||
if (rv != OGS_OK) {
|
||||
ogs_error("s1ap_encode_pdu() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
@ -2116,8 +2135,7 @@ int tests1ap_build_path_switch_request(
|
|||
mme_ue = enb_ue->mme_ue;
|
||||
ogs_assert(mme_ue);
|
||||
|
||||
for (i = 0; i < num_of_bearer; i++)
|
||||
{
|
||||
for (i = 0; i < num_of_bearer; i++) {
|
||||
S1AP_E_RABToBeSwitchedDLItemIEs_t *item = NULL;
|
||||
S1AP_E_RABToBeSwitchedDLItem_t *e_rab = NULL;
|
||||
|
||||
|
@ -2138,15 +2156,12 @@ int tests1ap_build_path_switch_request(
|
|||
|
||||
e_rab->e_RAB_ID = ebi+i;
|
||||
|
||||
if (target == 0)
|
||||
{
|
||||
if (target == 0) {
|
||||
rv = ogs_getaddrinfo(&addr, AF_INET, ipstr1, GTPV1_U_UDP_PORT, 0);
|
||||
rv = gtp_sockaddr_to_f_teid(
|
||||
addr, NULL, &f_teid, &len);
|
||||
ogs_freeaddrinfo(addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rv = ogs_getaddrinfo(&addr, AF_INET, ipstr2, GTPV1_U_UDP_PORT, 0);
|
||||
rv = gtp_sockaddr_to_f_teid(
|
||||
addr, NULL, &f_teid, &len);
|
||||
|
@ -2197,8 +2212,7 @@ int tests1ap_build_path_switch_request(
|
|||
rv = s1ap_encode_pdu(pkbuf, &pdu);
|
||||
s1ap_free_pdu(&pdu);
|
||||
|
||||
if (rv != OGS_OK)
|
||||
{
|
||||
if (rv != OGS_OK) {
|
||||
ogs_error("s1ap_encode_pdu() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
@ -2383,8 +2397,7 @@ int tests1ap_build_handover_request_ack(
|
|||
*MME_UE_S1AP_ID = mme_ue_s1ap_id;
|
||||
*ENB_UE_S1AP_ID = enb_ue_s1ap_id;
|
||||
|
||||
for (i = 0; i < num_of_bearer; i++)
|
||||
{
|
||||
for (i = 0; i < num_of_bearer; i++) {
|
||||
S1AP_E_RABAdmittedItemIEs_t *item = NULL;
|
||||
S1AP_E_RABAdmittedItem_t *e_rab = NULL;
|
||||
|
||||
|
@ -2405,15 +2418,12 @@ int tests1ap_build_handover_request_ack(
|
|||
|
||||
e_rab->e_RAB_ID = ebi+i;
|
||||
|
||||
if (target == 0)
|
||||
{
|
||||
if (target == 0) {
|
||||
rv = ogs_getaddrinfo(&addr, AF_INET, ipstr1, GTPV1_U_UDP_PORT, 0);
|
||||
rv = gtp_sockaddr_to_f_teid(
|
||||
addr, NULL, &f_teid, &len);
|
||||
ogs_freeaddrinfo(addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rv = ogs_getaddrinfo(&addr, AF_INET, ipstr2, GTPV1_U_UDP_PORT, 0);
|
||||
rv = gtp_sockaddr_to_f_teid(
|
||||
addr, NULL, &f_teid, &len);
|
||||
|
@ -2453,8 +2463,7 @@ int tests1ap_build_handover_request_ack(
|
|||
rv = s1ap_encode_pdu(pkbuf, &pdu);
|
||||
s1ap_free_pdu(&pdu);
|
||||
|
||||
if (rv != OGS_OK)
|
||||
{
|
||||
if (rv != OGS_OK) {
|
||||
ogs_error("s1ap_encode_pdu() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
@ -2758,8 +2767,7 @@ int testgtpu_build_ping(
|
|||
gtp_h->type = GTPU_MSGTYPE_GPDU;
|
||||
gtp_h->teid = htonl(1);
|
||||
|
||||
if (dst_ipsub.family == AF_INET)
|
||||
{
|
||||
if (dst_ipsub.family == AF_INET) {
|
||||
struct ip *ip_h = NULL;
|
||||
struct icmp *icmp_h = NULL;
|
||||
|
||||
|
@ -2784,9 +2792,7 @@ int testgtpu_build_ping(
|
|||
icmp_h->icmp_seq = rand();
|
||||
icmp_h->icmp_id = rand();
|
||||
icmp_h->icmp_cksum = in_cksum((uint16_t *)icmp_h, ICMP_MINLEN);
|
||||
}
|
||||
else if (dst_ipsub.family == AF_INET6)
|
||||
{
|
||||
} else if (dst_ipsub.family == AF_INET6) {
|
||||
struct ip6_hdr *ip6_h = NULL;
|
||||
struct icmp6_hdr *icmp6_h = NULL;
|
||||
uint16_t plen = 0;
|
||||
|
@ -2821,8 +2827,7 @@ int testgtpu_build_ping(
|
|||
ip6_h->ip6_hlim = 0xff;
|
||||
memcpy(ip6_h->ip6_src.s6_addr, src_ipsub.sub, sizeof src_ipsub.sub);
|
||||
memcpy(ip6_h->ip6_dst.s6_addr, dst_ipsub.sub, sizeof dst_ipsub.sub);
|
||||
}
|
||||
else
|
||||
} else
|
||||
ogs_assert_if_reached();
|
||||
|
||||
*sendbuf = pkbuf;
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef TEST_PACKET_H
|
||||
#define TEST_PACKET_H
|
||||
|
||||
|
@ -10,10 +29,19 @@ extern "C" {
|
|||
int testpacket_init();
|
||||
int testpacket_final();
|
||||
|
||||
ogs_socknode_t *testenb_s1ap_client(const char *ipstr);
|
||||
ogs_pkbuf_t *testenb_s1ap_read(ogs_socknode_t *node);
|
||||
ogs_socknode_t *testsctp_server(const char *ipstr);
|
||||
ogs_socknode_t *testsctp_client(const char *ipstr);
|
||||
ogs_pkbuf_t *testsctp_read(ogs_socknode_t *node);
|
||||
|
||||
#define testenb_s1ap_client testsctp_client
|
||||
#define testenb_s1ap_read testsctp_read
|
||||
int testenb_s1ap_send(ogs_socknode_t *node, ogs_pkbuf_t *sendbuf);
|
||||
void testenb_s1ap_close(ogs_socknode_t *node);
|
||||
#define testenb_s1ap_close ogs_socknode_free
|
||||
|
||||
#define testvlr_sgsap_server testsctp_server
|
||||
#define testvlr_sgsap_read testsctp_read
|
||||
int testvlr_sgsap_send(ogs_socknode_t *node, ogs_pkbuf_t *sendbuf);
|
||||
#define testvlr_sgsap_close ogs_socknode_free
|
||||
|
||||
ogs_socknode_t *testenb_gtpu_server(const char *ipstr);
|
||||
ogs_pkbuf_t *testenb_gtpu_read(ogs_socknode_t *node);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "app-init.h"
|
||||
#include "test-packet.h"
|
||||
#include "test-app.h"
|
||||
|
||||
abts_suite *test_csfb(abts_suite *suite);
|
||||
|
||||
|
@ -47,12 +48,16 @@ static void test_fd_logger_handler(enum fd_hook_type type, struct msg * msg,
|
|||
}
|
||||
}
|
||||
|
||||
static ogs_socknode_t *sgsap = NULL;
|
||||
|
||||
void test_terminate(void)
|
||||
{
|
||||
ogs_msleep(300);
|
||||
|
||||
testvlr_sgsap_close(sgsap);
|
||||
|
||||
testpacket_final();
|
||||
epc_terminate();
|
||||
test_app_terminate();
|
||||
|
||||
base_finalize();
|
||||
ogs_core_finalize();
|
||||
|
@ -68,17 +73,21 @@ int test_initialize(app_param_t *param, int argc, const char *const argv[])
|
|||
ogs_core_initialize();
|
||||
base_initialize();
|
||||
|
||||
rv = epc_initialize(param);
|
||||
rv = test_app_initialize(param);
|
||||
if (rv != OGS_OK) {
|
||||
ogs_error("app_initialize() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
rv = testpacket_init();
|
||||
if (rv != OGS_OK) {
|
||||
ogs_error("testpacket() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
sgsap = testvlr_sgsap_server("127.0.0.2");
|
||||
ogs_assert(sgsap);
|
||||
|
||||
while(1) {
|
||||
if (connected_count == 1) break;
|
||||
ogs_msleep(50);
|
||||
|
|
|
@ -0,0 +1,270 @@
|
|||
#include "app/context.h"
|
||||
#include "app/application.h"
|
||||
|
||||
#include "app-init.h"
|
||||
|
||||
static ogs_proc_mutex_t *pcrf_sem1 = NULL;
|
||||
static ogs_proc_mutex_t *pcrf_sem2 = NULL;
|
||||
|
||||
static ogs_proc_mutex_t *pgw_sem1 = NULL;
|
||||
static ogs_proc_mutex_t *pgw_sem2 = NULL;
|
||||
|
||||
static ogs_proc_mutex_t *sgw_sem1 = NULL;
|
||||
static ogs_proc_mutex_t *sgw_sem2 = NULL;
|
||||
|
||||
static ogs_proc_mutex_t *hss_sem1 = NULL;
|
||||
static ogs_proc_mutex_t *hss_sem2 = NULL;
|
||||
|
||||
int test_epc_initialize(app_param_t *param);
|
||||
|
||||
int test_app_initialize(app_param_t *param)
|
||||
{
|
||||
param->name = "epc";
|
||||
return test_epc_initialize(param);
|
||||
}
|
||||
|
||||
int test_epc_initialize(app_param_t *param)
|
||||
{
|
||||
pid_t pid;
|
||||
int rv;
|
||||
|
||||
rv = app_will_initialize(param);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
/************************* PCRF Process **********************/
|
||||
pcrf_sem1 = ogs_proc_mutex_create(0); /* copied to PCRF/PGW/SGW/HSS process */
|
||||
pcrf_sem2 = ogs_proc_mutex_create(0); /* copied to PCRF/PGW/SGW/HSS process */
|
||||
|
||||
if (context_self()->config.parameter.no_pcrf == 0)
|
||||
{
|
||||
pid = fork();
|
||||
ogs_assert(pid >= 0);
|
||||
|
||||
if (pid == 0)
|
||||
{
|
||||
ogs_info("PCRF try to initialize");
|
||||
rv = pcrf_initialize();
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_info("PCRF initialize...done");
|
||||
|
||||
if (pcrf_sem1) ogs_proc_mutex_post(pcrf_sem1);
|
||||
if (pcrf_sem2) ogs_proc_mutex_wait(pcrf_sem2);
|
||||
|
||||
if (rv == OGS_OK)
|
||||
{
|
||||
ogs_info("PCRF try to terminate");
|
||||
pcrf_terminate();
|
||||
ogs_info("PCRF terminate...done");
|
||||
}
|
||||
|
||||
if (pcrf_sem1) ogs_proc_mutex_post(pcrf_sem1);
|
||||
|
||||
/* allocated from parent process */
|
||||
if (pcrf_sem1) ogs_proc_mutex_delete(pcrf_sem1);
|
||||
if (pcrf_sem2) ogs_proc_mutex_delete(pcrf_sem2);
|
||||
|
||||
context_final();
|
||||
ogs_core_finalize();
|
||||
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (pcrf_sem1) ogs_proc_mutex_wait(pcrf_sem1);
|
||||
}
|
||||
|
||||
|
||||
/************************* PGW Process **********************/
|
||||
pgw_sem1 = ogs_proc_mutex_create(0); /* copied to PGW/SGW/HSS process */
|
||||
pgw_sem2 = ogs_proc_mutex_create(0); /* copied to PGW/SGW/HSS process */
|
||||
|
||||
if (context_self()->config.parameter.no_pgw == 0)
|
||||
{
|
||||
pid = fork();
|
||||
ogs_assert(pid >= 0);
|
||||
|
||||
if (pid == 0)
|
||||
{
|
||||
/* allocated from parent process */
|
||||
if (pcrf_sem1) ogs_proc_mutex_delete(pcrf_sem1);
|
||||
if (pcrf_sem2) ogs_proc_mutex_delete(pcrf_sem2);
|
||||
|
||||
ogs_info("PGW try to initialize");
|
||||
rv = pgw_initialize();
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_info("PGW initialize...done");
|
||||
|
||||
if (pgw_sem1) ogs_proc_mutex_post(pgw_sem1);
|
||||
if (pgw_sem2) ogs_proc_mutex_wait(pgw_sem2);
|
||||
|
||||
if (rv == OGS_OK)
|
||||
{
|
||||
ogs_info("PGW try to terminate");
|
||||
pgw_terminate();
|
||||
ogs_info("PGW terminate...done");
|
||||
}
|
||||
|
||||
if (pgw_sem1) ogs_proc_mutex_post(pgw_sem1);
|
||||
|
||||
/* allocated from parent process */
|
||||
if (pgw_sem1) ogs_proc_mutex_delete(pgw_sem1);
|
||||
if (pgw_sem2) ogs_proc_mutex_delete(pgw_sem2);
|
||||
|
||||
context_final();
|
||||
ogs_core_finalize();
|
||||
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (pgw_sem1) ogs_proc_mutex_wait(pgw_sem1);
|
||||
}
|
||||
|
||||
|
||||
/************************* SGW Process **********************/
|
||||
sgw_sem1 = ogs_proc_mutex_create(0); /* copied to SGW/HSS process */
|
||||
sgw_sem2 = ogs_proc_mutex_create(0); /* copied to SGW/HSS process */
|
||||
|
||||
if (context_self()->config.parameter.no_sgw == 0)
|
||||
{
|
||||
pid = fork();
|
||||
ogs_assert(pid >= 0);
|
||||
|
||||
if (pid == 0)
|
||||
{
|
||||
/* allocated from parent process */
|
||||
if (pcrf_sem1) ogs_proc_mutex_delete(pcrf_sem1);
|
||||
if (pcrf_sem2) ogs_proc_mutex_delete(pcrf_sem2);
|
||||
if (pgw_sem1) ogs_proc_mutex_delete(pgw_sem1);
|
||||
if (pgw_sem2) ogs_proc_mutex_delete(pgw_sem2);
|
||||
|
||||
ogs_info("SGW try to initialize");
|
||||
rv = sgw_initialize();
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_info("SGW initialize...done");
|
||||
|
||||
if (sgw_sem1) ogs_proc_mutex_post(sgw_sem1);
|
||||
if (sgw_sem2) ogs_proc_mutex_wait(sgw_sem2);
|
||||
|
||||
if (rv == OGS_OK)
|
||||
{
|
||||
ogs_info("SGW try to terminate");
|
||||
sgw_terminate();
|
||||
ogs_info("SGW terminate...done");
|
||||
}
|
||||
|
||||
if (sgw_sem1) ogs_proc_mutex_post(sgw_sem1);
|
||||
|
||||
/* allocated from parent process */
|
||||
if (sgw_sem1) ogs_proc_mutex_delete(sgw_sem1);
|
||||
if (sgw_sem2) ogs_proc_mutex_delete(sgw_sem2);
|
||||
|
||||
context_final();
|
||||
ogs_core_finalize();
|
||||
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (sgw_sem1) ogs_proc_mutex_wait(sgw_sem1);
|
||||
}
|
||||
|
||||
|
||||
/************************* HSS Process **********************/
|
||||
hss_sem1 = ogs_proc_mutex_create(0); /* copied to HSS process */
|
||||
hss_sem2 = ogs_proc_mutex_create(0); /* copied to HSS process */
|
||||
|
||||
if (context_self()->config.parameter.no_hss == 0)
|
||||
{
|
||||
pid = fork();
|
||||
ogs_assert(pid >= 0);
|
||||
|
||||
if (pid == 0)
|
||||
{
|
||||
/* allocated from parent process */
|
||||
if (pcrf_sem1) ogs_proc_mutex_delete(pcrf_sem1);
|
||||
if (pcrf_sem2) ogs_proc_mutex_delete(pcrf_sem2);
|
||||
if (pgw_sem1) ogs_proc_mutex_delete(pgw_sem1);
|
||||
if (pgw_sem2) ogs_proc_mutex_delete(pgw_sem2);
|
||||
if (sgw_sem1) ogs_proc_mutex_delete(sgw_sem1);
|
||||
if (sgw_sem2) ogs_proc_mutex_delete(sgw_sem2);
|
||||
|
||||
ogs_info("HSS try to initialize");
|
||||
rv = hss_initialize();
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_info("HSS initialize...done");
|
||||
|
||||
if (hss_sem1) ogs_proc_mutex_post(hss_sem1);
|
||||
if (hss_sem2) ogs_proc_mutex_wait(hss_sem2);
|
||||
|
||||
if (rv == OGS_OK)
|
||||
{
|
||||
ogs_info("HSS try to terminate");
|
||||
hss_terminate();
|
||||
ogs_info("HSS terminate...done");
|
||||
}
|
||||
|
||||
if (hss_sem1) ogs_proc_mutex_post(hss_sem1);
|
||||
|
||||
if (hss_sem1) ogs_proc_mutex_delete(hss_sem1);
|
||||
if (hss_sem2) ogs_proc_mutex_delete(hss_sem2);
|
||||
|
||||
context_final();
|
||||
ogs_core_finalize();
|
||||
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (hss_sem1) ogs_proc_mutex_wait(hss_sem1);
|
||||
}
|
||||
|
||||
ogs_info("MME try to initialize");
|
||||
rv = mme_initialize();
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_info("MME initialize...done");
|
||||
|
||||
rv = app_did_initialize();
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
return OGS_OK;;
|
||||
}
|
||||
|
||||
void test_app_terminate(void)
|
||||
{
|
||||
app_will_terminate();
|
||||
|
||||
ogs_info("MME try to terminate");
|
||||
mme_terminate();
|
||||
ogs_info("MME terminate...done");
|
||||
|
||||
if (context_self()->config.parameter.no_hss == 0)
|
||||
{
|
||||
if (hss_sem2) ogs_proc_mutex_post(hss_sem2);
|
||||
if (hss_sem1) ogs_proc_mutex_wait(hss_sem1);
|
||||
}
|
||||
if (hss_sem1) ogs_proc_mutex_delete(hss_sem1);
|
||||
if (hss_sem2) ogs_proc_mutex_delete(hss_sem2);
|
||||
|
||||
if (context_self()->config.parameter.no_sgw == 0)
|
||||
{
|
||||
if (sgw_sem2) ogs_proc_mutex_post(sgw_sem2);
|
||||
if (sgw_sem1) ogs_proc_mutex_wait(sgw_sem1);
|
||||
}
|
||||
if (sgw_sem1) ogs_proc_mutex_delete(sgw_sem1);
|
||||
if (sgw_sem2) ogs_proc_mutex_delete(sgw_sem2);
|
||||
|
||||
if (context_self()->config.parameter.no_pgw == 0)
|
||||
{
|
||||
if (pgw_sem2) ogs_proc_mutex_post(pgw_sem2);
|
||||
if (pgw_sem1) ogs_proc_mutex_wait(pgw_sem1);
|
||||
}
|
||||
if (pgw_sem1) ogs_proc_mutex_delete(pgw_sem1);
|
||||
if (pgw_sem2) ogs_proc_mutex_delete(pgw_sem2);
|
||||
|
||||
if (context_self()->config.parameter.no_pcrf == 0)
|
||||
{
|
||||
if (pcrf_sem2) ogs_proc_mutex_post(pcrf_sem2);
|
||||
if (pcrf_sem1) ogs_proc_mutex_wait(pcrf_sem1);
|
||||
}
|
||||
if (pcrf_sem1) ogs_proc_mutex_delete(pcrf_sem1);
|
||||
if (pcrf_sem2) ogs_proc_mutex_delete(pcrf_sem2);
|
||||
|
||||
app_did_terminate();
|
||||
}
|
Loading…
Reference in New Issue