Commit Graph

6225 Commits

Author SHA1 Message Date
Harald Welte a1c5de45c1 Remove traces of meas_feed
Measurement reporting (and the relate feed) are functions of the BSC,
not the MSC.  This code should never have been inherited from OsmoNITB
to OsmoMSC in the first place, let's remove it.

Change-Id: I0d57ac214e574e267fa9752daf76566197b9aa64
2018-01-24 14:04:46 +00:00
Harald Welte 37382ec2cf Reject any CM SERVICE we don't support
When we receive a CM Service Request, OsmoMSC should eventually verify
what kind of service it is the phone requests, and whether we support
that service.

Change-Id: I499730d760dc9ac7f599e09959c6eac4452f2eab
Closes: OS#2668
2018-01-24 14:04:46 +00:00
Harald Welte 3995d2ea85 Refuse Emergency Calls by IMEI with proper CM SERVICE REJECT Cause
OsmoMSC rejects an Emergency Call with IMEI as mobile identity with
"semantically incorrect message" which is clearly wrong. According to TS
24.008 4.5.1.5 we should reject with cause 5 "IMEI not accepted"

Found with TTCN-3 test case MSC_Tests.TC_emerg_call_imei

Change-Id: I2f7ab0e32b914a112c0b17c523d149ccd0299099
Closes: #2866
2018-01-24 14:04:46 +00:00
Harald Welte 0dd013770e Emergency Call: Set MNCC_F_EMERGENCY flag
MNCC has a MNCC_F_EMERGENCY flag to indicate that the mncc.emergency
field is present. However, OsmoMSC never sets this flag.

Change-Id: I0ebd8f88e483172988f4a0cb0636b4160688d8ad
Closes: OS#2865
2018-01-24 14:04:45 +00:00
Harald Welte 79826e104a Log difference between SETUP and EMERGENCY_SETUP
An emergency call should be logged different from a normal call,
and we also increase the log level from INFO to NOTICE in such a
situation.

Change-Id: I83f3b8bd0aeda70f03aa7b8d264a9008d10d5687
2018-01-24 14:04:45 +00:00
Max c309fe37c5 cosmetic: log prim operation as text
When logging SCCP error, log failed primitive operation as text.

Change-Id: Icda9f8f18aacc7bcc281aad5fbb89208e6dab336
Related: OS#2851
2018-01-24 14:03:54 +00:00
Max 923a23900e VLR: constify GSUP-related function parameters
Change-Id: If3852e096210713cb5297f6b42ed66dbb98c4a50
2018-01-24 13:55:03 +01:00
Harald Welte 5718429ec9 MNCC: Add input validation
There appears to have been no input validation whatsoever on MNCC
messages.  Hence it was very easy for an external MNCC handler to
crash OsmoMSC, such as in OS#2853

Change-Id: Idaf3b8e409c84564b1eb26d01a19c605f89b14f4
Closes: OS#2853
2018-01-23 17:03:05 +00:00
Stefan Sperling 3b26f34950 Fix value of stored SMS validity time.
Quote the argument to sqlite's datetime(). Otherwise, the timestamp
stored in the database reads back as a negative value for some reason.

Before:

1032            validity_timestamp = dbi_result_get_datetime(result, "valid_until");
(gdb) p validity_timestamp
$2 = -1516814654

After:

1032            validity_timestamp = dbi_result_get_datetime(result, "valid_until");
(gdb) p validity_timestamp
$2 = 1516814654

Change-Id: Icf786f9b1efabfe7407fb6414ec0d326d8f7244a
2018-01-23 16:57:52 +00:00
Pau Espin b8c0cf8d09 libmsc: msc_vty: Fix compilation warning
As the include file gsm_data.h is generic (does not depend on osmo-iuh0s
iu_client.h), rab_assign_addr_enc is declared as "int" instead of "enum ranap_nsap_addr_enc".

osmo-msc/src/libmsc/msc_vty.c: In function ‘msc_vty_init’:
osmo-msc/src/libmsc/msc_vty.c:212:30: warning: passing argument 2 of ‘ranap_iu_vty_init’ from incompatible pointer type [-Wincompatible-pointer-types]
  ranap_iu_vty_init(MSC_NODE, &msc_network->iu.rab_assign_addr_enc);
                              ^

