Commit Graph

41 Commits

Author SHA1 Message Date
Jacob Erlbeck 29805da6d1 gbproxy: Add gbprox_clear_patch_filter() (Coverity)
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-22 00:21:56 +02:00
Jacob Erlbeck 5e68ecf3b2 gbproxy: Pass tlli_info around
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-13 11:14:08 +02:00
Jacob Erlbeck 7b821d031a gbproxy: Don't call time() in TLLI related functions
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-13 10:42:27 +02:00
Jacob Erlbeck 291f0508c5 gbproxy: Test and fix IMSI/TMSI matching
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-13 10:41:23 +02:00
Jacob Erlbeck 89d3d343d1 gbproxy: Track TLLI even when the IMSI is not known
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-13 10:29:09 +02:00
Holger Hans Peter Freyther 0196c9936c gbproxy/test: Test TLLI expiry
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-05 15:02:06 +02:00
Holger Hans Peter Freyther 3fa26448d1 gbproxy: Kill the global gbprox_global_patch_state struct
Move this patching state into the gbproxy_config as well.

Done by Jacob
2014-08-04 16:27:11 +02:00
Holger Hans Peter Freyther eece627799 gbproxy: Remove global state from the gbproxy
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-04 16:01:12 +02:00
Holger Hans Peter Freyther fa7a8bc6eb gprs: The methods moved to gprs_utils.h remove them here
Stop declaring the apn routines in here.

Done with Jacob
2014-08-04 15:44:21 +02:00
Holger Hans Peter Freyther 1ddd9e518e gbproxy: Use gbproxy_ for all structures
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-04 11:37:50 +02:00
Holger Hans Peter Freyther b900459e96 gbproxy: The dump routines are only used by the test, move it there
Done with Jacob
2014-08-04 11:37:47 +02:00
Holger Hans Peter Freyther 16f30b5373 gbproxy: Have a clear namespace for the public functions
Done with Jacob
2014-08-04 11:37:45 +02:00
Holger Hans Peter Freyther a7027a04dd gbproxy: Remove the global rate counter and place it in the config
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-04 11:37:40 +02:00
Holger Hans Peter Freyther d4d36f22ee gbproxy: Correct the method name. We work on TLLIs
Done with Jacob
2014-08-04 11:37:33 +02:00
Holger Hans Peter Freyther 18739ea32d gbproxy: Move the VTY code into the vty file and create public API
Create public accessors to the core of the peer to allow to
simplify the test and separate concerns.

Done with Jacob.
2014-08-04 11:37:28 +02:00
Jacob Erlbeck 7dd498de64 gprs/vty: Add commands to manage the TLLI list
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-22 17:02:34 +02:00
Jacob Erlbeck 7c101d922e gprs: Track IMSI/TLLI to control APN patching
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-22 16:56:33 +02:00
Jacob Erlbeck 736852825a gprs: Add APN patch support for LLC/GSM messages
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-22 16:07:01 +02:00
Jacob Erlbeck 91fb680236 gprs: Add MCC/MNC patch support for LLC/GMM messages
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-22 16:05:59 +02:00
Jacob Erlbeck 67a4445675 gprs: Implement BSSGP MCC/MNC patching
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-22 16:04:54 +02:00
Jacob Erlbeck b32d3c041b gprs/test: Remove verbose parameter of gbprox_dump_* functions
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-07-07 15:05:59 +02:00
Jacob Erlbeck 72b401f33d gbproxy: Add test for NSEI and NSVCI changes
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-24 18:02:36 +02:00
Jacob Erlbeck 4211d79cd1 gbproxy/vty: Enhance delete-gbproxy-peer command
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-24 18:02:33 +02:00
Holger Hans Peter Freyther 90267a961c gbproxy: Add a command to delete peers from the GBProxy
This just deletes the peer entry based on NSEI and BVCI. The NS-VC
are not touched.
2013-10-24 08:22:45 +02:00
Jacob Erlbeck da890c7733 gbproxy: Test invalid BVCI from SGSN
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-19 12:10:21 +02:00
Jacob Erlbeck bc555742aa gbproxy: Add global and per peer counters
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-19 12:10:19 +02:00
Jacob Erlbeck e75fec60d0 gbproxy: Replace NS-VC references by NSEI
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-15 15:19:29 +02:00
Jacob Erlbeck 51a869c80c gbproxy: Add test program to test gbproxy message handling
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
2013-10-15 15:10:22 +02:00
Harald Welte ea34a4e3a7 split libgb into a separate library for outside use
This also removes the dependency to osmo_sock() inside libcommon and
replaces it with osmo_sock_* from libosmocore
2012-06-16 15:14:00 +08:00
Holger Hans Peter Freyther a8a09df6a6 misc: Remove sys/types.h includes from the files
These are not needed any more. We used them for u_int
types but we now use uint which comes from stdint.h
2011-04-18 17:31:39 +02:00
Holger Hans Peter Freyther c42ad8b686 misc: Move from u_int to uint types of stdint.h
This was done with sed on the files.
2011-04-18 17:31:39 +02:00
Pablo Neira Ayuso 136f453dd2 src: use new library libosmogsm and new path to headers in libosmocore
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-03-23 18:17:56 +01:00
Harald Welte 4b037e4117 Migrate VTY code to libosmovty 2010-05-25 23:40:38 +02:00
Harald Welte ff3bde8b49 [GPRS] NS: VTY: Move all local ip/port bind values into 'ns' node
This removes the requirement for gb_proxy and sgsn to have duplicate
vty parsing code
2010-05-19 15:09:09 +02:00
Harald Welte 5540c4cbd3 [GPRS] Add Frame Relay in GRE encapsulation for NS 2010-05-19 14:38:50 +02:00
Harald Welte 7af4962e07 [SGSN] Gb Proxy: Simplify configuration
Almost all parameters about the SGSNs NS-VC can be specified in the NS
protocol node.  All that needs to remain in the gbproxy config node
is "nsip sgsn nsei XXX".
2010-05-19 14:04:23 +02:00
Harald Welte 1ccbf44d79 [GPRS] gb_proxy: Initiate RESET procedure on persistent NS-VC at startup
Some BSS that connect to the proxy do not continue to perform the
RESET procedure after a timeout.  In order to resurrect them, we
simply start a RESET procedure.
2010-05-14 11:53:08 +00:00
Harald Welte c1c1dd260a [gprs] gb_proxy: Forward NS-RESET/NS-BLOCK/NS-UNBLOCK from SGSN to BTSs 2010-05-11 06:34:24 +02:00
Harald Welte 85801d0294 [gprs] gb_proxy: More VTY 'show' information
The 'show gbproxy' now actually shows information about the Gb proxy
BTS peers, whereas 'show ns' shows information about existing NS links.
2010-05-11 05:49:43 +02:00
Harald Welte 672f5c4dfd [gprs] gb_proxy: Fix proxying of BSS messages to SGSN
We don't keep a superfluous gbprox_peer for the SGSN anymore.
2010-05-04 07:20:44 +02:00
Harald Welte b77c697c0b [gprs] fully integrate VTY configuration into Gb proxy
The Gb-proxy is now fully configured by config file / VTY
2010-05-04 07:20:42 +02:00