merge libcore/libcoreunix to libcore

merge libfd/libfdx/libfds6a to libfd
This commit is contained in:
Sukchan Lee 2017-11-06 08:32:19 +00:00
parent bfbb98fc1f
commit 4ef15728a0
18 changed files with 28 additions and 361 deletions

View File

@ -410,7 +410,6 @@ AC_CONFIG_SUBDIRS([lib/freeDiameter-1.2.1])
AC_CONFIG_FILES([lib/core/include/core.h])
AC_CONFIG_FILES([lib/core/src/Makefile])
AC_CONFIG_FILES([lib/core/src/unix/Makefile])
AC_CONFIG_FILES([lib/core/test/Makefile])
AC_CONFIG_FILES([lib/core/Makefile])
AC_CONFIG_FILES([lib/base/Makefile])
@ -426,8 +425,6 @@ AC_CONFIG_FILES([lib/fd/extensions/dict_dcca/Makefile])
AC_CONFIG_FILES([lib/fd/extensions/dict_dcca_3gpp/Makefile])
AC_CONFIG_FILES([lib/fd/extensions/dict_s6a/Makefile])
AC_CONFIG_FILES([lib/fd/extensions/Makefile])
AC_CONFIG_FILES([lib/fd/gx/Makefile])
AC_CONFIG_FILES([lib/fd/s6a/Makefile])
AC_CONFIG_FILES([lib/fd/Makefile])
AC_CONFIG_FILES([lib/gtp/Makefile])
AC_CONFIG_FILES([lib/ipfw/Makefile])

View File

@ -7,11 +7,9 @@ libbase_la_SOURCES = \
types.c context.c
libbase_la_DEPENDENCIES = \
$(top_srcdir)/lib/core/src/@OSDIR@/libcore@OSDIR@.la \
$(top_srcdir)/lib/core/src/libcore.la
libbase_la_LIBADD = \
$(top_srcdir)/lib/core/src/@OSDIR@/libcore@OSDIR@.la \
$(top_srcdir)/lib/core/src/libcore.la \
@MONGOC_LIBS@

View File

@ -1,7 +1,6 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = @OSDIR@
AUTOMAKE_OPTIONS = subdir-objects
pkglib_LTLIBRARIES = libcore.la
libcore_la_SOURCES = \
@ -19,22 +18,27 @@ libcore_la_SOURCES = \
../include/core_atomic.h ../include/core_portable.h \
../include/core_version.h ../include/core_event.h ../include/core_hash.h \
../include/core_jsmn.h \
version.c fsm.c msgq.c ringbuf.c timer.c tlv.c tlv_msg.c \
\
debug.c version.c fsm.c msgq.c ringbuf.c timer.c tlv.c tlv_msg.c \
aes.c aes_cmac.c sha1.c sha1_hmac.c sha2.c sha2_hmac.c misc.c event.c \
hash.c jsmn.c start.c
libcore_la_DEPENDENCIES = \
$(top_srcdir)/lib/core/src/@OSDIR@/libcore@OSDIR@.la
libcore_la_LIBADD = \
$(top_srcdir)/lib/core/src/@OSDIR@/libcore@OSDIR@.la
hash.c jsmn.c \
\
../include/arch/core_private_common.h \
../include/arch/unix/core_arch_file.h \
../include/arch/unix/core_arch_mutex.h \
../include/arch/unix/core_arch_semaphore.h \
../include/arch/unix/core_arch_thread.h \
unix/start.c unix/errorcodes.c unix/pkbuf.c \
unix/rand.c unix/time.c unix/file.c unix/net_lib.c \
unix/thread.c unix/signal.c \
unix/atomic.c unix/cond.c unix/mutex.c unix/rwlock.c unix/semaphore.c
AM_CPPFLAGS = \
-I$(top_srcdir)/lib/core/include/arch/@OSDIR@ \
-I$(top_srcdir)/lib/core/include
AM_CFLAGS = \
-Wall -Werror
-Wall -Werror @OSCPPFLAGS@
MAINTAINERCLEANFILES = Makefile.in
MOSTLYCLEANFILES = core *.stackdump

View File

@ -1,23 +0,0 @@
## Process this file with automake to produce Makefile.in
pkglib_LTLIBRARIES = libcoreunix.la
libcoreunix_la_SOURCES = \
../../include/arch/core_private_common.h \
../../include/arch/unix/core_arch_file.h \
../../include/arch/unix/core_arch_mutex.h \
../../include/arch/unix/core_arch_semaphore.h \
../../include/arch/unix/core_arch_thread.h \
debug.c cond.c file.c net_lib.c thread.c errorcodes.c mutex.c rwlock.c \
time.c semaphore.c signal.c pkbuf.c rand.c atomic.c
AM_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_srcdir)/lib/core/include/arch/@OSDIR@ \
-I$(top_srcdir)/lib/core/include
AM_CFLAGS = \
-Wall -Werror @OSCPPFLAGS@
MAINTAINERCLEANFILES = Makefile.in
MOSTLYCLEANFILES = core *.stackdump

