Commit Graph

73 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther 8239e063b9 gsm0408: Provide unique strings for the gsm 04.08 message
At Rhizomatica we see that some GSM 04.08 messages are leaked and
have no other indication if that is Call Control, SMS or something
else.
2016-01-30 09:57:49 +01:00
Harald Welte 53d51f501c mncc: introduce 'struct gsm_mncc_bridge' for MNCC_BRIDGE
When a MNCC handler wants to issue the MNCC_BRIDGE primitive
overt the MNCC interface, this was not possible so far via the
MNCC socket.   This primitive was so far only available from the
internal MNCC handler, more or less by accident I suppose.  The reason
for this is in the way the array of two call references had been passed
into mncc_tx_to_cc().
2015-12-12 21:43:16 +01:00
Holger Hans Peter Freyther 53122b09d0 mncc: Use the default codec from the built-in mncc mode
In case of the RTP bridge mode we need to select the codec
ourselves. Rely on the same (incomplete) codec selection that
can be done using the mncc-int configuration node. This might
gain bearer capabilities support.

In case of a SDCCH a TCH/F will be attempted to be assigned.
This is an open issue for both modes and there should be a
preference for full or half-rate channels somewhere.
2015-09-14 10:12:29 +02:00
Holger Hans Peter Freyther c21dcb20e5 mncc: Implement CRCX->MDCX for handover for direct rtp mode
Implement sending MDCX on the newly allocated channel and send
the data to the same destination as the currently connected one.
This way the receiver can implement RTP RFC Appendix A.1 and
deal with the new source.
2015-09-14 10:12:29 +02:00
Holger Hans Peter Freyther c8a6c13e4e mncc: Implement the direct RTP mode for ip based systems
For the LCR rtp-bridge audio should directly flow to the
remote system. In contrast to the original patch audio
will now flow directly from the BTS to the remote system.
This assumes that BTS and the remote system are in the
same network segment and can directly communicate.

There are various limitations in the first iteration of
the implementation:

We could (and in the future) should delay the assignment
but currently we are forced to pick the channel and move
it to the audio state. In case we are located on a SDCCH
we always need to change but if we are on a TCH we could
send the ipa.CRCX and change the audio state a lot later.
The net effect is that the audio codec selection needs to
be done in the NITB code and not in the system connected
to it.

This only works with ip based systems. For E1 systems one
could still use the RTP socket or even try to move this
out of the process.

There is no code for handover handling and it relies on
the remote system dealing with the SSRC change of the
system.
2015-09-14 10:12:29 +02:00
Harald Welte b9845f937e GSM/GPRS 04.08: Don't print numeric mobile identity types
I guess none of our users knows what a mi_type=0x02 is, but most would
know what an IMSI or a TMSI is.  So let's use the newly introduced
gsm48_mi_type_name() function to fix this.
2015-08-18 19:35:02 +02:00
Andreas Eversberg 93e795c1fd Add check for non existing lchan at tch_frame_down()
Traffic cannot sent to BTS, if there is (currently) no logical channel
associated with the transaction.

This happens, if TCH traffic is received from upper layer, but there is
no lchan available before completing immediate assignment, handover or
assignment process.

[hfreyther: The code has not been moved to tch_frame_down
but the issue looks similiar]
2015-08-17 16:21:24 +02:00
Holger Hans Peter Freyther 666e36aea9 nitb: Add a mode to not use TMSI for normal operation
In case foreign simcards are used we can not do authentication
and ciphering. In case a TMSI is re-used too early and we do
page using TMSI we can't know which of the two MS is responding
to us. We could change the "secure channel" routine to ask for
the IMSI and only then stop the paging.

As we don't have ciphering there is not much use in using the
TMSI. Add a mode "no assign-tmsi" that will not assign the TMSI
during LU. Now CM Service Request and Paging Response  will
work using the IMSI. There can't be a clash with that.

[ciaby fixed the vty write to use the right name]
2015-08-01 23:49:16 +00:00
Holger Hans Peter Freyther 5f8a0c5c70 nitb: Be less strict about the reject cause
When we can't find the TMSI then the subscriber is not in our
VLR. We have not consulted with the HLR and it is better to not
use such a severe error code.
2015-08-01 23:49:16 +00:00
Ivan Kluchnikov 5fd0c64e0a gsm_04_08: Use osmo_assert for transt->conn and conn only in case of paging succeeded
setup_trig_pag_evt function can receive parameter conn = NULL, if T3113 expires.
2015-05-29 15:14:23 +02:00
Holger Hans Peter Freyther d6d7affa6e sub: Remove the queue from the subscriber code
The idea of "subscriber_get_channel" was that different
requests would be coordinated. At the same time we have
seen that the "queue" can get stuck at both 31C3 and the
rhizomatica installations.

Voice calls and SMS do not need coordination. We should
be able to send SMS on a voice channel and switch the MS
from a SDCCH to a TCH in case we establish a voice call.
The SMS code itself needs to coordinate to obey the limit
of one SMS per direction but this should be enforced in
the sms layer and not on the subscriber.

Modify the code to have a simple paging coordination. The
subscriber code will schedule the paging and register who
would like to know about success/failure.

This allowed to greatly simplify the paging response
handling for the transaction code (and in fact we could
move the transaction list into the subscriber structure
now). The code gained to support to cancel the notification
of a request (but not the paging itself yet).

TODO: Cancel paging request in case no one cares about it
anymore.
2015-04-29 18:53:28 +02:00
Holger Hans Peter Freyther 1ba0730a71 nitb: Allow the network to decide if a subscriber should be created 2015-01-27 10:44:17 +01:00
Holger Hans Peter Freyther b7ccac4d62 logging: Set the context for paging requests as well. 2015-01-02 11:43:06 +01:00
Harald Welte 5468f76861 convert away from deprecated gsm_7bit_{encode,decode}() functions
which removes yet another bunch of compiler warnings.
2015-01-01 12:41:39 +01:00
Jacob Erlbeck af792d6bb2 msc: Add net parameter to trans_alloc
The trans_alloc function still uses the subscr object to access the
network object.

This patch adds an explicit net parameter to this function and
removes the access to subscr to obtain it.

Sponsored-by: On-Waves ehf
2014-12-09 08:59:29 +01:00
Jacob Erlbeck 1e30a28e51 msc: Add and use gsm_subscriber_group
Currently every subcriber object directly refers to the gsm_network
which contains a flag shared by every related subscriber
(keep_subscr). This adds a dependency on gsm_network even if only the
function defined in gsm_subscriber_base.c are used.

This patch adds a new struct gsm_subscriber_group which contains the
keep_subscr flag and a back reference to the network object. The
latter is not dereferenced in gsm_subscriber_base.c, so it can safely
be set to NULL when only that part of the gsm_subscriber API is being
used. It also changes that API to use gsm_subscriber_group instead of
gsm_network parameters.

Since there are some places where a pointer to the gsm_network is
needed but where only a gsm_subscriber is available, a 'net' back
pointer is added to the group struct, too. Nevertheless subscr group
and network could be separated completely, but this is not the topic
of this commit.

Sponsored-by: On-Waves ehf
2014-12-05 14:59:02 +01:00
Jacob Erlbeck dae1f64ba6 msc: Don't use the subscriber to access the net object
Sponsored-by: On-Waves ehf
2014-12-05 14:58:41 +01:00
Jacob Erlbeck f07c605361 msc: Add net back pointer to gsm_trans
Currently the net pointer is obtained from trans->subscr->net. On the
other hand, the list gsm_trans object is managed by the net object.

This patch adds the back pointer to the structure and replaces all
trans->subscr->net by trans->net expressions. In trans_alloc() the
trans->net pointer is obtained from the subscr object.

