forked from acouzens/open5gs
update it
This commit is contained in:
parent
1f187f5de9
commit
3adc609e4b
|
@ -265,6 +265,7 @@ AC_CONFIG_FILES([lib/s6a/freeDiameter/Makefile])
|
|||
AC_CONFIG_FILES([lib/s6a/Makefile])
|
||||
AC_CONFIG_FILES([lib/Makefile])
|
||||
AC_CONFIG_FILES([src/mme/Makefile])
|
||||
AC_CONFIG_FILES([src/hss/Makefile])
|
||||
AC_CONFIG_FILES([src/Makefile])
|
||||
AC_CONFIG_FILES([test/Makefile])
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
|
|
|
@ -5,15 +5,12 @@ SUBDIRS = freeDiameter
|
|||
noinst_LTLIBRARIES = libs6a.la
|
||||
|
||||
libs6a_la_SOURCES = \
|
||||
hss_ctx.h hss_sm.h
|
||||
milenage.h kasme.h \
|
||||
s6a_app.h
|
||||
|
||||
nodist_libs6a_la_SOURCES = \
|
||||
milenage.c kasme.c \
|
||||
s6a_init.c s6a_config.c s6a_fd.c s6a_app.c s6a_dict.c \
|
||||
hss_main.c hss_sm.c hss_ctx.c \
|
||||
mme_init.c
|
||||
s6a_config.c s6a_fd.c s6a_app.c s6a_dict.c
|
||||
|
||||
libs6a_la_DEPENDENCIES = \
|
||||
$(top_srcdir)/lib/s6a/freeDiameter/libs6afreeDiameter.la
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
#define TRACE_MODULE _s6a_init
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "core_lib.h"
|
||||
#include "core_signal.h"
|
||||
#include "core_semaphore.h"
|
||||
|
||||
#include "s6a_app.h"
|
||||
|
||||
static pid_t s6a_hss_pid;
|
||||
|
||||
static int check_signal(int signum);
|
||||
|
||||
int s6a_init()
|
||||
{
|
||||
status_t rv;
|
||||
int ret;
|
||||
semaphore_id semaphore;
|
||||
|
||||
rv = semaphore_create(&semaphore, 0);
|
||||
d_assert(rv == CORE_OK, return -1, "semaphore_create() failed");
|
||||
|
||||
s6a_hss_pid = fork();
|
||||
d_assert(s6a_hss_pid >= 0, _exit(EXIT_FAILURE), "fork() failed");
|
||||
|
||||
if (s6a_hss_pid == 0)
|
||||
{
|
||||
/* Child */
|
||||
rv = semaphore_wait(semaphore);
|
||||
d_assert(rv == CORE_OK, _exit(EXIT_FAILURE), "semaphore_wait() failed");
|
||||
|
||||
rv = semaphore_delete(semaphore);
|
||||
d_assert(rv == CORE_OK, _exit(EXIT_FAILURE), "semaphore_delete() failed");
|
||||
|
||||
ret = hss_init();
|
||||
if (ret != 0) _exit(EXIT_FAILURE);
|
||||
|
||||
signal_thread(check_signal);
|
||||
hss_final();
|
||||
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Parent */
|
||||
ret = mme_init();
|
||||
if (ret != 0) return -1;
|
||||
|
||||
rv = semaphore_post(semaphore);
|
||||
d_assert(rv == CORE_OK, return -1, "semaphore_post() failed");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void s6a_final()
|
||||
{
|
||||
mme_final();
|
||||
|
||||
core_kill(s6a_hss_pid, SIGTERM);
|
||||
}
|
||||
|
||||
static int check_signal(int signum)
|
||||
{
|
||||
switch (signum)
|
||||
{
|
||||
case SIGTERM:
|
||||
case SIGINT:
|
||||
{
|
||||
d_info("%s received",
|
||||
signum == SIGTERM ? "SIGTERM" : "SIGINT");
|
||||
|
||||
return 1;
|
||||
}
|
||||
default:
|
||||
{
|
||||
d_error("Unknown signal number = %d\n", signum);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
## Process this file with automake to produce Makefile.in.
|
||||
|
||||
SUBDIRS = mme
|
||||
SUBDIRS = mme hss
|
||||
|
||||
noinst_LTLIBRARIES = libcellwire.la
|
||||
|
||||
|
@ -11,15 +11,17 @@ nodist_libcellwire_la_SOURCES = \
|
|||
init.c
|
||||
|
||||
libcellwire_la_DEPENDENCIES = \
|
||||
$(top_srcdir)/src/mme/libmme.la
|
||||
$(top_srcdir)/src/mme/libmme.la \
|
||||
$(top_srcdir)/src/hss/libhss.la
|
||||
|
||||
libcellwire_la_LIBADD = \
|
||||
$(top_srcdir)/src/mme/libmme.la
|
||||
$(top_srcdir)/src/mme/libmme.la \
|
||||
$(top_srcdir)/src/hss/libhss.la
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/lib/core/include \
|
||||
-I$(top_srcdir)/lib/logger \
|
||||
-I$(top_srcdir)/src/mme/include
|
||||
-I$(top_srcdir)/lib/s6a
|
||||
|
||||
AM_CFLAGS = \
|
||||
-Wall -Werror
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
## Process this file with automake to produce Makefile.in.
|
||||
|
||||
noinst_LTLIBRARIES = libhss.la
|
||||
|
||||
libhss_la_SOURCES = \
|
||||
hss_ctx.h hss_sm.h
|
||||
|
||||
nodist_libhss_la_SOURCES = \
|
||||
init.c hss_ctx.c hss_sm.c
|
||||
|
||||
libhss_la_DEPENDENCIES = \
|
||||
$(top_srcdir)/lib/core/src/libcore.la \
|
||||
$(top_srcdir)/lib/3gpp/lib3gpp.la \
|
||||
$(top_srcdir)/lib/s6a/libs6a.la
|
||||
|
||||
libhss_la_LIBADD = \
|
||||
$(top_srcdir)/lib/core/src/libcore.la \
|
||||
$(top_srcdir)/lib/3gpp/lib3gpp.la \
|
||||
$(top_srcdir)/lib/s6a/libs6a.la
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/lib/core/include \
|
||||
-I$(top_srcdir)/lib/3gpp \
|
||||
-I$(top_srcdir)/lib/s6a
|
||||
|
||||
AM_CFLAGS = \
|
||||
-Wall -Werror
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
MOSTLYCLEANFILES = core *.stackdump
|
||||
|
||||
EXTRA_DIST = .libs $(noinst_LTLIBRARIES)
|
63
src/init.c
63
src/init.c
|
@ -5,20 +5,29 @@
|
|||
/* Core library */
|
||||
#define TRACE_MODULE _cellwire_init
|
||||
#include "core_general.h"
|
||||
#include "core_debug.h"
|
||||
#include "core_thread.h"
|
||||
#include "core_net.h"
|
||||
#include "core_signal.h"
|
||||
#include "core_semaphore.h"
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include "cellwire.h"
|
||||
|
||||
#include "s6a_app.h"
|
||||
|
||||
static pid_t child_pid;
|
||||
static thread_id net_thread;
|
||||
|
||||
static int check_signal(int signum);
|
||||
void *THREAD_FUNC net_main(void *data);
|
||||
|
||||
status_t cellwire_initialize(char *config_path, char *log_path)
|
||||
{
|
||||
status_t rv;
|
||||
int ret;
|
||||
semaphore_id semaphore;
|
||||
|
||||
core_initialize();
|
||||
|
||||
|
@ -30,9 +39,37 @@ status_t cellwire_initialize(char *config_path, char *log_path)
|
|||
if (log_path)
|
||||
logger_start(log_path);
|
||||
|
||||
rv = semaphore_create(&semaphore, 0);
|
||||
d_assert(rv == CORE_OK, return -1, "semaphore_create() failed");
|
||||
|
||||
child_pid = fork();
|
||||
d_assert(child_pid >= 0, _exit(EXIT_FAILURE), "fork() failed");
|
||||
|
||||
if (child_pid == 0)
|
||||
{
|
||||
/* Child */
|
||||
rv = semaphore_wait(semaphore);
|
||||
d_assert(rv == CORE_OK, _exit(EXIT_FAILURE), "semaphore_wait() failed");
|
||||
|
||||
rv = semaphore_delete(semaphore);
|
||||
d_assert(rv == CORE_OK, _exit(EXIT_FAILURE), "semaphore_delete() failed");
|
||||
|
||||
ret = hss_init();
|
||||
if (ret != 0) _exit(EXIT_FAILURE);
|
||||
|
||||
signal_thread(check_signal);
|
||||
hss_final();
|
||||
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Parent */
|
||||
rv = mme_initialize();
|
||||
if (rv != CORE_OK) return rv;
|
||||
|
||||
rv = semaphore_post(semaphore);
|
||||
d_assert(rv == CORE_OK, return -1, "semaphore_post() failed");
|
||||
|
||||
rv = thread_create(&net_thread, NULL, net_main, NULL);
|
||||
if (rv != CORE_OK) return rv;
|
||||
|
||||
|
@ -44,9 +81,34 @@ void cellwire_terminate(void)
|
|||
thread_delete(net_thread);
|
||||
|
||||
mme_terminate();
|
||||
|
||||
core_kill(child_pid, SIGTERM);
|
||||
|
||||
core_terminate();
|
||||
}
|
||||
|
||||
static int check_signal(int signum)
|
||||
{
|
||||
switch (signum)
|
||||
{
|
||||
case SIGTERM:
|
||||
case SIGINT:
|
||||
{
|
||||
d_info("%s received",
|
||||
signum == SIGTERM ? "SIGTERM" : "SIGINT");
|
||||
|
||||
return 1;
|
||||
}
|
||||
default:
|
||||
{
|
||||
d_error("Unknown signal number = %d\n", signum);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *THREAD_FUNC net_main(void *data)
|
||||
{
|
||||
while (!thread_should_stop())
|
||||
|
@ -56,3 +118,4 @@ void *THREAD_FUNC net_main(void *data)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ libmme_la_SOURCES = \
|
|||
nodist_libmme_la_SOURCES = \
|
||||
init.c event.c context.c \
|
||||
s1ap_build.c s1ap_conv.c s1ap_path.c \
|
||||
s6a_auth_info.c \
|
||||
s6a_init.c s6a_auth_info.c \
|
||||
mme_sm.c enb_s1_sm.c
|
||||
|
||||
libmme_la_DEPENDENCIES = \
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
#include "core_debug.h"
|
||||
#include "core_thread.h"
|
||||
|
||||
#include "s6a_app.h"
|
||||
|
||||
#include "context.h"
|
||||
#include "event.h"
|
||||
|
||||
#include "s6a_app.h"
|
||||
|
||||
#define EVENT_WAIT_TIMEOUT 10000 /* 10 msec */
|
||||
|
||||
static thread_id mme_sm_thread;
|
||||
|
@ -21,8 +21,8 @@ status_t mme_initialize()
|
|||
rv = context_init();
|
||||
if (rv != CORE_OK) return rv;
|
||||
|
||||
ret = s6a_init();
|
||||
if (ret != 0) return CORE_ERROR;
|
||||
ret = mme_init();
|
||||
if (ret != 0) return -1;
|
||||
|
||||
rv = thread_create(&mme_sm_thread, NULL, mme_sm_main, NULL);
|
||||
if (rv != CORE_OK) return rv;
|
||||
|
@ -34,7 +34,8 @@ void mme_terminate(void)
|
|||
{
|
||||
thread_delete(mme_sm_thread);
|
||||
|
||||
s6a_final();
|
||||
mme_final();
|
||||
|
||||
context_final();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue