Commit Graph

4903 Commits

Author SHA1 Message Date
Jacob Erlbeck 4110868029 gbproxy: Honour the BSS TLLI type when creating an SGSN TLLI
Currently gbproxy_make_sgsn_tlli always returns a foreign TLLI when
it uses the (SGSN) P-TMSI to generate one.

This patch changes the implementation to return a SGSN TLLI of the
same type like the BSS TLLI in that case.

Sponsored-by: On-Waves ehf
2014-11-11 22:44:32 +01:00
Henning Heinold 0d8ac0eac0 systemd: use Wants for the dependency btw. osmo-bsc-mgcp and osmo-bsc
* osmo-bsc and osmo-bsc-mgcp are needed to run
* with Wants, both are started but can be indepently
  controlled via systemctl

Fixes: SYS#738
2014-11-11 17:59:49 +01:00
Holger Hans Peter Freyther 054bc24e6d bts: Allow to set the LAC through the CTRL interface
Allow to set the LAC of the BTS through the CTRL interface.
The change will not be effective immediately.

Fixes: SYS#738
2014-11-10 11:41:03 +01:00
Jacob Erlbeck 74b2028167 bsc: Fix use-after-free on OML NM messages from the BTS
Currently the sign_link pointer is dereferenced after a call to
osmo_signal_dispatch, which can indirectly call
e1inp_sign_link_destroy. If that happens, accessing *sign_link is
illegal and can lead to a segmentation violation.

Since only the bts pointer is needed from sign_link after the call to
osmo_signal_dispatch, this patch changes abis_nm_rcvmsg_fom to save
that pointer to a local variable earlier.

Addresses:
<0019> input/ipa.c:250 accept()ed new link from 192.168.1.101 to port 3002
SET ATTR NACK  CAUSE=Message cannot be performed
<0005> bsc_init.c:52 Got a NACK going to drop the OML links.
<001b> bsc_init.c:319 Lost some E1 TEI link: 1 0xb351a830
=================================================================
==13198== ERROR: AddressSanitizer: heap-use-after-free on address 0xb5d1bc70 at pc 0x80a6e3d bp 0xbfbb33d8 sp 0xbfbb33cc

Sponsored-by: On-Waves ehf
2014-11-10 08:47:14 +01:00
Holger Hans Peter Freyther 33f2c4d898 bts: Fail OML in case the channel combination is wrong
In case a BTS is being bootstrapped and one TS can not be
activated prevent the whole BTS from coming up.

When the OML activation is not being done the rest of the BSC
code still assumes these logical channel(s) to be available
and one will see channel activation issues that might be hard
to debug.

Instead of having a half-configured system up and running,
keep the BTS offline.
2014-11-07 09:54:57 +01:00
Holger Hans Peter Freyther 1464a121c0 ipa: Correct the prototype of these functions
They return nothing and not int.
2014-11-06 16:32:57 +01:00
Jacob Erlbeck 9d0fb1e97a gbproxy/test: Extend test_gbproxy_keep_info
Add new test message sequences:
  - Normal attach (with IMSI) after detach (ok)
  - Normal attach (with local TLLI) after detach (ok)
  - Unexpected attach (with IMSI) after successful TLLI validation (fails)
  - Unexpected attach (with P-TMSI) after successful TLLI validation (fails)

Ticket: OW#1324
Sponsored-by: On-Waves ehf
2014-11-05 00:26:34 +01:00
Jacob Erlbeck de74e721b2 gbproxy: Fixed VTY doc for delete-gbproxy-link
The command definition delete_gb_link_by_id_cmd lacks a description
for the sgsn-nsei token.

This patch adds the missing description.

Addresses:
Verifying src/gprs/osmo-gbproxy -c doc/examples/osmo-gbproxy/osmo-gbproxy.cfg, test verify_doc
Documentation error (missing docs):
<command id='delete-gbproxy-link &lt;0-65534&gt; (tlli|imsi|sgsn-nsei) IDENT'>
        <param name='IDENT' doc='(null)' />

Sponsored-by: On-Waves ehf
2014-11-05 00:24:13 +01:00
Jacob Erlbeck 14ae582064 sgsn: Unassign the LLME after GMM Status without mmctx
Currently the LLME is not deleted when a GMM Status message is
received for which a mmctx cannot be found. This can fill the LLME
list with unneeded entries.

