forked from acouzens/open5gs
Use the process interface instead of fork()
- CommandLine Options is also changed - PID File removed (Old-style daemon)
This commit is contained in:
parent
33c5562835
commit
0aae608c5c
|
@ -211,8 +211,8 @@ AC_CONFIG_FILES([support/logrotate/Makefile])
|
|||
AC_CONFIG_FILES([support/newsyslog/nextepc.conf])
|
||||
AC_CONFIG_FILES([support/newsyslog/Makefile])
|
||||
AC_CONFIG_FILES([support/Makefile])
|
||||
AC_CONFIG_FILES([tests/sample.conf])
|
||||
AC_CONFIG_FILES([tests/sample-simple.conf])
|
||||
AC_CONFIG_FILES([tests/sample-complex.conf])
|
||||
AC_CONFIG_FILES([tests/sample-volte.conf])
|
||||
AC_CONFIG_FILES([tests/sample-csfb.conf])
|
||||
AC_CONFIG_FILES([tests/Makefile])
|
||||
|
|
|
@ -62,6 +62,8 @@ extern "C" {
|
|||
#define MAX_FILEPATH_LEN 256
|
||||
#define MAX_FQDN_LEN 256
|
||||
|
||||
#define OGS_ARG_MAX 256
|
||||
|
||||
#define NEXT_ID(__id, __min, __max) \
|
||||
((__id) = ((__id) == (__max) ? (__min) : ((__id) + 1)))
|
||||
#define COMPARE_ID(__id1, __id2, __max) \
|
||||
|
|
|
@ -944,7 +944,9 @@ void fd_psm_abord(struct fd_peer * peer )
|
|||
fd_psm_cleanup(peer, 1);
|
||||
|
||||
/* Destroy the event list */
|
||||
#if 0 /* modified by acetcom */
|
||||
CHECK_FCT_DO( fd_fifo_del(&peer->p_events), /* continue */ );
|
||||
#endif
|
||||
|
||||
/* Remaining cleanups are performed in fd_peer_free */
|
||||
return;
|
||||
|
|
|
@ -397,7 +397,11 @@ int fd_peer_fini()
|
|||
wait_until.tv_nsec = now.tv_nsec;
|
||||
}
|
||||
|
||||
#if 0 /* modified by acetcom */
|
||||
while ((!list_empty) && (TS_IS_INFERIOR(&now, &wait_until))) {
|
||||
#else
|
||||
if (!list_empty) {
|
||||
#endif
|
||||
|
||||
/* Allow the PSM(s) to execute */
|
||||
usleep(100000);
|
||||
|
|
210
main.c
210
main.c
|
@ -9,56 +9,44 @@
|
|||
#include "app/application.h"
|
||||
#include "app-init.h"
|
||||
|
||||
static char *version = "NextEPC daemon v" PACKAGE_VERSION;
|
||||
|
||||
static void show_version()
|
||||
void show_version()
|
||||
{
|
||||
printf("%s", version);
|
||||
printf("%s\n\n", app_version());
|
||||
}
|
||||
|
||||
static void show_help(const char *name)
|
||||
void show_help(const char *name)
|
||||
{
|
||||
printf("%s", version);
|
||||
|
||||
printf("\n"
|
||||
"Usage: %s [arguments]\n"
|
||||
"\n"
|
||||
"Arguments:\n"
|
||||
" -v Show version\n"
|
||||
" -h Show help\n"
|
||||
" -D Start as daemon\n"
|
||||
" -f Set configuration file name\n"
|
||||
" -l log_file Log file path to be logged to\n"
|
||||
" -p pid_file PID file path\n"
|
||||
" -d core:gtp:event Enable debugging\n"
|
||||
" -t sock:mem: Enable trace\n"
|
||||
"\n", name);
|
||||
printf("Usage: %s [options]\n"
|
||||
"Options:\n"
|
||||
" -c filename : set configuration file\n"
|
||||
" -l filename : set logging file\n"
|
||||
" -e level : set global log-level (default:info)\n"
|
||||
" -m domain : set log-domain (e.g. mme:sgw:gtp)\n"
|
||||
" -d : print lots of debugging information\n"
|
||||
" -t : print tracing information for developer\n"
|
||||
" -D : start as a daemon\n"
|
||||
" -v : show version number and exit\n"
|
||||
" -h : show this message and exit\n"
|
||||
"\n", name);
|
||||
}
|
||||
|
||||
static int check_signal(int signum)
|
||||
{
|
||||
switch (signum)
|
||||
{
|
||||
case SIGTERM:
|
||||
case SIGINT:
|
||||
{
|
||||
ogs_info("%s received",
|
||||
signum == SIGTERM ? "SIGTERM" : "SIGINT");
|
||||
switch (signum) {
|
||||
case SIGTERM:
|
||||
case SIGINT:
|
||||
ogs_info("%s received",
|
||||
signum == SIGTERM ? "SIGTERM" : "SIGINT");
|
||||
|
||||
return 1;
|
||||
}
|
||||
case SIGHUP:
|
||||
{
|
||||
ogs_info("SIGHUP received");
|
||||
app_logger_restart();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ogs_error("Signal-%d received (%s)",
|
||||
signum, ogs_signal_description_get(signum));
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
case SIGHUP:
|
||||
ogs_info("SIGHUP received");
|
||||
app_logger_restart();
|
||||
break;
|
||||
default:
|
||||
ogs_error("Signal-NUM[%d] received (%s)",
|
||||
signum, ogs_signal_description_get(signum));
|
||||
break;
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
@ -78,26 +66,32 @@ int main(int argc, char *argv[])
|
|||
*
|
||||
* Keep the order of starting-up
|
||||
*/
|
||||
int rv;
|
||||
int i;
|
||||
app_param_t param;
|
||||
const char *debug_mask = NULL;
|
||||
const char *trace_mask = NULL;
|
||||
int rv, i, opt;
|
||||
ogs_getopt_t options;
|
||||
struct {
|
||||
char *config_file;
|
||||
char *log_file;
|
||||
char *log_level;
|
||||
char *domain_mask;
|
||||
|
||||
memset(¶m, 0, sizeof(param));
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (!strcmp(argv[i], "-v"))
|
||||
{
|
||||
bool enable_debug;
|
||||
bool enable_trace;
|
||||
} optarg;
|
||||
char *argv_out[argc];
|
||||
|
||||
memset(&optarg, 0, sizeof(optarg));
|
||||
|
||||
ogs_getopt_init(&options, argv);
|
||||
while ((opt = ogs_getopt(&options, "vhDc:l:e:m:dt")) != -1) {
|
||||
switch (opt) {
|
||||
case 'v':
|
||||
show_version();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
if (!strcmp(argv[i], "-h"))
|
||||
{
|
||||
return OGS_OK;
|
||||
case 'h':
|
||||
show_help(argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
if (!strcmp(argv[i], "-D"))
|
||||
return OGS_OK;
|
||||
case 'D':
|
||||
#if !defined(_WIN32)
|
||||
{
|
||||
pid_t pid;
|
||||
pid = fork();
|
||||
|
@ -113,63 +107,81 @@ int main(int argc, char *argv[])
|
|||
|
||||
setsid();
|
||||
umask(027);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-f"))
|
||||
{
|
||||
param.config_path = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-l"))
|
||||
{
|
||||
param.log_path = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-p"))
|
||||
{
|
||||
param.pid_path = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-d"))
|
||||
{
|
||||
param.log_level = OGS_LOG_DEBUG;
|
||||
param.log_domain = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-t"))
|
||||
{
|
||||
param.log_level = OGS_LOG_TRACE;
|
||||
param.log_domain = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (argv[i][0] == '-') {
|
||||
#else
|
||||
printf("%s: Not Support in WINDOWS", argv[0]);
|
||||
#endif
|
||||
break;
|
||||
case 'c':
|
||||
optarg.config_file = options.optarg;
|
||||
break;
|
||||
case 'l':
|
||||
optarg.log_file = options.optarg;
|
||||
break;
|
||||
case 'e':
|
||||
optarg.log_level = options.optarg;
|
||||
break;
|
||||
case 'm':
|
||||
optarg.domain_mask = options.optarg;
|
||||
break;
|
||||
case 'd':
|
||||
optarg.enable_debug = true;
|
||||
break;
|
||||
case 't':
|
||||
optarg.enable_trace = true;
|
||||
break;
|
||||
case '?':
|
||||
fprintf(stderr, "%s: %s\n", argv[0], options.errmsg);
|
||||
show_help(argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
return OGS_ERROR;
|
||||
default:
|
||||
fprintf(stderr, "%s: should not be reached\n", OGS_FUNC);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
atexit(terminate);
|
||||
if (optarg.enable_debug) optarg.log_level = "debug";
|
||||
if (optarg.enable_trace) optarg.log_level = "trace";
|
||||
|
||||
i = 0;
|
||||
argv_out[i++] = argv[0];
|
||||
|
||||
if (optarg.config_file) {
|
||||
argv_out[i++] = "-c";
|
||||
argv_out[i++] = optarg.config_file;
|
||||
}
|
||||
if (optarg.log_file) {
|
||||
argv_out[i++] = "-l";
|
||||
argv_out[i++] = optarg.log_file;
|
||||
}
|
||||
if (optarg.log_level) {
|
||||
argv_out[i++] = "-e";
|
||||
argv_out[i++] = optarg.log_level;
|
||||
}
|
||||
if (optarg.domain_mask) {
|
||||
argv_out[i++] = "-m";
|
||||
argv_out[i++] = optarg.domain_mask;
|
||||
}
|
||||
|
||||
argv_out[i] = NULL;
|
||||
|
||||
ogs_core_initialize();
|
||||
ogs_setup_signal_thread();
|
||||
base_initialize();
|
||||
|
||||
ogs_info("NextEPC daemon start");
|
||||
ogs_log_print(OGS_LOG_INFO, "\n");
|
||||
|
||||
rv = app_initialize(¶m);
|
||||
if (rv != OGS_OK)
|
||||
{
|
||||
rv = app_initialize(argv_out);
|
||||
if (rv != OGS_OK) {
|
||||
if (rv == OGS_RETRY)
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
ogs_fatal("NextEPC initialization failed. Aborted");
|
||||
return EXIT_FAILURE;
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
ogs_log_print(OGS_LOG_INFO, "\n\n%s\n\n", version);
|
||||
atexit(terminate);
|
||||
ogs_signal_thread(check_signal);
|
||||
|
||||
ogs_info("NextEPC daemon terminating...");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,11 +5,14 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
int app_initialize(app_param_t *param);
|
||||
#define app_terminate epc_terminate
|
||||
/* For testing */
|
||||
void epc_child_terminate(void);
|
||||
ogs_thread_t *epc_child_create(char *name, char **argv);
|
||||
|
||||
int epc_initialize(app_param_t *param);
|
||||
void epc_terminate(void);
|
||||
char *app_version(void);
|
||||
|
||||
int app_initialize(char **argv);
|
||||
void app_terminate(void);
|
||||
|
||||
int mme_initialize();
|
||||
void mme_terminate(void);
|
||||
|
|
|
@ -22,26 +22,67 @@
|
|||
#include "context.h"
|
||||
#include "application.h"
|
||||
|
||||
#define DEFAULT_CONFIG_FILE_PATH SYSCONF_DIR "nextepc/nextepc.conf"
|
||||
#define DEFAULT_RUNTIME_DIR_PATH LOCALSTATE_DIR "run/"
|
||||
#include "base/context.h"
|
||||
|
||||
static int log_pid(const char *app_name, const char *pid_path);
|
||||
#define DEFAULT_CONFIG_FILENAME SYSCONF_DIR "nextepc/nextepc.conf"
|
||||
|
||||
int app_will_initialize(app_param_t *param)
|
||||
static char *version = "NextEPC daemon v" PACKAGE_VERSION;
|
||||
|
||||
char *app_version()
|
||||
{
|
||||
int rv;
|
||||
ogs_assert(param);
|
||||
return version;
|
||||
}
|
||||
|
||||
int app_will_initialize(char **argv)
|
||||
{
|
||||
int rv, opt;
|
||||
ogs_getopt_t options;
|
||||
struct {
|
||||
char *config_file;
|
||||
char *log_file;
|
||||
char *log_level;
|
||||
char *domain_mask;
|
||||
|
||||
bool enable_debug;
|
||||
bool enable_trace;
|
||||
} optarg;
|
||||
|
||||
context_init();
|
||||
|
||||
if (param->name) {
|
||||
rv = log_pid(param->name, param->pid_path);
|
||||
if (rv != OGS_OK) return rv;
|
||||
/**************************************************************************
|
||||
* Stage 1 : Command Line Options
|
||||
*/
|
||||
memset(&optarg, 0, sizeof(optarg));
|
||||
|
||||
ogs_getopt_init(&options, argv);
|
||||
while ((opt = ogs_getopt(&options, "c:l:e:m:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
optarg.config_file = options.optarg;
|
||||
break;
|
||||
case 'l':
|
||||
optarg.log_file = options.optarg;
|
||||
break;
|
||||
case 'e':
|
||||
optarg.log_level = options.optarg;
|
||||
break;
|
||||
case 'm':
|
||||
optarg.domain_mask = options.optarg;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
ogs_assert_if_reached();
|
||||
return OGS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
context_self()->config.path = param->config_path;
|
||||
if (context_self()->config.path == NULL)
|
||||
context_self()->config.path = DEFAULT_CONFIG_FILE_PATH;
|
||||
/**************************************************************************
|
||||
* Stage 2 : Load Configuration File
|
||||
*/
|
||||
if (optarg.config_file)
|
||||
context_self()->config.file = optarg.config_file;
|
||||
else
|
||||
context_self()->config.file = DEFAULT_CONFIG_FILENAME;
|
||||
|
||||
rv = context_read_file();
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
@ -49,76 +90,73 @@ int app_will_initialize(app_param_t *param)
|
|||
rv = context_parse_config();
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
/**************************************************************************
|
||||
* Stage 3 : Initialize Default Memory Pool
|
||||
*/
|
||||
ogs_pkbuf_default_create(&context_self()->config.pool.defconfig);
|
||||
|
||||
context_self()->log.path = param->log_path;
|
||||
|
||||
if (param->logfile_disabled == false &&
|
||||
context_self()->config.logger.file) {
|
||||
if (context_self()->log.path)
|
||||
context_self()->config.logger.file = context_self()->log.path;
|
||||
/**************************************************************************
|
||||
* Stage 4 : Setup LOG Module
|
||||
*/
|
||||
if (optarg.log_file)
|
||||
context_self()->config.logger.file = optarg.log_file;
|
||||
|
||||
if (context_self()->config.logger.file) {
|
||||
if (ogs_log_add_file(context_self()->config.logger.file) == NULL) {
|
||||
ogs_fatal("cannot open log file : %s",
|
||||
ogs_fatal("cannot open log file : %s",
|
||||
context_self()->config.logger.file);
|
||||
ogs_assert_if_reached();
|
||||
}
|
||||
|
||||
ogs_log_print(OGS_LOG_INFO,
|
||||
"File Logging: '%s'\n", context_self()->config.logger.file);
|
||||
}
|
||||
|
||||
if (context_self()->config.logger.level) {
|
||||
if (!strcasecmp(context_self()->config.logger.level, "none"))
|
||||
context_self()->log.level = OGS_LOG_NONE;
|
||||
else if (!strcasecmp(context_self()->config.logger.level, "fatal"))
|
||||
context_self()->log.level = OGS_LOG_FATAL;
|
||||
else if (!strcasecmp(context_self()->config.logger.level, "error"))
|
||||
context_self()->log.level = OGS_LOG_ERROR;
|
||||
else if (!strcasecmp(context_self()->config.logger.level, "warn"))
|
||||
context_self()->log.level = OGS_LOG_WARN;
|
||||
else if (!strcasecmp(context_self()->config.logger.level, "info"))
|
||||
context_self()->log.level = OGS_LOG_INFO;
|
||||
else if (!strcasecmp(context_self()->config.logger.level, "debug"))
|
||||
context_self()->log.level = OGS_LOG_DEBUG;
|
||||
else if (!strcasecmp(context_self()->config.logger.level, "trace"))
|
||||
context_self()->log.level = OGS_LOG_TRACE;
|
||||
else {
|
||||
ogs_error("Invalid LOG-LEVEL : %s\n",
|
||||
context_self()->config.logger.level);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
ogs_log_print(OGS_LOG_INFO,
|
||||
"LOG-LEVEL: '%s'\n", context_self()->config.logger.level);
|
||||
}
|
||||
|
||||
if (context_self()->config.logger.domain) {
|
||||
context_self()->log.domain = context_self()->config.logger.domain;
|
||||
ogs_log_print(OGS_LOG_INFO,
|
||||
"LOG-DOMAIN: '%s'\n", context_self()->config.logger.domain);
|
||||
}
|
||||
if (optarg.domain_mask)
|
||||
context_self()->config.logger.domain = optarg.domain_mask;
|
||||
|
||||
if (param->log_level) {
|
||||
context_self()->log.level = param->log_level;
|
||||
context_self()->log.domain = param->log_domain;
|
||||
}
|
||||
if (optarg.log_level)
|
||||
context_self()->config.logger.level = optarg.log_level;
|
||||
|
||||
rv = context_setup_log_module();
|
||||
rv = ogs_log_config_domain(
|
||||
context_self()->config.logger.domain,
|
||||
context_self()->config.logger.level);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
if (param->db_disabled == false &&
|
||||
context_self()->config.db_uri) {
|
||||
/* Override configuration if DB_URI environment variable is existed */
|
||||
if (ogs_env_get("DB_URI"))
|
||||
context_self()->config.db_uri = ogs_env_get("DB_URI");
|
||||
|
||||
/**************************************************************************
|
||||
* Stage 5 : Setup DATABASE
|
||||
*/
|
||||
if (ogs_env_get("DB_URI"))
|
||||
context_self()->config.db_uri = ogs_env_get("DB_URI");
|
||||
|
||||
if (context_self()->config.db_uri) {
|
||||
rv = context_db_init(context_self()->config.db_uri);
|
||||
if (rv != OGS_OK) return rv;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Stage 6 : Print Result
|
||||
*/
|
||||
ogs_log_print(OGS_LOG_INFO, "%s\n\n", version);
|
||||
|
||||
ogs_log_print(OGS_LOG_INFO, "Configuration: '%s'\n",
|
||||
context_self()->config.file);
|
||||
|
||||
if (context_self()->config.logger.file) {
|
||||
ogs_log_print(OGS_LOG_INFO,
|
||||
"File Logging: '%s'\n", context_self()->config.logger.file);
|
||||
|
||||
if (context_self()->config.logger.level)
|
||||
ogs_log_print(OGS_LOG_INFO,
|
||||
"LOG-LEVEL: '%s'\n", context_self()->config.logger.level);
|
||||
|
||||
if (context_self()->config.logger.domain)
|
||||
ogs_log_print(OGS_LOG_INFO,
|
||||
"LOG-DOMAIN: '%s'\n", context_self()->config.logger.domain);
|
||||
}
|
||||
|
||||
if (context_self()->config.db_uri) {
|
||||
ogs_log_print(OGS_LOG_INFO, "MongoDB URI: '%s'\n",
|
||||
context_self()->config.db_uri);
|
||||
}
|
||||
ogs_log_print(OGS_LOG_INFO, "Configuration: '%s'\n",
|
||||
context_self()->config.path);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -138,36 +176,10 @@ void app_did_terminate(void)
|
|||
context_final();
|
||||
}
|
||||
|
||||
static int log_pid(const char *app_name, const char *pid_path)
|
||||
{
|
||||
FILE *pid_file = NULL;
|
||||
pid_t mypid;
|
||||
char default_pid_path[MAX_FILEPATH_LEN];
|
||||
|
||||
if (pid_path == NULL) {
|
||||
ogs_snprintf(default_pid_path, sizeof(default_pid_path),
|
||||
"%snextepc-%sd/pid", DEFAULT_RUNTIME_DIR_PATH, app_name);
|
||||
pid_path = default_pid_path;
|
||||
}
|
||||
|
||||
mypid = getpid();
|
||||
pid_file = fopen(pid_path, "w");
|
||||
if (!pid_file) {
|
||||
ogs_error("CHECK PERMISSION of Installation Directory...");
|
||||
ogs_error("Cannot create PID file:`%s`", pid_path);
|
||||
ogs_assert_if_reached();
|
||||
}
|
||||
fprintf(pid_file, "%d\n", (int)mypid);
|
||||
fclose(pid_file);
|
||||
|
||||
ogs_log_print(OGS_LOG_INFO, "PID[%d]: '%s'\n", (int)mypid, pid_path);
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
int app_logger_restart()
|
||||
{
|
||||
ogs_log_cycle();
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,28 +24,14 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct app_param_s {
|
||||
const char *name;
|
||||
void show_version(void);
|
||||
void show_help(const char *name);
|
||||
|
||||
const char *config_path;
|
||||
const char *log_path;
|
||||
const char *pid_path;
|
||||
|
||||
bool logfile_disabled;
|
||||
bool db_disabled;
|
||||
|
||||
ogs_log_level_e log_level;
|
||||
const char *log_domain;
|
||||
} app_param_t;
|
||||
|
||||
int app_will_initialize(app_param_t *param);
|
||||
int app_will_initialize(char **argv);
|
||||
int app_did_initialize(void);
|
||||
void app_will_terminate(void);
|
||||
void app_did_terminate(void);
|
||||
|
||||
int config_initialize(const char *config_path);
|
||||
void config_terminate(void);
|
||||
|
||||
int app_logger_restart(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -69,11 +69,11 @@ int context_read_file()
|
|||
yaml_parser_t parser;
|
||||
yaml_document_t *document = NULL;
|
||||
|
||||
ogs_assert(config->path);
|
||||
ogs_assert(config->file);
|
||||
|
||||
file = fopen(config->path, "rb");
|
||||
file = fopen(config->file, "rb");
|
||||
if (!file) {
|
||||
ogs_fatal("cannot open file `%s`", config->path);
|
||||
ogs_fatal("cannot open file `%s`", config->file);
|
||||
ogs_assert_if_reached();
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ int context_read_file()
|
|||
|
||||
document = calloc(1, sizeof(yaml_document_t));
|
||||
if (!yaml_parser_load(&parser, document)) {
|
||||
ogs_fatal("Failed to parse configuration file '%s'", config->path);
|
||||
ogs_fatal("Failed to parse configuration file '%s'", config->file);
|
||||
switch (parser.error) {
|
||||
case YAML_MEMORY_ERROR:
|
||||
ogs_error("Memory error: Not enough memory for parsing");
|
||||
|
@ -141,15 +141,6 @@ int context_read_file()
|
|||
return OGS_OK;
|
||||
}
|
||||
|
||||
int context_setup_log_module()
|
||||
{
|
||||
if (context_self()->log.level || context_self()->log.domain)
|
||||
ogs_log_set_mask_level(context_self()->log.domain,
|
||||
context_self()->log.level);
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
static void context_recalculate_pool_size()
|
||||
{
|
||||
self.pool.ue = self.config.max.ue * self.config.max.enb;
|
||||
|
@ -192,7 +183,7 @@ static int context_validation()
|
|||
if (self.config.parameter.no_ipv4 == 1 &&
|
||||
self.config.parameter.no_ipv6 == 1) {
|
||||
ogs_error("Both `no_ipv4` and `no_ipv6` set to `true` in `%s`",
|
||||
context_self()->config.path);
|
||||
context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _config_t {
|
||||
const char *path;
|
||||
const char *file;
|
||||
void *document;
|
||||
|
||||
const char *db_uri;
|
||||
|
@ -84,12 +84,6 @@ typedef struct _context_t {
|
|||
void *database;
|
||||
} db;
|
||||
|
||||
struct {
|
||||
const char *path;
|
||||
ogs_log_level_e level;
|
||||
const char *domain;
|
||||
} log;
|
||||
|
||||
struct {
|
||||
int ue;
|
||||
int sess;
|
||||
|
@ -106,7 +100,6 @@ context_t *context_self(void);
|
|||
|
||||
int context_read_file(void);
|
||||
int context_parse_config(void);
|
||||
int context_setup_log_module(void);
|
||||
|
||||
int context_db_init(const char *db_uri);
|
||||
int context_db_final(void);
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
|
||||
#include "ogs-core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct yaml_document_s yaml_document_t;
|
||||
typedef struct yaml_node_s yaml_node_t;
|
||||
typedef struct yaml_node_pair_s yaml_node_pair_t;
|
||||
|
|
309
src/epc.c
309
src/epc.c
|
@ -1,219 +1,101 @@
|
|||
#include "mme/ogs-sctp.h"
|
||||
|
||||
#include "base/types.h"
|
||||
|
||||
#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_thread_t *pcrf_thread = NULL;
|
||||
static ogs_thread_t *pgw_thread = NULL;
|
||||
static ogs_thread_t *sgw_thread = NULL;
|
||||
static ogs_thread_t *hss_thread = NULL;
|
||||
|
||||
static ogs_proc_mutex_t *pgw_sem1 = NULL;
|
||||
static ogs_proc_mutex_t *pgw_sem2 = NULL;
|
||||
#define MAX_CHILD_PROCESS 8
|
||||
static ogs_proc_t process[MAX_CHILD_PROCESS];
|
||||
static int process_num = 0;
|
||||
|
||||
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 app_initialize(app_param_t *param)
|
||||
static void child_main(void *data)
|
||||
{
|
||||
param->name = "epc";
|
||||
return epc_initialize(param);
|
||||
char **commandLine = data;
|
||||
ogs_proc_t *current = NULL;
|
||||
FILE *out = NULL;
|
||||
char buf[OGS_HUGE_LEN];
|
||||
int ret = 0, out_return_code = 0;;
|
||||
|
||||
current = &process[process_num++];
|
||||
ret = ogs_proc_create((const char *const*)commandLine,
|
||||
ogs_proc_option_combined_stdout_stderr|
|
||||
ogs_proc_option_inherit_environment,
|
||||
current);
|
||||
ogs_assert(ret == 0);
|
||||
out = ogs_proc_stdout(current);
|
||||
ogs_assert(out);
|
||||
|
||||
while(fgets(buf, OGS_HUGE_LEN, out)) {
|
||||
printf("%s", buf);
|
||||
}
|
||||
|
||||
ret = ogs_proc_join(current, &out_return_code);
|
||||
ogs_assert(ret == 0);
|
||||
ogs_assert(out_return_code == 0);
|
||||
|
||||
ret = ogs_proc_destroy(current);
|
||||
ogs_assert(ret == 0);
|
||||
}
|
||||
|
||||
int epc_initialize(app_param_t *param)
|
||||
ogs_thread_t *epc_child_create(char *name, char **argv)
|
||||
{
|
||||
ogs_thread_t *child = NULL;
|
||||
char *commandLine[OGS_ARG_MAX];
|
||||
int i = 0;
|
||||
char directory[MAX_FILEPATH_LEN];
|
||||
char command[MAX_FILEPATH_LEN];
|
||||
|
||||
while(argv[i] && i < 32) {
|
||||
commandLine[i] = argv[i];
|
||||
i++;
|
||||
}
|
||||
commandLine[i] = NULL;
|
||||
|
||||
ogs_path_remove_last_component(directory, argv[0]);
|
||||
if (strstr(directory, ".libs"))
|
||||
ogs_path_remove_last_component(directory, directory);
|
||||
ogs_snprintf(command, sizeof command, "%s/%s", directory, name);
|
||||
commandLine[0] = command;
|
||||
|
||||
child = ogs_thread_create(child_main, (void*)commandLine);
|
||||
ogs_msleep(50);
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
void epc_child_terminate(void)
|
||||
{
|
||||
int i;
|
||||
ogs_proc_t *current = NULL;
|
||||
for (i = 0; i < process_num; i++) {
|
||||
current = &process[i];
|
||||
ogs_proc_terminate(current);
|
||||
}
|
||||
}
|
||||
|
||||
int app_initialize(char **argv)
|
||||
{
|
||||
pid_t pid;
|
||||
int rv;
|
||||
|
||||
rv = app_will_initialize(param);
|
||||
rv = app_will_initialize(argv);
|
||||
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 */
|
||||
|
||||
pcrf_thread = epc_child_create("nextepc-pcrfd", argv);
|
||||
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 */
|
||||
|
||||
pgw_thread = epc_child_create("nextepc-pgwd", argv);
|
||||
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 */
|
||||
|
||||
sgw_thread = epc_child_create("nextepc-sgwd", argv);
|
||||
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);
|
||||
}
|
||||
hss_thread = epc_child_create("nextepc-hssd", argv);
|
||||
|
||||
ogs_info("MME try to initialize");
|
||||
ogs_sctp_init(context_self()->config.usrsctp.udp_port);
|
||||
|
@ -227,7 +109,7 @@ int epc_initialize(app_param_t *param)
|
|||
return OGS_OK;;
|
||||
}
|
||||
|
||||
void epc_terminate(void)
|
||||
void app_terminate(void)
|
||||
{
|
||||
app_will_terminate();
|
||||
|
||||
|
@ -236,37 +118,10 @@ void epc_terminate(void)
|
|||
ogs_sctp_final();
|
||||
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);
|
||||
if (hss_thread) ogs_thread_destroy(hss_thread);
|
||||
if (sgw_thread) ogs_thread_destroy(sgw_thread);
|
||||
if (pgw_thread) ogs_thread_destroy(pgw_thread);
|
||||
if (pcrf_thread) ogs_thread_destroy(pcrf_thread);
|
||||
|
||||
app_did_terminate();
|
||||
}
|
||||
|
|
|
@ -8,12 +8,11 @@ extern int __hss_log_domain;
|
|||
#undef OGS_LOG_DOMAIN
|
||||
#define OGS_LOG_DOMAIN __hss_log_domain
|
||||
|
||||
int app_initialize(app_param_t *param)
|
||||
int app_initialize(char **argv)
|
||||
{
|
||||
int rv;
|
||||
|
||||
param->name = "hss";
|
||||
rv = app_will_initialize(param);
|
||||
rv = app_will_initialize(argv);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
rv = hss_initialize();
|
||||
|
|
|
@ -78,7 +78,7 @@ static int hss_context_validation()
|
|||
(self.fd_config->cnf_diamid == NULL ||
|
||||
self.fd_config->cnf_diamrlm == NULL ||
|
||||
self.fd_config->cnf_addr == NULL)) {
|
||||
ogs_error("No hss.freeDiameter in '%s'", context_self()->config.path);
|
||||
ogs_error("No hss.freeDiameter in '%s'", context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,9 @@ int hss_initialize(void)
|
|||
rv = hss_context_parse_config();
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
rv = context_setup_log_module();
|
||||
rv = ogs_log_config_domain(
|
||||
context_self()->config.logger.domain,
|
||||
context_self()->config.logger.level);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
rv = hss_db_init();
|
||||
|
|
|
@ -10,12 +10,11 @@ extern int __mme_log_domain;
|
|||
#undef OGS_LOG_DOMAIN
|
||||
#define OGS_LOG_DOMAIN __mme_log_domain
|
||||
|
||||
int app_initialize(app_param_t *param)
|
||||
int app_initialize(char **argv)
|
||||
{
|
||||
int rv;
|
||||
|
||||
param->name = "mme";
|
||||
rv = app_will_initialize(param);
|
||||
rv = app_will_initialize(argv);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
ogs_sctp_init(context_self()->config.usrsctp.udp_port);
|
||||
|
|
|
@ -178,71 +178,71 @@ static int mme_context_validation()
|
|||
(self.fd_config->cnf_diamid == NULL ||
|
||||
self.fd_config->cnf_diamrlm == NULL ||
|
||||
self.fd_config->cnf_addr == NULL)) {
|
||||
ogs_error("No mme.freeDiameter in '%s'", context_self()->config.path);
|
||||
ogs_error("No mme.freeDiameter in '%s'", context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
if (ogs_list_first(&self.s1ap_list) == NULL &&
|
||||
ogs_list_first(&self.s1ap_list6) == NULL) {
|
||||
ogs_error("No mme.s1ap in '%s'", context_self()->config.path);
|
||||
ogs_error("No mme.s1ap in '%s'", context_self()->config.file);
|
||||
return OGS_RETRY;
|
||||
}
|
||||
|
||||
if (ogs_list_first(&self.gtpc_list) == NULL &&
|
||||
ogs_list_first(&self.gtpc_list6) == NULL) {
|
||||
ogs_error("No mme.gtpc in '%s'", context_self()->config.path);
|
||||
ogs_error("No mme.gtpc in '%s'", context_self()->config.file);
|
||||
return OGS_RETRY;
|
||||
}
|
||||
|
||||
if (ogs_list_first(&self.sgw_list) == NULL) {
|
||||
ogs_error("No sgw.gtpc in '%s'", context_self()->config.path);
|
||||
ogs_error("No sgw.gtpc in '%s'", context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
if (ogs_list_first(&self.pgw_list) == NULL) {
|
||||
ogs_error("No pgw.gtpc in '%s'", context_self()->config.path);
|
||||
ogs_error("No pgw.gtpc in '%s'", context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
if (self.max_num_of_served_gummei == 0) {
|
||||
ogs_error("No mme.gummei in '%s'", context_self()->config.path);
|
||||
ogs_error("No mme.gummei in '%s'", context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
if (self.served_gummei[0].num_of_plmn_id == 0) {
|
||||
ogs_error("No mme.gummei.plmn_id in '%s'", context_self()->config.path);
|
||||
ogs_error("No mme.gummei.plmn_id in '%s'", context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
if (self.served_gummei[0].num_of_mme_gid == 0) {
|
||||
ogs_error("No mme.gummei.mme_gid in '%s'", context_self()->config.path);
|
||||
ogs_error("No mme.gummei.mme_gid in '%s'", context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
if (self.served_gummei[0].num_of_mme_code == 0) {
|
||||
ogs_error("No mme.gummei.mme_code in '%s'", context_self()->config.path);
|
||||
ogs_error("No mme.gummei.mme_code in '%s'", context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
if (self.num_of_served_tai == 0) {
|
||||
ogs_error("No mme.tai in '%s'", context_self()->config.path);
|
||||
ogs_error("No mme.tai in '%s'", context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
if (self.served_tai[0].list0.tai[0].num == 0 &&
|
||||
self.served_tai[0].list2.num == 0) {
|
||||
ogs_error("No mme.tai.plmn_id|tac in '%s'", context_self()->config.path);
|
||||
ogs_error("No mme.tai.plmn_id|tac in '%s'", context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
if (self.num_of_integrity_order == 0) {
|
||||
ogs_error("No mme.security.integrity_order in '%s'",
|
||||
context_self()->config.path);
|
||||
context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
if (self.num_of_ciphering_order == 0) {
|
||||
ogs_error("no mme.security.ciphering_order in '%s'",
|
||||
context_self()->config.path);
|
||||
context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,9 @@ int mme_initialize()
|
|||
rv = mme_context_parse_config();
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
rv = context_setup_log_module();
|
||||
rv = ogs_log_config_domain(
|
||||
context_self()->config.logger.domain,
|
||||
context_self()->config.logger.level);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
rv = mme_m_tmsi_pool_generate();
|
||||
|
|
|
@ -8,12 +8,11 @@ extern int __pcrf_log_domain;
|
|||
#undef OGS_LOG_DOMAIN
|
||||
#define OGS_LOG_DOMAIN __pcrf_log_domain
|
||||
|
||||
int app_initialize(app_param_t *param)
|
||||
int app_initialize(char **argv)
|
||||
{
|
||||
int rv;
|
||||
|
||||
param->name = "pcrf";
|
||||
rv = app_will_initialize(param);
|
||||
rv = app_will_initialize(argv);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
rv = pcrf_initialize();
|
||||
|
|
|
@ -85,7 +85,7 @@ static int pcrf_context_validation()
|
|||
self.fd_config->cnf_diamrlm == NULL ||
|
||||
self.fd_config->cnf_addr == NULL)) {
|
||||
ogs_error("No pcrf.freeDiameter in '%s'",
|
||||
context_self()->config.path);
|
||||
context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,9 @@ int pcrf_initialize(void)
|
|||
rv = pcrf_context_parse_config();
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
rv = context_setup_log_module();
|
||||
rv = ogs_log_config_domain(
|
||||
context_self()->config.logger.domain,
|
||||
context_self()->config.logger.level);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
rv = pcrf_db_init();
|
||||
|
|
|
@ -8,12 +8,11 @@ extern int __pgw_log_domain;
|
|||
#undef OGS_LOG_DOMAIN
|
||||
#define OGS_LOG_DOMAIN __pgw_log_domain
|
||||
|
||||
int app_initialize(app_param_t *param)
|
||||
int app_initialize(char **argv)
|
||||
{
|
||||
int rv;
|
||||
|
||||
param->name = "pgw";
|
||||
rv = app_will_initialize(param);
|
||||
rv = app_will_initialize(argv);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
rv = pgw_initialize();
|
||||
|
|
|
@ -130,24 +130,24 @@ static int pgw_context_validation()
|
|||
self.fd_config->cnf_diamrlm == NULL ||
|
||||
self.fd_config->cnf_addr == NULL)) {
|
||||
ogs_error("No pgw.freeDiameter in '%s'",
|
||||
context_self()->config.path);
|
||||
context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
if (ogs_list_first(&self.gtpc_list) == NULL &&
|
||||
ogs_list_first(&self.gtpc_list6) == NULL) {
|
||||
ogs_error("No pgw.gtpc in '%s'",
|
||||
context_self()->config.path);
|
||||
context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
if (ogs_list_first(&self.gtpu_list) == NULL &&
|
||||
ogs_list_first(&self.gtpu_list6) == NULL) {
|
||||
ogs_error("No pgw.gtpu in '%s'",
|
||||
context_self()->config.path);
|
||||
context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
if (self.dns[0] == NULL && self.dns6[0] == NULL) {
|
||||
ogs_error("No pgw.dns in '%s'",
|
||||
context_self()->config.path);
|
||||
context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
return OGS_OK;
|
||||
|
|
|
@ -44,7 +44,9 @@ int pgw_initialize()
|
|||
rv = pgw_context_parse_config();
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
rv = context_setup_log_module();
|
||||
rv = ogs_log_config_domain(
|
||||
context_self()->config.logger.domain,
|
||||
context_self()->config.logger.level);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
rv = pgw_ue_pool_generate();
|
||||
|
|
|
@ -8,12 +8,11 @@ extern int __sgw_log_domain;
|
|||
#undef OGS_LOG_DOMAIN
|
||||
#define OGS_LOG_DOMAIN __sgw_log_domain
|
||||
|
||||
int app_initialize(app_param_t *param)
|
||||
int app_initialize(char **argv)
|
||||
{
|
||||
int rv;
|
||||
|
||||
param->name = "sgw";
|
||||
rv = app_will_initialize(param);
|
||||
rv = app_will_initialize(argv);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
rv = sgw_initialize();
|
||||
|
|
|
@ -107,13 +107,13 @@ static int sgw_context_validation()
|
|||
if (ogs_list_empty(&self.gtpc_list) &&
|
||||
ogs_list_empty(&self.gtpc_list6)) {
|
||||
ogs_error("No sgw.gtpc in '%s'",
|
||||
context_self()->config.path);
|
||||
context_self()->config.file);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
if (ogs_list_empty(&self.gtpu_list) &&
|
||||
ogs_list_empty(&self.gtpu_list6)) {
|
||||
ogs_error("No sgw.gtpu in '%s'",
|
||||
context_self()->config.path);
|
||||
context_self()->config.file);
|
||||
return OGS_RETRY;
|
||||
}
|
||||
return OGS_OK;
|
||||
|
|
|
@ -42,7 +42,9 @@ int sgw_initialize()
|
|||
rv = sgw_context_parse_config();
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
rv = context_setup_log_module();
|
||||
rv = ogs_log_config_domain(
|
||||
context_self()->config.logger.domain,
|
||||
context_self()->config.logger.level);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
thread = ogs_thread_create(sgw_main, NULL);
|
||||
|
|
|
@ -9,9 +9,6 @@ Type=simple
|
|||
User=nextepc
|
||||
Group=nextepc
|
||||
|
||||
RuntimeDirectory=nextepc-hssd
|
||||
PIDFile=@LOCALSTATE_DIR@/run/nextepc-hssd/pid
|
||||
|
||||
Restart=always
|
||||
ExecStart=@BIN_DIR@/nextepc-hssd -f @SYSCONF_DIR@/nextepc/hss.conf
|
||||
RestartSec=2
|
||||
|
|
|
@ -8,9 +8,6 @@ Type=simple
|
|||
User=nextepc
|
||||
Group=nextepc
|
||||
|
||||
RuntimeDirectory=nextepc-mmed
|
||||
PIDFile=@LOCALSTATE_DIR@/run/nextepc-mmed/pid
|
||||
|
||||
Restart=always
|
||||
ExecStart=@BIN_DIR@/nextepc-mmed -f @SYSCONF_DIR@/nextepc/mme.conf
|
||||
RestartSec=2
|
||||
|
|
|
@ -9,9 +9,6 @@ Type=simple
|
|||
User=nextepc
|
||||
Group=nextepc
|
||||
|
||||
RuntimeDirectory=nextepc-pcrfd
|
||||
PIDFile=@LOCALSTATE_DIR@/run/nextepc-pcrfd/pid
|
||||
|
||||
Restart=always
|
||||
ExecStart=@BIN_DIR@/nextepc-pcrfd -f @SYSCONF_DIR@/nextepc/pcrf.conf
|
||||
RestartSec=2
|
||||
|
|
|
@ -8,9 +8,6 @@ Type=simple
|
|||
User=nextepc
|
||||
Group=nextepc
|
||||
|
||||
RuntimeDirectory=nextepc-pgwd
|
||||
PIDFile=@LOCALSTATE_DIR@/run/nextepc-pgwd/pid
|
||||
|
||||
Restart=always
|
||||
ExecStart=@BIN_DIR@/nextepc-pgwd -f @SYSCONF_DIR@/nextepc/pgw.conf
|
||||
RestartSec=2
|
||||
|
|
|
@ -8,9 +8,6 @@ Type=simple
|
|||
User=nextepc
|
||||
Group=nextepc
|
||||
|
||||
RuntimeDirectory=nextepc-sgwd
|
||||
PIDFile=@LOCALSTATE_DIR@/run/nextepc-sgwd/pid
|
||||
|
||||
Restart=always
|
||||
ExecStart=@BIN_DIR@/nextepc-sgwd -f @SYSCONF_DIR@/nextepc/sgw.conf
|
||||
RestartSec=2
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
if [ 1 -ne $# ]
|
||||
then
|
||||
echo "You must specify argument : ./systemctl.sh {start|stop|force-stop|restart|force-reload|status}"
|
||||
|
||||
exit;
|
||||
fi
|
||||
|
||||
systemctl $1 nextepc-mmed
|
||||
systemctl $1 nextepc-sgwd
|
||||
systemctl $1 nextepc-pgwd
|
||||
systemctl $1 nextepc-hssd
|
||||
systemctl $1 nextepc-pcrfd
|
|
@ -3,7 +3,9 @@
|
|||
bin_PROGRAMS = testunit testsimple testcomplex testvolte testcsfb
|
||||
|
||||
configdir = ${sysconfdir}/nextepc/tests
|
||||
config_DATA = sample.conf sample-simple.conf sample-volte.conf sample-csfb.conf
|
||||
config_DATA = \
|
||||
sample-simple.conf sample-complex.conf sample-volte.conf sample-csfb.conf \
|
||||
$(NULL)
|
||||
|
||||
testunit_SOURCES = \
|
||||
common/test-packet.h common/test-packet.c \
|
||||
|
@ -16,6 +18,7 @@ testunit_LDADD = $(top_srcdir)/src/libepc.la
|
|||
|
||||
testsimple_SOURCES = \
|
||||
common/test-packet.h common/test-packet.c \
|
||||
common/test-app.h common/test-app.c \
|
||||
simple/abts-main.c \
|
||||
simple/mnc3-test.c \
|
||||
$(NULL)
|
||||
|
@ -23,6 +26,7 @@ testsimple_LDADD = $(top_srcdir)/src/libepc.la
|
|||
|
||||
testcomplex_SOURCES = \
|
||||
common/test-packet.h common/test-packet.c \
|
||||
common/test-app.h common/test-app.c \
|
||||
complex/abts-main.c \
|
||||
complex/s1setup-test.c \
|
||||
complex/attach-test.c complex/volte-test.c complex/handover-test.c \
|
||||
|
@ -32,8 +36,8 @@ testcomplex_LDADD = $(top_srcdir)/src/libepc.la
|
|||
|
||||
testvolte_SOURCES = \
|
||||
common/test-packet.h common/test-packet.c \
|
||||
common/test-app.h \
|
||||
volte/abts-main.c volte/test-app.c \
|
||||
common/test-app.h common/test-app.c \
|
||||
volte/abts-main.c \
|
||||
volte/pcscf-fd-path.h volte/pcscf-fd-path.c \
|
||||
volte/volte-test.c \
|
||||
$(NULL)
|
||||
|
@ -41,8 +45,8 @@ testvolte_LDADD = $(top_srcdir)/src/libepc.la
|
|||
|
||||
testcsfb_SOURCES = \
|
||||
common/test-packet.h common/test-packet.c \
|
||||
common/test-app.h \
|
||||
csfb/abts-main.c csfb/test-app.c \
|
||||
common/test-app.h common/test-app.c \
|
||||
csfb/abts-main.c \
|
||||
csfb/mo-idle-test.c csfb/mt-idle-test.c \
|
||||
csfb/mo-active-test.c csfb/mt-active-test.c \
|
||||
csfb/mo-sms-test.c csfb/mt-sms-test.c \
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* 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 "ogs-core.h"
|
||||
#include "core/abts.h"
|
||||
|
||||
#include "base/types.h"
|
||||
#include "fd/fd-lib.h"
|
||||
|
||||
#include "test-app.h"
|
||||
|
||||
static int connected_count = 0;
|
||||
static void test_fd_logger_handler(enum fd_hook_type type, struct msg * msg,
|
||||
struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd,
|
||||
void * regdata)
|
||||
{
|
||||
if (type == HOOK_PEER_CONNECT_SUCCESS) {
|
||||
connected_count++;
|
||||
}
|
||||
}
|
||||
|
||||
void test_main(int argc, char **argv,
|
||||
const char *name, void (*init)(char **argv))
|
||||
{
|
||||
int rv;
|
||||
bool user_config;
|
||||
|
||||
/* '-f sample-XXXX.conf -e error' is always added */
|
||||
char *argv_out[argc+4], *new_argv[argc+4];
|
||||
int argc_out;
|
||||
|
||||
char directory[MAX_FILEPATH_LEN];
|
||||
char exec_file[MAX_FILEPATH_LEN];
|
||||
char conf_file[MAX_FILEPATH_LEN];
|
||||
|
||||
ogs_path_remove_last_component(directory, argv[0]);
|
||||
if (strstr(directory, ".libs")) {
|
||||
ogs_path_remove_last_component(directory, directory);
|
||||
if (strstr(directory, "tests"))
|
||||
ogs_path_remove_last_component(directory, directory);
|
||||
}
|
||||
|
||||
user_config = false;
|
||||
for (argc_out = 0; argc_out < argc; argc_out++) {
|
||||
if (strcmp("-c", argv[argc_out]) == 0) {
|
||||
user_config = true;
|
||||
}
|
||||
argv_out[argc_out] = argv[argc_out];
|
||||
}
|
||||
argv_out[argc_out] = NULL;
|
||||
|
||||
if (!user_config) {
|
||||
ogs_snprintf(conf_file, sizeof conf_file, "%s/tests/%s",
|
||||
directory, name);
|
||||
argv_out[argc_out++] = "-c";
|
||||
argv_out[argc_out++] = conf_file;
|
||||
argv_out[argc_out] = NULL;
|
||||
}
|
||||
|
||||
ogs_snprintf(exec_file, sizeof exec_file, "%s/nextepc-epcd", directory);
|
||||
argv_out[0] = exec_file;
|
||||
|
||||
rv = abts_main(argc_out, argv_out, new_argv);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
|
||||
fd_logger_register(test_fd_logger_handler);
|
||||
|
||||
(*init)(new_argv);
|
||||
|
||||
while(1) {
|
||||
if (connected_count == 1) break;
|
||||
ogs_msleep(50);
|
||||
}
|
||||
|
||||
ogs_msleep(300); /* Wait for listening all sockets */
|
||||
}
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
#ifndef __TESTAPP_H__
|
||||
#define __TESTAPP_H__
|
||||
#ifndef TEST_APP_H
|
||||
#define TEST_APP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
int test_app_initialize(app_param_t *param);
|
||||
void test_app_terminate(void);
|
||||
void test_main(int argc, char **argv,
|
||||
const char *name, void (*init)(char **argv));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __TESTAPP_H__ */
|
||||
#endif /* TEST_APP_H */
|
||||
|
|
|
@ -50,16 +50,6 @@
|
|||
|
||||
#include "mme/sgsap-path.h"
|
||||
|
||||
int testpacket_init()
|
||||
{
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
int testpacket_final()
|
||||
{
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
ogs_socknode_t *testsctp_server(const char *ipstr)
|
||||
{
|
||||
int rv;
|
||||
|
|
|
@ -26,9 +26,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
int testpacket_init();
|
||||
int testpacket_final();
|
||||
|
||||
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, int type);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "app/context.h"
|
||||
|
||||
#include "app-init.h"
|
||||
#include "test-packet.h"
|
||||
#include "test-app.h"
|
||||
|
||||
abts_suite *test_s1setup(abts_suite *suite);
|
||||
abts_suite *test_attach(abts_suite *suite);
|
||||
|
@ -45,120 +45,38 @@ const struct testlist {
|
|||
{NULL},
|
||||
};
|
||||
|
||||
static int connected_count = 0;
|
||||
static void test_fd_logger_handler(enum fd_hook_type type, struct msg * msg,
|
||||
struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd,
|
||||
void * regdata)
|
||||
static void terminate(void)
|
||||
{
|
||||
if (type == HOOK_PEER_CONNECT_SUCCESS)
|
||||
{
|
||||
connected_count++;
|
||||
}
|
||||
}
|
||||
ogs_msleep(50);
|
||||
|
||||
void test_terminate(void)
|
||||
{
|
||||
ogs_msleep(300);
|
||||
|
||||
testpacket_final();
|
||||
epc_terminate();
|
||||
epc_child_terminate();
|
||||
app_terminate();
|
||||
|
||||
base_finalize();
|
||||
ogs_core_finalize();
|
||||
}
|
||||
|
||||
int test_initialize(app_param_t *param, int argc, const char *const argv[])
|
||||
static void initialize(char **argv)
|
||||
{
|
||||
int rv;
|
||||
fd_logger_register(test_fd_logger_handler);
|
||||
|
||||
atexit(test_terminate);
|
||||
|
||||
ogs_core_initialize();
|
||||
base_initialize();
|
||||
|
||||
rv = epc_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;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
if (connected_count == 1) break;
|
||||
ogs_msleep(50);
|
||||
}
|
||||
|
||||
return rv;
|
||||
rv = app_initialize(argv);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
app_param_t param;
|
||||
const char *debug_mask = NULL;
|
||||
const char *trace_mask = NULL;
|
||||
char config_dir[MAX_FILEPATH_LEN/2];
|
||||
char config_path[MAX_FILEPATH_LEN];
|
||||
abts_suite *suite = NULL;
|
||||
|
||||
abts_init(argc, argv);
|
||||
|
||||
memset(¶m, 0, sizeof(param));
|
||||
for (i = 1; i < argc; i++) {
|
||||
/* abts_init(argc, argv) handles the following options */
|
||||
if (!strcmp(argv[i], "-v")) continue;
|
||||
if (!strcmp(argv[i], "-x")) continue;
|
||||
if (!strcmp(argv[i], "-l")) continue;
|
||||
if (!strcmp(argv[i], "-q")) continue;
|
||||
|
||||
if (!strcmp(argv[i], "-d")) {
|
||||
param.log_level = OGS_LOG_DEBUG;
|
||||
param.log_domain = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-t")) {
|
||||
param.log_level = OGS_LOG_TRACE;
|
||||
param.log_domain = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-f")) {
|
||||
param.config_path = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (argv[i][0] == '-') {
|
||||
fprintf(stderr, "Invalid option: `%s'\n", argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!param.config_path)
|
||||
{
|
||||
ogs_path_remove_last_component(config_dir, argv[0]);
|
||||
if (strstr(config_dir, ".libs"))
|
||||
ogs_path_remove_last_component(config_dir, config_dir);
|
||||
ogs_snprintf(config_path, sizeof config_path,
|
||||
"%s/sample.conf", config_dir);
|
||||
param.config_path = config_path;
|
||||
}
|
||||
|
||||
if (param.log_level)
|
||||
ogs_core()->log.level = OGS_LOG_DEFAULT;
|
||||
else
|
||||
ogs_core()->log.level = OGS_LOG_ERROR;
|
||||
test_initialize(¶m, argc, argv);
|
||||
atexit(terminate);
|
||||
test_main(argc, argv, "sample-complex.conf", initialize);
|
||||
|
||||
for (i = 0; alltests[i].func; i++)
|
||||
{
|
||||
suite = alltests[i].func(suite);
|
||||
}
|
||||
|
||||
return abts_report(suite);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "core/abts.h"
|
||||
|
||||
#include "fd/fd-lib.h"
|
||||
#include "mme/ogs-sctp.h"
|
||||
|
||||
#include "app/application.h"
|
||||
#include "app/context.h"
|
||||
|
@ -50,118 +51,75 @@ const struct testlist {
|
|||
{NULL},
|
||||
};
|
||||
|
||||
static int connected_count = 0;
|
||||
static void test_fd_logger_handler(enum fd_hook_type type, struct msg * msg,
|
||||
struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd,
|
||||
void * regdata)
|
||||
{
|
||||
if (type == HOOK_PEER_CONNECT_SUCCESS) {
|
||||
connected_count++;
|
||||
}
|
||||
}
|
||||
static ogs_thread_t *pcrf_thread = NULL;
|
||||
static ogs_thread_t *pgw_thread = NULL;
|
||||
static ogs_thread_t *sgw_thread = NULL;
|
||||
static ogs_thread_t *hss_thread = NULL;
|
||||
ogs_socknode_t *sgsap = NULL;
|
||||
|
||||
void test_terminate(void)
|
||||
static void terminate(void)
|
||||
{
|
||||
ogs_msleep(300);
|
||||
ogs_msleep(50);
|
||||
|
||||
testpacket_final();
|
||||
test_app_terminate();
|
||||
epc_child_terminate();
|
||||
|
||||
app_will_terminate();
|
||||
|
||||
ogs_info("MME try to terminate");
|
||||
mme_terminate();
|
||||
testvlr_sgsap_close(sgsap);
|
||||
ogs_sctp_final();
|
||||
ogs_info("MME terminate...done");
|
||||
|
||||
if (hss_thread) ogs_thread_destroy(hss_thread);
|
||||
if (sgw_thread) ogs_thread_destroy(sgw_thread);
|
||||
if (pgw_thread) ogs_thread_destroy(pgw_thread);
|
||||
if (pcrf_thread) ogs_thread_destroy(pcrf_thread);
|
||||
|
||||
app_did_terminate();
|
||||
|
||||
base_finalize();
|
||||
ogs_core_finalize();
|
||||
}
|
||||
|
||||
int test_initialize(app_param_t *param, int argc, const char *const argv[])
|
||||
static void initialize(char **argv)
|
||||
{
|
||||
int rv;
|
||||
fd_logger_register(test_fd_logger_handler);
|
||||
|
||||
atexit(test_terminate);
|
||||
|
||||
ogs_core_initialize();
|
||||
base_initialize();
|
||||
|
||||
rv = test_app_initialize(param);
|
||||
if (rv != OGS_OK) {
|
||||
ogs_error("app_initialize() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
rv = app_will_initialize(argv);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
|
||||
rv = testpacket_init();
|
||||
if (rv != OGS_OK) {
|
||||
ogs_error("testpacket() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
pcrf_thread = epc_child_create("nextepc-pcrfd", argv);
|
||||
pgw_thread = epc_child_create("nextepc-pgwd", argv);
|
||||
sgw_thread = epc_child_create("nextepc-sgwd", argv);
|
||||
hss_thread = epc_child_create("nextepc-hssd", argv);
|
||||
|
||||
while(1) {
|
||||
if (connected_count == 1) break;
|
||||
ogs_msleep(50);
|
||||
}
|
||||
ogs_info("MME try to initialize");
|
||||
ogs_sctp_init(context_self()->config.usrsctp.udp_port);
|
||||
sgsap = testvlr_sgsap_server("127.0.0.2");
|
||||
ogs_assert(sgsap);
|
||||
|
||||
ogs_msleep(100); /* waiting for running SCTP server */
|
||||
rv = mme_initialize();
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_info("MME initialize...done");
|
||||
|
||||
return rv;
|
||||
rv = app_did_initialize();
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
app_param_t param;
|
||||
const char *debug_mask = NULL;
|
||||
const char *trace_mask = NULL;
|
||||
char config_dir[MAX_FILEPATH_LEN/2];
|
||||
char config_path[MAX_FILEPATH_LEN];
|
||||
abts_suite *suite = NULL;
|
||||
|
||||
abts_init(argc, argv);
|
||||
|
||||
memset(¶m, 0, sizeof(param));
|
||||
for (i = 1; i < argc; i++) {
|
||||
/* abts_init(argc, argv) handles the following options */
|
||||
if (!strcmp(argv[i], "-v")) continue;
|
||||
if (!strcmp(argv[i], "-x")) continue;
|
||||
if (!strcmp(argv[i], "-l")) continue;
|
||||
if (!strcmp(argv[i], "-q")) continue;
|
||||
|
||||
if (!strcmp(argv[i], "-d")) {
|
||||
param.log_level = OGS_LOG_DEBUG;
|
||||
param.log_domain = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-t")) {
|
||||
param.log_level = OGS_LOG_TRACE;
|
||||
param.log_domain = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-f")) {
|
||||
param.config_path = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (argv[i][0] == '-') {
|
||||
fprintf(stderr, "Invalid option: `%s'\n", argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!param.config_path) {
|
||||
ogs_path_remove_last_component(config_dir, argv[0]);
|
||||
if (strstr(config_dir, ".libs"))
|
||||
ogs_path_remove_last_component(config_dir, config_dir);
|
||||
ogs_snprintf(config_path, sizeof config_path,
|
||||
"%s/sample-csfb.conf", config_dir);
|
||||
param.config_path = config_path;
|
||||
}
|
||||
|
||||
if (param.log_level)
|
||||
ogs_core()->log.level = OGS_LOG_DEFAULT;
|
||||
else
|
||||
ogs_core()->log.level = OGS_LOG_ERROR;
|
||||
test_initialize(¶m, argc, argv);
|
||||
atexit(terminate);
|
||||
test_main(argc, argv, "sample-csfb.conf", initialize);
|
||||
|
||||
for (i = 0; alltests[i].func; i++)
|
||||
{
|
||||
suite = alltests[i].func(suite);
|
||||
}
|
||||
|
||||
return abts_report(suite);
|
||||
}
|
||||
|
|
|
@ -1,283 +0,0 @@
|
|||
#include "mme/ogs-sctp.h"
|
||||
|
||||
#include "app/context.h"
|
||||
#include "app/application.h"
|
||||
|
||||
#include "app-init.h"
|
||||
#include "test-packet.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;
|
||||
|
||||
ogs_socknode_t *sgsap = NULL;
|
||||
|
||||
int test_epc_initialize(app_param_t *param);
|
||||
|
||||
int test_app_initialize(app_param_t *param)
|
||||
{
|
||||
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");
|
||||
ogs_sctp_init(context_self()->config.usrsctp.udp_port);
|
||||
|
||||
sgsap = testvlr_sgsap_server("127.0.0.2");
|
||||
ogs_assert(sgsap);
|
||||
|
||||
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();
|
||||
|
||||
testvlr_sgsap_close(sgsap);
|
||||
|
||||
ogs_sctp_final();
|
||||
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();
|
||||
}
|
|
@ -20,13 +20,10 @@
|
|||
#include "ogs-core.h"
|
||||
#include "core/abts.h"
|
||||
|
||||
#include "fd/fd-lib.h"
|
||||
|
||||
#include "app/application.h"
|
||||
#include "app/context.h"
|
||||
#include "base/context.h"
|
||||
|
||||
#include "app-init.h"
|
||||
#include "test-packet.h"
|
||||
#include "test-app.h"
|
||||
|
||||
abts_suite *test_mnc3(abts_suite *suite);
|
||||
|
||||
|
@ -37,120 +34,38 @@ const struct testlist {
|
|||
{NULL},
|
||||
};
|
||||
|
||||
static int connected_count = 0;
|
||||
static void test_fd_logger_handler(enum fd_hook_type type, struct msg * msg,
|
||||
struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd,
|
||||
void * regdata)
|
||||
{
|
||||
if (type == HOOK_PEER_CONNECT_SUCCESS)
|
||||
{
|
||||
connected_count++;
|
||||
}
|
||||
}
|
||||
|
||||
void test_terminate(void)
|
||||
static void terminate(void)
|
||||
{
|
||||
ogs_msleep(50);
|
||||
|
||||
testpacket_final();
|
||||
epc_terminate();
|
||||
epc_child_terminate();
|
||||
app_terminate();
|
||||
|
||||
base_finalize();
|
||||
ogs_core_finalize();
|
||||
}
|
||||
|
||||
int test_initialize(app_param_t *param, int argc, const char *const argv[])
|
||||
static void initialize(char **argv)
|
||||
{
|
||||
int rv;
|
||||
fd_logger_register(test_fd_logger_handler);
|
||||
|
||||
atexit(test_terminate);
|
||||
|
||||
ogs_core_initialize();
|
||||
base_initialize();
|
||||
|
||||
rv = epc_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;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
if (connected_count == 1) break;
|
||||
ogs_msleep(50);
|
||||
}
|
||||
|
||||
return rv;
|
||||
rv = app_initialize(argv);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
app_param_t param;
|
||||
const char *debug_mask = NULL;
|
||||
const char *trace_mask = NULL;
|
||||
char config_dir[MAX_FILEPATH_LEN/2];
|
||||
char config_path[MAX_FILEPATH_LEN];
|
||||
abts_suite *suite = NULL;
|
||||
|
||||
abts_init(argc, argv);
|
||||
|
||||
memset(¶m, 0, sizeof(param));
|
||||
for (i = 1; i < argc; i++) {
|
||||
/* abts_init(argc, argv) handles the following options */
|
||||
if (!strcmp(argv[i], "-v")) continue;
|
||||
if (!strcmp(argv[i], "-x")) continue;
|
||||
if (!strcmp(argv[i], "-l")) continue;
|
||||
if (!strcmp(argv[i], "-q")) continue;
|
||||
|
||||
if (!strcmp(argv[i], "-d")) {
|
||||
param.log_level = OGS_LOG_DEBUG;
|
||||
param.log_domain = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-t")) {
|
||||
param.log_level = OGS_LOG_TRACE;
|
||||
param.log_domain = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-f")) {
|
||||
param.config_path = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (argv[i][0] == '-') {
|
||||
fprintf(stderr, "Invalid option: `%s'\n", argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!param.config_path)
|
||||
{
|
||||
ogs_path_remove_last_component(config_dir, argv[0]);
|
||||
if (strstr(config_dir, ".libs"))
|
||||
ogs_path_remove_last_component(config_dir, config_dir);
|
||||
ogs_snprintf(config_path, sizeof config_path,
|
||||
"%s/sample-simple.conf", config_dir);
|
||||
param.config_path = config_path;
|
||||
}
|
||||
|
||||
if (param.log_level)
|
||||
ogs_core()->log.level = OGS_LOG_DEFAULT;
|
||||
else
|
||||
ogs_core()->log.level = OGS_LOG_ERROR;
|
||||
test_initialize(¶m, argc, argv);
|
||||
atexit(terminate);
|
||||
test_main(argc, argv, "sample-simple.conf", initialize);
|
||||
|
||||
for (i = 0; alltests[i].func; i++)
|
||||
{
|
||||
suite = alltests[i].func(suite);
|
||||
}
|
||||
|
||||
return abts_report(suite);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ AT_BANNER([NextEPC Amazing Tests.])
|
|||
AT_SETUP([unit])
|
||||
AT_KEYWORDS([unit])
|
||||
AT_CHECK_UNQUOTED(
|
||||
[$abs_top_builddir/tests/testunit -f $abs_top_builddir/tests/sample.conf],
|
||||
[$abs_top_builddir/tests/testunit -q],
|
||||
[0], [dnl
|
||||
s1ap-message-test : SUCCESS
|
||||
nas-message-test : SUCCESS
|
||||
|
@ -19,7 +19,7 @@ AT_CLEANUP
|
|||
AT_SETUP([simple])
|
||||
AT_KEYWORDS([simple])
|
||||
AT_CHECK_UNQUOTED(
|
||||
[$abs_top_builddir/tests/testsimple -f $abs_top_builddir/tests/sample-simple.conf],
|
||||
[$abs_top_builddir/tests/testsimple -q -c $abs_top_builddir/tests/sample-simple.conf],
|
||||
[0], [dnl
|
||||
mnc3-test : SUCCESS
|
||||
All tests passed.
|
||||
|
@ -29,7 +29,7 @@ AT_CLEANUP
|
|||
AT_SETUP([complex])
|
||||
AT_KEYWORDS([complex])
|
||||
AT_CHECK_UNQUOTED(
|
||||
[$abs_top_builddir/tests/testcomplex -f $abs_top_builddir/tests/sample.conf],
|
||||
[$abs_top_builddir/tests/testcomplex -q -c $abs_top_builddir/tests/sample-complex.conf],
|
||||
[0], [dnl
|
||||
s1setup-test : SUCCESS
|
||||
attach-test : SUCCESS
|
||||
|
@ -43,7 +43,7 @@ AT_CLEANUP
|
|||
AT_SETUP([volte])
|
||||
AT_KEYWORDS([volte])
|
||||
AT_CHECK_UNQUOTED(
|
||||
[$abs_top_builddir/tests/testvolte -f $abs_top_builddir/tests/sample-volte.conf],
|
||||
[$abs_top_builddir/tests/testvolte -q -c $abs_top_builddir/tests/sample-volte.conf],
|
||||
[0], [dnl
|
||||
volte-test : SUCCESS
|
||||
All tests passed.
|
||||
|
@ -53,7 +53,7 @@ AT_CLEANUP
|
|||
AT_SETUP([csfb])
|
||||
AT_KEYWORDS([csfb])
|
||||
AT_CHECK_UNQUOTED(
|
||||
[$abs_top_builddir/tests/testcsfb -f $abs_top_builddir/tests/sample-csfb.conf],
|
||||
[$abs_top_builddir/tests/testcsfb -q -c $abs_top_builddir/tests/sample-csfb.conf],
|
||||
[0], [dnl
|
||||
mo-idle-test : SUCCESS
|
||||
mt-idle-test : SUCCESS
|
||||
|
|
|
@ -49,103 +49,68 @@ const struct testlist {
|
|||
{NULL},
|
||||
};
|
||||
|
||||
void test_terminate(void)
|
||||
static void terminate(void)
|
||||
{
|
||||
app_will_terminate();
|
||||
mme_context_final();
|
||||
ogs_sctp_final();
|
||||
app_did_terminate();
|
||||
|
||||
ogs_pkbuf_default_destroy();
|
||||
|
||||
base_finalize();
|
||||
ogs_core_finalize();
|
||||
}
|
||||
|
||||
int test_initialize(app_param_t *param, int argc, const char *const argv[])
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int rv;
|
||||
int rv, i, opt;
|
||||
ogs_getopt_t options;
|
||||
struct {
|
||||
char *log_level;
|
||||
char *domain_mask;
|
||||
} optarg;
|
||||
char *argv_out[argc+2]; /* '-e error' is always added */
|
||||
|
||||
abts_suite *suite = NULL;
|
||||
ogs_pkbuf_config_t config;
|
||||
|
||||
atexit(test_terminate);
|
||||
rv = abts_main(argc, argv, argv_out);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
memset(&optarg, 0, sizeof(optarg));
|
||||
ogs_getopt_init(&options, argv_out);
|
||||
|
||||
while ((opt = ogs_getopt(&options, "e:m:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'e':
|
||||
optarg.log_level = options.optarg;
|
||||
break;
|
||||
case 'm':
|
||||
optarg.domain_mask = options.optarg;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
fprintf(stderr, "%s: should not be reached\n", OGS_FUNC);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
ogs_core_initialize();
|
||||
base_initialize();
|
||||
|
||||
param->logfile_disabled = true;
|
||||
param->db_disabled = true;
|
||||
rv = app_will_initialize(param);
|
||||
if (rv != OGS_OK) {
|
||||
ogs_error("app_will_initialize() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
ogs_pkbuf_default_init(&config);
|
||||
ogs_pkbuf_default_create(&config);
|
||||
|
||||
context_init();
|
||||
mme_context_init();
|
||||
ogs_sctp_init(context_self()->config.usrsctp.udp_port);
|
||||
|
||||
app_did_initialize();
|
||||
atexit(terminate);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
int i;
|
||||
app_param_t param;
|
||||
const char *debug_mask = NULL;
|
||||
const char *trace_mask = NULL;
|
||||
char config_dir[MAX_FILEPATH_LEN/2];
|
||||
char config_path[MAX_FILEPATH_LEN];
|
||||
abts_suite *suite = NULL;
|
||||
|
||||
abts_init(argc, argv);
|
||||
|
||||
memset(¶m, 0, sizeof(param));
|
||||
for (i = 1; i < argc; i++) {
|
||||
/* abts_init(argc, argv) handles the following options */
|
||||
if (!strcmp(argv[i], "-v")) continue;
|
||||
if (!strcmp(argv[i], "-x")) continue;
|
||||
if (!strcmp(argv[i], "-l")) continue;
|
||||
if (!strcmp(argv[i], "-q")) continue;
|
||||
|
||||
if (!strcmp(argv[i], "-d")) {
|
||||
param.log_level = OGS_LOG_DEBUG;
|
||||
param.log_domain = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-t")) {
|
||||
param.log_level = OGS_LOG_TRACE;
|
||||
param.log_domain = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-f")) {
|
||||
param.config_path = argv[++i];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (argv[i][0] == '-') {
|
||||
fprintf(stderr, "Invalid option: `%s'\n", argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!param.config_path)
|
||||
{
|
||||
ogs_path_remove_last_component(config_dir, argv[0]);
|
||||
if (strstr(config_dir, ".libs"))
|
||||
ogs_path_remove_last_component(config_dir, config_dir);
|
||||
ogs_snprintf(config_path, sizeof config_path,
|
||||
"%s/sample.conf", config_dir);
|
||||
param.config_path = config_path;
|
||||
}
|
||||
|
||||
if (param.log_level)
|
||||
ogs_core()->log.level = OGS_LOG_DEFAULT;
|
||||
else
|
||||
ogs_core()->log.level = OGS_LOG_ERROR;
|
||||
test_initialize(¶m, argc, argv);
|
||||
rv = ogs_log_config_domain(optarg.domain_mask, optarg.log_level);
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
for (i = 0; alltests[i].func; i++)
|
||||
{
|
||||
suite = alltests[i].func(suite);
|
||||
}
|
||||
|
||||
return abts_report(suite);
|
||||
}
|
||||
|
|
|
@ -43,129 +43,70 @@ const struct testlist {
|
|||
{NULL},
|
||||
};
|
||||
|
||||
static int connected_count = 0;
|
||||
static void test_fd_logger_handler(enum fd_hook_type type, struct msg * msg,
|
||||
struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd,
|
||||
void * regdata)
|
||||
{
|
||||
if (type == HOOK_PEER_CONNECT_SUCCESS)
|
||||
{
|
||||
connected_count++;
|
||||
}
|
||||
}
|
||||
static ogs_thread_t *pcrf_thread = NULL;
|
||||
static ogs_thread_t *pgw_thread = NULL;
|
||||
static ogs_thread_t *sgw_thread = NULL;
|
||||
static ogs_thread_t *hss_thread = NULL;
|
||||
static ogs_thread_t *mme_thread = NULL;
|
||||
|
||||
void test_terminate(void)
|
||||
static void terminate(void)
|
||||
{
|
||||
ogs_msleep(50);
|
||||
|
||||
epc_child_terminate();
|
||||
|
||||
app_will_terminate();
|
||||
|
||||
if (mme_thread) ogs_thread_destroy(mme_thread);
|
||||
if (hss_thread) ogs_thread_destroy(hss_thread);
|
||||
if (sgw_thread) ogs_thread_destroy(sgw_thread);
|
||||
if (pgw_thread) ogs_thread_destroy(pgw_thread);
|
||||
if (pcrf_thread) ogs_thread_destroy(pcrf_thread);
|
||||
|
||||
app_did_terminate();
|
||||
|
||||
pcscf_fd_final();
|
||||
testpacket_final();
|
||||
ogs_sctp_final();
|
||||
test_app_terminate();
|
||||
|
||||
base_finalize();
|
||||
ogs_core_finalize();
|
||||
}
|
||||
|
||||
int test_initialize(app_param_t *param, int argc, const char *const argv[])
|
||||
static void initialize(char **argv)
|
||||
{
|
||||
int rv;
|
||||
fd_logger_register(test_fd_logger_handler);
|
||||
|
||||
atexit(test_terminate);
|
||||
|
||||
ogs_core_initialize();
|
||||
base_initialize();
|
||||
rv = test_app_initialize(param);
|
||||
if (rv != OGS_OK)
|
||||
{
|
||||
ogs_error("test_app_initialize() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
rv = pcscf_fd_init();
|
||||
if (rv != OGS_OK)
|
||||
{
|
||||
ogs_error("pcscf_fd_init() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
rv = app_will_initialize(argv);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
|
||||
pcrf_thread = epc_child_create("nextepc-pcrfd", argv);
|
||||
pgw_thread = epc_child_create("nextepc-pgwd", argv);
|
||||
sgw_thread = epc_child_create("nextepc-sgwd", argv);
|
||||
hss_thread = epc_child_create("nextepc-hssd", argv);
|
||||
mme_thread = epc_child_create("nextepc-mmed", argv);
|
||||
|
||||
ogs_sctp_init(context_self()->config.usrsctp.udp_port);
|
||||
|
||||
rv = testpacket_init();
|
||||
if (rv != OGS_OK)
|
||||
{
|
||||
ogs_error("testpacket() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
rv = pcscf_fd_init();
|
||||
ogs_assert(rv == OGS_OK);
|
||||
|
||||
while(1)
|
||||
{
|
||||
if (connected_count == 1) break;
|
||||
ogs_msleep(50);
|
||||
}
|
||||
|
||||
return rv;
|
||||
rv = app_did_initialize();
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
app_param_t param;
|
||||
const char *debug_mask = NULL;
|
||||
const char *trace_mask = NULL;
|
||||
char config_dir[MAX_FILEPATH_LEN/2];
|
||||
char config_path[MAX_FILEPATH_LEN];
|
||||
abts_suite *suite = NULL;
|
||||
|
||||
abts_init(argc, argv);
|
||||
|
||||
memset(¶m, 0, sizeof(param));
|
||||
for (i = 1; i < argc; i++) {
|
||||
/* abts_init(argc, argv) handles the following options */
|
||||
if (!strcmp(argv[i], "-v")) continue;
|
||||
if (!strcmp(argv[i], "-x")) continue;
|
||||
if (!strcmp(argv[i], "-l")) continue;
|
||||
if (!strcmp(argv[i], "-q")) continue;
|
||||
|
||||
if (!strcmp(argv[i], "-d")) {
|
||||
param.log_level = OGS_LOG_DEBUG;
|
||||
param.log_domain = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-t")) {
|
||||
param.log_level = OGS_LOG_TRACE;
|
||||
param.log_domain = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-f")) {
|
||||
param.config_path = argv[++i];
|
||||
continue;
|
||||
}
|
||||
if (argv[i][0] == '-') {
|
||||
fprintf(stderr, "Invalid option: `%s'\n", argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!param.config_path)
|
||||
{
|
||||
ogs_path_remove_last_component(config_dir, argv[0]);
|
||||
if (strstr(config_dir, ".libs"))
|
||||
ogs_path_remove_last_component(config_dir, config_dir);
|
||||
ogs_snprintf(config_path, sizeof config_path,
|
||||
"%s/sample-volte.conf", config_dir);
|
||||
param.config_path = config_path;
|
||||
}
|
||||
|
||||
if (param.log_level)
|
||||
ogs_core()->log.level = OGS_LOG_DEFAULT;
|
||||
else
|
||||
ogs_core()->log.level = OGS_LOG_ERROR;
|
||||
test_initialize(¶m, argc, argv);
|
||||
atexit(terminate);
|
||||
test_main(argc, argv, "sample-volte.conf", initialize);
|
||||
|
||||
for (i = 0; alltests[i].func; i++)
|
||||
{
|
||||
suite = alltests[i].func(suite);
|
||||
}
|
||||
|
||||
return abts_report(suite);
|
||||
}
|
||||
|
|
|
@ -1,320 +0,0 @@
|
|||
/*
|
||||
* 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"
|
||||
#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;
|
||||
|
||||
static ogs_proc_mutex_t *mme_sem1 = NULL;
|
||||
static ogs_proc_mutex_t *mme_sem2 = NULL;
|
||||
|
||||
int test_app_initialize(app_param_t *param)
|
||||
{
|
||||
pid_t pid;
|
||||
int rv;
|
||||
int app = 0;
|
||||
|
||||
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/MME */
|
||||
pcrf_sem2 = ogs_proc_mutex_create(0); /* copied to PCRF/PGW/SGW/HSS/MME */
|
||||
|
||||
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/MME */
|
||||
pgw_sem2 = ogs_proc_mutex_create(0); /* copied to PGW/SGW/HSS/MME */
|
||||
|
||||
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/MME */
|
||||
sgw_sem2 = ogs_proc_mutex_create(0); /* copied to SGW/HSS/MME */
|
||||
|
||||
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/MME */
|
||||
hss_sem2 = ogs_proc_mutex_create(0); /* copied to HSS/MME */
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/************************* MME Process **********************/
|
||||
mme_sem1 = ogs_proc_mutex_create(0); /* copied to MME */
|
||||
mme_sem2 = ogs_proc_mutex_create(0); /* copied to MME */
|
||||
|
||||
/* if (context_self()->config.parameter.no_mme == 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);
|
||||
if (hss_sem1) ogs_proc_mutex_delete(hss_sem1);
|
||||
if (hss_sem2) ogs_proc_mutex_delete(hss_sem2);
|
||||
|
||||
ogs_info("MME try to initialize");
|
||||
ogs_sctp_init(context_self()->config.usrsctp.udp_port);
|
||||
rv = mme_initialize();
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_info("MME initialize...done");
|
||||
|
||||
if (mme_sem1) ogs_proc_mutex_post(mme_sem1);
|
||||
if (mme_sem2) ogs_proc_mutex_wait(mme_sem2);
|
||||
|
||||
if (rv == OGS_OK) {
|
||||
ogs_info("MME try to terminate");
|
||||
mme_terminate();
|
||||
ogs_sctp_final();
|
||||
ogs_info("MME terminate...done");
|
||||
}
|
||||
|
||||
if (mme_sem1) ogs_proc_mutex_post(mme_sem1);
|
||||
|
||||
if (mme_sem1) ogs_proc_mutex_delete(mme_sem1);
|
||||
if (mme_sem2) ogs_proc_mutex_delete(mme_sem2);
|
||||
|
||||
context_final();
|
||||
ogs_core_finalize();
|
||||
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (mme_sem1) ogs_proc_mutex_wait(mme_sem1);
|
||||
}
|
||||
|
||||
rv = app_did_initialize();
|
||||
if (rv != OGS_OK) return rv;
|
||||
|
||||
return OGS_OK;;
|
||||
}
|
||||
|
||||
void test_app_terminate(void)
|
||||
{
|
||||
app_will_terminate();
|
||||
|
||||
/* if (context_self()->config.parameter.no_mme == 0) */
|
||||
{
|
||||
if (mme_sem2) ogs_proc_mutex_post(mme_sem2);
|
||||
if (mme_sem1) ogs_proc_mutex_wait(mme_sem1);
|
||||
}
|
||||
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 (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