Commit Graph

1279 Commits

Author SHA1 Message Date
Vadim Yanitskiy 531d3a4b11 SMS-over-GSUP: move net->sms_over_gsup check to gsm411_gsup_rx()
Change-Id: I89988b7148b164af304ecae1f53b74f322fdc7bd
2020-04-26 23:55:48 +07:00
Vadim Yanitskiy 46b0f80e69 SMS-over-GSUP: clarify error message about unexpected MO/MT SMS
Change-Id: I34b25764f9ce9b09ccd28cf23fea01028d0828e0
2020-04-26 14:45:29 +00:00
Harald Welte 61ec0295fc vlr_auth_fsm: Fix compilation with gcc-10
See also: https://alioth-lists.debian.net/pipermail/debian-mobcom-maintainers/Week-of-Mon-20200413/000650.html

Change-Id: If3fdbfa20dec02ba57c582700dff12ebbb7d9439
2020-04-20 18:18:18 +00:00
Neels Hofmeyr ebf55f4b31 fix segfault: unsolicited Paging Response
Do not crash when a Paging Response could not be associated with a VLR
subscriber.

Related: OS#4449
Change-Id: Ie117949dd6da86afaa1a0a6ac57bf2111f6cff43
2020-03-09 21:02:31 +01:00
Vadim Yanitskiy 40b11c9ba4 libmsc/sdp: cosmetic: fix less-than-zero comparison of an unsigned value
Change-Id: I57ed17d8457ada69a3c22233f30339d2c0f65bce
Fixes: CID#206075
2020-02-09 04:05:08 +07:00
Vadim Yanitskiy ef830ef225 osmo-msc: use stderr to print error messages, not stdout
Change-Id: I702dd054d2e881b526f701ca482ec0f64ba8da28
2020-01-29 00:18:23 +07:00
Vadim Yanitskiy 5b19f6ed1e libmsc/gsm_04_08: use DRR in gsm48_rx_rr_pag_resp(), not DMM
Change-Id: I006c2b4c684dc6b96e98dbb82063a0aa37e33c66
2020-01-27 18:21:08 +00:00
Vadim Yanitskiy 6a9a3a779f libmsc/gsm_04_08: make use of msc_a in gsm48_rx_rr_app_info()
Change-Id: I2a0991c9bbf86b7eb248d74334f9472c56a3c964
2020-01-27 18:21:08 +00:00
Vadim Yanitskiy 9b56cd893b VTY: cosmetic: make struct cmd_node for GSMNET_NODE static
We don't need to expose it anyway.

Change-Id: Icbaed6b3b15aa719a19bb4be8fed347073025a22
2020-01-27 18:21:08 +00:00
Vadim Yanitskiy 601af0ca00 vlr_sgs_fsm: add missing break, do not call to_null() twice
Change-Id: Ib5d1d7633ca6c32d7d63bb1481f51355c97b90fb
2020-01-27 18:21:08 +00:00
Vadim Yanitskiy 3daf0c2786 vlr: remove unused parameter 'log_level' of auth_fsm_start()
We unconditionally use logging level of the parent FSM anyway.
All callers of auth_fsm_start() always pass fi->log_level.

Change-Id: If2fdf2564eb56d3d94ec3800bdcb0aabcad4e48d
2020-01-27 18:21:08 +00:00
Vadim Yanitskiy fc2b019cd8 libmsc: move subscriber expiration timer T3212 to libvlr
Since the split of OsmoNiTB, OsmoMSC does not deal with the radio
access network directly. Therefore the only purpose of T3212 is to
control subscriber expiration in the local VLR. The timeout value
indicated in System Information Type 3 needs to be configured
separately in the BSC/RNC.

This means that we don't need to store it in deci-hours anymore.
Let's move T3212 to the group of VLR specific timers, so it can
be configured and introspected using the generic 'timer' command,
and deprecate the old '[no] periodic location update' command.

It should be also noted that in the old code subscriber expiration
timeout was actually set to twice the T3212 value plus one minute.
After this change, we apply the configured value 'as-is', but
keep the old behaviour for 'periodic location update' command.

Change-Id: I9b12066599a7c834a53a93acf5902d91273bc74f
2020-01-25 12:49:42 +07:00
Vadim Yanitskiy baf71a72ec libvlr: use generic osmo_tdef API for T3250, T3260, and T3270
These timers so far were implemented as a list of unsigned integers,
which has never been initialized to any reasonable defaults. Since
they are used as state timeouts in several FSMs, we might end up
staying in some state forever.

Let's migrate to generic osmo_tdef API and use default values from
table 11.2 of 3GPP TS 24.008. This way the user can introspect and
change their values from the VTY / configuration file.

Change-Id: Ia8cf98da0aea0e626c5ff088a833d7359c43847f
Related: OS#4368
2020-01-25 10:52:26 +07:00
Vadim Yanitskiy ffc7f39f01 VTY: add osmo_tdef introspection and configuration commands
This change introduces several new VTY commands letting the user
a possibility to introspect and reconfigure some of the existing
timers implemented using libosmocore's osmo_tdef API.

At the moment this covers the following timers:

  - MGW specific timers:
    - X1 - MGCP response timeout,
    - X2 - RTP stream establishing timeout,

  - RAN specific timers (same names for GERAN and UTRAN):
    - X1 - Authentication and Ciphering timeout,
    - X2 - RAN connection release sanity timeout,
    - X3 - Handover procedure timeout.

The following commands are introduced:

  - 'enable' node:
    - show timer [(mgw|mncc|sccp|geran|utran|sgs)] [TNNNN]

  - 'config-msc' node:
    - timer [(mgw|mncc|sccp|geran|utran|sgs)] [TNNNN] [(<0-2147483647>|default)]

Both MNCC and SCCP related timer definitions are empty at the
moment. Achieved by using osmo_tdef_group API of libosmovty.

Change-Id: I6024c104b6101666c8aa1108a043910eb75db9a5
Related: OS#4368
2020-01-25 10:24:14 +07:00
Vadim Yanitskiy b7ddbf377f VTY: mark 'subscriber create imsi' command as deprecated
Neither it should appear in the interactive VTY nor in documentation.

Change-Id: I208faab69a40948af5d081edbeaf75f586dfb2e4
2020-01-25 08:17:56 +07:00
Vadim Yanitskiy 047dd50bc8 osmo-msc: fix: properly initialize default values for MGW timers
Otherwise they're all set to 0, if not configured in the VTY.

Change-Id: I4a0823c2f0ca50ed7407fb0457c54a485799c585
2020-01-19 03:59:47 +07:00
Pablo Neira Ayuso 83616a8e5f libmsc: SMS, Avoid premature RP-ACK to MS
There was one libmsc commit to openbsc that was
thus far missing in osmo-msc.

This commit completes the work on delayed response
from an ESME. Without this patch, the SMR sends
an RP-ACK to the mobile station, and subsequently a
DELIVER_SM_REPONSE from the ESME provokes either a second
RP-ACK, or an RP-ERROR; both of which result in
"unhandled at this state (IDLE)" from the SMR

After this patch, we have two things corrected:

1) RP-ERROR respects Deliver-SM error cause.
2) No more "unhandled as this state" error from the SMR

Extract from original commit message:
--------
libmsc: annotate esme route in the sms object from deliver_to_esme()

Annotate this esme route, so we can use it to return -EINPROGRESS to
skip sending premature RP-ACK to the mobile station, in case we're
handling sms routes through SMPP.
--------

Fixes: #OS4351
Change-Id: Ic34d398e0a850856e20380ae35e5c2ae5e3c539b
2020-01-15 14:47:04 +00:00
Keith Whyte 2cad562eb2 Trivial: code simplification, return early
This commit also, (for what it is worth) removes a
difference to the same file in openbsc, which I found
while looking for changes that affected SMPP delivery.
This is essentially a "forward-port" of [1]

[1] https://gerrit.osmocom.org/#/c/openbsc/+/3899/

Change-Id: I350c19f5bb70b2656171c096334c2ee83f49df7e
2020-01-13 06:34:35 +01:00
Keith Whyte b67131595f Use GSM411_RP_* and not GSM48_CC_*
d34ed5768c introduced
comparison of GSM411_RP_CAUSE_MO_NUM_UNASSIGNED with
GSM48_CC_CAUSE_UNASSIGNED_NR

For consistency lets use the GSM411_RP constants
in SMS related code.

Change-Id: Ie54966560f66d2dcde905feb2eb19ef90406acd1
2020-01-11 13:07:14 +01:00
Neels Hofmeyr 02dd265d68 vlr.c: fix condition to check MSISDN presence
msisdn_enc is a buffer, its address is always != 0

Change-Id: Ib2294d2cd339c36df599d7d134f979a572ac308a
2020-01-06 18:00:40 +01:00
Neels Hofmeyr 27c8b033fc vlr_gsup_rx: fix uninitialized rc
Change-Id: Id7776a473b8356d1d136d78736698f20accc7a36
2020-01-06 18:00:31 +01:00
Vadim Yanitskiy a79aac0113 libmsc/gsm_04_08.c: fix: verify MI before calling vlr_subscr_rx_id_resp()
During the last congress, we have noticed that OsmoMSC crashes
on receipt of malformed MM Identity Response messages:

  BSSAP
      Message Type: Direct Transfer (0x01)
      Data Link Connection Identifier
          00.. .... = Control Channel: not further specified (0x0)
          ..00 0... = Spare: 0x0
          .... .000 = SAPI: RR/MM/CC (0x0)
      Length: 11
  GSM A-I/F DTAP - Identity Response
      Protocol Discriminator: Mobility Management messages (5)
          .... 0101 = Protocol discriminator: Mobility Management messages (0x5)
          0000 .... = Skip Indicator: No indication of selected PLMN (0)
      01.. .... = Sequence number: 1
      ..01 1001 = DTAP Mobility Management Message Type: Identity Response (0x19)
      Mobile Identity - Format Unknown
          Length: 8
          .... 1... = Odd/even indication: Odd number of identity digits
          .... .111 = Mobile Identity Type: Unknown (7)  <-- This makes OsmoMSC crash
              [Expert Info (Warning/Protocol): Unknown format 7]
                  [Unknown format 7]
                  [Severity level: Warning]
                  [Group: Protocol]

The value '111'B is not a valid Mobile Identity type, and shall be
considered as reserved according to 3GPP TS 24.008, section 10.5.1.4.
Later on it was discovered that '000'B also crashes OsmoMSC in the same way.

The crash itself is provoked by OSMO_ASSERT(0) in vlr_subscr_rx_id_resp().
Let's keep that assert in there, and make sure that:

  - on receipt of MM Identity Response, Mobile Identity type
    matches the one in MM Identity Request;

  - on receipt of RR Ciphering Mode Complete, Mobile Identity
    contains IMEI(SV) if present.

Change-Id: Ica4c90b8eb4d90325313c6eb400fa4a6bc5df825
TTCN-3 test case: I62f23355eb91df2edf9dc837c928cb86b530b743
Fixes: OS#4340
2020-01-05 11:23:09 +00:00
Vadim Yanitskiy 6e72282454 libmsc/gsm_04_11_gsup.c: fix SM-RP-OA encoding for MO SMS over GSUP
We shall not include additional BCD length octet into the value part
of SM-RP-OA (Originating Address) IE. Instead, there should be
ToA/NPI header (1 octet).

Since we do not get ToN/NPI fields from the VLR/HLR, let's assume
the following default values:

  1... .... = Extension: No extension
  .001 .... = Type of number: International (1)
  .... 0001 = Numbering plan: ISDN/telephone (E.164/E.163) (1)

Change-Id: I0f32e2af0ed2d2fea6addf45efbdfee120c2425d
TTCN-3 test case: Ib467eeca6439bc6cce72293fbb5bb48f6d233db9
Related: OS#4324
2019-12-19 22:12:18 +09:00
Vadim Yanitskiy 61f4780f29 libmsc/gsm_04_11_gsup.c: do not init a buffer in gsm411_gsup_mo_fwd_sm_req()
Because there is no real need for that.

Change-Id: I19d4d0de0d5a46bf1de194b966f18ea8a84ced94
2019-12-19 22:08:23 +09:00
Neels Hofmeyr 3d6a8be0f9 sms log tweak
Change-Id: I77e7a1501f74b9045f032c5b6c2322025a11fd59
2019-12-12 15:46:57 +00:00
Neels Hofmeyr a252bcd089 sms db: when storing an SMS, retrieve the ID
seemed like a good idea, but not sure if we need it at all.

Change-Id: I5fa55307a6abb8bbfe56619235d7b79fbbda6caf
2019-12-12 15:46:41 +00:00
Neels Hofmeyr 63b246453b gsup: indicate CN-Domain in SendAuthInfo Requests
In order for osmo-hlr to be able to 100% guarantee distinct INDs for CS and PS,
set CN-Domain = CS in all SendAuthInfo Requests.

In Milenage auth, it is highly desirable that osmo-hlr guarantees use of
distinct INDs for CS and PS domains.  If an MSC and SGSN attached at the same
time use the same IND bucket to generate Milenage SQN, that collision would
rapidly waste SQNs and load osmo-hlr with requesting new auth tuples on each
CS/PS Complete-Layer3.

So far, osmo-msc did not indicate the CN domain in the GSUP SendAuthInfo
Request, which was neither required nor evaluated. The CN-Domain is only sent
for the UpdateLocation Request that usually follows later.

Related: OS#4318
Change-Id: I22f44068268e62801cadbf6542efaf153423cd65
2019-12-12 02:10:06 +01:00
Harald Welte abbdbfbbab msc: exit(2) on unsupported positional arguments on command line
Change-Id: Iad858974e9d97ae14f3da6dc21267aafafcda0ef
2019-12-03 22:19:32 +01:00
Vadim Yanitskiy db4839c267 libmsc: fix potential NULL-pointer dereferences detected by GCC's LTO
Change-Id: Ib7ba8909dce64d1b8ff3a53495fe3eefc446ed8e
2019-12-02 08:44:53 +00:00
Harald Welte 34a8cc33a2 Check for osmo_fsm_register() error return value
Change-Id: I4cce3d6798fe3184a3085d114b749b4645620978
2019-12-01 15:32:09 +01:00
Harald Welte e000050971 check for osmo_ss7_init() error return value
Change-Id: I2bc34f3962ca7355f20757e36a86ab2fd1a7aef6
2019-12-01 13:19:51 +01:00
Neels Hofmeyr b455205783 MNCC v6: add optional SDP to the socket protocol
Add a char buffer of 1024 characters length as space for SDP to pass to /
receive from MNCC.

Actually support receiving MNCC without such an SDP tail. The main reason for
this is to avoid the need to adjust the ttcn3 implementation of MNCC: it would
stop working for older osmo-msc.

Older or non-SIP MNCC peers could operate the previous MNCC protocol unchanged
(save the protocol number bump) without having to implement SDP.

The SDP part in the MNCC protocol will be used in upcoming patch
I8c3b2de53ffae4ec3a66b9dabf308c290a2c999f.

This patch must be merged at the same time as osmo-sip-connector patch
Iaca9ed6611fc5ca8ca749bbbefc31f54bea5e925, so that both sides have a matching
MNCC protocol version number.

Change-Id: Ie16f0804c4d99760cd4a0c544d0889b6313eebb7
2019-11-28 02:52:55 +01:00
Neels Hofmeyr eef4578102 add sdp_msg API: SDP parsing/composition
Rationale: in order to add full SDP to the MNCC protocol (upcoming patch
I8c3b2de53ffae4ec3a66b9dabf308c290a2c999f), we need to parse and compose SDP
messages. Obviously, libosmo-mgcp-client already contains similar code, but
that is unfortunately heavily glued to the actual MGCP implementation. The
simplest solution is to create this separate implementation, copy-pasting from
the existing libosmo-mgcp-client code as is convenient.

This API is added here to probe whether it works well. When it does, the
intention is to "move it up" to osmo-mgw and overhaul the SDP parsing in our
MGCP client and MGCP server APIs using this same API.

Change-Id: If3ce23cd5bab15e2ab4c52ef3e4c75979dffe931
2019-11-28 02:52:55 +01:00
Neels Hofmeyr bde605dfc5 fix incoming call while Paging
Do not free the CC transaction when an MT subscriber is already being Paged.
Instead, invoke another paging request, which paging.c will correctly add to
the list of pending paging response callbacks to run.

A ttcn3 test is linked in the related patch (s.b.).

Related: OS#4240
Related: Ieeae6322d4e80893ea3408c6b74bf8e32bea8e46
Change-Id: Idd4537b5f4817d17e5c87d9a93775a32aee0e7be
2019-11-28 02:52:55 +01:00
Neels Hofmeyr 00a476bc24 msc_a CC: add some basic sanity tests
Change-Id: I9d7d7d4073282abc6c02a6a297c807dc70c5154c
2019-11-28 02:46:05 +01:00
Neels Hofmeyr cc918cb416 fail on invalid RTP address from MGW
When the CRCX OK returns an invalid RTP address, abort the call; fixes
MSC_Tests.TC_invalid_mgcp_crash.

