Commit Graph

89 Commits

Author SHA1 Message Date
Jacob Erlbeck c37ef6cd0e gbproxy: Patch BSSGP P-TMSI in PAGING PS messages
Currently the P-TMSI IE in PAGING_PS is not patched.

This commit adds code to patch BSSGP P-TMSI IE in
gbproxy_patch_bssgp independently from the P-TMSI patching at the LLC
layer. It also extends gbproxy_update_link_state_dl to use the IMSI
to find the link_info if the TLLI is not present in the message.

Note that the spec (GSM 08.18, 7.2) requires to use of the P-TMSI
instead of the IMSI to select the MS if that IE is available.
Nevertheless as long as the IMSI is always present in downlink BSSGP
messages and as long as the optional P-TMSI refers to the same MS
(which is the case currently), this is not an issue.

Sponsored-by: On-Waves ehf
2014-10-27 11:59:28 +01:00
Jacob Erlbeck 91e9f555b6 gbproxy: Fix P-TMSI generation for repeated Attach Accept messages
Currently, when P-TMSI patching is enabled, a new BSS P-TMSI is
generated for each Attach Accept. So two duplicated, subsequent
Attach Accept messages will be mapped to different BSS side P-TMSI.
Because the last one will replace former ones in the link_info
struct, the MS will fail to access the SGSN if it uses the former
P-TMSI to derive the new TLLI.

