From jengelh at inai.de Thu Oct 2 21:09:05 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Thu, 2 Oct 2014 23:09:05 +0200 Subject: libosmocore: some build fixes Message-ID: <1412284150-11771-1-git-send-email-jengelh@inai.de> The following changes since commit 336915aa0a86316ba26cdfecbf160ed643ccf301: prepare for 0.7.0 release (2014-08-21 15:53:20 +0200) are available in the git repository at: git://git.inai.de/libosmocore HEAD for you to fetch changes up to 0929c5b1d3ae71fb600120fd5c60221495b8391c: build: fix linker error with kasumi_test (2014-10-02 22:33:24 +0200) ---------------------------------------------------------------- Jan Engelhardt (5): utils: resolve compiler warnings on implicit declarations build: resolve link failure in libosmogsm when --disable-talloc is used build: always install our talloc.h build: remove unused all_includes and use AM_CPPFLAGS build: fix linker error with kasumi_test Makefile.am | 1 - include/Makefile.am | 2 -- src/Makefile.am | 3 ++- src/codec/Makefile.am | 3 ++- src/gb/Makefile.am | 3 ++- src/gsm/Makefile.am | 6 +++++- src/vty/Makefile.am | 3 ++- tests/Makefile.am | 6 +++--- utils/Makefile.am | 3 ++- utils/osmo-auc-gen.c | 1 + 10 files changed, 19 insertions(+), 12 deletions(-) From jengelh at inai.de Thu Oct 2 21:09:06 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Thu, 2 Oct 2014 23:09:06 +0200 Subject: [PATCH 1/5] utils: resolve compiler warnings on implicit declarations In-Reply-To: <1412284150-11771-1-git-send-email-jengelh@inai.de> References: <1412284150-11771-1-git-send-email-jengelh@inai.de> Message-ID: <1412284150-11771-2-git-send-email-jengelh@inai.de> CC osmo-auc-gen.o osmo-auc-gen.c: In function 'main': osmo-auc-gen.c:216:3: warning: implicit declaration of function 'time' [-Wimplicit-function-declaration] --- utils/osmo-auc-gen.c | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c index fda045a..54128ff 100644 --- a/utils/osmo-auc-gen.c +++ b/utils/osmo-auc-gen.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include -- 2.0.0 From jengelh at inai.de Thu Oct 2 21:09:07 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Thu, 2 Oct 2014 23:09:07 +0200 Subject: [PATCH 2/5] build: resolve link failure in libosmogsm when --disable-talloc is used In-Reply-To: <1412284150-11771-1-git-send-email-jengelh@inai.de> References: <1412284150-11771-1-git-send-email-jengelh@inai.de> Message-ID: <1412284150-11771-3-git-send-email-jengelh@inai.de> The link stage fails at some point. libosmogsm.so:lapd-core.c uses talloc_free, but does not link to libtalloc.so. Correct this. CCLD osmo-arfcn ../src/gsm/.libs/libosmogsm.so: undefined reference to `talloc_free' collect2: error: ld returned 1 exit status make[2]: *** [osmo-arfcn] Error 1 --- src/gsm/Makefile.am | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index 4207959..df72bf7 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -23,5 +23,8 @@ libosmogsm_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \ libosmogsm_la_LDFLAGS = $(LTLDFLAGS_OSMOGSM) -version-info $(LIBVERSION) -no-undefined libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la +if !ENABLE_TALLOC +libosmogsm_la_LIBDADD = -ltalloc +endif EXTRA_DIST = libosmogsm.map -- 2.0.0 From holger at freyther.de Fri Oct 3 06:41:33 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 3 Oct 2014 08:41:33 +0200 Subject: [PATCH 2/5] build: resolve link failure in libosmogsm when --disable-talloc is used In-Reply-To: <1412284150-11771-3-git-send-email-jengelh@inai.de> References: <1412284150-11771-1-git-send-email-jengelh@inai.de> <1412284150-11771-3-git-send-email-jengelh@inai.de> Message-ID: <20141003064133.GI19169@xiaoyu.lan> On Thu, Oct 02, 2014 at 11:09:07PM +0200, Jan Engelhardt wrote: Good Morning Jan, > The link stage fails at some point. libosmogsm.so:lapd-core.c uses > talloc_free, but does not link to libtalloc.so. Correct this. my position has not changed. The --disable-talloc is an option for Embedded Firmware (e.g. OsmocomBB) that do not want to include talloc. It is not for people that want to use their distributions talloc. Using the osmocom/core/talloc.h and linking against another/unknown version of talloc is scraming for problems (API/ABI issues, etc.) I agree that having a talloc code clone inside libosmocore was not a good idea from us and that we should fix it in the long run. But this means _only_ requiring an external talloc, killing the osmocom/core/talloc.h include file. But that is different to the patches you propose. For this reason I am not taking your talloc patches. Sorry. holger From jengelh at inai.de Fri Oct 3 09:11:55 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Fri, 3 Oct 2014 11:11:55 +0200 (CEST) Subject: [PATCH 2/5] build: resolve link failure in libosmogsm when --disable-talloc is used In-Reply-To: <20141003064133.GI19169@xiaoyu.lan> References: <1412284150-11771-1-git-send-email-jengelh@inai.de> <1412284150-11771-3-git-send-email-jengelh@inai.de> <20141003064133.GI19169@xiaoyu.lan> Message-ID: On Friday 2014-10-03 08:41, Holger Hans Peter Freyther wrote: >On Thu, Oct 02, 2014 at 11:09:07PM +0200, Jan Engelhardt wrote: > >Good Morning Jan, > >> The link stage fails at some point. libosmogsm.so:lapd-core.c uses >> talloc_free, but does not link to libtalloc.so. Correct this. > >my position has not changed. The --disable-talloc is an option for >Embedded Firmware (e.g. OsmocomBB) that do not want to include talloc. >It is not for people that want to use their distributions talloc. The software does not fully build with --disable-talloc, how could it be of use? (It's possible yes, by sneaking in the talloc symbols in another way, e.g. through a patched libc...) >Using the osmocom/core/talloc.h and linking against another/unknown >version of talloc is scraming for problems (API/ABI issues, etc.) I am aware of this, and wrote this down in p 3/5 (replacing talloc.h with a matching one). From holger at freyther.de Fri Oct 3 10:43:43 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 3 Oct 2014 12:43:43 +0200 Subject: [PATCH 2/5] build: resolve link failure in libosmogsm when --disable-talloc is used In-Reply-To: References: <1412284150-11771-1-git-send-email-jengelh@inai.de> <1412284150-11771-3-git-send-email-jengelh@inai.de> <20141003064133.GI19169@xiaoyu.lan> Message-ID: <20141003104343.GC12776@xiaoyu.lan> On Fri, Oct 03, 2014 at 11:11:55AM +0200, Jan Engelhardt wrote: Dear Jan, > >my position has not changed. The --disable-talloc is an option for > >Embedded Firmware (e.g. OsmocomBB) that do not want to include talloc. > >It is not for people that want to use their distributions talloc. > > The software does not fully build with --disable-talloc, > how could it be of use? > (It's possible yes, by sneaking in the talloc symbols in > another way, e.g. through a patched libc...) --disable-talloc (and other feature flags) is a special purpose option to reduce the size of the library (e.g. for usage on the OsmocomBB firmware). It is not expected that on a library with reduced functionality the remaining code will build. We had this discussion in 02.2013 and my position has not changed. I agree that we should not have a copy of talloc in our codebase and should rely on the system to provide it. There should not be a osmocom/core/talloc.h and all projects that use talloc should check for the talloc.pc file. Your patch is not moving us in that direction and opens a new can of worms (potential ABI/API incompats, assuming that libtalloc can be found in the library paths passed to the linker, etc.) kind regards holger From jengelh at inai.de Fri Oct 3 10:53:25 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Fri, 3 Oct 2014 12:53:25 +0200 (CEST) Subject: [PATCH 2/5] build: resolve link failure in libosmogsm when --disable-talloc is used In-Reply-To: <20141003104343.GC12776@xiaoyu.lan> References: <1412284150-11771-1-git-send-email-jengelh@inai.de> <1412284150-11771-3-git-send-email-jengelh@inai.de> <20141003064133.GI19169@xiaoyu.lan> <20141003104343.GC12776@xiaoyu.lan> Message-ID: On Friday 2014-10-03 12:43, Holger Hans Peter Freyther wrote: >On Fri, Oct 03, 2014 at 11:11:55AM +0200, Jan Engelhardt wrote: > >Dear Jan, > >> >my position has not changed. The --disable-talloc is an option for >> >Embedded Firmware (e.g. OsmocomBB) that do not want to include talloc. >> >It is not for people that want to use their distributions talloc. >> >> The software does not fully build with --disable-talloc, >> how could it be of use? >> (It's possible yes, by sneaking in the talloc symbols in >> another way, e.g. through a patched libc...) > > >--disable-talloc (and other feature flags) is a special purpose option >to reduce the size of the library (e.g. for usage on the OsmocomBB >firmware). >It is not expected that on a library with reduced functionality >the remaining code will build. However, --disable-talloc does not reduce any functionality; it is just a fancy name for --use-system-talloc-in-half-the-package. I am sending a new set soon that completes the system-talloc support, with optionally using the bundled talloc for whoever needs it. Support for both methods has mostly been there anyway already. From jengelh at inai.de Thu Oct 2 21:09:08 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Thu, 2 Oct 2014 23:09:08 +0200 Subject: [PATCH 3/5] build: always install our talloc.h In-Reply-To: <1412284150-11771-1-git-send-email-jengelh@inai.de> References: <1412284150-11771-1-git-send-email-jengelh@inai.de> Message-ID: <1412284150-11771-4-git-send-email-jengelh@inai.de> Next-level packages like libosmo-abis strictly depend on , therefore always ship this file. When distributions are using --disable-talloc to use a system talloc instead of the shipped copy, they will simply have to overwrite osmocom/core/talloc.h with the single line #include . --- include/Makefile.am | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/Makefile.am b/include/Makefile.am index c59f9b2..e971e42 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -89,9 +89,7 @@ if ENABLE_PLUGIN nobase_include_HEADERS += osmocom/core/plugin.h endif -if ENABLE_TALLOC nobase_include_HEADERS += osmocom/core/talloc.h -endif if ENABLE_MSGFILE nobase_include_HEADERS += osmocom/core/msgfile.h -- 2.0.0 From jengelh at inai.de Thu Oct 2 21:09:09 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Thu, 2 Oct 2014 23:09:09 +0200 Subject: [PATCH 4/5] build: remove unused all_includes and use AM_CPPFLAGS In-Reply-To: <1412284150-11771-1-git-send-email-jengelh@inai.de> References: <1412284150-11771-1-git-send-email-jengelh@inai.de> Message-ID: <1412284150-11771-5-git-send-email-jengelh@inai.de> Preprocessor flags are best placed in AM_CPPFLAGS. Remove use of the unused all_includes variable, which is never set. --- Makefile.am | 1 - src/Makefile.am | 3 ++- src/codec/Makefile.am | 3 ++- src/gb/Makefile.am | 3 ++- src/gsm/Makefile.am | 3 ++- src/vty/Makefile.am | 3 ++- tests/Makefile.am | 3 ++- utils/Makefile.am | 3 ++- 8 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Makefile.am b/Makefile.am index f2899cc..faf7a83 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,5 @@ ACLOCAL_AMFLAGS = -I m4 -AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include SUBDIRS = include src src/vty src/codec src/gsm src/gb src/ctrl tests utils pkgconfigdir = $(libdir)/pkgconfig diff --git a/src/Makefile.am b/src/Makefile.am index 841f672..29f981d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,7 +2,8 @@ # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification LIBVERSION=4:0:0 -AM_CFLAGS = -Wall $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include +AM_CFLAGS = -Wall lib_LTLIBRARIES = libosmocore.la diff --git a/src/codec/Makefile.am b/src/codec/Makefile.am index f4dec62..b4834e5 100644 --- a/src/codec/Makefile.am +++ b/src/codec/Makefile.am @@ -2,7 +2,8 @@ # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification LIBVERSION=0:0:0 -AM_CFLAGS = -Wall $(all_includes) -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CFLAGS = -Wall lib_LTLIBRARIES = libosmocodec.la diff --git a/src/gb/Makefile.am b/src/gb/Makefile.am index 83af71d..ba85b4f 100644 --- a/src/gb/Makefile.am +++ b/src/gb/Makefile.am @@ -2,7 +2,8 @@ # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification LIBVERSION=3:1:0 -AM_CFLAGS = -Wall ${GCC_FVISIBILITY_HIDDEN} -fno-strict-aliasing $(all_includes) -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CFLAGS = -Wall ${GCC_FVISIBILITY_HIDDEN} -fno-strict-aliasing # FIXME: this should eventually go into a milenage/Makefile.am noinst_HEADERS = common_vty.h diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index df72bf7..8d94ae1 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -2,7 +2,8 @@ # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification LIBVERSION=6:0:1 -AM_CFLAGS = -Wall ${GCC_FVISIBILITY_HIDDEN} $(all_includes) -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CFLAGS = -Wall ${GCC_FVISIBILITY_HIDDEN} # FIXME: this should eventually go into a milenage/Makefile.am noinst_HEADERS = milenage/aes.h milenage/aes_i.h milenage/aes_wrap.h \ diff --git a/src/vty/Makefile.am b/src/vty/Makefile.am index d45659e..52b7ba5 100644 --- a/src/vty/Makefile.am +++ b/src/vty/Makefile.am @@ -2,7 +2,8 @@ # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification LIBVERSION=0:1:0 -AM_CFLAGS = -Wall $(all_includes) -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CFLAGS = -Wall if ENABLE_VTY lib_LTLIBRARIES = libosmovty.la diff --git a/tests/Makefile.am b/tests/Makefile.am index ea4bf9c..8779c4f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,5 @@ -AM_CFLAGS = -Wall $(all_includes) -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CFLAGS = -Wall check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test \ smscb/smscb_test bits/bitrev_test a5/a5_test \ diff --git a/utils/Makefile.am b/utils/Makefile.am index 6a3cd12..51c884a 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -1,5 +1,6 @@ if ENABLE_UTILITIES -AM_CFLAGS = -Wall $(all_includes) -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CFLAGS = -Wall bin_PROGRAMS = osmo-arfcn osmo-auc-gen -- 2.0.0 From jengelh at inai.de Thu Oct 2 21:09:10 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Thu, 2 Oct 2014 23:09:10 +0200 Subject: [PATCH 5/5] build: fix linker error with kasumi_test In-Reply-To: <1412284150-11771-1-git-send-email-jengelh@inai.de> References: <1412284150-11771-1-git-send-email-jengelh@inai.de> Message-ID: <1412284150-11771-6-git-send-email-jengelh@inai.de> When the osmocore package is configured with --disable-static, building of kasumi_test fails. This seems quite legit, given the function _kasumi_kgcore is not exported. Don't try to workaround the build system. Include the code. CCLD kasumi/kasumi_test kasumi_test.o: In function `test_expansion': ~tests/kasumi/kasumi_test.c:25: undefined reference to `_kasumi_key_expand' kasumi_test.o: In function `main': ~tests/kasumi/kasumi_test.c:56: undefined reference to `_kasumi' ~tests/kasumi/kasumi_test.c:100: undefined reference to `_kasumi_key_expand' ~tests/kasumi/kasumi_test.c:112: undefined reference to `_kasumi_kgcore' [...] --- tests/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 8779c4f..3f7db1f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -20,9 +20,8 @@ utils_utils_test_LDADD = $(top_builddir)/src/libosmocore.la a5_a5_test_SOURCES = a5/a5_test.c a5_a5_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la -kasumi_kasumi_test_SOURCES = kasumi/kasumi_test.c +kasumi_kasumi_test_SOURCES = kasumi/kasumi_test.c ../src/gsm/kasumi.c kasumi_kasumi_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la -kasumi_kasumi_test_LDFLAGS = -static comp128_comp128_test_SOURCES = comp128/comp128_test.c comp128_comp128_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la -- 2.0.0 From jengelh at inai.de Thu Oct 2 22:03:43 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Fri, 3 Oct 2014 00:03:43 +0200 Subject: libosmo-netif: build system cleanups Message-ID: <1412287425-28003-1-git-send-email-jengelh@inai.de> The following changes since commit 603f6c40d55b87f81fbd8ff1ad7b9568f3b962ff: build: rename INCLUDES to AM_CPPFLAGS in Makefile.am to avoid warnings (2014-09-11 18:22:02 +0200) are available in the git repository at: git://git.inai.de/libosmo-netif HEAD for you to fetch changes up to 226e99483234c100e5a18ea12838d98a3b091de6: build: remove all_includes (2014-10-02 23:22:55 +0200) ---------------------------------------------------------------- Jan Engelhardt (2): build: put dependency libraries in the right place in Makefiles build: remove all_includes Makefile.am | 1 - examples/Makefile.am | 2 +- examples/channel/Makefile.am | 2 +- src/Makefile.am | 6 +++--- src/channel/abis/Makefile.am | 5 +++-- tests/Makefile.am | 2 +- tests/osmo-pcap-test/Makefile.am | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) From jengelh at inai.de Thu Oct 2 22:03:44 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Fri, 3 Oct 2014 00:03:44 +0200 Subject: [PATCH 1/2] build: put dependency libraries in the right place in Makefiles In-Reply-To: <1412287425-28003-1-git-send-email-jengelh@inai.de> References: <1412287425-28003-1-git-send-email-jengelh@inai.de> Message-ID: <1412287425-28003-2-git-send-email-jengelh@inai.de> Libs must be in _LDADD/_LIBADD and not in _LDFLAGS. --- src/Makefile.am | 4 ++-- src/channel/abis/Makefile.am | 3 ++- tests/osmo-pcap-test/Makefile.am | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 8b4b58e..ca40152 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,13 +4,13 @@ LIBVERSION=2:0:0 AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) AM_CFLAGS= -fPIC -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS) -AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(COVERAGE_LDFLAGS) +AM_LDFLAGS = $(COVERAGE_LDFLAGS) SUBDIRS = channel lib_LTLIBRARIES = libosmonetif.la -libosmonetif_la_LIBADD = channel/abis/libosmonetif-abis.la +libosmonetif_la_LIBADD = channel/abis/libosmonetif-abis.la $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) libosmonetif_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined libosmonetif_la_SOURCES = amr.c \ diff --git a/src/channel/abis/Makefile.am b/src/channel/abis/Makefile.am index e4d93a3..7b744f2 100644 --- a/src/channel/abis/Makefile.am +++ b/src/channel/abis/Makefile.am @@ -1,8 +1,9 @@ AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) AM_CFLAGS= -fPIC -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS) -AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(COVERAGE_LDFLAGS) +AM_LDFLAGS = $(COVERAGE_LDFLAGS) noinst_LTLIBRARIES = libosmonetif-abis.la libosmonetif_abis_la_SOURCES = ipa_stream_server.c \ ipa_stream_client.c +libosmonetif_abis_la_LIBADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) diff --git a/tests/osmo-pcap-test/Makefile.am b/tests/osmo-pcap-test/Makefile.am index 0be6fc4..a256005 100644 --- a/tests/osmo-pcap-test/Makefile.am +++ b/tests/osmo-pcap-test/Makefile.am @@ -9,6 +9,6 @@ osmo_pcap_test_SOURCES = proto.c \ osmux_test.c \ pcap.c -osmo_pcap_test_LDFLAGS = -lpcap \ +osmo_pcap_test_LDADD = -lpcap \ -losmocore \ -losmonetif -- 2.0.0 From jengelh at inai.de Thu Oct 2 22:03:45 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Fri, 3 Oct 2014 00:03:45 +0200 Subject: [PATCH 2/2] build: remove all_includes In-Reply-To: <1412287425-28003-1-git-send-email-jengelh@inai.de> References: <1412287425-28003-1-git-send-email-jengelh@inai.de> Message-ID: <1412287425-28003-3-git-send-email-jengelh@inai.de> This variable is never set and could therefore be removed. --- Makefile.am | 1 - examples/Makefile.am | 2 +- examples/channel/Makefile.am | 2 +- src/Makefile.am | 2 +- src/channel/abis/Makefile.am | 2 +- tests/Makefile.am | 2 +- 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index c8a05a3..519d1ae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,6 @@ AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6 ACLOCAL_AMFLAGS = -I m4 -AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include SUBDIRS = include src examples tests pkgconfigdir = $(libdir)/pkgconfig diff --git a/examples/Makefile.am b/examples/Makefile.am index f8cfc8f..ddfaa48 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include AM_CFLAGS=-Wall -g $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS) AM_LDFLAGS = $(COVERAGE_LDFLAGS) diff --git a/examples/channel/Makefile.am b/examples/channel/Makefile.am index 4191c94..c417909 100644 --- a/examples/channel/Makefile.am +++ b/examples/channel/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include AM_CFLAGS=-Wall -g $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS) AM_LDFLAGS = $(COVERAGE_LDFLAGS) diff --git a/src/Makefile.am b/src/Makefile.am index ca40152..7fbdaf2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,7 +2,7 @@ # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification LIBVERSION=2:0:0 -AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir) AM_CFLAGS= -fPIC -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS) AM_LDFLAGS = $(COVERAGE_LDFLAGS) diff --git a/src/channel/abis/Makefile.am b/src/channel/abis/Makefile.am index 7b744f2..9ccce1d 100644 --- a/src/channel/abis/Makefile.am +++ b/src/channel/abis/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir) AM_CFLAGS= -fPIC -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS) AM_LDFLAGS = $(COVERAGE_LDFLAGS) diff --git a/tests/Makefile.am b/tests/Makefile.am index 0c1fed3..a986940 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -AM_CFLAGS = -Wall $(all_includes) -I$(top_srcdir)/include $(LIBOSMOCORE_CFLAGS) +AM_CFLAGS = -Wall -I$(top_srcdir)/include $(LIBOSMOCORE_CFLAGS) AM_LDFLAGS = $(LIBOSMOCORE_LDFLAGS) check_PROGRAMS = osmux/osmux_test -- 2.0.0 From jengelh at inai.de Fri Oct 3 10:57:01 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Fri, 3 Oct 2014 12:57:01 +0200 Subject: libosmocore: system-talloc+bundled-talloc support Message-ID: <1412333824-18594-1-git-send-email-jengelh@inai.de> "--disable-talloc" had the effect of a "--enable-system-talloc". So the first patch fixes up all the link failures by adding -ltalloc where needed, _for the case that one decides to use disable-talloc_. Second patch will use pkg-config to determine the parameters for a system talloc. These will be used unconditionally, because the variables TALLOC_CFLAGS/TALLOC_LIBS will be empty when using the bundled talloc. === The following changes since commit c60de4f35f3f73f3d79b4ff61d0a20b92f818702: build: fix linker error with kasumi_test (2014-10-03 08:48:31 +0200) are available in the git repository at: git://git.inai.de/libosmocore HEAD for you to fetch changes up to d6c1607a724a07416c7d39f9b43f7af7349de666: build: default to system-provided talloc (2014-10-03 12:43:25 +0200) ---------------------------------------------------------------- Jan Engelhardt (3): build: resolve link failure in libosmogsm when --disable-talloc is used build: allow using a system-provided talloc properly build: default to system-provided talloc .gitignore | 1 + configure.ac | 26 +++++++++++++++++++------ include/Makefile.am | 5 +++-- include/osmocom/core/talloc.h.in | 6 ++++++ include/osmocom/core/{talloc.h => talloc_int.h} | 0 src/Makefile.am | 7 ++++--- src/gsm/Makefile.am | 5 +++-- tests/Makefile.am | 12 ++++++------ tests/msgfile/msgfile_test.c | 1 + 9 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 include/osmocom/core/talloc.h.in rename include/osmocom/core/{talloc.h => talloc_int.h} (100%) From jengelh at inai.de Fri Oct 3 10:57:02 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Fri, 3 Oct 2014 12:57:02 +0200 Subject: [PATCH 1/3] build: resolve link failure in libosmogsm when --disable-talloc is used In-Reply-To: <1412333824-18594-1-git-send-email-jengelh@inai.de> References: <1412333824-18594-1-git-send-email-jengelh@inai.de> Message-ID: <1412333824-18594-2-git-send-email-jengelh@inai.de> libosmogsm.so:lapd-core.c uses talloc_free unconditionally (like libosmocore), but in the absence of the builtin talloc, does not link to libtalloc.so (like libosmocore would). This causes linker failures when programs using libosmogsm are being built. Correct this issue. CCLD osmo-arfcn ../src/gsm/.libs/libosmogsm.so: undefined reference to `talloc_free' collect2: error: ld returned 1 exit status make[2]: *** [osmo-arfcn] Error 1 --- src/gsm/Makefile.am | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index 828aa50..b0cdea2 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -24,5 +24,8 @@ libosmogsm_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \ libosmogsm_la_LDFLAGS = $(LTLDFLAGS_OSMOGSM) -version-info $(LIBVERSION) -no-undefined libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la +if !ENABLE_TALLOC +libosmogsm_la_LIBADD += -ltalloc +endif EXTRA_DIST = libosmogsm.map -- 2.0.0 From holger at freyther.de Fri Oct 3 11:04:06 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 3 Oct 2014 13:04:06 +0200 Subject: [PATCH 1/3] build: resolve link failure in libosmogsm when --disable-talloc is used In-Reply-To: <1412333824-18594-2-git-send-email-jengelh@inai.de> References: <1412333824-18594-1-git-send-email-jengelh@inai.de> <1412333824-18594-2-git-send-email-jengelh@inai.de> Message-ID: <20141003110406.GE12776@xiaoyu.lan> On Fri, Oct 03, 2014 at 12:57:02PM +0200, Jan Engelhardt wrote: Hi! > +if !ENABLE_TALLOC > +libosmogsm_la_LIBADD += -ltalloc > +endif please see my other mail. You assume that a libtalloc exists on the system and that it is found in the library search paths. This is not an improvement, it is a change that breaks in different ways for different people. As in 02.2013 and as of today. I really appreciate your work but I can't take this patch. holger > From jengelh at inai.de Fri Oct 3 11:16:53 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Fri, 3 Oct 2014 13:16:53 +0200 (CEST) Subject: [PATCH 1/3] build: resolve link failure in libosmogsm when --disable-talloc is used In-Reply-To: <20141003110406.GE12776@xiaoyu.lan> References: <1412333824-18594-1-git-send-email-jengelh@inai.de> <1412333824-18594-2-git-send-email-jengelh@inai.de> <20141003110406.GE12776@xiaoyu.lan> Message-ID: On Friday 2014-10-03 13:04, Holger Hans Peter Freyther wrote: >On Fri, Oct 03, 2014 at 12:57:02PM +0200, Jan Engelhardt wrote: > >> +if !ENABLE_TALLOC >> +libosmogsm_la_LIBADD += -ltalloc >> +endif > >You assume that a libtalloc exists on the >system and that it is found in the library search paths. This is >not an improvement, it is a change that breaks in different ways for >different people. It is the same logic that was used for libosmocore_la_LIBADD. It goes away with patch 2 anyway, so it should not hurt. Squash the two if need be. From jengelh at inai.de Fri Oct 3 10:57:03 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Fri, 3 Oct 2014 12:57:03 +0200 Subject: [PATCH 2/3] build: allow using a system-provided talloc properly In-Reply-To: <1412333824-18594-1-git-send-email-jengelh@inai.de> References: <1412333824-18594-1-git-send-email-jengelh@inai.de> Message-ID: <1412333824-18594-3-git-send-email-jengelh@inai.de> When --disable-talloc was given to configure, it would already link libosmocore.so to libtalloc. Make it use pkg-config to discover talloc's flags and location, and when the system talloc is used, make sure to use its API header file too. --- .gitignore | 1 + configure.ac | 16 +++- include/Makefile.am | 3 +- include/osmocom/core/talloc.h | 189 -------------------------------------- include/osmocom/core/talloc.h.in | 6 ++ include/osmocom/core/talloc_int.h | 189 ++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 5 +- src/gsm/Makefile.am | 8 +- tests/Makefile.am | 12 +-- tests/msgfile/msgfile_test.c | 1 + 10 files changed, 226 insertions(+), 204 deletions(-) delete mode 100644 include/osmocom/core/talloc.h create mode 100644 include/osmocom/core/talloc.h.in create mode 100644 include/osmocom/core/talloc_int.h diff --git a/.gitignore b/.gitignore index 1299028..30707a6 100644 --- a/.gitignore +++ b/.gitignore @@ -92,6 +92,7 @@ doc/html.tar src/crc*gen.c include/osmocom/core/crc*gen.h include/osmocom/core/bit*gen.h +/include/osmocom/core/talloc.h # vi files *.sw? diff --git a/configure.ac b/configure.ac index deaa8bf..f0d1206 100644 --- a/configure.ac +++ b/configure.ac @@ -85,10 +85,23 @@ AC_CONFIG_HEADER(config.h) AC_ARG_ENABLE(talloc, [AS_HELP_STRING( [--disable-talloc], - [Disable building talloc memory allocator] + [Disable using bundled talloc memory allocator] )], [enable_talloc=$enableval], [enable_talloc="yes"]) AM_CONDITIONAL(ENABLE_TALLOC, [test x"$enable_talloc" = x"yes"]) +AS_IF([test x"$enable_talloc" = xno], + [ + PKG_CHECK_MODULES([TALLOC], [talloc]) + OSMOCORE_INTERNAL_TALLOC=0 + ], + [ + TALLOC_CFLAGS="" + TALLOC_LIBS="" + OSMOCORE_INTERNAL_TALLOC=1 + AC_SUBST([TALLOC_CFLAGS]) + AC_SUBST([TALLOC_LIBS]) + ]) +AC_SUBST([OSMOCORE_INTERNAL_TALLOC]) AC_ARG_ENABLE(plugin, [AS_HELP_STRING( @@ -188,6 +201,7 @@ AC_OUTPUT( libosmogb.pc libosmoctrl.pc include/Makefile + include/osmocom/core/talloc.h src/Makefile src/vty/Makefile src/codec/Makefile diff --git a/include/Makefile.am b/include/Makefile.am index c59f9b2..4d59a72 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -89,8 +89,9 @@ if ENABLE_PLUGIN nobase_include_HEADERS += osmocom/core/plugin.h endif +nobase_nodist_include_HEADERS = osmocom/core/talloc.h if ENABLE_TALLOC -nobase_include_HEADERS += osmocom/core/talloc.h +nobase_include_HEADERS += osmocom/core/talloc_int.h endif if ENABLE_MSGFILE diff --git a/include/osmocom/core/talloc.h b/include/osmocom/core/talloc.h deleted file mode 100644 index dde102b..0000000 --- a/include/osmocom/core/talloc.h +++ /dev/null @@ -1,189 +0,0 @@ -#pragma once -/* - Unix SMB/CIFS implementation. - Samba temporary memory allocation functions - - Copyright (C) Andrew Tridgell 2004-2005 - Copyright (C) Stefan Metzmacher 2006 - - ** NOTE! The following LGPL license applies to the talloc - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include -#include -#include - -#define HAVE_VA_COPY - -/* this is only needed for compatibility with the old talloc */ -typedef void TALLOC_CTX; - -/* - this uses a little trick to allow __LINE__ to be stringified -*/ -#ifndef __location__ -#define __TALLOC_STRING_LINE1__(s) #s -#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s) -#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__) -#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__ -#endif - -#ifndef TALLOC_DEPRECATED -#define TALLOC_DEPRECATED 0 -#endif - -#ifndef PRINTF_ATTRIBUTE -#if (__GNUC__ >= 3) -/** Use gcc attribute to check printf fns. a1 is the 1-based index of - * the parameter containing the format, and a2 the index of the first - * argument. Note that some gcc 2.x versions don't handle this - * properly **/ -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) -#else -#define PRINTF_ATTRIBUTE(a1, a2) -#endif -#endif - -/* try to make talloc_set_destructor() and talloc_steal() type safe, - if we have a recent gcc */ -#if (__GNUC__ >= 3) -#define _TALLOC_TYPEOF(ptr) __typeof__(ptr) -#define talloc_set_destructor(ptr, function) \ - do { \ - int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \ - _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \ - } while(0) -/* this extremely strange macro is to avoid some braindamaged warning - stupidity in gcc 4.1.x */ -#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; }) -#else -#define talloc_set_destructor(ptr, function) \ - _talloc_set_destructor((ptr), (int (*)(void *))(function)) -#define _TALLOC_TYPEOF(ptr) void * -#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)) -#endif - -#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr)) -#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr)) - -/* useful macros for creating type checked pointers */ -#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) -#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) -#define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr))) - -#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) - -#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) -#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__) - -#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) -#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) -#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) -#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count) -#define talloc_array_length(ctx) (talloc_get_size(ctx)/sizeof(*ctx)) - -#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type) -#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) - -#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) - -#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type) -#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) -#define talloc_get_type_abort(ptr, type) (type *)_talloc_get_type_abort(ptr, #type, __location__) - -#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type) - -#if TALLOC_DEPRECATED -#define talloc_zero_p(ctx, type) talloc_zero(ctx, type) -#define talloc_p(ctx, type) talloc(ctx, type) -#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count) -#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count) -#define talloc_destroy(ctx) talloc_free(ctx) -#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a)) -#endif - -#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0) - -/* The following definitions come from talloc.c */ -void *_talloc(const void *context, size_t size); -void *talloc_pool(const void *context, size_t size); -void _talloc_set_destructor(const void *ptr, int (*_destructor)(void *)); -int talloc_increase_ref_count(const void *ptr); -size_t talloc_reference_count(const void *ptr); -void *_talloc_reference(const void *context, const void *ptr); -int talloc_unlink(const void *context, void *ptr); -const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -void talloc_set_name_const(const void *ptr, const char *name); -void *talloc_named(const void *context, size_t size, - const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); -void *talloc_named_const(const void *context, size_t size, const char *name); -const char *talloc_get_name(const void *ptr); -void *talloc_check_name(const void *ptr, const char *name); -void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location); -void *talloc_parent(const void *ptr); -const char *talloc_parent_name(const void *ptr); -void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); -int talloc_free(void *ptr); -void talloc_free_children(void *ptr); -void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); -void *_talloc_steal(const void *new_ctx, const void *ptr); -void *_talloc_move(const void *new_ctx, const void *pptr); -size_t talloc_total_size(const void *ptr); -size_t talloc_total_blocks(const void *ptr); -void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, - void (*callback)(const void *ptr, - int depth, int max_depth, - int is_ref, - void *private_data), - void *private_data); -void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f); -void talloc_report_full(const void *ptr, FILE *f); -void talloc_report(const void *ptr, FILE *f); -void talloc_enable_null_tracking(void); -void talloc_disable_null_tracking(void); -void talloc_enable_leak_report(void); -void talloc_enable_leak_report_full(void); -void *_talloc_zero(const void *ctx, size_t size, const char *name); -void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); -void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); -void *talloc_realloc_fn(const void *context, void *ptr, size_t size); -void *talloc_autofree_context(void); -size_t talloc_get_size(const void *ctx); -void *talloc_find_parent_byname(const void *ctx, const char *name); -void talloc_show_parents(const void *context, FILE *file); -int talloc_is_parent(const void *context, const void *ptr); - -char *talloc_strdup(const void *t, const char *p); -char *talloc_strdup_append(char *s, const char *a); -char *talloc_strdup_append_buffer(char *s, const char *a); - -char *talloc_strndup(const void *t, const char *p, size_t n); -char *talloc_strndup_append(char *s, const char *a, size_t n); -char *talloc_strndup_append_buffer(char *s, const char *a, size_t n); - -char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); -char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); -char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); - -char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); - -void talloc_set_abort_fn(void (*abort_fn)(const char *reason)); diff --git a/include/osmocom/core/talloc.h.in b/include/osmocom/core/talloc.h.in new file mode 100644 index 0000000..edbbb63 --- /dev/null +++ b/include/osmocom/core/talloc.h.in @@ -0,0 +1,6 @@ +#pragma once +#if @OSMOCORE_INTERNAL_TALLOC@ +#include +#else +#include +#endif diff --git a/include/osmocom/core/talloc_int.h b/include/osmocom/core/talloc_int.h new file mode 100644 index 0000000..dde102b --- /dev/null +++ b/include/osmocom/core/talloc_int.h @@ -0,0 +1,189 @@ +#pragma once +/* + Unix SMB/CIFS implementation. + Samba temporary memory allocation functions + + Copyright (C) Andrew Tridgell 2004-2005 + Copyright (C) Stefan Metzmacher 2006 + + ** NOTE! The following LGPL license applies to the talloc + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see . +*/ + +#include +#include +#include + +#define HAVE_VA_COPY + +/* this is only needed for compatibility with the old talloc */ +typedef void TALLOC_CTX; + +/* + this uses a little trick to allow __LINE__ to be stringified +*/ +#ifndef __location__ +#define __TALLOC_STRING_LINE1__(s) #s +#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s) +#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__) +#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__ +#endif + +#ifndef TALLOC_DEPRECATED +#define TALLOC_DEPRECATED 0 +#endif + +#ifndef PRINTF_ATTRIBUTE +#if (__GNUC__ >= 3) +/** Use gcc attribute to check printf fns. a1 is the 1-based index of + * the parameter containing the format, and a2 the index of the first + * argument. Note that some gcc 2.x versions don't handle this + * properly **/ +#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) +#else +#define PRINTF_ATTRIBUTE(a1, a2) +#endif +#endif + +/* try to make talloc_set_destructor() and talloc_steal() type safe, + if we have a recent gcc */ +#if (__GNUC__ >= 3) +#define _TALLOC_TYPEOF(ptr) __typeof__(ptr) +#define talloc_set_destructor(ptr, function) \ + do { \ + int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \ + _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \ + } while(0) +/* this extremely strange macro is to avoid some braindamaged warning + stupidity in gcc 4.1.x */ +#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; }) +#else +#define talloc_set_destructor(ptr, function) \ + _talloc_set_destructor((ptr), (int (*)(void *))(function)) +#define _TALLOC_TYPEOF(ptr) void * +#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)) +#endif + +#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr)) +#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr)) + +/* useful macros for creating type checked pointers */ +#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) +#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) +#define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr))) + +#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) + +#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) +#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__) + +#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) +#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) +#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) +#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count) +#define talloc_array_length(ctx) (talloc_get_size(ctx)/sizeof(*ctx)) + +#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type) +#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) + +#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) + +#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type) +#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) +#define talloc_get_type_abort(ptr, type) (type *)_talloc_get_type_abort(ptr, #type, __location__) + +#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type) + +#if TALLOC_DEPRECATED +#define talloc_zero_p(ctx, type) talloc_zero(ctx, type) +#define talloc_p(ctx, type) talloc(ctx, type) +#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count) +#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count) +#define talloc_destroy(ctx) talloc_free(ctx) +#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a)) +#endif + +#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0) + +/* The following definitions come from talloc.c */ +void *_talloc(const void *context, size_t size); +void *talloc_pool(const void *context, size_t size); +void _talloc_set_destructor(const void *ptr, int (*_destructor)(void *)); +int talloc_increase_ref_count(const void *ptr); +size_t talloc_reference_count(const void *ptr); +void *_talloc_reference(const void *context, const void *ptr); +int talloc_unlink(const void *context, void *ptr); +const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +void talloc_set_name_const(const void *ptr, const char *name); +void *talloc_named(const void *context, size_t size, + const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); +void *talloc_named_const(const void *context, size_t size, const char *name); +const char *talloc_get_name(const void *ptr); +void *talloc_check_name(const void *ptr, const char *name); +void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location); +void *talloc_parent(const void *ptr); +const char *talloc_parent_name(const void *ptr); +void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); +int talloc_free(void *ptr); +void talloc_free_children(void *ptr); +void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); +void *_talloc_steal(const void *new_ctx, const void *ptr); +void *_talloc_move(const void *new_ctx, const void *pptr); +size_t talloc_total_size(const void *ptr); +size_t talloc_total_blocks(const void *ptr); +void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, + void (*callback)(const void *ptr, + int depth, int max_depth, + int is_ref, + void *private_data), + void *private_data); +void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f); +void talloc_report_full(const void *ptr, FILE *f); +void talloc_report(const void *ptr, FILE *f); +void talloc_enable_null_tracking(void); +void talloc_disable_null_tracking(void); +void talloc_enable_leak_report(void); +void talloc_enable_leak_report_full(void); +void *_talloc_zero(const void *ctx, size_t size, const char *name); +void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); +void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); +void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); +void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); +void *talloc_realloc_fn(const void *context, void *ptr, size_t size); +void *talloc_autofree_context(void); +size_t talloc_get_size(const void *ctx); +void *talloc_find_parent_byname(const void *ctx, const char *name); +void talloc_show_parents(const void *context, FILE *file); +int talloc_is_parent(const void *context, const void *ptr); + +char *talloc_strdup(const void *t, const char *p); +char *talloc_strdup_append(char *s, const char *a); +char *talloc_strdup_append_buffer(char *s, const char *a); + +char *talloc_strndup(const void *t, const char *p, size_t n); +char *talloc_strndup_append(char *s, const char *a, size_t n); +char *talloc_strndup_append_buffer(char *s, const char *a, size_t n); + +char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); + +char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); + +void talloc_set_abort_fn(void (*abort_fn)(const char *reason)); diff --git a/src/Makefile.am b/src/Makefile.am index 65494a5..3924330 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,7 +2,8 @@ # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification LIBVERSION=5:0:0 -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \ + $(TALLOC_CFLAGS) AM_CFLAGS = -Wall lib_LTLIBRARIES = libosmocore.la @@ -29,7 +30,7 @@ endif if ENABLE_TALLOC libosmocore_la_SOURCES += talloc.c else -libosmocore_la_LIBADD += -ltalloc +libosmocore_la_LIBADD += $(TALLOC_LIBS) endif if ENABLE_MSGFILE diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index b0cdea2..40a1821 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -2,7 +2,8 @@ # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification LIBVERSION=6:0:1 -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \ + $(TALLOC_CFLAGS) AM_CFLAGS = -Wall ${GCC_FVISIBILITY_HIDDEN} # FIXME: this should eventually go into a milenage/Makefile.am @@ -23,9 +24,6 @@ libosmogsm_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \ milenage/milenage.c gan.c ipa.c libosmogsm_la_LDFLAGS = $(LTLDFLAGS_OSMOGSM) -version-info $(LIBVERSION) -no-undefined -libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la -if !ENABLE_TALLOC -libosmogsm_la_LIBADD += -ltalloc -endif +libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) EXTRA_DIST = libosmogsm.map diff --git a/tests/Makefile.am b/tests/Makefile.am index 3f7db1f..9f034c0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include $(TALLOC_CFLAGS) AM_CFLAGS = -Wall check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test \ @@ -45,7 +45,7 @@ lapd_lapd_test_SOURCES = lapd/lapd_test.c lapd_lapd_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la msgfile_msgfile_test_SOURCES = msgfile/msgfile_test.c -msgfile_msgfile_test_LDADD = $(top_builddir)/src/libosmocore.la +msgfile_msgfile_test_LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) smscb_smscb_test_SOURCES = smscb/smscb_test.c smscb_smscb_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la @@ -54,13 +54,13 @@ sms_sms_test_SOURCES = sms/sms_test.c sms_sms_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la timer_timer_test_SOURCES = timer/timer_test.c -timer_timer_test_LDADD = $(top_builddir)/src/libosmocore.la +timer_timer_test_LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) ussd_ussd_test_SOURCES = ussd/ussd_test.c ussd_ussd_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la gb_bssgp_fc_test_SOURCES = gb/bssgp_fc_test.c -gb_bssgp_fc_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la +gb_bssgp_fc_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(TALLOC_LIBS) gb_gprs_ns_test_SOURCES = gb/gprs_ns_test.c gb_gprs_ns_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DL) @@ -75,10 +75,10 @@ loggingrb_loggingrb_test_SOURCES = logging/logging_test.c loggingrb_loggingrb_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/vty/libosmovty.la strrb_strrb_test_SOURCES = strrb/strrb_test.c -strrb_strrb_test_LDADD = $(top_builddir)/src/libosmocore.la +strrb_strrb_test_LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) vty_vty_test_SOURCES = vty/vty_test.c -vty_vty_test_LDADD = $(top_builddir)/src/vty/libosmovty.la $(top_builddir)/src/libosmocore.la +vty_vty_test_LDADD = $(top_builddir)/src/vty/libosmovty.la $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) # The `:;' works around a Bash 3.2 bug when the output is not writeable. diff --git a/tests/msgfile/msgfile_test.c b/tests/msgfile/msgfile_test.c index a919694..2684b6a 100644 --- a/tests/msgfile/msgfile_test.c +++ b/tests/msgfile/msgfile_test.c @@ -20,6 +20,7 @@ */ #include +#include #include -- 2.0.0 From holger at freyther.de Fri Oct 3 11:19:25 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 3 Oct 2014 13:19:25 +0200 Subject: [PATCH 2/3] build: allow using a system-provided talloc properly In-Reply-To: <1412333824-18594-3-git-send-email-jengelh@inai.de> References: <1412333824-18594-1-git-send-email-jengelh@inai.de> <1412333824-18594-3-git-send-email-jengelh@inai.de> Message-ID: <20141003111925.GF12776@xiaoyu.lan> On Fri, Oct 03, 2014 at 12:57:03PM +0200, Jan Engelhardt wrote: > When --disable-talloc was given to configure, it would already link > libosmocore.so to libtalloc. Make it use pkg-config to discover > talloc's flags and location, and when the system talloc is used, > make sure to use its API header file too. > include/osmocom/core/talloc.h.in | 6 ++ Have you considered patching libosmocore.pc.in as well to list talloc as "required" there? This way users of libosmocore do not need to check for talloc themselves? $ pkg-config --cflags --libs libosmocore -I/home/ich/install/openbsc/include/ -L/home/ich/install/openbsc/lib -losmocore -ltalloc > AC_ARG_ENABLE(talloc, > [AS_HELP_STRING( > [--disable-talloc], > - [Disable building talloc memory allocator] > + [Disable using bundled talloc memory allocator] > )], > [enable_talloc=$enableval], [enable_talloc="yes"]) > AM_CONDITIONAL(ENABLE_TALLOC, [test x"$enable_talloc" = x"yes"]) > +AS_IF([test x"$enable_talloc" = xno], I think the wording does not reflect the two different usecases we have here. * Firmware builds with no talloc * People wanting to use > +#pragma once > +#if @OSMOCORE_INTERNAL_TALLOC@ > +#include > +#else > +#include > +#endif Let's hope no-one puts -Iinclude/osmocom/core into the compile line or we might end up with recursion. :) > diff --git a/include/osmocom/core/talloc_int.h b/include/osmocom/core/talloc_int.h > new file mode 100644 > index 0000000..dde102b > --- /dev/null > +++ b/include/osmocom/core/talloc_int.h Do you know the '-M' option for send-email/format-patch? It helps with reviewing simple renames. > diff --git a/tests/msgfile/msgfile_test.c b/tests/msgfile/msgfile_test.c > index a919694..2684b6a 100644 > --- a/tests/msgfile/msgfile_test.c > +++ b/tests/msgfile/msgfile_test.c > @@ -20,6 +20,7 @@ > */ > > #include > +#include Is this hunk needed? If you address the pkg-config issue I am happy to inclue your patch. In terms of options.. maybe we can just remove --disable-talloc instead of having sort of a tri-state? thanks a lot holger From jengelh at inai.de Fri Oct 3 11:34:22 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Fri, 3 Oct 2014 13:34:22 +0200 (CEST) Subject: [PATCH 2/3] build: allow using a system-provided talloc properly In-Reply-To: <20141003111925.GF12776@xiaoyu.lan> References: <1412333824-18594-1-git-send-email-jengelh@inai.de> <1412333824-18594-3-git-send-email-jengelh@inai.de> <20141003111925.GF12776@xiaoyu.lan> Message-ID: On Friday 2014-10-03 13:19, Holger Hans Peter Freyther wrote: >On Fri, Oct 03, 2014 at 12:57:03PM +0200, Jan Engelhardt wrote: >> When --disable-talloc was given to configure, it would already link >> libosmocore.so to libtalloc. Make it use pkg-config to discover >> talloc's flags and location, and when the system talloc is used, >> make sure to use its API header file too. > >> include/osmocom/core/talloc.h.in | 6 ++ > >Have you considered patching libosmocore.pc.in as well to list talloc >as "required" there? This way users of libosmocore do not need to check >for talloc themselves? I can do that. >> AC_ARG_ENABLE(talloc, >> [AS_HELP_STRING( >> [--disable-talloc], >> - [Disable building talloc memory allocator] >> + [Disable using bundled talloc memory allocator] >> )], >> [enable_talloc=$enableval], [enable_talloc="yes"]) >> AM_CONDITIONAL(ENABLE_TALLOC, [test x"$enable_talloc" = x"yes"]) >> +AS_IF([test x"$enable_talloc" = xno], > >I think the wording does not reflect the two different usecases we have here. > >* Firmware builds with no talloc That may be the use case, but it is not what was implemented. If you build 0.7.0 [336915aa0a] with --disable-talloc, `ldd src/.libs/libosmocore.so` will show libtalloc.so.2. Which kind of goes against this use case. Therefore, "disable-talloc" really just meant "disable-system-talloc". >> diff --git a/include/osmocom/core/talloc_int.h b/include/osmocom/core/talloc_int.h >> new file mode 100644 >> index 0000000..dde102b >> --- /dev/null >> +++ b/include/osmocom/core/talloc_int.h > >Do you know the '-M' option for send-email/format-patch? It helps with >reviewing simple renames. Been there, tried that. And when I used it, comes someone who wants a non-M submission because they are using some traditional utility or something. Not here, but I remember it occurring on netfilter-devel. >> diff --git a/tests/msgfile/msgfile_test.c b/tests/msgfile/msgfile_test.c >> index a919694..2684b6a 100644 >> --- a/tests/msgfile/msgfile_test.c >> +++ b/tests/msgfile/msgfile_test.c >> @@ -20,6 +20,7 @@ >> */ >> >> #include >> +#include > >Is this hunk needed? Yes, because system talloc has a #define talloc_free(ctx) _talloc_free(ctx, __location__) and otherwise, one gets "implicit definition of talloc_free" and "undefined reference to `talloc_free'". >If you address the pkg-config issue I am happy to inclue your patch. In >terms of options.. maybe we can just remove --disable-talloc instead of >having sort of a tri-state? What's the third option? From peter at stuge.se Fri Oct 3 12:20:53 2014 From: peter at stuge.se (Peter Stuge) Date: Fri, 3 Oct 2014 14:20:53 +0200 Subject: [PATCH 2/3] build: allow using a system-provided talloc properly In-Reply-To: References: <1412333824-18594-1-git-send-email-jengelh@inai.de> <1412333824-18594-3-git-send-email-jengelh@inai.de> <20141003111925.GF12776@xiaoyu.lan> Message-ID: <20141003122053.25826.qmail@stuge.se> Jan Engelhardt wrote: > >* Firmware builds with no talloc > > That may be the use case, but it is not what was implemented. Why don't you look into fixing that instead of renaming configure options - that's just pointless noise. > If you build 0.7.0 [336915aa0a] with --disable-talloc, `ldd > src/.libs/libosmocore.so` will show libtalloc.so.2. Do you want to investigate why? > >> +++ b/tests/msgfile/msgfile_test.c > >> @@ -20,6 +20,7 @@ > >> */ > >> > >> #include > >> +#include > > > >Is this hunk needed? > > Yes, because system talloc has a > > #define talloc_free(ctx) _talloc_free(ctx, __location__) > > and otherwise, one gets "implicit definition of talloc_free" and > "undefined reference to `talloc_free'". Dude, that is a kludge at a callsite, as opposed to a proper dependency fix. Try again. //Peter From jengelh at inai.de Fri Oct 3 12:34:46 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Fri, 3 Oct 2014 14:34:46 +0200 (CEST) Subject: [PATCH 2/3] build: allow using a system-provided talloc properly In-Reply-To: <20141003122053.25826.qmail@stuge.se> References: <1412333824-18594-1-git-send-email-jengelh@inai.de> <1412333824-18594-3-git-send-email-jengelh@inai.de> <20141003111925.GF12776@xiaoyu.lan> <20141003122053.25826.qmail@stuge.se> Message-ID: On Friday 2014-10-03 14:20, Peter Stuge wrote: >Jan Engelhardt wrote: >> >* Firmware builds with no talloc >> >> That may be the use case, but it is not what was implemented. > >Why don't you look into fixing that Why should I? Why can't you? >> If you build 0.7.0 [336915aa0a] with --disable-talloc, `ldd >> src/.libs/libosmocore.so` will show libtalloc.so.2. > >Do you want to investigate why? Because someone placed -ltalloc into libosmocore_la_LIBADD, the result of satisfying the calls to talloc that the osmocore code is sprinkled with. IOW, osmocore provides no alternative paths to using talloc. >> >> +++ b/tests/msgfile/msgfile_test.c >> >> @@ -20,6 +20,7 @@ >> >> */ >> >> >> >> #include >> >> +#include >> > >> >Is this hunk needed? >> >> Yes, because system talloc has a >> >> #define talloc_free(ctx) _talloc_free(ctx, __location__) >> >> and otherwise, one gets "implicit definition of talloc_free" and >> "undefined reference to `talloc_free'". > >Dude, that is a kludge at a callsite, as opposed to a proper >dependency fix. Try again. Well, enlighten us, mr-know-it-all. From peter at stuge.se Fri Oct 3 13:16:14 2014 From: peter at stuge.se (Peter Stuge) Date: Fri, 3 Oct 2014 15:16:14 +0200 Subject: [PATCH 2/3] build: allow using a system-provided talloc properly In-Reply-To: References: <1412333824-18594-1-git-send-email-jengelh@inai.de> <1412333824-18594-3-git-send-email-jengelh@inai.de> <20141003111925.GF12776@xiaoyu.lan> <20141003122053.25826.qmail@stuge.se> Message-ID: <20141003131614.29780.qmail@stuge.se> Jan Engelhardt wrote: > >Jan Engelhardt wrote: > >> >* Firmware builds with no talloc > >> > >> That may be the use case, but it is not what was implemented. > > > >Why don't you look into fixing that > > Why should I? Because you seem to be working with this part of the code now and you might as well do a thorough job if you're spending time on it. > Why can't you? I wish I could. > >> >> +++ b/tests/msgfile/msgfile_test.c > >> >> @@ -20,6 +20,7 @@ > >> >> */ > >> >> > >> >> #include > >> >> +#include > >> > > >> >Is this hunk needed? > >> > >> Yes, because system talloc has a > >> > >> #define talloc_free(ctx) _talloc_free(ctx, __location__) > >> > >> and otherwise, one gets "implicit definition of talloc_free" and > >> "undefined reference to `talloc_free'". > > > >Dude, that is a kludge at a callsite, as opposed to a proper > >dependency fix. Try again. > > Well, enlighten us, mr-know-it-all. Here's a hint at least: Think about symmetry and dependency. //Peter From jengelh at inai.de Fri Oct 3 14:42:55 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Fri, 3 Oct 2014 16:42:55 +0200 (CEST) Subject: [PATCH 2/3] build: allow using a system-provided talloc properly In-Reply-To: <20141003131614.29780.qmail@stuge.se> References: <1412333824-18594-1-git-send-email-jengelh@inai.de> <1412333824-18594-3-git-send-email-jengelh@inai.de> <20141003111925.GF12776@xiaoyu.lan> <20141003122053.25826.qmail@stuge.se> <20141003131614.29780.qmail@stuge.se> Message-ID: On Friday 2014-10-03 15:16, Peter Stuge wrote: >> >> >* Firmware builds with no talloc >> >> That may be the use case, but it is not what was implemented. >> >Why don't you look into fixing that >> Why should I? > >Because you seem to be working with this part of the code now and you >might as well do a thorough job if you're spending time on it. I am not going to sprinkle osmocore with defines or otherwise make talloc pluggable/replaceable by some other set of allocation functions. I came to fix the problem I have an interest in, and that is making osmocore support a system talloc in lieu or in addition to a bundled talloc (-> http://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries), exercising standard diliegence, which includes that previously supported cases continue to function to the best of observation. >> >> >> +++ b/tests/msgfile/msgfile_test.c >> >> >> @@ -20,6 +20,7 @@ >> >> >> */ >> >> >> >> >> >> #include >> >> >> +#include >> >> > >> >> >Is this hunk needed? >> >> Yes, because system talloc has a >> >> #define talloc_free(ctx) _talloc_free(ctx, __location__) >> >> and otherwise, one gets "implicit definition of talloc_free" and >> >> "undefined reference to `talloc_free'". >> > >> >Dude, that is a kludge at a callsite, as opposed to a proper >> >dependency fix. Try again. > >Here's a hint at least: Think about symmetry and dependency. I have no idea what you mean by that. Talk code, not riddles. Other code also uses #include , so it does not seem too far-fetched to use the exact line to support the case of multiple talloc configurations. From holger at freyther.de Fri Oct 3 20:56:50 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 3 Oct 2014 22:56:50 +0200 Subject: [PATCH 2/3] build: allow using a system-provided talloc properly In-Reply-To: References: <1412333824-18594-1-git-send-email-jengelh@inai.de> <1412333824-18594-3-git-send-email-jengelh@inai.de> <20141003111925.GF12776@xiaoyu.lan> <20141003122053.25826.qmail@stuge.se> <20141003131614.29780.qmail@stuge.se> Message-ID: <20141003205650.GD2849@xiaoyu.lan> On Fri, Oct 03, 2014 at 04:42:55PM +0200, Jan Engelhardt wrote: Dear Jan, Peter, > >Because you seem to be working with this part of the code now and you > >might as well do a thorough job if you're spending time on it. > > I am not going to sprinkle osmocore with defines or otherwise make > talloc pluggable/replaceable by some other set of allocation > functions. I came to fix the problem I have an interest in, and that > is making osmocore support a system talloc in lieu or in addition to > a bundled talloc (-> > http://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries), > exercising standard diliegence, which includes that previously > supported cases continue to function to the best of observation. Nobody is arguing about that. We should not even have a bundled copy of talloc.c. The reason we have one is historic (IIRC there were certainly no -dev/devel packages in any distribution back then and I am not sure if talloc.c even existed outside the samba code). I do appreciate your work to help us move to using the system version of libtalloc. So let's all calm down. > >> >> >Is this hunk needed? > >> >> Yes, because system talloc has a > >> >> #define talloc_free(ctx) _talloc_free(ctx, __location__) > >> >> and otherwise, one gets "implicit definition of talloc_free" and okay, I see the compiler warning now and will fix it. cheers holger From peter at stuge.se Fri Oct 3 22:45:43 2014 From: peter at stuge.se (Peter Stuge) Date: Sat, 4 Oct 2014 00:45:43 +0200 Subject: [PATCH 2/3] build: allow using a system-provided talloc properly In-Reply-To: References: <1412333824-18594-1-git-send-email-jengelh@inai.de> <1412333824-18594-3-git-send-email-jengelh@inai.de> <20141003111925.GF12776@xiaoyu.lan> <20141003122053.25826.qmail@stuge.se> <20141003131614.29780.qmail@stuge.se> Message-ID: <20141003224543.8828.qmail@stuge.se> Jan Engelhardt wrote: > > On Friday 2014-10-03 15:16, Peter Stuge wrote: > > >> >> >* Firmware builds with no talloc > >> >> That may be the use case, but it is not what was implemented. > >> >Why don't you look into fixing that > >> Why should I? > > > >Because you seem to be working with this part of the code now and you > >might as well do a thorough job if you're spending time on it. > > I am not going to Okey then. > >> >> >> +#include > >> >> > > >> >> >Is this hunk needed? > >> >> Yes, because system talloc has a > >> >> #define talloc_free(ctx) _talloc_free(ctx, __location__) > >> >> and otherwise, one gets "implicit definition of talloc_free" and > >> >> "undefined reference to `talloc_free'". > >> > > >> >Dude, that is a kludge at a callsite, as opposed to a proper > >> >dependency fix. Try again. > > > >Here's a hint at least: Think about symmetry and dependency. > > I have no idea what you mean by that. That's sad.. :\ > Talk code, not riddles. > Other code also uses #include , > so it does not seem too far-fetched to use the exact line > to support the case of multiple talloc configurations. Think more about it. Why did you add the talloc.h include? - Because the file calls talloc_free(). Why is talloc_free() called? - To free memory allocated and returned by osmo_config_list_parse(). Symmetry then dictates that the talloc.h include belongs in msgfile.h, as opposed to in all files which includes msgfile.h. I really hope that makes sense. Headers usually do include their dependencies, rather than require callers to do that on their own. //Peter From jengelh at inai.de Sat Oct 4 08:54:25 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Sat, 4 Oct 2014 10:54:25 +0200 (CEST) Subject: [PATCH 2/3] build: allow using a system-provided talloc properly In-Reply-To: <20141003224543.8828.qmail@stuge.se> References: <1412333824-18594-1-git-send-email-jengelh@inai.de> <1412333824-18594-3-git-send-email-jengelh@inai.de> <20141003111925.GF12776@xiaoyu.lan> <20141003122053.25826.qmail@stuge.se> <20141003131614.29780.qmail@stuge.se> <20141003224543.8828.qmail@stuge.se> Message-ID: On Saturday 2014-10-04 00:45, Peter Stuge wrote: > >Why did you add the talloc.h include? >- Because the file calls talloc_free(). >Why is talloc_free() called? >- To free memory allocated and returned by osmo_config_list_parse(). > >Symmetry then dictates that the talloc.h include belongs in msgfile.h, >as opposed to in all files which includes msgfile.h. Certainly. I even concur with the symmetry argument, though I feel you have missed one point: Symmetry would desire that there be a osmo_config_list_free() function (or macro/static inline function), because the allocation method of "struct osmo_config_list" would be an implementation detail of osmo_config_list_parse(). >I really hope that makes sense. Headers usually do include their >dependencies, rather than require callers to do that on their own. As of yet though, talloc is not a "direct" dependency of msgfile.h, that is, there are no names used from talloc.h and `gcc -x c msgfile.h` will succeed. With a osmo_config_list_free() function/macro/SI, the talloc #include would always be at the callsite too, though the callsite is shifted. From jengelh at inai.de Fri Oct 3 10:57:04 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Fri, 3 Oct 2014 12:57:04 +0200 Subject: [PATCH 3/3] build: default to system-provided talloc In-Reply-To: <1412333824-18594-1-git-send-email-jengelh@inai.de> References: <1412333824-18594-1-git-send-email-jengelh@inai.de> Message-ID: <1412333824-18594-4-git-send-email-jengelh@inai.de> Rename the option --enable-talloc to --enable-internal-talloc, and then make disable-internal-talloc the default when nothing else is specified. --- configure.ac | 12 ++++++------ include/Makefile.am | 2 +- src/Makefile.am | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index f0d1206..f12675a 100644 --- a/configure.ac +++ b/configure.ac @@ -82,14 +82,14 @@ CHECK_TM_INCLUDES_TM_GMTOFF dnl Generate the output AC_CONFIG_HEADER(config.h) -AC_ARG_ENABLE(talloc, +AC_ARG_ENABLE([internal-talloc], [AS_HELP_STRING( - [--disable-talloc], + [--enable-internal-talloc], [Disable using bundled talloc memory allocator] )], - [enable_talloc=$enableval], [enable_talloc="yes"]) -AM_CONDITIONAL(ENABLE_TALLOC, [test x"$enable_talloc" = x"yes"]) -AS_IF([test x"$enable_talloc" = xno], + [internal_talloc=$enableval], [internal_talloc="no"]) +AM_CONDITIONAL([INTERNAL_TALLOC], [test x"$internal_talloc" = x"yes"]) +AS_IF([test x"$internal_talloc" = xno], [ PKG_CHECK_MODULES([TALLOC], [talloc]) OSMOCORE_INTERNAL_TALLOC=0 @@ -186,7 +186,7 @@ then AM_CONDITIONAL(ENABLE_MSGFILE, false) AM_CONDITIONAL(ENABLE_SERIAL, false) AM_CONDITIONAL(ENABLE_VTY, false) - AM_CONDITIONAL(ENABLE_TALLOC, false) + AM_CONDITIONAL([INTERNAL_TALLOC], [true]) AM_CONDITIONAL(ENABLE_UTILITIES, false) AM_CONDITIONAL(ENABLE_GB, false) AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort]) diff --git a/include/Makefile.am b/include/Makefile.am index 4d59a72..d8af474 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -90,7 +90,7 @@ nobase_include_HEADERS += osmocom/core/plugin.h endif nobase_nodist_include_HEADERS = osmocom/core/talloc.h -if ENABLE_TALLOC +if INTERNAL_TALLOC nobase_include_HEADERS += osmocom/core/talloc_int.h endif diff --git a/src/Makefile.am b/src/Makefile.am index 3924330..4a6ba5c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,7 +27,7 @@ else libosmocore_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined endif -if ENABLE_TALLOC +if INTERNAL_TALLOC libosmocore_la_SOURCES += talloc.c else libosmocore_la_LIBADD += $(TALLOC_LIBS) -- 2.0.0 From jengelh at inai.de Sat Oct 4 09:10:20 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Sat, 4 Oct 2014 11:10:20 +0200 Subject: libosmocore: to talloc or not to talloc Message-ID: <1412413825-24016-1-git-send-email-jengelh@inai.de> Changes to previous submission: - split out the implicit declaration patch (p3 -> p3,p1) - edit libosmocore.pc to include Requires: pkgconfig. (in p3) - add (p5) as an optional commit to completely remove the bundled copy The antisymmetry of osmo_config_list_parse is a matter for a subsequent submission. === The following changes since commit c60de4f35f3f73f3d79b4ff61d0a20b92f818702: build: fix linker error with kasumi_test (2014-10-03 08:48:31 +0200) are available in the git repository at: git://git.inai.de/libosmocore HEAD for you to fetch changes up to a962cd7b62b92a0acc49591d9b3af2b46e023850: build: remove bundled copy of talloc (2014-10-04 11:06:44 +0200) ---------------------------------------------------------------- Jan Engelhardt (5): build: resolve compiler warning about implicit delcaration build: resolve link failure in libosmogsm when --disable-talloc is used build: allow using a system-provided talloc properly build: default to system-provided talloc build: remove bundled copy of talloc Makefile.am | 2 + configure.ac | 9 +- include/Makefile.am | 4 - include/osmocom/core/strrb.h | 2 +- include/osmocom/core/talloc.h | 189 ------------------------------------- include/osmocom/core/utils.h | 2 +- include/osmocom/ctrl/control_cmd.h | 2 +- libosmocore.pc.in | 2 +- src/Makefile.am | 10 +- src/ctrl/control_cmd.c | 2 +- src/ctrl/control_if.c | 2 +- src/gb/common_vty.c | 2 +- src/gb/gprs_bssgp.c | 2 +- src/gb/gprs_bssgp_bss.c | 2 +- src/gb/gprs_bssgp_util.c | 2 +- src/gb/gprs_bssgp_vty.c | 2 +- src/gb/gprs_ns.c | 2 +- src/gb/gprs_ns_frgre.c | 2 +- src/gb/gprs_ns_vty.c | 2 +- src/gsm/Makefile.am | 5 +- src/gsm/ipa.c | 2 +- src/gsm/lapd_core.c | 2 +- src/gsmtap_util.c | 2 +- src/logging.c | 2 +- src/logging_syslog.c | 2 +- src/msgb.c | 2 +- src/msgfile.c | 2 +- src/rate_ctr.c | 2 +- src/signal.c | 2 +- src/statistics.c | 2 +- src/talloc.c | 2 +- src/vty/buffer.c | 2 +- src/vty/command.c | 2 +- src/vty/logging_vty.c | 2 +- src/vty/telnet_interface.c | 2 +- src/vty/utils.c | 2 +- src/vty/vector.c | 2 +- src/vty/vty.c | 2 +- tests/Makefile.am | 12 +-- tests/gb/bssgp_fc_test.c | 2 +- tests/gb/gprs_ns_test.c | 2 +- tests/msgfile/msgfile_test.c | 1 + tests/strrb/strrb_test.c | 2 +- tests/timer/timer_test.c | 2 +- tests/vty/vty_test.c | 2 +- 45 files changed, 53 insertions(+), 253 deletions(-) delete mode 100644 include/osmocom/core/talloc.h From jengelh at inai.de Sat Oct 4 09:10:21 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Sat, 4 Oct 2014 11:10:21 +0200 Subject: [PATCH 1/5] build: resolve compiler warning about implicit delcaration In-Reply-To: <1412413825-24016-1-git-send-email-jengelh@inai.de> References: <1412413825-24016-1-git-send-email-jengelh@inai.de> Message-ID: <1412413825-24016-2-git-send-email-jengelh@inai.de> CC msgfile_test.o msgfile/msgfile_test.c: In function "main": msgfile/msgfile_test.c:48:2: warning: implicit declaration of function "talloc_free" [-Wimplicit-function-declaration] talloc_free(entries); ^ --- tests/msgfile/msgfile_test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/msgfile/msgfile_test.c b/tests/msgfile/msgfile_test.c index a919694..2684b6a 100644 --- a/tests/msgfile/msgfile_test.c +++ b/tests/msgfile/msgfile_test.c @@ -20,6 +20,7 @@ */ #include +#include #include -- 2.0.0 From jengelh at inai.de Sat Oct 4 09:10:22 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Sat, 4 Oct 2014 11:10:22 +0200 Subject: [PATCH 2/5] build: resolve link failure in libosmogsm when --disable-talloc is used In-Reply-To: <1412413825-24016-1-git-send-email-jengelh@inai.de> References: <1412413825-24016-1-git-send-email-jengelh@inai.de> Message-ID: <1412413825-24016-3-git-send-email-jengelh@inai.de> libosmogsm.so:lapd-core.c uses talloc_free unconditionally (like libosmocore), but in the absence of the builtin talloc, does not link to libtalloc.so (like libosmocore would). This causes linker failures when programs using libosmogsm are being built. Correct this issue. CCLD osmo-arfcn ../src/gsm/.libs/libosmogsm.so: undefined reference to `talloc_free' collect2: error: ld returned 1 exit status make[2]: *** [osmo-arfcn] Error 1 --- src/gsm/Makefile.am | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index 828aa50..b0cdea2 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -24,5 +24,8 @@ libosmogsm_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \ libosmogsm_la_LDFLAGS = $(LTLDFLAGS_OSMOGSM) -version-info $(LIBVERSION) -no-undefined libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la +if !ENABLE_TALLOC +libosmogsm_la_LIBADD += -ltalloc +endif EXTRA_DIST = libosmogsm.map -- 2.0.0 From jengelh at inai.de Sat Oct 4 09:10:23 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Sat, 4 Oct 2014 11:10:23 +0200 Subject: [PATCH 3/5] build: allow using a system-provided talloc properly In-Reply-To: <1412413825-24016-1-git-send-email-jengelh@inai.de> References: <1412413825-24016-1-git-send-email-jengelh@inai.de> Message-ID: <1412413825-24016-4-git-send-email-jengelh@inai.de> When --disable-talloc was given to configure, it would already link libosmocore.so to libtalloc. Make it use pkg-config to discover talloc's flags and location, and when the system talloc is used, make sure to use its API header file too. --- .gitignore | 1 + Makefile.am | 2 ++ configure.ac | 16 +++++++++++++++- include/Makefile.am | 3 ++- include/osmocom/core/talloc.h.in | 6 ++++++ include/osmocom/core/{talloc.h => talloc_int.h} | 0 libosmocore.pc.in | 2 +- src/Makefile.am | 5 +++-- src/gsm/Makefile.am | 8 +++----- tests/Makefile.am | 12 ++++++------ 10 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 include/osmocom/core/talloc.h.in rename include/osmocom/core/{talloc.h => talloc_int.h} (100%) diff --git a/.gitignore b/.gitignore index 1299028..30707a6 100644 --- a/.gitignore +++ b/.gitignore @@ -92,6 +92,7 @@ doc/html.tar src/crc*gen.c include/osmocom/core/crc*gen.h include/osmocom/core/bit*gen.h +/include/osmocom/core/talloc.h # vi files *.sw? diff --git a/Makefile.am b/Makefile.am index faf7a83..5144c87 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,6 +6,8 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libosmocore.pc libosmocodec.pc libosmovty.pc libosmogsm.pc \ libosmogb.pc libosmoctrl.pc +$(pkgconfig_DATA): $(top_builddir)/config.status + BUILT_SOURCES = $(top_srcdir)/.version $(top_srcdir)/.version: echo $(VERSION) > $@-t && mv $@-t $@ diff --git a/configure.ac b/configure.ac index deaa8bf..f0d1206 100644 --- a/configure.ac +++ b/configure.ac @@ -85,10 +85,23 @@ AC_CONFIG_HEADER(config.h) AC_ARG_ENABLE(talloc, [AS_HELP_STRING( [--disable-talloc], - [Disable building talloc memory allocator] + [Disable using bundled talloc memory allocator] )], [enable_talloc=$enableval], [enable_talloc="yes"]) AM_CONDITIONAL(ENABLE_TALLOC, [test x"$enable_talloc" = x"yes"]) +AS_IF([test x"$enable_talloc" = xno], + [ + PKG_CHECK_MODULES([TALLOC], [talloc]) + OSMOCORE_INTERNAL_TALLOC=0 + ], + [ + TALLOC_CFLAGS="" + TALLOC_LIBS="" + OSMOCORE_INTERNAL_TALLOC=1 + AC_SUBST([TALLOC_CFLAGS]) + AC_SUBST([TALLOC_LIBS]) + ]) +AC_SUBST([OSMOCORE_INTERNAL_TALLOC]) AC_ARG_ENABLE(plugin, [AS_HELP_STRING( @@ -188,6 +201,7 @@ AC_OUTPUT( libosmogb.pc libosmoctrl.pc include/Makefile + include/osmocom/core/talloc.h src/Makefile src/vty/Makefile src/codec/Makefile diff --git a/include/Makefile.am b/include/Makefile.am index c59f9b2..4d59a72 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -89,8 +89,9 @@ if ENABLE_PLUGIN nobase_include_HEADERS += osmocom/core/plugin.h endif +nobase_nodist_include_HEADERS = osmocom/core/talloc.h if ENABLE_TALLOC -nobase_include_HEADERS += osmocom/core/talloc.h +nobase_include_HEADERS += osmocom/core/talloc_int.h endif if ENABLE_MSGFILE diff --git a/include/osmocom/core/talloc.h.in b/include/osmocom/core/talloc.h.in new file mode 100644 index 0000000..edbbb63 --- /dev/null +++ b/include/osmocom/core/talloc.h.in @@ -0,0 +1,6 @@ +#pragma once +#if @OSMOCORE_INTERNAL_TALLOC@ +#include +#else +#include +#endif diff --git a/include/osmocom/core/talloc.h b/include/osmocom/core/talloc_int.h similarity index 100% rename from include/osmocom/core/talloc.h rename to include/osmocom/core/talloc_int.h diff --git a/libosmocore.pc.in b/libosmocore.pc.in index 7c29869..25832f6 100644 --- a/libosmocore.pc.in +++ b/libosmocore.pc.in @@ -8,4 +8,4 @@ Description: C Utility Library Version: @VERSION@ Libs: -L${libdir} -losmocore Cflags: -I${includedir}/ - + at ENABLE_TALLOC_FALSE@Requires: talloc diff --git a/src/Makefile.am b/src/Makefile.am index 65494a5..3924330 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,7 +2,8 @@ # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification LIBVERSION=5:0:0 -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \ + $(TALLOC_CFLAGS) AM_CFLAGS = -Wall lib_LTLIBRARIES = libosmocore.la @@ -29,7 +30,7 @@ endif if ENABLE_TALLOC libosmocore_la_SOURCES += talloc.c else -libosmocore_la_LIBADD += -ltalloc +libosmocore_la_LIBADD += $(TALLOC_LIBS) endif if ENABLE_MSGFILE diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index b0cdea2..40a1821 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -2,7 +2,8 @@ # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification LIBVERSION=6:0:1 -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \ + $(TALLOC_CFLAGS) AM_CFLAGS = -Wall ${GCC_FVISIBILITY_HIDDEN} # FIXME: this should eventually go into a milenage/Makefile.am @@ -23,9 +24,6 @@ libosmogsm_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \ milenage/milenage.c gan.c ipa.c libosmogsm_la_LDFLAGS = $(LTLDFLAGS_OSMOGSM) -version-info $(LIBVERSION) -no-undefined -libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la -if !ENABLE_TALLOC -libosmogsm_la_LIBADD += -ltalloc -endif +libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) EXTRA_DIST = libosmogsm.map diff --git a/tests/Makefile.am b/tests/Makefile.am index 3f7db1f..9f034c0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include $(TALLOC_CFLAGS) AM_CFLAGS = -Wall check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test \ @@ -45,7 +45,7 @@ lapd_lapd_test_SOURCES = lapd/lapd_test.c lapd_lapd_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la msgfile_msgfile_test_SOURCES = msgfile/msgfile_test.c -msgfile_msgfile_test_LDADD = $(top_builddir)/src/libosmocore.la +msgfile_msgfile_test_LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) smscb_smscb_test_SOURCES = smscb/smscb_test.c smscb_smscb_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la @@ -54,13 +54,13 @@ sms_sms_test_SOURCES = sms/sms_test.c sms_sms_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la timer_timer_test_SOURCES = timer/timer_test.c -timer_timer_test_LDADD = $(top_builddir)/src/libosmocore.la +timer_timer_test_LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) ussd_ussd_test_SOURCES = ussd/ussd_test.c ussd_ussd_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la gb_bssgp_fc_test_SOURCES = gb/bssgp_fc_test.c -gb_bssgp_fc_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la +gb_bssgp_fc_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(TALLOC_LIBS) gb_gprs_ns_test_SOURCES = gb/gprs_ns_test.c gb_gprs_ns_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DL) @@ -75,10 +75,10 @@ loggingrb_loggingrb_test_SOURCES = logging/logging_test.c loggingrb_loggingrb_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/vty/libosmovty.la strrb_strrb_test_SOURCES = strrb/strrb_test.c -strrb_strrb_test_LDADD = $(top_builddir)/src/libosmocore.la +strrb_strrb_test_LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) vty_vty_test_SOURCES = vty/vty_test.c -vty_vty_test_LDADD = $(top_builddir)/src/vty/libosmovty.la $(top_builddir)/src/libosmocore.la +vty_vty_test_LDADD = $(top_builddir)/src/vty/libosmovty.la $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) # The `:;' works around a Bash 3.2 bug when the output is not writeable. -- 2.0.0 From jengelh at inai.de Sat Oct 4 09:10:24 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Sat, 4 Oct 2014 11:10:24 +0200 Subject: [PATCH 4/5] build: default to system-provided talloc In-Reply-To: <1412413825-24016-1-git-send-email-jengelh@inai.de> References: <1412413825-24016-1-git-send-email-jengelh@inai.de> Message-ID: <1412413825-24016-5-git-send-email-jengelh@inai.de> Rename the option --enable-talloc to --enable-internal-talloc, and then make disable-internal-talloc the default when nothing else is specified. --- configure.ac | 12 ++++++------ include/Makefile.am | 2 +- libosmocore.pc.in | 2 +- src/Makefile.am | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index f0d1206..f12675a 100644 --- a/configure.ac +++ b/configure.ac @@ -82,14 +82,14 @@ CHECK_TM_INCLUDES_TM_GMTOFF dnl Generate the output AC_CONFIG_HEADER(config.h) -AC_ARG_ENABLE(talloc, +AC_ARG_ENABLE([internal-talloc], [AS_HELP_STRING( - [--disable-talloc], + [--enable-internal-talloc], [Disable using bundled talloc memory allocator] )], - [enable_talloc=$enableval], [enable_talloc="yes"]) -AM_CONDITIONAL(ENABLE_TALLOC, [test x"$enable_talloc" = x"yes"]) -AS_IF([test x"$enable_talloc" = xno], + [internal_talloc=$enableval], [internal_talloc="no"]) +AM_CONDITIONAL([INTERNAL_TALLOC], [test x"$internal_talloc" = x"yes"]) +AS_IF([test x"$internal_talloc" = xno], [ PKG_CHECK_MODULES([TALLOC], [talloc]) OSMOCORE_INTERNAL_TALLOC=0 @@ -186,7 +186,7 @@ then AM_CONDITIONAL(ENABLE_MSGFILE, false) AM_CONDITIONAL(ENABLE_SERIAL, false) AM_CONDITIONAL(ENABLE_VTY, false) - AM_CONDITIONAL(ENABLE_TALLOC, false) + AM_CONDITIONAL([INTERNAL_TALLOC], [true]) AM_CONDITIONAL(ENABLE_UTILITIES, false) AM_CONDITIONAL(ENABLE_GB, false) AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort]) diff --git a/include/Makefile.am b/include/Makefile.am index 4d59a72..d8af474 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -90,7 +90,7 @@ nobase_include_HEADERS += osmocom/core/plugin.h endif nobase_nodist_include_HEADERS = osmocom/core/talloc.h -if ENABLE_TALLOC +if INTERNAL_TALLOC nobase_include_HEADERS += osmocom/core/talloc_int.h endif diff --git a/libosmocore.pc.in b/libosmocore.pc.in index 25832f6..2ec6a74 100644 --- a/libosmocore.pc.in +++ b/libosmocore.pc.in @@ -8,4 +8,4 @@ Description: C Utility Library Version: @VERSION@ Libs: -L${libdir} -losmocore Cflags: -I${includedir}/ - at ENABLE_TALLOC_FALSE@Requires: talloc + at INTERNAL_TALLOC_FALSE@Requires: talloc diff --git a/src/Makefile.am b/src/Makefile.am index 3924330..4a6ba5c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,7 +27,7 @@ else libosmocore_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined endif -if ENABLE_TALLOC +if INTERNAL_TALLOC libosmocore_la_SOURCES += talloc.c else libosmocore_la_LIBADD += $(TALLOC_LIBS) -- 2.0.0 From jengelh at inai.de Sat Oct 4 09:10:25 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Sat, 4 Oct 2014 11:10:25 +0200 Subject: [PATCH 5/5] build: remove bundled copy of talloc In-Reply-To: <1412413825-24016-1-git-send-email-jengelh@inai.de> References: <1412413825-24016-1-git-send-email-jengelh@inai.de> Message-ID: <1412413825-24016-6-git-send-email-jengelh@inai.de> Mailing list discussion showed that the bundled talloc idea was not so good after all. --- .gitignore | 1 - configure.ac | 23 +---- include/Makefile.am | 5 - include/osmocom/core/strrb.h | 2 +- include/osmocom/core/talloc.h.in | 6 -- include/osmocom/core/talloc_int.h | 189 ------------------------------------- include/osmocom/core/utils.h | 2 +- include/osmocom/ctrl/control_cmd.h | 2 +- libosmocore.pc.in | 2 +- src/Makefile.am | 5 - src/ctrl/control_cmd.c | 2 +- src/ctrl/control_if.c | 2 +- src/gb/common_vty.c | 2 +- src/gb/gprs_bssgp.c | 2 +- src/gb/gprs_bssgp_bss.c | 2 +- src/gb/gprs_bssgp_util.c | 2 +- src/gb/gprs_bssgp_vty.c | 2 +- src/gb/gprs_ns.c | 2 +- src/gb/gprs_ns_frgre.c | 2 +- src/gb/gprs_ns_vty.c | 2 +- src/gsm/ipa.c | 2 +- src/gsm/lapd_core.c | 2 +- src/gsmtap_util.c | 2 +- src/logging.c | 2 +- src/logging_syslog.c | 2 +- src/msgb.c | 2 +- src/msgfile.c | 2 +- src/rate_ctr.c | 2 +- src/signal.c | 2 +- src/statistics.c | 2 +- src/talloc.c | 2 +- src/vty/buffer.c | 2 +- src/vty/command.c | 2 +- src/vty/logging_vty.c | 2 +- src/vty/telnet_interface.c | 2 +- src/vty/utils.c | 2 +- src/vty/vector.c | 2 +- src/vty/vty.c | 2 +- tests/gb/bssgp_fc_test.c | 2 +- tests/gb/gprs_ns_test.c | 2 +- tests/msgfile/msgfile_test.c | 2 +- tests/strrb/strrb_test.c | 2 +- tests/timer/timer_test.c | 2 +- tests/vty/vty_test.c | 2 +- 44 files changed, 39 insertions(+), 266 deletions(-) delete mode 100644 include/osmocom/core/talloc.h.in delete mode 100644 include/osmocom/core/talloc_int.h diff --git a/.gitignore b/.gitignore index 30707a6..1299028 100644 --- a/.gitignore +++ b/.gitignore @@ -92,7 +92,6 @@ doc/html.tar src/crc*gen.c include/osmocom/core/crc*gen.h include/osmocom/core/bit*gen.h -/include/osmocom/core/talloc.h # vi files *.sw? diff --git a/configure.ac b/configure.ac index f12675a..68ef830 100644 --- a/configure.ac +++ b/configure.ac @@ -82,26 +82,7 @@ CHECK_TM_INCLUDES_TM_GMTOFF dnl Generate the output AC_CONFIG_HEADER(config.h) -AC_ARG_ENABLE([internal-talloc], - [AS_HELP_STRING( - [--enable-internal-talloc], - [Disable using bundled talloc memory allocator] - )], - [internal_talloc=$enableval], [internal_talloc="no"]) -AM_CONDITIONAL([INTERNAL_TALLOC], [test x"$internal_talloc" = x"yes"]) -AS_IF([test x"$internal_talloc" = xno], - [ - PKG_CHECK_MODULES([TALLOC], [talloc]) - OSMOCORE_INTERNAL_TALLOC=0 - ], - [ - TALLOC_CFLAGS="" - TALLOC_LIBS="" - OSMOCORE_INTERNAL_TALLOC=1 - AC_SUBST([TALLOC_CFLAGS]) - AC_SUBST([TALLOC_LIBS]) - ]) -AC_SUBST([OSMOCORE_INTERNAL_TALLOC]) +PKG_CHECK_MODULES([TALLOC], [talloc]) AC_ARG_ENABLE(plugin, [AS_HELP_STRING( @@ -186,7 +167,6 @@ then AM_CONDITIONAL(ENABLE_MSGFILE, false) AM_CONDITIONAL(ENABLE_SERIAL, false) AM_CONDITIONAL(ENABLE_VTY, false) - AM_CONDITIONAL([INTERNAL_TALLOC], [true]) AM_CONDITIONAL(ENABLE_UTILITIES, false) AM_CONDITIONAL(ENABLE_GB, false) AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort]) @@ -201,7 +181,6 @@ AC_OUTPUT( libosmogb.pc libosmoctrl.pc include/Makefile - include/osmocom/core/talloc.h src/Makefile src/vty/Makefile src/codec/Makefile diff --git a/include/Makefile.am b/include/Makefile.am index d8af474..858140c 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -89,11 +89,6 @@ if ENABLE_PLUGIN nobase_include_HEADERS += osmocom/core/plugin.h endif -nobase_nodist_include_HEADERS = osmocom/core/talloc.h -if INTERNAL_TALLOC -nobase_include_HEADERS += osmocom/core/talloc_int.h -endif - if ENABLE_MSGFILE nobase_include_HEADERS += osmocom/core/msgfile.h endif diff --git a/include/osmocom/core/strrb.h b/include/osmocom/core/strrb.h index c563d1b..2c7cfb2 100644 --- a/include/osmocom/core/strrb.h +++ b/include/osmocom/core/strrb.h @@ -31,7 +31,7 @@ #include #include -#include +#include /*! \brief A structure representing an osmocom string ringbuffer */ diff --git a/include/osmocom/core/talloc.h.in b/include/osmocom/core/talloc.h.in deleted file mode 100644 index edbbb63..0000000 --- a/include/osmocom/core/talloc.h.in +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -#if @OSMOCORE_INTERNAL_TALLOC@ -#include -#else -#include -#endif diff --git a/include/osmocom/core/talloc_int.h b/include/osmocom/core/talloc_int.h deleted file mode 100644 index dde102b..0000000 --- a/include/osmocom/core/talloc_int.h +++ /dev/null @@ -1,189 +0,0 @@ -#pragma once -/* - Unix SMB/CIFS implementation. - Samba temporary memory allocation functions - - Copyright (C) Andrew Tridgell 2004-2005 - Copyright (C) Stefan Metzmacher 2006 - - ** NOTE! The following LGPL license applies to the talloc - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include -#include -#include - -#define HAVE_VA_COPY - -/* this is only needed for compatibility with the old talloc */ -typedef void TALLOC_CTX; - -/* - this uses a little trick to allow __LINE__ to be stringified -*/ -#ifndef __location__ -#define __TALLOC_STRING_LINE1__(s) #s -#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s) -#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__) -#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__ -#endif - -#ifndef TALLOC_DEPRECATED -#define TALLOC_DEPRECATED 0 -#endif - -#ifndef PRINTF_ATTRIBUTE -#if (__GNUC__ >= 3) -/** Use gcc attribute to check printf fns. a1 is the 1-based index of - * the parameter containing the format, and a2 the index of the first - * argument. Note that some gcc 2.x versions don't handle this - * properly **/ -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) -#else -#define PRINTF_ATTRIBUTE(a1, a2) -#endif -#endif - -/* try to make talloc_set_destructor() and talloc_steal() type safe, - if we have a recent gcc */ -#if (__GNUC__ >= 3) -#define _TALLOC_TYPEOF(ptr) __typeof__(ptr) -#define talloc_set_destructor(ptr, function) \ - do { \ - int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \ - _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \ - } while(0) -/* this extremely strange macro is to avoid some braindamaged warning - stupidity in gcc 4.1.x */ -#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; }) -#else -#define talloc_set_destructor(ptr, function) \ - _talloc_set_destructor((ptr), (int (*)(void *))(function)) -#define _TALLOC_TYPEOF(ptr) void * -#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)) -#endif - -#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr)) -#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr)) - -/* useful macros for creating type checked pointers */ -#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) -#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) -#define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr))) - -#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) - -#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) -#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__) - -#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) -#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) -#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) -#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count) -#define talloc_array_length(ctx) (talloc_get_size(ctx)/sizeof(*ctx)) - -#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type) -#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) - -#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) - -#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type) -#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) -#define talloc_get_type_abort(ptr, type) (type *)_talloc_get_type_abort(ptr, #type, __location__) - -#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type) - -#if TALLOC_DEPRECATED -#define talloc_zero_p(ctx, type) talloc_zero(ctx, type) -#define talloc_p(ctx, type) talloc(ctx, type) -#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count) -#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count) -#define talloc_destroy(ctx) talloc_free(ctx) -#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a)) -#endif - -#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0) - -/* The following definitions come from talloc.c */ -void *_talloc(const void *context, size_t size); -void *talloc_pool(const void *context, size_t size); -void _talloc_set_destructor(const void *ptr, int (*_destructor)(void *)); -int talloc_increase_ref_count(const void *ptr); -size_t talloc_reference_count(const void *ptr); -void *_talloc_reference(const void *context, const void *ptr); -int talloc_unlink(const void *context, void *ptr); -const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -void talloc_set_name_const(const void *ptr, const char *name); -void *talloc_named(const void *context, size_t size, - const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); -void *talloc_named_const(const void *context, size_t size, const char *name); -const char *talloc_get_name(const void *ptr); -void *talloc_check_name(const void *ptr, const char *name); -void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location); -void *talloc_parent(const void *ptr); -const char *talloc_parent_name(const void *ptr); -void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); -int talloc_free(void *ptr); -void talloc_free_children(void *ptr); -void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); -void *_talloc_steal(const void *new_ctx, const void *ptr); -void *_talloc_move(const void *new_ctx, const void *pptr); -size_t talloc_total_size(const void *ptr); -size_t talloc_total_blocks(const void *ptr); -void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, - void (*callback)(const void *ptr, - int depth, int max_depth, - int is_ref, - void *private_data), - void *private_data); -void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f); -void talloc_report_full(const void *ptr, FILE *f); -void talloc_report(const void *ptr, FILE *f); -void talloc_enable_null_tracking(void); -void talloc_disable_null_tracking(void); -void talloc_enable_leak_report(void); -void talloc_enable_leak_report_full(void); -void *_talloc_zero(const void *ctx, size_t size, const char *name); -void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); -void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); -void *talloc_realloc_fn(const void *context, void *ptr, size_t size); -void *talloc_autofree_context(void); -size_t talloc_get_size(const void *ctx); -void *talloc_find_parent_byname(const void *ctx, const char *name); -void talloc_show_parents(const void *context, FILE *file); -int talloc_is_parent(const void *context, const void *ptr); - -char *talloc_strdup(const void *t, const char *p); -char *talloc_strdup_append(char *s, const char *a); -char *talloc_strdup_append_buffer(char *s, const char *a); - -char *talloc_strndup(const void *t, const char *p, size_t n); -char *talloc_strndup_append(char *s, const char *a, size_t n); -char *talloc_strndup_append_buffer(char *s, const char *a, size_t n); - -char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); -char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); -char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); - -char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); - -void talloc_set_abort_fn(void (*abort_fn)(const char *reason)); diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 373522a..b627c7b 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include /*! \defgroup utils General-purpose utility functions * @{ diff --git a/include/osmocom/ctrl/control_cmd.h b/include/osmocom/ctrl/control_cmd.h index 8f2eaa2..c5b7162 100644 --- a/include/osmocom/ctrl/control_cmd.h +++ b/include/osmocom/ctrl/control_cmd.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include diff --git a/libosmocore.pc.in b/libosmocore.pc.in index 2ec6a74..7a9b925 100644 --- a/libosmocore.pc.in +++ b/libosmocore.pc.in @@ -8,4 +8,4 @@ Description: C Utility Library Version: @VERSION@ Libs: -L${libdir} -losmocore Cflags: -I${includedir}/ - at INTERNAL_TALLOC_FALSE@Requires: talloc +Requires: talloc diff --git a/src/Makefile.am b/src/Makefile.am index 4a6ba5c..8050ad0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,12 +26,7 @@ libosmocore_la_LDFLAGS = -version-info $(LIBVERSION) $(LIBRARY_DL) -no-undefined else libosmocore_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined endif - -if INTERNAL_TALLOC -libosmocore_la_SOURCES += talloc.c -else libosmocore_la_LIBADD += $(TALLOC_LIBS) -endif if ENABLE_MSGFILE libosmocore_la_SOURCES += msgfile.c diff --git a/src/ctrl/control_cmd.c b/src/ctrl/control_cmd.c index 4e156b8..4d47145 100644 --- a/src/ctrl/control_cmd.c +++ b/src/ctrl/control_cmd.c @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index c20c1e0..364a092 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/gb/common_vty.c b/src/gb/common_vty.c index 0bd0b6c..030b2a6 100644 --- a/src/gb/common_vty.c +++ b/src/gb/common_vty.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index 0e9fd38..b002286 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include diff --git a/src/gb/gprs_bssgp_bss.c b/src/gb/gprs_bssgp_bss.c index 7d4c07c..5094e76 100644 --- a/src/gb/gprs_bssgp_bss.c +++ b/src/gb/gprs_bssgp_bss.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/gb/gprs_bssgp_util.c b/src/gb/gprs_bssgp_util.c index 604764c..0e534df 100644 --- a/src/gb/gprs_bssgp_util.c +++ b/src/gb/gprs_bssgp_util.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index d8e1d32..0a2b05b 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index ee2d7ec..0f27710 100644 --- a/src/gb/gprs_ns.c +++ b/src/gb/gprs_ns.c @@ -72,7 +72,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/gb/gprs_ns_frgre.c b/src/gb/gprs_ns_frgre.c index 57cf65e..9b7e92e 100644 --- a/src/gb/gprs_ns_frgre.c +++ b/src/gb/gprs_ns_frgre.c @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include diff --git a/src/gb/gprs_ns_vty.c b/src/gb/gprs_ns_vty.c index 4fa60ad..d4b7812 100644 --- a/src/gb/gprs_ns_vty.c +++ b/src/gb/gprs_ns_vty.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c index a49d8ac..77136f1 100644 --- a/src/gsm/ipa.c +++ b/src/gsm/ipa.c @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c index 8c5fe9c..d7401de 100644 --- a/src/gsm/lapd_core.c +++ b/src/gsm/lapd_core.c @@ -80,7 +80,7 @@ #include #include #include -#include +#include #include /* TS 04.06 Table 4 / Section 3.8.1 */ diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c index 82690a9..fe9d30b 100644 --- a/src/gsmtap_util.c +++ b/src/gsmtap_util.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/logging.c b/src/logging.c index f9d789d..d636170 100644 --- a/src/logging.c +++ b/src/logging.c @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include diff --git a/src/logging_syslog.c b/src/logging_syslog.c index 5b0ae5f..202b3d1 100644 --- a/src/logging_syslog.c +++ b/src/logging_syslog.c @@ -39,7 +39,7 @@ #include #endif -#include +#include #include #include diff --git a/src/msgb.c b/src/msgb.c index b2fe1d2..d169d56 100644 --- a/src/msgb.c +++ b/src/msgb.c @@ -31,7 +31,7 @@ #include //#include -#include +#include //#include void *tall_msgb_ctx; diff --git a/src/msgfile.c b/src/msgfile.c index 1a99184..d4cc567 100644 --- a/src/msgfile.c +++ b/src/msgfile.c @@ -22,7 +22,7 @@ */ #include -#include +#include #include #include diff --git a/src/rate_ctr.c b/src/rate_ctr.c index 8a232e8..602e060 100644 --- a/src/rate_ctr.c +++ b/src/rate_ctr.c @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include diff --git a/src/signal.c b/src/signal.c index 6384384..68be30f 100644 --- a/src/signal.c +++ b/src/signal.c @@ -19,7 +19,7 @@ */ #include -#include +#include #include #include #include diff --git a/src/statistics.c b/src/statistics.c index e28541b..0e559d8 100644 --- a/src/statistics.c +++ b/src/statistics.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include static LLIST_HEAD(counters); diff --git a/src/talloc.c b/src/talloc.c index d3a0690..b3c0146 100644 --- a/src/talloc.c +++ b/src/talloc.c @@ -54,7 +54,7 @@ #define __USE_GNU #include #undef __USE_GNU -#include +#include #define MIN(x,y) ((x) < (y) ? (x) : (y)) #endif /* not _TALLOC_SAMBA3 */ diff --git a/src/vty/buffer.c b/src/vty/buffer.c index e385f9f..ecfb961 100644 --- a/src/vty/buffer.c +++ b/src/vty/buffer.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/src/vty/command.c b/src/vty/command.c index 44a1b6c..bf83a74 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -38,7 +38,7 @@ Boston, MA 02111-1307, USA. */ #include #include -#include +#include /*! \addtogroup command * @{ diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 47877fe..0faa17f 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -24,7 +24,7 @@ #include "../../config.h" -#include +#include #include #include #include diff --git a/src/vty/telnet_interface.c b/src/vty/telnet_interface.c index 50b08c8..bd4037f 100644 --- a/src/vty/telnet_interface.c +++ b/src/vty/telnet_interface.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/src/vty/utils.c b/src/vty/utils.c index d0ad431..d7df523 100644 --- a/src/vty/utils.c +++ b/src/vty/utils.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/vty/vector.c b/src/vty/vector.c index 4012f24..6a4f4bd 100644 --- a/src/vty/vector.c +++ b/src/vty/vector.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include void *tall_vty_vec_ctx; diff --git a/src/vty/vty.c b/src/vty/vty.c index 10a323f..1739d92 100644 --- a/src/vty/vty.c +++ b/src/vty/vty.c @@ -54,7 +54,7 @@ #include #include #include -#include +#include /* \addtogroup vty * @{ diff --git a/tests/gb/bssgp_fc_test.c b/tests/gb/bssgp_fc_test.c index 64e4b4e..bc9ab39 100644 --- a/tests/gb/bssgp_fc_test.c +++ b/tests/gb/bssgp_fc_test.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include static unsigned long in_ctr = 1; diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c index c90d752..c51f643 100644 --- a/tests/gb/gprs_ns_test.c +++ b/tests/gb/gprs_ns_test.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/tests/msgfile/msgfile_test.c b/tests/msgfile/msgfile_test.c index 2684b6a..1dd922b 100644 --- a/tests/msgfile/msgfile_test.c +++ b/tests/msgfile/msgfile_test.c @@ -20,7 +20,7 @@ */ #include -#include +#include #include diff --git a/tests/strrb/strrb_test.c b/tests/strrb/strrb_test.c index 6140ac9..9b8ec34 100644 --- a/tests/strrb/strrb_test.c +++ b/tests/strrb/strrb_test.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include diff --git a/tests/timer/timer_test.c b/tests/timer/timer_test.c index 6184f66..67a22c7 100644 --- a/tests/timer/timer_test.c +++ b/tests/timer/timer_test.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c index 2a7347f..67c8679 100644 --- a/tests/vty/vty_test.c +++ b/tests/vty/vty_test.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include -- 2.0.0 From holger at freyther.de Sat Oct 4 09:59:56 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sat, 4 Oct 2014 11:59:56 +0200 Subject: [PATCH 5/5] build: remove bundled copy of talloc In-Reply-To: <1412413825-24016-6-git-send-email-jengelh@inai.de> References: <1412413825-24016-1-git-send-email-jengelh@inai.de> <1412413825-24016-6-git-send-email-jengelh@inai.de> Message-ID: <20141004095956.GA21893@xiaoyu.lan> On Sat, Oct 04, 2014 at 11:10:25AM +0200, Jan Engelhardt wrote: > diff --git a/include/osmocom/core/talloc.h.in b/include/osmocom/core/talloc.h.in > deleted file mode 100644 > index edbbb63..0000000 > --- a/include/osmocom/core/talloc.h.in > +++ /dev/null > @@ -1,6 +0,0 @@ > -#pragma once > -#if @OSMOCORE_INTERNAL_TALLOC@ > -#include > -#else > -#include > -#endif leave it for a transition period. > --- a/include/osmocom/ctrl/control_cmd.h > +++ b/include/osmocom/ctrl/control_cmd.h > @@ -1,7 +1,7 @@ > #pragma once > > #include > -#include > +#include > #include > #include In general these blocks are grouped. E.g. from most specific to general (specially to make sure that a header file can be included directly). So all of the #include are at the wrong place now. Either it is done correctly right now or leave osmocom/core/talloc.h for a transition period. thanks for working on it holger From jengelh at inai.de Sat Oct 4 10:11:46 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Sat, 4 Oct 2014 12:11:46 +0200 (CEST) Subject: [PATCH 5/5] build: remove bundled copy of talloc In-Reply-To: <20141004095956.GA21893@xiaoyu.lan> References: <1412413825-24016-1-git-send-email-jengelh@inai.de> <1412413825-24016-6-git-send-email-jengelh@inai.de> <20141004095956.GA21893@xiaoyu.lan> Message-ID: On Saturday 2014-10-04 11:59, Holger Hans Peter Freyther wrote: >On Sat, Oct 04, 2014 at 11:10:25AM +0200, Jan Engelhardt wrote: >> >> #include >> -#include >> +#include >> #include >> #include > >In general these blocks are grouped. E.g. from most specific to >general (specially to make sure that a header file can be included >directly). So all of the #include are at the wrong place >now. Either it is done correctly right now or leave osmocom/core/talloc.h >for a transition period. Just take the first four then. From jerlbeck at sysmocom.de Wed Oct 8 10:05:13 2014 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 8 Oct 2014 12:05:13 +0200 Subject: [PATCH 1/6] gprs-ns/test: Use gprs_nsvc_reset instead of gprs_ns_tx_reset Message-ID: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> Currently gprs_ns_tx_reset is used to let the NS stack generate NS_RESET message. This is not adjusting the nsvc state properly. This patch uses gprs_nsvc_reset instead which starts the full reset procedure. Sponsored-by: On-Waves ehf --- tests/gb/gprs_ns_test.c | 23 ++++++++--------------- tests/gb/gprs_ns_test.ok | 12 +++++------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c index c90d752..15e36ba 100644 --- a/tests/gb/gprs_ns_test.c +++ b/tests/gb/gprs_ns_test.c @@ -573,7 +573,6 @@ static void test_bss_reset_ack() struct sockaddr_in peer[4] = {{0},}; struct gprs_nsvc *nsvc; struct sockaddr_in *nse[4]; - int rc; peer[0].sin_family = AF_INET; peer[0].sin_port = htons(1111); @@ -604,7 +603,7 @@ static void test_bss_reset_ack() printf("--- Setup VC 1 SGSN -> BSS ---\n\n"); nsvc = gprs_nsvc_by_nsvci(nsi, 0x1001); - gprs_ns_tx_reset(nsvc, NS_CAUSE_OM_INTERVENTION); + gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION); send_ns_reset_ack(nsi, nse[0], 0x1001, 0x1000); gprs_dump_nsi(nsi); @@ -616,25 +615,19 @@ static void test_bss_reset_ack() printf("--- Setup VC 2 SGSN -> BSS (hits NSEI 1) ---\n\n"); nsvc = gprs_nsvc_by_nsvci(nsi, 0x2001); - gprs_ns_tx_reset(nsvc, NS_CAUSE_OM_INTERVENTION); + gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION); send_ns_reset_ack(nsi, nse[0], 0x1001, 0x1000); gprs_dump_nsi(nsi); printf("--- Setup VC 2 SGSN -> BSS (hits NSEI 2) ---\n\n"); nsvc = gprs_nsvc_by_nsvci(nsi, 0x2001); - rc = gprs_ns_tx_reset(nsvc, NS_CAUSE_OM_INTERVENTION); - if (rc < 0) - printf("Failed to send RESET to %s\n\n", gprs_ns_ll_str(nsvc)); - else { - send_ns_reset_ack(nsi, nse[1], 0x2001, 0x2000); - gprs_dump_nsi(nsi); - } + gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION); printf("--- Setup VC 1 SGSN -> BSS (hits NSEI 1) ---\n\n"); nsvc = gprs_nsvc_by_nsvci(nsi, 0x1001); - gprs_ns_tx_reset(nsvc, NS_CAUSE_OM_INTERVENTION); + gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION); send_ns_reset_ack(nsi, nse[0], 0x1001, 0x1000); gprs_dump_nsi(nsi); @@ -683,7 +676,7 @@ static void test_bss_reset_ack() printf("--- RESET_ACK with invalid NSEI, BSS -> SGSN ---\n\n"); nsvc = gprs_nsvc_by_nsvci(nsi, 0x1001); - gprs_ns_tx_reset(nsvc, NS_CAUSE_OM_INTERVENTION); + gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION); send_ns_reset_ack(nsi, nse[0], 0x1001, 0xf000); gprs_dump_nsi(nsi); @@ -692,7 +685,7 @@ static void test_bss_reset_ack() printf("--- RESET_ACK with invalid NSVCI, BSS -> SGSN ---\n\n"); nsvc = gprs_nsvc_by_nsvci(nsi, 0x1001); - gprs_ns_tx_reset(nsvc, NS_CAUSE_OM_INTERVENTION); + gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION); send_ns_reset_ack(nsi, nse[0], 0xf001, 0x1000); gprs_dump_nsi(nsi); @@ -761,7 +754,7 @@ static void test_sgsn_reset() printf("--- RESET_ACK with invalid NSEI, BSS -> SGSN ---\n\n"); nsvc = gprs_nsvc_by_nsvci(nsi, SGSN_NSEI+1); - gprs_ns_tx_reset(nsvc, NS_CAUSE_OM_INTERVENTION); + gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION); send_ns_reset_ack(nsi, &sgsn_peer, SGSN_NSEI+1, 0xe000); gprs_dump_nsi(nsi); @@ -770,7 +763,7 @@ static void test_sgsn_reset() printf("--- RESET_ACK with invalid NSVCI, BSS -> SGSN ---\n\n"); nsvc = gprs_nsvc_by_nsvci(nsi, SGSN_NSEI+1); - gprs_ns_tx_reset(nsvc, NS_CAUSE_OM_INTERVENTION); + gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION); send_ns_reset_ack(nsi, &sgsn_peer, 0xe001, SGSN_NSEI); gprs_dump_nsi(nsi); diff --git a/tests/gb/gprs_ns_test.ok b/tests/gb/gprs_ns_test.ok index 13d5f36..0d4b7fb 100644 --- a/tests/gb/gprs_ns_test.ok +++ b/tests/gb/gprs_ns_test.ok @@ -368,15 +368,13 @@ MESSAGE to BSS, msg length 1 result (RESET_ACK) = 1 Current NS-VCIs: - VCI 0x2001, NSEI 0x2000, peer 0x00000000:0 + VCI 0x2001, NSEI 0x2000, peer 0x00000000:0, blocked, dead VCI 0x1001, NSEI 0x1000, peer 0x01020304:2222, blocked NS-VC Block count : 2 NS-VC replaced other count: 1 --- Setup VC 2 SGSN -> BSS (hits NSEI 2) --- -Failed to send RESET to 0.0.0.0:0 - --- Setup VC 1 SGSN -> BSS (hits NSEI 1) --- MESSAGE to BSS, msg length 12 @@ -391,7 +389,7 @@ MESSAGE to BSS, msg length 1 result (RESET_ACK) = 1 Current NS-VCIs: - VCI 0x2001, NSEI 0x2000, peer 0x00000000:0 + VCI 0x2001, NSEI 0x2000, peer 0x00000000:0, blocked, dead VCI 0x1001, NSEI 0x1000, peer 0x01020304:2222, blocked NS-VC Block count : 3 NS-VC replaced other count: 1 @@ -566,7 +564,7 @@ Current NS-VCIs: NS-VC Block count : 1 NS-VC replaced other count: 2 VCI 0x2001, NSEI 0x2000, peer 0x01020304:1111 - VCI 0x1001, NSEI 0xf000, peer 0x00000000:0, blocked + VCI 0x1001, NSEI 0xf000, peer 0x00000000:0, blocked, dead NS-VC Block count : 4 NS-VC replaced other count: 2 NS-VC changed NSEI count : 3 @@ -700,7 +698,7 @@ PROCESSING RESET_ACK from 0x05060708:32000 result (RESET_ACK) = -22 Current NS-VCIs: - VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000, blocked + VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000, blocked, dead NS-VC Block count : 1 NS-VCI was invalid count : 1 NSEI was invalid count : 2 @@ -717,7 +715,7 @@ PROCESSING RESET_ACK from 0x05060708:32000 result (RESET_ACK) = -22 Current NS-VCIs: - VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000, blocked + VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000, blocked, dead NS-VC Block count : 1 NS-VCI was invalid count : 2 NSEI was invalid count : 2 -- 1.9.1 From jerlbeck at sysmocom.de Wed Oct 8 10:05:14 2014 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 8 Oct 2014 12:05:14 +0200 Subject: [PATCH 2/6] gprs-ns/test: Save the last PCU type sent In-Reply-To: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> References: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1412762718-31961-2-git-send-email-jerlbeck@sysmocom.de> This records the PCU type of the last message sent to the remote peer in the global variable sent_pdu_type, which can then be used in assertions. Note that sent_pdu_type will remain unchanged if no message has been sent via sendto. Sponsored-by: On-Waves ehf --- tests/gb/gprs_ns_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c index 15e36ba..0b3a76c 100644 --- a/tests/gb/gprs_ns_test.c +++ b/tests/gb/gprs_ns_test.c @@ -32,6 +32,8 @@ #define SGSN_NSEI 0x0100 +static int sent_pdu_type = 0; + static int gprs_process_message(struct gprs_ns_inst *nsi, const char *text, struct sockaddr_in *peer, const unsigned char* data, size_t data_len); @@ -265,6 +267,8 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, if (!real_sendto) real_sendto = dlsym(RTLD_NEXT, "sendto"); + sent_pdu_type = len > 0 ? ((uint8_t *)buf)[0] : -1; + if (dest_host == REMOTE_BSS_ADDR) printf("MESSAGE to BSS, msg length %d\n%s\n\n", len, osmo_hexdump(buf, len)); else if (dest_host == REMOTE_SGSN_ADDR) -- 1.9.1 From holger at freyther.de Thu Oct 9 05:44:22 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 9 Oct 2014 07:44:22 +0200 Subject: [PATCH 2/6] gprs-ns/test: Save the last PCU type sent In-Reply-To: <1412762718-31961-2-git-send-email-jerlbeck@sysmocom.de> References: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> <1412762718-31961-2-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20141009054422.GB12473@xiaoyu.lan> On Wed, Oct 08, 2014 at 12:05:14PM +0200, Jacob Erlbeck wrote: > This records the PCU type of the last message sent to the remote peer ^-- PDU ;) From jerlbeck at sysmocom.de Wed Oct 8 10:05:15 2014 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 8 Oct 2014 12:05:15 +0200 Subject: [PATCH 3/6] gprs-ns/test: Add expire_nsvc_timer In-Reply-To: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> References: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1412762718-31961-3-git-send-email-jerlbeck@sysmocom.de> This function forces the expiration of the timer within struct gprs_nsvc. It is meant to be used for controlled (and faster) timer expiration in unit tests. The timer_mode of the expired timer is returned (or -1 if the timer wasn't active). Sponsored-by: On-Waves ehf --- tests/gb/gprs_ns_test.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c index 0b3a76c..d56bf9a 100644 --- a/tests/gb/gprs_ns_test.c +++ b/tests/gb/gprs_ns_test.c @@ -451,6 +451,21 @@ static void gprs_dump_nsi(struct gprs_ns_inst *nsi) printf("\n"); } +static int expire_nsvc_timer(struct gprs_nsvc *nsvc) +{ + int rc; + + if (!osmo_timer_pending(&nsvc->timer)) + return -1; + + rc = nsvc->timer_mode; + osmo_timer_del(&nsvc->timer); + + nsvc->timer.cb(nsvc->timer.data); + + return rc; +} + static void test_nsvc() { struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL); -- 1.9.1 From jerlbeck at sysmocom.de Wed Oct 8 10:05:16 2014 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 8 Oct 2014 12:05:16 +0200 Subject: [PATCH 4/6] gprs-ns/test: Add test_sgsn_reset_invalid_state In-Reply-To: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> References: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1412762718-31961-4-git-send-email-jerlbeck@sysmocom.de> This tests the behaviour for a certain combination of messages and packet losses that can put the NS-VC object into an undefined state. In that state, the peer's ALIVE messages are properly answered, but the local test procedure has stopped, incoming unitdata PDUs are answered by STATUS(NS-VC blocked) and the unblocking procedure is not initiated. Ticket: OW#1312 Sponsored-by: On-Waves ehf --- tests/gb/gprs_ns_test.c | 64 +++++++++++++++++++++++++++++++ tests/gb/gprs_ns_test.ok | 99 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+) diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c index d56bf9a..ad8e6d5 100644 --- a/tests/gb/gprs_ns_test.c +++ b/tests/gb/gprs_ns_test.c @@ -791,6 +791,69 @@ static void test_sgsn_reset() nsi = NULL; } +static void test_sgsn_reset_invalid_state() +{ + struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL); + struct sockaddr_in sgsn_peer= {0}; + struct gprs_nsvc *nsvc; + int retry; + uint8_t dummy_sdu[] = {0x01, 0x02, 0x03, 0x04}; + + sgsn_peer.sin_family = AF_INET; + sgsn_peer.sin_port = htons(32000); + sgsn_peer.sin_addr.s_addr = htonl(REMOTE_SGSN_ADDR); + + gprs_dump_nsi(nsi); + + printf("=== %s ===\n", __func__); + printf("--- Setup SGSN connection, BSS -> SGSN ---\n\n"); + + gprs_ns_nsip_connect(nsi, &sgsn_peer, SGSN_NSEI, SGSN_NSEI+1); + OSMO_ASSERT(sent_pdu_type == NS_PDUT_RESET); + send_ns_reset_ack(nsi, &sgsn_peer, SGSN_NSEI+1, SGSN_NSEI); + OSMO_ASSERT(sent_pdu_type == NS_PDUT_ALIVE); + send_ns_alive_ack(nsi, &sgsn_peer); + OSMO_ASSERT(sent_pdu_type == NS_PDUT_UNBLOCK); + send_ns_unblock_ack(nsi, &sgsn_peer); + gprs_dump_nsi(nsi); + nsvc = gprs_nsvc_by_nsvci(nsi, SGSN_NSEI+1); + OSMO_ASSERT(nsvc->state == NSE_S_ALIVE); + OSMO_ASSERT(nsvc->remote_state == NSE_S_ALIVE); + + printf("--- Time out local test procedure ---\n\n"); + + OSMO_ASSERT(expire_nsvc_timer(nsvc) == NSVC_TIMER_TNS_TEST); + OSMO_ASSERT(expire_nsvc_timer(nsvc) == NSVC_TIMER_TNS_ALIVE); + + for (retry = 1; retry <= nsi->timeout[NS_TOUT_TNS_ALIVE_RETRIES]; ++retry) + OSMO_ASSERT(expire_nsvc_timer(nsvc) == NSVC_TIMER_TNS_ALIVE); + + OSMO_ASSERT(nsvc->state == NSE_S_BLOCKED); + + printf("--- Remote test procedure continues ---\n\n"); + + send_ns_alive(nsi, &sgsn_peer); + OSMO_ASSERT(sent_pdu_type == NS_PDUT_RESET); + + printf("--- Don't send a NS_RESET_ACK message (pretend it is lost) ---\n\n"); + + sent_pdu_type = -1; + send_ns_alive(nsi, &sgsn_peer); + /* Disabled, since it is not yet fixed + OSMO_ASSERT(sent_pdu_type == -1); + send_ns_reset_ack(nsi, &sgsn_peer, SGSN_NSEI+1, SGSN_NSEI); + OSMO_ASSERT(sent_pdu_type == NS_PDUT_ALIVE); + send_ns_alive_ack(nsi, &sgsn_peer); + OSMO_ASSERT(sent_pdu_type == NS_PDUT_UNBLOCK); + send_ns_unblock_ack(nsi, &sgsn_peer); + */ + + send_ns_unitdata(nsi, &sgsn_peer, 0x1234, dummy_sdu, sizeof(dummy_sdu)); + + gprs_ns_destroy(nsi); + nsi = NULL; +} + static void test_sgsn_output() { struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL); @@ -875,6 +938,7 @@ int main(int argc, char **argv) test_bss_port_changes(); test_bss_reset_ack(); test_sgsn_reset(); + test_sgsn_reset_invalid_state(); test_sgsn_output(); printf("===== NS protocol test END\n\n"); diff --git a/tests/gb/gprs_ns_test.ok b/tests/gb/gprs_ns_test.ok index 0d4b7fb..66b1dbb 100644 --- a/tests/gb/gprs_ns_test.ok +++ b/tests/gb/gprs_ns_test.ok @@ -722,6 +722,105 @@ Current NS-VCIs: Current NS-VCIs: +=== test_sgsn_reset_invalid_state === +--- Setup SGSN connection, BSS -> SGSN --- + +MESSAGE to SGSN, msg length 12 +02 00 81 01 01 82 01 01 04 82 01 00 + +PROCESSING RESET_ACK from 0x05060708:32000 +03 01 82 01 01 04 82 01 00 + +MESSAGE to SGSN, msg length 1 +0a + +result (RESET_ACK) = 1 + +PROCESSING ALIVE_ACK from 0x05060708:32000 +0b + +MESSAGE to SGSN, msg length 1 +06 + +result (ALIVE_ACK) = 1 + +PROCESSING UNBLOCK_ACK from 0x05060708:32000 +07 + +==> got signal NS_UNBLOCK, NS-VC 0x0101/5.6.7.8:32000 +result (UNBLOCK_ACK) = 0 + +Current NS-VCIs: + VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000 + NS-VC Block count : 1 + +--- Time out local test procedure --- + +MESSAGE to SGSN, msg length 1 +0a + +MESSAGE to SGSN, msg length 1 +0a + +MESSAGE to SGSN, msg length 1 +0a + +MESSAGE to SGSN, msg length 1 +0a + +MESSAGE to SGSN, msg length 1 +0a + +MESSAGE to SGSN, msg length 1 +0a + +MESSAGE to SGSN, msg length 1 +0a + +MESSAGE to SGSN, msg length 1 +0a + +MESSAGE to SGSN, msg length 1 +0a + +MESSAGE to SGSN, msg length 1 +0a + +MESSAGE to SGSN, msg length 1 +0a + +==> got signal NS_ALIVE_EXP, NS-VC 0x0101/5.6.7.8:32000 +==> got signal NS_BLOCK, NS-VC 0x0101/5.6.7.8:32000 +--- Remote test procedure continues --- + +PROCESSING ALIVE from 0x05060708:32000 +0a + +MESSAGE to SGSN, msg length 12 +02 00 81 0a 01 82 01 01 04 82 01 00 + +result (ALIVE) = 12 + +--- Don't send a NS_RESET_ACK message (pretend it is lost) --- + +PROCESSING ALIVE from 0x05060708:32000 +0a + +MESSAGE to SGSN, msg length 1 +0b + +result (ALIVE) = 1 + +PROCESSING UNITDATA from 0x05060708:32000 +00 00 12 34 01 02 03 04 + +MESSAGE to SGSN, msg length 8 +08 00 81 03 01 82 01 01 + +result (UNITDATA) = 8 + +Current NS-VCIs: + --- Send message to SGSN --- SENDING BSSGP RESET to NSEI 0x0100, BVCI 0x0000 -- 1.9.1 From jerlbeck at sysmocom.de Wed Oct 8 10:05:17 2014 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 8 Oct 2014 12:05:17 +0200 Subject: [PATCH 5/6] gprs-ns: Let gprs_nsvc_reset return a value In-Reply-To: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> References: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1412762718-31961-5-git-send-email-jerlbeck@sysmocom.de> Currently gprs_nsvc_reset does not return any value. This patch changes the function to return an integer, where a value less than zero indicates an error. The value is taken from the gprs_ns_tx_reset function. In case of failure, an error message is logged. Sponsored-by: On-Waves ehf --- include/osmocom/gprs/gprs_ns.h | 2 +- src/gb/gprs_ns.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/osmocom/gprs/gprs_ns.h b/include/osmocom/gprs/gprs_ns.h index b4af61b..e77ca42 100644 --- a/include/osmocom/gprs/gprs_ns.h +++ b/include/osmocom/gprs/gprs_ns.h @@ -172,7 +172,7 @@ struct gprs_nsvc *gprs_nsvc_by_nsei(struct gprs_ns_inst *nsi, uint16_t nsei); struct gprs_nsvc *gprs_nsvc_by_nsvci(struct gprs_ns_inst *nsi, uint16_t nsvci); /* Initiate a RESET procedure (including timer start, ...)*/ -void gprs_nsvc_reset(struct gprs_nsvc *nsvc, uint8_t cause); +int gprs_nsvc_reset(struct gprs_nsvc *nsvc, uint8_t cause); /* Add NS-specific VTY stuff */ int gprs_ns_vty_init(struct gprs_ns_inst *nsi); diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index ee2d7ec..cf7adaf 100644 --- a/src/gb/gprs_ns.c +++ b/src/gb/gprs_ns.c @@ -1495,20 +1495,25 @@ int gprs_ns_nsip_listen(struct gprs_ns_inst *nsi) * will not only send a NS-RESET, but also set the state to BLOCKED and * start the Tns-reset timer. */ -void gprs_nsvc_reset(struct gprs_nsvc *nsvc, uint8_t cause) +int gprs_nsvc_reset(struct gprs_nsvc *nsvc, uint8_t cause) { + int rc; + LOGP(DNS, LOGL_INFO, "NSEI=%u RESET procedure based on API request\n", nsvc->nsei); /* Mark NS-VC locally as blocked and dead */ nsvc->state = NSE_S_BLOCKED; /* Send NS-RESET PDU */ - if (gprs_ns_tx_reset(nsvc, cause) < 0) { + rc = gprs_ns_tx_reset(nsvc, cause); + if (rc < 0) { LOGP(DNS, LOGL_ERROR, "NSEI=%u, error resetting NS-VC\n", nsvc->nsei); } /* Start Tns-reset */ nsvc_start_timer(nsvc, NSVC_TIMER_TNS_RESET); + + return rc; } /*! \brief Establish a NS connection (from the BSS) to the SGSN -- 1.9.1 From holger at freyther.de Thu Oct 9 05:49:39 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 9 Oct 2014 07:49:39 +0200 Subject: [PATCH 5/6] gprs-ns: Let gprs_nsvc_reset return a value In-Reply-To: <1412762718-31961-5-git-send-email-jerlbeck@sysmocom.de> References: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> <1412762718-31961-5-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20141009054939.GC12473@xiaoyu.lan> On Wed, Oct 08, 2014 at 12:05:17PM +0200, Jacob Erlbeck wrote: > Currently gprs_nsvc_reset does not return any value. > > This patch changes the function to return an integer, where a value > less than zero indicates an error. The value is taken from the > gprs_ns_tx_reset function. In case of failure, an error message is logged. ah. Now update the unit test to print "failed" again or preferable OSMO_ASSERT(rc < 0)? From jerlbeck at sysmocom.de Wed Oct 8 10:05:18 2014 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 8 Oct 2014 12:05:18 +0200 Subject: [PATCH 6/6] gprs-ns: Fix reset state handling In-Reply-To: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> References: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1412762718-31961-6-git-send-email-jerlbeck@sysmocom.de> Currently the NS-VC's state is updated from within gprs_ns_tx_reset, which can lead to an inconsistent state when the RESET_ACK is lost. In this state, the NSE_S_RESET bit is set but the Tns-reset timer is not started. This patch moves the state update into gprs_nsvc_reset. This way, the state flags are consistent with the timer. Addresses: SGSN -> BSS NS_ALIVE BSS -> SGSN NS_ALIVE_ACK BSS -> SGSN BVC_RESET SGSN -> BSS NS_STATUS, Cause: NS-VC blocked, NS VCI: 0x65 and there is no BSS->SGSN NS_ALIVE Ticket: OW#1213 Sponsored-by: On-Waves ehf --- src/gb/gprs_ns.c | 9 ++++----- tests/gb/gprs_ns_test.c | 2 -- tests/gb/gprs_ns_test.ok | 27 +++++++++++++++++++++++---- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index cf7adaf..65d0494 100644 --- a/src/gb/gprs_ns.c +++ b/src/gb/gprs_ns.c @@ -348,8 +348,6 @@ int gprs_ns_tx_reset(struct gprs_nsvc *nsvc, uint8_t cause) LOGP(DNS, LOGL_INFO, "NSEI=%u Tx NS RESET (NSVCI=%u, cause=%s)\n", nsvc->nsei, nsvc->nsvci, gprs_ns_cause_str(cause)); - nsvc->state |= NSE_S_RESET; - msg->l2h = msgb_put(msg, sizeof(*nsh)); nsh = (struct gprs_ns_hdr *) msg->l2h; nsh->pdu_type = NS_PDUT_RESET; @@ -1250,8 +1248,8 @@ int gprs_ns_process_msg(struct gprs_ns_inst *nsi, struct msgb *msg, * and should send a NS-RESET to make sure everything recovers * fine. */ if ((*nsvc)->state == NSE_S_BLOCKED) - rc = gprs_ns_tx_reset((*nsvc), NS_CAUSE_PDU_INCOMP_PSTATE); - else + rc = gprs_nsvc_reset((*nsvc), NS_CAUSE_PDU_INCOMP_PSTATE); + else if (!((*nsvc)->state & NSE_S_RESET)) rc = gprs_ns_tx_alive_ack(*nsvc); break; case NS_PDUT_ALIVE_ACK: @@ -1503,7 +1501,8 @@ int gprs_nsvc_reset(struct gprs_nsvc *nsvc, uint8_t cause) nsvc->nsei); /* Mark NS-VC locally as blocked and dead */ - nsvc->state = NSE_S_BLOCKED; + nsvc->state = NSE_S_BLOCKED | NSE_S_RESET; + /* Send NS-RESET PDU */ rc = gprs_ns_tx_reset(nsvc, cause); if (rc < 0) { diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c index ad8e6d5..2185ff8 100644 --- a/tests/gb/gprs_ns_test.c +++ b/tests/gb/gprs_ns_test.c @@ -839,14 +839,12 @@ static void test_sgsn_reset_invalid_state() sent_pdu_type = -1; send_ns_alive(nsi, &sgsn_peer); - /* Disabled, since it is not yet fixed OSMO_ASSERT(sent_pdu_type == -1); send_ns_reset_ack(nsi, &sgsn_peer, SGSN_NSEI+1, SGSN_NSEI); OSMO_ASSERT(sent_pdu_type == NS_PDUT_ALIVE); send_ns_alive_ack(nsi, &sgsn_peer); OSMO_ASSERT(sent_pdu_type == NS_PDUT_UNBLOCK); send_ns_unblock_ack(nsi, &sgsn_peer); - */ send_ns_unitdata(nsi, &sgsn_peer, 0x1234, dummy_sdu, sizeof(dummy_sdu)); diff --git a/tests/gb/gprs_ns_test.ok b/tests/gb/gprs_ns_test.ok index 66b1dbb..1e0bf7f 100644 --- a/tests/gb/gprs_ns_test.ok +++ b/tests/gb/gprs_ns_test.ok @@ -806,18 +806,37 @@ result (ALIVE) = 12 PROCESSING ALIVE from 0x05060708:32000 0a +result (ALIVE) = 0 + +PROCESSING RESET_ACK from 0x05060708:32000 +03 01 82 01 01 04 82 01 00 + MESSAGE to SGSN, msg length 1 +0a + +result (RESET_ACK) = 1 + +PROCESSING ALIVE_ACK from 0x05060708:32000 0b -result (ALIVE) = 1 +MESSAGE to SGSN, msg length 1 +06 + +result (ALIVE_ACK) = 1 + +PROCESSING UNBLOCK_ACK from 0x05060708:32000 +07 + +==> got signal NS_UNBLOCK, NS-VC 0x0101/5.6.7.8:32000 +result (UNBLOCK_ACK) = 0 PROCESSING UNITDATA from 0x05060708:32000 00 00 12 34 01 02 03 04 -MESSAGE to SGSN, msg length 8 -08 00 81 03 01 82 01 01 +CALLBACK, event 0, msg length 4, bvci 0x1234 +01 02 03 04 -result (UNITDATA) = 8 +result (UNITDATA) = 0 Current NS-VCIs: -- 1.9.1 From holger at freyther.de Thu Oct 9 05:52:17 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 9 Oct 2014 07:52:17 +0200 Subject: [PATCH 6/6] gprs-ns: Fix reset state handling In-Reply-To: <1412762718-31961-6-git-send-email-jerlbeck@sysmocom.de> References: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> <1412762718-31961-6-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20141009055217.GD12473@xiaoyu.lan> On Wed, Oct 08, 2014 at 12:05:18PM +0200, Jacob Erlbeck wrote: > Currently the NS-VC's state is updated from within gprs_ns_tx_reset, > which can lead to an inconsistent state when the RESET_ACK is lost. > In this state, the NSE_S_RESET bit is set but the Tns-reset timer is > not started. > sent_pdu_type = -1; > send_ns_alive(nsi, &sgsn_peer); > - /* Disabled, since it is not yet fixed > OSMO_ASSERT(sent_pdu_type == -1); > send_ns_reset_ack(nsi, &sgsn_peer, SGSN_NSEI+1, SGSN_NSEI); > OSMO_ASSERT(sent_pdu_type == NS_PDUT_ALIVE); > send_ns_alive_ack(nsi, &sgsn_peer); > OSMO_ASSERT(sent_pdu_type == NS_PDUT_UNBLOCK); > send_ns_unblock_ack(nsi, &sgsn_peer); > - */ > > send_ns_unitdata(nsi, &sgsn_peer, 0x1234, dummy_sdu, sizeof(dummy_sdu)); I think it would be nice if you could directly ASSERT the unblocked alive state of the NSI? It should be fairly to do? All patches look great and it is nice incremental work. I am going to merge them now. Please provide a follow-up patch that addresses the points you think are valid. holger From holger at freyther.de Thu Oct 9 05:43:12 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 9 Oct 2014 07:43:12 +0200 Subject: [PATCH 1/6] gprs-ns/test: Use gprs_nsvc_reset instead of gprs_ns_tx_reset In-Reply-To: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> References: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20141009054312.GA12473@xiaoyu.lan> On Wed, Oct 08, 2014 at 12:05:13PM +0200, Jacob Erlbeck wrote: > Currently gprs_ns_tx_reset is used to let the NS stack generate > NS_RESET message. This is not adjusting the nsvc state properly. > > This patch uses gprs_nsvc_reset instead which starts the full reset > procedure. Shall we patch gprs_nsvc_reset to return the error from the gprs_ns_tx_reset call? > - rc = gprs_ns_tx_reset(nsvc, NS_CAUSE_OM_INTERVENTION); > - if (rc < 0) > - printf("Failed to send RESET to %s\n\n", gprs_ns_ll_str(nsvc)); > - else { > - send_ns_reset_ack(nsi, nse[1], 0x2001, 0x2000); > - gprs_dump_nsi(nsi); > - } > + gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION); e.g. we entered the "failed" path here and don't capture the log output. of libosmogb. From jerlbeck at sysmocom.de Thu Oct 9 09:07:55 2014 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Thu, 9 Oct 2014 11:07:55 +0200 Subject: [PATCH 1/2] gprs-ns/test: Re-add return value check for gprs_nsvc_reset Message-ID: <1412845676-13076-1-git-send-email-jerlbeck@sysmocom.de> The return value check has been removed in the commit 'Use gprs_nsvc_reset instead of gprs_ns_tx_reset', because gprs_nsvc_reset had no return value then. Since a compatible return value has been added by 'Let gprs_nsvc_reset return a value', the former patch is partly reverted by this commit. Sponsored-by: On-Waves ehf --- tests/gb/gprs_ns_test.c | 9 ++++++++- tests/gb/gprs_ns_test.ok | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c index 2185ff8..eab71e7 100644 --- a/tests/gb/gprs_ns_test.c +++ b/tests/gb/gprs_ns_test.c @@ -592,6 +592,7 @@ static void test_bss_reset_ack() struct sockaddr_in peer[4] = {{0},}; struct gprs_nsvc *nsvc; struct sockaddr_in *nse[4]; + int rc; peer[0].sin_family = AF_INET; peer[0].sin_port = htons(1111); @@ -641,7 +642,13 @@ static void test_bss_reset_ack() printf("--- Setup VC 2 SGSN -> BSS (hits NSEI 2) ---\n\n"); nsvc = gprs_nsvc_by_nsvci(nsi, 0x2001); - gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION); + rc = gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION); + if (rc < 0) + printf("Failed to send RESET to %s\n\n", gprs_ns_ll_str(nsvc)); + else { + send_ns_reset_ack(nsi, nse[1], 0x2001, 0x2000); + gprs_dump_nsi(nsi); + } printf("--- Setup VC 1 SGSN -> BSS (hits NSEI 1) ---\n\n"); diff --git a/tests/gb/gprs_ns_test.ok b/tests/gb/gprs_ns_test.ok index 1e0bf7f..d6be1a9 100644 --- a/tests/gb/gprs_ns_test.ok +++ b/tests/gb/gprs_ns_test.ok @@ -375,6 +375,8 @@ Current NS-VCIs: --- Setup VC 2 SGSN -> BSS (hits NSEI 2) --- +Failed to send RESET to 0.0.0.0:0 + --- Setup VC 1 SGSN -> BSS (hits NSEI 1) --- MESSAGE to BSS, msg length 12 -- 1.9.1 From jerlbeck at sysmocom.de Thu Oct 9 09:07:56 2014 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Thu, 9 Oct 2014 11:07:56 +0200 Subject: [PATCH 2/2] gprs-ns/test: Check the nsvc state explicitely In-Reply-To: <1412845676-13076-1-git-send-email-jerlbeck@sysmocom.de> References: <1412845676-13076-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1412845676-13076-2-git-send-email-jerlbeck@sysmocom.de> This patch extends test_sgsn_reset_invalid_state by assertions to check that nscv->state and nsvc->remote_state have been set as expected. Sponsored-by: On-Waves ehf --- tests/gb/gprs_ns_test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c index eab71e7..9c3a3ac 100644 --- a/tests/gb/gprs_ns_test.c +++ b/tests/gb/gprs_ns_test.c @@ -847,11 +847,18 @@ static void test_sgsn_reset_invalid_state() sent_pdu_type = -1; send_ns_alive(nsi, &sgsn_peer); OSMO_ASSERT(sent_pdu_type == -1); + send_ns_reset_ack(nsi, &sgsn_peer, SGSN_NSEI+1, SGSN_NSEI); OSMO_ASSERT(sent_pdu_type == NS_PDUT_ALIVE); + send_ns_alive_ack(nsi, &sgsn_peer); + OSMO_ASSERT(nsvc->state == (NSE_S_ALIVE | NSE_S_BLOCKED)); + OSMO_ASSERT(nsvc->remote_state == (NSE_S_ALIVE | NSE_S_BLOCKED)); OSMO_ASSERT(sent_pdu_type == NS_PDUT_UNBLOCK); + send_ns_unblock_ack(nsi, &sgsn_peer); + OSMO_ASSERT(nsvc->state == NSE_S_ALIVE); + OSMO_ASSERT(nsvc->remote_state == NSE_S_ALIVE); send_ns_unitdata(nsi, &sgsn_peer, 0x1234, dummy_sdu, sizeof(dummy_sdu)); -- 1.9.1 From rabbitmq at yahoo.com Sat Oct 11 22:36:24 2014 From: rabbitmq at yahoo.com (Rabbit Maque) Date: Sat, 11 Oct 2014 23:36:24 +0100 Subject: nanoBTS 139U1800 for sale Message-ID: <1413066984.74142.YahooMailNeo@web172101.mail.ir2.yahoo.com> Hello, Sorry for the intrusion but I have two 139U 1800 for sale. Please email me if interested. Kind regards, Rabbit -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.suraev at fairwaves.co Mon Oct 13 18:36:02 2014 From: max.suraev at fairwaves.co (Max) Date: Mon, 13 Oct 2014 20:36:02 +0200 Subject: [PATCH 1/2] Ignore build byproducts Message-ID: <1413225363-29660-1-git-send-email-max.suraev@fairwaves.co> Signed-off-by: Max --- .gitignore | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0e0e704 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +.deps/ +.libs/ +*.lo +*.la +*.o +osmo-trx +CommonLibs/*Test +Transceiver52M/osmo-trx-options.c +Transceiver52M/osmo-trx-options.h +Transceiver52M/osmo-trx.ggo~ +aclocal.m4 +autom4te.cache/ +missing +ltmain.sh +install-sh +depcomp +configure +config/ +compile +libtool +stamp-h1 +config.guess +config.h.in +config.status +config.log +config.h +config.sub +Makefile +Makefile.in -- 1.9.1 From Max.Suraev at fairwaves.co Mon Oct 13 18:52:33 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Mon, 13 Oct 2014 20:52:33 +0200 Subject: [PATCH 1/2] Ignore build byproducts In-Reply-To: <1413225363-29660-1-git-send-email-max.suraev@fairwaves.co> References: <1413225363-29660-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <543C1F71.3020709@fairwaves.co> This patch is for OsmoTRX - I hope I've understood correctly message from http://openbsc.osmocom.org/trac/wiki/OsmoTRX about suitable ML. The 2nd part of the patch is monstrous 5Mb so it was rejected by mailman - this is due to removal of embedded sqlite (I don't believe the person who decided to include it was sober while making that decision :) I'll send it directly to maintainer to avoid spamming the list. 13.10.2014 20:36, Max ?????: > Signed-off-by: Max > --- > .gitignore | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > create mode 100644 .gitignore > > diff --git a/.gitignore b/.gitignore > new file mode 100644 > index 0000000..0e0e704 > --- /dev/null > +++ b/.gitignore > @@ -0,0 +1,29 @@ > +.deps/ > +.libs/ > +*.lo > +*.la > +*.o > +osmo-trx > +CommonLibs/*Test > +Transceiver52M/osmo-trx-options.c > +Transceiver52M/osmo-trx-options.h > +Transceiver52M/osmo-trx.ggo~ > +aclocal.m4 > +autom4te.cache/ > +missing > +ltmain.sh > +install-sh > +depcomp > +configure > +config/ > +compile > +libtool > +stamp-h1 > +config.guess > +config.h.in > +config.status > +config.log > +config.h > +config.sub > +Makefile > +Makefile.in > -- best regards, Max, http://fairwaves.co From peter at stuge.se Tue Oct 14 00:50:38 2014 From: peter at stuge.se (Peter Stuge) Date: Tue, 14 Oct 2014 02:50:38 +0200 Subject: [PATCH 1/2] Ignore build byproducts In-Reply-To: <1413225363-29660-1-git-send-email-max.suraev@fairwaves.co> References: <1413225363-29660-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <20141014005038.5399.qmail@stuge.se> Max wrote: > +++ b/.gitignore .. > +CommonLibs/*Test > +Transceiver52M/osmo-trx-options.c > +Transceiver52M/osmo-trx-options.h > +Transceiver52M/osmo-trx.ggo~ Why is that needed? //Peter From Max.Suraev at fairwaves.co Tue Oct 14 08:29:03 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 14 Oct 2014 10:29:03 +0200 Subject: [PATCH 1/2] Ignore build byproducts In-Reply-To: <20141014005038.5399.qmail@stuge.se> References: <1413225363-29660-1-git-send-email-max.suraev@fairwaves.co> <20141014005038.5399.qmail@stuge.se> Message-ID: <543CDECF.2030400@fairwaves.co> The *Test are the binaries generated during the build - not sure we need them at all but they certainly do not belong to git. The options are generated as part of 2nd patch which was too big for the ML due to sqlite removal. This patch introduces command-line options handling via gengetopt which makes using sqlite db for configuration optional. 14.10.2014 02:50, Peter Stuge ?????: > Max wrote: >> +++ b/.gitignore > .. >> +CommonLibs/*Test >> +Transceiver52M/osmo-trx-options.c >> +Transceiver52M/osmo-trx-options.h >> +Transceiver52M/osmo-trx.ggo~ > > Why is that needed? > > > //Peter > -- best regards, Max, http://fairwaves.co From tom at tsou.cc Tue Oct 14 19:10:32 2014 From: tom at tsou.cc (ttsou) Date: Tue, 14 Oct 2014 12:10:32 -0700 Subject: [PATCH 1/2] Ignore build byproducts In-Reply-To: <543C219E.6070503@fairwaves.co> References: <1413225363-29660-1-git-send-email-max.suraev@fairwaves.co> <543C219E.6070503@fairwaves.co> Message-ID: <20141014191032.GA29851@phenom.amer.corp.natinst.com> Hi Max, On Mon, Oct 13, 2014 at 09:01:50PM +0200, ? wrote: > Attached is a 2nd patch - it completely disables sqlite, all the configuration for > osmo-trx is supplied through command-line options. This makes troubleshooting easier > because now we have single source of truth: all the defaults are in one place. Thanks for looking into this. I agree that the sqlite configuration should be removed because it only causes confusion at this point. The original intention was to have backwards compatibility with OpenBTS-style sqlite options, but the number of users of that approach is approximately -1. Logging is the other concern. Have you tried removing the configuration table entirely? The existing queries are rarely, if ever, used. Without sqlite, the table shouldn't exist at all. Some general comments. Please remove code when you intend to remove it - committing commented out lines makes code and the patch difficult to read. Git will track the changes. Pull requests work well for large commits, such as sqlite3.c removal. > diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp > index 9215fa5..16ac7b9 100644 > --- a/Transceiver52M/osmo-trx.cpp > +++ b/Transceiver52M/osmo-trx.cpp > - > +volatile bool gshutdown = false; // FIXME: what the ... is that for? The shutdown variable is a relic from OpenBTS, and exists because of the mess involving threads and shutdown. That issue is unrelated to logging or sqlite. > - refstr = config->extref ? "Enabled" : "Disabled"; > - fillstr = config->filler ? "Enabled" : "Disabled"; > - divstr = config->diversity ? "Enabled" : "Disabled"; > - > std::ostringstream ost(""); > ost << "Config Settings" << std::endl; > ost << " Log Level............... " << config->log_level << std::endl; > @@ -176,9 +96,9 @@ bool trx_setup_config(struct trx_config *config) > ost << " TRX Address............. " << config->addr << std::endl; > ost << " Channels................ " << config->chans << std::endl; > ost << " Samples-per-Symbol...... " << config->sps << std::endl; > - ost << " External Reference...... " << refstr << std::endl; > - ost << " C0 Filler Table......... " << fillstr << std::endl; > - ost << " Diversity............... " << divstr << std::endl; > + ost << " External Reference...... " << (config->extref ? "Enabled" : "Disabled") << std::endl; > + ost << " C0 Filler Table......... " << (config->filler ? "Enabled" : "Disabled") << std::endl; > + ost << " Diversity............... " << (config->diversity ? "Enabled" : "Disabled") << std::endl; > ost << " Tuning offset........... " << config->offset << std::endl; > std::cout << ost << std::endl; Please put whitespace / formatting changes in a separate patch. Osmocom projects generally use kernel style, which becomes somewhat odd and less strict in the context of C++. In this case, the code change is fine, but don't add it to an already massive patch. -TT From Max.Suraev at fairwaves.co Wed Oct 15 08:06:33 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Wed, 15 Oct 2014 10:06:33 +0200 Subject: [PATCH 1/2] Ignore build byproducts In-Reply-To: <20141014191032.GA29851@phenom.amer.corp.natinst.com> References: <1413225363-29660-1-git-send-email-max.suraev@fairwaves.co> <543C219E.6070503@fairwaves.co> <20141014191032.GA29851@phenom.amer.corp.natinst.com> Message-ID: <543E2B09.9020906@fairwaves.co> Thanks for review. I'll cleanup patches and make a pull-request to your repo on github. 14.10.2014 21:10, ttsou ?????: > Hi Max, > > On Mon, Oct 13, 2014 at 09:01:50PM +0200, ? wrote: >> Attached is a 2nd patch - it completely disables sqlite, all the configuration for >> osmo-trx is supplied through command-line options. This makes troubleshooting easier >> because now we have single source of truth: all the defaults are in one place. > > Thanks for looking into this. I agree that the sqlite configuration should be > removed because it only causes confusion at this point. The original intention > was to have backwards compatibility with OpenBTS-style sqlite options, but the > number of users of that approach is approximately -1. > > Logging is the other concern. Have you tried removing the configuration > table entirely? The existing queries are rarely, if ever, used. Without > sqlite, the table shouldn't exist at all. > > Some general comments. Please remove code when you intend to remove it - > committing commented out lines makes code and the patch difficult to read. > Git will track the changes. Pull requests work well for large commits, > such as sqlite3.c removal. > >> diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp >> index 9215fa5..16ac7b9 100644 >> --- a/Transceiver52M/osmo-trx.cpp >> +++ b/Transceiver52M/osmo-trx.cpp >> - >> +volatile bool gshutdown = false; // FIXME: what the ... is that for? > > The shutdown variable is a relic from OpenBTS, and exists because of > the mess involving threads and shutdown. That issue is unrelated to logging or > sqlite. > >> - refstr = config->extref ? "Enabled" : "Disabled"; >> - fillstr = config->filler ? "Enabled" : "Disabled"; >> - divstr = config->diversity ? "Enabled" : "Disabled"; >> - >> std::ostringstream ost(""); >> ost << "Config Settings" << std::endl; >> ost << " Log Level............... " << config->log_level << std::endl; >> @@ -176,9 +96,9 @@ bool trx_setup_config(struct trx_config *config) >> ost << " TRX Address............. " << config->addr << std::endl; >> ost << " Channels................ " << config->chans << std::endl; >> ost << " Samples-per-Symbol...... " << config->sps << std::endl; >> - ost << " External Reference...... " << refstr << std::endl; >> - ost << " C0 Filler Table......... " << fillstr << std::endl; >> - ost << " Diversity............... " << divstr << std::endl; >> + ost << " External Reference...... " << (config->extref ? "Enabled" : "Disabled") << std::endl; >> + ost << " C0 Filler Table......... " << (config->filler ? "Enabled" : "Disabled") << std::endl; >> + ost << " Diversity............... " << (config->diversity ? "Enabled" : "Disabled") << std::endl; >> ost << " Tuning offset........... " << config->offset << std::endl; >> std::cout << ost << std::endl; > > Please put whitespace / formatting changes in a separate patch. Osmocom > projects generally use kernel style, which becomes somewhat odd and less > strict in the context of C++. In this case, the code change is fine, but don't > add it to an already massive patch. > > -TT > -- best regards, Max, http://fairwaves.co From max.suraev at fairwaves.co Tue Oct 14 11:54:47 2014 From: max.suraev at fairwaves.co (Max Suraev) Date: Tue, 14 Oct 2014 13:54:47 +0200 Subject: [PATCH] Use normal talloc instead of libosmocore copy Message-ID: <1413287687-24807-1-git-send-email-max.suraev@fairwaves.co> Signed-off-by: Max Suraev --- configure.ac | 1 + src/Makefile.am | 2 ++ src/bitvector.cpp | 2 +- src/bts.cpp | 2 +- src/gprs_bssgp_pcu.h | 2 +- src/gprs_debug.cpp | 2 +- src/openbts_sock.cpp | 2 +- src/pcu_l1_if.cpp | 2 +- src/sba.cpp | 2 +- src/sysmo_l1_fwd.c | 2 +- src/sysmo_l1_hw.c | 2 +- src/sysmo_l1_if.c | 2 +- src/sysmo_sock.cpp | 2 +- src/ta.cpp | 2 +- src/tbf.cpp | 2 +- src/tbf_dl.cpp | 2 +- src/tbf_ul.cpp | 2 +- tests/Makefile.am | 13 +++++++++---- tests/alloc/AllocTest.cpp | 2 +- tests/emu/pcu_emu.cpp | 2 +- tests/rlcmac/RLCMACTest.cpp | 1 + tests/tbf/TbfTest.cpp | 2 +- tests/types/TypesTest.cpp | 2 +- 23 files changed, 32 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index 3b2f380..c72cb4b 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,7 @@ PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.3.9) PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty) PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.3.3) PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 0.5.1.4) +PKG_CHECK_MODULES(LIBTALLOC, talloc >= 2.0.1) AC_MSG_CHECKING([whether to enable sysmocom-bts hardware support]) AC_ARG_ENABLE(sysmocom-bts, diff --git a/src/Makefile.am b/src/Makefile.am index d1ed701..8c625ed 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -112,6 +112,7 @@ osmo_pcu_LDADD = \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ + $(LIBTALLOC_LIBS) \ $(COMMON_LA) if ENABLE_SYSMODSP @@ -120,6 +121,7 @@ osmo_pcu_remote_LDADD = \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ + $(LIBTALLOC_LIBS) \ $(COMMON_LA) endif diff --git a/src/bitvector.cpp b/src/bitvector.cpp index 43feebc..bc1bcb0 100644 --- a/src/bitvector.cpp +++ b/src/bitvector.cpp @@ -27,7 +27,7 @@ #include extern "C" { -#include +#include } void *bv_tall_ctx; diff --git a/src/bts.cpp b/src/bts.cpp index b660014..d18361e 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -30,7 +30,7 @@ #include extern "C" { - #include + #include #include } diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h index 32b6728..a05ef75 100644 --- a/src/gprs_bssgp_pcu.h +++ b/src/gprs_bssgp_pcu.h @@ -23,7 +23,7 @@ extern "C" { -#include +#include #include #include #include diff --git a/src/gprs_debug.cpp b/src/gprs_debug.cpp index 6f9e310..aa8864e 100644 --- a/src/gprs_debug.cpp +++ b/src/gprs_debug.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/openbts_sock.cpp b/src/openbts_sock.cpp index 2d9cae4..50880f3 100644 --- a/src/openbts_sock.cpp +++ b/src/openbts_sock.cpp @@ -27,7 +27,7 @@ #include #include extern "C" { -#include +#include #include #include #include diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp index 0cb79eb..2a81584 100644 --- a/src/pcu_l1_if.cpp +++ b/src/pcu_l1_if.cpp @@ -27,7 +27,7 @@ #include #include extern "C" { -#include +#include #include #include } diff --git a/src/sba.cpp b/src/sba.cpp index 6eec235..a0e1506 100644 --- a/src/sba.cpp +++ b/src/sba.cpp @@ -25,7 +25,7 @@ #include extern "C" { -#include +#include } #include diff --git a/src/sysmo_l1_fwd.c b/src/sysmo_l1_fwd.c index 535a7f0..0336889 100644 --- a/src/sysmo_l1_fwd.c +++ b/src/sysmo_l1_fwd.c @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/sysmo_l1_hw.c b/src/sysmo_l1_hw.c index 8351d68..9190a51 100644 --- a/src/sysmo_l1_hw.c +++ b/src/sysmo_l1_hw.c @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/sysmo_l1_if.c b/src/sysmo_l1_if.c index 4274e77..fa3a983 100644 --- a/src/sysmo_l1_if.c +++ b/src/sysmo_l1_if.c @@ -1,6 +1,7 @@ #include #include +#include #include #include @@ -8,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/src/sysmo_sock.cpp b/src/sysmo_sock.cpp index 951653e..9b97190 100644 --- a/src/sysmo_sock.cpp +++ b/src/sysmo_sock.cpp @@ -26,7 +26,7 @@ #include #include extern "C" { -#include +#include #include #include } diff --git a/src/ta.cpp b/src/ta.cpp index 0bc1d66..428f084 100644 --- a/src/ta.cpp +++ b/src/ta.cpp @@ -23,7 +23,7 @@ #include extern "C" { - #include + #include } #include diff --git a/src/tbf.cpp b/src/tbf.cpp index 2afe257..a688421 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -30,7 +30,7 @@ extern "C" { #include -#include +#include } #include diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index 8de3b2b..369a5cb 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -29,7 +29,7 @@ extern "C" { #include -#include +#include } #include diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp index 3ab71f0..a5a0d2f 100644 --- a/src/tbf_ul.cpp +++ b/src/tbf_ul.cpp @@ -30,7 +30,7 @@ extern "C" { #include -#include +#include } #include diff --git a/tests/Makefile.am b/tests/Makefile.am index e84f17d..84039a2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,6 +7,7 @@ rlcmac_RLCMACTest_SOURCES = rlcmac/RLCMACTest.cpp rlcmac_RLCMACTest_LDADD = \ $(top_builddir)/src/libgprs.la \ $(LIBOSMOCORE_LIBS) \ + $(LIBTALLOC_LIBS) \ $(COMMON_LA) alloc_AllocTest_SOURCES = alloc/AllocTest.cpp @@ -15,15 +16,17 @@ alloc_AllocTest_LDADD = \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOCORE_LIBS) \ + $(LIBTALLOC_LIBS) \ $(COMMON_LA) tbf_TbfTest_SOURCES = tbf/TbfTest.cpp tbf_TbfTest_LDADD = \ + $(top_builddir)/src/libgprs.la \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOCORE_LIBS) \ - $(COMMON_LA) \ - $(top_builddir)/src/libgprs.la + $(LIBTALLOC_LIBS) \ + $(COMMON_LA) emu_pcu_emu_SOURCES = emu/pcu_emu.cpp emu/test_replay_gprs_attach.cpp \ emu/openbsc_clone.c emu/openbsc_clone.h emu/gprs_tests.h \ @@ -33,15 +36,17 @@ emu_pcu_emu_LDADD = \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOCORE_LIBS) \ + $(LIBTALLOC_LIBS) \ $(COMMON_LA) types_TypesTest_SOURCES = types/TypesTest.cpp types_TypesTest_LDADD = \ + $(top_builddir)/src/libgprs.la \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOCORE_LIBS) \ - $(COMMON_LA) \ - $(top_builddir)/src/libgprs.la + $(LIBTALLOC_LIBS) \ + $(COMMON_LA) # The `:;' works around a Bash 3.2 bug when the output is not writeable. diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp index d711ad8..012bb47 100644 --- a/tests/alloc/AllocTest.cpp +++ b/tests/alloc/AllocTest.cpp @@ -28,8 +28,8 @@ extern "C" { #include #include -#include #include +#include } /* globals used by the code */ diff --git a/tests/emu/pcu_emu.cpp b/tests/emu/pcu_emu.cpp index ed0abbe..0a9ecbd 100644 --- a/tests/emu/pcu_emu.cpp +++ b/tests/emu/pcu_emu.cpp @@ -20,7 +20,7 @@ */ extern "C" { -#include +#include #include } diff --git a/tests/rlcmac/RLCMACTest.cpp b/tests/rlcmac/RLCMACTest.cpp index 66bc53c..987d3e9 100644 --- a/tests/rlcmac/RLCMACTest.cpp +++ b/tests/rlcmac/RLCMACTest.cpp @@ -28,6 +28,7 @@ extern "C" { extern const struct log_info gprs_log_info; #include "pcu_vty.h" +#include #include #include #include diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index 0811520..c62a74c 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -27,8 +27,8 @@ extern "C" { #include #include -#include #include +#include } void *tall_pcu_ctx; diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp index 8a464b1..9ceae77 100644 --- a/tests/types/TypesTest.cpp +++ b/tests/types/TypesTest.cpp @@ -28,8 +28,8 @@ extern "C" { #include #include -#include #include +#include } #define OSMO_ASSERT_STR_EQ(a, b) \ -- 1.9.1 From jengelh at inai.de Tue Oct 14 12:15:29 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Tue, 14 Oct 2014 14:15:29 +0200 (CEST) Subject: [PATCH] Use normal talloc instead of libosmocore copy In-Reply-To: <1413287687-24807-1-git-send-email-max.suraev@fairwaves.co> References: <1413287687-24807-1-git-send-email-max.suraev@fairwaves.co> Message-ID: On Tuesday 2014-10-14 13:54, Max Suraev wrote: >+++ b/src/bitvector.cpp >@@ -27,7 +27,7 @@ > > #include > extern "C" { >-#include >+#include > } Mh, it would be better to avoid having #includes inside extern "C", because you never really know what exactly header files contain. Instead, each .h file wraps the C functions it has in a #ifdef __cplusplus / extern "C" {} / #endif block of its own, just like talloc.h does. From max.suraev at fairwaves.co Tue Oct 14 13:29:28 2014 From: max.suraev at fairwaves.co (Max Suraev) Date: Tue, 14 Oct 2014 15:29:28 +0200 Subject: [PATCH] Use normal talloc instead of libosmocore copy Message-ID: <1413293368-32353-1-git-send-email-max.suraev@fairwaves.co> Signed-off-by: Max Suraev --- configure.ac | 1 + src/Makefile.am | 2 ++ src/bitvector.cpp | 4 +--- src/bts.cpp | 2 +- src/gprs_bssgp_pcu.h | 2 +- src/gprs_debug.cpp | 2 +- src/openbts_sock.cpp | 2 +- src/pcu_l1_if.cpp | 3 ++- src/sba.cpp | 5 +---- src/sysmo_l1_fwd.c | 2 +- src/sysmo_l1_hw.c | 2 +- src/sysmo_l1_if.c | 2 +- src/sysmo_sock.cpp | 3 ++- src/ta.cpp | 5 +---- src/tbf.cpp | 2 +- src/tbf_dl.cpp | 2 +- src/tbf_ul.cpp | 2 +- tests/Makefile.am | 13 +++++++++---- tests/alloc/AllocTest.cpp | 2 +- tests/emu/pcu_emu.cpp | 2 +- tests/rlcmac/RLCMACTest.cpp | 2 ++ tests/tbf/TbfTest.cpp | 2 +- tests/types/TypesTest.cpp | 3 ++- 23 files changed, 36 insertions(+), 31 deletions(-) diff --git a/configure.ac b/configure.ac index 3b2f380..c72cb4b 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,7 @@ PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.3.9) PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty) PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.3.3) PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 0.5.1.4) +PKG_CHECK_MODULES(LIBTALLOC, talloc >= 2.0.1) AC_MSG_CHECKING([whether to enable sysmocom-bts hardware support]) AC_ARG_ENABLE(sysmocom-bts, diff --git a/src/Makefile.am b/src/Makefile.am index d1ed701..8c625ed 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -112,6 +112,7 @@ osmo_pcu_LDADD = \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ + $(LIBTALLOC_LIBS) \ $(COMMON_LA) if ENABLE_SYSMODSP @@ -120,6 +121,7 @@ osmo_pcu_remote_LDADD = \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ + $(LIBTALLOC_LIBS) \ $(COMMON_LA) endif diff --git a/src/bitvector.cpp b/src/bitvector.cpp index 43feebc..05a0781 100644 --- a/src/bitvector.cpp +++ b/src/bitvector.cpp @@ -26,9 +26,7 @@ */ #include -extern "C" { -#include -} +#include void *bv_tall_ctx; diff --git a/src/bts.cpp b/src/bts.cpp index b660014..ac41384 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -30,11 +30,11 @@ #include extern "C" { - #include #include } #include +#include #include #include diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h index 32b6728..cbe6ef8 100644 --- a/src/gprs_bssgp_pcu.h +++ b/src/gprs_bssgp_pcu.h @@ -23,7 +23,6 @@ extern "C" { -#include #include #include #include @@ -36,6 +35,7 @@ extern "C" { struct bssgp_bvc_ctx *btsctx_alloc(uint16_t bvci, uint16_t nsei); } #include +#include #define QOS_PROFILE 4 #define BSSGP_HDR_LEN 53 diff --git a/src/gprs_debug.cpp b/src/gprs_debug.cpp index 6f9e310..aa8864e 100644 --- a/src/gprs_debug.cpp +++ b/src/gprs_debug.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/openbts_sock.cpp b/src/openbts_sock.cpp index 2d9cae4..a19097b 100644 --- a/src/openbts_sock.cpp +++ b/src/openbts_sock.cpp @@ -26,8 +26,8 @@ #include #include #include +#include extern "C" { -#include #include #include #include diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp index 0cb79eb..de6549b 100644 --- a/src/pcu_l1_if.cpp +++ b/src/pcu_l1_if.cpp @@ -26,8 +26,9 @@ #include #include #include +#include + extern "C" { -#include #include #include } diff --git a/src/sba.cpp b/src/sba.cpp index 6eec235..b09b5cb 100644 --- a/src/sba.cpp +++ b/src/sba.cpp @@ -24,10 +24,7 @@ #include #include -extern "C" { -#include -} - +#include #include extern void *tall_pcu_ctx; diff --git a/src/sysmo_l1_fwd.c b/src/sysmo_l1_fwd.c index 535a7f0..0336889 100644 --- a/src/sysmo_l1_fwd.c +++ b/src/sysmo_l1_fwd.c @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/sysmo_l1_hw.c b/src/sysmo_l1_hw.c index 8351d68..9190a51 100644 --- a/src/sysmo_l1_hw.c +++ b/src/sysmo_l1_hw.c @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/sysmo_l1_if.c b/src/sysmo_l1_if.c index 4274e77..fa3a983 100644 --- a/src/sysmo_l1_if.c +++ b/src/sysmo_l1_if.c @@ -1,6 +1,7 @@ #include #include +#include #include #include @@ -8,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/src/sysmo_sock.cpp b/src/sysmo_sock.cpp index 951653e..10eb2d7 100644 --- a/src/sysmo_sock.cpp +++ b/src/sysmo_sock.cpp @@ -25,8 +25,9 @@ #include #include #include +#include + extern "C" { -#include #include #include } diff --git a/src/ta.cpp b/src/ta.cpp index 0bc1d66..5b0bcd8 100644 --- a/src/ta.cpp +++ b/src/ta.cpp @@ -22,10 +22,7 @@ #include #include -extern "C" { - #include -} - +#include #include extern void *tall_pcu_ctx; diff --git a/src/tbf.cpp b/src/tbf.cpp index 2afe257..4d95f15 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -30,9 +30,9 @@ extern "C" { #include -#include } +#include #include #include diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index 8de3b2b..8113e49 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -29,9 +29,9 @@ extern "C" { #include -#include } +#include #include #include diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp index 3ab71f0..35581ac 100644 --- a/src/tbf_ul.cpp +++ b/src/tbf_ul.cpp @@ -30,9 +30,9 @@ extern "C" { #include -#include } +#include #include #include diff --git a/tests/Makefile.am b/tests/Makefile.am index e84f17d..84039a2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,6 +7,7 @@ rlcmac_RLCMACTest_SOURCES = rlcmac/RLCMACTest.cpp rlcmac_RLCMACTest_LDADD = \ $(top_builddir)/src/libgprs.la \ $(LIBOSMOCORE_LIBS) \ + $(LIBTALLOC_LIBS) \ $(COMMON_LA) alloc_AllocTest_SOURCES = alloc/AllocTest.cpp @@ -15,15 +16,17 @@ alloc_AllocTest_LDADD = \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOCORE_LIBS) \ + $(LIBTALLOC_LIBS) \ $(COMMON_LA) tbf_TbfTest_SOURCES = tbf/TbfTest.cpp tbf_TbfTest_LDADD = \ + $(top_builddir)/src/libgprs.la \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOCORE_LIBS) \ - $(COMMON_LA) \ - $(top_builddir)/src/libgprs.la + $(LIBTALLOC_LIBS) \ + $(COMMON_LA) emu_pcu_emu_SOURCES = emu/pcu_emu.cpp emu/test_replay_gprs_attach.cpp \ emu/openbsc_clone.c emu/openbsc_clone.h emu/gprs_tests.h \ @@ -33,15 +36,17 @@ emu_pcu_emu_LDADD = \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOCORE_LIBS) \ + $(LIBTALLOC_LIBS) \ $(COMMON_LA) types_TypesTest_SOURCES = types/TypesTest.cpp types_TypesTest_LDADD = \ + $(top_builddir)/src/libgprs.la \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOCORE_LIBS) \ - $(COMMON_LA) \ - $(top_builddir)/src/libgprs.la + $(LIBTALLOC_LIBS) \ + $(COMMON_LA) # The `:;' works around a Bash 3.2 bug when the output is not writeable. diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp index d711ad8..be57f18 100644 --- a/tests/alloc/AllocTest.cpp +++ b/tests/alloc/AllocTest.cpp @@ -24,11 +24,11 @@ #include #include +#include extern "C" { #include #include -#include #include } diff --git a/tests/emu/pcu_emu.cpp b/tests/emu/pcu_emu.cpp index ed0abbe..45e49ee 100644 --- a/tests/emu/pcu_emu.cpp +++ b/tests/emu/pcu_emu.cpp @@ -20,7 +20,6 @@ */ extern "C" { -#include #include } @@ -31,6 +30,7 @@ extern "C" { #include #include +#include #include #include #include diff --git a/tests/rlcmac/RLCMACTest.cpp b/tests/rlcmac/RLCMACTest.cpp index 66bc53c..30a38a7 100644 --- a/tests/rlcmac/RLCMACTest.cpp +++ b/tests/rlcmac/RLCMACTest.cpp @@ -23,6 +23,8 @@ #include #include #include +#include + #include "csn1.h" #include "gsm_rlcmac.h" extern "C" { diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index 0811520..662be73 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#include #include "bts.h" #include "tbf.h" @@ -27,7 +28,6 @@ extern "C" { #include #include -#include #include } diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp index 8a464b1..eb6824a 100644 --- a/tests/types/TypesTest.cpp +++ b/tests/types/TypesTest.cpp @@ -19,6 +19,8 @@ * along with this program. If not, see . * */ +#include + #include "bts.h" #include "tbf.h" #include "gprs_debug.h" @@ -28,7 +30,6 @@ extern "C" { #include #include -#include #include } -- 1.9.1 From Max.Suraev at fairwaves.co Tue Oct 14 13:33:50 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 14 Oct 2014 15:33:50 +0200 Subject: [PATCH] Use normal talloc instead of libosmocore copy In-Reply-To: <1413293368-32353-1-git-send-email-max.suraev@fairwaves.co> References: <1413293368-32353-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <543D263E.5010804@fairwaves.co> This is a v2 of the osmo-pcu patch - this time talloc.h is outside of extern C declarations. I've tested compilation with it and it works fine: I mean the 3 out of 4 tests fails exactly the same way as it fails for me with master branch :) -- best regards, Max, http://fairwaves.co From jerlbeck at sysmocom.de Thu Oct 16 07:11:35 2014 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Thu, 16 Oct 2014 09:11:35 +0200 Subject: [PATCH 1/2] gprs/test: Add BSSGP tests Message-ID: <1413443496-6247-1-git-send-email-jerlbeck@sysmocom.de> This patch adds a test suite for the BSSGP protocol. The first (and only) test checks the handling of BSSGP SUSPEND/RESUME. Sponsored-by: On-Waves ehf --- tests/Makefile.am | 8 ++- tests/gb/gprs_bssgp_test.c | 151 ++++++++++++++++++++++++++++++++++++++++++++ tests/gb/gprs_bssgp_test.ok | 5 ++ tests/testsuite.at | 6 ++ 4 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 tests/gb/gprs_bssgp_test.c create mode 100644 tests/gb/gprs_bssgp_test.ok diff --git a/tests/Makefile.am b/tests/Makefile.am index 3f7db1f..b7ae607 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -5,8 +5,8 @@ check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test \ smscb/smscb_test bits/bitrev_test a5/a5_test \ conv/conv_test auth/milenage_test lapd/lapd_test \ gsm0808/gsm0808_test gsm0408/gsm0408_test \ - gb/bssgp_fc_test gb/gprs_ns_test kasumi/kasumi_test \ - logging/logging_test fr/fr_test \ + gb/bssgp_fc_test gb/gprs_bssgp_test gb/gprs_ns_test \ + kasumi/kasumi_test logging/logging_test fr/fr_test \ loggingrb/loggingrb_test strrb/strrb_test \ vty/vty_test comp128/comp128_test utils/utils_test @@ -62,6 +62,9 @@ ussd_ussd_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gs gb_bssgp_fc_test_SOURCES = gb/bssgp_fc_test.c gb_bssgp_fc_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la +gb_gprs_bssgp_test_SOURCES = gb/gprs_bssgp_test.c +gb_gprs_bssgp_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DL) + gb_gprs_ns_test_SOURCES = gb/gprs_ns_test.c gb_gprs_ns_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DL) @@ -106,6 +109,7 @@ EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) \ lapd/lapd_test.ok gsm0408/gsm0408_test.ok \ gsm0808/gsm0808_test.ok gb/bssgp_fc_tests.err \ gb/bssgp_fc_tests.ok gb/bssgp_fc_tests.sh \ + gb/gprs_bssgp_test.ok \ gb/gprs_ns_test.ok kasumi/kasumi_test.ok \ msgfile/msgfile_test.ok msgfile/msgconfig.cfg \ logging/logging_test.ok logging/logging_test.err \ diff --git a/tests/gb/gprs_bssgp_test.c b/tests/gb/gprs_bssgp_test.c new file mode 100644 index 0000000..a2a4068 --- /dev/null +++ b/tests/gb/gprs_bssgp_test.c @@ -0,0 +1,151 @@ +/* Test routines for the BSSGP implementation in libosmogb + * + * (C) 2014 by sysmocom s.f.m.c. GmbH + * Author: Jacob Erlbeck + * + * Skeleton based on bssgp_fc_test.c + * (C) 2012 by Harald Welte + */ + +#undef _GNU_SOURCE +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#define BSS_NSEI 0x0b55 + +static struct osmo_prim_hdr last_oph = {0}; + +/* override */ +ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, + const struct sockaddr *dest_addr, socklen_t addrlen) +{ + typedef ssize_t (*sendto_t)(int, const void *, size_t, int, + const struct sockaddr *, socklen_t); + static sendto_t real_sendto = NULL; + uint32_t dest_host = htonl(((struct sockaddr_in *)dest_addr)->sin_addr.s_addr); + + if (!real_sendto) + real_sendto = dlsym(RTLD_NEXT, "sendto"); + + fprintf(stderr, "MESSAGE to 0x%08x, msg length %d\n%s\n", + dest_host, len, osmo_hexdump(buf, len)); + + return len; +} + +/* override */ +int gprs_ns_callback(enum gprs_ns_evt event, struct gprs_nsvc *nsvc, + struct msgb *msg, uint16_t bvci) +{ + fprintf(stderr, "CALLBACK, event %d, msg length %d, bvci 0x%04x\n%s\n\n", + event, msgb_bssgp_len(msg), bvci, + osmo_hexdump(msgb_bssgph(msg), msgb_bssgp_len(msg))); + return 0; +} + +int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx) +{ + printf("BSSGP primitive, SAP %d, prim = %d, op = %d, msg = %s\n", + oph->sap, oph->primitive, oph->operation, msgb_hexdump(oph->msg)); + + last_oph.sap = oph->sap; + last_oph.primitive = oph->primitive; + last_oph.operation = oph->operation; + last_oph.msg = NULL; + return -1; +} + +static void msgb_bssgp_send_and_free(struct msgb *msg) +{ + msgb_nsei(msg) = BSS_NSEI; + + bssgp_rcvmsg(msg); + + msgb_free(msg); +} + +static void send_bssgp_supend(enum bssgp_pdu_type pdu_type, uint32_t tlli) +{ + struct msgb *msg = bssgp_msgb_alloc(); + uint32_t tlli_be = htonl(tlli); + uint8_t rai[] = {0x0f, 0xf1, 0x80, 0x20, 0x37, 0x00}; + + msgb_v_put(msg, pdu_type); + msgb_tvlv_put(msg, BSSGP_IE_TLLI, sizeof(tlli_be), (uint8_t *)&tlli_be); + msgb_tvlv_put(msg, BSSGP_IE_ROUTEING_AREA, sizeof(rai), &rai[0]); + + msgb_bssgp_send_and_free(msg); +} + +static void send_bssgp_resume(enum bssgp_pdu_type pdu_type, uint32_t tlli) +{ + struct msgb *msg = bssgp_msgb_alloc(); + uint32_t tlli_be = htonl(tlli); + uint8_t rai[] = {0x0f, 0xf1, 0x80, 0x20, 0x37, 0x00}; + uint8_t suspend_ref = 1; + + msgb_v_put(msg, pdu_type); + msgb_tvlv_put(msg, BSSGP_IE_TLLI, sizeof(tlli_be), (uint8_t *)&tlli_be); + msgb_tvlv_put(msg, BSSGP_IE_ROUTEING_AREA, sizeof(rai), &rai[0]); + msgb_tvlv_put(msg, BSSGP_IE_SUSPEND_REF_NR, 1, &suspend_ref); + + msgb_bssgp_send_and_free(msg); +} + +static void test_bssgp_suspend_resume(void) +{ + const uint32_t tlli = 0xf0123456; + + printf("----- %s START\n", __func__); + memset(&last_oph, 0, sizeof(last_oph)); + + send_bssgp_supend(BSSGP_PDUT_SUSPEND, tlli); + /* OSMO_ASSERT(last_oph.primitive == PRIM_BSSGP_GMM_SUSPEND); */ + + send_bssgp_resume(BSSGP_PDUT_RESUME, tlli); + /* OSMO_ASSERT(last_oph.primitive == PRIM_BSSGP_GMM_RESUME); */ + + printf("----- %s END\n", __func__); +} + +static struct log_info info = {}; + +int main(int argc, char **argv) +{ + struct sockaddr_in bss_peer= {0}; + + osmo_init_logging(&info); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_filename(osmo_stderr_target, 0); + + bssgp_nsi = gprs_ns_instantiate(gprs_ns_callback, NULL); + + bss_peer.sin_family = AF_INET; + bss_peer.sin_port = htons(32000); + bss_peer.sin_addr.s_addr = htonl(0x7f0000ff); + + gprs_ns_nsip_connect(bssgp_nsi, &bss_peer, BSS_NSEI, BSS_NSEI+1); + + + printf("===== BSSGP test START\n"); + test_bssgp_suspend_resume(); + printf("===== BSSGP test END\n\n"); + + exit(EXIT_SUCCESS); +} diff --git a/tests/gb/gprs_bssgp_test.ok b/tests/gb/gprs_bssgp_test.ok new file mode 100644 index 0000000..9c7b4c0 --- /dev/null +++ b/tests/gb/gprs_bssgp_test.ok @@ -0,0 +1,5 @@ +===== BSSGP test START +----- test_bssgp_suspend_resume START +----- test_bssgp_suspend_resume END +===== BSSGP test END + diff --git a/tests/testsuite.at b/tests/testsuite.at index 7ce2ee8..fe30363 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -118,6 +118,12 @@ cat $abs_srcdir/vty/vty_test.ok > expout AT_CHECK([$abs_top_builddir/tests/vty/vty_test], [0], [expout], [ignore]) AT_CLEANUP +AT_SETUP([gprs-bssgp]) +AT_KEYWORDS([gprs-bssgp]) +cat $abs_srcdir/gb/gprs_bssgp_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/gb/gprs_bssgp_test], [0], [expout], [ignore]) +AT_CLEANUP + AT_SETUP([gprs-ns]) AT_KEYWORDS([gprs-ns]) cat $abs_srcdir/gb/gprs_ns_test.ok > expout -- 1.9.1 From jerlbeck at sysmocom.de Thu Oct 16 07:11:36 2014 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Thu, 16 Oct 2014 09:11:36 +0200 Subject: [PATCH 2/2] gprs: Don't discard SUSPEND/RESUME in bssgp_rcvmsg In-Reply-To: <1413443496-6247-1-git-send-email-jerlbeck@sysmocom.de> References: <1413443496-6247-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1413443496-6247-2-git-send-email-jerlbeck@sysmocom.de> Currently sending SUSPEND/RESUME messages to this function (like it is done in the osmo-sgsn) results in STATUS messages complaining about an unknown BVCI. The reason is, that these messages rely on a TLLI/RAI pair to identify the context and do not contain an explicit BVCI. This patch modifies bssgp_rcvmsg() to only complain about and unknown BVCI if one is given but a matching context is not found (except for RESET messages). The ctx argument is removed from the functions handling SUSPEND and RESUME since it will always be NULL then. Sponsored-by: On-Waves ehf --- src/gb/gprs_bssgp.c | 44 ++++++++++++++++++++++++++------------------ tests/gb/gprs_bssgp_test.c | 4 ++-- tests/gb/gprs_bssgp_test.ok | 2 ++ 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index 7a5d628..506efdf 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -398,32 +398,32 @@ static int bssgp_rx_ul_ud(struct msgb *msg, struct tlv_parsed *tp, return bssgp_prim_cb(&gbp.oph, NULL); } -static int bssgp_rx_suspend(struct msgb *msg, struct tlv_parsed *tp, - struct bssgp_bvc_ctx *ctx) +static int bssgp_rx_suspend(struct msgb *msg, struct tlv_parsed *tp) { struct osmo_bssgp_prim gbp; struct gprs_ra_id raid; uint32_t tlli; + uint16_t ns_bvci = msgb_bvci(msg); int rc; if (!TLVP_PRESENT(tp, BSSGP_IE_TLLI) || !TLVP_PRESENT(tp, BSSGP_IE_ROUTEING_AREA)) { LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx SUSPEND " - "missing mandatory IE\n", ctx->bvci); + "missing mandatory IE\n", ns_bvci); return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg); } tlli = ntohl(*(uint32_t *)TLVP_VAL(tp, BSSGP_IE_TLLI)); DEBUGP(DBSSGP, "BSSGP BVCI=%u TLLI=0x%08x Rx SUSPEND\n", - ctx->bvci, tlli); + ns_bvci, tlli); gsm48_parse_ra(&raid, TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA)); /* Inform GMM about the SUSPEND request */ memset(&gbp, 0, sizeof(gbp)); gbp.nsei = msgb_nsei(msg); - gbp.bvci = ctx->bvci; + gbp.bvci = ns_bvci; gbp.tlli = tlli; gbp.ra_id = &raid; osmo_prim_init(&gbp.oph, SAP_BSSGP_GMM, PRIM_BSSGP_GMM_SUSPEND, @@ -438,34 +438,34 @@ static int bssgp_rx_suspend(struct msgb *msg, struct tlv_parsed *tp, return 0; } -static int bssgp_rx_resume(struct msgb *msg, struct tlv_parsed *tp, - struct bssgp_bvc_ctx *ctx) +static int bssgp_rx_resume(struct msgb *msg, struct tlv_parsed *tp) { struct osmo_bssgp_prim gbp; struct gprs_ra_id raid; uint32_t tlli; uint8_t suspend_ref; + uint16_t ns_bvci = msgb_bvci(msg); int rc; if (!TLVP_PRESENT(tp, BSSGP_IE_TLLI) || !TLVP_PRESENT(tp, BSSGP_IE_ROUTEING_AREA) || !TLVP_PRESENT(tp, BSSGP_IE_SUSPEND_REF_NR)) { LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx RESUME " - "missing mandatory IE\n", ctx->bvci); + "missing mandatory IE\n", ns_bvci); return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg); } tlli = ntohl(*(uint32_t *)TLVP_VAL(tp, BSSGP_IE_TLLI)); suspend_ref = *TLVP_VAL(tp, BSSGP_IE_SUSPEND_REF_NR); - DEBUGP(DBSSGP, "BSSGP BVCI=%u TLLI=0x%08x Rx RESUME\n", ctx->bvci, tlli); + DEBUGP(DBSSGP, "BSSGP BVCI=%u TLLI=0x%08x Rx RESUME\n", ns_bvci, tlli); gsm48_parse_ra(&raid, TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA)); /* Inform GMM about the RESUME request */ memset(&gbp, 0, sizeof(gbp)); gbp.nsei = msgb_nsei(msg); - gbp.bvci = ctx->bvci; + gbp.bvci = ns_bvci; gbp.tlli = tlli; gbp.ra_id = &raid; gbp.u.resume.suspend_ref = suspend_ref; @@ -886,23 +886,29 @@ static int bssgp_rx_sign(struct msgb *msg, struct tlv_parsed *tp, uint8_t pdu_type = bgph->pdu_type; int rc = 0; uint16_t ns_bvci = msgb_bvci(msg); + uint16_t bvci = bctx ? bctx->bvci : ns_bvci; switch (bgph->pdu_type) { case BSSGP_PDUT_SUSPEND: /* MS wants to suspend */ - rc = bssgp_rx_suspend(msg, tp, bctx); + rc = bssgp_rx_suspend(msg, tp); break; case BSSGP_PDUT_RESUME: /* MS wants to resume */ - rc = bssgp_rx_resume(msg, tp, bctx); + rc = bssgp_rx_resume(msg, tp); break; case BSSGP_PDUT_FLUSH_LL_ACK: /* BSS informs us it has performed LL FLUSH */ - DEBUGP(DBSSGP, "BSSGP Rx BVCI=%u FLUSH LL ACK\n", bctx->bvci); + DEBUGP(DBSSGP, "BSSGP Rx BVCI=%u FLUSH LL ACK\n", bvci); /* FIXME: send NM_FLUSH_LL.res to NM */ break; case BSSGP_PDUT_LLC_DISCARD: /* BSS informs that some LLC PDU's have been discarded */ + if (!bctx) { + LOGP(DBSSGP, LOGL_ERROR, + "BSSGP Rx LLC-DISCARD missing mandatory BVCI\n"); + goto err_mand_ie; + } rc = bssgp_rx_llc_disc(msg, tp, bctx); break; case BSSGP_PDUT_BVC_BLOCK: @@ -936,7 +942,7 @@ static int bssgp_rx_sign(struct msgb *msg, struct tlv_parsed *tp, break; case BSSGP_PDUT_STATUS: /* Some exception has occurred */ - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx BVC STATUS\n", bctx->bvci); + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx BVC STATUS\n", bvci); /* FIXME: send NM_STATUS.ind to NM */ break; /* those only exist in the SGSN -> BSS direction */ @@ -951,13 +957,13 @@ static int bssgp_rx_sign(struct msgb *msg, struct tlv_parsed *tp, case BSSGP_PDUT_BVC_UNBLOCK_ACK: case BSSGP_PDUT_SGSN_INVOKE_TRACE: DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x only exists " - "in DL\n", bctx->bvci, pdu_type); + "in DL\n", bvci, pdu_type); bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); rc = -EINVAL; break; default: DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x unknown\n", - bctx->bvci, pdu_type); + bvci, pdu_type); rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); break; } @@ -998,8 +1004,10 @@ int bssgp_rcvmsg(struct msgb *msg) /* look-up or create the BTS context for this BVC */ bctx = btsctx_by_bvci_nsei(bvci, msgb_nsei(msg)); - /* Only a RESET PDU can create a new BVC context */ - if (!bctx && pdu_type != BSSGP_PDUT_BVC_RESET) { + /* Only a RESET PDU can create a new BVC context, + * otherwise it must be registered if a BVCI is given */ + if (!bctx && bvci != BVCI_SIGNALLING && + pdu_type != BSSGP_PDUT_BVC_RESET) { LOGP(DBSSGP, LOGL_NOTICE, "NSEI=%u/BVCI=%u Rejecting PDU " "type %u for unknown BVCI\n", msgb_nsei(msg), bvci, pdu_type); diff --git a/tests/gb/gprs_bssgp_test.c b/tests/gb/gprs_bssgp_test.c index a2a4068..d24250d 100644 --- a/tests/gb/gprs_bssgp_test.c +++ b/tests/gb/gprs_bssgp_test.c @@ -116,10 +116,10 @@ static void test_bssgp_suspend_resume(void) memset(&last_oph, 0, sizeof(last_oph)); send_bssgp_supend(BSSGP_PDUT_SUSPEND, tlli); - /* OSMO_ASSERT(last_oph.primitive == PRIM_BSSGP_GMM_SUSPEND); */ + OSMO_ASSERT(last_oph.primitive == PRIM_BSSGP_GMM_SUSPEND); send_bssgp_resume(BSSGP_PDUT_RESUME, tlli); - /* OSMO_ASSERT(last_oph.primitive == PRIM_BSSGP_GMM_RESUME); */ + OSMO_ASSERT(last_oph.primitive == PRIM_BSSGP_GMM_RESUME); printf("----- %s END\n", __func__); } diff --git a/tests/gb/gprs_bssgp_test.ok b/tests/gb/gprs_bssgp_test.ok index 9c7b4c0..c9ec83d 100644 --- a/tests/gb/gprs_bssgp_test.ok +++ b/tests/gb/gprs_bssgp_test.ok @@ -1,5 +1,7 @@ ===== BSSGP test START ----- test_bssgp_suspend_resume START +BSSGP primitive, SAP 16777219, prim = 3, op = 0, msg = 0b 1f 84 f0 12 34 56 1b 86 0f f1 80 20 37 00 +BSSGP primitive, SAP 16777219, prim = 4, op = 0, msg = 0e 1f 84 f0 12 34 56 1b 86 0f f1 80 20 37 00 1d 81 01 ----- test_bssgp_suspend_resume END ===== BSSGP test END -- 1.9.1 From Max.Suraev at fairwaves.co Thu Oct 16 14:16:12 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Thu, 16 Oct 2014 16:16:12 +0200 Subject: end2end test with fakeBTS Message-ID: <543FD32C.9050707@fairwaves.co> Hi all. I've found pretty interesting test case in ofono-end-to-end folder of osmo-st-openbsc-test repo. Sadly the documentation is not there. What does it do exactly and which hardware (client-side obviously :) is required for the test? How do I run it? Using some magic gst command? -- best regards, Max, http://fairwaves.co From max.suraev at fairwaves.co Fri Oct 17 10:19:58 2014 From: max.suraev at fairwaves.co (Max) Date: Fri, 17 Oct 2014 12:19:58 +0200 Subject: [PATCH] Use generic auth API Message-ID: <1413541198-18547-1-git-send-email-max.suraev@fairwaves.co> Signed-off-by: Max --- openbsc/src/libmsc/auth.c | 69 +++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 10d8edf..d04b2fc 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -24,47 +24,11 @@ #include #include #include - -#include +#include #include -static int -_use_xor(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple) -{ - int i, l = ainfo->a3a8_ki_len; - - if ((l > A38_XOR_MAX_KEY_LEN) || (l < A38_XOR_MIN_KEY_LEN)) { - LOGP(DMM, LOGL_ERROR, "Invalid XOR key (len=%d) %s\n", - ainfo->a3a8_ki_len, - osmo_hexdump(ainfo->a3a8_ki, ainfo->a3a8_ki_len)); - return -1; - } - - for (i=0; i<4; i++) - atuple->sres[i] = atuple->rand[i] ^ ainfo->a3a8_ki[i]; - for (i=4; i<12; i++) - atuple->kc[i-4] = atuple->rand[i] ^ ainfo->a3a8_ki[i]; - - return 0; -} - -static int -_use_comp128_v1(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple) -{ - if (ainfo->a3a8_ki_len != A38_COMP128_KEY_LEN) { - LOGP(DMM, LOGL_ERROR, "Invalid COMP128v1 key (len=%d) %s\n", - ainfo->a3a8_ki_len, - osmo_hexdump(ainfo->a3a8_ki, ainfo->a3a8_ki_len)); - return -1; - } - - comp128(ainfo->a3a8_ki, atuple->rand, atuple->sres, atuple->kc); - - return 0; -} - /* Return values * -1 -> Internal error * 0 -> Not available @@ -76,6 +40,11 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, { struct gsm_auth_info ainfo; int i, rc; + static struct osmo_sub_auth_data auth = { + .type = OSMO_AUTH_TYPE_GSM + }; + struct osmo_auth_vector _vec; + struct osmo_auth_vector *vec = &_vec; /* Get subscriber info (if any) */ rc = db_get_authinfo_for_subscr(&ainfo, subscr); @@ -109,13 +78,23 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, return 0; case AUTH_ALGO_XOR: - if (_use_xor(&ainfo, atuple)) - return 0; + auth.algo = OSMO_AUTH_ALG_XOR; + if ((ainfo.a3a8_ki_len > A38_XOR_MAX_KEY_LEN) || (ainfo.a3a8_ki_len < A38_XOR_MIN_KEY_LEN)) { + LOGP(DMM, LOGL_ERROR, "Invalid XOR key (len=%d) %s\n", + ainfo.a3a8_ki_len, + osmo_hexdump(ainfo.a3a8_ki, ainfo.a3a8_ki_len)); + return -1; + } break; case AUTH_ALGO_COMP128v1: - if (_use_comp128_v1(&ainfo, atuple)) - return 0; + auth.algo = OSMO_AUTH_ALG_COMP128v1; + if (ainfo.a3a8_ki_len != A38_COMP128_KEY_LEN) { + LOGP(DMM, LOGL_ERROR, "Invalid COMP128v1 key (len=%d) %s\n", + ainfo.a3a8_ki_len, + osmo_hexdump(ainfo.a3a8_ki, ainfo.a3a8_ki_len)); + return -1; + } break; default: @@ -124,6 +103,14 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, return 0; } + memcpy(auth.u.gsm.ki, ainfo.a3a8_ki, sizeof(auth.u.gsm.ki)); + + if (osmo_auth_gen_vec(vec, &auth, atuple->rand) < 0) + return -1; + + memcpy(atuple->sres, vec->sres, 4); + memcpy(atuple->kc, vec->kc, 8); + db_sync_lastauthtuple_for_subscr(atuple, subscr); DEBUGP(DMM, "Need to do authentication and ciphering\n"); -- 1.9.1 From Max.Suraev at fairwaves.co Fri Oct 17 10:31:23 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Fri, 17 Oct 2014 12:31:23 +0200 Subject: [PATCH] Use generic auth API In-Reply-To: <1413541198-18547-1-git-send-email-max.suraev@fairwaves.co> References: <1413541198-18547-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <5440EFFB.4060903@fairwaves.co> Just realized that this long time ago published patch s not visible at patchwork. I'd appreciate help with testing it against sim cards using xor - don't have any at hands. 17.10.2014 12:19, Max ?????: > Signed-off-by: Max > --- > openbsc/src/libmsc/auth.c | 69 +++++++++++++++++++---------------------------- > 1 file changed, 28 insertions(+), 41 deletions(-) > > diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c > index 10d8edf..d04b2fc 100644 > --- a/openbsc/src/libmsc/auth.c > +++ b/openbsc/src/libmsc/auth.c > @@ -24,47 +24,11 @@ > #include > #include > #include > - > -#include > +#include > > #include > > > -static int > -_use_xor(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple) > -{ > - int i, l = ainfo->a3a8_ki_len; > - > - if ((l > A38_XOR_MAX_KEY_LEN) || (l < A38_XOR_MIN_KEY_LEN)) { > - LOGP(DMM, LOGL_ERROR, "Invalid XOR key (len=%d) %s\n", > - ainfo->a3a8_ki_len, > - osmo_hexdump(ainfo->a3a8_ki, ainfo->a3a8_ki_len)); > - return -1; > - } > - > - for (i=0; i<4; i++) > - atuple->sres[i] = atuple->rand[i] ^ ainfo->a3a8_ki[i]; > - for (i=4; i<12; i++) > - atuple->kc[i-4] = atuple->rand[i] ^ ainfo->a3a8_ki[i]; > - > - return 0; > -} > - > -static int > -_use_comp128_v1(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple) > -{ > - if (ainfo->a3a8_ki_len != A38_COMP128_KEY_LEN) { > - LOGP(DMM, LOGL_ERROR, "Invalid COMP128v1 key (len=%d) %s\n", > - ainfo->a3a8_ki_len, > - osmo_hexdump(ainfo->a3a8_ki, ainfo->a3a8_ki_len)); > - return -1; > - } > - > - comp128(ainfo->a3a8_ki, atuple->rand, atuple->sres, atuple->kc); > - > - return 0; > -} > - > /* Return values > * -1 -> Internal error > * 0 -> Not available > @@ -76,6 +40,11 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, > { > struct gsm_auth_info ainfo; > int i, rc; > + static struct osmo_sub_auth_data auth = { > + .type = OSMO_AUTH_TYPE_GSM > + }; > + struct osmo_auth_vector _vec; > + struct osmo_auth_vector *vec = &_vec; > > /* Get subscriber info (if any) */ > rc = db_get_authinfo_for_subscr(&ainfo, subscr); > @@ -109,13 +78,23 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, > return 0; > > case AUTH_ALGO_XOR: > - if (_use_xor(&ainfo, atuple)) > - return 0; > + auth.algo = OSMO_AUTH_ALG_XOR; > + if ((ainfo.a3a8_ki_len > A38_XOR_MAX_KEY_LEN) || (ainfo.a3a8_ki_len < A38_XOR_MIN_KEY_LEN)) { > + LOGP(DMM, LOGL_ERROR, "Invalid XOR key (len=%d) %s\n", > + ainfo.a3a8_ki_len, > + osmo_hexdump(ainfo.a3a8_ki, ainfo.a3a8_ki_len)); > + return -1; > + } > break; > > case AUTH_ALGO_COMP128v1: > - if (_use_comp128_v1(&ainfo, atuple)) > - return 0; > + auth.algo = OSMO_AUTH_ALG_COMP128v1; > + if (ainfo.a3a8_ki_len != A38_COMP128_KEY_LEN) { > + LOGP(DMM, LOGL_ERROR, "Invalid COMP128v1 key (len=%d) %s\n", > + ainfo.a3a8_ki_len, > + osmo_hexdump(ainfo.a3a8_ki, ainfo.a3a8_ki_len)); > + return -1; > + } > break; > > default: > @@ -124,6 +103,14 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, > return 0; > } > > + memcpy(auth.u.gsm.ki, ainfo.a3a8_ki, sizeof(auth.u.gsm.ki)); > + > + if (osmo_auth_gen_vec(vec, &auth, atuple->rand) < 0) > + return -1; > + > + memcpy(atuple->sres, vec->sres, 4); > + memcpy(atuple->kc, vec->kc, 8); > + > db_sync_lastauthtuple_for_subscr(atuple, subscr); > > DEBUGP(DMM, "Need to do authentication and ciphering\n"); > -- best regards, Max, http://fairwaves.co From ereedsanchez at gmail.com Sun Oct 19 06:26:06 2014 From: ereedsanchez at gmail.com (Edwin Reed-Sanchez) Date: Sun, 19 Oct 2014 02:26:06 -0400 Subject: Registering Phones on USRP1 Message-ID: Total new to SDR and Osmocom. I have USRP1 with clock-tamer installed. 1 daughtercard - RFX1800 (I believe) I have been following this tutorial: http://openbsc.osmocom.org/trac/wiki/network_from_scratch My phones can see network but not register. Nothing comes up in the log file when phones try to connect. Not sure if its a config problem, or the external clock tamer, or something else. Attached is configs and screenshots Thanks, E -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: open-bsc-OSMOSITE.cfg Type: application/octet-stream Size: 1865 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: osmo-bts_OSMOSITE.cfg Type: application/octet-stream Size: 376 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot from 2014-10-19 00_56_24.png Type: image/png Size: 85312 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: currentbsc.png Type: image/png Size: 52520 bytes Desc: not available URL: From tom at tsou.cc Mon Oct 20 17:49:46 2014 From: tom at tsou.cc (Tom Tsou) Date: Mon, 20 Oct 2014 10:49:46 -0700 Subject: Registering Phones on USRP1 In-Reply-To: References: Message-ID: On Sat, Oct 18, 2014 at 11:26 PM, Edwin Reed-Sanchez wrote: > Total new to SDR and Osmocom. > > I have USRP1 with clock-tamer installed. > > 1 daughtercard - RFX1800 (I believe) Did you build with osmo-trx with USRP1 single daughterboard support? './configure --with-singledb' USRP1 is an older device now and configuration is unique and more complicated than more recent devices. -TT From Max.Suraev at fairwaves.co Tue Oct 21 16:37:49 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 21 Oct 2014 18:37:49 +0200 Subject: cfu support Message-ID: <54468BDD.1020705@fairwaves.co> Hi all. Is stuff from ETSI TS 100 543 supported? I mean all the "call forwarding" features like CFU, CFB, CFNRy and CFNRc. If yes than how to configure that? If not that what's missing? -- best regards, Max, http://fairwaves.co From max.suraev at fairwaves.co Wed Oct 22 14:21:20 2014 From: max.suraev at fairwaves.co (Max) Date: Wed, 22 Oct 2014 16:21:20 +0200 Subject: [PATCH] Replace ad-hoc function with generic one from libosmocore Message-ID: <1413987680-5796-1-git-send-email-max.suraev@fairwaves.co> Signed-off-by: Max --- openbsc/src/osmo-bsc/osmo_bsc_bssap.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c index dda3157..c2bbbd3 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c @@ -29,16 +29,6 @@ #include #include -#include - -static uint16_t read_data16(const uint8_t *data) -{ - uint16_t res; - - memcpy(&res, data, sizeof(res)); - return res; -} - /* * helpers for the assignment command */ @@ -154,7 +144,7 @@ static int bssmap_handle_paging(struct osmo_msc_data *msc, * Support paging to all network or one BTS at one LAC */ if (data_length == 3 && data[0] == CELL_IDENT_LAC) { - lac = ntohs(read_data16(&data[1])); + lac = osmo_load16be(&data[1]); } else if (data_length > 1 || (data[0] & 0x0f) != CELL_IDENT_BSS) { LOGP(DMSC, LOGL_ERROR, "Unsupported Cell Identifier List: %s\n", osmo_hexdump(data, data_length)); return -1; @@ -321,7 +311,7 @@ static int bssmap_handle_assignm_req(struct osmo_bsc_sccp_con *conn, goto reject; } - conn->cic = ntohs(read_data16(TLVP_VAL(&tp, GSM0808_IE_CIRCUIT_IDENTITY_CODE))); + conn->cic = osmo_load16be(TLVP_VAL(&tp, GSM0808_IE_CIRCUIT_IDENTITY_CODE)); timeslot = conn->cic & 0x1f; multiplex = (conn->cic & ~0x1f) >> 5; -- 1.9.1 From Max.Suraev at fairwaves.co Wed Oct 22 15:14:41 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Wed, 22 Oct 2014 17:14:41 +0200 Subject: [PATCH] Replace ad-hoc function with generic one from libosmocore In-Reply-To: <1413987680-5796-1-git-send-email-max.suraev@fairwaves.co> References: <1413987680-5796-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <5447C9E1.9080706@fairwaves.co> Not sure if it's covered by tests. Please review. -- best regards, Max, http://fairwaves.co From max.suraev at fairwaves.co Wed Oct 22 14:50:08 2014 From: max.suraev at fairwaves.co (Max) Date: Wed, 22 Oct 2014 16:50:08 +0200 Subject: [PATCH] Fix bunch of printf warnings Message-ID: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> Signed-off-by: Max --- openbsc/src/libbsc/bsc_api.c | 4 ++-- openbsc/src/libmgcp/mgcp_protocol.c | 2 +- openbsc/tests/abis/abis_test.c | 16 ++++++++-------- openbsc/tests/gbproxy/gbproxy_test.c | 16 ++++++++-------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c index 5ce0bc4..f4121de 100644 --- a/openbsc/src/libbsc/bsc_api.c +++ b/openbsc/src/libbsc/bsc_api.c @@ -416,7 +416,7 @@ static void handle_ass_compl(struct gsm_subscriber_connection *conn, gh = msgb_l3(msg); if (msgb_l3len(msg) - sizeof(*gh) != 1) { - LOGP(DMSC, LOGL_ERROR, "Assignment Compl invalid: %u\n", + LOGP(DMSC, LOGL_ERROR, "Assignment Compl invalid: %lu\n", msgb_l3len(msg) - sizeof(*gh)); return; } @@ -461,7 +461,7 @@ static void handle_ass_fail(struct gsm_subscriber_connection *conn, gh = msgb_l3(msg); if (msgb_l3len(msg) - sizeof(*gh) != 1) { - LOGP(DMSC, LOGL_ERROR, "assignemnt failure unhandled: %u\n", + LOGP(DMSC, LOGL_ERROR, "assignemnt failure unhandled: %lu\n", msgb_l3len(msg) - sizeof(*gh)); rr_failure = NULL; } else { diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c index 79422fe..00315fb 100644 --- a/openbsc/src/libmgcp/mgcp_protocol.c +++ b/openbsc/src/libmgcp/mgcp_protocol.c @@ -308,7 +308,7 @@ static int write_response_sdp(struct mgcp_endpoint *endp, return len; buffer_too_small: - LOGP(DMGCP, LOGL_ERROR, "SDP buffer too small: %d (needed %d)\n", + LOGP(DMGCP, LOGL_ERROR, "SDP buffer too small: %zu (needed %d)\n", size, len); return -1; } diff --git a/openbsc/tests/abis/abis_test.c b/openbsc/tests/abis/abis_test.c index e7e78d2..f82740f 100644 --- a/openbsc/tests/abis/abis_test.c +++ b/openbsc/tests/abis/abis_test.c @@ -61,11 +61,11 @@ static void test_simple_sw_config(void) } if (descr[0].len != 13) { - printf("WRONG SIZE: %d\n", descr[0].len); + printf("WRONG SIZE: %zu\n", descr[0].len); abort(); } - printf("Start: %u len: %zu\n", descr[0].start - simple_config, descr[0].len); + printf("Start: %lu len: %zu\n", descr[0].start - simple_config, descr[0].len); printf("file_id: %s\n", osmo_hexdump(descr[0].file_id, descr[0].file_id_len)); printf("file_ver: %s\n", osmo_hexdump(descr[0].file_ver, descr[0].file_ver_len)); } @@ -99,20 +99,20 @@ static void test_dual_sw_config(void) } if (descr[0].len != 13) { - printf("WRONG SIZE0: %d\n", descr[0].len); + printf("WRONG SIZE0: %zu\n", descr[0].len); abort(); } if (descr[1].len != 13) { - printf("WRONG SIZE1: %d\n", descr[1].len); + printf("WRONG SIZE1: %zu\n", descr[1].len); abort(); } - printf("Start: %u len: %zu\n", descr[0].start - dual_config, descr[0].len); + printf("Start: %lu len: %zu\n", descr[0].start - dual_config, descr[0].len); printf("file_id: %s\n", osmo_hexdump(descr[0].file_id, descr[0].file_id_len)); printf("file_ver: %s\n", osmo_hexdump(descr[0].file_ver, descr[0].file_ver_len)); - printf("Start: %u len: %zu\n", descr[1].start - dual_config, descr[1].len); + printf("Start: %lu len: %zu\n", descr[1].start - dual_config, descr[1].len); printf("file_id: %s\n", osmo_hexdump(descr[1].file_id, descr[1].file_id_len)); printf("file_ver: %s\n", osmo_hexdump(descr[1].file_ver, descr[1].file_ver_len)); } @@ -129,11 +129,11 @@ static void test_sw_selection(void) abort(); } - printf("Start: %u len: %zu\n", descr[0].start - load_config, descr[0].len); + printf("Start: %lu len: %zu\n", descr[0].start - load_config, descr[0].len); printf("file_id: %s\n", osmo_hexdump(descr[0].file_id, descr[0].file_id_len)); printf("file_ver: %s\n", osmo_hexdump(descr[0].file_ver, descr[0].file_ver_len)); - printf("Start: %u len: %zu\n", descr[1].start - load_config, descr[1].len); + printf("Start: %lu len: %zu\n", descr[1].start - load_config, descr[1].len); printf("file_id: %s\n", osmo_hexdump(descr[1].file_id, descr[1].file_id_len)); printf("file_ver: %s\n", osmo_hexdump(descr[1].file_ver, descr[1].file_ver_len)); diff --git a/openbsc/tests/gbproxy/gbproxy_test.c b/openbsc/tests/gbproxy/gbproxy_test.c index 5aa301b..161f7fd 100644 --- a/openbsc/tests/gbproxy/gbproxy_test.c +++ b/openbsc/tests/gbproxy/gbproxy_test.c @@ -898,7 +898,7 @@ int gprs_ns_rcvmsg(struct gprs_ns_inst *nsi, struct msgb *msg, int gprs_ns_callback(enum gprs_ns_evt event, struct gprs_nsvc *nsvc, struct msgb *msg, uint16_t bvci) { - printf("CALLBACK, event %d, msg length %d, bvci 0x%04x\n%s\n\n", + printf("CALLBACK, event %d, msg length %zu, bvci 0x%04x\n%s\n\n", event, msgb_bssgp_len(msg), bvci, osmo_hexdump(msgb_l2(msg), msgb_l2len(msg))); @@ -925,15 +925,15 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, real_sendto = dlsym(RTLD_NEXT, "sendto"); if (dest_host == REMOTE_BSS_ADDR) - printf("MESSAGE to BSS at 0x%08x:%d, msg length %d\n%s\n\n", + printf("MESSAGE to BSS at 0x%08x:%d, msg length %zu\n%s\n\n", dest_host, dest_port, len, osmo_hexdump(buf, len)); else if (dest_host == REMOTE_SGSN_ADDR) - printf("MESSAGE to SGSN at 0x%08x:%d, msg length %d\n%s\n\n", + printf("MESSAGE to SGSN at 0x%08x:%d, msg length %zu\n%s\n\n", dest_host, dest_port, len, osmo_hexdump(buf, len)); else if (dest_host == REMOTE_SGSN2_ADDR) - printf("MESSAGE to SGSN 2 at 0x%08x:%d, msg length %d\n%s\n\n", + printf("MESSAGE to SGSN 2 at 0x%08x:%d, msg length %zu\n%s\n\n", dest_host, dest_port, len, osmo_hexdump(buf, len)); else @@ -957,15 +957,15 @@ int gprs_ns_sendmsg(struct gprs_ns_inst *nsi, struct msgb *msg) if (nsei == SGSN_NSEI) printf("NS UNITDATA MESSAGE to SGSN, BVCI 0x%04x, " - "msg length %d (%s)\n", + "msg length %zu (%s)\n", bvci, len, __func__); else if (nsei == SGSN2_NSEI) printf("NS UNITDATA MESSAGE to SGSN 2, BVCI 0x%04x, " - "msg length %d (%s)\n", + "msg length %zu (%s)\n", bvci, len, __func__); else printf("NS UNITDATA MESSAGE to BSS, BVCI 0x%04x, " - "msg length %d (%s)\n", + "msg length %zu (%s)\n", bvci, len, __func__); if (received_messages) { @@ -1195,7 +1195,7 @@ static int gprs_process_message(struct gprs_ns_inst *nsi, const char *text, stru struct msgb *msg; int ret; if (data_len > NS_ALLOC_SIZE - NS_ALLOC_HEADROOM) { - fprintf(stderr, "message too long: %d\n", data_len); + fprintf(stderr, "message too long: %zu\n", data_len); return -1; } -- 1.9.1 From Max.Suraev at fairwaves.co Wed Oct 22 15:15:26 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Wed, 22 Oct 2014 17:15:26 +0200 Subject: [PATCH] Fix bunch of printf warnings In-Reply-To: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> References: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <5447CA0E.6050507@fairwaves.co> One step closer to build with -Werror :) -- best regards, Max, http://fairwaves.co From holger at freyther.de Wed Oct 22 21:32:49 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 22 Oct 2014 23:32:49 +0200 Subject: [PATCH] Fix bunch of printf warnings In-Reply-To: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> References: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <20141022213249.GA7591@xiaoyu.lan> On Wed, Oct 22, 2014 at 04:50:08PM +0200, Max wrote: Hi, > gh = msgb_l3(msg); > if (msgb_l3len(msg) - sizeof(*gh) != 1) { > - LOGP(DMSC, LOGL_ERROR, "Assignment Compl invalid: %u\n", > + LOGP(DMSC, LOGL_ERROR, "Assignment Compl invalid: %lu\n", > msgb_l3len(msg) - sizeof(*gh)); it looks like a candidate for ping-pong games on 32bit/64bit userland on GNU/Linux. What is the type here? unsigned int - size_t? holger From Max.Suraev at fairwaves.co Thu Oct 23 08:24:57 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Thu, 23 Oct 2014 10:24:57 +0200 Subject: [PATCH] Fix bunch of printf warnings In-Reply-To: <20141022213249.GA7591@xiaoyu.lan> References: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> <20141022213249.GA7591@xiaoyu.lan> Message-ID: <5448BB59.3060605@fairwaves.co> Good catch, I didn't notice it. Maybe we should just use size_t for all the length functions in libosmo*? That's what size_t was invented for after all :) 22.10.2014 23:32, Holger Hans Peter Freyther ?????: > On Wed, Oct 22, 2014 at 04:50:08PM +0200, Max wrote: > > Hi, > >> gh = msgb_l3(msg); >> if (msgb_l3len(msg) - sizeof(*gh) != 1) { >> - LOGP(DMSC, LOGL_ERROR, "Assignment Compl invalid: %u\n", >> + LOGP(DMSC, LOGL_ERROR, "Assignment Compl invalid: %lu\n", >> msgb_l3len(msg) - sizeof(*gh)); > > it looks like a candidate for ping-pong games on 32bit/64bit userland > on GNU/Linux. What is the type here? unsigned int - size_t? > > holger > -- best regards, Max, http://fairwaves.co From holger at freyther.de Thu Oct 23 12:39:21 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 23 Oct 2014 14:39:21 +0200 Subject: [PATCH] Fix bunch of printf warnings In-Reply-To: <5448BB59.3060605@fairwaves.co> References: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> <20141022213249.GA7591@xiaoyu.lan> <5448BB59.3060605@fairwaves.co> Message-ID: <20141023123921.GB7591@xiaoyu.lan> On Thu, Oct 23, 2014 at 10:24:57AM +0200, ? wrote: > Good catch, I didn't notice it. Maybe we should just use size_t for all the length > functions in libosmo*? That's what size_t was invented for after all :) > > it looks like a candidate for ping-pong games on 32bit/64bit userland > > on GNU/Linux. What is the type here? unsigned int - size_t? I can't quote the ISO C specification. So what type is the result of "unsigned int - size_t"? We have size_t, off_t, ptrdiff_t as potential types. I don't know which is the right one. :) From jengelh at inai.de Thu Oct 23 12:47:26 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Thu, 23 Oct 2014 14:47:26 +0200 (CEST) Subject: [PATCH] Fix bunch of printf warnings In-Reply-To: <20141023123921.GB7591@xiaoyu.lan> References: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> <20141022213249.GA7591@xiaoyu.lan> <5448BB59.3060605@fairwaves.co> <20141023123921.GB7591@xiaoyu.lan> Message-ID: On Thursday 2014-10-23 14:39, Holger Hans Peter Freyther wrote: >On Thu, Oct 23, 2014 at 10:24:57AM +0200, ? wrote: > >> Good catch, I didn't notice it. Maybe we should just use size_t for all the length >> functions in libosmo*? That's what size_t was invented for after all :) > >> > it looks like a candidate for ping-pong games on 32bit/64bit userland >> > on GNU/Linux. What is the type here? unsigned int - size_t? > >I can't quote the ISO C specification. So what type is the result of >"unsigned int - size_t"? size_t, because it is of higher rank. (The specifier to use is %zu.) From peter at stuge.se Thu Oct 23 15:59:32 2014 From: peter at stuge.se (Peter Stuge) Date: Thu, 23 Oct 2014 17:59:32 +0200 Subject: [PATCH] Fix bunch of printf warnings In-Reply-To: References: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> <20141022213249.GA7591@xiaoyu.lan> <5448BB59.3060605@fairwaves.co> <20141023123921.GB7591@xiaoyu.lan> Message-ID: <20141023155932.975.qmail@stuge.se> Jan Engelhardt wrote: > > So what type is the result of "unsigned int - size_t"? > > size_t, because it is of higher rank. How come it has higher rank? I don't have the spec, maybe it is stated explicitly there, but this blog post (it's on the internet so it MUST be true!) outlines rules based on the standard, and doesn't mention either size_t type. I have a feeling that size_t is not strictly defined, ie. that a programmer or even a compiler is free to choose any representation, as long as all memory addresses can be stored. In that case size_t rank can't really be determined. We could always cast... :) //Peter From Max.Suraev at fairwaves.co Thu Oct 23 16:09:51 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Thu, 23 Oct 2014 18:09:51 +0200 Subject: [PATCH] Fix bunch of printf warnings In-Reply-To: <20141023155932.975.qmail@stuge.se> References: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> <20141022213249.GA7591@xiaoyu.lan> <5448BB59.3060605@fairwaves.co> <20141023123921.GB7591@xiaoyu.lan> <20141023155932.975.qmail@stuge.se> Message-ID: <5449284F.9000200@fairwaves.co> 23.10.2014 17:59, Peter Stuge ?????: > > We could always cast... :) > That's an evil witchcraft! :) -- best regards, Max, http://fairwaves.co From holger at freyther.de Sat Oct 25 13:42:40 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sat, 25 Oct 2014 15:42:40 +0200 Subject: [PATCH] Fix bunch of printf warnings In-Reply-To: <20141023155932.975.qmail@stuge.se> References: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> <20141022213249.GA7591@xiaoyu.lan> <5448BB59.3060605@fairwaves.co> <20141023123921.GB7591@xiaoyu.lan> <20141023155932.975.qmail@stuge.se> Message-ID: <20141025134240.GA22843@xiaoyu.lan> On Thu, Oct 23, 2014 at 05:59:32PM +0200, Peter Stuge wrote: > How come it has higher rank? > > I don't have the spec, maybe it is stated explicitly there, but this > blog post (it's on the internet so it MUST be true!) outlines rules > based on the standard, and doesn't mention either size_t type. #include #include #include int foo() { unsigned int foo = 1212323123123; size_t bla = 2; typeof(foo - bla) k; k = 3; } clang-3.4 -Xclang -ast-dump -fsyntax-only foo.c `-FunctionDecl 0x9946300 foo 'int ()' `-CompoundStmt 0x9946588 |-DeclStmt 0x99463c8 | `-VarDecl 0x9946370 foo 'unsigned int' | `-ImplicitCastExpr 0x99463b8 'unsigned int' | `-IntegerLiteral 0x99463a0 'long long' 1212323123123 |-DeclStmt 0x9946438 | `-VarDecl 0x99463e0 bla 'size_t':'unsigned int' | `-ImplicitCastExpr 0x9946428 'size_t':'unsigned int' | `-IntegerLiteral 0x9946410 'int' 2 |-DeclStmt 0x9946520 | `-VarDecl 0x99464f0 k 'typeof (foo - bla)':'unsigned int' `-BinaryOperator 0x9946570 'typeof (foo - bla)':'unsigned int' '=' |-DeclRefExpr 0x9946530 'typeof (foo - bla)':'unsigned int' lvalue Var 0x99464f0 'k' 'typeof (foo - bla)':'unsigned int' `-ImplicitCastExpr 0x9946560 'typeof (foo - bla)':'unsigned int' `-IntegerLiteral 0x9946548 'int' 3 If I read this correctly the type is 'unsigned int' with clang? An issue with my reading? Clang bug? cheers holger From jengelh at inai.de Sat Oct 25 15:41:12 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Sat, 25 Oct 2014 17:41:12 +0200 (CEST) Subject: [PATCH] Fix bunch of printf warnings In-Reply-To: <20141025134240.GA22843@xiaoyu.lan> References: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> <20141022213249.GA7591@xiaoyu.lan> <5448BB59.3060605@fairwaves.co> <20141023123921.GB7591@xiaoyu.lan> <20141023155932.975.qmail@stuge.se> <20141025134240.GA22843@xiaoyu.lan> Message-ID: On Saturday 2014-10-25 15:42, Holger Hans Peter Freyther wrote: >int foo() >{ > unsigned int foo = 1212323123123; > size_t bla = 2; > > typeof(foo - bla) k; > k = 3; >} > >clang-3.4 -Xclang -ast-dump -fsyntax-only foo.c > | `-VarDecl 0x99464f0 k 'typeof (foo - bla)':'unsigned int' > >If I read this correctly the type is 'unsigned int' with clang? You seem to be compiling in LP32 mode. I get unsigned long -- which is what size_t amounts to on Linux/LP64. From peter at stuge.se Sun Oct 26 12:04:36 2014 From: peter at stuge.se (Peter Stuge) Date: Sun, 26 Oct 2014 13:04:36 +0100 Subject: [PATCH] Fix bunch of printf warnings In-Reply-To: <20141023155932.975.qmail@stuge.se> References: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> <20141022213249.GA7591@xiaoyu.lan> <5448BB59.3060605@fairwaves.co> <20141023123921.GB7591@xiaoyu.lan> <20141023155932.975.qmail@stuge.se> Message-ID: <20141026120436.4123.qmail@stuge.se> Peter Stuge wrote: > Jan Engelhardt wrote: > > > So what type is the result of "unsigned int - size_t"? > > > > size_t, because it is of higher rank. > > How come it has higher rank? I'd appreciate an answer to this. "because" isn't it. //Peter From jengelh at inai.de Sun Oct 26 17:29:21 2014 From: jengelh at inai.de (Jan Engelhardt) Date: Sun, 26 Oct 2014 18:29:21 +0100 (CET) Subject: [PATCH] Fix bunch of printf warnings In-Reply-To: <20141026120436.4123.qmail@stuge.se> References: <1413989408-14993-1-git-send-email-max.suraev@fairwaves.co> <20141022213249.GA7591@xiaoyu.lan> <5448BB59.3060605@fairwaves.co> <20141023123921.GB7591@xiaoyu.lan> <20141023155932.975.qmail@stuge.se> <20141026120436.4123.qmail@stuge.se> Message-ID: On Sunday 2014-10-26 13:04, Peter Stuge wrote: >> > > So what type is the result of "unsigned int - size_t"? >> > size_t, because it is of higher rank. >> How come it has higher rank? >I'd appreciate an answer to this. "because" isn't it. Then you will be disappointed, because "because it is" is the answer - the standards body defined it to be that way. https://www.securecoding.cert.org/confluence/display/seccode/INT02-C.+Understand+integer+conversion+rules From admin at manateeshome.com Sat Oct 25 06:15:00 2014 From: admin at manateeshome.com (Pierre Kim) Date: Sat, 25 Oct 2014 15:15:00 +0900 Subject: SGSN bug report Message-ID: <5ee401cff01b$02f704c0$08e50e40$@manateeshome.com> Hello, While testing with multiple devices I found a problem where Samsung phones don't correctly respond to identity request messages. Attached is the pcap file of the GPRS-NS transmission. Regards, Pierre -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: galaxy.pcap Type: application/octet-stream Size: 1703 bytes Desc: not available URL: From holger at freyther.de Sat Oct 25 09:03:40 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sat, 25 Oct 2014 11:03:40 +0200 Subject: SGSN bug report In-Reply-To: <5ee401cff01b$02f704c0$08e50e40$@manateeshome.com> References: <5ee401cff01b$02f704c0$08e50e40$@manateeshome.com> Message-ID: <20141025090340.GB26398@xiaoyu.lan> On Sat, Oct 25, 2014 at 03:15:00PM +0900, Pierre Kim wrote: > Hello, Hi, > While testing with multiple devices I found a problem where Samsung phones > don't correctly respond to identity request messages. > > Attached is the pcap file of the GPRS-NS transmission. have you seen the LLC-DISCARDED message? This indicates that a PCU failed to transmit the data to the phone. Which PCU are you using? holger From admin at manateeshome.com Sat Oct 25 09:18:38 2014 From: admin at manateeshome.com (Pierre Kim) Date: Sat, 25 Oct 2014 18:18:38 +0900 Subject: SGSN bug report In-Reply-To: <20141025090340.GB26398@xiaoyu.lan> References: <5ee401cff01b$02f704c0$08e50e40$@manateeshome.com> <20141025090340.GB26398@xiaoyu.lan> Message-ID: <5efb01cff034$aa69cda0$ff3d68e0$@manateeshome.com> Hello, I am using a nanoBTS EDGE model. An iPhone on the same BTS doesn't have this issue. But Samsung phones and HTC Diamond do. Everything else(voice/sms) works flawlessly. Regards, Pierre -----Original Message----- From: openbsc-bounces at lists.osmocom.org [mailto:openbsc-bounces at lists.osmocom.org] On Behalf Of Holger Hans Peter Freyther Sent: Saturday, October 25, 2014 6:04 PM To: Pierre Kim Cc: openbsc at lists.osmocom.org Subject: Re: SGSN bug report On Sat, Oct 25, 2014 at 03:15:00PM +0900, Pierre Kim wrote: > Hello, Hi, > While testing with multiple devices I found a problem where Samsung > phones don't correctly respond to identity request messages. > > Attached is the pcap file of the GPRS-NS transmission. have you seen the LLC-DISCARDED message? This indicates that a PCU failed to transmit the data to the phone. Which PCU are you using? holger From holger at freyther.de Sat Oct 25 09:44:50 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sat, 25 Oct 2014 11:44:50 +0200 Subject: SGSN bug report In-Reply-To: <5efb01cff034$aa69cda0$ff3d68e0$@manateeshome.com> References: <5ee401cff01b$02f704c0$08e50e40$@manateeshome.com> <20141025090340.GB26398@xiaoyu.lan> <5efb01cff034$aa69cda0$ff3d68e0$@manateeshome.com> Message-ID: <20141025094450.GA11692@xiaoyu.lan> On Sat, Oct 25, 2014 at 06:18:38PM +0900, Pierre Kim wrote: > Hello, Hi, > I am using a nanoBTS EDGE model. that is what I assumed. You will need to figure out what the ip.access PCU is doing. > An iPhone on the same BTS doesn't have this issue. > But Samsung phones and HTC Diamond do. Different stacks, different firmware, it doesn't say much. But please have a look at the trace: Packet Delta-TS Direction TLLI message #7 0 MS->SGSN 2584537203 GMM Attach Request #8 ~0s SGSN->MS 2584537203 GMM Identity Request #10 ~2s PCU->SGSN - LLC Discarded In packet #10 the PCU tells the SGSN that 9 octets could not be transferred. Assuming you included the full trace the '9' are the nine bytes of the "LLC/GMM Identity Request". This means that the closed source PCU of the nanoBTS EDGE model couldn't transfer the LLC data to the MS within the 2s deadline that was set in the PDU-Lifetime of packet #8. Now nobody in this community can tell you why the PCU of the nanoBTS doesn't transfer it. Last time I tried to contact an engineer at ip.access (the one that patched GSMTAP for PDCH handling), I was ignored. kind regards holger