Sponsored-by: On-Waves ehf
2014-12-05 14:56:35 +01:00
Andreas Eversberg 035b874fdf MNCC: Add IMSI to CALL CONFIRM message
LCR requires IMSI to correlate calls for MPTY (multi party conference)
and ECT (call transfer).
2014-08-04 08:59:16 +02:00
Andreas Eversberg d8967f76a5 Add support for AMR frames to MNCC/RTP interface
AMR rate is currently fixed to 5.9k.
2014-05-18 22:23:15 +02:00
Andreas Eversberg 72c0dbd753 bsc_api/NITB: If TCH/H channel is used, indicate it to bsc_api
If we don't do this, OsmoNITB will send an assignment command from
a TCH/H to another TCH/H without any need.
2014-05-18 22:23:15 +02:00
Andreas Eversberg a4d0e3cc6b Add check to tch_map(), if RTP sockets exist 2014-05-18 22:23:15 +02:00
Andreas Eversberg 63bfdd83ea mncc: Add support for half rate V1 frames to MNCC/RTP interface 2014-03-20 22:36:16 +01:00
Jacob Erlbeck 8e68b56fe5 sms/dtap: Add log messages to analyse SMS message loss
Incoming DTAP messages from MS are discarded during silent calls,
which leads to the repeated delivery of SMS since the ACKs are not
being processed.

This patch adds some log messages that have been helpful to track
this down.

Sponsored-by: On-Waves ehf
2014-01-31 11:17:44 +01:00
Andreas Eversberg dcf38e1c96 Add function to update TRAU muxer after assignment or handover
E1 based BTS use TRAU muxer to decode TRAU frames. After changing
channel from one timeslot to another (due to handover or assignment),
the TRAU muxer must be updated. The call reference of the call is
disconnected from the old channel and connected to the new channel.
2014-01-27 14:39:06 +01:00
Andreas Eversberg caae10b71f Remove obsolete check of conn and lchan pointers not beeing NULL
The check is removed from gsm48_cc_rx_setup() and gsm48_cc_rx_call_conf().
Receiving a layer 3 message implies that the transaction has a subscriber
connection and a logical channel.

This patch fixes the Coverity issues with CID 115311 and CID 1155312.
2014-01-16 20:49:07 +01:00
Andreas Eversberg a83d511b61 Each BTS can be configured for speech support (other than GSM full rate)
Speech codings which are not supported by BTS will be removed from the
bearer capability information element after parsing. This way it is not
required for the MNCC application to consider support of each BTS.

Only GSM full rate is supported by default.
2014-01-14 17:37:02 +01:00
Jacob Erlbeck f46e226428 nitb: Set the DST field in generated MM info messages
Currently the NET_DST information element (see GSM 24.008) is not
included in generated MM info messages even when the DST field in the
timezone info has been set via the VTY or the control interface.

This patch modifies gsm48_tx_mm_info() to append this information
element if (and only if) a non-zero DST has been configured. The
DST IE is not part of GSM 4.8. Therefore it will only be sent, if the
DST offset is configured to a value != 0.

The DST functionality has been verified with wireshark by Jacob.

Sponsored-by: On-Waves ehf
2014-01-08 10:49:26 +01:00
Holger Hans Peter Freyther 249b3f38c5 mncc: Add the context we get from the MNCC interface
Currently we only set the SUBSCR on RSL messages. Extend it to
messages that go through MNCC. For call control/bridging it is
difficult to pick the right subscriber. We should support a list
or at least two legs in the imsi filter context.
2013-12-29 20:24:37 +01:00
Holger Hans Peter Freyther 1a345ca48f lu crash: Fix a crash that likely occurred during the LU procedure
conn->loc_operation is already NULL (e.g. due a five second timeout but
we are still processing a RSL message after we initiated the release
procedure). Do not attempt to authorize a subcriber without knowing the
key_sequence.

This can cause more problems but we will need to test this in the field.

(gdb) bt
 #0  gsm0408_authorize (conn=0x19fc2f0, msg=<optimized out>) at gsm_04_08.c:323
 #1  gsm0408_authorize (conn=0x19fc2f0, msg=<optimized out>) at gsm_04_08.c:319
 #2  0x000000000043a99a in mm_rx_id_resp (conn=0x19fc2f0, msg=<optimized out>)
     at gsm_04_08.c:495
 #3  gsm0408_rcv_mm (msg=<optimized out>, conn=0x19fc2f0) at gsm_04_08.c:1041
 #4  gsm0408_dispatch (conn=0x19fc2f0, msg=<optimized out>) at gsm_04_08.c:3232

(gdb) p *conn
 $5 = {entry = {next = 0x1746930, prev = 0x1a14270}, subscr = 0x1745eb0,
  expire_timer_stopped = 1 '\001', loc_operation = 0x0, sec_operation = 0x0,
  anch_operation = 0x0, silent_call = 0, put_channel = 0, sccp_con = 0x0, in_release = 0,
  lchan = 0x7f8c79007218, ho_lchan = 0x0, bts = 0x1719f90, T10 = {node = {
      rb_parent_color = 0, rb_right = 0x0, rb_left = 0x0}, list = {next = 0x0, prev = 0x0},
    timeout = {tv_sec = 0, tv_usec = 0}, active = 0, cb = 0, data = 0x0},
  secondary_lchan = 0x0}
2013-12-27 17:37:27 +01:00
Holger Hans Peter Freyther 2147bc4cc9 periodic/lu: Attempt to implicitly attach a subscriber instead of rejecting
When modern Smartphones receive "Not in VLR". The baseband firmware
apparently does not try to do an IMSI ATTACH but just remains un-happy
and will not connect to the network anymore.
2013-12-27 17:22:32 +01:00
Andreas Eversberg d074f8f396 Add EFR support to TRAU muxer + test case
Decoding and encoding of FR and EFR TRAU frames are put into seperate
functions. CRC check is done to detect bad EFR TRAU frames.

The test case includes FR and EFR transcoding.

EFR support was tested with Nokia InSite BTS and Siemens BS11.
2013-12-19 10:12:28 +01:00
Jacob Erlbeck 24d3b91d46 bsc: Move gsm48_tx_mm_serv_ack/rej to gsm_04_08_utils.c
These functions are currently located in libmsc/gsm_04_08.c together
with other symbols that (transitively) depend on many external
symbols (and thus libraries) that aren't otherwise needed by e.g.
osmo-bsc.

Since gsm48_tx_mm_serv_ack() will be needed by osmo-bsc, these
functions are moved to avoid the dependency on gsm_04_08.o.

Sponsored-by: On-Waves ehf
2013-11-01 17:12:37 +01:00
Holger Hans Peter Freyther 28e183f385 Revert "bsc/ussd: Send faked CM Service Accept before sending USSD"
This reverts commit 61bd965b04.

No, we should not link to dbi.. and these libraries..
2013-10-31 13:35:28 +01:00
Jacob Erlbeck 61bd965b04 bsc/ussd: Send faked CM Service Accept before sending USSD
The MS do not show the USSD messages yet. This patch modifies the
implementation to insert a CM Service Accept before the ussdNotify
to finish the establishment of the MM connection according to
3GPP TS 04.10/3.2.1.

This fix has been tested with a Blackberry phone that has shown
an ussd_grace_txt after rf_locked has been set to '1'. Without this
patch, that message wasn't shown. The phone has sent a CC Setup
and other messages before processing the channel release message sent
by the BSC, but these messages have not been forwarded to the MSC (as
expected).

