path: root/openbsc/tests
AgeCommit message (Collapse)AuthorFilesLines
2016-02-22sgsn: Remove tlli_foreign2localJacob Erlbeck1-5/+0
Currently foreign TLLI are sometimes mapped to local TLLI in the hope that they will match. This seems to sometimes introduce inconsisties, possibly leading to a failing assertion in _bssgp_tx_dl_ud. This mapping should probably reduce the allocation of additional LLME during routing area changes. This commit removes tlli_foreign2local. Sponsored-by: On-Waves ehf
2016-02-18Patch to make openbsc find libsmpp34Ruben Undheim1-1/+1
This patch lets the build script for openbsc find the libsmpp34 installation with the help of pkg-config instead of assuming the header files are in /usr/include.
2016-01-15tests/abis: fix format specifiersAlexander Huemer1-5/+5
2016-01-15tests/oap: depend on libgtpAlexander Huemer1-0/+4
exclude logic copied from src/gprs/Makefile.am
2015-12-07gtphub: improve handling of restarted peer.Neels Hofmeyr2-9/+48
Handle peer restart earlier, so that all the tunnels are deleted by the restart code path, instead of the first one being deleted due to reused TEI. That caused confusing logging messages. Also, when receiving Delete confirmations from the peer that didn't restart, don't complain about unknown peer, but acknowledge and remove the half invalidated tunnel. This means that the pending delete entry from the restart code path is not needed / not used, so don't bother to add pending delete entries upon peer restart. The test test_peer_restarted_reusing_tei() hits the situation where a tunnel is removed because of a reused TEI rather than the restart counter. Adjust the test to expect the "out-of-band" delete request earlier on, and to still see the half invalidated tunnel around. Enhance the test by adding the delete response from the peer that didn't restart, and add a final tunnels_are() verification. Sponsored-by: On-Waves ehi
2015-12-07gtphub: simplify/fix: one TEI mapping per tunnel.Neels Hofmeyr1-79/+102
Because the sender is known, one unique TEI per tunnel suffices to map the TEIs that the peers are sending to gtphub, instead of previously 4 (SGSN<->GGSN interaction on User and Ctrl plane, where each had an own unique TEI). Also, previously, a tunnel's endpoints should also have been checked against each other for TEI reuse, not only against the endpoints of other tunnels. This simplification fixes that problem for free. Thus simplify TEI reuse detection and improve VTY show readability and debugging. Adjust log and VTY output for tunnels. Adjust tests accordingly. Suggested-by: Holger Hans Peter Freyther <holger@moiji-mobile.com> Sponsored-by: On-Waves ehi
2015-12-07gtphub_test: add test_parallel_context_creation()Neels Hofmeyr2-0/+161
Sponsored-by: On-Waves ehi
2015-12-07gtphub: tweak logging.Neels Hofmeyr1-32/+32
Less spaces in tunnel strings, adjust tests accordingly. Use side_idx to remove code dup in rate counter output. Sponsored-by: On-Waves ehi
2015-12-03gtphub: add test for SGSN behind NATNeels Hofmeyr2-0/+105
2015-12-03gtphub_test: tweak test_user_data(): no seq routing.Neels Hofmeyr1-4/+4
Don't route User message back by sequence number, rather test that a completely unrelated User message is routed back properly. Sponsored-by: On-Waves ehi
2015-12-03tests: fix condition to run sgsn, oap, gtphub testsNeels Hofmeyr1-2/+3
Sponsored-by: On-Waves ehi
2015-12-03gtphub: fix restart cleanup peer matching.Neels Hofmeyr2-3/+6
Adjust test expectations accordingly. Sponsored-by: On-Waves ehi
2015-12-03gtphub: wrap gtphub_write() for test suite.Neels Hofmeyr2-1/+20
Sponsored-by: On-Waves ehi
2015-12-03gtphub: add restart counter testNeels Hofmeyr2-0/+165
Sponsored-by: On-Waves ehi
2015-12-03gtphub: add test for reused TEI.Neels Hofmeyr2-0/+78
Sponsored-by: On-Waves ehi
2015-12-03gtphub_test: add test for Del PDP from GGSN side.Neels Hofmeyr2-6/+58
Sponsored-by: On-Waves ehi
2015-12-03gtphub_test: add some cleanup asserts.Neels Hofmeyr1-0/+5
Sponsored-by: On-Waves ehi
2015-12-03gtphub: handle Delete PDP Context.Neels Hofmeyr2-4/+74
During resolution of the header TEI, also return the tunnel struct that resolved the TEI, so the Delete PDP Ctx code does not need to look it up again. Upon Delete PDP Ctx Request, remember the IEs and that a request was made. Upon Delete PDP Ctx Response, find the pending delete and remove the corresponding tunnel, iff the response indicates success. Add a context deletion to regression tests, rename the test appropriately. Sponsored-by: On-Waves ehi
2015-12-03gtphub: refactor: use side_idx everywhere.Neels Hofmeyr1-36/+36
This is a mostly cosmetic change. Instead of separate buffer handling functions, reduce some code duplication by using a side_idx just like the plane_idx, with arrays. Sponsored-by: On-Waves ehi
2015-12-03gtphub: use a single TEI pool across planes.Neels Hofmeyr1-14/+14
There's no need to keep two separate number pools when both can be fed from the same pool. User and Ctrl plane TEIs can technically overlap without colliding, but it doesn't hurt if they don't overlap, either. Sponsored-by: On-Waves ehi
2015-12-03gtphub: implement restart counter properly.Neels Hofmeyr1-4/+4
Force passing a restart counter, by adding such arg to gtphub_start() (test suite is not affected by this). In gtphub_main.c, add -r,--restart-file <path> and next_restart_count() to maintain the counter file. While at it, tweak the cmdline help to unify the formatting (mostly commas and a missing line break). Send gtphub's own restart counter. So far, the sender's restart counter was copied through, which would break as soon as more than one GSN would talk to the same peer with differing restart counters. Also fix the in-mem restart counter data type (one octet, not two). Sponsored-by: On-Waves ehi
2015-12-03gtphub: track tunnels explicitly.Neels Hofmeyr1-10/+63
So far, gtphub worked perfectly by only tracking single TEIs ... for probably most uses. But a Ctrl plane tunnel may have expired despite a still active corresponding User plane tunnel. The User plane would continue to work indefinitely, but if any Ctrl messages followed after more than six hours of Ctrl silence, they would have been dropped due to an expired TEI mapping. We want to - combine expiry of a user TEI with its ctrl TEI. (done in this patch) - upon delete PDP context, remove both user and ctrl TEI mappings. (future) - when a peer indicates a restart counter bump, invalidate its tunnels. (future) To facilitate these, track tunnels, complete with both SGSN's and GGSN's address, original and replaced TEIs, all for both user and ctrl plane, in a single struct. A single expiry entry handles the entire tunnel, instead of previously four separate expiries for each endpoint identifier. Add the concept of a "side", being either GGSN or SGSN, to index tunnel endpoint structs, and so on. Track the originating side in the gtp_packet_desc. Add header_tei_rx: set_tei() overwrites header_tei, but the originally received header TEI is still needed to match a Create PDP Context Response up with its Request (and for logging). Adjust the test suite to expect tunnel listing strings instead of TEI mappings, with a bonus of making it a lot easier to grok, and including the IP addresses. Add regression test for refreshing tunnel expiry upon use. Note: the current implementation is as slow as can possibly be, iterating all the tunnels all the time. Optimizations are kept for a future commit, on purpose. BTW, the sequence number mapping/unmapping structures remain unchanged. Sponsored-by: On-Waves ehi
2015-12-03gtphub: add explicit cleanup handles.Neels Hofmeyr1-6/+21
Clean up functionality is added for the test suite only, to be able to clean out all allocations and test against memory leaks. So far, it was sufficient to expire everything to free a gtphub. In preparation for the upcoming rate counters, which will need to be freed explicitly, add gtphub functions to clean up everything. As added bonus, also close the sockets explicitly -- not really needed upon program exit, neither by the test suite, but *if* we have a cleanup function, it should clean up everything properly. Closing the sockets is however kept separate, for the test suite. gtphub_start() and gtphub_stop() are for normal use (published in gtphub.h), and gtphub_init() and gtphub_free() are for the test suite, without sockets. (gtphub_stop() will probably never be called by anyone, but its existence completes the picture.) In gtphub_test.c, have a function to clean up the testing gtphub struct. First, expire everything by timeout, assert emptiness, then call the cleanup function. Call from each test in the end. Sponsored-by: On-Waves ehi
2015-12-03gtphub: nr_map: add min,max and wrap.Neels Hofmeyr1-2/+47
Implement min/max bounds for nr_pool, adjust nr_pool_init() and current tests, and create unit tests for nr_map wrapping. Sequence numbers range from 0 to 65535, while TEIs range from 1 to 0xffffffff. Both cause problems when the nr_pool surpasses the range: seq exit their valid range, causing unmappings to fail, and a TEI would be mapped as zero (invalid). Add a comment about TEI wrapping, and lose the comment about random TEIs (not really important). Sponsored-by: On-Waves ehi
2015-12-03gtphub: fix number map range for TEIs.Neels Hofmeyr1-3/+3
Use unsigned int for nr_map, just large enough to fit the TEI space. Adjust log output formats and casts accordingly. Fixes: TEIs are uint32_t, but the nr_map so far used int. This would cause TEIs from 0x80000000 on to be handled and printed as a negative value. Sponsored-by: On-Waves ehi
2015-11-29gtphub_test: build only when c-ares and gtp are present.Neels Hofmeyr1-0/+4
2015-11-24gtphub: add enable_gtphub_test to atlocal.in.Neels Hofmeyr1-0/+1
This line was missing, I noticed only now.
2015-11-21tests/smpp: Fix linking orderHarald Welte1-2/+3
At least when using system-wide libtalloc, the LIBOSMOCORE_LIBS must come last, after the static libraries under libcommon.
2015-11-21Fix compilation with no libc-ares present on the systemHarald Welte1-1/+4
This build failure was introduced with the OAP and gtphub changes.
2015-11-20oap and gtphub tests must only be compiled of LIBGTP is present!Harald Welte1-2/+2
2015-11-20gtphub: fix echo reply to SGSNs: wrong fd. Add test.Neels Hofmeyr1-15/+61
The actual fix is just one character, but also add a regression test against this, on both CTRL and USER plane.
2015-11-18fix build: remove obsolete gtphub EXTRA_DIST.Neels Hofmeyr1-4/+1
Sponsored-by: On-Waves ehi
2015-11-16gtphub: cosmetic: break long lines.Neels Hofmeyr1-58/+76
Fit most of the code in 80 chars width. Some instances still leak past 80 characters because of long function names, inline comments or the like, "the exception proves the rule." Sponsored-by: On-Waves ehi
2015-11-16gtphub: fix User plane decoding, add unit test.Neels Hofmeyr2-8/+119
Split decoding return code GTP_RC_PDU in GTP_RC_PDU_C and GTP_RC_PDU_U. Don't do IEs in GTP_RC_PDU_U. Add a unit test for User plane data, expected to fail (nonstandard port case). In gtphub_test.c, tweak logging so that it is easily visible which test produced which output. Also add the global resolved_sgsn_addr and ggsn_sender, symmetrically to resolved_ggsn_add and sgsn_sender. Sponsored-by: On-Waves ehi
2015-11-16gtphub: make test code reusable for future tests.Neels Hofmeyr1-177/+242
Generalize to make the PDP ctx message definitions and "sending" of messages from SGSN->gtphub->GGSN and back reusable in future tests. Publish gsn_addr_from_sockaddr() in gtphub.h for use in gtphub_test.c. Use an osmo_sockaddr for resolved_ggsn_addr, because one is needed for comparison in probably every future test. Add LVL2_ASSERT() to print assertion message and return instead of abort, so that functions can be called from several tests without losing the info of which test caused it from which line. Use globals for struct gtphub and time_t now, to reduce nr of args that need to be passed around when writing tests. Add a default test setup function. Sponsored-by: On-Waves ehi
2015-11-16gtphub: fix Echo behavior: respond directly.Neels Hofmeyr2-67/+62
Up to now I used the Echo as a test for sequence nr mappings. But Echos should be handled differently: they are scoped on the link and an Echo response should be sent right back to the requester. Sponsored-by: On-Waves ehi
2015-11-16gtphub: add first bits of GRX aresNeels Hofmeyr3-35/+105
For the resolving function, change the function signature to return a gtphub_peer_port. In consequence, publish two functions concerned with gtphub_peer_port instances for use in test and gtphub_ext.c. Add GGSN resolution queue, callback and cache. Simple implementation: if an SGSN asks for a GGSN, it will first get no answer, and I hope it will ask again once the GGSN is in the cache. Within gtphub_ext.c, have a dummy sgsn struct, as the sgsn_ares code currently depends on it (half the functions pass an sgsn instance pointer around, but the other half use the global one). In the unit tests, wrap away the ares initialization so that they can work without a DNS server around. The netcat test breaks because of this, will remove it. Using sgsn_ares, implement the gtphub_resolve_ggsn_addr() function, I hope: untested. Minor cosmetics just to see if you're paying attention... ;) Sponsored-by: On-Waves ehi
2015-11-16Add GTP hub initial code base.Neels Hofmeyr5-1/+740
First steps towards a new GTP hub. The aim is to mux GTP connections, so that multiple SGSN <--> GGSN links can pass through a single point. Background: allow having more than one SGSN, possibly in various remote locations. The recent addition of OAP to GSUP is related to the same background idea. (This is a collapsed patch of various changes that do not make sense to review in chronological order anymore, since a lot of it has thorougly transmorphed after it was first committed.) Sponsored-by: On-Waves ehf
2015-11-10gbproxy: Count more GSM 04.08 messagesHolger Hans Peter Freyther1-0/+576
Extend the ul/dl counting to count the usual messages on the Gb interface. Add counters for the attach, routing area update, pdp context activation and deactivation procedures. Update the test result with the new counters.
2015-11-02mgcp_osmux: available circuit IDs from 0 to 255, not from 0 to 128Pablo Neira Ayuso1-1/+1
Holger reports that the bitmap that accounts for available Osmux circuit IDs is limited to 128, when the maximum number of circuit IDs are determined by the uint8_t field in the header (ie. 256 circuits). [hfreyther: Update the testcase now that we have more ids to allocate]
2015-11-02gsup/oap: add OAP to GSUP client.Neels Hofmeyr1-0/+2
Trigger an OAP registration upon IPA connect. Feed incoming OAP messages to oap_handle() and send replies returned by it. Add oap_config to sgsn_config (todo: vty). Sponsored-by: On-Waves ehf [hfreyther: Fix coding style]
2015-11-02oap: add OAP API testNeels Hofmeyr2-5/+195
Sponsored-by: On-Waves ehf
2015-11-02oap: add oap testsuite skeletonNeels Hofmeyr5-1/+87
Sponsored-by: On-Waves ehf
2015-11-02libcommon: soak up three static functions.Neels Hofmeyr1-1/+2
Add new kitchen sink openbsc/utils.h and libcommon/utils.c to make three so far static functions public (so I can use them in the upcoming OAP code). A place to put them could have been the gprs_utils.h, but all general functions in there have a gprs_ prefix, and todo markings to move them away. All other libcommon headers are too specific, so I opened up this kitchen sink header. Replace the implementation of encode_big_endian() with a call to osmo_store64be_ext(). See comments. Apply the change in Makefiles and C files.
2015-10-13gprs/gb_proxy: Use RAND_bytes for gbproxy TLLI/TMSI allocationDaniel Willmann3-293/+315
This change has some implications for the test case. It manipulated bss_ptmsi_state and sgsn_tlli_state variables to make the output of rand_r() and thus the TLLI/TMSI used predictable. This possibility is gone when using RAND_bytes() so instead it is overridden by a function that returns a deterministic sequence of values (0x00dead00, 0x00dead01, ...). The test cases are adapted to expect these values instead of the pseudo random values before. The gbproxy_test stdout file changes as well, but only where the TLLI/TMSI is displayed (in the hex dumps as well as the TLLI cache entries). All other output is the same.
2015-10-13gbproxy/test: Add and call cleanup_test functionDaniel Willmann1-0/+20
This (currently empty) function is meant to contain code that cleans up the left-overs of the test functions. This is needed by the next commit to reset the RAND_bytes sequence.
2015-10-13gprs: Use RAND_bytes for p-tmsiDaniel Willmann1-0/+1
[hfreyther: Link to libcrypto, include header, add uint8_t* cast]
2015-10-13sgsn/test: Really parse received DL LLC messagesJacob Erlbeck2-27/+61
Currently just the number of intercepted downlink messages is counted and eventually checked. The contents of the messages is lost. The PTMSI contained in ATTACH/RAU Accept messages is just 'guessed' by resetting the random number generator after reference PTMSIs have been generated. While this works with rand_r, RAND_bytes cannot be forced to recreate a certain number sequence this way (unless the backend is replaced). This commit changes that behaviour so that the last received msgb is kept and decoded. The PTMSI that has been assigned by the SGSN is then taken in the affected test cases and used instead of a 'guessed' one. This is similar to how a real MS would react to the Accept message. Sponsored-by: On-Waves ehf
2015-10-13sgsn/test: Add and call cleanup_test functionJacob Erlbeck1-0/+46
This (currently empty) function is meant to contain code that cleans up the left-overs of the test functions. This will be needed by the next commit that will store the last received msgb for later inspection. Sponsored-by: On-Waves ehf
2015-10-12Revert "gprs: Use RAND_bytes for p-tmsi"Holger Hans Peter Freyther1-1/+0
The commit not compiling/linking should have been a strong indicator that it has not been tested either. This reverts commit 6cf0249dacc4ae46eb0857c007906c9a3f128a3e.