Change-Id: I1b63ee350911bdf772a2324fff55035275a455c4
2018-01-22 13:49:55 +01:00
Stefan Sperling d494162c9c Store/retrieve SMS validity time in the SMS datebase
Compute a validity timestamp based on SMS validity time.
Store the computed value in the database and recompute the validity
time when an SMS is read from the database.

Change-Id: Id27c250d3a64cd109416450e8ca155b18a8b9568
2018-01-20 15:02:40 +00:00
Stefan Sperling 6ba2d5a9f7 Delete SMS from the database once they were sent successfully
Currently the SMS database keeps accumulating entries for each SMS.
These entries are never deleted automatically. With this change, we
start deleting SMS which have successfully been sent to subscriber B.

Change-Id: I3749855fe25d9d4e37ec96b0c2bffbc692b66a78
2018-01-18 18:55:26 +01:00
Stefan Sperling 832046d383 Improve an error message in db_init().
If we cannot open a connection to the sqlite3 database, show the name of the
database we failed to access, and also hint at the fact that a likely reason
for the problem is a missing sqlite3 driver for libdbi.

Change-Id: If1c0026e882984b4358ce116ec4a7ad40340517c
2018-01-16 14:21:16 +01:00
Neels Hofmeyr ce4e984fe8 fix build: missing LIBOSMORANAP flags in libmsc
Change-Id: I2f498a2d008571d3eb8753bede0847fa7ab704ed
2018-01-16 14:06:36 +01:00
Vadim Yanitskiy b274d56dbb src/libmsc/ussd.c: drop useless forward declaration
There is no any significant reason to define static function
'send_own_number' after the code that calls it.

Change-Id: I7f76f278c09489dccd96921610e8d06efa679ff2
2018-01-10 22:17:37 +06:00
Vadim Yanitskiy 6e19d1b2d5 msc/gsm_04_80.h: use '#pragma once' instead of includes
This is a common include guard way for Osmocom projects.

Change-Id: I5a12a742719d4deba0b9dfa8bb330c1986a727f6
2018-01-10 22:17:37 +06:00
Vadim Yanitskiy 0774a539da msc/gsm_04_80.h: cosmetic: whitespace fix
Change-Id: Ia3632c75cf2d2ce79b42b3b55ef50a72ab1bb94c
2018-01-10 22:17:31 +06:00
Vadim Yanitskiy 7c93591b2c msc/gsm_04_80.h: clean up useless declarations
This change removes a few USSD specific declarations, which are
not actually used now, and probably accidentally migrated from
legacy OpenBSC.

Change-Id: Id57a24b92790d3ce0f9c7343d060f511e2b979c7
2018-01-10 18:09:16 +06:00
Neels Hofmeyr 563e1dbef2 a_iface_tx_assignment: fix log lvl for "Sending Assignment..."
Change-Id: I42bd3dc601465a4ac6a6e2bf8c4af736547d4838
2018-01-08 12:56:27 +00:00
the 34c3 gsm team cfab83e642 smpp_smsc.c: don't talloc_strdup NULL pointers
Change-Id: Ie6a83a20464a959cf51f999d6f900fa4516ced1b
2018-01-07 19:04:10 +01:00
Max dcc193d3a6 Add control command to expire subscriber
It's equivalent of existing vty command: common part is extracted into
shared helper function.

Change-Id: I267886b7c79ed6d9c2f34a2e60d2972b7f4f4036
2018-01-05 10:10:35 +00:00
Max a263bb215b VLR: log subscriber update
* move log helpers to generic header
* log subscriber update

It's handy for troubleshooting issues with subscriber update via GSUP
from HLR.

Change-Id: I1958aeeb3ea99831c7e2c5ee9a6b59834baf4520
2017-12-31 11:01:46 +00:00
Max 7772c7de55 VLR: remove unused parameter
The expire_lu is never used but is printed for every subscriber. Let's
remove it to avoid confusion.

Change-Id: I6f7ad1670836384d1e6a58f47a13464fdbbf8509
2017-12-29 18:12:37 +01:00
Max 753c15de2f Migrate from OpenSSL to osmo_get_rand_id()
This avoids potential licensing incompatibility and makes integration of
Debian packaging patches easier.

