aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/include
AgeCommit message (Collapse)AuthorFilesLines
2015-12-03gtphub: cosmetic: fix an argument name.Neels Hofmeyr1-1/+1
Sponsored-by: On-Waves ehi
2015-12-03gtphub: first vty show commands.Neels Hofmeyr1-1/+2
Start adding VTY commands to show rate counters / statistics / cache dumps. Sponsored-by: On-Waves ehi
2015-12-03gtphub: add first rate countersNeels Hofmeyr1-0/+2
Sponsored-by: On-Waves ehi
2015-12-03gtphub: add explicit cleanup handles.Neels Hofmeyr1-0/+7
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: cosmetic: rename a file.Neels Hofmeyr1-1/+1
gtphub_ext.c's initial purpose was to wrap a specific function. The file then turned into everything related to DNS, which fits pretty well. Rename to gtphub_ares.c. Tweak the header comment to reflect the new file name. Sponsored-by: On-Waves ehi
2015-12-03gtphub: nr_map: add min,max and wrap.Neels Hofmeyr1-2/+9
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-1/+1
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-24gtphub: lose obsolete comment.Neels Hofmeyr1-2/+0
The del_cb is now also used for ares (GGSN resolution) timeouts, and expiry is anyway separated from nr_map, so this comment is void. Sponsored-by: On-Waves ehi
2015-11-20gtp: Fix Makefile.am so maybe distcheck is now going to workHolger Hans Peter Freyther1-1/+1
2015-11-20Fix TSC/BSIC handling bug and remove bts->tscHarald Welte2-6/+4
This fixes a bug in the following circumstances: * BSIC is set to 0 in the config file * No TSC is explicitly specified at the BST level in the config file In this case, we ended up using BSIC=0 and TSC=7, as TSC=7 is our default initialization value. The TSC of the CCCH/BCCH must always be the BCC, which is the lower 3 bits of the BSIC. Having configuration options for both the BSIC _and_ the TSC at the BTS level therefore makes no sense, as it only adds ways in which users can configure non-oprational configurations. So we remove the bts->tsc member, and keep only the ts->tsc members that allow us to configure a timeslot-specific TSC that's different from the BTS TSC (= BCC).
2015-11-16gtphub: cosmetic: break long lines.Neels Hofmeyr1-5/+9
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: add logging labels to bind struct.Neels Hofmeyr1-0/+2
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: fix numerous segfaults, and other stupidities.Neels Hofmeyr1-0/+3
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: make test code reusable for future tests.Neels Hofmeyr1-0/+4
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 Hofmeyr1-0/+4
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-0/+28
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 Hofmeyr4-0/+427
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/+16
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-02gsup/oap: add OAP to GSUP client.Neels Hofmeyr2-1/+9
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: implement initial OAP API.Neels Hofmeyr3-1/+150
Add oap.[hc] and oap_messages.[hc]. Sponsored-by: On-Waves ehf
2015-11-02libcommon: soak up three static functions.Neels Hofmeyr2-1/+27
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 Willmann1-4/+0
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-12osmux: Allow to listen to a specific addressHolger Hans Peter Freyther1-0/+2
For a setup with multiple network interfaces be able to pick the one that osmux should be used/visible.
2015-10-12mgcp: Use the right bind addresses for NET and BTS0.15.0Holger Hans Peter Freyther1-4/+4
This API is a bit unfortunate as the caller will also access the endpoint directly. E.g. like this: output = bsc_mgcp_rewrite(..., mgcp_net_src_addr(endp), endp->net_end.local_port, -1, In terms of "terminology" the "net" was meant to be bad internet and the "bts" is the local and trusted network segment. With this terminology the "bts" would be the call-agent/MGW and "net" where the BSCs will send data to but that is not the case and terminology actuallys refers to: * net: The addresses exposed to the entity that made the MGCP call * bts: The system where we get our data for the local audio flow. Fix the method but leave the API as it is. Use the net_end in the net_src method and the bts_end in the bts_src method.
2015-10-12osmux: Remember the allocated CID and make sure it is releasedHolger Hans Peter Freyther2-0/+4
There appears to be a leak of CIDs: <000b> mgcp_osmux.c:544 All Osmux circuits are in use! There are paths that a CID had been requested and never released of the NAT. Remember the allocated CID inside the endpoint so it can always be released. It is using a new variable as the behavior for the NAT and MGCP MGW is different. The allocated_cid must be signed so that we can assign outside of the 0-255 range of it. Fixes: OW#1493
2015-10-12osmux: Allow to enforce using Osmux for the clientHolger Hans Peter Freyther1-0/+6
Some systems only want to use Osmux. In case only Osmux should be used fail if it has not be offered/acked. Client: Verified On, Off and Only with X-Osmux: 3 and without this field. <000b> mgcp_protocol.c:823 Osmux only and no osmux offered on 0x14 <000b> mgcp_protocol.c:884 Resource error on 0x14 NAT: Not tested and implemented Fixes: OW#1492
2015-10-12osmux: Test cid allocation and de-allocationHolger Hans Peter Freyther1-0/+1
* Test that one can get an id * That they are assigned predicatble right now * That returning them will make the number of used ones go down * That allocating more will fail
2015-10-02amr: Attempt to unbreak the AMR support in the BSCHolger Hans Peter Freyther1-1/+1
The signature of mr_config and the BSC implementation didn't match and the compiler was warning about it: osmo_bsc_api.c:530:2: warning: initialization from incompatible pointer type .mr_config = bsc_mr_config, ^ osmo_bsc_api.c:530:2: warning: (near initialization for ‘bsc_handler.mr_config’) Change the mr_config again and provide an implementation that will set the ms and bts data structure. It would be better to put the size outside of the IE but I am not going to change it right now. It would also be nice to either move the AMR setting into the "nitb" structure or have the msc data be used _after_ the bts settings. This needs to be cleaned up in the next step. Manually verified by placing a MO call and checking that both the channel mode modify and the mode modify request contain the multi rate config with the rate mr config (length two bytes, version 1, icmi==1, no start mode being set).
2015-10-02amr: Instead of putting ms/bts into the same struct.. use it twiceHolger Hans Peter Freyther2-6/+7
This way a lot of if/else can just be killed by the caller deciding which of the two instances to use. I have copied both branches to new files, replace bts for ms in one of them and ran diff on it. There is no difference.
2015-09-22Add full AMR multirate IE support with VTY config for MS and BTS sideAndreas Eversberg3-4/+15
2015-09-14mncc: Use the default codec from the built-in mncc modezecke/features/rtp-bridgeHolger Hans Peter Freyther1-0/+2
In case of the RTP bridge mode we need to select the codec ourselves. Rely on the same (incomplete) codec selection that can be done using the mncc-int configuration node. This might gain bearer capabilities support. In case of a SDCCH a TCH/F will be attempted to be assigned. This is an open issue for both modes and there should be a preference for full or half-rate channels somewhere.
2015-09-14mncc: Implement CRCX->MDCX for handover for direct rtp modeHolger Hans Peter Freyther1-0/+1
Implement sending MDCX on the newly allocated channel and send the data to the same destination as the currently connected one. This way the receiver can implement RTP RFC Appendix A.1 and deal with the new source.
2015-09-14mncc: Implement the direct RTP mode for ip based systemsHolger Hans Peter Freyther1-0/+4
For the LCR rtp-bridge audio should directly flow to the remote system. In contrast to the original patch audio will now flow directly from the BTS to the remote system. This assumes that BTS and the remote system are in the same network segment and can directly communicate. There are various limitations in the first iteration of the implementation: We could (and in the future) should delay the assignment but currently we are forced to pick the channel and move it to the audio state. In case we are located on a SDCCH we always need to change but if we are on a TCH we could send the ipa.CRCX and change the audio state a lot later. The net effect is that the audio codec selection needs to be done in the NITB code and not in the system connected to it. This only works with ip based systems. For E1 systems one could still use the RTP socket or even try to move this out of the process. There is no code for handover handling and it relies on the remote system dealing with the SSRC change of the system.
2015-09-14mncc: Update the protocol to match LCRHolger Hans Peter Freyther1-1/+13
This adds the protocol definition for the RTP bridge extension of Andreas Eversberg and bumps the protocol version. I added the missing mncc mappings from value to string. [ 5cf8fb10ea3addcae74d37f4dbf1c1be664df53e protocol extension 5dac90de38990b188f499c602bf18a4f232070e8 payload extension]
2015-09-14msc: Add channel information to the meas_feed, bump version to v1.Alexander Chemeris1-1/+13
2015-08-20mgcp: Allow to bind to different ports for net/bts portsHolger Hans Peter Freyther2-0/+7
When using multiple interfaces on a system one can now configure which will be served for the BTS ports and which will be served for the network. The direct usage of source_addr is now only to initialize the MGCP receiving port itself.
2015-08-20mgcp: Begin to separate network and bts endpointsHolger Hans Peter Freyther1-0/+14
Make it possible to bind the call-agent to a specific IP address and the network and bts end to different ip addresses. Begin by clarifying which source ip address we want to have.
2015-08-19mgcp: Add transcoding from PCMU as wellHolger Hans Peter Freyther1-1/+2
Use the existing ulaw encode/decode to support PCMU as well. The MERA VoIP switch has some severe issues with the GSM codec and it appears easier to enable transcoding for it. The mera switch doesn't appear to cope with codec change between a SIP 180 trying and the 200 ok connection result. Inserting the codec is touching too many places. Ideally we should have the transcoding function as pointer in the struct as well but the arguments differ.. so it is not a direct way forward.
2015-08-19osmux: add option to pad the circuit with dummy messagesPablo Neira Ayuso1-0/+4
Iridium is a satellite network which operates a GPRS-like that allows you to get speeds up to 128kbit/s. However, it takes from 5 to 6 secs to get the bandwidth allocated, so the conversation is garbled during the time. This patch uses the new dummy padding support in libosmo-netif that is controlled through the osmux osmux_xfrm_input_open_circuit(). This includes a new VTY option for osmux.
2015-08-18sgsn: make all SGSN timers configurable via the VTYHarald Welte1-0/+15
2015-08-17Add option to set RADIO LINK TIMEOUT value via VTYAndreas Eversberg1-0/+14
2015-08-14mgcp: Allow to enforce that the codecs need to matchHolger Hans Peter Freyther1-1/+1
We have a lot of legacy that I am afraid to break. We have everything in place to make a good codec selection (e.g. if we can avoid transcoding, pick the one with best quality or the lowest speed). Right now I have a specific case where from all options I want to pick GSM. Guard the codec compat check behind the disallow transcoding option to make sure to not break legacy application.
2015-08-14mgcp: Move the SDP handling into a separate file/moduleHolger Hans Peter Freyther1-0/+61
The SDP file handling will get more complicated in terms of codec selection so let's remove it from the protocol handling before we start blowing it up in size.
2015-08-14mgcp: Remove unused parsing data structHolger Hans Peter Freyther1-3/+0
This struct was removed when we switched to strtok_r for parsing the data. Remove the left-over.
2015-08-13nat: Forward SDP files with multiple payload types in itHolger Hans Peter Freyther1-1/+1
The parsing code assumed that there will be a single payload type and this assumption is clearly wrong. Forward all of the payload types. The code is still only extracting the first type from the list. The variable name has been renamed to reflect this.
2015-08-01nitb: Add a mode to not use TMSI for normal operationHolger Hans Peter Freyther1-0/+3
In case foreign simcards are used we can not do authentication and ciphering. In case a TMSI is re-used too early and we do page using TMSI we can't know which of the two MS is responding to us. We could change the "secure channel" routine to ask for the IMSI and only then stop the paging. As we don't have ciphering there is not much use in using the TMSI. Add a mode "no assign-tmsi" that will not assign the TMSI during LU. Now CM Service Request and Paging Response will work using the IMSI. There can't be a clash with that. [ciaby fixed the vty write to use the right name]
2015-08-01mgcp: Include enough socket data structures to build on freebsdHolger Hans Peter Freyther1-0/+3
in_address is not 'accidently' included by FreeBSD when we include the osmocom/core/select.h header file. We need to include a bit more. In file included from mgcp_protocol.c:38: ../../include/openbsc/mgcp_internal.h:134:21: error: field has incomplete type 'struct sockaddr_in' struct sockaddr_in forward;
2015-07-13bsc: Rename core_ncc to core_mncHolger Hans Peter Freyther1-1/+1
Struct osmo_msc_data contains int core_ncc, which is actually the MNC part of the PLMN, not to be confused with the Network Colour Code. The following patch renames this field for clarity and consistency with the standards.
2015-07-01nat: Use RAND_bytes instead of /dev/urandomHolger Hans Peter Freyther1-3/+0
We don't need to consume all the entropy of the kernel but can use libcrypto (OpenSSL) to generate random data. It is not clear if we need to call RAND_load_file but I think we can assume that our Unices have a /dev/urandom. This takes less CPU time, provides good enough entropy (in theory) and leaves some in the kernel entropy pool.
2015-07-01nat: After we identified the bsc check the keyHolger Hans Peter Freyther1-0/+2
We are using the token to find the right bsc_config and then we can use the last_rand of the bsc_connection to calculate the expected result and try to compare it with a time constant(???) memcmp.