The original crash happened when adding this error handling without this commit
I08c03946605aa12e0a5ce8b3c773704ef5327a7a ("fsm: use deferred deallocation" for
osmo-mgw I7df2e9202b04e7ca7366bb0a8ec53cf3bb14faf3 "fix use-after-free: require
new fsm deferred dealloc, check for term"). With this error handling added,
even though avoiding a crash, the test does not pass yet, because instead of
rejecting the call, it currently composes an Assignment Command without a
Transport Layer Address. Fix that.

Change-Id: I00c3b5ff74c05bcc2b7c39375c33419916a57193
2019-11-28 02:45:40 +01:00
Martin Hauke 3f07daceef Fix some typos
Fix typos and common misspellings in code comments and log messages.

Change-Id: Ie66b89065f2100c1d2125ce5a6c9b1d58df7c8ad
2019-11-19 01:04:34 +00:00
Neels Hofmeyr 8a50cfbc4e BSSMAP: decode Codec List (BSS Supported)
Actually decode the Codec List (BSS Supported) in BSSMAP, in both the Complete
Layer 3 Information and the Assignment Complete messages.

An upcoming patch improves codec negotiation and requires the BSS supported
codecs, which are so far ignored (which is/was a pity as osmo-bsc goes at great
lengths to compose those IEs).

Change-Id: I66c735c79e982388f06b5de783aa584c9d13569e
2019-11-05 01:33:30 +01:00
Neels Hofmeyr e04cd98121 cc trans: remove unused tch_rtp_create
Use of this flag was dropped when adding inter-BSC and inter-MSC Handover
support, I forgot to remove it.

Change-Id: I5ec78e30eb36fbe78a3f7c46bfa44af5a4eb7bf2
2019-11-05 01:33:30 +01:00
Neels Hofmeyr f439ff121f CC: add error handling for CRCX responses
Fix three 'FIXME: ERROR HANDLING' occurences in the code that reacts upon the
MGW providing (or failing to provide) an RTP port for the RAN side. From an
earlier stage of the code, the cleanup for this situation was extremely
complex, and hence the choice was to simply wait for the call to time out and
fail. But since we have implemented safe deallocation of nested FSMs in
libosmocore, the situation has become rather trivial: simply free the CC
transactions, and all the rest will immediately release, and terminate
correctly without crashing.

A ttcn3 test for this is MSC_Tests:TC_invalid_mgcp_crash, which actually also
needs the change to osmo_sockaddr_str_is_nonzero() in preceding patch
I53ddb19a70fda3deb906464e1b89c12d9b4c7cbd, so that a seemingly valid MGCP
message ends up causing a failure in the on_success() branch of
mgcp_client_endpoint_fsm.c.

Change-Id: I8313bed1d782100bebeac7d8fc040557c4cb653e
2019-11-01 17:35:17 +01:00
Neels Hofmeyr 84ce206ae3 use osmo_sockaddr_str_is_nonzero()
Also regard an RTP port as invalid if the IP address is 0.0.0.0.
Achieve this by using osmo_sockaddr_str_is_nonzero() instead of
osmo_sockaddr_str_is_set().

Depends: I73cbcab90cffcdc9a5f8d5281c57c1f87b2c3550 (libosmocore)
Change-Id: I53ddb19a70fda3deb906464e1b89c12d9b4c7cbd
2019-11-01 17:35:17 +01:00
Neels Hofmeyr 523b92f3aa rtp_stream: sanely cancel MGW endpoint FSM notify
libosmo-mgcp-client recently introduced osmo_mgcpc_ep_cancel_notify() to cancel
notification if a notify target FSM deallocates. Use it for sanity in
rtp_stream FSM cleanup, the notify target for endpoint FSMs.

Depends: I41687d7f3a808587ab7f7520f46dcc3c29cff92d (osmo-mgw)
	 I14f7a46031327fb2b2047b998eae6ad0bb7324ad (osmo-mgw)
Change-Id: I351bb8e8fbc46eb629bcd599f6453e2c84c15015
2019-11-01 17:35:17 +01:00
Neels Hofmeyr 33f71a1200 fsm: use deferred deallocation
Since osmo-bsc uses the MGCP client FSMs, it is required to enable this new
feature to guarantee safe operation. The issue is described in detail in commit
logs linked below.

Notably, osmo-msc currently chooses to omit error handling during MGCP events
(marked "FIXME"). An upcoming patch implements this error handling, and would
make osmo-msc vulnerable to crash from unexpected MGCP messages without this.

Deferred FSM deallocation is a more general, simpler approach to
osmo_fsm_term_safely(), so we can switch that off now.

Depends: Ief4dba9ea587c9b4aea69993e965fbb20fb80e78 (libosmocore),
         I0adc13a1a998e953b6c850efa2761350dd07e03a (libosmocore)
Related: I7df2e9202b04e7ca7366bb0a8ec53cf3bb14faf3 (osmo-mgw)
Change-Id: I08c03946605aa12e0a5ce8b3c773704ef5327a7a
2019-11-01 17:33:02 +01:00
Neels Hofmeyr cf90bdb07d send MNCC REL only if MNCC has actually started
Change-Id: I07b2b6c0ee33f5d3e0a060c10cf36d5c7c9f0d9b
2019-10-29 16:46:32 +01:00
Neels Hofmeyr 0c1ed15336 log: ran_msg_a: tweak a message name
Change-Id: I691025cb957e9b87c8af2dc8eb741dcba6ca26e2
2019-10-29 16:46:32 +01:00
Neels Hofmeyr fe5ae8ef5b log: RANAP encode: use RANAP message names instead of BSSAP
Change-Id: Ib0e0630d775a28958ea86802f70cbeec07087f91
2019-10-29 16:46:32 +01:00
Neels Hofmeyr 72fc706af5 BSSMAP log tweak
Before:
  RAN decode: BSSMAP: Rx BSSMAP DT1 COMPLETE LAYER 3
After:
  RAN decode: BSSMAP: COMPLETE LAYER 3

This caught my attention while I was writing up a script to parse osmo-msc
logging to produce ladder diagrams.

Change-Id: I387dde8f2eb3edb35d22ce52dc0ed580978dea36
2019-10-29 16:46:32 +01:00
Neels Hofmeyr c67b4831c4 also log MNCC_SETUP_REQ
If an incoming MNCC_SETUP_REQ ends up in Paging (as usually it does), the early
return so far skipped logging of that MNCC message. Add this logging.

Change-Id: I1495dd562a06cf6c1e9453a1fe111bdf8f4be081
2019-10-29 16:46:32 +01:00
Neels Hofmeyr 467bb87f44 log: drop duplicate MNCC log
Change-Id: I46055a4f7a6ae517772c6794faad8c775454974a
2019-10-21 00:40:31 +02:00
Neels Hofmeyr c192c0bf71 log which DTAP messages are sent to RAN
So far, the logging said only "RAN encode: BSSMAP: DTAP", but not *which* DTAP
message, which is in fact a very interesting detail when reading osmo-msc logs.

Change-Id: I0cb8d1e3307737ffe53730c64bb984adacedb2da
2019-10-21 00:40:31 +02:00
Neels Hofmeyr f636e6cedd LOG_TRANS for CC: always log CC state
For all CC type transaction logging, log the current trans->cc.state string for
all LOG_TRANS*() logging.

Change-Id: I67be12c74c679ce684f8c0b9b4e0d96299849dc6
2019-10-21 00:40:31 +02:00
Alexander Couzens a09f4987c1 vlr_auth_fsm: on SAI use the GSUP provided GMM cause code
The HLR might respond with a specific GMM cause code. E.g. roaming not
allowed which needs to be passed down the layers.

Change-Id: I9af515dc52834b7c57c42fc3a76ee2c682734e2a
2019-10-17 08:02:07 +00:00
Alexander Couzens 7312b15830 make vlr_gmm_cause_to_mm_cause public
To be used by vlr_auth_fsm

Change-Id: I9e13e756f359a9b9e6a2056ab37adf0af14afec1
2019-10-17 08:01:42 +00:00
Neels Hofmeyr 1bfe0e1cd1 catch GSUP auth result without auth_fsm
When a vlr_subscr receives an Send Auth Info result, properly check whether the
subscriber has an auth_fsm.

Before, a missing auth_fsm would crash osmo-msc with:

    vlr.c:762 Trying to dispatch event 1 to non-existent FSM instance!

Related: OS#4191
Change-Id: I1995d8f68cfde1140968fb9a97bd054de950de2e
2019-09-26 23:05:51 +00:00
Philipp Maier 002fb01faa paging: Send SGsAP-SERVICE-ABORT-REQUEST on paging timeout
When pagig for a CS-Call via SGs times out, the MME expects to be
informed about this via an SGsAP-SERVICE-ABORT-REQUEST, make sure this
message is sent, but only for CS-Fallback calls.

Change-Id: I3f8f153afe24cf2efa245713509bdc8488902877
Depends: osmo-ttcn3-hacks I99950a17ccf26aaa0eebded5480f33be4c57586a
Related: OS#3614
2019-09-26 19:23:54 +00:00
Philipp Maier 6dcdfb036a sgs_iface: Accept messages with unknown TLV elements
3GPP TS 29.118, chapter 7.5 states that unknown TLV elements should be
ignored rather than that the whole message is discarded a STATUS message
is sent. Lets turn the returncode check of the tlv_parse() call into a
log message and continue normally.

Change-Id: Ic6714451ad970043d4765f8420d753daf5294a44
Related: OS#4214
2019-09-24 11:48:19 +02:00
Neels Hofmeyr e9a3911844 fix error on BSSMAP Cipher Mode Complete L3 msg IE
When an MS returns the IMEISV in the BSSMAP Cipher Mode Complete message in
the Layer 3 Message Contents IE, do not re-invoke the decode_cb() a second
time, but instead point to it from the ran_msg.cipher_mode_complete struct.

When the MSC-A decodes the Ciphering Mode Complete message, it always wants to
also decode the enclosed DTAP from the Layer 3 Message Contents IE. However,
when the MSC-I preliminarily decodes messages, it often just wants to identify
specific messages without fully acting on them, let alone dispatching RAN_UP_L2
events more than once. So leave it up to the supplied decode_cb passed to
ran_dec_l2() implementations to decide whether to decode the DTAP.

In msc_a.c hence evaluate the DTAP by passing a msgb to msc_a_up_l3(), which
will evaluate the RR Ciphering Mode Complete message found in the BSSMAP Cipher
Mode Complete's Layer 3 Message Contents IE.

Particularly, the previous choice of calling the decode_cb a second time for
the enclosed DTAP caused a header/length parsing error: the second decode_cb
call tried to mimick DTAP by overwriting the l3h pointer and truncating the
length of the msgb, but subsequently ran_a_decode_l2() would again derive the
l3h from the l2h, obliterating the intended re-interpretation as DTAP, and
hence the previous truncation caused error messages on each and every Cipher
Mode Complete message, like:

DBSSAP ERROR libmsc/ran_msg_a.c:764 msc_a(IMSI-26242340300XXXX:MSISDN-XXXX:TMSI-0xA73E055A:GERAN-A-77923:LU)[0x5563947521e0]{MSC_A_ST_AUTH_CIPH}: RAN decode: BSSMAP: BSSMAP data truncated, discarding message

This error was seen a lot at CCCamp2019.

Modifying the msgb was a bad idea to begin with, the approach taken in this
patch is much cleaner.

Note that apparently many phones include the IMEISV in the Cipher Mode Complete
message even though the BSSMAP Cipher Mode Command did not include the Cipher
Response Mode IE. So, even though we did not specifically ask for the Cipher
Mode Complete to include any identity, many MS default to including the IMEISV
of their own accord. Reproduce: attach to osmo-msc with ciphering enabled using
a Samsung Galaxy S4mini.

Related: OS#4168
Change-Id: Icd8dad18d6dda24d075dd8da72c3d6db1302090d
2019-09-18 15:31:13 +02:00
Alexander Couzens eb1b03a98a vlr: gmm_cause_to_fsm_and_mm_cause() drop fsm_cause_p argument
It's always set to OSMO_TERM_ERROR. Move the assignment to the caller.
In prepartion to use gmm_cause_to_fsm_and_mm_cause() in vlr_auth_fsm.

Change-Id: Ie4720ad40ef7bcfc528d8d63bfc606c9c0545fb2
2019-09-16 17:57:39 +00:00
Pau Espin b08a380420 vty: fix access to wrong argv in paging response-timer
Fixes: 2ff5bcdc38
Change-Id: I667cf4c8e3e7b6e77ea6ed8ae603727ad22a2ee2
2019-09-16 19:01:40 +02:00
Neels Hofmeyr 01653252b4 msc_a fsm: ignore state chg to same state
We sometimes see errors like

   libmsc/msc_a.c:361 msc_a(...){MSC_A_ST_RELEASING}: transition to state MSC_A_ST_RELEASING not permitted!

i.e. changing state to the state msc_a is already in.

Ignore re-entering the same state for most state changes. However, there is one
state change in msc_a where re-entering the MSC_A_ST_VALIDATE_L3 is necessary
to start the timeout.

Hence add msc_a_state_chg_always() and use that for re-entering
MSC_A_ST_VALIDATE_L3. Change msc_a_state_chg() to skip no-op state changes.

This should silence all no-op state change error messages for msc_a.

Related: OS#4169
Change-Id: I0c74c10b5fa7bbdd6ae3674926cc0393edf15a35
2019-09-03 13:59:05 +00:00
Neels Hofmeyr f092301a0f ran_dec logging: log message sizes on errors
Change-Id: Id08e4ee5a4dbf552dbb107d8f0519110664f6acb
2019-09-03 13:59:05 +00:00
Neels Hofmeyr 4b78b29b8c vlr: don't log about "gratuitous ID RESPONSE"
If an ID Response comes in during a non-LU L3 Complete (Paging or CM Service
Request), no event needs to be dispatched. So far vlr_subscr_rx_id_resp()
logged a NOTICE "gratuitous ID RESPONSE?!?" if no lu_fsm is present.

An ID Response can come in particularly as payload with a BSSMAP Cipher Mode
Complete message, even though osmo-msc didn't explicitly ask for it.

It is not an error to get a Cipher Mode Complete containing an ID Response
during Paging or CM Service Request, so remove the confusing log message.

Related: OS#4168 (only loosely related)
Change-Id: I8a5b8735eb41cd0976c7ab32cdd55440d3ef70ac
2019-09-03 13:59:05 +00:00
Keith Whyte 991bb422d4 Implement a global switch on the network to disable call waiting.
Add a network -> callwaiting VTY command as boolean.

When this is enabled (default) there is no change to
operation previous to this commit.

When this switch is disabled with "no call-waiting" in vty
then when a call arrives, we will check if we have an active
call transaction for this subscriber, no matter if it is
establishing, established, or alerting, in any of these cases we
will return USER BUSY to the calling party.

Change-Id: I3eb6f23f7103e3002874fb5d3a30c9de952202ae
2019-09-03 11:47:13 +00:00
Neels Hofmeyr b4ef5e7bd1 msc_a.c, CC trans: change a comment to a debug log
Change-Id: I5a3cc6219080910119b0c9ff11fc2b9eb96a06e5
2019-09-02 11:07:49 +02:00
Neels Hofmeyr 43e8d4d412 gsm48_tch_rtp_create(): check against NULL mgcp_info
osmo_mgcpc_ep_ci_get_rtp_info() might return a NULL mgcp_info, guard against
that.

Fixes: CID#203651
Change-Id: I98fe5860c49751ade1af10d99487aba259504f23
2019-09-02 11:07:49 +02:00
Neels Hofmeyr 38816dab97 log, cosmetic: add "RR" to "Ciphering Mode Complete"
Distinguish the enclosed DTAP RR Ciphering Mode Complete message from the outer
BSSMAP Cipher Mode Complete message in the DEBUG log.

Change-Id: I80c69b491e2ddb932bc4295a01caaf6a903b1fe4
2019-09-02 11:06:05 +02:00
Neels Hofmeyr 43a349fd63 tweak CC cause for incoming call to unattached nr
So far we sent CC cause "Unassigned Number"

But the MSC doesn't trivially know whether the HLR has the number assigned or
not: any handset that is currently switched off would cause "Unassigned number"
to be displayed on the caller's handset.

Rather send a temporary failure cause code.

Send this cause code for all cases, because claiming that an assigned number is
unassigned is worse than rejecting an unassigned number with a temporary
failure.

Change-Id: Ia3d4f67b53fcc2654ff048fbc338e92cb763a095
2019-08-29 05:42:02 +00:00
Neels Hofmeyr 364f927ac4 vlr_lu_fsm: ignore ID_IMEISV during VLR_ULA_S_WAIT_HLR_UPD
Change-Id: I2ea4f46efa013671d93892cb07bf830393289150
2019-08-29 05:42:02 +00:00
Neels Hofmeyr 2e8f881f72 fix segfault: don't send CC REL on NULL msc_a
Apparently, if a conn disappears during an ongoing call, the CC code tried to
send a CC REL on a NULL msc_a during cleanup, which lead to a crash
(cccamp2019). Guard against that.

Crash:

 #0  msc_a_tx_dtap_to_i (msc_a=0x0, dtap=0x55a4bf2fa0f0) at ../../../../src/osmo-msc/src/libmsc/msc_a.c:1565
 #1  0x000055a4be1bb03c in trans_tx_gsm48 (trans=0x55a4bf2d52a0, trans=0x55a4bf2d52a0, trans=0x55a4bf2d52a0, msg=<optimized out>)
     at ../../../../src/osmo-msc/src/libmsc/gsm_04_08_cc.c:82
 #2  gsm48_cc_tx_release (trans=trans@entry=0x55a4bf2d52a0, arg=arg@entry=0x7ffdd731a0e0) at ../../../../src/osmo-msc/src/libmsc/gsm_04_08_cc.c:1101
 #3  0x000055a4be1bee65 in _gsm48_cc_trans_free (trans=trans@entry=0x55a4bf2d52a0) at ../../../../src/osmo-msc/src/libmsc/gsm_04_08_cc.c:278
 #4  0x000055a4be1ab654 in trans_free (trans=trans@entry=0x55a4bf2d52a0) at ../../../../src/osmo-msc/src/libmsc/transaction.c:170
 #5  0x000055a4be1bd091 in mncc_tx_to_gsm_cc (net=<optimized out>, msg=msg@entry=0x55a4bf2d3b68)
     at ../../../../src/osmo-msc/src/libmsc/gsm_04_08_cc.c:1971
 #6  0x000055a4be1bf1e5 in mncc_tx_to_cc (net=<optimized out>, arg=arg@entry=0x55a4bf2d3b68)
     at ../../../../src/osmo-msc/src/libmsc/gsm_04_08_cc.c:2049
 #7  0x000055a4be18ed63 in mncc_sock_read (bfd=0x55a4bf2563b8, bfd=0x55a4bf2563b8) at ../../../../src/osmo-msc/src/libmsc/mncc_sock.c:121
 #8  mncc_sock_cb (bfd=0x55a4bf2563b8, flags=1) at ../../../../src/osmo-msc/src/libmsc/mncc_sock.c:189
 #9  0x00007fcfad607ce1 in osmo_fd_disp_fds (_eset=0x7ffdd731a9a0, _wset=0x7ffdd731a920, _rset=0x7ffdd731a8a0)
     at ../../../src/libosmocore/src/select.c:223
 #10 osmo_select_main (polling=<optimized out>) at ../../../src/libosmocore/src/select.c:263
 #11 0x000055a4be17dd56 in main (argc=3, argv=<optimized out>) at ../../../../src/osmo-msc/src/osmo-msc/msc_main.c:723

Change-Id: Ia1bb0410ad0618c182a5f6da06af342b6d483eff
2019-08-29 05:42:02 +00:00
Neels Hofmeyr 85031ee0aa cc trans: make sure bearer cap is empty
Change-Id: I147f10f9258fc8685f2f666878dd2a655b8e4583
2019-08-29 04:58:49 +02:00
Neels Hofmeyr 61ae18c956 memleak on cc setup errors
Change-Id: I3333b90064575b270627721ace7e07d085f4ad43
2019-08-29 04:58:49 +02:00
Neels Hofmeyr 5e19b9a0bf mncc: send payload type matching chosen codec
Change-Id: Id32f32d77d24b753adb96b5393c0363439e312c2
2019-08-28 21:22:45 +00:00
Alexander Couzens 4aeb4ec182 smpp_openbsc.c: check acl before deref it
All other calls check acl before deref because in a setup
with no access policy, there won't be any acl structure

Change-Id: Ibe0256535b40351594d79baa05a0147a9f89dc26
2019-08-23 23:48:51 +02:00
Philipp Maier 47cf84d8d7 msc_a: switch RAN type back to SGs when a CSFB-Call is cleared
When a CSFB call is over the MS changes back to LTE after the call is
cleared. However, at the moment the MSC does not change the
cs.attached_via_ran flag. This may cause problems with the next call. Lets
make sure that if there is an SGs association present, the ran type is
set back to SGs when the call is cleared.

Related: SYS#4624
Change-Id: I104adecb0645b81b90ee230c57bf8b463c9e7045
2019-08-19 09:00:24 +00:00
Vadim Yanitskiy ed73ae13a1 libvlr/vlr.c: cosmetic: move message_type assignment
Change-Id: Ice7f98597b54f03069375fac56fb162f2669e7f0
2019-08-18 11:11:44 +00:00
Philipp Maier 25e7ba5b77 sgs_iface: do not use SGsAP-MO-CSFB-INDICATION for CSFB return
When the VLR/MSC receives an SGsAP-MO-CSFB-INDICATION message it sets
the RAN type back to SGs. This is wrong, the message
SGsAP-MO-CSFB-INDICATION has just an informative character. It informs
the VLR that the UE has initiated an MO CSFB call (service request).

Change-Id: I625574fc42fc915ba483db3bb406922ad6df370d
Related: SYS#4624
2019-08-16 08:59:06 +00:00
Neels Hofmeyr 4dfb2babf2 add 'encryption uea 1 2' cfg / fix ttcn3 iu tests
Recently, the ability to run UTRAN without encryption was added, but the config
for it was tied to the A5 GERAN encryption configuration. This affected
osmo-msc's default behavior of Iu, breaking osmo-msc ttcn3 Iu tests: the ttcn3
test suite sets A5 to 0 (no encryption) but still expects Iu to enable air
encryption. Fix this "regression".

Add a separate vty config option for UEA encryption, even if it does not
provide full granularity to select individual UEA algorithms yet.

As a result, Iu default behavior remains to enable encryption regardless of the
A5 config. UTRAN encryption can be disabled by the new cfg option
"encryption uea 0" alone.

Even though the new vty command already allows passing various combinations of
the UEA algorithm numbers, only '0' and '1 2' are accepted as valid
combinations, to reflect current osmo-msc capabilities.

Revert most changes to the msc_vlr test suite in commit "do not force
encryption on UTRAN" (I04ecd7a3b1cc603b2e3feb630e8c7c93fc36ccd7): use new
net->iu_encryption instead of net->a5_encryption_mask.

Adjust/add to test_nodes.vty transcript tests.

Related: OS#4144
Change-Id: Ie138f2fcb105533f7bc06a6d2e6deccf6faccc5b
2019-08-13 23:52:31 +02:00
Philipp Maier cd64af7cd4 cosmetic: make function mncc_tx_to_gsm_cc static
The function mncc_tx_to_gsm_cc() is declared as non static but only used
from within gsm_04_08_cc.c. Lets declare it as static to increase
readability of the code

Change-Id: Icd02c669cfee6dd7e6b154e303cd0f4c148c83c4
2019-08-12 08:41:34 +00:00
Neels Hofmeyr 106ba523c8 vlr_lu_fsm: fix missing event for IMEISV
Event VLR_ULA_E_ID_IMEISV is listed as permitted in VLR_ULA_S_WAIT_LU_COMPL,
but is missing from the switch() on the incoming event. So, sending an IMEISV
identity during the WAIT_LU_COMPL state would crash osmo-msc.

When receiving an IMEISV, vlr_subscr_set_imeisv() in turn calls
vlr_subscr_set_imei(), so as far as the lu_fsm is concerned, receiving an
IMEISV is identical to receiving an IMEI, and it can continue to send a Check
IMEI request to the HLR. Thus simply add VLR_ULA_E_ID_IMEISV to the
VLR_ULA_E_ID_IMEI switch case.

Change-Id: I11106cb108a4b1406ff9a8b8ff5761440a274dad
2019-08-08 02:08:55 +02:00
Neels Hofmeyr a4d7a76816 do not force encryption on UTRAN
Remove the conditions that always enable encryption on UTRAN.

We so far lack an explicit configuration for UTRAN encryption, and this patch
does not add any either. Instead, whether UTRAN encryption is enabled is simply
triggered on whether GERAN has A5 encryption enabled (A5/n with n > 0). Though
GERAN and UTRAN encryption are not technically related at all, this makes UTRAN
behave like GERAN for now, until we implement a proper separate configuration
for UTRAN encryption.

Adjust the msc_vlr_test_* configuration by setting the net->a5_encryption_mask
such that the expected output remains unchanged. A subsequent patch
(I54227f1f08c38c0bf69b9c48924669c4829b04b9) will add more tests, particularly
cases of UTRAN without encryption.

Adjust manual and vty doc.

Related: OS#2783
Change-Id: I04ecd7a3b1cc603b2e3feb630e8c7c93fc36ccd7
2019-08-05 23:24:47 +02:00
Pau Espin 3e1e47679d Remove undefined param passed to logging_vty_add_cmds
Since March 15th 2017, libosmocore API logging_vty_add_cmds() had its
parameter removed (c65c5b4ea075ef6cef11fff9442ae0b15c1d6af7). However,
definition in C file doesn't contain "(void)", which means number of
parameters is undefined and thus compiler doesn't complain. Let's remove
parameters from all callers before enforcing "(void)" on it.

Change-Id: Ia2b24ffd7f9cbb271fcdb979b851f3a07b9d6d3e
Related: OS#4138
2019-08-05 16:07:08 +02:00
Keith Whyte ff17f8fd8a Set coding in mncc_set_cause()
GSM 04.08 10.5.4.11

The Release indication needs to have the Coding Standard set.

For phones that would display a message on screen, such as
"Number not in use", if the coding standard is not defined,
the display may show "Error in Connection"

Change-Id: Ib28b62a41d433e231cff5910d19455296b284df6
2019-08-02 08:08:33 +00:00
Neels Hofmeyr 4014e481d4 minor comments in msc_vty.c
Change-Id: I83d8c778190adb1e74debc8f8ddac6996de7c513
2019-07-29 18:39:50 +02:00
Oliver Smith c0a5e71d0e vlr_lu_fsm.c: don't send LU reject twice
Don't call tx_lu_rej() in the "vlr_lu_compl" FSM. It is always getting
called in the parent "lu" FSM and is therefore redundant:

_vlr_lu_compl_fsm_done(fi, VLR_FSM_RESULT_FAILURE, cause)
-> osmo_fsm_inst_state_chg(fi, LU_COMPL_VLR_S_DONE, 0, 0)
-> vlr_lu_compl_fsm_dispatch_result()
-> lu_fsm_wait_lu_compl()/lu_fsm_wait_lu_compl_standalone()
-> lu_fsm_failure()
-> lfp->vlr->ops.tx_lu_rej()

I have noticed the bug with the TTCN3 tests. This patch fixes
TC_lu_imsi_auth_tmsi_check_imei_{nack,err} after stricter checking
in [1] and also TC_iu_mo_crcx_ran_reject.

[1] I836f76242463789c4c003feec757714827f2a31b (osmo-ttcn3-hacks)
Change-Id: I127b27937613ea0ff29d67991c0414fca6d441d9
2019-07-24 09:08:22 +02:00
Alexander Couzens efa7b97133 replace osmo_counter with stat_items
osmo_counter will be soon deprecated. Use the newer and more flexible
osmo_stat_item instead.

Depends on: Id2462c4866bd22bc2338c9c8f69b775f88ae7511 (libosmocore)
Change-Id: I6a20123b263f4f808153794ee8a735092deb399e
2019-07-18 14:50:51 +00:00
Thorsten Alteholz 3a357de631 fix spelling detected by lintian
Change-Id: I01e54b5cf111677079a8ad57645d3ceb7834702a
2019-07-16 20:12:03 +00:00
Vadim Yanitskiy 09ce3dcbdf libmsc/msc_vty.c: print subscriber expiration time
Change-Id: I092691a8c443f4c5ed4d33de2e551fef592c1baf
2019-07-09 07:14:09 +00:00
Vadim Yanitskiy d14422a236 Fix: add missing semicolons to OSMO_ASSERT statements
Change-Id: I4fae5fbab5fdbcce35906601d4f1031d971f4931
2019-07-09 07:13:45 +00:00
Vadim Yanitskiy 1c50044efb libmsc/ran_msg_iu.c: fix: properly handle SAPI IE of RANAP_DirectTransfer
The RANAP DirectTransfer message may contain an optional SAPI IE.
Thanks to our TTCN-3 tests (and Wireshark!), it was discovered
that this IE is ignored, so even if the MO SMS related messages
arrive on SAPI 3 (as per GSM TS 04.11, section 2.3) OsmoMSC sends
MT messages on SAPI 0.

In ran_iu_decode_l3() we need to check if the SAPI IE is present,
and tag the NAS PDU message buffer with a proper DLCI value.

This change makes the failing SMS related test cases pass.

Change-Id: I728b55b04e87fc23be6d4f8735e8cad82b6f640e
2019-06-20 16:54:45 +00:00
Vadim Yanitskiy 7659482318 libmsc/gsm_04_11.c: do not abuse LOG_TRANS() in gsm411_alloc_mt_trans()
This change is similar to I6b68a0f0b32eb126e0f7e914a314130254d28467.
If we 100% sure that trans == NULL, it makes more sense to use
generic LOGP(DLSMS, LOGL_*, ...) call, so the logs can reflect
more information than such dummy prefix:

  trans(NULL NULL callref-0x0 tid-0) ...

Change-Id: I3c1e633aee5dd7cd0d367404a3def9cffe0b3baa
2019-06-20 16:54:45 +00:00
Vadim Yanitskiy 59e0c6b46a gsm_04_11_gsup.c: fix broken reference counting for vsub
This change is similar to I5540556b1c75f6873883e46b78656f31fc1ef186.
In gsm411_gsup_rx() we do call vlr_subscr_find_by_imsi(), which
increases subscriber's reference count by one using the function
name as the token. However, we never release this token, so the
reference count grows on every received GSUP FORWARD-SM message.

Change-Id: Ic729beb5f94cbbfbb251bc9ab66a5e7b799286c0
2019-06-20 16:54:45 +00:00
Pau Espin fe5b7046ea sms_queue.c: Improve misleading log line
Otherwise when read in a log file it seems it's really going to send 20
sms even if there's none to send.

Change-Id: Ieb9bb61a90f295d2ba5fb67a2abee2d30785876d
2019-06-20 10:45:37 +02:00
Vadim Yanitskiy 718f32fa88 libvlr/vlr.c: do not expire subscribers if periodic LU is disabled
When periodic Location Update is disabled (T3212 = 0), it was noticed
that OsmoMSC does expire subscribers quite soon - after 60 seconds
(VLR_SUBSCRIBER_LU_EXPIRATION_INTERVAL) since the last LU.

In order to avoid that, we need to check T3212 timer value in
vlr_subscr_expire_lu(), and if it's equal to 0, do not expire
anybody until the explicit IMSI Detach.

Change-Id: I2ead2241a3394dbdd5417f4554190df3fd698af2
2019-06-19 14:36:28 +07:00
Vadim Yanitskiy b3bdc768be libmsc/gsm_09_11.c: do not suppress rc of gsup_client_mux_tx()
Change-Id: Ide2440188fb6fe1c54681fef8ec4fed9e6da66e2
2019-06-17 22:23:09 +07:00
Vadim Yanitskiy 6632251572 libmsc/gsm_09_11.c: do not abuse LOG_TRANS() in gsm0911_rcv_nc_ss()
If we 100% sure that trans == NULL, it makes more sense to use
generic LOGP(DSS, LOGL_*, ...) call, so the logs can reflect
more information than such dummy prefix:

  trans(NULL NULL callref-0x0 tid-0) ...

Change-Id: I6b68a0f0b32eb126e0f7e914a314130254d28467
2019-06-17 22:13:03 +07:00
Vadim Yanitskiy e0da446e76 libmsc/gsm_09_11.c: fix broken reference counting for vsub
In gsm0911_gsup_rx() we do call vlr_subscr_find_by_imsi(), which
increases subscriber's reference count by one using the function
name as the token. However, we never release this token, so the
reference count grows on every received GSUP PROC-SS message.

Change-Id: I5540556b1c75f6873883e46b78656f31fc1ef186
2019-06-17 21:57:30 +07:00
Vadim Yanitskiy 944d6a2acb libmsc/gsm_09_11.c: avoid double zero-initialization of gsup_msg
Change-Id: Ib991b01534499401e7a0c3de49ceba770fdd9b48
2019-06-17 21:57:30 +07:00
Vadim Yanitskiy f177590488 libmsc/gsm_09_11.c: properly handle OSMO_GSUP_MSGT_PROC_SS_ERROR
This message can be used by the HLR/EUSE to indicate that something
went wrong, e.g. the connection with EUSE is lost, EUSE or the MS
did not respond in time, etc. OsmoMSC needs to release the SS/USSD
transaction, and send GSM 04.80 RELEASE COMPLETE message to the MS
if there is an active RAN connection.

Change-Id: I076d12ef24d7320eda1df1ee4588da7375ef3d9e
Related: (TTCN-3) I5586a88136c936441a842f49248824680603672e
Related: OS#2931
2019-06-17 21:08:14 +07:00
Vadim Yanitskiy 7480852eea libmsc/gsm_09_11.c: inform HLR/EUSE if Paging has failed
Change-Id: Ie2ac06aadb18251310e0cfd85bb0d9865470aab7
Related: (TTCN-3) I1f53c56d569c8ac4071835685bbe3bc9e0ebd7f0
Related: OS#2931
2019-06-17 21:06:43 +07:00
Vadim Yanitskiy 805eca2b3e libmsc/msc_net_init.c: pass pointer to gsm_network directly
Change-Id: I122d2880b356997c60df5f0cf4f5ecb3abb2e672
2019-06-17 21:06:43 +07:00
Vadim Yanitskiy 95b040c45a libmsc/gsm_09_11.c: drop meaningless check for concurrent paging
This check was copy-pasted from the CC handling code during the
initial development of "SS/USSD over GSUP" feature. It probably
makes sense for MT calls, but definitely not for SS/USSD.

Change-Id: I2899a23ee49fd7917443943629603700a5025cf4
2019-06-17 21:06:43 +07:00
Vadim Yanitskiy ae95436c7a libmsc/gsm_09_11.c: drop rudimentary vsub->cgi.lai.lac check
This check was copy-pasted either from CC, or from SMS handling
code during the initial development of "SS/USSD over GSUP". Now
this is the only one survived after the recent refactoring.

I doubt this is exactly the right way to check whether subscriber
is attached or not. Moreover, this check should rather be done in
a single place, rather then in each CC/SS/SMS handler separately.

Change-Id: I7bd48860e923cb1f1a5bccc4b0f497ec1a7bcf84
2019-06-17 21:06:43 +07:00
Vadim Yanitskiy db5bc701a8 libmsc/gsm_09_11.c: log network-originated session establishment error
Change-Id: I090c25de3421f770115ed68a7ecc050694cedff7
2019-06-17 21:06:43 +07:00
Vadim Yanitskiy 10c3ce563b libmsc/gsm_09_11.c: do not abuse LOG_TRANS() and early trans allocation
In case of network-originated SS/USSD session establishment, we
need to verify the received GSUP PROC_SS_REQ message and make
sure that all mandatory IEs are present.

There is no sensible need to allocate a new transaction before
doing all the checks, other than the ability to use LOG_TRANS().
This complicates the code, so let's avoid the early allocation.

Change-Id: I4e027b19e8065a39324a1647957cef4066b82ce7
2019-06-17 21:01:09 +07:00
Eric Wild 58abc67caa libvlr: fix sgsn tmsi creation, replace constant with define
reported by _dev_zero in #osmocom

Change-Id: Ib5679ab5d06b6ef735725b4a68eeb1e9cbcc11ba
Depends-On: libosmocore I52b9f6b5f3e96d85a390ba2af21d7814df8aaeec
2019-06-17 12:51:27 +00:00
Vadim Yanitskiy 01926fc240 libmsc/paging.c: cosmetic: remove leading space in log line
Change-Id: Ie7816f3b30a6c6ac5175646b479eb9a3e76429e1
2019-06-16 00:22:13 +07:00
Vadim Yanitskiy 08553e0f10 libmsc/paging.c: cosmetic: actually use default branch of switch
Change-Id: I9b566885f722a28816760532b645f606fdf4faeb
2019-06-16 00:22:13 +07:00
Vadim Yanitskiy a12ac82352 libmsc/paging.c: avoid double zero-initialization
Change-Id: Icc839370fc39ab57078ec6deeac337ed2f37793c
2019-06-16 00:22:13 +07:00
Vadim Yanitskiy 6539bfb8e3 libmsc/msc_a.c: fix: remove dummy allstate_action of msc_a_fsm
Since [1] has been merged to libosmocore, it was discovered that
the 'msc_a' FSM has a dummy 'allstate_action' handler assigned,
but 'allstate_event_mask' is 0x00 at the same time.

It basically doesn't make any sense, and moreover does cause
warnings and build failures.

[1] https://git.osmocom.org/libosmocore/commit/?id=b3f94eb39e19366c3458643ee329a73155d46ff8
[1] https://gerrit.osmocom.org/#/c/libosmocore/+/14361/

Change-Id: Ieb81b7a07ced1c40ba70d2adb0df68160ee62118
2019-06-16 00:12:17 +07:00
Vadim Yanitskiy 49d45f1e85 libmsc/gsm_04_08.c: clean up unused leftover includes
During the recent refactoring, some code parts has been moved out
of 'gsm_04_08.c', but the related header files were forgotten.

Change-Id: I61e728069a1e79bf72c01ef9d9fc5fb171d3892e
2019-06-15 11:24:00 +00:00
Vadim Yanitskiy efb1f60c76 libmsc/gsm_09_11.c: send GSUP PROS_SS ERROR message when needed
OsmoMSC should notify the remote SS/USSD entity if:

  - received GSUP message has unexpected session state;
  - received GSUP message has unknown session ID;
  - received GSUP message missing mandatory IE(s);
  - NCSS transaction establishment failed;
  - NCSS message delivery failed.

Change-Id: Ief9f8a197b0860072b671edfc55180f619860d9d
Related: (TTCN-3) Ie267ee174c5061cd3fc102a2824abe03d73f3aac
Related: OS#2931
2019-06-15 15:38:03 +07:00
Vadim Yanitskiy 04bbfb83d4 libmsc/gsm_09_11.c: fix: return trans from establish_nc_ss_trans()
It is expected that establish_nc_ss_trans() returns an allocated
transaction in successful case, or NULL in case of error. The
function assumes two scenarios:

  - the subscriber already has an active RAN connection,
  - RAN connection needs to be established (Paging).

In the first case, a pointer to the transaction is returned as
expected, but in case of Paging, NULL has always been returned,
even if there were no errors. Let's fix this.

Change-Id: I9dcee64dd0b435ef29630c223132b81724701f93
2019-06-15 15:38:03 +07:00
Vadim Yanitskiy 20edc9723e gsup_client_mux_tx_error_reply(): fix: do not omit SM-RP-MR IE
The SM-RP-MR (Message Reference for SM Service) value in the response
(no matter result or error) shall match the value from the request.

Change-Id: Ifb6e749928548e6febfe7768aefe9a2a3ecf4de0
2019-06-15 13:13:50 +07:00
Vadim Yanitskiy c33d94be93 gsup_client_mux_tx_error_reply(): fix: do not omit message class IE
Found using the new TC_mt_ussd_for_unknown_subscr test case.

Change-Id: Id00a99b713a6b97c455b8e6ae49abea163e8281f
Related: (TTCN-3) Id35cd3ec15d1bab15260312d7bbb41e2d10349fe
Related: OS#2931
2019-06-15 13:13:50 +07:00
Vadim Yanitskiy 463005e246 gsup_client_mux_tx_error_reply(): fix: do not omit session IEs
For SS/USSD, it's important to have both session state and ID IEs.
Found using the new TC_mt_ussd_for_unknown_subscr test case.

Change-Id: I57317a7b8036d1ffd36e2021efc146db4633da84
Related: (TTCN-3) Id35cd3ec15d1bab15260312d7bbb41e2d10349fe
Related: OS#2931
2019-06-15 13:13:50 +07:00
Vadim Yanitskiy 4d0066ceb6 gsup_client_mux_tx_error_reply(): fix: do not override IMSI
I am not a big fan of using such syntax sugar for initializing
structures, and this is one of the reasons: it's much easier
to shoot yourself in the foot.

IMSI was copied to the new GSUP message, but then overridden.
Found using the new TC_mt_ussd_for_unknown_subscr test case.

Change-Id: If81c3fa56951185339f33a523ab6364594101be1
Related: (TTCN-3) Id35cd3ec15d1bab15260312d7bbb41e2d10349fe
Related: OS#2931
2019-06-14 21:51:49 +00:00
Vadim Yanitskiy 3d603034a9 libmsc/gsm_0(4|9)_11_gsup.c: print error message if subscr is not known
Change-Id: I0b9d4128c853866d7d834f381ad520f78f441afe
Related: (TTCN-3) Id35cd3ec15d1bab15260312d7bbb41e2d10349fe
Related: OS#2931
2019-06-15 01:15:06 +07:00
Vadim Yanitskiy 79e6db0f07 libmsc/mncc_builtin.c: drop dummy switch in int_mncc_recv()
Change-Id: I24153919596d58b495f9c9057dfc230e1501b95f
2019-06-14 22:58:33 +07:00
Vadim Yanitskiy 570b4c8be2 libmsc/db.c: get rid of hard-coded SMS expiry threshold
The initial idea of the SMS expiry threshold was to avoid storing
SMS messages with too long validity time (e.g. 63 weeks).
Unfortunately, neither this feature was properly documented, nor
the expiry threshold is configurable. Moreover, it has been
implemented in a wrong way, so instead of deleting the oldest
expired message, it would delete the youngest one or nothing:

  SELECT ... FROM SMS ORDER BY created LIMIT 1;

while it should be sorted by 'valid_until' in ascending order:

  SELECT .. FROM SMS ORDER BY valid_until LIMIT 1;

Thus, if the oldest message is expired, it gets deleted. If the
oldest message is not expired yet, there is nothing to delete.

Change-Id: I0ce6b1ab50986dc69a2be4ea62b6a24c7f3f8f0a
2019-06-07 08:05:24 +07:00
Vadim Yanitskiy 0d13e8358e libmsc/db.c: warn user about SMS text truncation
In general, neither TP-User-Data nor decoded text should be
truncated. If the SMSC's database for some reason does contain
such weird messages, let's at least let the user know about it.

Change-Id: I75e852ebe44ba4784572cbffa029e13f0d3c430c
2019-06-06 19:45:20 +00:00
Vadim Yanitskiy ea24bb50cc libmsc/db.c: introduce and use parse_sm_ud_from_result()
The following functions:

  - sms_from_result(),
  - sms_from_result_v3(),
  - sms_from_result_v4(),

do retrieve the TP-UD, TP-UDL and text in the same way.

A consequence of such duplication is [1], which fixed potential
NULL-pointer dereference for sms_from_result(), but not for two
other functions: sms_from_result_v3() and sms_from_result_v4().

[1] I545967464c406348b8505d1729213cfb4afcd3e2

Change-Id: If67dfb9f7d2a55fa3d45dc4689a2acff9909faf6
2019-06-06 19:45:20 +00:00
Vadim Yanitskiy ad585d8895 libmsc/db.c: fix potential integer overflow
The value of 'sms->user_data_len' is fetched from the database:

  sms->user_data_len = dbi_result_get_field_length(result, "user_data");

and this is where the problem is. As per the libdbi's documentation
(see 3.5.3), dbi_result_get_field_length() returns the length in
bytes of the value stored in the specified field:

  unsigned int dbi_result_get_field_length(dbi_result Result,
                                           const char *fieldname)

so 'unsigned int' is assigned to 'uint8_t', what could lead to an
integer overflow if the value is grather than 0xff. As a result,
if the database for some reason does contain such odd TP-UD,
the truncation of 'user_data' would be done incorrectly.

Let's avoid such direct assignment, and use a separate variable.
Also, let's warn user if TP-UDL value is grether than 140, as
per 3GPP TS 03.40.

Change-Id: Ibbd588545e1a4817504c806a3d02cf59d5938ee2
Related: OS#3684
2019-06-06 19:45:20 +00:00
Pau Espin 7f97d67108 db: Fix call to mempcy with NULL src ptr
Catched by ASan on db_sms_test unit test:
DDB NOTICE test_db_sms_get('Empty TP-UD'): osmo-msc/src/libmsc/db.c:796:2: runtime error: null pointer passed as argument 2, which is declared to never be null

That happens on empty PDU because dbi_result_get_binary returns NULL,
and sms->user_data_len is 0, so it's harmless but we can avoid calling
mempcy and make ASan happy.

Change-Id: I545967464c406348b8505d1729213cfb4afcd3e2
2019-06-03 18:51:04 +02:00
Vadim Yanitskiy 9d61db7f06 libmsc/db.c: fix storing SMS with empty TP-User-Data
Thanks to db_sms_test, it was discovered that storing an SMS with
empty TP-User-Data (TP-UDL=1) causes buffer overruns in libdbi
and it's SQLite3 driver (libdbdsqlite3):

  DDB NOTICE test_db_sms_store('Empty TP-UD'): ==7791== Invalid write of size 2
  ==7791==    at 0x857DC60: dbd_quote_binary (in /usr/lib/x86_64-linux-gnu/dbd/libdbdsqlite3.so)
  ==7791==    by 0x5B2B321: dbi_conn_quote_binary_copy (in /usr/lib/x86_64-linux-gnu/libdbi.so.1.1.0)
  ==7791==    by 0x4073B1: db_sms_store (db.c:701)
  ==7791==    by 0x405BB5: test_db_sms_store (db_sms_test.c:310)
  ==7791==    by 0x405BB5: main (db_sms_test.c:546)
  ==7791==  Address 0x7ed1cf0 is 0 bytes after a block of size 0 alloc'd
  ==7791==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==7791==    by 0x857DC4B: dbd_quote_binary (in /usr/lib/x86_64-linux-gnu/dbd/libdbdsqlite3.so)
  ==7791==    by 0x5B2B321: dbi_conn_quote_binary_copy (in /usr/lib/x86_64-linux-gnu/libdbi.so.1.1.0)
  ==7791==    by 0x4073B1: db_sms_store (db.c:701)
  ==7791==    by 0x405BB5: test_db_sms_store (db_sms_test.c:310)
  ==7791==    by 0x405BB5: main (db_sms_test.c:546)

  ...

  DDB NOTICE test_db_sms_get('Empty TP-UD'): ==8051== Invalid read of size 1
  ==8051==    at 0x5B30510: _dbd_decode_binary (in /usr/lib/x86_64-linux-gnu/libdbi.so.1.1.0)
  ==8051==    by 0x857D957: dbd_fetch_row (in /usr/lib/x86_64-linux-gnu/dbd/libdbdsqlite3.so)
  ==8051==    by 0x5B2C86E: dbi_result_seek_row (in /usr/lib/x86_64-linux-gnu/libdbi.so.1.1.0)
  ==8051==    by 0x40828F: next_row (db.c:188)
  ==8051==    by 0x40828F: db_sms_get (db.c:805)
  ==8051==    by 0x406C29: test_db_sms_get (db_sms_test.c:390)
  ==8051==    by 0x405C14: main (db_sms_test.c:547)
  ==8051==  Address 0x8f74641 is 0 bytes after a block of size 1 alloc'd
  ==8051==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==8051==    by 0x5DBEB49: strdup (strdup.c:42)
  ==8051==    by 0x857D93C: dbd_fetch_row (in /usr/lib/x86_64-linux-gnu/dbd/libdbdsqlite3.so)
  ==8051==    by 0x5B2C86E: dbi_result_seek_row (in /usr/lib/x86_64-linux-gnu/libdbi.so.1.1.0)
  ==8051==    by 0x40828F: next_row (db.c:188)
  ==8051==    by 0x40828F: db_sms_get (db.c:805)
  ==8051==    by 0x406C29: test_db_sms_get (db_sms_test.c:390)
  ==8051==    by 0x405C14: main (db_sms_test.c:547)
  ==8051==
  success, as expected
  DDB NOTICE verify_sms('Empty TP-UD'): user_data_len mismatch: E0 vs A3

Apparently, dbi_conn_quote_binary_copy() doesn't properly handle
zero-length input. Let's guard against this.

Observed with:

  - libdbi-dev 0.9.0-1
  - libdbd-sqlite3:amd64 0.9.0-2ubuntu2

Change-Id: If0b2bb557118c5f0e520a2e6c2816336f6028661
2019-06-03 17:28:44 +07:00
Vadim Yanitskiy e1e7247500 Introduce initial unit test for db_sms_* API
Since OsmoMSC has built-in SMSC, it needs to store the messages
somewhere. Currently we use libdbi and SQLite3 back-end for that.

For a long time, the db_sms_* API remained uncovered by unit tests.
This change aims to fix that, and does cover the following calls:

  - db_sms_store(),
  - db_sms_get(),

  - db_sms_get_next_unsent(),
  - db_sms_mark_delivered(),

  - db_sms_delete_sent_message_by_id(),
  - db_sms_delete_by_msisdn(),
  - db_sms_delete_oldest_expired_message().

Due to performance reasons, the test database is initialized in
RAM using the magic filename ':memory:'. This is a feature of
SQLite3 (and not libdbi), see:

  https://www.sqlite.org/inmemorydb.html

Of course, this unit test helped to discover some problems:

  1) Storing an SMS with empty TP-User-Data (TP-UDL=0) causes
     buffer overruns in both db_sms_store() and db_sms_get().

  2) TP-User-Data-Length is always being interpreted in octets,
     regardless of DCS (Data Coding Scheme). This results in
     storing garbage in the database if the default 7-bit
     encoding is used. Fortunately, the 'user_data' buffer
     in structure 'gsm_sms' is large emough, so we don't
     experience buffer overruns.

  3) db_sms_delete_oldest_expired_message() doesn't work
     as expected. Instead of removing the *oldest* expired
     message, it tries to remove the *newest* one.