Ticket: OW#957
Sponsored-by: On-Waves ehf
2013-10-31 13:29:51 +01:00
Holger Hans Peter Freyther 7634ec1de1 db: Remove the struct gsm_network from the database layer
The database code should not know about the network. Move the
setting of the network pointer into the subscriber layer.
2013-10-13 13:44:54 +02:00
Alexander Chemeris a3d41c9124 Fix typo in console output: "PEROIDOC" -> "PERIODIC". 2013-10-04 08:18:14 +02:00
Andreas Eversberg a874b8d396 Fix: Handle CM service request on already secured channel correctly
Second part of the previous patch. Log an error message in case
we receive a location updating request on an already authenticated
channel.
2013-08-18 10:32:45 +02:00
Holger Hans Peter Freyther e7bd863f76 expiration: Speculative fixes for the periodic expiring handling
We were expiring subscribers during active calls. This is because
the T3212 is stopped under certain conditions but we didn't stop
that timer at all.

Remember if T3212 timer was stopped due something done by NITB and
update the expiration time at the end of the radio connection, as
the phone should restart it when returning to MM Idle.

It is a bit difficult to decide when we should set the flag. E.g.
in a CM Service Request we don't know if we accept the service and
during a LU we already send MM messages before we accept or reject
the subscriber.

The easiest is to set the flag when receiving a paging response
on known subscribers and at the end of the authentication process.

Do not expire a subscriber that has an active connection that is
marked with the flag, e.g. we would still expire a subscriber that
is being paged.

Manual tests executed/passed:

 * gst LUTest.st verified that a expiration date was set
 * gst SMSTest.st (doing another LU but forcing a timeout on the
   SMS sending). Verified that the expire_lu was updated.
2013-07-27 21:39:13 +02:00
Andreas Eversberg 641475cb81 Fix: Handle CM service request on already secured channel correctly
A CM service request must be acknowledged also, when encryption is already
enabled.

Without encryption enabled, the security status is GSM_SECURITY_NOTAVAIL,
which causes a CM service acknowledge. On initial CM service request, the
security status is GSM_SECURITY_SUCCEED, if encryption is enabled. This
will not lead to an acknowledge, because the cyphering command implies an
acknowlege. An additional CM service request requires an acknowledge, so
I added a new security status: GSM_SECURITY_ALREADY
2013-07-11 08:27:26 +02:00
Holger Hans Peter Freyther 1e61b25661 mncc: Remove what we believe to be a tautology from the MNCC code
Coverity pointed out that we use trans->subscr after a NULL check,
it is our believe that every transaction will have a subscriber.
Remove the check and add an assert before we are dispatching things.

Fixes: Coverity CID 1040740, CID 1040739
2013-07-06 11:45:38 +02:00
Andreas Eversberg e7ea08379e CC: gsm48_cc_tx_release() must not remove callref
If after release has been sent, the call control layer waits for:
- reception of release complete
- or timeout
- or release of transaction (due to radio link failure)
In this case, an MNCC_REL_CNF is sent to upper layer. The callref must
still exist, so the upper layer can handle this confirm.
2013-01-25 08:43:01 +01:00
Andreas Eversberg 1590727b64 CC: mncc_release_ind() must send MNCC_REL_CNF in state N19
If transaction is destroyed, but callref still exists, the
mncc_release_ind function is called. If the upper layer already sent an
MNCC_REL_REQ, the state N19 was entered. In this case it expects an
MNCC_REL_CNF.
2013-01-25 08:38:29 +01:00
Holger Hans Peter Freyther 4d2a68cf11 misc: Do not use else when using return in the previous branch 2013-01-01 17:18:27 +01:00
Sylvain Munaut 11c1b6e014 libmsc: Refuse service to anyone not attached
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-01-01 17:03:15 +01:00
Daniel Willmann 977cd13741 gsm_04_08: Display debug message correctly on DETACH INDICATION
Log messages would get mangled before if we receive detach by TMSI or
IMSI.
2012-12-29 12:47:31 +01:00
Holger Hans Peter Freyther c121bb3188 handover: Fix the handover signalling for IP based BTSes
This was reported by Kevin when he was testing handover. The problem
is the order of the signal handlers for S_ABISIP_CRCX_ACK. Right now
the handover signal handler is called before the one inside the libmsc
gsm_04_08.c. This means S_HANDOVER_ACK is signalled _before_ there is a
rtp socket created for the channel. The result is that the MDCX will
never be sent and the called will not be properly switched _after_ the
handover detection.

