aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gprs/gb_proxy.c
AgeCommit message (Collapse)AuthorFilesLines
2014-08-04gbproxy: Remove the global rate counter and place it in the configHolger Hans Peter Freyther1-31/+21
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 Freyther1-2/+2
Done with Jacob
2014-08-04gbproxy: Move the VTY code into the vty file and create public APIHolger Hans Peter Freyther1-289/+18
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 Erlbeck1-0/+110
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 Erlbeck1-12/+312
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 Erlbeck1-1/+197
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 Erlbeck1-1/+293
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 Erlbeck1-0/+132
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
2014-07-07gprs/test: Remove verbose parameter of gbprox_dump_* functionsJacob Erlbeck1-8/+2
This parameter is not used (the methods are always called with an argument of 1 in the third position). Thus the parameter is removed completely. Sponsored-by: On-Waves ehf
2014-06-15gprs: Use area terms LAI/RAI as defined in GSM 03.03Jacob Erlbeck1-27/+27
Currently the terms 'Routing area code' (RAC) and 'Location area code' (LAC) are used in several places where 'Routing area identification' (RAI) or 'Location area identification' (LAI) are meant in fact. This patch replaces RAC/LAC by RAI/LAI and 'code' by 'identification' at these places. Note that RAI := MCC MNC LAC RAC, and LAI := MCC MNC LAC (see GSM 03.03, sections 4.1 and 4.2). Sponsored-by: On-Waves ehf
2013-11-03gbproxy: The "[stats]" option was not documented, document itHolger Hans Peter Freyther1-1/+1
Documentation error (missing docs): <command id='show gbproxy [stats]'> <param name='[stats]' doc='(null)' />
2013-10-24gbproxy: Fix handling of NSEI changesJacob Erlbeck1-3/+6
The gbproxy looses NSEI changes on BVC_RESET and then tries to send later messages to the wrong (not longer existing) destination. This patch fixes this by updating the peer's nsei field on BVC_RESET. Ticket: OW#874 Sponsored-by: On-Waves ehf
2013-10-24gbproxy: Add test for NSEI and NSVCI changesJacob Erlbeck1-0/+11
This checks the behavior of the gbproxy when the BSS peer changes the NSEI and the NSVCI. It also tests BVC_RESET and other UNITDATA messages after these changes between BSS and SGSN and vice versa (via the gbproxy). Ticket: OW#874 Sponsored-by: On-Waves ehf
2013-10-24gbproxy/vty: Enhance delete-gbproxy-peer commandJacob Erlbeck1-22/+113
This adds the option to delete all BVC peers and/or NS_VC with a given NSEI with a single command. Static (configured) NS-VC are not affected. In addition, all connections for this NSEI that can be deleted by this command can be listed without deleting them by appending 'dry-run' to the command. Sponsored-by: On-Waves ehf
2013-10-24gbproxy: Add a command to delete peers from the GBProxyHolger Hans Peter Freyther1-2/+25
This just deletes the peer entry based on NSEI and BVCI. The NS-VC are not touched.
2013-10-24gbproxy: Fix rate counter group leak in peer_free()Jacob Erlbeck1-0/+1
This also frees the counter group pointed to by peer->ctrg when the peer gets freed. Sponsored-by: On-Waves ehf
2013-10-19gbproxy: Reject SGSN UNITDATA messages with an invalid BVCIJacob Erlbeck1-5/+7
Currently such messages lead to a creation of a new peer with the SGSN's NSEI, which results in echoing the message back to the SGSN. This patch modifies this by sending a STATUS response (invalid BVCI) instead back to the SGSN. Sponsored-by: On-Waves ehf
2013-10-19gbproxy: Test invalid BVCI from SGSNJacob Erlbeck1-1/+35
This adds a test with a UNITDATA SGSN message that is addressed to an invalid (unknown) BVCI. The test shows, that the message is echoed to the SGSN. Sponsored-by: On-Waves ehf
2013-10-19gbproxy: Add global and per peer countersJacob Erlbeck1-6/+165
This adds counters that are incremented when errors are detected. It also modifies the VTY command 'show gbproxy' so that 'show gbproxy stats' shows the counters. Sponsored-by: On-Waves ehf
2013-10-19gbproxy: Fix warning and log messageJacob Erlbeck1-1/+2
Add the unused attribute to peer_free() that isn't used currently. Change 'RAC' to 'NSEI' in the log message, since the latter has been examined before the log message is generated. Sponsored-by: On-Waves ehf
2013-10-15gbproxy: Replace NS-VC references by NSEIJacob Erlbeck1-60/+64
Currently in most places in gb_proxy.c a reference to a NS-VC object is used where the peer is meant instead. The patch changes this by using the NSEI instead in these cases. Sponsored-by: On-Waves ehf
2013-10-15gbproxy: Add test program to test gbproxy message handlingJacob Erlbeck1-0/+23
This program tests the gbproxy implementation by passing NS messages to a modified gbproxy that dumps the resulting messages, signals, and state. It focusses on testing abnormal situations like port changes. Ticket: OW#874 Sponsored-by: On-Waves ehf
2012-12-19misc: Fix compilation now that the method is located in libosmocoreHolger Hans Peter Freyther1-7/+0
These TLV helper functions are now located in libosmocore.
2012-09-11gbproxy: Address two unaligned memory access warningsHolger Hans Peter Freyther1-8/+14
The lines 461 and 303 were producing unaligned memory access as the BVCI was not aligned properly. Introduce a tlvp_val16_unal to read 16bit from the data, use memcpy to the stack to make sure that it is working in the aligned and unaligned case.
2012-06-17libgb: prefix all NS related functions with gprs_Harald Welte1-2/+2
2012-06-17libgb: don't call directly into GMM / LLC layerHarald Welte1-0/+5
Instead of direct function calls to individual functions, we now generate primitives (osmo_prim) and send them to one application-provided function "bssgp_prim_cb()"
2012-06-16libgb: Use library SS_L_NS instead lf local SS_NSHarald Welte1-1/+1
which removes some further dependencies of libgb to openbsc internal code and data.
2012-06-16libgb: move GPRS specific msgb CB definitions to separate headerHarald Welte1-3/+3
2012-06-16split libgb into a separate library for outside useHarald Welte1-2/+3
This also removes the dependency to osmo_sock() inside libcommon and replaces it with osmo_sock_* from libosmocore
2011-04-18misc: Remove sys/types.h includes from the filesHolger Hans Peter Freyther1-1/+0
These are not needed any more. We used them for u_int types but we now use uint which comes from stdint.h
2011-03-23src: use new library libosmogsm and new path to headers in libosmocorePablo Neira Ayuso1-2/+2
libosmogsm is a new library that is distributed in the libosmocore. Now, openbsc depends on it. This patch gets openbsc with this change. This patch also rewrites all include path to the new osmocom/[gsm|core] Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-02-06[gb_proxy] vty: display the BVC BLOCKED status in 'show gbproxy'Harald Welte1-4/+6
2011-02-06[gb_proxy] make sure bssgp cell id is copied correctlyHarald Welte1-1/+3
When we copy a msgb, we need to make sure the msgb_cb->bssgp_cell_id pointer points to data in the new message, not in the old message. Thanks to Dieter Spaar for spotting this.
2011-02-06[gb proxy] treat BVCI=1 consistently like signallingHarald Welte1-2/+2
1 is reserved for point-to-multipoint data, i.e. not a point-to-point BVCI.
2011-02-06[gb_proxy] Convert a NS-BLOCK from BSS into BVC-RESET to SGSNHarald Welte1-12/+31
As we only have one NS-VC between gb_proxy and SGSN, we cannot forward a NS-BLOCK from the BSS to the SGSN, as it would affect all other BSS's, too. Thus, we check if we have an unblocked PTP-BVC in the NSVC to the BSS, and then issue a BVC-BLOCK towards the SGSN. This should prevent any further PDU's from the SGSN to be sent to this BSS.
2011-02-06[gb_proxy] Track the state of blocked/unblocked BVC in the proxyHarald Welte1-13/+59
This allows us to reject any additional messages sent by the SGSN after the BVC was blocked (+ acknowledged to be blocked)
2011-01-01License change: We are now AGPLv3+ instead of GPLv2+Harald Welte1-6/+5
The reason for this is quite simple: We want to make sure anyone running a customized version of OpenBSC to operate a network will have to release all custom modifiations to the source code.
2010-10-06misc: Once again go from "On Waves" to "On-Waves"..Holger Hans Peter Freyther1-1/+1
Try to get the company name of our sponsor right...
2010-06-09GPRS: Copy the content of the msgb instead of creating one that points to ↵Holger Hans Peter Freyther1-4/+26
the other Right now the memcpy with the data will copy data to itself as the new_msg->data and msg->data are the same due the previous copying of the header which included copying the list entry.. We allocate a message as big as the current one, then we have to set all pointers by looking of how far they are away from the msg->_data and add that to the new pointers. Also copy the OpenBSC/GPRS specific CB data, also do the same for calculating the offset to the data... At the end we should end up with a copy...
2010-06-09GPRS: Fix crash when the peer can not be found...Holger Hans Peter Freyther1-2/+2
Use UINT_MAX (or -1) if the peer can not be found.
2010-05-25Migrate VTY code to libosmovtyHarald Welte1-1/+1