View File

@ -14,7 +14,6 @@ testcore_SOURCES += testsctp.c
endif
testcore_LDADD = \
$(top_srcdir)/lib/core/src/@OSDIR@/libcore@OSDIR@.la \
$(top_srcdir)/lib/core/src/libcore.la
AM_CPPFLAGS = \

View File

@ -1,27 +1,36 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = extensions gx s6a
AUTOMAKE_OPTIONS = subdir-objects
SUBDIRS = extensions
pkglib_LTLIBRARIES = libfd.la
libfd_la_SOURCES = \
fd_message.h fd_logger.h fd_lib.h \
libapp_sip.c fd_message.c fd_logger.c fd_init.c
libapp_sip.c fd_message.c fd_logger.c fd_init.c \
\
gx/gx_dict.h gx/gx_message.h \
gx/dict_init.c gx/gx_message.c \
\
s6a/s6a_dict.h s6a/s6a_message.h \
s6a/dict_init.c
libfd_la_DEPENDENCIES = \
$(top_srcdir)/lib/core/src/@OSDIR@/libcore@OSDIR@.la \
$(top_srcdir)/lib/core/src/libcore.la \
$(top_srcdir)/lib/base/libbase.la \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdcore/libfdcore.la \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdproto/libfdproto.la
libfd_la_LIBADD = \
$(top_srcdir)/lib/core/src/@OSDIR@/libcore@OSDIR@.la \
$(top_srcdir)/lib/core/src/libcore.la \
$(top_srcdir)/lib/base/libbase.la \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdcore/libfdcore.la \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdproto/libfdproto.la
AM_CPPFLAGS = \
-I$(top_srcdir)/lib/core/include \
-I$(top_srcdir)/lib/base \
-I$(top_srcdir)/lib/@FREEDIAMETER_DIR@/include
AM_CFLAGS = \

View File

@ -1,31 +0,0 @@
## Process this file with automake to produce Makefile.in
pkglib_LTLIBRARIES = libfdgx.la
libfdgx_la_SOURCES = \
gx_dict.h gx_message.h dict_init.c gx_message.c
libfdgx_la_DEPENDENCIES = \
$(top_srcdir)/lib/core/src/@OSDIR@/libcore@OSDIR@.la \
$(top_srcdir)/lib/core/src/libcore.la \
$(top_srcdir)/lib/base/libbase.la \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdcore/libfdcore.la \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdproto/libfdproto.la
libfdgx_la_LIBADD = \
$(top_srcdir)/lib/core/src/@OSDIR@/libcore@OSDIR@.la \
$(top_srcdir)/lib/core/src/libcore.la \
$(top_srcdir)/lib/base/libbase.la \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdcore/libfdcore.la \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdproto/libfdproto.la
AM_CPPFLAGS = \
-I$(top_srcdir)/lib/core/include \
-I$(top_srcdir)/lib/base \
-I$(top_srcdir)/lib/@FREEDIAMETER_DIR@/include
AM_CFLAGS = \
-Wall -Werror
MAINTAINERCLEANFILES = Makefile.in
MOSTLYCLEANFILES = *.stackdump

View File

@ -1,23 +0,0 @@
## Process this file with automake to produce Makefile.in
pkglib_LTLIBRARIES = libfds6a.la
libfds6a_la_SOURCES = \
s6a_dict.h s6a_message.h dict_init.c
libfds6a_la_DEPENDENCIES = \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdcore/libfdcore.la \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdproto/libfdproto.la
libfds6a_la_LIBADD = \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdcore/libfdcore.la \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdproto/libfdproto.la
AM_CPPFLAGS = \
-I$(top_srcdir)/lib/@FREEDIAMETER_DIR@/include
AM_CFLAGS = \
-Wall -Werror
MAINTAINERCLEANFILES = Makefile.in
MOSTLYCLEANFILES = *.stackdump

View File

@ -7,12 +7,10 @@ libgtp_la_SOURCES = \
gtp_message.c gtp_types.c gtp_conv.c gtp_path.c gtp_xact.c
libgtp_la_DEPENDENCIES = \
$(top_srcdir)/lib/core/src/@OSDIR@/libcore@OSDIR@.la \
$(top_srcdir)/lib/core/src/libcore.la \
$(top_srcdir)/lib/base/libbase.la
libgtp_la_LIBADD = \
$(top_srcdir)/lib/core/src/@OSDIR@/libcore@OSDIR@.la \
$(top_srcdir)/lib/core/src/libcore.la \
$(top_srcdir)/lib/base/libbase.la