I do not want to play with the order of signal handlers, remove the
CRCX ack handling from the handover_logic.c and force the NITB (and
later the BSC) to check if the lchan is involved with a handover and
do the switching in there. This means right now we do what two signal
handlers did in one.

Reproduced and tested with the FakeBTS Handover test.

Log message:
<0004> abis_rsl.c:1954 (bts=1,trx=0,ts=3,ss=0) IPAC_CRCX_ACK ...
<000c> gsm_04_08.c:1400 no RTP socket for new_lchan
<001a> rtp_proxy.c:533 rtp_socket_create(): success
<001a> rtp_proxy.c:615 rtp_socket_bind(rs=0x48703c8, IP=0.0.0.0): ...
2012-12-26 10:32:02 +01:00
Holger Hans Peter Freyther 3e9b2ec257 libmsc: Avoid a crash on lchan release during call control
If subscriber A is calling B and has sent a CC Setup message we will
allocate the MO and MT transaction and link them together. When the
BTS or the lchan is failing the BSC API will send a clear request,
as part of the clear request all pending transactions will be released.

As part of taking down the transaction, the remote leg will be informed
and will send a MNCC_REL_REQ. This results in a call to trans_free. The
llist_for_each_entry_safe does not handle removing other elements from
the list and we would segfault.

One way to fix this is to move the transaction list into the subscriber
connection. This might require to create the subscriber connection for
MT handling earlier. Otherwise one could have one transaction list inside
the subscriber connection and a global list for MT- transactions.
2012-12-22 18:45:27 +01:00
Holger Hans Peter Freyther 408208d887 nitb: Do not crash on IMSI Detach messages from a phone
This has been reported and analyzed by Tobias Engel. The IMSI Detach
is dispatched as part of the complete layer3 message. I had patched
the code to release the anchor and call msc_release_connection to
release the connection as fast as possible (otherwise the anchor would
trigger in a couple of seconds).

With commit 70ae5d3000 I made this more
generic to release the connection immediately if there are no operations,
no transaction and no silent call. This leads to the subscriber connection
being released twice and eventually causing a segfault. Remove the
msc_release_connection invocation from the IMSI Detach code as the connection
will be taken down by the BSC API.

This has been tested using the FakeBTS and an IMSI Detach message. The
channel is released immediately and the nitb does not crash.
2012-12-16 14:12:38 +01:00
Holger Hans Peter Freyther a5050b14c9 misc: Address compiler warning on unused variables
abis_nm.c: In function ‘abis_nm_get_attr’:
abis_nm.c:1380:11: warning: unused variable ‘cur’ [-Wunused-variable]

abis_nm.c: In function ‘ipac_parse_bcch_info’:
abis_nm.c:2588:11: warning: variable ‘len’ set but not used [-Wunused-but-set-variable]

bts_nokia_site.c:1310:6: warning: variable ‘constructed’ set but not used [-Wunused-but-set-variable]
bts_nokia_site.c: At top level:
bts_nokia_site.c:1364:12: warning: ‘dump_elements’ defined but not used [-Wunused-function]

gsm_04_08.c: In function ‘mm_rx_loc_upd_req’:
gsm_04_08.c:521:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]

osmo_msc.c: In function ‘msc_ciph_m_compl’:
osmo_msc.c:122:7: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]

bts_hsl_femtocell.c: In function ‘hslfemto_bootstrap_om’:
bts_hsl_femtocell.c:101:11: warning: variable ‘cur’ set but not used [-Wunused-but-set-variable]

bts_hsl_femtocell.c: In function ‘hsl_drop_oml’:
bts_hsl_femtocell.c:232:21: warning: variable ‘line’ set but not used [-Wunused-but-set-variable]

handover_logic.c: In function ‘ho_chan_activ_ack’:
handover_logic.c:197:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
2012-09-11 12:41:23 +02:00