This patch adds code to unassign the LLME in that case.

Ticket: OW#1324
Sponsored-by: On-Waves ehf
2014-11-05 00:24:02 +01:00
Jacob Erlbeck 7067142100 sgsn: Remove unused static functions from gprs_gmm.c
The following functions are not being used:
 - gsm48_tx_gmm_status_oldmsg
 - gsm48_tx_sm_status_oldmsg

This patch removes the function definitions.

Sponsored-by: On-Waves ehf
2014-11-05 00:23:44 +01:00
Holger Hans Peter Freyther db64f2e45a bsc: Allow to disable sending ping/pong to the MSC
Some switches do not like to receive the IPA PING/PONG messages.
Allow to disable the handling with "no timeout-ping" and create
test cases that verify the switching between the modes. Change the
code to trat <= 0 as an invalid timeout.

Fixes: SYS#713
2014-10-29 10:11:21 +01:00
Jacob Erlbeck 76606d3473 nitb/ctrl: Fix access to freed memory in verify_subscriber_modify
Currently the temporary string 'tmp' is freed before parts of it are
referenced. This lets address sanitizer complain when evaluating
strlen(imsi), where imsi points into the 'tmp' data block.

This patch moves the talloc_free to the end of the function and uses
a rc variable instead of using early returns.

Addresses:
testSubscriberAddRemove (__main__.TestCtrlNITB) ... Launch:
./src/osmo-nitb/osmo-nitb -c
  ./doc/examples/osmo-nitb/nanobts/openbsc.cfg -l test_hlr.sqlite3
Connecting to host 127.0.0.1:4249
Sending "SET 1000 subscriber-modify-v1 2620345,445566"
Decoded replies:  {}
ERROR

Sponsored-by: On-Waves ehf
2014-10-28 15:17:02 +01:00
Jacob Erlbeck 5a38f6470e sgsn: Handle Detach Requests even when there is no mmctx
Currently, when a Detach Request is received with an unknown TLLI,
it is answered by another Detach Request (!), even when a power_off
Type is used.

This patch uses gsm48_rx_gmm_det_req to handle the message instead.
So this function is changed to cope with a NULL mmctx. In that case
it doesn't unassign the llme, so this must be done manually
afterwards.

Sponsored-by: On-Waves ehf
2014-10-27 15:34:14 +01:00
Jacob Erlbeck b9ab0d4f39 sgsn: Only send Detach Accept (MO) if power_off isn't set
Currently, every time the SGSN received a Detach Request from the MS
via an established logical link, it is answered by a Detach Accept.
This violates the specification (GSM 04.08, 4.7.4.1.2 and .3), which
states, that it should only be sent, if "the detach type IE value
indicates that the detach request has not been sent due to switching
off".

This patch adds a conditional to limit the sending of Detach Accept
accordingly.

Sponsored-by: On-Waves ehf
2014-10-27 15:21:31 +01:00
Jacob Erlbeck 189999d654 sgsn/test: Add test case for Detach Request (MO, power-off = 1)
Currently only a Detach Request (MO) message with power_off = 0 is
checked.

This commit adds a new test case with power_off set to 1. It also
adds checks for the number of messages generated by the SGSN to
verify that these messages are handled differently.

Note that the handling of power_off isn't implemented yet. Therefore
the corresponding assertion is being disabled yet.

Sponsored-by: On-Waves ehf
2014-10-27 15:21:11 +01:00
Jacob Erlbeck abc16a55b2 sgsn/test: Move MM context allocation into separate function
This refactores serveral code lines needed for the allocation of MM
contexts into the new function alloc_mm_ctx.

Sponsored-by: On-Waves ehf
2014-10-27 15:20:07 +01:00
Jacob Erlbeck 3b5d407203 sgsn: Moved IMSI ACL management to sgsn_auth.c
Currently the ACL code is located in sgsn_vty.c.

This commit moves this to a new file sgsn_auth.c as a first step to
make authorization more flexible in order to implement remote
acquisition on subsciber data.