View File

@ -1,18 +0,0 @@
## Process this file with automake to produce Makefile.in.
pkglib_LTLIBRARIES = liblogger.la
liblogger_la_SOURCES = \
logger.h logger.c
AM_LDFLAGS = \
-avoid-version -shared
AM_CPPFLAGS = \
-I$(top_srcdir)/lib/core/include
AM_CFLAGS = \
-Wall -Werror
MAINTAINERCLEANFILES = Makefile.in
MOSTLYCLEANFILES = core *.stackdump

View File

@ -1,218 +0,0 @@
#include "logger.h"
#include "core_general.h"
#include "core_debug.h"
#include "core_param.h"
#include "core_file.h"
#include "core_thread.h"
#include <stdio.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
#include <signal.h>
#define MAX_LOG_FILE_SIZE (6*16*1024) /* 96 KB */
#define MAX_BACKUP_LOG_FILE_NUM 19 /* 96 KB x 19 */
#define FILE_CHECK_CYCLE 15
static char g_buffer[1024];
static char g_path[MAX_FILENAME_SIZE] = "nextepc.log";
static file_t *g_file = NULL;
status_t log_file_backup()
{
status_t rv;
char fn[MAX_FILENAME_SIZE], nfn[MAX_FILENAME_SIZE];
file_t *tmpf = NULL;
int i, j;
file_close(g_file);
for (i = 0; ; i++)
{
sprintf(fn, "%s.%d", g_path, i);
rv = file_open(&tmpf, fn, FILE_READ, 0);
if (rv != CORE_OK)
break;
file_close(tmpf);
}
for (j = i - 1; j >= 0; j--)
{
sprintf(fn, "%s.%d", g_path, j);
sprintf(nfn, "%s.%d", g_path, j + 1);
if (j + 1 > MAX_BACKUP_LOG_FILE_NUM)
{
rv = file_remove(fn);
if (rv != CORE_OK)
{
fprintf(stderr, "Can't remove '%s'\n", fn);
return CORE_ERROR;
}
}
else
{
rv = file_rename(fn, nfn);
if (rv != CORE_OK)
{
fprintf(stderr, "Can't rename '%s' to '%s'\n", fn, nfn);
return CORE_ERROR;
}
}
}
sprintf(fn, "%s", g_path);
sprintf(nfn, "%s.0", g_path);
rv = file_rename(fn, nfn);
if (rv != CORE_OK)
{
fprintf(stderr, "Can't rename '%s' to '%s'\n", fn, nfn);
return CORE_ERROR;
}
rv = file_open(&g_file, g_path,
FILE_CREATE | FILE_WRITE| FILE_APPEND,
FILE_UREAD | FILE_UWRITE | FILE_GREAD);
if (rv != CORE_OK)
{
fprintf(stderr, "Cannot open log file '%s'", g_path);
return CORE_ERROR;
}
return CORE_OK;
}
int logger_start(const char *path)
{
status_t rv;
int ret, count = 0;
size_t nbytes;
ssize_t r;
file_info_t finfo;
int us;
fd_set readfd;
struct timeval timer_val;
struct sockaddr_un svaddr;
/* If path is given, use it */
if (path)
strcpy(g_path, path);
us = socket(AF_UNIX, SOCK_DGRAM, 0);
if (us < 0)
{
fprintf(stderr, "socket() failed. (%d:%s)\n",
errno, strerror(errno));
return -1;
}
svaddr.sun_family = AF_UNIX;
strcpy(svaddr.sun_path, D_LOGD_IPC_PATH);
ret = bind(us, (struct sockaddr *)&svaddr, sizeof(svaddr));
if (ret != 0)
{
if (errno == EADDRINUSE)
{
ret = unlink(D_LOGD_IPC_PATH);
if (ret != 0)
{
fprintf(stderr, "unlink(`%s`) failed. (%d:%s)\n",
D_LOGD_IPC_PATH, errno, strerror(errno));
return -1;
}
ret = bind(us, (struct sockaddr *)&svaddr, sizeof(svaddr));
if (ret != 0)
{
fprintf(stderr, "bind() failed 2. (%d:%s)\n",
errno, strerror(errno));
return -1;
}
}
else
{
fprintf(stderr, "bind() failed. (%d:%s)\n",
errno, strerror(errno));
return -1;
}
}
rv = file_open(&g_file, g_path,
FILE_CREATE | FILE_WRITE| FILE_APPEND,
FILE_UREAD | FILE_UWRITE | FILE_GREAD);
if (rv != CORE_OK)
{
fprintf(stderr, "Cannot open log file '%s'\n", g_path);
close(us);
return -1;
}
while (!thread_should_stop())
{
timer_val.tv_sec = 0;
timer_val.tv_usec = 50000;
FD_ZERO(&readfd);
FD_SET(us, &readfd);
r = select (us+1, &readfd, NULL, NULL, &timer_val);
if (r == -1)
{
if (errno == EINTR)
break;
fprintf(stderr, "select() error(%d: %s)",
errno, strerror(errno));
}
if (r == 0)
continue;
if (FD_ISSET(us, &readfd))
{
r = read(us, g_buffer, sizeof(g_buffer));
if (r < 0)
{
if (errno == EINTR)
break;
fprintf(stderr, "read() failed. (%d:%s)\n",
errno, strerror(errno));
continue;
}
if (r == 0)
continue;
nbytes = r;
rv = file_write(g_file, g_buffer, &nbytes);
if (rv != CORE_OK || r != nbytes)
{
fprintf(stderr, "Cannot write %ld bytes to log file (%ld written)\n",
(long)r, (long)nbytes);
}
if (count % FILE_CHECK_CYCLE == 0)
{
file_info_get(&finfo, FILE_INFO_SIZE, g_file);
if (finfo.size > MAX_LOG_FILE_SIZE)
{
log_file_backup();
}
}
count++;
}
}
file_close(g_file);
close(us);
unlink(D_LOGD_IPC_PATH);
return 0;
}