This patch checks the SGSN P-TMSI already assigned to the link_info
and only generates a new BSS P-TMSI on mismatch (or if the BSS P-TMSI
hasn't been set yet).

Ticket: OW#1322
Sponsored-by: On-Waves ehf
2014-10-27 11:17:11 +01:00
Jacob Erlbeck e99c333d61 gbproxy/test: Add test case for repeated and otherwise bad messages
This adds a test case to check gbproxy's behaviour when processing
two subsequent but identical Attach Accept messages.

Ticket: OW#1322
Sponsored-by: On-Waves ehf
2014-10-27 11:12:22 +01:00
Jacob Erlbeck fb83ed32d2 gbproxy/test: Add expect_msg checks to test_gbproxy_keep_info
This patch adds assertions to check the LLC/GMM message received from
the gbproxy by the test framework within the function
test_gbproxy_keep_info.

It also fixes the source address of the DETACH ACC messages.

Sponsored-by: On-Waves ehf
2014-10-27 10:51:40 +01:00
Jacob Erlbeck c79beec8f6 gbproxy/test: Don't assign a variable within OSMO_ASSERT (Coverity)
Coverity complains about having side effects in OSMO_ASSERT argument
expressions. This would be an issue in this case, because that
variable is only reference in other OSMO_ASSERT expressions.

Nevertheless this patch changes this to assign the variable outside
of OSMO_ASSERT.

Fixes: Coverity CID 1244239
Sponsored-by: On-Waves ehf
2014-10-27 09:45:28 +01:00
Jacob Erlbeck b36032cb27 gbproxy: Use a separate regexp for routing
Currently one regexp ('patching') is used for all matching.

This patch adds a second category 'routing' which is exclusively used
for SGSN selection. It also adds a corresponding VTY command:

  - match-imsi patching RE : MS related patching (currently APN)
  - match-imsi routing RE  : Select secondary SGSN on match only
  - no match-imsi          : Clear all filter expressions

Ticket: OW#1258
Sponsored-by: On-Waves ehf
2014-10-09 18:06:30 +02:00
Jacob Erlbeck 9ccc41ea05 gbproxy: Cleanup match config after tests
Currently, patch filter configurations are leaking between tests.

This adds a call to gbproxy_clear_patch_filter() to the end of each
test that calls gbproxy_set_patch_filter().

Sponsored-by: On-Waves ehf
2014-10-09 18:04:14 +02:00
Jacob Erlbeck 9a83d7af55 gbproxy: Refactor IMSI matching
The current implementation makes it difficult to add further match
expressions.

This patch adds a new struct gbproxy_match that contains the fields
needed for each match expression. The matches (config) and the
results (link_info) are stored in arrays. All related functions are
updated to use them. The old fields in the config structure are
removed.

Sponsored-by: On-Waves ehf
2014-10-09 18:02:33 +02:00
Jacob Erlbeck 55ec2bf97f gbproxy/test: Add expect_msg checks to test_gbproxy_ra_patching
This patch adds assertions to check the LLC/GMM message received from
the gbproxy by the test framework within the function
test_gbproxy_ra_patching.

Sponsored-by: On-Waves ehf
2014-10-09 18:01:48 +02:00
Jacob Erlbeck acfaff38db gbproxy/test: Save and check received messages
Currently the only way to check, whether the right message have been
generated is to look into the generated text output. This is
error-prone if there are many messages.

This patch adds a way to optionally store all received messages into
a FIFO. They can then be checked by calling expect_msg() which
removes the first message from the FIFO and returns a pointer to it
or NULL if there is none. The pointer is only valid until the next
call to this function.

A few convenience functions are added to check for common message
types:

  - expect_gmm_msg checks for certain GSM 04.08 messages in LLC/GMM
  - expect_llc_msg checks for arbitrary LLC messages in BSSGP/UD
  - expect_bssgp_msg checks for arbitrary BSSG messages

Each of their arguments can be set by MATCH_ANY to ignore it while
matching. On success, they return a pointer to a statically
allocated struct containing the pointer to the msg and the full parse
context.

Recording is enabled by setting the global variable received_messages
to a pointer to a struct llist_head. It can be disabled again by
setting it to NULL.

Sponsored-by: On-Waves ehf
2014-10-09 18:01:15 +02:00
Jacob Erlbeck 9c65c8116f gbproxy: Parse Attach Reject messages
That message is currently ignored but should invalidate the TLLI and
de-register the logical link instead.

This patch extends the parser to recognize such messages and to set
the invalidate_tlli flag.

Sponsored-by: On-Waves ehf
2014-10-09 17:48:37 +02:00
Jacob Erlbeck 2bf326186a gbproxy/test: Add invalidation tests to test_gbproxy_keep_info()
The TLLI should also be invalidated:
 - when an Attach Reject info is received from the SGSN
 - when an Attach Req is immediately followed by a Detach Req
 - when an Attach Req is immediately followed by an MT detach
   procedure

To verify that, this patch adds corresponding message sequences to
the test.

Sponsored-by: On-Waves ehf
2014-10-09 17:48:29 +02:00
Jacob Erlbeck ea71b4880c gbproxy/test: Fix IMSI length check (Coverity)
This fixes the IMSI length assertion, which currently uses a
greater-or-equal than zero comparison which always yields true. It is
replaced by a greater than zero check.

Fixes: Coverity CID 1239442

Sponsored-by: On-Waves ehf
2014-10-09 17:47:58 +02:00
Jacob Erlbeck 51fde08b07 gbproxy/test: Fix time calculation in test_gbproxy_tlli_expire()
A single test case still uses time() to obtain the reference time.

This commit fixes this by using the 'now' variable instead, that
contains a fixed time value and does therefore not depend on when the
test is executed.

Sponsored-by: On-Waves ehf
2014-10-09 17:47:30 +02:00
Jacob Erlbeck f8562e362b gbproxy: Rename the field 'enabled_tllis' to 'logical_links'
This field in struct gbproxy_patch_state has involved and holds a
list of all tracked logical links now. Thus the name is modified
accordingly.

Sponsored-by: On-Waves ehf
2014-10-09 17:45:14 +02:00
Jacob Erlbeck 91d2f8a704 gbproxy: Use the term 'link' instead of 'tlli'
Currently in many places where 'tlli' (Temporary Logical Link
Identifier) within identifiers is used, the logical link itself is
meant instead. For instance, the tlli_info contain information about
an LLC logical link including up to four individual TLLI.

To avoid confusion between these concepts, this patch replaces all
'tlli_info' by 'link_info' and a few 'tlli' by 'link'.

Sponsored-by: On-Waves ehf
2014-10-09 17:44:57 +02:00
Jacob Erlbeck 9a7b0d5641 gbproxy: Rename functions related to tlli_info
This patch replaces 'tlli' by 'tlli_info' within the following
function identifiers:
  - gbproxy_delete_tlli
  - gbproxy_delete_tllis
  - gbproxy_remove_stale_tllis
  - gbproxy_touch_tlli
  - gbproxy_unregister_tlli
  - gbproxy_remove_matching_tllis
  - gbproxy_find_tlli -> gbproxy_tlli_info_by_tlli
  - gbproxy_find_tlli_by_* -> gbproxy_tlli_info_by_*

These functions refer to the whole logical link info rather than to a
certain TLLI. So they are renamed to be named consistently with
gbproxy_attach_tlli_info and others.

Sponsored-by: On-Waves ehf
2014-10-09 17:43:53 +02:00
Jacob Erlbeck 8992f30866 gbproxy: Rename identifiers related to IMSI matching
This patch renames gbproxy_check_tlli() to
gbproxy_imsi_matches() and struct tlli_info's
enable_patching to imsi_matches.

It's meant to be more obvious and consistent this way.

Sponsored-by: On-Waves ehf
2014-10-09 17:43:12 +02:00
Jacob Erlbeck 2ec2757def gbproxy/test: Test IMSI acquisition for RA UDP REQ
When a MS is state GMM_REGISTERED enters a new RA, it sends a RA
Update Request which is then handled by a gbproxy that possibly
doesn't have a matching tlli_info. In this case, depending on the
configuration an identification procedure to acquire the IMSI must be
started.

This adds tests to test_gbproxy_imsi_acquisition():
 - IMSI acquisition triggered by a RA Update Request message
 - Reaction to repeated RA Update Request messages, like it could be
   caused by packet loss between PCU and gbproxy.

Sponsored-by: On-Waves ehf
2014-10-09 17:41:06 +02:00
Jacob Erlbeck 91a0e8639a gbproxy: Separate SGSN numeric namespaces
Currently the SGSN side message's TLLI are searched without checking
the originating SGSN. This leads to collisions if both SGSN use the
same P-TMSI for different MS.

With this patch, the SGSN NSEI is stored within the tlli_info and is
used in comparisons to separate the namespaces.

Note that this type of collision cannot happen with BSS numbers,
since the tlli_info are already separated and stored per (BSS) peer.

Sponsored-by: On-Waves ehf
2014-09-19 11:21:35 +02:00
Jacob Erlbeck af952baffc gbproxy/test: Add a test with a P-TMSI collision between two SGSNs
This patch extends test_gbproxy_secondary_sgsn() by the establishment
of a third MS connection using a P-TMSI that has been assigned by the
other SGSN already. It is expected that the entries do not
interfere and are properly retrieved.

Note that these collisions are not handled properly yet.

Sponsored-by: On-Waves ehf
2014-09-19 11:21:24 +02:00
Jacob Erlbeck 2bb4543809 gbproxy/test: Fix Identification Response
At one place, the reply to the second Ident Req contains the wrong
IMSI. That is fixed by this patch.

Sponsored-by: On-Waves ehf
2014-09-19 11:21:13 +02:00
Jacob Erlbeck 1a02442f66 gbproxy: Check other tlli_infos for matching TLLI/P-TMSI
Currently it is possible to create serveral entries referring to the
same P-TMSI/TLLI by using P-TMSI assigment via Attach Accept or
RA Update Accept messages. This can lead to the use of the wrong
tlli_info.

This patch adds gbproxy_remove_matching_tllis() that removes all
conflicting entries. This function is called after the P-TMSIs and
the resulting TLLIs has been set up.

Sponsored-by: On-Waves ehf
2014-09-19 11:21:01 +02:00
Jacob Erlbeck 04f679be73 gbproxy/test: Add test case for P-TMSI assigment
This tests P-TMSI assignment when P-TMSI patching is disabled. A test
with colliding P-TMSI in Attach Accept messages is included.

Note that P-TMSI collisions are not handled properly yet.

Sponsored-by: On-Waves ehf
2014-09-19 11:20:50 +02:00
Jacob Erlbeck 85e5c8f905 gbproxy: Parse RA_UPD_REJ and invalidate TLLI
Since this message puts the MS into DEREGISTERED state (like a detach
procedure), this message is parsed and the invalidate_tlli field is
set accordingly.

Sponsored-by: On-Waves ehf
2014-09-19 11:20:31 +02:00
Jacob Erlbeck 16a3cd3847 gbproxy: Avoid multiple tlli_info entries with the same IMSI
Currently it is possible to create several tlli_info entries with the
same IMSI.

This patch disables this by adding a check before the imsi field
is updated.

Sponsored-by: On-Waves ehf
2014-09-19 10:49:12 +02:00
Jacob Erlbeck 7430da621a gbproxy: Keep tlli_info after detach
Currently a tlli_info entry is deleted when the TLLI gets invalidated
by a Detach message.

This patch introduces the possibility to keep tlli_info entries in
the list. Those entries then have cleared TLLI fields, are marked as
de-registered, and can only be retrieved by a message containing an
IMSI or a P-TMSI.

The following VTY configuration commands are added to the gbproxy
node:
  - tlli-list keep-mode never : Don't keep the entries (default)
  - tlli-list keep-mode re-attach : Only keep them, when a Detach
    message with re-attach required has been received
  - tlli-list keep-mode identified : Only keep entries which are
    associated with an IMSI
  - tlli-list keep-mode always : Keep all entries

Note that at least one of max-length or max-age should be set when
this feature is used to limit the number of entries.

Sponsored-by: On-Waves ehf
2014-09-19 10:46:23 +02:00
Jacob Erlbeck 772a22b529 gbproxy/test: Add test case for tlli_info persistence
This test case consists of a sequence of several attach and detach
procedures. The kind of detach varies (mobile originated, mobile
terminated re-attach required, mobile terminated re-attach not
required, routing area update reject). To main focus is to check that
the tlli_info is de-registered correctly (not accessible via the
TLLI) and that can be re-used afterwards (which is not implemented
yet).

Sponsored-by: On-Waves ehf
2014-09-18 13:40:03 +02:00
Jacob Erlbeck a42fe9f61e gbproxy: Remove gbproxy_register_tlli
This function is a remainder of the initial implemenation that was
not meant for TLLI patching and can be used for the BSS side only.
The SGSN side is already using a composition of more flexible
single purpose functions.

This patch changes the implementation to use a similar approach. The
function is moved to gbproxy_test.c and renamed to register_tlli to
keep the tests intact.

Sponsored-by: On-Waves ehf
2014-09-18 13:21:17 +02:00
Jacob Erlbeck 948c07f490 gbproxy: Fixed RAI patching in Attach Request messages
Currently the RAI in the LLC part of the message is not updated if
the message has been taken from the list of stored messages. The
reason is, that old_raid_matches is update in
gbprox_process_bssgp_ul() but not in gbproxy_flush_stored_messages().

This patch moves the check to gprs_gb_parse_bssgp() which is called
at both places and where other fields like parse_ctx->tlli are set,
too.

In addition, old_raid_matches is replaced by old_raid_is_foreign
since this is clearer in the case when there is no old RAI at all.

Several RAI patch counter assertions are also added to
test_gbproxy_ra_patching().

Sponsored-by: On-Waves ehf
2014-09-18 13:20:58 +02:00
Jacob Erlbeck 991606b57a gbproxy/test: Add/modify test cases
Add a Attach Request message to test_gbproxy_ra_patching, where the
BSSGP RAI differs from the old RAI signalled in the LLC part. This
case had not been tested explicitely yet.

Change the RAI in the first Attach Request in
test_gbproxy_imsi_acquisition from rai_unknown to rai_bss.

Add Detach Requests to test_gbproxy_imsi_acquisition, one for a
incomplete attach procedure and one for an unknown (fresh) TLLI.
In these cases, the acquisition of a IMSI is not necessary and also
doesn't work properly with an E71.

Sponsored-by: On-Waves ehf
2014-09-18 11:26:07 +02:00
Jacob Erlbeck 2fd1ba4c6d gbproxy: Replace 'mi_data' by 'imsi'
Since at all places where mi_data/mi_data_len is used it will always
contain an IMSI. Thus the names of the identifiers have been updated
accordingly for clarity.

Sponsored-by: On-Waves ehf
2014-09-18 11:22:15 +02:00
Jacob Erlbeck 7fb26c2943 gbproxy/test: Add assertions, improve test coverage
This patch add explicit tests for
  - gbproxy_peer_by_bvci
  - gbproxy_peer_by_nsei
  - gbproxy_cleanup_peers
  - gbproxy_peer_by_rai
  - gbproxy_peer_by_lai
  - gbproxy_peer_by_lac
and for messages with an unknown TLLI sent by the SGSN.

Sponsored-by: On-Waves ehf
2014-09-09 10:10:12 +02:00
Jacob Erlbeck ea1698e322 gbproxy/test: Add test cases for IMSI acquisition
If the Attach Request procedure gets restarted e.g. because of a lost
message, all of these messages are stored if IMSI acquisition is in
progress.

This patch adds a test for this case and modifies the dump_peers
function to output the number of stored messages.

Note that the number of stored messages currently increases with each
(repeatedly) received Attach Request which is not the desired behaviour.

Sponsored-by: On-Waves ehf
2014-09-09 10:09:50 +02:00
Jacob Erlbeck 52f070a099 gbproxy/test: Extend P-TMSI patch test by a sequence of RA UDP REQ
This adds a sequence of two RA update procedures to
test_gbproxy_ptmsi_patching(). Each of them assigns a new P-TMSI.

Note that the implementation fails to patch the RAI within the
message labelled 'RA UDP ACC (P-TMSI 3)' and logs 'TLLI sent by the
SGSN is unknown'.

Sponsored-by: On-Waves ehf
2014-09-08 13:34:13 +02:00
Jacob Erlbeck 82add78f89 gbproxy/test: Check APN patching while P-TMSI patching is enabled
This commit adds a single ACT PDP CTX REQ message to
test_gbproxy_ptmsi_patching() to check whether APN patching works in
this case, too.

Note that this doesn't work currently, the APN patch count is not
incremented.

Sponsored-by: On-Waves ehf
2014-09-08 09:27:41 +02:00
Jacob Erlbeck f181f9ec2a gbproxy/test: Add test case for secondary SGSN
This patch adds a case to test the establishment (and shutdown) of
connection between 2 MS and 2 SGSN, where the assignment is based
on each IMSI. Since BVC-RESET and FLOW-CONTROL-BVC will have to be
sent to both SGSN, an ACK is simulated for both.

New functions to generate FLOW-CONTROL-BVC(-ACK) messages are
provided.

It modifies dump_peers to add the string "IMSI matches" to a TLLI dump
line if appropriate.

Note that there is no real support to use a secondary SGSN in the
gbproxy yet, but the test code reflects the expected behaviour when
the feature is implemented.

Sponsored-by: On-Waves ehf
2014-09-08 09:12:02 +02:00
Jacob Erlbeck 5f4ef321a6 gbproxy: Implement IMSI acquisition
To modify or route messages based on the IMSI the latter must be known
when the action shall take place.

This patch modifies the gbproxy to optionally retain and enqueue
messages from the MS while initiating an identification procedure.
Further message processing of the LLC PTP link towards the SGSN will
be done, when the identity of the MS has been acquired.

Note that the N(U) of the LLC GMM SAPI are not adjusted, so it is
possible that adjacent messages of a single LLC link arriving either
at the BSS or the SGSN have the same N(U) and might get discarded,
leading to retransmissions and additional delay.

Note also that retransmissions and packet loss are not yet handled
explicitely. If for instance the generated IDENT REQ gets lost, the
gbproxy will not act on its own. In this case, the MS will time out
and eventually resend the Attach Request on which the gbproxy will
act exactly like before (thus having two Attach Req messages in its
queue, which will both be sent after the Ident Resp arrives).

This has been tested successfully with an E71, needing one
retransmission by the SGSN due to an N(U) collision.

Ticket: OW#1261
Sponsored-by: On-Waves ehf
2014-09-02 09:53:47 +02:00
Jacob Erlbeck 28fe98891f gbproxy/test: Add a test for IMSI acquisition
This patch copies test_gbproxy_ptmsi_patching to
test_gbproxy_imsi_acquisition as a base for a later test for IMSI
acquisition (which is not yet implemented). The idea behind this is
to make the different behaviour visible in the ok file without
compromising the P-TMSI test.

Sponsored-by: On-Waves ehf
2014-09-02 09:53:42 +02:00
Jacob Erlbeck 299389a99f gbproxy/test: Test patching BSSGP SUSPEND/LLC-DISCARDED
Currently messages like these with a TLLI IE (BSSGP) are not
tested (properly) with TLLI patching.

This patch extends the send_bssgp_suspend* functions to accept a
TLLI as argument and adds the send_bssgp_llc_discarded function.
These are then used in test_gbproxy_ptmsi_patching() with a valid
TLLI.

Note that the TLLI IE patching doesn't work currently.

Sponsored-by: On-Waves ehf
2014-09-02 09:53:34 +02:00
Jacob Erlbeck 5f1faa3cd2 gbproxy: Move peer definitions to gb_proxy_peer.c
This patch moves the peer related definitions from gb_proxy.c to
gb_proxy_peer.c and adjusts the prefix of each global symbol to
gbproxy_:

Peer definitions (prefix adjusted to gbproxy_):
  peer_ctr_description -> gprs/gb_proxy_peer.c (static)
  peer_ctrg_desc -> gprs/gb_proxy_peer.c (static)
  *peer_by_* -> gprs/gb_proxy_peer.c
  gbproxy_peer_alloc -> gprs/gb_proxy_peer.c
  gbproxy_peer_free -> gprs/gb_proxy_peer.c
  gbprox_cleanup_peers -> gprs/gb_proxy_peer.c

Sponsored-by: On-Waves ehf
2014-08-24 16:16:40 +02:00
Jacob Erlbeck 9114bee242 gbproxy: Refactor gb_proxy.c into several files
This patch moves several functions and declarations out of gb_proxy.c
to make them reusable by other components and to separate them by
context and task.

Counter enums (prefix is changed to gbproxy_):
  enum gbprox_global_ctr -> gprs/gb_proxy.h
  enum gbprox_peer_ctr -> gprs/gb_proxy.h

Generic Gb parsing (prefix is changed to gprs_gb_):
  struct gbproxy_parse_context -> openbsc/gprs_gb_parse.h
  gbprox_parse_dtap() -> gprs/gprs_gb_parse.c
  gbprox_parse_llc() -> gprs/gprs_gb_parse.c
  gbprox_parse_bssgp() -> gprs/gprs_gb_parse.c
  gbprox_log_parse_context() -> gprs/gprs_gb_parse.c
  *_shift(), *_match() -> gprs/gprs_gb_parse.c (no prefix)
  gbprox_parse_gmm_* -> gprs/gprs_gb_parse.c (static)
  gbprox_parse_gsm_* -> gprs/gprs_gb_parse.c (static)

MI testing/parsing (prefix gprs_ added):
  is_mi_tmsi() -> gprs/gprs_utils.c
  is_mi_imsi() -> gprs/gprs_utils.c
  parse_mi_tmsi() -> gprs/gprs_utils.c

TLLI state handling (prefix is changed to gbproxy_):
  gbprox_*tlli* -> gprs/gb_proxy_tlli.c
  (except gbprox_patch_tlli, gbproxy_make_sgsn_tlli)

Message patching (prefix is changed to gbproxy_):
  gbprox_*patch* -> gprs/gb_proxy_patch.c
  gbprox_check_imsi -> gprs/gb_proxy_patch.c

Sponsored-by: On-Waves ehf
2014-08-24 16:16:40 +02:00
Jacob Erlbeck 6bd7ded71e gbproxy/test: Add test for TLLI patching
Add LLC test messages containing XID (SAPI LLGMM, U frame) and IP traffic
(SAPI LL11, UI frame).

Add a test case containing a complete SGSN session with TLLI/PTMSI
patching enabled.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:40 +02:00
Jacob Erlbeck 9057bc3c72 gbproxy: Track SGSN and BSS TLLI/PTMSI separately
This patch separates BSS side from SGSN side TLLI/PTMSI tracking. When
TLLI/PTMSI patching is not enabled, the corresponding states shall be
identical. The TLLI/PTMSI state has been moved into the struct
gbproxy_tlli_state and is used twice in gbproxy_tlli_info.

Since the state handling for uplink and downlink messages is
diverging, gbprox_update_state() is replaced by two functions
gbprox_update_state_dl/gbprox_update_state_ul and
gbprox_process_bssgp_message() is replaced by
gbprox_process_bssgp_dl/gbprox_process_bssgp_ul.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck c53f2a6961 gbproxy/test: Generate BSSGP and LLC layer for DTAP messages
This patch adds the functions send_bssgp_ul_unitdata(),
send_bssgp_dl_unitdata(), send_llc_ul_ui(), and send_llc_dl_ui().
They are used instead of send_ns_unitdata() in
test_gbproxy_ra_patching(). This make it easier to modify TLLI, N(U),
and other parameters.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck 425afaca2f gbproxy/test: Fix BSSGP/LLC test messages
The following parts of the messages have been fixed
  - Attach Accept: checksum
  - Attach Complete: checksum
  - RA Update Accept: Use the same MS Radio Access Capabilities and
    DRX Parameters like the other messages

The N(U) of most messages have not been fixed.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck 59748e653b gbproxy: Handle old and new P-TMSI/TLLI
Don't replace the current TLLI immediately, store it in an additional
'assigned_tlli' field and discard the old TLLI when both sides have
used the new one (see GSM 04.08, 4.7.1.5).

Add an Attach Complete message to test and check, whether the related
field of the corresponding tlli_info struct are set as expected
during the local TLLI validation cycle.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck 3e23ddf88b gbproxy: Parse Detach Request messages
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-24 16:16:39 +02:00
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 948b730fea gbproxy: Fix warnings (signed/unsigned)
Adresses:
gbproxy_test.c:1288:17: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]

Sponsored-by: On-Waves ehf
2014-08-13 11:22:03 +02:00