aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gprs/gtphub.c
AgeCommit message (Collapse)AuthorFilesLines
2015-12-03gtphub: add explicit cleanup handles.Neels Hofmeyr1-0/+57
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: ensure cleanup of peer addresses.Neels Hofmeyr1-0/+1
Upon calling gtphub_peer_del(), all addresses and ports should already have expired (by force). Make sure the code heeds that with a so far missing assertion. Sponsored-by: On-Waves ehi
2015-12-03gtphub: ares vty and initNeels Hofmeyr1-2/+8
From sgsn_vty.c, copy the cfg_grx_ggsn_cmd to add an ares server to the static sgsn_instance. This is sort of preliminary. As described in comments, the sgsn_ares functions should actually be separated from the static sgsn structure. gtphub keeps such an sgsn structure just for the sgsn_ares functions. Sponsored-by: On-Waves ehi
2015-12-03gtphub: nr_map: add min,max and wrap.Neels Hofmeyr1-9/+12
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-7/+8
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-26gtphub: remove another obsolete comment.Neels Hofmeyr1-69/+0
2015-11-24gtphub: fix ares segfault: add missing initialization.Neels Hofmeyr1-0/+2
The struct gtphub_resolved_ggsn was not initialized properly, so that adding it to a list caused a segmentation fault.
2015-11-20gtphub: fix echo reply to SGSNs: wrong fd. Add test.Neels Hofmeyr1-1/+1
The actual fix is just one character, but also add a regression test against this, on both CTRL and USER plane.
2015-11-18gtphub: fix three oversights (thanks to coverity).Neels Hofmeyr1-5/+3
- an unnecessary if-not-NULL check (1339764); - a missing nul termination safety net (1339768); - a typo resulting in the wrong proxy being logged (1339767). Sponsored-by: On-Waves ehi
2015-11-18gtphub: fix fatal log msg for SGSN proxy.Neels Hofmeyr1-1/+1
While reworking the logging, a stray comma found its way into the code. Fixes coverity 1339765. Sponsored-by: On-Waves ehi
2015-11-18gtphub: fix gtphub_read() semantics.Neels Hofmeyr1-9/+7
gtphub always wants to know the sender, hence make the from_addr pointer mandatory. Fixes two coverity complaints (1339766, 1339764). Sponsored-by: On-Waves ehi
2015-11-16gtphub: cosmetic: break long lines.Neels Hofmeyr1-51/+96
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: review log levels, add level arg to LOG().Neels Hofmeyr1-141/+133
For maintenance, it is convenient to have the log level explicit at each log statement. Tweak some log levels / message formatting while at it. Sponsored-by: On-Waves ehi
2015-11-16gtphub: add logging labels to bind struct.Neels Hofmeyr1-1/+7
Allow logging the plane (Ctrl/User) and side (SGSN/GGSN) in functions that only have a gtphub_bind* to work with, by adding a constant label to each bind. Sponsored-by: On-Waves ehi
2015-11-16gtphub: don't always try to do GGSN resolution.Neels Hofmeyr1-27/+3
If a GGSN is already known from unmapping, don't invoke a host resolution. In a live working environment, it wouldn't hurt, because the lookups would mostly return from the cache. But in a testing environment without a name server, it barfs on every packet. Sponsored-by: On-Waves ehi
2015-11-16gtphub: fix numerous segfaults, and other stupidities.Neels Hofmeyr1-4/+4
Initialize llist_heads to empty (2 were missing). Move those for struct gtphub instances to gtphub_zero() (one moved, one added). In from_[gs]gsns_read_cb(), use a return type that can actually reflect negative return values. resolved_addr.buf: no need to take the address of a byte array var (cosmetic). Pass the proper user data address to sgsn_ares_query(), not the address of the pointer holding the user data address. Initialize ggsn_lookup->expiry_entry (was missing). Publish the function for that in gtphub.h so gtphub_ext.c can use it. Sponsored-by: On-Waves ehi
2015-11-16gtphub: Add logging for ares queries.Neels Hofmeyr1-6/+7
Looking for a segfault, I added a lot of logging. This may be useful for live testing ares, leaving it in there for now. Note: I still want to clean up the logging concerning log levels etc. once we're out of alpha. Sponsored-by: On-Waves ehi
2015-11-16gtphub: fix handling of sender from nonstandard port.Neels Hofmeyr1-3/+35
Allow a peer sending from an unknown port but a known address, and just create the port (and unmap the seq nr back to this port later to return the response to the sender). Only an SGSN on the Ctrl plane is allowed to make the very first contact from an unknown address. Sponsored-by: On-Waves ehi
2015-11-16gtphub: fix User plane decoding, add unit test.Neels Hofmeyr1-16/+37
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-2/+0
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: add/fix IMSI and APN IE error handlingNeels Hofmeyr1-22/+66
Sponsored-by: On-Waves ehi
2015-11-16gtphub: fix Echo behavior: respond directly.Neels Hofmeyr1-27/+59
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 Hofmeyr1-58/+93
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 Hofmeyr1-0/+2080
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