Commit Graph

21 Commits

Author SHA1 Message Date
Pau Espin 1562225332 Introduce dynamic log category for libosmo-rua/hnbap
Same as already done for libosmo-ranap.
This allows applications setting the cateogy dynamically, and will allow
untangling library tests using hnbgw log categories in this repo.

Change-Id: I5d09b67b115ad8938e5162a23accfcbafab139d4
2022-01-04 18:57:22 +01:00
Pau Espin 4f35665b9f Fix OneDefinitionRule Asan violation in tests and osmo-hnbgw
With new gcc 10.1.0, tests failed at runtime when built with ASAN
enabled, since some global variables where defined multiple times.
See OS#4556 for a sample Asan error.

Fixes: OS#4556
Change-Id: I12a667ea8a9f16404c13c9218b246d2e3acfe3e8
2020-05-19 20:32:58 +00:00
Vadim Yanitskiy 065c192475 tests/test-ranap: cosmetic: remove unused variable 'rc'
Change-Id: Ie931d11efd7bb083558852a7f329c984c17fec62
2020-04-07 21:11:13 +07:00
Pau Espin ca74126d54 tests/test-ranap.c: Fix wrong printf format
Caught by compiler:
test-ranap.c:54:30: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘RANAP_MaxBitrate_t’ {aka ‘long int’} [-Wformat=]
test-ranap.c:78:30: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘RANAP_CauseMisc_t’ {aka ‘long int’} [-Wformat=]

Change-Id: Icc4e81beaa35e13aea3adfed983016c78b730061
2020-03-20 20:23:04 +01:00
Neels Hofmeyr d9cb19a8fb tests: sanitize: fix mem leaks, clean after tests
Fix various mem leaks in the testing code.

Add test_common_cleanup() in test_common.c, to free talloc contexts; call in
test-{helpers,hnbap,ranap}.c. Upon talloc ctx cleanup, ensure that they are
actually empty, in order to catch newly introduced mem leaks.

If non-empty, print talloc context reports.

Change-Id: Ic66c005f2a264774e18bb54e58b87bef5944511c
2017-11-22 03:11:40 +01:00
Neels Hofmeyr 4ff1a5a957 fix msgb talloc context initialization
Properly initialize msgb talloc context in hnbgw and all tests, using the new
msgb_talloc_ctx_init().

test-ranap.c: since msgb talloc ctx is now in test_common_init(), remove msgb
talloc init here.

Change-Id: I807c799aff1239184728551ed77fdafa73bd683f
2016-10-13 04:17:40 +02:00
Neels Hofmeyr df63de2e37 build: move headers to include/osmocom/*
This came up while fixing 'make distcheck'; this is certainly not the easiest
way but it makes sense to have the headers in include/, like we do in openbsc.

The easy alternative might be to add -I$(top_srcdir)/src to src/Makefile.am.

Remove -I$(top_srcdir)/src from src/tests/Makefile.am, no longer needed.

Change-Id: I5a82e029dcdc4df0a60a31271a4883393fe59234
2016-09-09 06:43:32 +00:00
Neels Hofmeyr f6673b7257 RAB Assign for voice: heed the x213 nsap flag
Add use_x213_nsap arg to ranap_new_msg_rab_assign_voice() and
new_transp_info_rtp(). Pass this to new_transp_layer_addr() to compose 32bit
addresses when use_x213_nsap == false.

This is analogous to ranap_new_msg_rab_assign_data().

Particularly, the ip.access nano3G does not accept x213 NSAP 56bit addresses,
so we want to send 32bit addresses there.

Change-Id: I0c3c95d709c8a2b1c48d7a187faca34102226329
2016-09-08 15:50:32 +02:00
Neels Hofmeyr 802acd0da4 fix: test-ranap.c: missing NULL init
The decoding target pointer has to be NULL so that a new structure is allocated
by aper_decode(). Fixes a probable segmentation fault upon decoding at
test-ranap.c:77 or free of unallocated memory in test-ranap.c:81.
2016-05-03 13:14:30 +02:00
Neels Hofmeyr 95d0ba5f40 test-ranap: fix missing free in test_aper_causemisc, fixes expout
After aper_decode(), we still need to free the decoded struct.

This was introduced in 14da5411a4
("test-ranap: Add test case about constrained integer range decode")

Note, in that commit there is another test failure in expout (a reversed byte
order) which is "secretly" fixed in bb289e3b81
("RAB parameters: add Extended Max Bitrate").

This commit fixes:

@@ -213,6 +212,7 @@
 </RANAP_IE>
 00 0a 00 11 00 00 01 00 29 40 0a 00 00 01 00 28 40 03 05 c2 d0
 report
-talloc report on 'asn1_context' (total      0 bytes in   1 blocks)
+talloc report on 'asn1_context' (total     40 bytes in   2 blocks)
+    constr_CHOICE.c:927            contains     40 bytes in   1 blocks (ref 0) 0x187e690
 talloc report on 'msgb' (total      1 bytes in   1 blocks)
 exit
2016-05-02 14:44:56 +02:00
Harald Welte 14da5411a4 test-ranap: Add test case about constrained integer range decode
There was a bug in the asn1c/libffasn1c APER patch that caused
constrained integer ranges to be decoded incorrectly.  Add a test
case for that to avoid people falling into that trap...
2016-05-01 15:44:13 +02:00
Harald Welte f764a15c23 Add test case about RANAP MaxBitrate encoding
Our version of asn1c/libasn1c used to have an INTEGER encoding but,
where the encoding of integers of > 2 bytes length was broken.

Add a test case to what we expect with the updated/fixed libasn1c.

If your compilation breaks, please upate to libasn1c with related
fix commited a few minutes ago.
2016-04-30 17:47:16 +02:00
Neels Hofmeyr edf1367e62 new RAB: add use_x213_nsap parameter / change it to bool
Allow the *caller* of ranap_new_msg_rab_assign_data() to make the decision for
using 32 bit or longer IP addresses in RAB Assignment Request messages.

This requires a follow-up change in openbsc branch sysmocom/iu.
2016-04-25 15:34:28 +02:00
Daniel Willmann f44d12ce27 ranap_msg_factory: Add keystatus parameter for security mode cmd 2016-04-20 10:17:53 +02:00
Neels Hofmeyr 96979af054 move ranap_*.h,iu_helpers.h to include/osmocom/ranap/
A bit hacky: the ranap_ies_defs.h is generated together with the
ranap_encoder.c and ranap_decoder.c. See comments in src/Makefile.am and
include/osmocom/ranap/Makefile.am.
2016-01-05 15:37:23 +01:00
Harald Welte a575ebfd0f test-ranap: Call new RANAP encoder functions from ranap_msg_factory.c 2016-01-01 16:47:13 +01:00
Harald Welte 87ffeb91dc factor out some common shared test init code 2015-12-25 15:34:22 +01:00
Harald Welte f8db61b554 First compiling (and leak-free) RANAP message generation functions
encoding correctness still needs to be verified at this point.  At least
they generate some binary output without failing somewhere earlier in
the encoding process - and they don't leave any leaked memory behind,
see talloc_report() at the end of test-ranap.c:main().
2015-12-18 20:20:47 +01:00
Harald Welte d062df5307 test-ranap.c: Further WIP, it now actually compiles 2015-12-18 13:35:58 +01:00
Harald Welte 091039d47e test-ranap.c: More WIP code for convoluted RANAP message encoding 2015-12-18 13:35:58 +01:00
Harald Welte d328c1a3ac WIP: add some early code for generating required RANAP messages 2015-12-16 23:04:21 +01:00