View File

@ -1,17 +0,0 @@
#ifndef __LOGGER_H__
#define __LOGGER_H__
#include "core.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
CORE_DECLARE(int) logger_start(const char *path);
CORE_DECLARE(void) logger_stop();
#ifdef __cplusplus
}
#endif /* !__cplusplus */
#endif /* !__LOGGER_H__ */

View File

@ -8,12 +8,10 @@ libhss_la_SOURCES = \
libhss_la_DEPENDENCIES = \
$(top_srcdir)/lib/base/libbase.la \
$(top_srcdir)/lib/fd/s6a/libfds6a.la \
$(top_srcdir)/lib/fd/libfd.la
libhss_la_LIBADD = \
$(top_srcdir)/lib/base/libbase.la \
$(top_srcdir)/lib/fd/s6a/libfds6a.la \
$(top_srcdir)/lib/fd/libfd.la
AM_CPPFLAGS = \

View File

@ -31,14 +31,12 @@ endif
libmme_la_DEPENDENCIES = \
$(top_srcdir)/lib/s1ap/libs1ap.la \
$(top_srcdir)/lib/nas/libnas.la \
$(top_srcdir)/lib/fd/s6a/libfds6a.la \
$(top_srcdir)/lib/fd/libfd.la \
$(top_srcdir)/lib/gtp/libgtp.la
libmme_la_LIBADD = \
$(top_srcdir)/lib/s1ap/libs1ap.la \
$(top_srcdir)/lib/nas/libnas.la \
$(top_srcdir)/lib/fd/s6a/libfds6a.la \
$(top_srcdir)/lib/fd/libfd.la \
$(top_srcdir)/lib/gtp/libgtp.la

View File

@ -7,11 +7,9 @@ libpcrf_la_SOURCES = \
pcrf_init.c pcrf_context.c pcrf_fd_path.c
libpcrf_la_DEPENDENCIES = \
$(top_srcdir)/lib/fd/gx/libfdgx.la \
$(top_srcdir)/lib/fd/libfd.la
libpcrf_la_LIBADD = \
$(top_srcdir)/lib/fd/gx/libfdgx.la \
$(top_srcdir)/lib/fd/libfd.la
AM_CPPFLAGS = \

View File

@ -13,13 +13,11 @@ libpgw_la_SOURCES = \
pgw_fd_path.c pgw_gx_handler.c
libpgw_la_DEPENDENCIES = \
$(top_srcdir)/lib/fd/gx/libfdgx.la \
$(top_srcdir)/lib/fd/libfd.la \
$(top_srcdir)/lib/gtp/libgtp.la \
$(top_srcdir)/lib/ipfw/libipfw.la
libpgw_la_LIBADD = \
$(top_srcdir)/lib/fd/gx/libfdgx.la \
$(top_srcdir)/lib/fd/libfd.la \
$(top_srcdir)/lib/gtp/libgtp.la \
$(top_srcdir)/lib/ipfw/libipfw.la