The current test expectations do reflect these problems.
All of them will be fixed in the follow-up patches.

Change-Id: Id94ad35b6f78f839137db2e17010fbf9b40111a3
2019-06-03 17:28:35 +07:00
Vadim Yanitskiy dcf2868e62 libmsc/msc_vty.c: do not abuse strlen() to check char buffers
In the most cases we need to check whether particular char buffer
is empty or not. Using strlen() for that involves more CPU power,
so let's just check the first character against '\0'.

Change-Id: I8728876b80c870e82247e6e56f719e10ed322a95
2019-06-03 07:18:41 +00:00
Vadim Yanitskiy 8014917f0a libmsc/msc_vty.c: refactor 'show subscr / conn / trans' commands
The current way of printing subscriber, connection, and transaction
info is ugly (sorry) and has several problems:

  - the terminal width should be large enough to fit quite long lines,
    otherwise the output is unreadable and looks misaligned;

  - some fields (such as subscriber name) can be larger than it's
    expected, so either they're getting truncated, or again, the
    output is misaligned and unreadable;

  - adding new info fields would require one to think about the
    alignment and would make the output even more cumbersome.

Here is an example output of 'show connection' command:

  _Subscriber_______________________________________ _LAC_ _RAN___________________ _MSC-A_state_________ _MSC-A_use_
  IMSI-123456789012345:MSISDN-12345:TMSI-0x12345678      1 GERAN-A-4294967295:A5-3 WAIT_CLASSMARK_UPDATE 2=cm_service,trans_cc
  IMSI-123456789012356:MSISDN-234567:TMSI-0x123ABC78 65535     UTRAN-Iu-4294967295         COMMUNICATING 2=cm_service,trans_sms
  IMSI-262073993158656:MSISDN-123456:TMSI-0x493026BA     1               GERAN-A-1 MSC_A_ST_COMMUNICATING 1=1 (silent_call)

