From 4e33365bf4157a98a90c78a50a48699c733eff52 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Fri, 27 Oct 2017 16:15:14 +0000 Subject: [PATCH] debian packaging is initially done. network script is added move testscript in debian/rules --- configure.ac | 10 +- debian/etc/nextepc/hss.conf | 14 - debian/etc/nextepc/pcrf.conf | 15 - debian/nextepc-core.install | 1 + debian/nextepc-hss.install | 2 +- debian/nextepc-mme.install | 2 +- debian/nextepc-pcrf.install | 2 +- debian/nextepc-pgw.install | 3 +- debian/nextepc-sgw.install | 2 +- debian/rules | 10 +- lib/freeDiameter-1.2.1/configure.ac | 31 +- support/config/Makefile.am | 9 +- support/config/hss.conf.in | 15 + .../mme.conf => support/config/mme.conf.in | 4 +- support/config/pcrf.conf.in | 15 + .../pgw.conf => support/config/pgw.conf.in | 4 +- .../sgw.conf => support/config/sgw.conf.in | 3 +- support/freeDiameter/dict_gx.xml | 709 ------------------ support/{ => freeDiameter}/make_certs.sh | 0 support/network/nextepc | 6 + support/{netconfig.sh => network/restart.sh} | 0 test/abts.c | 8 +- test/attach_test.c | 18 +- test/checkepc.sh | 10 - test/testpacket.c | 10 + 25 files changed, 118 insertions(+), 785 deletions(-) delete mode 100644 debian/etc/nextepc/hss.conf delete mode 100644 debian/etc/nextepc/pcrf.conf create mode 100644 support/config/hss.conf.in rename debian/etc/nextepc/mme.conf => support/config/mme.conf.in (88%) create mode 100644 support/config/pcrf.conf.in rename debian/etc/nextepc/pgw.conf => support/config/pgw.conf.in (76%) rename debian/etc/nextepc/sgw.conf => support/config/sgw.conf.in (63%) delete mode 100644 support/freeDiameter/dict_gx.xml rename support/{ => freeDiameter}/make_certs.sh (100%) create mode 100644 support/network/nextepc rename support/{netconfig.sh => network/restart.sh} (100%) delete mode 100755 test/checkepc.sh diff --git a/configure.ac b/configure.ac index 1550e4f28..0007115f4 100644 --- a/configure.ac +++ b/configure.ac @@ -459,10 +459,15 @@ AC_CONFIG_FILES([src/pgw/Makefile]) AC_CONFIG_FILES([src/pcrf/Makefile]) AC_CONFIG_FILES([src/Makefile]) AC_CONFIG_FILES([support/config/nextepc.conf]) +AC_CONFIG_FILES([support/config/mme.conf]) +AC_CONFIG_FILES([support/config/sgw.conf]) +AC_CONFIG_FILES([support/config/pgw.conf]) +AC_CONFIG_FILES([support/config/hss.conf]) +AC_CONFIG_FILES([support/config/pcrf.conf]) AC_CONFIG_FILES([support/config/Makefile]) AC_CONFIG_FILES([support/freeDiameter/mme.conf]) -AC_CONFIG_FILES([support/freeDiameter/hss.conf]) AC_CONFIG_FILES([support/freeDiameter/pgw.conf]) +AC_CONFIG_FILES([support/freeDiameter/hss.conf]) AC_CONFIG_FILES([support/freeDiameter/pcrf.conf]) AC_CONFIG_FILES([support/freeDiameter/Makefile]) AC_CONFIG_FILES([support/systemd/nextepc-mmed.service]) @@ -486,7 +491,8 @@ source code location : ${srcdir} compiler : ${CC} compiler flags : ${CFLAGS} linker flags : ${LDFLAGS} ${LIBS} -exec directory : ${BIN_DIR} +bin directory : ${BIN_DIR} +lib directory : ${LIB_DIR}/nextepc config directory : ${SYSCONF_DIR}/nextepc log directory : ${LOCALSTATE_DIR}/log/nextepc " diff --git a/debian/etc/nextepc/hss.conf b/debian/etc/nextepc/hss.conf deleted file mode 100644 index f8344202a..000000000 --- a/debian/etc/nextepc/hss.conf +++ /dev/null @@ -1,14 +0,0 @@ -{ - DB_URI : "mongodb://localhost/nextepc", - LOG_PATH : "/var/log/nextepc/hss.log", - TRACE: - { - FD: 1, - OTHERS: 1, - } - - HSS : - { - FD_CONF_PATH : "/etc/nextepc/freeDiameter/hss.conf", - } -} diff --git a/debian/etc/nextepc/pcrf.conf b/debian/etc/nextepc/pcrf.conf deleted file mode 100644 index 671d17b2d..000000000 --- a/debian/etc/nextepc/pcrf.conf +++ /dev/null @@ -1,15 +0,0 @@ -{ - DB_URI : "mongodb://localhost/nextepc", - LOG_PATH : "/var/log/nextepc/pcrf.log", - TRACE: - { - FD: 1, - OTHERS: 1, - } - - PCRF : - { - FD_CONF_PATH : "/etc/nextepc/freeDiameter/pcrf.conf", - } - -} diff --git a/debian/nextepc-core.install b/debian/nextepc-core.install index 85055c7fa..30544fe1f 100644 --- a/debian/nextepc-core.install +++ b/debian/nextepc-core.install @@ -1,5 +1,6 @@ usr/lib/*/nextepc/* var/log/nextepc var/run/nextepc +etc/nextepc/nextepc.conf etc/nextepc/freeDiameter/cacert.pem support/logrotate/nextepc /etc/logrotate.d diff --git a/debian/nextepc-hss.install b/debian/nextepc-hss.install index fda014658..59fcd8ab2 100644 --- a/debian/nextepc-hss.install +++ b/debian/nextepc-hss.install @@ -2,5 +2,5 @@ usr/bin/nextepc-hssd etc/nextepc/freeDiameter/hss.conf etc/nextepc/freeDiameter/hss.cert.pem etc/nextepc/freeDiameter/hss.key.pem -debian/etc/nextepc/hss.conf etc/nextepc +etc/nextepc/hss.conf support/systemd/nextepc-hssd.service lib/systemd/system diff --git a/debian/nextepc-mme.install b/debian/nextepc-mme.install index 12dd5b316..619d1a771 100644 --- a/debian/nextepc-mme.install +++ b/debian/nextepc-mme.install @@ -2,5 +2,5 @@ usr/bin/nextepc-mmed etc/nextepc/freeDiameter/mme.conf etc/nextepc/freeDiameter/mme.cert.pem etc/nextepc/freeDiameter/mme.key.pem -debian/etc/nextepc/mme.conf etc/nextepc +etc/nextepc/mme.conf support/systemd/nextepc-mmed.service lib/systemd/system diff --git a/debian/nextepc-pcrf.install b/debian/nextepc-pcrf.install index a0a689e91..d4479c82c 100644 --- a/debian/nextepc-pcrf.install +++ b/debian/nextepc-pcrf.install @@ -2,5 +2,5 @@ usr/bin/nextepc-pcrfd etc/nextepc/freeDiameter/pcrf.conf etc/nextepc/freeDiameter/pcrf.cert.pem etc/nextepc/freeDiameter/pcrf.key.pem -debian/etc/nextepc/pcrf.conf etc/nextepc +etc/nextepc/pcrf.conf support/systemd/nextepc-pcrfd.service lib/systemd/system diff --git a/debian/nextepc-pgw.install b/debian/nextepc-pgw.install index e276973e0..07cc22776 100644 --- a/debian/nextepc-pgw.install +++ b/debian/nextepc-pgw.install @@ -2,5 +2,6 @@ usr/bin/nextepc-pgwd etc/nextepc/freeDiameter/pgw.conf etc/nextepc/freeDiameter/pgw.cert.pem etc/nextepc/freeDiameter/pgw.key.pem -debian/etc/nextepc/pgw.conf etc/nextepc +etc/nextepc/pgw.conf support/systemd/nextepc-pgwd.service lib/systemd/system +support/network/nextepc etc/network/interfaces.d diff --git a/debian/nextepc-sgw.install b/debian/nextepc-sgw.install index b5677f718..bbbc090f6 100644 --- a/debian/nextepc-sgw.install +++ b/debian/nextepc-sgw.install @@ -1,3 +1,3 @@ usr/bin/nextepc-sgwd -debian/etc/nextepc/sgw.conf etc/nextepc +etc/nextepc/sgw.conf support/systemd/nextepc-sgwd.service lib/systemd/system diff --git a/debian/rules b/debian/rules index 93ffcbc97..2f13cc021 100755 --- a/debian/rules +++ b/debian/rules @@ -14,5 +14,11 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all %: dh $@ --with autoreconf --with systemd -#override_dh_auto_test: - # skip 'make test' as currently it expects config/log in system paths +override_dh_auto_test: + mkdir -p debian/test/etc/nextepc/freeDiameter debian/test/var/log/nextepc + sed 's?@SYSCONF_DIR@?'`pwd`'/debian/test/etc?g;s?@LOCALSTATE_DIR@?'`pwd`'/debian/test/var?g' support/config/nextepc.conf.in > debian/test/etc/nextepc/nextepc.conf + for i in `find support/freeDiameter -name '*.conf.in' -printf "%f\n" | sed 's/.in$$//g'`; do \ + sed 's?@SYSCONF_DIR@/nextepc?'`pwd`'/support?g;s?@LIB_DIR@/nextepc/\([_a-z0-9]*\)\.so?'`pwd`'/lib/fd/extensions/\1/.libs/\1.so?g' support/freeDiameter/$$i.in > debian/test/etc/nextepc/freeDiameter/$$i; \ + done; + test/testepc -f debian/test/etc/nextepc/nextepc.conf -c + rm -rf debian/test diff --git a/lib/freeDiameter-1.2.1/configure.ac b/lib/freeDiameter-1.2.1/configure.ac index 0d16cf429..e4e5b04ef 100644 --- a/lib/freeDiameter-1.2.1/configure.ac +++ b/lib/freeDiameter-1.2.1/configure.ac @@ -104,14 +104,29 @@ AC_DEFINE_UNQUOTED([FD_PROJECT_VERSION_API], [6], [API version of this package]) -PREFIX=$ac_default_prefix -if test "x$prefix" != "xNONE"; then - PREFIX=$prefix -fi +# adl_RECURSIVE_EVAL(VALUE, RESULT) +# ================================= +# Interpolate the VALUE in loop until it doesn't change, +# and set the result to $RESULT. +# WARNING: It's easy to get an infinite loop with some unsane input. +# For example ${datadir} becomes ${datarootdir}, and then ${prefix}/share, and +# finally ${prefix} is replaced by the prefix. +AC_DEFUN([adl_RECURSIVE_EVAL], +[_lcl_receval="$1" +$2=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix" + test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" + _lcl_receval_old='' + while test "[$]_lcl_receval_old" != "[$]_lcl_receval"; do + _lcl_receval_old="[$]_lcl_receval" + eval _lcl_receval="\"[$]_lcl_receval\"" + done + echo "[$]_lcl_receval")`]) +adl_RECURSIVE_EVAL(["${libdir}"], [LIB_DIR]) +adl_RECURSIVE_EVAL(["${sysconfdir}"], [SYSCONF_DIR]) AC_DEFINE_UNQUOTED([DEFAULT_CONF_PATH], - ["${PREFIX}/etc/freeDiameter"], [Default Configuration Path]) + ["${SYSCONF_DIR}/nextepc/freeDiameter"], [Default Configuration Path]) AC_DEFINE_UNQUOTED([DEFAULT_EXTENSIONS_PATH], - ["${PREFIX}/lib/freeDiameter"], [Default Configuration Path]) + ["${LIB_DIR}/nextepc"], [Default Extensions Path]) AC_SUBST(PREFIX) @@ -172,6 +187,6 @@ source code location : ${srcdir} compiler : ${CC} compiler flags : ${CFLAGS} linker flags : ${LDFLAGS} ${LIBS} -config directory : `eval echo \`echo ${sysconfdir}/freeDiameter\`` -extention directory : `eval echo \`echo ${localstatedir}/freeDiameter\`` +config directory : ${SYSCONF_DIR}/nextepc/freeDiameter +extensions directory : ${LIB_DIR}/nextepc " diff --git a/support/config/Makefile.am b/support/config/Makefile.am index 8c9f1b6ad..da3456e89 100644 --- a/support/config/Makefile.am +++ b/support/config/Makefile.am @@ -1,4 +1,11 @@ -configfiles = nextepc.conf +configfiles = \ + nextepc.conf \ + mme.conf \ + sgw.conf \ + pgw.conf \ + hss.conf \ + pcrf.conf \ + $(NULL) configdir = ${sysconfdir}/nextepc diff --git a/support/config/hss.conf.in b/support/config/hss.conf.in new file mode 100644 index 000000000..afb3a7df4 --- /dev/null +++ b/support/config/hss.conf.in @@ -0,0 +1,15 @@ +{ + DB_URI : "mongodb://localhost/nextepc", + LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/nextepc.log", + TRACE: + { + FD: 1, + OTHERS: 1, + } + + HSS : + { + FD_CONF_PATH : "@SYSCONF_DIR@/nextepc/freeDiameter/hss.conf", + } + +} diff --git a/debian/etc/nextepc/mme.conf b/support/config/mme.conf.in similarity index 88% rename from debian/etc/nextepc/mme.conf rename to support/config/mme.conf.in index 584f58a51..65d18df9d 100644 --- a/debian/etc/nextepc/mme.conf +++ b/support/config/mme.conf.in @@ -1,6 +1,6 @@ { DB_URI : "mongodb://localhost/nextepc", - LOG_PATH : "/var/log/nextepc/mme.log", + LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/nextepc.log", TRACE: { S1AP: 1, @@ -12,7 +12,7 @@ MME : { - FD_CONF_PATH : "/etc/nextepc/freeDiameter/mme.conf", + FD_CONF_PATH : "@SYSCONF_DIR@/nextepc/freeDiameter/mme.conf", DEFAULT_PAGING_DRX : "v64", #RELATIVE_CAPACITY : 255, NETWORK : diff --git a/support/config/pcrf.conf.in b/support/config/pcrf.conf.in new file mode 100644 index 000000000..83773dd43 --- /dev/null +++ b/support/config/pcrf.conf.in @@ -0,0 +1,15 @@ +{ + DB_URI : "mongodb://localhost/nextepc", + LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/nextepc.log", + TRACE: + { + FD: 1, + OTHERS: 1, + } + + PCRF : + { + FD_CONF_PATH : "@SYSCONF_DIR@/nextepc/freeDiameter/pcrf.conf", + } + +} diff --git a/debian/etc/nextepc/pgw.conf b/support/config/pgw.conf.in similarity index 76% rename from debian/etc/nextepc/pgw.conf rename to support/config/pgw.conf.in index 26f17d817..c1a2cb36c 100644 --- a/debian/etc/nextepc/pgw.conf +++ b/support/config/pgw.conf.in @@ -1,6 +1,6 @@ { DB_URI : "mongodb://localhost/nextepc", - LOG_PATH : "/var/log/nextepc/pgw.log", + LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/nextepc.log", TRACE: { FD: 1, @@ -10,7 +10,7 @@ PGW : { - FD_CONF_PATH : "/etc/nextepc/freeDiameter/pgw.conf", + FD_CONF_PATH : "@SYSCONF_DIR@/nextepc/freeDiameter/pgw.conf", NETWORK : { GTPC_IPV4: "127.76.0.3", diff --git a/debian/etc/nextepc/sgw.conf b/support/config/sgw.conf.in similarity index 63% rename from debian/etc/nextepc/sgw.conf rename to support/config/sgw.conf.in index 753c00ced..02be82d5f 100644 --- a/debian/etc/nextepc/sgw.conf +++ b/support/config/sgw.conf.in @@ -1,5 +1,6 @@ { - LOG_PATH : "/var/log/nextepc/sgw.log", + DB_URI : "mongodb://localhost/nextepc", + LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/nextepc.log", TRACE: { GTP: 1, diff --git a/support/freeDiameter/dict_gx.xml b/support/freeDiameter/dict_gx.xml deleted file mode 100644 index c985fe514..000000000 --- a/support/freeDiameter/dict_gx.xml +++ /dev/null @@ -1,709 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/support/make_certs.sh b/support/freeDiameter/make_certs.sh similarity index 100% rename from support/make_certs.sh rename to support/freeDiameter/make_certs.sh diff --git a/support/network/nextepc b/support/network/nextepc new file mode 100644 index 000000000..50f56541f --- /dev/null +++ b/support/network/nextepc @@ -0,0 +1,6 @@ +auto pgwtun +iface pgwtun inet static +address 45.45.0.1 +netmask 255.255.0.0 +pre-up ip tuntap add name pgwtun mode tun +post-down ip tuntap del name pgwtun mode tun diff --git a/support/netconfig.sh b/support/network/restart.sh similarity index 100% rename from support/netconfig.sh rename to support/network/restart.sh diff --git a/test/abts.c b/test/abts.c index 32d2bea70..d9d0d0d7f 100644 --- a/test/abts.c +++ b/test/abts.c @@ -28,6 +28,7 @@ static int verbose = 1; static int exclude = 0; static int quiet = 0; static int list_tests = 0; +int test_only_control_plane = 0; const char **testlist = NULL; @@ -423,8 +424,6 @@ void abts_not_impl(abts_case *tc, const char *message, int lineno) } } -int disable_data_plane_test = 0; - int main(int argc, const char *const argv[]) { int i; int rv; @@ -461,7 +460,10 @@ int main(int argc, const char *const argv[]) { } if (!strcmp(argv[i], "-f")) { config_path = argv[++i]; - disable_data_plane_test = 1; + continue; + } + if (!strcmp(argv[i], "-c")) { + test_only_control_plane = 1; continue; } if (argv[i][0] == '-') { diff --git a/test/attach_test.c b/test/attach_test.c index 4f0678a1b..4ff01952d 100644 --- a/test/attach_test.c +++ b/test/attach_test.c @@ -301,18 +301,14 @@ static void attach_test1(abts_case *tc, void *data) core_sleep(time_from_msec(300)); /* Send GTP-U ICMP Packet */ - extern int disable_data_plane_test; - if (!disable_data_plane_test) - { - rv = testgtpu_enb_send(gtpu, - inet_addr("45.45.0.2"), inet_addr("45.45.0.1")); - ABTS_INT_EQUAL(tc, CORE_OK, rv); + rv = testgtpu_enb_send(gtpu, + inet_addr("45.45.0.2"), inet_addr("45.45.0.1")); + ABTS_INT_EQUAL(tc, CORE_OK, rv); - /* Receive GTP-U ICMP Packet */ - recvbuf = pkbuf_alloc(0, MAX_SDU_LEN); - rc = testgtpu_enb_read(gtpu, recvbuf); - pkbuf_free(recvbuf); - } + /* Receive GTP-U ICMP Packet */ + recvbuf = pkbuf_alloc(0, MAX_SDU_LEN); + rc = testgtpu_enb_read(gtpu, recvbuf); + pkbuf_free(recvbuf); /***************************************************************** * Attach Request : Known GUTI, Integrity Protected, MAC Matched diff --git a/test/checkepc.sh b/test/checkepc.sh deleted file mode 100755 index 78742a1c5..000000000 --- a/test/checkepc.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -mkdir -p /tmp/nextepc/etc/nextepc/freeDiameter /tmp/nextepc/var/log/nextepc -sed 's?@SYSCONF_DIR@?/tmp/nextepc/etc?g;s?@LOCALSTATE_DIR@?/tmp/nextepc/var?g' `pwd`/../support/config/nextepc.conf.in > /tmp/nextepc/etc/nextepc/nextepc.conf -for i in `cd ../support/freeDiameter && find . -name '*.conf.in' ! -name 'dict_legacy_xml.conf.in' -printf "%f\n" | sed 's/.in$//g'` -do -sed 's?@SYSCONF_DIR@/nextepc?'`pwd`'/../support?g;s?@LIB_DIR@/nextepc/\([_a-z0-9]*\)\.so?'`pwd`'/../lib/fd/extensions/\1/.libs/\1.so?g' `pwd`/../support/freeDiameter/$i.in > /tmp/nextepc/etc/nextepc/freeDiameter/$i -done - -./testepc -f /tmp/nextepc/etc/nextepc/nextepc.conf || exit; diff --git a/test/testpacket.c b/test/testpacket.c index fdc9490fb..7192df427 100644 --- a/test/testpacket.c +++ b/test/testpacket.c @@ -9,6 +9,8 @@ #include "s1ap_conv.h" #include "s1ap_path.h" +extern int test_only_control_plane; + net_sock_t *testgtpu_enb_connect(void) { char buf[INET_ADDRSTRLEN]; @@ -16,6 +18,8 @@ net_sock_t *testgtpu_enb_connect(void) mme_context_t *mme = mme_self(); net_sock_t *sock = NULL; + if (test_only_control_plane) return (net_sock_t *)1; + if (!mme) return NULL; rc = net_listen_ext(&sock, SOCK_DGRAM, IPPROTO_UDP, @@ -27,6 +31,8 @@ net_sock_t *testgtpu_enb_connect(void) status_t testgtpu_enb_close(net_sock_t *sock) { + if (test_only_control_plane) return CORE_OK; + return net_close(sock); } @@ -89,6 +95,8 @@ int testgtpu_enb_send(net_sock_t *sock, c_uint32_t src_ip, c_uint32_t dst_ip) } un; } *icmp_h = NULL; + if (test_only_control_plane) return 0; + hi = mme_ue_first(); if (!hi) return -1; mme_ue = mme_ue_this(hi); @@ -147,6 +155,8 @@ int testgtpu_enb_read(net_sock_t *sock, pkbuf_t *recvbuf) { int rc = 0; + if (test_only_control_plane) return 0; + while(1) { rc = net_read(sock, recvbuf->payload, recvbuf->len, 0);