fix indentation

This commit is contained in:
Sukchan Lee 2019-08-03 22:08:20 +09:00
parent 56ff495e7b
commit 715d2b7922
4 changed files with 137 additions and 127 deletions

View File

@ -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/>.
*/
#include "gtp/gtp-xact.h"
#include "fd/fd-lib.h"
@ -84,8 +103,7 @@ void pcscf_rx_send_aar(uint8_t **rx_sid, const char *ip,
}
/* Find Diameter Rx Session */
if (*rx_sid)
{
if (*rx_sid) {
/* Retrieve session by Session-Id */
size_t sidlen = strlen((char *)*rx_sid);
ret = fd_sess_fromsid_msg(*rx_sid, sidlen, &session, &new);
@ -97,9 +115,7 @@ void pcscf_rx_send_aar(uint8_t **rx_sid, const char *ip,
ogs_assert(ret == 0);
/* Save the session associated with the message */
ret = fd_msg_sess_set(req, session);
}
else
{
} else {
/* Create a new session */
#define RX_APP_SID_OPT "app_rx"
ret = fd_msg_new_session(req, (os0_t)RX_APP_SID_OPT,
@ -111,8 +127,7 @@ void pcscf_rx_send_aar(uint8_t **rx_sid, const char *ip,
/* Retrieve session state in this session */
ret = fd_sess_state_retrieve(pcscf_rx_reg, session, &sess_data);
if (!sess_data)
{
if (!sess_data) {
os0_t sid;
size_t sidlen;
@ -175,8 +190,7 @@ void pcscf_rx_send_aar(uint8_t **rx_sid, const char *ip,
ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp);
ogs_assert(ret == 0);
if (ipsub.family == AF_INET)
{
if (ipsub.family == AF_INET) {
/* Set Framed-IP-Address */
ret = fd_msg_avp_new(rx_framed_ip_address, 0, &avp);
ogs_assert(ret == 0);
@ -186,9 +200,7 @@ void pcscf_rx_send_aar(uint8_t **rx_sid, const char *ip,
ogs_assert(ret == 0);
ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp);
ogs_assert(ret == 0);
}
else if (ipsub.family == AF_INET6)
{
} else if (ipsub.family == AF_INET6) {
/* Set Framed-IPv6-Prefix */
ret = fd_msg_avp_new(rx_framed_ipv6_prefix, 0, &avp);
ogs_assert(ret == 0);
@ -226,8 +238,7 @@ void pcscf_rx_send_aar(uint8_t **rx_sid, const char *ip,
ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1);
ogs_assert(ret == 0);
if (qos_type == 1)
{
if (qos_type == 1) {
ret = fd_msg_avp_new(rx_max_requested_bandwidth_dl, 0, &avpch1);
ogs_assert(ret == 0);
val.i32 = 96000;
@ -259,9 +270,7 @@ void pcscf_rx_send_aar(uint8_t **rx_sid, const char *ip,
ogs_assert(ret == 0);
ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1);
ogs_assert(ret == 0);
}
else if (qos_type == 2)
{
} else if (qos_type == 2) {
ret = fd_msg_avp_new(rx_max_requested_bandwidth_dl, 0, &avpch1);
ogs_assert(ret == 0);
val.i32 = 96000;
@ -295,8 +304,7 @@ void pcscf_rx_send_aar(uint8_t **rx_sid, const char *ip,
ogs_assert(ret == 0);
}
if (flow_presence)
{
if (flow_presence) {
/* Set Media-Sub-Component #1 */
ret = fd_msg_avp_new(rx_media_sub_component, 0, &avpch1);
@ -433,32 +441,25 @@ static void pcscf_rx_aaa_cb(void *data, struct msg **msg)
/* Value of Result Code */
ret = fd_msg_search_avp(*msg, fd_result_code, &avp);
ogs_assert(ret == 0);
if (avp)
{
if (avp) {
ret = fd_msg_avp_hdr(avp, &hdr);
ogs_assert(ret == 0);
result_code = hdr->avp_value->i32;
ogs_debug("Result Code: %d\n", hdr->avp_value->i32);
}
else
{
} else {
ret = fd_msg_search_avp(*msg, fd_experimental_result, &avp);
ogs_assert(ret == 0);
if (avp)
{
if (avp) {
ret = fd_avp_search_avp(avp, fd_experimental_result_code, &avpch1);
ogs_assert(ret == 0);
if (avpch1)
{
if (avpch1) {
ret = fd_msg_avp_hdr(avpch1, &hdr);
ogs_assert(ret == 0);
result_code = hdr->avp_value->i32;
ogs_debug("Experimental Result Code: %d\n",
result_code);
}
}
else
{
} else {
ogs_error("no Result-Code");
error++;
}
@ -467,15 +468,12 @@ static void pcscf_rx_aaa_cb(void *data, struct msg **msg)
/* Value of Origin-Host */
ret = fd_msg_search_avp(*msg, fd_origin_host, &avp);
ogs_assert(ret == 0);
if (avp)
{
if (avp) {
ret = fd_msg_avp_hdr(avp, &hdr);
ogs_assert(ret == 0);
ogs_debug("From '%.*s' ",
(int)hdr->avp_value->os.len, hdr->avp_value->os.data);
}
else
{
} else {
ogs_error("no_Origin-Host ");
error++;
}
@ -483,21 +481,17 @@ static void pcscf_rx_aaa_cb(void *data, struct msg **msg)
/* Value of Origin-Realm */
ret = fd_msg_search_avp(*msg, fd_origin_realm, &avp);
ogs_assert(ret == 0);
if (avp)
{
if (avp) {
ret = fd_msg_avp_hdr(avp, &hdr);
ogs_assert(ret == 0);
ogs_debug("('%.*s') ",
(int)hdr->avp_value->os.len, hdr->avp_value->os.data);
}
else
{
} else {
ogs_error("no_Origin-Realm ");
error++;
}
if (result_code != ER_DIAMETER_SUCCESS)
{
if (result_code != ER_DIAMETER_SUCCESS) {
ogs_warn("ERROR DIAMETER Result Code(%d)", result_code);
error++;
goto out;
@ -508,8 +502,7 @@ out:
ogs_assert(pthread_mutex_lock(&fd_logger_self()->stats_lock) == 0);
dur = ((ts.tv_sec - sess_data->ts.tv_sec) * 1000000) +
((ts.tv_nsec - sess_data->ts.tv_nsec) / 1000);
if (fd_logger_self()->stats.nb_recv)
{
if (fd_logger_self()->stats.nb_recv) {
/* Ponderate in the avg */
fd_logger_self()->stats.avg = (fd_logger_self()->stats.avg *
fd_logger_self()->stats.nb_recv + dur) /
@ -519,9 +512,7 @@ out:
fd_logger_self()->stats.shortest = dur;
if (dur > fd_logger_self()->stats.longest)
fd_logger_self()->stats.longest = dur;
}
else
{
} else {
fd_logger_self()->stats.shortest = dur;
fd_logger_self()->stats.longest = dur;
fd_logger_self()->stats.avg = dur;
@ -602,13 +593,10 @@ static int pcscf_rx_asr_cb( struct msg **msg, struct avp *avp,
/* Get Abort-Cause */
ret = fd_msg_search_avp(qry, rx_abort_cause, &avp);
ogs_assert(ret == 0);
if (avp)
{
if (avp) {
ret = fd_msg_avp_hdr(avp, &hdr);
ogs_assert(ret == 0);
}
else
{
} else {
ogs_error("no_Abort-Cause ");
}
@ -760,32 +748,25 @@ static void pcscf_rx_sta_cb(void *data, struct msg **msg)
/* Value of Result Code */
ret = fd_msg_search_avp(*msg, fd_result_code, &avp);
ogs_assert(ret == 0);
if (avp)
{
if (avp) {
ret = fd_msg_avp_hdr(avp, &hdr);
ogs_assert(ret == 0);
result_code = hdr->avp_value->i32;
ogs_debug("Result Code: %d\n", hdr->avp_value->i32);
}
else
{
} else {
ret = fd_msg_search_avp(*msg, fd_experimental_result, &avp);
ogs_assert(ret == 0);
if (avp)
{
if (avp) {
ret = fd_avp_search_avp(avp, fd_experimental_result_code, &avpch1);
ogs_assert(ret == 0);
if (avpch1)
{
if (avpch1) {
ret = fd_msg_avp_hdr(avpch1, &hdr);
ogs_assert(ret == 0);
result_code = hdr->avp_value->i32;
ogs_debug("Experimental Result Code: %d\n",
result_code);
}
}
else
{
} else {
ogs_error("no Result-Code");
error++;
}
@ -794,15 +775,12 @@ static void pcscf_rx_sta_cb(void *data, struct msg **msg)
/* Value of Origin-Host */
ret = fd_msg_search_avp(*msg, fd_origin_host, &avp);
ogs_assert(ret == 0);
if (avp)
{
if (avp) {
ret = fd_msg_avp_hdr(avp, &hdr);
ogs_assert(ret == 0);
ogs_debug("From '%.*s' ",
(int)hdr->avp_value->os.len, hdr->avp_value->os.data);
}
else
{
} else {
ogs_error("no_Origin-Host ");
error++;
}
@ -810,21 +788,17 @@ static void pcscf_rx_sta_cb(void *data, struct msg **msg)
/* Value of Origin-Realm */
ret = fd_msg_search_avp(*msg, fd_origin_realm, &avp);
ogs_assert(ret == 0);
if (avp)
{
if (avp) {
ret = fd_msg_avp_hdr(avp, &hdr);
ogs_assert(ret == 0);
ogs_debug("('%.*s') ",
(int)hdr->avp_value->os.len, hdr->avp_value->os.data);
}
else
{
} else {
ogs_error("no_Origin-Realm ");
error++;
}
if (result_code != ER_DIAMETER_SUCCESS)
{
if (result_code != ER_DIAMETER_SUCCESS) {
ogs_warn("ERROR DIAMETER Result Code(%d)", result_code);
error++;
goto out;
@ -835,8 +809,7 @@ out:
ogs_assert(pthread_mutex_lock(&fd_logger_self()->stats_lock) == 0);
dur = ((ts.tv_sec - sess_data->ts.tv_sec) * 1000000) +
((ts.tv_nsec - sess_data->ts.tv_nsec) / 1000);
if (fd_logger_self()->stats.nb_recv)
{
if (fd_logger_self()->stats.nb_recv) {
/* Ponderate in the avg */
fd_logger_self()->stats.avg = (fd_logger_self()->stats.avg *
fd_logger_self()->stats.nb_recv + dur) /
@ -846,9 +819,7 @@ out:
fd_logger_self()->stats.shortest = dur;
if (dur > fd_logger_self()->stats.longest)
fd_logger_self()->stats.longest = dur;
}
else
{
} else {
fd_logger_self()->stats.shortest = dur;
fd_logger_self()->stats.longest = dur;
fd_logger_self()->stats.avg = dur;

View File

@ -1,9 +1,28 @@
#ifndef __PCSCF_FD_PATH_H__
#define __PCSCF_FD_PATH_H__
/*
* 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 PCSCF_FD_PATH_H
#define PCSCF_FD_PATH_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif
int pcscf_fd_init(void);
void pcscf_fd_final(void);
@ -14,7 +33,7 @@ void pcscf_rx_send_str(uint8_t *rx_sid);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
#endif /* __PCSCF_FD_PATH_H__ */
#endif /* PCSCF_FD_PATH_H */

View File

@ -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/>.
*/
#include "mme/ogs-sctp.h"
#include "app/context.h"
@ -33,13 +52,11 @@ int test_app_initialize(app_param_t *param)
pcrf_sem1 = ogs_proc_mutex_create(0); /* copied to PCRF/PGW/SGW/HSS/MME */
pcrf_sem2 = ogs_proc_mutex_create(0); /* copied to PCRF/PGW/SGW/HSS/MME */
if (context_self()->config.parameter.no_pcrf == 0)
{
if (context_self()->config.parameter.no_pcrf == 0) {
pid = fork();
ogs_assert(pid >= 0);
if (pid == 0)
{
if (pid == 0) {
ogs_info("PCRF try to initialize");
rv = pcrf_initialize();
ogs_assert(rv == OGS_OK);
@ -48,8 +65,7 @@ int test_app_initialize(app_param_t *param)
if (pcrf_sem1) ogs_proc_mutex_post(pcrf_sem1);
if (pcrf_sem2) ogs_proc_mutex_wait(pcrf_sem2);
if (rv == OGS_OK)
{
if (rv == OGS_OK) {
ogs_info("PCRF try to terminate");
pcrf_terminate();
ogs_info("PCRF terminate...done");
@ -75,13 +91,11 @@ int test_app_initialize(app_param_t *param)
pgw_sem1 = ogs_proc_mutex_create(0); /* copied to PGW/SGW/HSS/MME */
pgw_sem2 = ogs_proc_mutex_create(0); /* copied to PGW/SGW/HSS/MME */
if (context_self()->config.parameter.no_pgw == 0)
{
if (context_self()->config.parameter.no_pgw == 0) {
pid = fork();
ogs_assert(pid >= 0);
if (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);
@ -94,8 +108,7 @@ int test_app_initialize(app_param_t *param)
if (pgw_sem1) ogs_proc_mutex_post(pgw_sem1);
if (pgw_sem2) ogs_proc_mutex_wait(pgw_sem2);
if (rv == OGS_OK)
{
if (rv == OGS_OK) {
ogs_info("PGW try to terminate");
pgw_terminate();
ogs_info("PGW terminate...done");
@ -121,13 +134,11 @@ int test_app_initialize(app_param_t *param)
sgw_sem1 = ogs_proc_mutex_create(0); /* copied to SGW/HSS/MME */
sgw_sem2 = ogs_proc_mutex_create(0); /* copied to SGW/HSS/MME */
if (context_self()->config.parameter.no_sgw == 0)
{
if (context_self()->config.parameter.no_sgw == 0) {
pid = fork();
ogs_assert(pid >= 0);
if (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);
@ -142,8 +153,7 @@ int test_app_initialize(app_param_t *param)
if (sgw_sem1) ogs_proc_mutex_post(sgw_sem1);
if (sgw_sem2) ogs_proc_mutex_wait(sgw_sem2);
if (rv == OGS_OK)
{
if (rv == OGS_OK) {
ogs_info("SGW try to terminate");
sgw_terminate();
ogs_info("SGW terminate...done");
@ -169,13 +179,11 @@ int test_app_initialize(app_param_t *param)
hss_sem1 = ogs_proc_mutex_create(0); /* copied to HSS/MME */
hss_sem2 = ogs_proc_mutex_create(0); /* copied to HSS/MME */
if (context_self()->config.parameter.no_hss == 0)
{
if (context_self()->config.parameter.no_hss == 0) {
pid = fork();
ogs_assert(pid >= 0);
if (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);
@ -192,8 +200,7 @@ int test_app_initialize(app_param_t *param)
if (hss_sem1) ogs_proc_mutex_post(hss_sem1);
if (hss_sem2) ogs_proc_mutex_wait(hss_sem2);
if (rv == OGS_OK)
{
if (rv == OGS_OK) {
ogs_info("HSS try to terminate");
hss_terminate();
ogs_info("HSS terminate...done");
@ -222,8 +229,7 @@ int test_app_initialize(app_param_t *param)
pid = fork();
ogs_assert(pid >= 0);
if (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);
@ -243,8 +249,7 @@ int test_app_initialize(app_param_t *param)
if (mme_sem1) ogs_proc_mutex_post(mme_sem1);
if (mme_sem2) ogs_proc_mutex_wait(mme_sem2);
if (rv == OGS_OK)
{
if (rv == OGS_OK) {
ogs_info("MME try to terminate");
mme_terminate();
ogs_sctp_final();
@ -283,32 +288,28 @@ void test_app_terminate(void)
if (mme_sem1) ogs_proc_mutex_delete(mme_sem1);
if (mme_sem2) ogs_proc_mutex_delete(mme_sem2);
if (context_self()->config.parameter.no_hss == 0)
{
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 (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 (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 (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);
}

View File

@ -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 <mongoc.h>
#include "core/abts.h"
@ -112,8 +130,7 @@ static void volte_test1(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("001010123456819"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
@ -216,6 +233,7 @@ static void volte_test1(abts_case *tc, void *data)
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Send AA-Request */
ogs_msleep(300);
pcscf_rx_send_aar(&rx_sid, "45.45.0.3", 1, 1);
/* Receive E-RAB Setup Request +
@ -237,6 +255,7 @@ static void volte_test1(abts_case *tc, void *data)
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Send AA-Request without Flow */
ogs_msleep(300);
pcscf_rx_send_aar(&rx_sid, "45.45.0.3", 2, 1);
/* Receive E-RAB Modify Request +
@ -428,8 +447,7 @@ static void volte_test2(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("001010123456819"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
@ -550,6 +568,7 @@ static void volte_test2(abts_case *tc, void *data)
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Send AA-Request */
ogs_msleep(300);
pcscf_rx_send_aar(&rx_sid, "45.45.0.5", 0, 1);
/* Receive downlink NAS transport +