Another 'show subscriber' command mixes the information about
subscriber, its connections and transactions without any alignment,
what also decreases the readability.

This change introduces a hierarchical approach, based on the old
'field per line' formatting. First of all, the VTY commands were
extended with optional flags:

  show connection [trans]
  show subscriber cache [(conn|trans|conn+trans)]
  show subscriber TYPE ID [(conn|trans|conn+trans)]

so it can be decided, whether to print child connections and/or
transaction, or not. For example:

  show connection trans

would print all connections and their child transactions with
hierarchical alignment:

  Connection #00:
    Subscriber: IMSI-262073993158656:MSISDN-123456:TMSI-0x76760B75
    RAN connection: GERAN-A-1
    RAN connection state: MSC_A_ST_COMMUNICATING
    LAC / cell ID: 1 / 0
    Use count total: 1
    Use count: 1 (silent_call)
    Transaction #00:
      Unique (global) identifier: 0x00000000
      GSM 04.07 identifier (MT): 0
      Type: silent-call

another example is:

  show subscriber cache conn+trans

which would print all known subscribers,
their active connections and transactions:

  Subscriber #00:
    MSISDN: 123456
    LAC / cell ID: 1 / 0
    RAN type: GERAN-A
    IMSI: 262073993158656
    TMSI: 76760B75
    ...
    Connection:
      RAN connection: GERAN-A-1
      RAN connection state: MSC_A_ST_COMMUNICATING
      ...
      Transaction #00:
        Unique (global) identifier: 0x00000000
	GSM 04.07 identifier (MT): 0
	Type: silent-call
      Transaction #01:
        Unique (global) identifier: 0x00000001
	GSM 04.07 identifier (MO): 0
	Type: SMS
      Transaction #02:
        Unique (global) identifier: 0x00000002
	GSM 04.07 identifier (MT): 0
	Type: SMS

