open5gs/src/epc.c

146 lines
3.5 KiB
C
Raw Normal View History

2017-07-11 09:44:59 +00:00
#define TRACE_MODULE _epc_main
#include "core_debug.h"
#include "core_signal.h"
#include "core_semaphore.h"
2017-08-02 12:11:22 +00:00
#include "core_proc.h"
2017-07-11 09:44:59 +00:00
2017-08-02 12:11:22 +00:00
#include "context.h"
2017-07-11 14:38:52 +00:00
#include "app.h"
2017-07-11 09:44:59 +00:00
static proc_id pgw_proc = 0;
static status_t PROC_FUNC pgw_start_func(proc_id id, void *data);
static status_t PROC_FUNC pgw_stop_func(proc_id id, void *data);
2017-07-11 09:44:59 +00:00
static proc_id sgw_proc = 0;
static status_t PROC_FUNC sgw_start_func(proc_id id, void *data);
static status_t PROC_FUNC sgw_stop_func(proc_id id, void *data);
2017-08-02 12:11:22 +00:00
static proc_id hss_proc = 0;
static status_t PROC_FUNC hss_start_func(proc_id id, void *data);
static status_t PROC_FUNC hss_stop_func(proc_id id, void *data);
2017-07-11 09:44:59 +00:00
2017-07-11 14:38:52 +00:00
status_t app_initialize(char *config_path, char *log_path)
2017-07-11 09:44:59 +00:00
{
status_t rv;
2017-08-02 12:11:22 +00:00
int others = 0;
2017-07-11 09:44:59 +00:00
2017-07-12 12:25:10 +00:00
rv = app_will_initialize(config_path, log_path);
if (rv != CORE_OK) return rv;
2017-07-11 09:44:59 +00:00
2017-08-02 12:11:22 +00:00
others = context_self()->trace_level.others;
if (others)
2017-07-11 09:44:59 +00:00
{
2017-08-02 12:11:22 +00:00
d_trace_level(&_epc_main, others);
}
2017-07-11 09:44:59 +00:00
if (context_self()->hidden.disable_pgw == 0)
{
rv = proc_create(&pgw_proc, pgw_start_func, pgw_stop_func, NULL);
if (rv != CORE_OK) return rv;
}
2017-07-11 09:44:59 +00:00
if (context_self()->hidden.disable_sgw == 0)
{
rv = proc_create(&sgw_proc, sgw_start_func, sgw_stop_func, NULL);
if (rv != CORE_OK) return rv;
}
2017-07-11 09:44:59 +00:00
if (context_self()->hidden.disable_hss == 0)
{
rv = proc_create(&hss_proc, hss_start_func, hss_stop_func, NULL);
if (rv != CORE_OK) return rv;
}
2017-07-11 09:44:59 +00:00
2017-08-02 12:11:22 +00:00
d_trace(1, "MME try to initialize\n");
rv = mme_initialize();
d_assert(rv == CORE_OK, return rv, "Failed to intialize MME");
2017-08-02 12:11:22 +00:00
d_trace(1, "MME initialize...done\n");
2017-07-11 09:44:59 +00:00
rv = app_did_initialize(config_path, log_path);
if (rv != CORE_OK) return rv;
2017-07-11 09:44:59 +00:00
return CORE_OK;;
2017-07-11 09:44:59 +00:00
}
2017-07-11 14:38:52 +00:00
void app_terminate(void)
2017-07-11 09:44:59 +00:00
{
2017-07-11 14:38:52 +00:00
app_will_terminate();
2017-07-11 09:44:59 +00:00
2017-08-02 12:11:22 +00:00
d_trace(1, "MME try to terminate\n");
2017-07-11 09:44:59 +00:00
mme_terminate();
2017-08-02 12:11:22 +00:00
d_trace(1, "MME terminate...done\n");
if (hss_proc)
proc_delete(hss_proc);
if (sgw_proc)
proc_delete(sgw_proc);
if (pgw_proc)
proc_delete(pgw_proc);
2017-07-11 09:44:59 +00:00
2017-07-11 14:38:52 +00:00
app_did_terminate();
2017-07-11 09:44:59 +00:00
}
static status_t PROC_FUNC pgw_start_func(proc_id id, void *data)
2017-07-11 09:44:59 +00:00
{
2017-08-02 12:11:22 +00:00
status_t rv;
d_trace(1, "PGW try to initialize\n");
rv = pgw_initialize();
d_assert(rv == CORE_OK, return rv, "Failed to intialize PGW");
2017-08-02 12:11:22 +00:00
d_trace(1, "PGW initialize...done\n");
return CORE_OK;
}
2017-08-02 12:11:22 +00:00
static status_t PROC_FUNC pgw_stop_func(proc_id id, void *data)
{
2017-08-02 12:11:22 +00:00
d_trace(1, "PGW try to terminate\n");
pgw_terminate();
d_trace(1, "PGW terminate...done\n");
return CORE_OK;
2017-08-02 12:11:22 +00:00
}
static status_t PROC_FUNC sgw_start_func(proc_id id, void *data)
2017-08-02 12:11:22 +00:00
{
status_t rv;
d_trace(1, "SGW try to initialize\n");
rv = sgw_initialize();
d_assert(rv == CORE_OK, return rv, "Failed to intialize SGW");
2017-08-02 12:11:22 +00:00
d_trace(1, "SGW initialize...done\n");
return CORE_OK;
}
2017-08-02 12:11:22 +00:00
static status_t PROC_FUNC sgw_stop_func(proc_id id, void *data)
{
2017-08-02 12:11:22 +00:00
d_trace(1, "SGW try to terminate\n");
sgw_terminate();
d_trace(1, "SGW terminate...done\n");
return CORE_OK;
2017-08-02 12:11:22 +00:00
}
static status_t PROC_FUNC hss_start_func(proc_id id, void *data)
2017-08-02 12:11:22 +00:00
{
status_t rv;
d_trace(1, "HSS try to initialize\n");
rv = hss_initialize();
d_assert(rv == CORE_OK, return rv, "Failed to intialize HSS");
2017-08-02 12:11:22 +00:00
d_trace(1, "HSS initialize...done\n");
return CORE_OK;
}
2017-08-02 12:11:22 +00:00
static status_t PROC_FUNC hss_stop_func(proc_id id, void *data)
{
2017-08-02 12:11:22 +00:00
d_trace(1, "HSS try to terminate\n");
hss_terminate();
d_trace(1, "HSS terminate...done\n");
return CORE_OK;
2017-07-11 09:44:59 +00:00
}