Related: OS#1694
Change-Id: I71cd631704a4dc155c6c752fee2a42cd6e2fa336
2017-12-27 11:11:14 +00:00
Max 629c479edd Enable sanitize for CI tests
Change-Id: I23da6f9b836595d81b509c8a6fb4e46b5d675103
2017-12-21 17:18:35 +01:00
Neels Hofmeyr facd57ac56 fix: properly cancel all Paging on IMSI Detach
It's not clear cut which code is responsible for canceling pending requests,
since the requests list is kept in vlr_subscr, but sending out Paging does
certainly not belong in the VLR. Place the requests cleanup in gsm_04_08.c.

Add to test_ms_timeout_paging() in msc_vlr_test_ms_timeout.c to verify that a
pending paging is canceled on IMSI Detach.

Change-Id: Ib8874a9d92f02b0826525b55518332f6899688fd
2017-12-20 23:07:10 +01:00
Neels Hofmeyr 2ff5bcdc38 fix paging: add timeout to discard unsuccessful paging
Currently, if there is no reply from the BSS / RNC, a subscriber will remain as
"already paged" forever, and is never going to be paged again. Even on IMSI
Detach, the pending request will keep a ref count on the vlr_subscr.

Add a paging timeout, as gsm_network->paging_timeout and in the VTY on the
'msc' node as 'paging timeout (default|<1-65535>'. (There is a 'network' /
'T3113' in OsmoBSC, but to not confuse the two, give this a different name.)

Add test_ms_timeout_paging() test to verify the timeout works.

I hit this while testing Paging across multiple hNodeB, when a UE lost
connection to the hNodeB. I noticed that no matter how long I wait, no Paging
is sent out anymore, and found this embarrassing issue. Good grief...

The choice of 10 seconds is taken from https://osmocom.org/issues/2756

Change-Id: I2db6f1e2ad341cf9c2cc7a21ec2fca0bae5b2db5
2017-12-20 23:07:10 +01:00
Neels Hofmeyr c1d69256f6 cosmetic: rename sccp_rx_udt and sccp_rx_dt to a_*
These rx functions are only used for the A interface, hence the names should
not suggest general SCCP rx (which Iu also has).

Change-Id: I6815c3d4dea4c2abfdff1cf0239ada6a9254f351
2017-12-20 16:14:50 +00:00
Pau Espin c22e54deab libmsc: db.c: Replace dbi APIs marked as deprecated
Several warning messages about those APIs being deprecated were printed
at compile time.

Change-Id: I6052159acf240cc7e8e2b3a3af10d8210708ddb6
2017-12-20 16:06:43 +00:00
Neels Hofmeyr 04960b15ec log: a_iface.c: revisit logging, use LOGPCONN
Add LOGPBSCCONN for struct bsc_conn.

Use LOGPCONN or LOGPBSCCONN whereever possible.

Tweak a few log messages and remove one redundant log.

Change-Id: If9cb0e7a5cef2ec37a1a7c548aecf11a11c22eec
2017-12-20 16:01:13 +00:00
Neels Hofmeyr 26c218d0e7 smpp_smsc: fix truncated string copy into bind_r.system_id
The target buffer in libsmpp is 16 bytes long, and snprintf() may omit the
terminating zero. There seems to be no handling for unterminated strings, so
osmo_strlcpy() is the safer (and presumably more optimal) choice.

Change-Id: I5845666201f945ea9f83da62f2dd4bec52eb74cf
2017-12-20 15:49:38 +00:00
Neels Hofmeyr 9baedafa24 a_iface_bssap: compiler warning: cast const away from TLV val for l2h
Change-Id: Id91a4299391ff0d0e4e28ed05c2f755b9702146a
2017-12-18 23:14:58 +00:00
Neels Hofmeyr 439077746f compiler warning: extend #if 0 to include unused array
Change-Id: I5157d6c6d0aab469011ea648369f8e743e2cb085
2017-12-18 23:14:58 +00:00
Neels Hofmeyr 5282171bc3 fix GSM-Milenage in presence of 2G keys
In case of UMTS AKA, the Kc for ciphering must be derived from the 3G auth
tokens. tuple->vec.kc was calculated from the GSM algorithm and is not
necessarily a match for the UMTS AKA tokens.