Please note that we don't print redundant info in child nodes
(i.e. connection and transaction info), such as subscriber name
in connection info, nor connection name in transaction info - it
is clear from the hierarchical formatting.

Change-Id: I5e58b56204c3f3d019e8d4c3c96cefdbb4af4d47
2019-06-03 07:18:41 +00:00
Vadim Yanitskiy 8b0737fa71 Use GSM23003_MSISDN_MAX_DIGITS from libosmogsm
Change-Id: If9eb46b83b6ad45f210b86b46dd416352adcc3ff
Depends on: Idc74f4d94ad44b9fc1b6d43178f5f33d551ebfb1
2019-05-29 08:48:16 +00:00
Philipp Maier 483cea889c sgs_iface: detect and react to VLR/HLR failure
The HLR (which is connected via the GSUP interface) may fail and
disconnect. On the next location update the VLR will try to talk to the
HLR and fail. This failure event is not communicated towards the SGs
related code and the SGs-association will remain in the LA-PRESENT state
forever. Lets add code to report the problem to the SGs code and trigger
a RESET an the SGs interface.

- Add a flag to report an HLR problem back to the SGs code
- Fix the FSM that controls the reset
- Make sure the all SGs associations are reset when the failure occurs.

Change-Id: Icc7df92879728bc98c85fc1d5d8b4c6246501b12
Related: OS#3859
2019-05-27 11:49:50 +00:00
Vadim Yanitskiy b683dcfe6b transaction: accept trans_type enum in trans_log_subsys()
Change-Id: I3c373d20ebd6e96ebd57f84b74dc15a6b69c03ac
2019-05-26 09:27:22 +00:00
Pau Espin a3cdab4481 Request Osmux CID and forward it in Assign Req and Assign Compl
Related: OS#2551
Depends: osmo-mgw.git I73b4c62baf39050da81d65553cbea07bc51163de
Change-Id: I5b14e34481e890669c9ee02dba81eba84293cebb
2019-05-21 18:32:38 +02:00
Vadim Yanitskiy 643270f717 libmsc/gsm_04_11.c: properly handle MMTS indication
According to 3GPP TS 29.002, section 7.6.8.7, MMS (More Messages to Send)
is an optional IE of MT-ForwardSM-Req message which is used by SMSC to
indicate that there are more (multi-part) MT SMS messages to be sent.

