From 6fb3ebc9c93cbe9c2e16562c0cede9f1981ce248 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Sun, 12 Mar 2017 10:23:49 +0900 Subject: [PATCH] update it --- configure.ac | 1 + lib/Makefile.am | 2 +- lib/gtp/asn_msg.h | 2 +- src/mme/Makefile.am | 9 ++++-- test/Makefile.am | 4 ++- test/abts_tests.h | 1 + test/gtp_message_test.c | 71 +++++++++++++++++++++++++++++++++++++++++ test/nas_message_test.c | 1 - test/testutil.h | 1 + 9 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 test/gtp_message_test.c diff --git a/configure.ac b/configure.ac index c0bf0c6ea..6e5c27f0a 100644 --- a/configure.ac +++ b/configure.ac @@ -262,6 +262,7 @@ AC_CONFIG_FILES([lib/s1ap/Makefile]) AC_CONFIG_FILES([lib/nas/Makefile]) AC_CONFIG_FILES([lib/s6a/freeDiameter/Makefile]) AC_CONFIG_FILES([lib/s6a/Makefile]) +AC_CONFIG_FILES([lib/gtp/Makefile]) AC_CONFIG_FILES([lib/Makefile]) AC_CONFIG_FILES([src/mme/Makefile]) AC_CONFIG_FILES([src/hss/Makefile]) diff --git a/lib/Makefile.am b/lib/Makefile.am index 569252be7..877881cef 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = core logger s1ap nas s6a +SUBDIRS = core logger s1ap nas s6a gtp MAINTAINERCLEANFILES = Makefile.in MOSTLYCLEANFILES = *.stackdump diff --git a/lib/gtp/asn_msg.h b/lib/gtp/asn_msg.h index 2931dc64f..b6dc40ddc 100644 --- a/lib/gtp/asn_msg.h +++ b/lib/gtp/asn_msg.h @@ -9,7 +9,7 @@ extern "C" { #endif /* __cplusplus */ typedef struct _asnv_header_t { - c_uint32_t set_ind; + c_uint64_t set_ind; } asnv_header_t; #define VALUE_SET(__m, __value) \ diff --git a/src/mme/Makefile.am b/src/mme/Makefile.am index b1d9576f3..fd94ed0bf 100644 --- a/src/mme/Makefile.am +++ b/src/mme/Makefile.am @@ -20,13 +20,15 @@ libmme_la_DEPENDENCIES = \ $(top_srcdir)/lib/core/src/libcore.la \ $(top_srcdir)/lib/s1ap/libs1ap.la \ $(top_srcdir)/lib/nas/libnas.la \ - $(top_srcdir)/lib/s6a/libs6a.la + $(top_srcdir)/lib/s6a/libs6a.la \ + $(top_srcdir)/lib/gtp/libgtp.la libmme_la_LIBADD = \ $(top_srcdir)/lib/core/src/libcore.la \ $(top_srcdir)/lib/s1ap/libs1ap.la \ $(top_srcdir)/lib/nas/libnas.la \ - $(top_srcdir)/lib/s6a/libs6a.la + $(top_srcdir)/lib/s6a/libs6a.la \ + $(top_srcdir)/lib/gtp/libgtp.la AM_CPPFLAGS = \ -I$(top_srcdir)/lib/core/include \ @@ -34,7 +36,8 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/lib/s1ap/asn1c \ -I$(top_srcdir)/lib/s1ap \ -I$(top_srcdir)/lib/nas \ - -I$(top_srcdir)/lib/s6a + -I$(top_srcdir)/lib/s6a \ + -I$(top_srcdir)/lib/gtp AM_CFLAGS = \ -Wall -Werror diff --git a/test/Makefile.am b/test/Makefile.am index 16639fff6..1c961ac8b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -5,7 +5,8 @@ bin_PROGRAMS = testcellwire testcellwire_SOURCES = \ abts.h abts_tests.h testutil.h \ abts.c testutil.c tests1ap.h tests1ap.c \ - s1ap_message_test.c nas_message_test.c security_test.c \ + s1ap_message_test.c nas_message_test.c gtp_message_test.c \ + security_test.c \ s1ap_sm_test.c nas_sm_test.c testcellwire_LDADD = \ @@ -18,6 +19,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/lib/s1ap \ -I$(top_srcdir)/lib/nas \ -I$(top_srcdir)/lib/s6a \ + -I$(top_srcdir)/lib/gtp \ -I$(top_srcdir)/src/mme \ -I$(top_srcdir)/src/hss \ -I$(top_srcdir)/src diff --git a/test/abts_tests.h b/test/abts_tests.h index c5d4b4d58..1cc6da402 100644 --- a/test/abts_tests.h +++ b/test/abts_tests.h @@ -28,6 +28,7 @@ const struct testlist { {test_nas_message}, {test_nas_sm}, {test_security}, + {test_gtp_message}, }; #endif /* APR_TEST_INCLUDES */ diff --git a/test/gtp_message_test.c b/test/gtp_message_test.c new file mode 100644 index 000000000..e7d9bc353 --- /dev/null +++ b/test/gtp_message_test.c @@ -0,0 +1,71 @@ +#include "core_pkbuf.h" +#include "core_lib.h" +#include "core_debug.h" + +#include "testutil.h" +#include "asn_msg.h" + +static void gtp_message_test1(abts_case *tc, void *data) +{ + asnv_msg_ms_preattachment_req reqv; + asnv_msg_ms_preattachment_req reqv2; + + pkbuf_t *req = NULL; + c_uint8_t *buf; + c_uint32_t buflen; + + { + extern int _asn_msg; + _asn_msg = 0; + } + /* Initialize message value structure */ + memset(&reqv, 0, sizeof(asnv_msg_ms_preattachment_req)); + + /* Set nessary members of message */ + COMPD_SET(reqv.ms_info); + COMPD_SET(reqv.ms_info.ms_security_history); + VALUE_SET(reqv.ms_info.ms_security_history.authorization_policy_support, 0x3); + + COMPD_SET(reqv.bs_info); + OCTET_SET(reqv.bs_info.bs_id, (c_uint8_t*)"\x11\x22\x33\x44\x55\x66", 6); + + /* Build message */ + asn_build_msg(&req, &asnt_msg_ms_preattachment_req, &reqv); + +#if 0 + d_print_hex(req->payload, req->len); +#endif + + /* Initialize message value structure */ + memset(&reqv2, 0, sizeof(asnv_msg_ms_preattachment_req)); + + /* Parse message */ + asn_parse_msg(&reqv2, &asnt_msg_ms_preattachment_req, req); + + if (COMPD_ISSET(reqv2.ms_info)) + if (COMPD_ISSET(reqv2.ms_info.ms_security_history)) + if (VALUE_ISSET(reqv2.ms_info.ms_security_history.authorization_policy_support)) +#if 0 + d_print("%02x", VALUE_GET(reqv2.ms_info.ms_security_history.authorization_policy_support)); +#else + ; +#endif + + if (COMPD_ISSET(reqv2.bs_info)) + if (OCTET_ISSET(reqv2.bs_info.bs_id)) + { + OCTET_GET(buf, buflen, reqv2.bs_info.bs_id); +#if 0 + d_print_hex(buf, buflen); +#endif + } +} + +abts_suite *test_gtp_message(abts_suite *suite) +{ + suite = ADD_SUITE(suite) + + abts_run_test(suite, gtp_message_test1, NULL); + + return suite; +} diff --git a/test/nas_message_test.c b/test/nas_message_test.c index a26ac2d04..bf94f768b 100644 --- a/test/nas_message_test.c +++ b/test/nas_message_test.c @@ -1,4 +1,3 @@ -#include "core_debug.h" #include "core_pkbuf.h" #include "core_lib.h" diff --git a/test/testutil.h b/test/testutil.h index c45139570..e82d869df 100644 --- a/test/testutil.h +++ b/test/testutil.h @@ -62,5 +62,6 @@ abts_suite *test_s1ap_sm(abts_suite *suite); abts_suite *test_nas_message(abts_suite *suite); abts_suite *test_nas_sm(abts_suite *suite); abts_suite *test_security(abts_suite *suite); +abts_suite *test_gtp_message(abts_suite *suite); #endif /* __TESTUTIL_H__ */