So far we were always sending the Kc retrieved from osmo-hlr. If the 2G auth
algo is set to milenage, the 2G Kc coincides with the one derived from 3G
tokens, but if 2G is set to a different algorithm, the Kc received from the
osmo-hlr is not usable for ciphering when UMTS AKA was used for authentication
(on R99 capable GERAN and MS).

Implementation: To decide whether to use UMTS AKA derived Kc or the Kc from the
auth vector, use the umts_aka flag added to set_ciph_mode() in a previous
patch. Use osmo_auth_c3() to derive the GSM AKA Kc from the UMTS AKA CK and KI.

Related: OS#2745
Requires: I85a1d6ae95ad9e5ce9524ef7fc06414848afc2aa (libosmocore)
Change-Id: If04e405426c55a81341747a9b450a69188525d5c
2017-12-18 23:06:25 +00:00
Neels Hofmeyr 7fca2ce929 cosmetic: msc_paging_request: drop obsolete comment
Change-Id: Icb5b7dbbca3ca0db3d80a4b693c57c6d67fd823e
2017-12-18 18:02:21 +01:00
Neels Hofmeyr 76a10f569f drop unused T* timers (BSC land, not MSC)
Change-Id: If27899c90b7c79f25cd5fd5e2429cb3012d69744
2017-12-18 18:02:21 +01:00
Neels Hofmeyr 2ef2da54ab cosmetic prep: tell vlr_ops.set_ciph_mode() whether UMTS AKA is used
In case of UMTS AKA, the Kc for ciphering must be derived from the 3G auth
tokens. tuple->vec.kc was calculated from the GSM algorithm and is not
necessarily a match for the UMTS AKA tokens.

To decide (in an upcoming patch) whether to use UMTS AKA derived Kc or the Kc
from the auth vector, the set_ciph_mode() from vlr_ops needs to know whether
UMTS AKA is being used. This could possibly derived from the msc_conn_ref, but
all flags are already available in the vlr_lu_fsm and vlr_access_req_fsm. Hence
add a umts_aka flag to the set_ciph_mode() callback invocation. The VLR FSMs
thus decide whether UMTS AKA or GSM AKA is to be used during Ciphering Mode
Command, which makes more sense than re-implementing the same decision process
in the MSC.

I considered placing the Kc derivation in vlr_set_ciph_mode() and only tell the
MSC's set_ciph_mode() implementation the precise keys it should use, but the
RAN particulars, and whether a Kc is used at all, rather belong with the MSC.

Related: OS#2745
Prepares: If04e405426c55a81341747a9b450a69188525d5c
Change-Id: I983c48347faf4ee1b405d8174b4e006c904157cf
2017-12-18 05:18:11 +01:00
Neels Hofmeyr e3d72d7827 cosmetic prep: publish vlr_use_umts_aka() decision
During Set Ciphering Mode on GERAN, it is required to know whether UMTS AKA is
used to decide which Kc to pick. Change static function is_umts_auth() into
public vlr_use_umts_aka(), so future patches can re-use it.

Prepares: If04e405426c55a81341747a9b450a69188525d5c
Change-Id: I85d784c62ecbabdb6186a3dae4dcd554e7921041
2017-12-18 05:18:11 +01:00
Neels Hofmeyr 703638e79a cosmetic: move translation of vlr_ciph into msc_vlr_set_ciph_mode()
a_iface_tx_cipher_mode() is a bit too far away from the VLR to be handling its
ciphering enums. Instead, construct the gsm0808_encrypt_info in the
msc_vlr_set_ciph_mode() callback.

Greatly simplify the sanity checking code: a_iface_tx_cipher_mode() no longer
needs to re-verify the presence of the gsm0808_encrypt_info contents.

Change-Id: Id46f9a513b555d0a481f7124c9984c2b5b196b3e
2017-12-18 05:18:11 +01:00
Neels Hofmeyr cf30913c8e fix BSSMAP Cipher Mode Cmd: properly set permitted algorithms
The bit shifting is performed in gsm0808_enc_encrypt_info(), and must not be
done when populating the gsm0808_encrypt_info struct.