The MSC needs to use this indication in order to decide whether to
keep the RAN connection with a given subscriber open.

Related Change-Id: (TTCN) I6308586a70c4fb3254c519330a61a9667372149f
Change-Id: Ic46b04913b2e8cc5d11a39426dcc1bfe11f1d31e
Related: OS#3587
2019-05-19 07:34:35 +00:00
Pau Espin c9ba754235 a_iface: Announce Osmux support on RESET (ACK) send
Related: OS#2551
Depends: libosmocore.git I28f83e2e32b9533c99e65ccc1562900ac2aec74e
Change-Id: Id607f60749e923755cb38179bc283a7957670653
2019-05-19 07:28:02 +00:00
Pau Espin f9f38b568c bssap: Detect BSC Osmux support on RESET (ACK) recv
Related: OS#2551
Depends: libosmocore.git I28f83e2e32b9533c99e65ccc1562900ac2aec74e
Change-Id: If4f33da9b414ab194098755d2c5be85e1fce5d31
2019-05-19 07:28:02 +00:00
Pau Espin 4faff9ef86 vty: Add option to enable osmux towards BSCs
Change-Id: I6de1be0322ddbdc115074ebb6be2598ebf6c95db
2019-05-19 07:28:02 +00:00
Neels Hofmeyr a10d79eab1 build osmo-msc: add "missing" LIBASN1C_LIBS
in osmo-msc/Makefile.am, osmo-msc was actually missing the LIBASN1C_LIBS even
though it included LIBASN1C_CFLAGS. Probably libasn1c is implicitly linked from
libranap.so, but doesn't hurt to name it.