Sponsored-by: On-Waves ehf
2014-10-27 13:06:55 +01:00
Jacob Erlbeck fb26c60a2f sgsn: Avoid duplicated Attach Accept messages
Currently each received Ident Resp triggers an Attach Accept/Reject
if IMSI and IMEI are known. This has led to duplicated Attach Accept
messages when used with the gbproxy (IMSI acquisition active) and
with certain mobile equipment (iOS).

This patch modifies gsm48_rx_gmm_id_resp to discard Ident Resp messages
if all required information (IMEI and IMSI) has been gathered.

Ticket: OW#1322
Sponsored-by: On-Waves ehf
2014-10-27 13:06:55 +01:00
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 78ecaf0561 sgsn: Send detach(re-attach) instead of gmm status if TLLI unknown
The osmo-sgsn sends Status messages (or nothing in case of non
GMM/GSM) when the TLLI is unknown. This prevents the MS from
reconnecting.

This patch adds the initiation of an MT detach procedure to force a
re-attach to set up a valid LLE context if an LLE or an MM context
cannot be found. Since this can also be triggered by non-GMM SAPI
messages, a GPRS application callback sgsn_force_reattach_oldmsg is
added which in turn calls the GMM layer to generate the GSM 04.08
specific messages.

Note that the MS can be left in REGISTERED state after initially
wanting to detach itself, since it will receive a Detach Req
(re-attach) when sending a DEACT PDP CTX REQ after the SGSN or
gbproxy (P-TMSI patching enabled) has been restarted. This same
behaviour has been observed with another SGSN.

Sponsored-by: On-Waves ehf
2014-10-27 10:50:36 +01:00
Jacob Erlbeck 99985b5ea8 sgsn: Delete PDP contexts properly
Currently the PDP contexts are hard freed (via sgsn_pdp_ctx_free)
at some places in gprs_gmm.c on the reception of a Detach Req and on
re-use of an IMSI that is already associated with an MM context. This
can lead to segfaults when there is a pending request or a data
indication at libgtp.

This patch add a new function sgsn_pdp_ctx_terminate that de-associates
the PTP context from the MM context, deactivates SNDCP, sets pdp->mm
to NULL and then calls sgsn_delete_pdp_ctx. sgsn_libgtp is updated to
check for pdp->mm being non-NULL before dereferencing it. The
sgsn_pdp_ctx_terminate function will be called for each PDP context of
an MM context before this context is going to be deleted via
sgsn_mm_ctx_free. To ensure, that the ctx->llme (which is accessed
during the deactivation of SNDCP) remains valid, the call to
gprs_llgmm_assign is moved after the call to sgsn_mm_ctx_free. The
handling of re-used IMSIs is changed to mimic the processing of a
Detach Req.

Addresses:
<0002> gprs_gmm.c:654 MM(/f6b31ab0) Deleting old MM Context for same
    IMSI p_tmsi_old=0xc6f19134
<000f> gprs_sgsn.c:259 PDP freeing PDP context that still has a
    libgtp handle attached to it, this shouldn't happen!
[...]
SEGFAULT

Ticket: OW#1311
Sponsored-by: On-Waves ehf
2014-10-27 10:25:13 +01:00
Jacob Erlbeck ae20b4b31b sgsn: Cancel pending timer in sgsn_mm_ctx_free
Currently the timer is not stopped before the MM context is freed
which can lead to failure if sgsn_mm_ctx_free is called while timer
protected procedures are active.

This patch add code to cancel the timer if necessary from within
sgsn_mm_ctx_free.

Ticket: OW#1322
Sponsored-by: On-Waves ehf
2014-10-27 10:25:03 +01:00
Holger Hans Peter Freyther 19e990d6a7 gprs: Fix typo in the comment 2014-10-27 10:25:03 +01:00
Jacob Erlbeck 6a1d428f56 gbproxy: Fix segfault for VTY delete-gbproxy-link
Currently the code segfaults when the link shall be deleted by IMSI
when the IMSI has not been set yet.

This patch adds a NULL check to skip the entry before calling
gsm48_mi_to_string,

