aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gprs
AgeCommit message (Collapse)AuthorFilesLines
2014-08-24gbproxy: Parse Detach Request messagesJacob Erlbeck1-4/+43
GSM 24.008 also allows a P-TMSI field in Detach request messages. This patch adds gbprox_parse_gmm_detach_req() to parse Detach Request messages which sets the ptmsi field if the IE is present. In addition, when power_off is set to 1 (MO only), the invalidate_tlli field is set, since Detach Request message is expected in this case. The second detach test (see 'RA update') is modified to use power_off instead of relying on a Detach Accept from the network. To make this work, the PTMSI of the RA Update Accept is fixed to match the TLLI of the Detach Request. Sponsored-by: On-Waves ehf
2014-08-22gbproxy: Add gbprox_clear_patch_filter() (Coverity)Jacob Erlbeck2-6/+11
Add a separate function to clear the IMSI filter to be used instead of gbprox_set_patch_filter(cfg, NULL, ...). Albeit it fixes a Coverity issue (Unchecked return value), it is a false positive, since the return value is always 0 in these cases. Nevertheless it is more obvious what happens when an explicit clear function is called. Using NULL as filter argument of gbprox_set_patch_filter still clears the filter. Fixes: Coverity CID 1231255 Sponsored-by: On-Waves ehf
2014-08-21libctrl: Follow rename of controlif_setup -> ctrl_interface_setupHarald Welte1-1/+1
2014-08-21libctrl: Move bulk of node lookup code into libosmocoreHarald Welte1-61/+1
Now that the bulk of the control interface node lookup has no reference to the BSC specific data structures, we are moving it into libosmocore. A control interface user now only registers an optional small node lookup function like bsc_ctrl_node_lookup()
2014-08-21move libctrl from openbsc to libosmoctrl (libosmocore.git)Harald Welte3-6/+6
2014-08-13gbproxy: Pass tlli_info aroundJacob Erlbeck1-23/+55
This patch modifies the code to pass a pointer to the tlli_info around once it has been acquired. To achieve this, gbprox_register_tlli() and gbprox_update_state() are modified to return it (if it has been found or created), and gbprox_patch_llc(), gbprox_patch_bssgp(), and gbprox_update_state_after() are modified to take it as parameter. Add a new function gbprox_touch_tlli() to update timestamp and list ordering for existing tlli_infos. The motivation behind this patch is to make the tlli_info available to the patching code and to avoid repeated searches for the same TLLI. Sponsored-by: On-Waves ehf
2014-08-13gbproxy: Optimize gbprox_remove_stale_tllisJacob Erlbeck1-15/+33
The current implementation of this function is O(N), where N is the number of entries. The new implementation is O(D), where D is the number of entries that are going to be deleted. Sponsored-by: On-Waves ehf
2014-08-13gbproxy: Don't call time() in TLLI related functionsJacob Erlbeck1-12/+10
Currently time() is called at several places to control TLLI aging. Beside calling time() more often than necessary, the decision which timesource is to be used is coded into the TLLI handling, and testing complex aging scenarios is cumbersome. This patch passes the current time as a parameter instead. The call to time() is moved to gbprox_process_bssgp_message(). Sponsored-by: On-Waves ehf
2014-08-13gbproxy: Don't remove stale TLLI automaticallyJacob Erlbeck1-14/+16
This patches removes the call to gbprox_remove_stale_tllis() from gbprox_register_tlli(), so it must be called explicitly now. The call is now done from within gbprox_update_state_after(). In addition, the TLLI cache size counter is also kept in sync when gbprox_remove_stale_tllis is called manually. The call to gbproxy_peer_free() in gbproxy_peer_free() is moved behind the TLLI to allow for counter updates in gbprox_delete_tlli(). Sponsored-by: On-Waves ehf
2014-08-13gbproxy: Move parse_ctx logging into separate functionJacob Erlbeck1-30/+50
Sponsored-by: On-Waves ehf
2014-08-13gbproxy: Refactor gbproxy_patch_bssgp_messageJacob Erlbeck1-56/+81
This patch refactors that function by separating the actual patch code into a new function gbproxy_patch_bssgp(), similar to gbproxy_patch_llc(). The remaining function is renamed to gbproxy_process_bssgp_message. The existing function gbproxy_parse_bssgp_message() is renamed to gbproxy_process_bssgp_message to match gbproxy_parse_llc. Sponsored-by: On-Waves ehf
2014-08-13gbproxy: Test and fix IMSI/TMSI matchingJacob Erlbeck1-6/+8
This adds a test for gbprox_set_patch_filter() and gbprox_check_imsi(). It also fixes the masking of the type field when IMSIs are checked by using GSM_MI_TYPE_MASK (0x07) instead of 0x0f. Sponsored-by: On-Waves ehf
2014-08-13gbproxy: Track TLLI even when the IMSI is not knownJacob Erlbeck2-40/+66
Currently only TLLIs for which it is known that they may be patched are put into the TLLI list. This patch changes this to add TLLIs even when the IMSI is not yet known. A enable_patching flag is added to the gbproxy_tlli_info structure to control patching. Note that this puts every active TLLI into the list where accesses are O(N) currently. Sponsored-by: On-Waves ehf
2014-08-13gbproxy: Make pointers to MI const in parse/check functionsJacob Erlbeck1-3/+5
The encoded mobile identity will never be modified in is_mi_tmsi/is_mi_imsi/parse_mi_tmsi, thus the pointer is made const. Sponsored-by: On-Waves ehf
2014-08-13gbproxy: Explicitly convert PTMSI to TLLIJacob Erlbeck1-3/+6
This patch modifies the new_ptmsi handling by setting its two most significant bits before using it as TLLI. Sponsored-by: On-Waves ehf
2014-08-13gbproxy: Parse additional IMSI/PTMSI/TLLI fieldsJacob Erlbeck1-9/+70
This adds parsing support for the following messages: - Attach Request: IMSI/PTMSI - Identity Response: IMSI/PTMSI - BSSGP: Optional TLLI IE - BSSGP/PAGING_PS: PTMSI A new new_ptmsi_enc field is added for newly assigned PTMSI in SGSN->BSS messages (instead of ptmsi_enc). The ptmsi_enc field is now used for informational PTMSI IE in messages. Sponsored-by: On-Waves ehf
2014-08-12gbproxy: Separate BSSGP parsing from patchingJacob Erlbeck1-123/+183
This adds a gbprox_parse_bssgp_message() function that contains the parsing part of the former gbprox_patch_bssgp_message(). This includes a call to gbprox_parse_llc(). The calls to gbprox_patch_llc(), gbprox_update_state() and gbprox_update_state_after() have therefore been moved to gbprox_patch_bssgp_message(). Sponsored-by: On-Waves ehf
2014-08-12gbproxy: Unify TLLI trackingJacob Erlbeck1-76/+121
This patch unifies the TLLI tracking for all LLC messages. The TLLI state handling is moved into separate functions. Only Detach Accept messages are taken into account to release a TLLI, which is safe but not optimal. Sponsored-by: On-Waves ehf
2014-08-12gbproxy: Move patching code out of the 04.08 specific functionsJacob Erlbeck1-94/+133
Currently, parsing and optionally patching is done in the same functions (e.g. gbprox_patch_gmm_attach_req()). This patch moves the patching code out of these functions into gbprox_patch_llc() and just stores pointers to the relevant data areas into parse_ctx. Consequently the len_change parameter is removed and the _patch_ in the function's names is renamed to _parse_. In addition, the patching_is_enabled checks and counter increments are moved out of these functions, too. Sponsored-by: On-Waves ehf
2014-08-08gbproxy: Track all TLLIs (not only LOCAL)Jacob Erlbeck1-5/+0
This patch removes all checks for the TLLI type. Sponsored-by: On-Waves ehf
2014-08-05sgsn: Make P-TMSI a local TLLI to avoid clashHolger Hans Peter Freyther1-1/+1
Some broken equipment does not convert the P-TMSI to a Local TLLI. This leads to the SGSN ignoring the GPRS Attach Complete message from the phone. Proprietary SGSNs and some documentation we found state that one should always set the two highest bits of a P-TMSI to one. This will help broken equipment and will avoid a potential P-TMSI/TLLI clash. The P-TMSI/Local TLLI mapping is now bijective.
2014-08-05gprs: Refactor gbprox_register_tlli()Jacob Erlbeck1-32/+54
Currently gbprox_register_tlli() is a rather complex function. This patch splits it into several smaller functions to ease reviewing and maintaining it. Sponsored-by: On-Waves ehf
2014-08-05gbproxy/test: Test TLLI expiryHolger Hans Peter Freyther1-7/+7
This adds a unit test for gbprox_register_tlli() and gbprox_remove_stale_tllis(). The dump_peers() function is extended by a cfg parameter to support a non-global gbproxy_config. Done with Jacob
2014-08-04gbproxy: Remove broken TLLI comparisonJacob Erlbeck1-1/+0
This comparison bit-ored the TLLI with 0xc000 instead of 0xc000000. Since this has never worked properly yet and since normalizing to local TLLIs doesn't seem sensible here, the comparison is removed entirely. Sponsored-by: On-Waves ehf
2014-08-04gbproxy: Kill the global gbprox_global_patch_state structHolger Hans Peter Freyther2-20/+15
Move this patching state into the gbproxy_config as well. Done by Jacob
2014-08-04gbproxy: Add a hint to the compiler that all parameters are not NULLHolger Hans Peter Freyther1-0/+8
In these functions we assume that peer is not NULL. Add a compiler attribute in the hope that either coverity or GCC/Clang will help us to find a misusage. Done with Jacob
2014-08-04gbproxy: Remove global state from the gbproxyHolger Hans Peter Freyther3-123/+131
Global state prevents us from writing simple units tests for single routines. Go through the code and add pointers to the gbproxy configuration. Only the vty and the test code remain using the global gbproxy instance.
2014-08-04gprs: Add testcases for the APN string/octet conversion and fix itHolger Hans Peter Freyther2-6/+18
Create a testcase for the gprs_str_to_apn and gprs_apn_to_str routines. While writing the testcase we noticed it is possible to write more bytes than should have been allowed. This is fixed by checking that the max_len is at least 1 (needed to write the first length octet) and to do the size check before writing to the output. Modify the signature of gprs_str_to_apn to put the length/size next to the parameter that requires a size. Done with Jacob
2014-08-04gbproxy: Use gbprox_delete_tlli if possibleHolger Hans Peter Freyther1-8/+4
Make use of the delete routine in more places and get test coverage for it. Done with Jacob
2014-08-04gprs: Create a gprs_utils file and move to be shared code in thereHolger Hans Peter Freyther4-134/+164
We intend to move some of these routines to libosmocore but to avoid a feature symbol clash we are prefixing these routines with gprs_. Done with Jacob
2014-08-04gbproxy: Use gbproxy_ for all structuresHolger Hans Peter Freyther2-86/+86
The application is called gbproxy but the structures and functions were inconsistently named as either gbprox or gbproxy. Rename all structures to use gbproxy. Done with Jacob
2014-08-04gbproxy: The dump routines are only used by the test, move it thereHolger Hans Peter Freyther1-92/+0
Done with Jacob
2014-08-04gbproxy: Have a clear namespace for the public functionsHolger Hans Peter Freyther2-5/+5
Done with Jacob
2014-08-04gbproxy: Remove the global rate counter and place it in the configHolger Hans Peter Freyther2-32/+22
Move the global data into the struct and use it. gbprox_reset will first free data and then re-initialize the structure. This code is used by the unit test. Done with Jacob
2014-08-04gbproxy: Correct the method name. We work on TLLIsHolger Hans Peter Freyther2-3/+3
Done with Jacob
2014-08-04gbproxy: Move the VTY code into the vty file and create public APIHolger Hans Peter Freyther3-289/+254
Create public accessors to the core of the peer to allow to simplify the test and separate concerns. Done with Jacob.
2014-07-22gprs: Move LLC IE length fix to BSSGP levelJacob Erlbeck1-20/+35
This commit moves the fixing code of the length field of the LLC information element to the BSSGP patching level since that is not a part of LLC itself. Sponsored-by: On-Waves ehf
2014-07-22gprs: Parse PTMSI and update TLLI accordinglyJacob Erlbeck1-2/+54
This commit adds code to parse the PTMSI in network originated messages - Attach Accept, - Routing Area Update Accept, and - P-TMSI Reallocation Command (see below) to keep track of the TLLI identifying the LLC connection. The P_TMSI Realloc Command specific code is not being tested yet, so a corresponding notice is logged when such a message will be received. NOTE: The gbproxy will lose the TLLI when the MS doesn't receive/use the message (normally the SGSN remembers the old TLLI for some time to avoid this kind of problem). If this happens the MS will probably restart the procedure and the network will have to answer again eventually using one of the above messages which will re-associate the IMSI with the TLLI before the MS can send a PDP Context Request message. Ticket: OW#1192 Sponsored-by: On-Waves ehf
2014-07-22gprs: Use struct to pass context informationJacob Erlbeck1-36/+63
Add a struct containing context information from the parts of the message that have been parsed already. A pointer to this (temporary) struct is passed to parse/patch functions. Sponsored-by: On-Waves ehf
2014-07-22gprs: Use shift functions instead of manual parsingJacob Erlbeck1-76/+60
Currently the patching code directly accesses the single bytes to parse the LLC/DTAP messages. This patch uses the shift functions instead to parse tlv and similar structures. Sponsored-by: On-Waves ehf
2014-07-22gprs: Add TLV parse functionsJacob Erlbeck1-0/+116
This adds a set of function that parse a single tlv, lv, tv, or v encoded information element. They are complementary to the *_put functions defined in libosmocore's tlv.h file. The functions update the data and data_len fields unless they are a 'match' function and the tag field doesn't match. Sponsored-by: On-Waves ehf
2014-07-22gprs: Fix TLLI cache size computationJacob Erlbeck1-1/+6
Currently the enabled_tllis_count field isn't always decremented when an element is removed from the TLLI cache list. This patch adds the missing update and also adjusts the counter accordingly. Sponsored-by: On-Waves ehf
2014-07-22gprs/test: Rearrange for PTMSI parsingJacob Erlbeck1-0/+20
Add TLLI cache output to gbprox_dump_peers() to include this info into the test output. Separate RA Update Req message handling from Attach Request handling. Note: There is no test case for the P-TMSI Reallocation Command yet. Sponsored-by: On-Waves ehf
2014-07-22gprs: Add counters related to LLC layer patchingJacob Erlbeck1-0/+15
This commit adds the following counters: - attach-reqs: Number of Attach Request messages - attach-rejs: Number of Attach Reject messages - tlli-cache: Size of the TLLI cache Sponsored-by: On-Waves ehf
2014-07-22gprs/vty: Add commands to manage the TLLI listJacob Erlbeck2-0/+112
These commands manage the TLLI list used to decide whether an APN shall be patched or not. Note that this list is (currently) only maintained if IMSI matching is used. VTY commands (enable node): show gbproxy tllis show all TLLI entries delete-gbproxy-tlli NSEI stale purge all stale entries delete-gbproxy-tlli NSEI imsi IMSI purge entry with the IMSI given delete-gbproxy-tlli NSEI tlli TLLI purge entry with the TLLI given Sponsored-by: On-Waves ehf
2014-07-22gprs: Track IMSI/TLLI to control APN patchingJacob Erlbeck2-41/+444
This patch adds IMSI/TLLI connection tracking and uses it to control APN patching based on the IMSI. TLLI entries can expire based on age and/or by limiting the TLLI list size. VTY config-gbproxy: no core-access-point-name disable APN patching core-access-point-name none remove APN if present core-access-point-name APN replace APN if present core-access-point-name none match-imsi RE remove if IMSI matches core-access-point-name APN match-imsi RE replace if IMSI matches tlli-list max-age SECONDS expire after SECONDS no tlli-list max-age don't expire by age tlli-list max-length N keep N entries only no tlli-list max-length don't limit list length RE is an extended regular expression, e.g. ^12345|^23456 Ticket: OW#1192 Sponsored-by: On-Waves ehf
2014-07-22gprs: Store gbproxy patching state per peerJacob Erlbeck1-63/+132
Currently, all patching state is stored globally in the gbproxy. Thus the feature cannot be used safely with a concentrating gbproxy (NAT). This patch moves the state and relevant counters to the gbprox_peer structure. It adds code to resolve the corresponding peer when packets are received by looking at BVCI, NSEI, and BSSGP IEs (BVCI, RAI/LAI/LAC) when the peer is not passed to the gbprox_patch_bssgp_message() function. Test cases are also added for the SGSN->BSS case including test cases with invalid identifiers. Note that this patch should make it possible to use RAI patching at a NAT gbproxy as long as the messages are not encrypted. Ticket: OW#1185 Sponsored-by: On-Waves ehf
2014-07-22gprs: Add APN patch support for LLC/GSM messagesJacob Erlbeck2-4/+264
Patch the APN in every 'Activate PDP Context Request' message to the value given by the 'core-access-point-name' command. If the command is given without an APN, the whole APN IE will be removed. If the command is being prefixed by a 'no', the APN IE remains unmodified. The patch mode 'llc-gsm' is added to selectively enable the patching of LLC session management messages. This is enabled implicitely by the patch mode 'llc'. Note that the patch mode should not be set to a value not enabling the patching of LLC GSM messages ('llc-gsm', 'llc', and 'default' are sufficient to patch 'Activate PDP Context Request' messages). Ticket: OW#1192 Sponsored-by: On-Waves ehf
2014-07-22gprs: Add MCC/MNC patch support for LLC/GMM messagesJacob Erlbeck2-1/+327
This patch extends the BSSGP patch code to also patch LLC information elements along with MCC/MNC patching support for the following messages: - Attach Request - Attach Accept - Routing Area Update Request - Routing Area Update Accept - P-TMSI reallocation command Note that encrypted packets will not be patched. Ticket: OW#1185 Sponsored-by: On-Waves ehf
2014-07-22gprs: Implement BSSGP MCC/MNC patchingJacob Erlbeck4-2/+187
This adds a feature to patch the BSSGP MNC/MCC fields of messages going to and coming from the SGSN. To enable this feature, the gbproxy's VTY commands 'core-mobile-country-code' and/or 'core-mobile-network-code' must be used. All packets to the SGSN are patched to match the configured values. Packets received from the SGSN are patched to the corresponding values as last seen from the BSS side. Note that this will probably not work with a gbproxy used for several BSS simultaneously. Note also, that MCC/MNC contained in a LLC IE will not be patched. Ticket: OW#1185 Sponsored-by: On-Waves ehf