When building without Iu support, the LIBOSMORANAP* and LIBASN1C* vars are
empty, so no need to explicitly switch on BUILD_IU, just name them.

Change-Id: I39ae5e3f0f7661ca9ee5c17a500be28c461d7ec7
2019-05-19 07:25:04 +00:00
Vadim Yanitskiy e0ef6d1e32 libmsc/rtp_stream.c: prevent NULL-pointer dereference
Change-Id: Ie80b9fae490acc9ee8de742e35b6ef59c4388f57
Fixes: CID#198432
2019-05-16 09:03:49 +00:00
Vadim Yanitskiy 56e722ff1a libmsc/msc_vty.c: use llist_count() in subscr_dump_full_vty()
Change-Id: I9e4814d2b2da7d4e75da074e138f423af850ed49
2019-05-16 08:48:51 +00:00
Vadim Yanitskiy 3ccd823ee0 libmsc/msc_vty.c: fix documentation of 'show subscriber id'
Change-Id: I3357e71ae54e22b97cbb3707712445d7602c1129
2019-05-16 08:48:51 +00:00
Vadim Yanitskiy 23d42d6358 libmsc/msc_vty.c: fix: use msub_for_vsub() in subscr_dump_full_vty()
Change-Id: I8a099b71b10ebb5d2bccfc7e78b6d37a1e60add8
Related: OS#4003
2019-05-16 08:48:51 +00:00
Alexander Couzens b10ec6a751 remove msc specific db counters
DB counters has been used to save osmo_counters & osmo_rate_ctr to a local
sqlite databases every 60 seconds.
This is quite slow e.g. 1000 subscriber might slow the msc down.

Change-Id: Id64f1839a55b5326f74ec04b7a5dbed9d269b89c
2019-05-15 18:27:12 +00:00
Pau Espin f15852b992 ran_peer: Move rx_reset_ack logic into its own func
Later on we want to do extra steps upon receiving a Rx Reset Ack
(checking for Osmux support from peer). Let's move handling of this
message into its own function to have handling implementation in one
place.

Change-Id: I516c4baf6071d26f6c530726d93677bed968efd1
2019-05-15 10:25:04 +00:00
Oliver Smith cbf2c93d11 vlr: optionally send IMEI early to HLR
When 'check-imei-rqd 1 early' is set in the config, send the IMEI to
the HLR before doing the location update with the HLR.

The OsmoHLR documentation referenced in the code will be added in
osmo-hlr.git's Change-Id I2dd4a56f7b8be8b5d0e6fc32e04459e5e278d0a9.

Related: OS#2542
Change-Id: I88283cad23793b475445d814ff49db534cb41244
2019-05-15 10:57:43 +02:00
Oliver Smith b8077b0c1d vlr: when setting IMEISV, also set IMEI
Copy IMEISV to IMEI when IMEISV changes. The additional SV digits will
get cut off then. This is needed for the subscriber on demand use case,
since we can get the IMEISV early (see [1]), but need to send the IMEI
to the Check IMEI procedure.

While adjusting the tests, I have noticed that there are code paths
where we ask the MS for the IMEISV first, and later ask the MS for the
IMEI, although we already have the IMEISV. This could be improved in a
future patch.

[1] Change-Id I256224194c3b8caf2b58a88d11dccd32c569201f

Related: OS#2542
Change-Id: I02e7b66848bf7dddb31b105e2ae981432817ae1e
2019-05-15 10:57:43 +02:00
Oliver Smith 03ded913ad vty: make retrieve-imeisv-early configurable
Prepare for Rhizomatica's subscriber on demand use case, in which the
network access is disabled by default for new subscribers, but the IMEI
is required in the HLR to find out which user has which IMSI. Due to the
network access being disabled, the location update request towards the
HLR fails and the MS gets rejected, so we need to get the IMEI early.

Related: OS#2542, OS#3755
Change-Id: I256224194c3b8caf2b58a88d11dccd32c569201f
2019-05-15 08:43:39 +00:00
Vadim Yanitskiy d24c46a38b libmsc/ran_peer.c: avoid unreasonable use of goto in ran_peer_down_paging()
Change-Id: I3320240d8f1dc318e516162bb32e01ddafc7e30e
2019-05-14 21:49:47 +07:00
Vadim Yanitskiy ede95d18b3 libmsc/ran_peer.c: fix msgb memleaks in ran_peer_down_paging()
Change-Id: I1e76b5eab7cfa091375bd9c76d8dcdec8d16ffe5
2019-05-14 21:41:06 +07:00
Oliver Smith ffd522ec6f vlr_lu_fsm.c: assert for invalid events
In state machine callback functions, instead of logging an error when
an invalid event arrives, do OSMO_ASSERT(0).

Change-Id: If5363ae37b414a0ac195e5f89664c75cbad0bb21
2019-05-14 08:19:52 +00:00
Vadim Yanitskiy c5a8e9f19a libmsc/mncc_call.c: fix uninitialized access of stack memory
Change-Id: I5f561d9682c9fb87e4837430063095ef2cb7bd5f
Fixes: CID#198405
2019-05-13 20:15:04 +00:00
Vadim Yanitskiy 444771dae2 libmsc/ran_msg_a.c: prevent chosen_encryption->key buffer overrun
In ran_a_make_handover_request() we do prevent destination buffer
(r.encryption_information.key) overflow, but not source buffer
(n->geran.chosen_encryption->key) overrun if an incorrect key
length is received. Let's fix this.

Change-Id: I278bb72660634c2d535e1bd3d7fce5696da23575
Fixes: CID#198450 Out-of-bounds access
2019-05-13 20:15:04 +00:00