Adresses:
Program received signal SIGSEGV, Segmentation fault.
0xb693af77 in gsm48_mi_to_string (string=0xbfffe020 "", str_len=200,
mi=0x0, mi_len=0) at gsm48.c:360
    360         mi_type = mi[0] & GSM_MI_TYPE_MASK;
    str_len=200, mi=0x0, mi_len=0) at gsm48.c:360
    self=0x807c9a0 <delete_gb_link_by_id_cmd>, vty=0xb4303c70,
     argc=3, argv=0xbfffe1c0) at gb_proxy_vty.c:670
...

Sponsored-by: On-Waves ehf
2014-10-27 09:47:00 +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 058ae12135 gbproxy: Discard UL PTP messages with an unknown BVCI
Currently all PTP messages are in general forwarded to the SGSN even
when the BVCI is not known to the gbproxy. Only if message patching
is active and the peer cannot be determined, a log message is
generated, a STATUS message returned, and the message discarded.
The intention for this was to keep the old gbproxy's behaviour if
patching is disabled. But the code gets much more complex this way.
Another drawback is that when the SGSN returns a corresponding STATUS
message, it cannot be routed to the BSS where the original message
came from.

This patch therefore changes the behaviour to reject BSSGP PTP uplink
messages immediately if the BVCI is not known.

Fixes: Coverity CID 1244240
Ticket: OW#1317
Sponsored-by: On-Waves ehf
2014-10-27 09:44:29 +01:00
Holger Hans Peter Freyther f9ffd1fa18 sgsn: Prevent memory leak and double free
This has been re-produced using the "osmo-pcu emulator" code
and a ping to force segmented SNDCP messages. When the NS link
enters the DEAD/BLOCKED state the msgb would be freed twice.
Once inside gprs_ns_sendmsg and once by the caller. Based on the
return one can not see if the parameter has been deleted.

I changed libosmocore/libosmogb to always free the msgb in case
of an error on the way to gprs_ns_sendmsg. Catch up, avoid the
double free and fix some memory leaks. In case the sending fails
assume the entire segmented message is at end and free the
original input data.

This has been tested by posix suspending/resuming the emulator
process to have the GPRS-NS link go to dead/blocked to alive
and unblocked. The ping recovers and "SIGUSR1" to the SGSN does
not show active memory allocations.

The SGSN calls bssgp_tx_dl_ud at the lowest level and has the
following callchains. Most of them allocate the msgb and have
no early return and transfer ownership already:

<- gprs_llc_tx_u
<- gprs_llc_tx_ui
	<- gsm48_gmm_sendmsg (all callers sane)
		<- _tx_status
		<- _tx_detach_req
	<- gprs_llc_tx_xid (all callers sane)
	<- sndcp_unitdata_req
		<- sndcp_send_ud_frag
2014-10-10 17:43:40 +02:00
Jacob Erlbeck b4f0e8089d gbproxy: Log more information on parse errors
To get a clue which message caused the error without having to enable
LOGL_DEBUG, information about how far the parser came (message name,
parsed fields) is logged with LOGL_NOTICE along with a full hexdump
of the message.

Ticket: OW#1307
Sponsored-by: On-Waves ehf
2014-10-09 18:17:06 +02:00
Jacob Erlbeck 1c407aa993 gbproxy: Pass the log level as argument to gprs_gb_log_parse_context
Currently, the log level is always LOGL_DEBUG. In case of errors it
would be helpful to use a higher log level.

This patch adds a log_level parameter to gprs_gb_log_parse_context to
let the caller decide about the level.

Ticket: OW#1307
Sponsored-by: On-Waves ehf
2014-10-09 18:16:22 +02:00
Jacob Erlbeck 9b07135b92 gbproxy: Add gprs_gb_message_name function
This function tries to get an accurate name for the message even if
the parsing has been aborted due to message errors.

The patch also moves the settings of the BSSGP related fields in
parse_ctx from behind to the front of bssgp_tlv_parse, to get more
information in the case of failure. This is now consistent with the
handling of the llc and g48_hdr fields.

Id addition, gprs_gb_log_parse_context now uses the new function to
derive a more accurate message name.

Ticket: OW#1307
Sponsored-by: On-Waves ehf
2014-10-09 18:15:31 +02:00
Jacob Erlbeck cc8856f9d3 gbproxy: Refuse to configure conflicting NSEIs
Currently it is possible to set the secondary SGSN NSEI to the same
value like the (primary) SGSN NSEI. This leads to undefined behaviour
and is hard to recognize.