Provide vlr_ciph_to_gsm0808_alg_id() to translate the enum vlr_ciph to the
GSM0808_* constants we need to put in the gsm0808_encrypt_info struct instead.

Related: OS#2745
Change-Id: If75f95e8a5cc8b9979610ce6d746c1f0073ee39a
2017-12-18 03:48:24 +01:00
Neels Hofmeyr 4cf4fddf28 vlr: debug log: log Ciphering Mode details
Change-Id: Ib19dfd7255bda01ebace62386df4ec89697d9d14
2017-12-18 03:48:24 +01:00
Neels Hofmeyr 3f5b7808f5 cosmetic: msc_vlr_tests: log SMS details when invoked with -v
DLSMS logs SMS pointers, so is not suitable for logging them always. Allow
logging for manual invocation, though.

Change-Id: I1b7d2fd3fb38bf50eeabd6f7ef736d70a17de7a6
2017-12-18 03:48:24 +01:00
Neels Hofmeyr f879fc92cf debug log: a_iface_tx_cipher_mode(): log cipher and key
Introduce LOGPCONN() which would also be useful in numerous other places in
this file.

Change-Id: Ib406d6e6784342341e716206997e382c702ac9d2
2017-12-18 03:47:14 +01:00
Neels Hofmeyr fb21d9dde6 compiler warning: drop double 'const' in a_iface_tx_cipher_mode()
Change-Id: I3b8baa9a259704e719ce7f12776f2d2125ebdef0
2017-12-14 03:51:34 +01:00
Neels Hofmeyr c5981b34af fix vty write: add missing 'authentication optional/required' output
Change-Id: I4918b8a8a6f4cbe783f588ebe68a2cf1e7e50ae2
2017-12-14 00:51:44 +01:00
Neels Hofmeyr db8272921d sms.db: silence libdbi warnings on out-of-range index
Apparently, since libdbi 0.9.0 aka 0.9.0-5 on debian-testing, osmo-msc barfs
numerous libdbi warnings whenever a query rightfully returns no rows.

Trivially query whether there are any rows first by adding an inline wrap
function next_row().

Silenced:

  DDB <000d> ../../../../src/osmo-msc/src/libmsc/db.c:188 DBI: -6: An invalid or out-of-range index was passed to libdbi
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:47 backtrace() returned 11 addresses
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0xfb81) [0x555555563b81]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/lib/x86_64-linux-gnu/libdbi.so.1(_error_handler+0x99) [0x7ffff63f5c39]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/lib/x86_64-linux-gnu/libdbi.so.1(dbi_result_next_row+0x3d) [0x7ffff63f785d]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0x11172) [0x555555565172]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0x1e6bc) [0x5555555726bc]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0x1e7f6) [0x5555555727f6]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0x1f1d2) [0x5555555731d2]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0xbb86) [0x55555555fb86]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1) [0x7ffff5cfe561]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0xbfba) [0x55555555ffba]

Related: OS#2667
Change-Id: Ib8993c8db171d1e845a6297deef137d18506cda3
2017-12-10 14:45:15 +01:00
Neels Hofmeyr 50d0900916 sms db: properly quote MSISDN in various SQL queries
Related: OS#2706
Change-Id: I793a3863e6f4ccbabafc7dabaff97a8c79bbd8e0
2017-12-06 12:54:13 +00:00
Neels Hofmeyr f6704f1a50 sms db: don't attempt to query pending SMS for unset MSISDN
When the subscriber has no MSISDN, we might construct an invalid SQL statement
such as

  ... AND dest_addr= AND ...

Instead, don't even query for empty MSISDNs.

Related: OS#2706
Change-Id: I7d6169d774b2da04b3051957e364fe620feed51e
2017-12-06 12:51:17 +00:00
Alexander Huemer a55dda703f Remove utils imported from openbsc, fix building remaining util smpp_mirror
Related: OS#2522
Change-Id: If7e1af11cdac8587bb4d66fb4eacee4b79945359
2017-12-05 19:16:32 +00:00
Alexander Huemer f6d6a574e2 Add missing CFLAGS
Change-Id: I67b5d797a80b55e01dcdbb8c782748b049cf9199
2017-12-05 19:16:32 +00:00