This patch adds checks to either NSEI configuration command to refuse
conflicting values.

Ticket: OW#1306
Sponsored-by: On-Waves ehf
2014-10-09 18:14:09 +02:00
Jacob Erlbeck 49389178cc gbproxy: Use pointer to PTMSI value instead of MI
Currently, ptmsi_enc and new_ptmsi_enc point to the beginning of the
mobile identity. Since all P-TMSI in 04.08 (MM) are encoded this way (1
byte header + 4 byte P-TMSI value). This is different to the P-TMSI
encoding in 08.18 (BSSGP), where the P-TMSI is encoded into 4 byte
without MI header.

This patch changes the code to use pointers to the P-TMSI value,
which is encoded in the same way in both specifications.

Sponsored-by: On-Waves ehf
2014-10-09 18:12:27 +02:00
Jacob Erlbeck 43b8f9f8a1 gbproxy: Send STATUS(BVCI unknown) to BSS on unknown PTP BVCI
Currently BSSGP PTP messages are silently dropped when the BVCI is
not known and patching is enabled. The nanoBTS will not recognize
this and continue to send messages on the BVCI. If it receives a
STATUS(BVCI unknown) instead, it will start a BVC reset procedure
instead.

This patch modifies gbprox_rx_ptp_from_bss() to return a
STATUS(BVCI unknown) to the BSS instead of dropping the message.

Sponsored-by: On-Waves ehf
2014-10-09 18:09:54 +02:00
Jacob Erlbeck f349baeec8 gbproxy: Replace ';;' by ';'
This patch removes some superfluous ';' from the code.

Sponsored-by: On-Waves ehf
2014-10-09 18:09:27 +02:00
Jacob Erlbeck c9cd15fbc9 gbproxy: Fix parser to accept GSM 24.008 Attach Req messages
Currently the parse expects a 'MS network capability' IE with
2 <= length <= 3 which is compliant to GSM 04.08, 9.4.1  but not to
GSM 24.008, 9.4.1 which specifies 3 <= length <= 9. Thus the parser
rejects messages with a length >= 4 (including length field).

This patch relaxes the length check to accept either range by
requiring 2 <= length <= 9.

Ticket: OW#1258
Sponsored-by: On-Waves ehf
2014-10-09 18:07:10 +02: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 6c3fdc1091 gbproxy: Extend the match-imsi VTY command to support categories
This patch modifies the match-imsi command to allow for different
match categories (currently only 'patching' is provided).

  - match-imsi patching RE : Filter APN patching and routing
  - no match-imsi          : Clear all filter expressions

Sponsored-by: On-Waves ehf
2014-10-09 18:05:17 +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 7e31f847af gprs: Fix gprs_msgb_copy pointer computation
Currently the pointers are computed by adding an offset to the new
message's _data pointer even when the original pointer is NULL.
This leads to invalid pointers in the copied msgb.

This patch adds a NULL check to each computation such that NULL
pointers are not adjusted.

Sponsored-by: On-Waves ehf
2014-10-09 18:00:55 +02:00
Jacob Erlbeck 657502812b gbproxy: Refactor local message generation
This patch adds und uses the function gbproxy_gsm48_to_peer() which
takes a GSM 04.08 message, encapsulates it in BSSGP and LLC, and
sends it to the BSS peer. This function increments vu_gen_tx_bss
which is now used instead of imsi_acq_retries to set the N(U) of the
outgoing message.

Since imsi_acq_retries isn't currently incremented before a Detach
Accept is generated, this patch also fixes the N(U) of such messages.

Sponsored-by: On-Waves ehf
2014-10-09 17:57:28 +02:00
Jacob Erlbeck d211d1d999 gbproxy: Reset IMSI acquisition within gbproxy_unregister_link_info
Currently then link_info is not cleaned up completely, when
gbproxy_unregister_link_info is called.

This patch adds a function gbproxy_reset_link that must be defined
externally. This is done in gb_proxy.c, where it resets the IMSI
acquisition.

Sponsored-by: On-Waves ehf
2014-10-09 17:56:16 +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