Commit Graph

1488 Commits

Author SHA1 Message Date
Max 038e3d6426 ctrl: take both address and port from vty config
Change-Id: I31e971270a6658366651b29c99ec5247656c62c6
2022-12-17 20:50:14 +03:00
Vadim Yanitskiy 8284fb053d libmsc: check return value of gsm0808_create_ass2()
Change-Id: I6fd1669f2919034599d99336cf56f25a97afdf7c
2022-12-14 04:47:58 +07:00
Max 634591e85b SMPP: make smpp_smsc_stop() static
It's only used in a single file so there's no point exposing it via header.

Related: OS#5568
Change-Id: I3d0d850ffe6ebf9d623c1f250d4293a3c427d5d8
2022-11-21 16:31:05 +03:00
Neels Hofmeyr 40d3497877 add some comments to sdp_msg.c,h
Related: SYS#5066
Change-Id: I68aa4af5d84eaaa08a567377687b6292cce0ce94
2022-11-15 12:53:07 +00:00
Neels Hofmeyr 2d116822f3 add sdp_audio_codec_is_set
Change-Id: I078efe5b42367ad1089c53f11f7eb6f3a9dd9443
2022-11-15 12:53:07 +00:00
Neels Hofmeyr e29ee5a4e2 log CC timeouts
Change-Id: I857b4b15ebf75cf253697e96d358128620923221
2022-11-15 12:53:07 +00:00
Neels Hofmeyr 6d9b485f6a sdp_msg: when NULL, do not crash but return empty SDP str
Change-Id: Ibd5c43fae61cd006d8fb42a06b99a609356f7037
2022-11-15 12:53:07 +00:00
Max 2c6c74ea5c SMPP: fix possible NULL pointer dereference
Related: OS#5568
Change-Id: I875eb5249004d3a960aee46c5099592d18fcaa76
2022-10-28 17:24:49 +00:00
Neels Hofmeyr 1cb18a2dc8 vlr: implement fallback to no-auth
When the HLR fails to return auth info and authentication and ciphering
are configured to be optional, fall back to no-auth.

This patch concludes a series of preparatory patches and implements the
actual functional change.

Related: OS#4830
Change-Id: I5feda196fa481dd8a46b0e4721c64b7c6600f0d1
2022-10-27 23:59:38 +02:00
Neels Hofmeyr 66d4ab8a61 vlr_auth_fsm: add result no_auth_info_event
Add third outcome of auth_fsm: the no_auth_info_event, which should be
dispatched when auth failed because the HLR has no auth info for this
subscriber, i.e. not because an actual auth challenge failed.

No functional change: Handling no_auth_info_event separately follows in
another patch (to allow fallback to no-auth). Feed the same
_E_AUTH_FAILURE as no_auth_info_event to still behave unchanged.

Related: OS#4830
Change-Id: I5103b1f2727f1729a5517ae359df813d50436ed3
2022-10-27 23:59:38 +02:00
Neels Hofmeyr 3189f39a4e vlr: auth_fsm: rename AUTH_RES to AUTH_SUCCESS
Previous patch added the AUTH_FAILURE event, which means that the
AUTH_RES event now only signals success. Reflect that in the name.

No functional change.

Related: OS#4830
Change-Id: I7124a3591fcf36cee06d7488eeb94f9b85af5dc2
2022-10-27 23:59:38 +02:00
Neels Hofmeyr 923b664215 vlr: auth_fsm: clarify success/failure result
Explicitly send distinct parent events on auth success and failure. So
far determining success depended only on the data pointer passed on with
the event. Distinct events clarify the logging and the FSM code.

This prepares for a third FSM outcome to be added in a subsequent patch,
to separately signal when the HLR has no auth data.

No functional change.

Related: OS#4830
Change-Id: I02776dfe6785983f2ebe398f57867f5ceb288ba0
2022-10-27 23:59:38 +02:00
Neels Hofmeyr c48afa1416 vlr_lu_fsm: clarify naming of static functions
These functions actually return whether these procedures should be
attempted, not whether they are absolutely required. Rename to avoid
confusion in upcoming patches.

Related: OS#4830
Change-Id: I0ea90476470109134411255ffd1f11d88236c91b
2022-10-27 23:59:17 +02:00
Neels Hofmeyr 2ea7264b86 msc_a,vlr: add is_ciphering_required (accurately named)
For establishing Layer 3, pass a flag from msc_a to VLR that indicates
to fail if encryption is not possible.

An earlier patch [1] renamed a previously existing flag
require_ciphering to is_ciphering_to_be_attempted, because the naming
was not accurate. This new flag now indicates what its name suggests.

This new flag is needed for upcoming patch [2] to distinguish between
optional and mandatory encryption.

[1] Ia55085e3b36feb275bcf92fc91a4be7d1c24a6b9
[2] I5feda196fa481dd8a46b0e4721c64b7c6600f0d1

Related: OS#4830
Change-Id: I52090c5f5db997030da7c2ed9beca9c51f55f4cf
2022-10-27 23:54:00 +02:00
Neels Hofmeyr d99a607ac9 msc_a,vlr: rename ciphering_required to is_ciphering_to_be_attempted
Clarify the name to avoid confusion in upcoming patches.

This function actually returns whether any ciphering mode besides A5/0
is enabled, and does not imply that ciphering is mandatory. A5/0 may
well be allowed when this function returns true.

Related: OS#4830
Change-Id: Ia55085e3b36feb275bcf92fc91a4be7d1c24a6b9
2022-10-27 23:30:30 +02:00
Max bb624162ea SMPP: use default port from libsmpp34
Related: OS#5568
Requires: libsmpp34.git I2fcc15ac60b7b6501c9cb1afd0fe6d66d4b76f5f
Change-Id: I2140ed57e64f17fb79130014eaf88f58b62d7a00
2022-10-20 20:10:39 +03:00
Pau Espin 093fd2e2b7 call_leg: Fix EV_MGW_ENDPOINT_GONE not processed in RELEASE state
Since call_leg_fsm_releasing_onenter() calls immediatelly
osmo_fsm_inst_term(), it meant we couldn't receive any event in that
state because osmo_fsm disables event dispatching to FSMs being
terminated.
As a result, CALL_LEG_EV_MGW_ENDPOINT_GONE was never received and hence
call_leg_mgw_endpoint_gone() was never called, which means the
mgcp_client used in cl->mgw_endpoint was never put back to the pool.

By first freeing all the children (rtp_streams), we make sure
cl->mgw_endpoint ends up with no conns and sends us the GONE event
before we go ourselves into termination state.

Related: SYS#5987
Change-Id: I2126578c4e64c9f336e8a1f6ee98de970866b8dc
2022-10-19 18:46:05 +02:00
Pau Espin 53639ea03f vty: Make use of new mgcp_client_pool_config_write() API
Let's use the new API available in libosmo-mgcp-client to control more
consciously where the mgw pool config is printed.
Before this patch, the place where the node was printed was defined
based on implementation details on how the enum of nodes are defined and
installed.

Related: SYS#5987
Depends: osmo-mgw.git Change-Id I7a620cf47886d8ecab30ce369cf123d98ab842c5
Change-Id: Ic473fe05c55e8df3eddedf0260ec04b6fefc501f
2022-10-19 18:27:18 +02:00
Pau Espin b44cf2d575 Introduce support for libosmo-mgcp-client MGW pooling
Large RAN installations may benefit from distributing the RTP voice
stream load over multiple media gateways.

libosmo-mgcp-client supports MGW pooling since version 1.8.0 (more than
one year ago). OsmoBSC has already been making use of it since then (see
osmo-bsc.git 8d22e6870637ed6d392a8a77aeaebc51b23a8a50); lets use this
feature in osmo-msc too.

This commit is also part of a series of patches cleaning up
libosmo-mgcp-client and slowly getting rid of the old non-mgw-pooled VTY
configuration, in order to keep only 1 way to configure
libosmo-mgcp-client through VTY.

Related: SYS#5091
Related: SYS#5987
Change-Id: I7670ba56fe989706579224a364595fdd4b4708ff
2022-10-19 18:27:15 +02:00
Max 9683b5f991 smpp_mirror: fix compiler warning
Use same system_id/password length limits as OsmoMSC.

Related: OS#5568
Change-Id: Iaf2b99b80f81762f5b2577f7bc490791c9cc1810
2022-10-15 16:36:54 +03:00
Max e4f429cc90 SMPP: remove duplicate g_smsc definition
The global g_smsc struct pointer is defined twice in the same file.
Let's keep the earlier definition.

Related: OS#5568
Change-Id: If96a44450563d45b707bdd4165cf3cf269db9906
2022-10-11 15:22:02 +00:00
Keith Whyte ba4d682b70 Change CC_CAUSE returned on unanswered MT Call
The timer "mgw X2" (RTP stream establishing timeout)
is set by default to 30 seconds.
When an MT call is ringing and remains unanswered, it
is this timer that will expire, and the call is terminated.

Up to now this results in a CC_CAUSE of Resource Unavailable
and if osmo-sip-connector is in use, the SIP agent will
get 503 Service Unavailable.
While "resource unavailable" may be technically correct, in
that the MGW did not return an rtp stream in time, returning
"No User Responding" (resulting in SIP 480) is probably a
more accurate description of what actually happened,
allowing the switch to inform the caller.

Change-Id: I4a9cfc388ec9ecb743d154a114a6db638eac4701
2022-10-03 19:16:14 +00:00
Vadim Yanitskiy eab86612d3 mncc: cosmetic: fix coding style in mncc_prim_check_sign()
Change-Id: I94d9cba7aca19f28c906e05dd86bfe3020abd5b1
Related: OS#5282
2022-10-03 16:20:05 +07:00
Vadim Yanitskiy 8e15c797ca mncc: move MNCC_F_ALL from mncc.c to mncc.h
Move it closer to the other MNCC_F_* entries, so that it's more
likely that it gets updated when new flags are added.

Change-Id: If1a12a696b87184c9eee14f475594c317927427b
Related: OS#5282
2022-10-03 16:20:01 +07:00
Keith Whyte fdfe0c23ec Update MNCC field validation mask.
In c6921e5068, 0x4000 was added to the
possible MNCC field flags, but before this commit, using it would
result in an ERROR of "Unknown MNCC field mask 0x....."

Related: OS#5282
Change-Id: I9e7d224e7f2d6d2824b2466752b6e8c994ac5a3d
2022-10-03 15:39:11 +07:00
Max dfb1cb80ca cosmetic: use proper name for SMPP handlers
Change-Id: I0d714e927e287a0ea9362008ed050a492510e22b
2022-09-15 20:47:37 +07:00
Max 4743a77e09 Use libsmpputil functions in smpp_mirror tool
Related: OS#5568
Change-Id: Icb046570803acb3eff89e2a4eb979c4899d485f7
2022-09-15 20:47:37 +07:00
Max 366a340ee1 Make esme struct shared
This helps to merge similar code from smpp_mirror and smpp_* in follow-up patches.

Related: OS#5568
Change-Id: I8f7ac2c00d16660925dd0b03aa1a0973edf9eb70
2022-09-15 20:47:37 +07:00
Max 62977d0484 Add ESME-specific logging
Related: OS#5568
Change-Id: Ie5ddde762350385f8d18ee1d441584a41b0290ec
2022-08-05 22:12:09 +07:00
Max 5346f69a54 Introduce libsmpputil
As part of preparation for libosmo-netif migration let's move common SMPP code
into separate build-time library and use it for both smpp_mirror and OsmoMSC
renaming the files if necessary.

While at it we also fix id/password legth limits in smpp_mirror and drop unused
fields from ESME struct.

Related: OS#5568
Change-Id: I61910651bc7c188dc2fb67d96189a66a47e7e8fb
2022-08-05 22:12:09 +07:00
Max 1470d0b870 ESME: use osmo_sock_get_name() for logging
This allows us to drop single-use parameters from osmo_esme to facilitate further code changes.

Related: OS#5568
Change-Id: I34bd4c145b0f6287a323e2350808feb59f1d3187
2022-08-01 13:53:37 +00:00
Max 4b1202bfdf SMPP: clarify (re)start logic
Having smpp_smsc_stop() called from within smpp_smsc_start() instead of
explicitly inside smpp_smsc_restart() is confusing and could lead to
hard-to-trace bugs. Let's get this fixed first before going further.

Related: OS#5568
Change-Id: I353f5b82c9f5308d93e926538d4ef7e24d0b0339
2022-08-01 13:53:37 +00:00
Neels Hofmeyr d20dd22082 sdp_msg: s/sdp_audio_codec_/sdp_audio_codecs_
Some functions act on a struct sdp_audio_codecs but begin with the name
sdp_audio_codec (singular). That's confusing.

Related: SYS#5066
Change-Id: Id87eb350c1f17f8dbf776909824bfa06634c1d04
2022-07-25 14:25:07 +02:00
Neels Hofmeyr c9e0ca3d1f sdp_msg: add sdp_audio_codecs_cmp(), add compare flags
A problem with SDP fmtp handling is visible in this patch: when cmp_fmtp
is true, we compare fmtp strings 1:1, which is not how things should be
done. The intention is to fix fmtp handling in a later patch.

At least there now is a flag to bypass fmtp comparison altogether.

Related: SYS#5066
Change-Id: I18d33e189674229501afec950aa1c732386455a2
2022-07-25 14:25:07 +02:00
Neels Hofmeyr 99ab7c57da in sdp logging: add payload type number like 'AMR#111'
Related: SYS#5066
Change-Id: Icbb4e89ce2947bf787c3ee14e3e115d406e43de2
2022-07-25 14:24:48 +02:00
Neels Hofmeyr 9a515e5db0 sdp_msg: s/_name_/_to_str_/g
foo_name is intended for a short id, foo_to_str is more accurate naming
here.

Related: SYS#5066
Change-Id: I21d73b2e2633dd4841ff69a0c5fdf9b1a4c0615f
2022-07-25 14:07:14 +02:00
Neels Hofmeyr 90933d46ba cosmetic: log actual MNCC msg in tch_rtp_connect()
Related: SYS#5066
Change-Id: I99161eeb64fd0faa7be6fc1e4986e2ba1bdcc75c
2022-07-25 14:06:26 +02:00
Neels Hofmeyr 550506aaf1 err log: fix reverse statement in msc_a call handling
Change-Id: I937abe25ba87d0fcddc3351ac391cf6e7e776de6
2022-07-22 19:11:18 +02:00
Neels Hofmeyr a9e383f5bd missing whitespace in gsm_04_08_cc.c
Change-Id: If9e2f543d1924421c1a1f1e1e100c7d9fb63c139
2022-07-22 19:09:58 +02:00
Neels Hofmeyr 3551d84ad8 fix typo in msgb name for CC SETUP
Change-Id: Id2c44966152805ea52bd7e7534529832fc2312ab
2022-07-22 19:09:44 +02:00
Keith Whyte 99bd0f3204 Turn off secure_delete in sqlite
libsqlite3 that ships with some distributions may have secure_delete
activated by default. This means all database records are overwritten
with zeros on DELETE. We don't needs this extra overhead.

Change-Id: I9da6499a38096c8df2025bb9d35ec789864b7c5e
2022-07-08 00:44:52 +01:00
Keith Whyte ea62986928 Don't let this osmo-msc operate on a libdbi database
The Binary format changed when libdbi was removed. If we let osmo-msc run on an
unconverted database, the results are unpredictable, certainly undesirable.

Change-Id: I887b6a4374b1c83684f4007e9791ae58bba4e8c1
2022-06-30 20:44:28 +00:00
Harald Welte a3c639ff5f sms: Introduce VTY-configurable minimum SMS validity period
This is meant as a safeguard against users or user equipment which
doesn't set a reasonable validity period.  Using this setting, the
SMSC administrator can set a minimum SMS validity period. Any SMS
submitted with lower validity period will be extended to that minimum.

Change-Id: I192528a6f9059d158fa12876a247d61bd7edaec8
Related: OS#5567
2022-05-19 19:34:41 +00:00
Harald Welte 2765a18450 sms: Make default SMS validity period configurable via VTY
Change-Id: Ie2c81c1d5795dd9aaf07b9766013f20b01abc762
2022-05-19 19:34:41 +00:00
Harald Welte e6f1160046 smpp: Parse and use SMPP-provided validity period
Before this patch, we always ignored any SMPP-provided validity period
and used '0' which is now, and means it expires immediately.

As SMPP allows for validity_period of NULL, use 7 days as SMSC default
in such situations.

Change-Id: Iad9f2697f045ed3bc0eb74c3a9730861f82e6c48
Closes: OS#5567
2022-05-19 19:34:41 +00:00
Harald Welte 53e2e5fe70 sms_queue: Make deletion of messages from DB VTY-configurable
This introduces some VTY settings that determine if delivered
or expired messages should be removed from he SQL database or not.

Change-Id: Id6174875d5c01c40d987077651b27ae1acbcaa93
2022-05-19 19:34:41 +00:00
Harald Welte 03e8583a43 sms_queue: Use local variable rather than 9x pointer de-ref in function
Change-Id: Idf6eb9ec6603a0643033396ed9227e4319724145
2022-05-19 19:34:41 +00:00
Harald Welte 1a62db20e7 sms: Give smsc its own VTY config node
The pre-historic sms_queue code used to have very strange aspects,
such as having some parameters (max-failure, max-pending) which could
only be sent from the 'enable' node, but not from a config file.

Before adding more configuration parameters, let's clean this up by
introducing a proper VTY config node for the 'smsc'; move the existing
config commands there and add new ones for max-failure and max-pending.

As the sms_queue data structure is only allocated after the config file
parsing happens, we are introducing a new 'sms_queue_config' data
structure.  This encapsulates the public readable/writable config
parameters.

Change-Id: Ie8e0ab1a9f979337ff06544b9ab3820954d9804a
2022-05-19 19:34:41 +00:00
Harald Welte d302bb11fa sms: Encapsulate SMS queue related config parameters
Introduce a 'struct sms_queue_config' that holds all config parameters
related to the SMS queue.

Change-Id: I559ab7a6e0502a1a12a662ebd5591875d47ec7b2
2022-05-17 14:47:31 +02:00
Harald Welte 1d72e301cb db: Switch from 'synchronous = FULL' to 'synchronous = NORMAL'
As we're using WAL mode, it is not neccessary to use synchronous=FULL
but rely on synchronous=NORMAL mode while still guaranteeing database
consistency.

To do this, we can fix the typo in one of our two PRAGMA statements,
and remove the other.

See https://www.sqlite.org/pragma.html#pragma_synchronous for the
sqlite3 documentation on that topic.

Change-Id: Ie782f0fe90e7204c4d55cdb3948b728c348367d1
Closes: OS#5566
RelateD: OS#5564, OS#5563
2022-05-17 14:04:44 +02:00
Harald Welte d43c22ef65 switch from libdbi to lbsqlite3
The choice of libdbi was one of the biggest early mistakes in (back
then) OpenBSC development.  A database abstraction library that
prevents you from using proper prepared statements.  Let's finally
abandon it and use sqlite3 directly, just like we do in osmo-hlr.

I decided to remove the database migration code as it would be relatively
cumbersome to port all of it to direct sqlite3 with prepared statements,
and it is prone to introduction of all kinds of errors.  Since we don't
have a body of older database files and comprehensive migration tests,
it is safer to not offer migration code of uncertain quality.  The last
schema revision (5) was introduced 5 years ago in 2017 (osmo-msc
v1.1.0), so it is considered an exceptionally rare case.  People can
install osmo-msc 1.1.0 through 1.8.0 to upgrade to v5 before using
this new 'direct sqlite3' version of osmo-msc.

Change-Id: Ia334904289f92d014e7bd16b02b3b5817c12c790
Related: OS#5559, OS#5563, OS#5564
2022-05-17 14:04:44 +02:00
Harald Welte 7262d0875a sms_queue: merge sms_pending_add into sms_pending_from
Both callers would immediately execute sms_pending_add() after
a successful sms_pending_from(); we can merge those two functions.

Change-Id: Iaf37234b3caafd568dd4fe17739be9ec842c2a8d
2022-05-16 17:44:01 +02:00
Harald Welte 7f918af50b sms_queue: refactor sms_pending add/remove code
This avoids every caller from manually having to remember to
increment the count, the stat_item and llist_{add,del}.

Change-Id: Ice4c73727ef2d7e4118f0ef5fe24cae943c7528f
2022-05-16 17:44:01 +02:00
Harald Welte bf254f6da5 smpp: don't enqueue write messages if ESME is disconnected
If the ESME has been disconnected (dead socket) but still is
in memory (other users hold a use count), we shouldn't enqueue
messages to the write queue.

This prevents messages like
DSMPP write_queue.c:112 wqueue(0x7f8bc392f6e0) is full. Rejecting msgb

Change-Id: I10a270f1d555782be272f4d78da43190618a9950
Closes: OS#3278
2022-05-16 17:43:57 +02:00
Harald Welte 022193da73 smpp: Fix use-after-free bug when ESME disconnects but has write pending
When the SMPP code free's an ESME it also free's the related write_queue
and the osmo_fd contained therein.  So if this happens while we are
in esme_link_read_cb(), we must return -EBADF to make
osmo_wqueue_bfd_cb() of libosmocore avoid further accessing related
memory.

Change-Id: I441d3b05c2f2556c530783a7f66c73adf6d845a1
Closes: OS#5565
2022-05-16 17:33:42 +02:00
Harald Welte 63494a6bef sms_queue: Introduce rate_ctr / stat_item
This allows us to monitor the load of the SMS queue.

Change-Id: I8c00b5b0d33695fbb5f89fd2a4c8e35c9f7df6ac
2022-05-16 10:30:43 +02:00
Harald Welte 123261e0bb vlr: Add rate counters and stat items
This should give us some more insight into what is happening inside
the MSC's VLR in terms of number of subcribers, rate of successful /
unsuccessful GSUP procedures, etc.

Related: OS#1974
Change-Id: I681bcfc1875363478190151f2931cad197323ee8
2022-05-15 16:23:02 +02:00
Harald Welte 173bdf303b vlr: Split vlr_subscr_rx_imsi_detach()
The function vlr_subscr_rx_imsi_detach() implies that an explicit IMSI
DETACH was received.  However, that same function was called in other
situations such as timer expiration or GSUP CANCEL.

Let's clean this up by splitting the function into two parts.

No logical change is introduced to the VLR in this patch.

Change-Id: Iffc02f3062ad591ca372a3c6d866066cf63a8830
2022-05-15 15:47:00 +02:00
Harald Welte dc7d841aad sms_queue: Annotate each function with some comment
It makes the code much more readable if there's at least a one-liner
documenting each function (and struct member).

Change-Id: I6d239369cabdf1703eba7f3606b46b95cbbb1ea7
2022-05-15 13:05:03 +02:00
Harald Welte 467fc5728d switch sqlite3 to single-threaded mode
Looking at 'perf top' of osmo-msc under load shows that there's a
significant amount of time spent in terms of locking (mutex,...)
which is useless as osmo-msc is a single-threaded application.

Unfortunately libdbi doesn't provide a mechanism to perform
sqlite3_config(), so we have to do it directly here, introducing an
explicit build-time dependency (and linkage) to libsqlite3.

Related: OS#5559
Change-Id: I5bbea90d28b6d73b64b9e5124ff59304b90a8a75
2022-05-15 13:04:56 +02:00
Harald Welte 2db1966e25 call rate_ctr_init() to make rate counters work properly
The existing rate counters per-minute/hour/day values were never
computed as the related timer was never started...

Change-Id: I27282051a6da5d1e1a25981712fbe4c4a6378dea
2022-05-13 19:16:57 +02:00
Neels Hofmeyr 5d53c6001d fix crash on CM Serv Rej: fix use count mismatch
With comments, clarify the code paths where a CM Service use count has
not yet been placed on the conn (just send CM Service Reject) and where
the use count is placed (decrement count on CM Service Reject).

Place the CM Service use count slightly earlier:
- it is then correctly present when checking the mobile identity in
  cm_serv_reuse_conn(), avoiding the crash reported in OS#5532.
- there is only one place incrementing the use count instead of two.

Related: OS#5532
Change-Id: I6c735b79b67108bcaadada3f01c7046e262f939b
2022-05-04 23:43:11 +02:00
Pau Espin dd26226395 call_leg: local_bridge: Avoid null pointer access if CN-side not ready
This happens if for instance an HNBGW drops the RAB-AssignmentRequest
and does nothing with it.

call_leg.c:348:15: runtime error: member access within null pointer of type 'struct rtp_stream'

Related: OS#5401
Change-Id: I67d2d5b2dd3b367c34f929d63c056306ec001431
2022-01-13 15:40:08 +01:00
Pau Espin d795531564 ran_msg_iu.c: Set proper codec in Assignment Complete
We need to set the codec as present in order for
msc_a_up_call_assignment_complete() to configure properly the CN-side of
he leg with the IUFP codec, which should be the desired default in order
to avoid transcoding.

Change-Id: Ib8086462239e2df748cf47ea7b37a07f1f3b85a8
2022-01-07 18:50:23 +01:00
Pau Espin 9de384a28c Avoid setting audio codec if not available during assignment_complete (MDCX)
RAB Assignment Complete contains no codec info, hence
assignment_complete.codec is not set and
assignment_complete.codec_present is false.
As a result a wrong value is passed to rtp_stream_set_codec.

This fixes osmo-msc sending "a=rtpmap:112 AMR/8000/1" during MDCX in the
RAT-side connection of the call leg after having properly sent
VND.3GPP.IUFP/16000 in CRCX.

Change-Id: Ic028d35893d29f7d72f22f82ef89695229c9b01b
2022-01-07 18:50:15 +01:00
Pau Espin 3a02d29804 Announce IuFP audio codec for UTRAN conns in CRCX towards MGW
This way the MGW knows it has to handle IuUP in that connection (answer
IuUP Initialization, etc.).

Depends: osmo-mgw.git 1de5ed6f979bd4c1380789c9a82f8e396f05c5f8
Change-Id: I7aca671e00ed27ac03f0d106b5a6b665a9bed4c1
2022-01-05 13:58:15 +01:00
Oliver Smith 2ee27f9e06 treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: I1b68e0aa26d81fbfe26abaa287d2bd5eec2cfd0f
2021-12-14 12:18:16 +01:00
Alexander Couzens e400b1161d ran_msg_iu: do not pass UEA0 to ranap_new_msg_sec_mod_cmd2()
On the protocol level, it's impossible to indicate UEA0 together
with the other algorithms.  The encryption is either a) disabled,
so the Encryption Information IE is not present, or b) enabled,
so the Encryption Information IE indicates UEA1 and/or UEA2.

Because of that, the ranap_new_msg_sec_mod_cmd2() would fail to
generate the RANAP PDU if the given bitmask has the UEA0 bit set.

Fixes: 505a94a610 ("Make UTRAN encryption algorithms configurable")
Change-Id: I3271d27c09fc8d70a912bce998ceffbce64dd95e
2021-12-09 13:42:28 +00:00
Vadim Yanitskiy c44342b88c libmsc: fix memory leak (struct msgb) in msc_i_ran_enc()
Function msc_i_ran_enc() calls msc_role_ran_encode(), but unlike the
other callers of this function it does not free() the encoded message.

A simple solution would be to call msgb_free(), like it's done in
the other places.  But a more elegant solution is to modify function
msc_role_ran_encode(), so that it attaches the msgb to OTC_SELECT.
This way there is no need to call msgb_free() here and there.

This change fixes a memleak observed while running ttcn3-msc-test.

Change-Id: I741e082badc32ba9a97c1495c894e1d22e122e3a
Related: OS#5340
2021-12-07 18:43:00 +03:00
Vadim Yanitskiy d405bad32d libmsc: ran_iu_make_security_mode_command(): clarify UIA mask
Change-Id: I7535d5ede5b22c61575a16d15927598e6137392a
2021-12-02 04:47:04 +03:00
Vadim Yanitskiy 35db146e88 libmsc: ran_iu_make_security_mode_command(): improve readability
Change-Id: I14f4f9617f91ed17fb7614f218cb023a0231866d
2021-11-30 13:14:16 +00:00
Vadim Yanitskiy 565ea2ba0c libvlr: fix is_ciph_required(): always send SecModeCmd for UTRAN
Ciphering is optional in both GERAN and UTRAN, however for the later
it's *required* to enable integrity protection for the signalling.
Thus we must always send Security Mode Command in UTRAN, even in
case if ciphering is disabled (UEA0) in the configuration.

The actual decision whether to send CMC/SMC or not is taken in:

  * vlr_access_req_fsm.c / _proc_arq_vlr_node2(), and
  * vlr_lu_fsm.c / vlr_loc_upd_post_auth().

depending on the value returned by is_ciph_required().  Let's
rename this function to is_cmc_smc_required() and ensure that
it always returns true in UTRAN.

This change fixes the Iu test cases in ttcn3-msc-test.

Change-Id: I6205f13453eff7afbf25e013d72ae98a78fcd31b
Fixes: OS#5333
2021-11-30 13:14:16 +00:00
Vadim Yanitskiy f4b87fa83c libvlr: vlr_set_ciph_mode(): avoid redundant check
This function is never called when ciph_required is false, so
there is no need for an additional check in this function.

Change-Id: I900ddd5f1882f8cee234ab1074adcf25830a092c
2021-11-30 09:53:47 +00:00
Vadim Yanitskiy 6d594e4e83 libmsc: fix another memleak (struct gsm_sms) in gsm340_rx_tpdu()
Change-Id: I42e819fb83096c1432df16f501b9d1f6a6160ae7
Fixes: I2c50904349dd4ed229b60b8468d776b817c0bd44
2021-11-29 20:36:35 +00:00
Vadim Yanitskiy ef19fc1ccd libmsc: fix memory leak (struct gsm_sms) in gsm340_rx_tpdu()
If a MO SMS gets successfully routed through SMPP, we return early
in gsm340_rx_tpdu() and leak a chunk of type 'struct gsm_sms'.

Change-Id: I8a745d747f06baa7109418ffe600b27b3c0a5228
Fixes: [1] Ic34d398e0a850856e20380ae35e5c2ae5e3c539b
Fixes: OS#5334
2021-11-29 20:36:35 +00:00
Vadim Yanitskiy 9a28230ef2 VTY: clarify deprecation message for cfg_net_per_loc_upd_cmd
Change-Id: I95636a7713cd90956e46a5b6f8f7ded3bf4f5f0a
2021-11-28 03:44:28 +03:00
Alexander Couzens 2c5e46104e libmsc/gsm_04_08: refactor require ciphering into an own function
Make it more readable.

Change-Id: I9e407f65b282e645feabe714f7f4c3e44fae21e9
2021-11-27 04:39:34 +01:00
Alexander Couzens 8b7d78588a utran: use new UTRAN encryption enum
Depends: libosmocore.git I4b9baff2c2fbd0e339fc769cc69cce58d3a72cdf
Change-Id: If6978d7ed1a78facc2591cfc30fda2721629bffa
2021-11-17 20:18:52 +00:00
Vadim Yanitskiy aefbf7a829 Do not mention deprecated -l / --database options
Change-Id: I47fe7e64126710db34c49f48ea9e8f8d46662e4b
2021-11-12 20:28:08 +03:00
Vadim Yanitskiy 1ec8e54317 Do not mention deprecated -M / --mncc-sock-path options
Change-Id: I34387f561446aa5bf5db5264f0aca6bf6469d0e5
2021-11-12 20:26:17 +03:00
Alexander Couzens 2aaff7513b Validate the choosen UTRAN encryption algorithm
RANAP Security Command can include an encryption IE. If it includes
it the RNC can still ignore it (e.g. unsupported encryption) and
return the Security Command Complete with an choosen encryption IE:
"no encryption".
Validate the encryption element and ensure the encryption is included in
the encryption mask.

Closes: OS#4144
Change-Id: Icfc135c8b8ae862defe7114db492af600c26407f
2021-11-05 01:29:05 +01:00
Harald Welte 505a94a610 Make UTRAN encryption algorithms configurable
Allow the user fine-grained control over which UMTS encryption
algorithms are permitted, rather than always permitting UEA1 and UEA2
or neither.

This brings the handling of UEA in line with the handling of A5 for
GERAN.

Change-Id: I91f9e50f9c1439aa19528f887b83ae9de628fcfd
Closes: OS#4144
Depends: osmo-iuh.git I6d2d033b0427bdc84fee61e0f3cb7b29935214bf
2021-11-05 01:29:05 +01:00
Harald Welte 274b70f1a8 Fix enabling of UMTS UEA encryption
The existing code allowed the user to configure UMTS encryption in the
vty, but we never actually passed this information down to RANAP.  As a
result, the RAN had no chance of ever enabling encryption on the air
interface.

Change-Id: Ieaaa6b23b7337b7edb902fad8031e195e0c5e9d2
Related: OS#4144
2021-11-05 01:29:05 +01:00
Vadim Yanitskiy c6921e5068 mncc: rework passing GCR over the MNCC interface
Using *unpacked* 'struct osmo_gcr_parsed' in the MNCC PDUs makes
the protocol even more complicated than it currently is, and
moreover complicates implementing MNCCv8 in the ttcn3-sip-test.

Replace 'struct osmo_gcr_parsed' in 'struct gsm_mncc' with a
fixed-length buffer, which is supposed to hold the Global Call
Reference encoded as per 3GPP TS 29.205.

Indicate presence of GCR using the MNCC_F_GCR flag.

Change-Id: I259b6d7e4cbe26159b9b496356fc7c1c27d54521
Fixes: I705c860e51637b4537cad65a330ecbaaca96dd5b
Related: OS#5164, OS#5282
2021-11-03 21:12:52 +00:00
Vadim Yanitskiy e0661105ac smpp_smsc: use osmo_talloc_replace_string() in smpp_smsc_conf()
Change-Id: Ie3dc0d9673a0410a5908cba77fc352d581bac6f6
Fixes: CID#240711
2021-10-30 02:27:21 +00:00
Vadim Yanitskiy 97b8e76b50 libmsc: struct smsc: drop 'const' qualifier from bind_addr
This pointer holds an address of a string allocated on heap.

Change-Id: I50145b57494aaccd4793f7b0ed2f65a6641db929
Related: CID#240711
2021-10-26 18:42:57 +00:00
Vadim Yanitskiy 583883bf2e libmsc: fix NULL pointer dereference in trans_lcls_compose()
Change-Id: I96342de4cb3e0bc3d3cac7538d4517aa211e8a38
Fixes: CID#240768
2021-10-26 10:25:39 +03:00
Keith Whyte a1a70be593 Add support for LCLS to the MSC
This commit is largely based on work by
Max <msuraev@sysmocom.de>

Adds LCLS parameters for A-interface transactions
This commit also adds a vty option to facilitate globally
disabling LCLS for all calls on this MSC.

Add a global call reference (GCR) to MNCC and therefore
bump the MNCC version to version 8. (This commit has to be
merged at the same time as the corresponing commit in the
osmo-sip-connector for mncc-external use.)

Depends: osmo-sip-connector Id40d7e0fed9356f801b3627c118150055e7232b1
Change-Id: I705c860e51637b4537cad65a330ecbaaca96dd5b
2021-10-25 10:07:48 +00:00
Harald Welte 890ece1277 smpp_mirror: Don't allocate msgb's for unrealistic amounts of memory
If the remote ESME would send us 0xffffffff as length field, don't try
to allocte 4GB of memory, but bail out.

Change-Id: I561f75210811826de06ea1673eca1df24faaa210
Fixes: CID#240738
2021-10-25 09:58:51 +00:00
Harald Welte 065b23ae5b smpp_mirror: Factor-out reset of SMPP read state
Change-Id: Ib9f210316eaddae19cb74db92b922016864dd786
2021-10-25 08:20:00 +02:00
Harald Welte 30811f865c smpp: Fix help string in vty for "alert-notifications"
Without the 'no' prefix, this command is about enabling, not disabling

Change-Id: I3019a0d9271e73030b9d7cd555761e17358ec812
2021-09-28 21:40:40 +02:00
Pau Espin 35ff852379 cosmetic: Fix typo in comment
Change-Id: Ic167bb4e12c657f917ad4f76ef65f46753c5f7a5
2021-08-25 12:40:36 +02:00
Pau Espin 017ba1fa30 vlr_sgs: Balance use_count incremented in vlr_sgs_loc_update
During a recent pcap trace, it was spotted that subscriber coming from
SGs had a use count with 16 "SGs" items, and later it incremented to 17.
Further investigation shows that the related use_count item was never
decreased, meaning every time an SGs-LU was sent by the MME, the item
was incremented further and never decremented.

Let's rename the item to be referenced while in LU, and then decremented
when LU is done. At that time, either the LU was accepted and the
subscriber object has a use_count item "attached", or it was rejected
and we already sent the reject messages, so we are fine deleting it if
needed.

Related: SYS#5337
Change-Id: I22c386f02ffa57428f700b003cc2cf23133598d0
2021-08-24 14:59:27 +02:00
Pau Espin 25b3ffb5f4 vlr_sgs.c: Fix missing use_count decrease in vlr_sgs_imsi_detach
it was recently observed in a pcap trace with gsmtap_log that the
use_count contained a "vlr_sgs_imsi_detach" item despite no related
message was seen near by. Further investigation shows that there's an
unbalanced get+put code path, introduced by an early return added to fix
another issue.

related: SYS#5337
Fixes: 0803d88d9a
Change-Id: I91ae956e50fca2f4d0e1d145d60ccb0ebfb409e9
2021-08-24 14:59:12 +02:00
Pau Espin eb1b3ab6da vlr_auth_fsm.c: Simplify function auth_fsm_wait_ai_resync
Change-Id: I2070002dea18b728deef5547b4deb6166cfcab6a
2021-08-24 12:25:40 +02:00
Pau Espin 25b6847f46 cosmetic: fix typos in comments
Change-Id: I89e8eba379f83bcf3061601b02af9f10dbca0f22
2021-08-24 11:42:15 +02:00
Neels Hofmeyr ae98b97382 implement CM Re-Establish for voice calls
Related: SYS#5130
Change-Id: I6fa37d6ca9fcb1637742b40e37b68d67664c9b60
2021-07-29 22:40:59 +02:00
Neels Hofmeyr 5bdba0d48d add vlr_subscr_find_by_mi
Will be used by I6fa37d6ca9fcb1637742b40e37b68d67664c9b60
"implement CM Re-Establish for voice calls"

Related: SYS#5130
Change-Id: I5291d098a02268bd1c2e30195ae61e4a13e8709c
2021-07-28 18:37:48 +02:00
Pau Espin e53ecde83e msc_a.c: Allow MSC_A_EV_CN_CLOSE in state MSC_A_ST_RELEASING
As seen in a running osmo-msc:
"vlr_access_req_fsm.c:153
msc_a(IMSI-....:MSISDN-...:TMSI-0x...:GERAN-A-8:CM_SERVICE_REQ){MSC_A_ST_RELEASING}:
Event MSC_A_EV_CN_CLOSE not permitted"

Also seen in several unit tests, which need update.

The action event handler for that state is actually already
expecting/handling the event by ignoring it, so we should allow it.

Change-Id: I4d30cffab693529aab3ba736419dec116a4dd7ef
2021-07-12 16:37:24 +02:00
Pau Espin 42ac3665c8 sgs_iface.c: Improve logging when paging over SGs
Change-Id: I745d3e904583ddf170ec1a1ceac5a49b72e813e3
2021-07-12 16:37:19 +02:00
Pau Espin 1086e20754 vlr_sgs: Drop recorded LastEutranPlmnId when UE no longer associated
Change-Id: I0dcb1850ab4f6f7d42bfcb19665ddeae2d3b057a
2021-07-02 21:46:49 +02:00
Pau Espin 8252959b74 sgs: Use available API to set vlr subscr LastUsedEutranPLMNId
This way it's easier to find out where the vlr subscriber field is set.

Change-Id: I203de82accc896c196cb70037af89be6dc826c05
2021-07-01 18:14:39 +02:00
Neels Hofmeyr 73d093a806 improve logging on encryption, for Ciphering and HO
log the algorithm and all keys instead of just Kc.

Change-Id: If7871dedda2b1fb115e6f00da1379ff2e3d68a10
2021-06-24 01:44:20 +02:00
Neels Hofmeyr db07fdcbfc support A5/4 in inter-BSC handover
Forward the Kc128 key to the new BSS in BSSMAP Handover Request.

Depends: Ieb6e43eef9e57281d54d4b7c63664668df5aef3e (libosmocore)
Change-Id: Id5ce995a741c8e469a50a0c46e53c06a2378bb7e
2021-06-24 01:44:17 +02:00
Neels Hofmeyr 6ce2edcac1 support A5/4 in Cipher Mode Command
Related: SYS#5324
Change-Id: I780a739b9bfbefd4f58be051794fe1a491823e67
2021-06-24 01:27:47 +02:00
Eric Wild a7f8020bfa vty: allow A5/4 encryption in config
Add A5/4 to the internal mask of allowed algorithms.

(Not actually working yet, A5/4 implementation follows in other
patches.)

Related: SYS#5324
Change-Id: I5b46aaa8579f8d069ca39caf996a8795ffe63dd7
2021-06-24 01:27:47 +02:00
Neels Hofmeyr cdcfc80176 ran_msg_a.c: use gsm0808_create_cipher2()
Use new API in Cipher Mode Command to prepare for A5/4 support.

Depends: Ib3906085e0c6e5a496a9f755f0f786238a86ca34 (libosmocore)
Related: SYS#5324
Change-Id: Ib238d367b8d5d07b6ab4cb2e48fbf4ce22ca4476
2021-06-23 23:58:59 +02:00
Neels Hofmeyr 07c8b7cb2e osmo-msc main: use osmo_select_shutdown()
Change-Id: I75f4637c051ed44628e65dab1bdbbf28dcc9626f
2021-06-22 23:34:34 +02:00
Vadim Yanitskiy 435f67f43c msc_tx_common_id(): fix potential NULL pointer dereference
Reported by GCC 11.1.0.  msc_a_vsub() may return NULL.

Change-Id: Iebdd6399e819a03258398e6b7b453bda37e45a20
2021-06-06 15:50:42 +02:00
Pau Espin 2e21a68e83 Use new osmo stat items/ctr APIs
Generated using several semantinc patches with spatch.

Change-Id: I3ee853539949a763a309856bf2e7196415b23741
2021-06-04 16:53:16 +02:00
Pau Espin 6710670cb1 Fill Last Used E-UTRAN PLMN Id when in CSFB
Since recently, osmo-bsc behaves strictly as per specs, meaning it will
only send the "Cell selection indicator after release of all TCH and SDCCH IE"
in RR Channel Release iff:
* "Last Used E-UTRAN PLMN Id" was received in the CommonID sent MSC->BSC
* "Last Used E-UTRAN PLMN Id" was received insider "old BSS to new BSS Information"
  in the HandoverRequest sent MSC->BSC.
On the other hand, CSFB_Indicator from ClearCommand MSC->BSC is nw
ignored and not taken into account.

Hence, let's update osmo-msc to also behave correctly by sending the
Last Used E-UTRAN PLMN ID at CommonID tx time to avoid regressions in
CSFB support when running against newer osmo-bsc.

Let's keep sending the CSFB Indicator in ClearCommand as we used too, in
order to keep compatibility with older BSCs (as per spec).

Related: SYS#5337
Change-Id: Ic5f175b179973d0a50d94f00e15f5a3e332605fc
2021-04-29 14:22:33 +02:00
Vadim Yanitskiy a361cab54a SMS-over-GSUP: notify sender if no transaction found
Change-Id: I4f564610fadbfdbbc33de267786534a5405319f6
2021-04-04 14:09:32 +00:00
Vadim Yanitskiy dd466cfa59 fix _gsm48_cc_trans_free(): send MNCC REL.ind on Clear Request
Calling gsm48_cc_tx_release() before mncc_release_ind() has a side
effect: the former may change CC state to GSM_CSTATE_RELEASE_REQ.
This makes the later send MNCC_REL_CNF instead of MNCC_REL_IND, so
if one of the call leg disconnects due to RF failure, the other one
will not be terminated correctly.

Makes both TC_{mo,mt}_call_clear_request TTCN-3 test cases pass.

Change-Id: I3ad4a99757878de3796027325627c87d9a4e93f1
Related: Id16969fe0de04445d1320a96d35cf1d48cc8cf09
Related: SYS#5340
2021-02-09 18:34:40 +01:00
Vadim Yanitskiy 33144f146a ran_a_decode_cipher_mode_reject(): use gsm0808_get_cause()
Change-Id: I56dd920b931e769ba4d268b09700fe3c9fca4fc6
2021-02-05 20:16:52 +01:00
Vadim Yanitskiy 566ce11df5 submit_to_sms(): fix the use of deprecated gsm_septets2octets()
Change-Id: I9985972f0b1d2b71bfd133c5004201a3a0ffcbd0
2021-02-05 20:15:08 +01:00
Pau Espin e917b1983a main: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Change-Id: Iff66eea9ee70850a4d038ece1d8473457023e1ee
Fixes: OS#4865
2020-11-25 18:51:06 +01:00
Harald Welte 4dc5dcf4e0 Use osmo_fd_*_{disable,enable}
Change-Id: I5208124e08d3b403492fe83acee235e61e423450
Depends: libosmocore.git Idb89ba7bc7c129a6304a76900d17f47daf54d17d
2020-11-11 20:14:27 +00:00
Vadim Yanitskiy 33a248724e main: add --vty-ref-mode, use vty_dump_xml_ref_mode()
Change-Id: I66c3521895dd0b9a35e9b75f7766ec8014116246
Depends: Ie2022a7f9e167e5ceacf15350c037dd43768ff40
Related: SYS#4910
2020-10-24 05:25:43 +07:00
Harald Welte aa29e33cb5 Use osmo_fd_setup() whenever applicable
Change-Id: Ib570e2ada619b72001d76d2cae159d78f09d6fb6
2020-10-19 11:38:05 +00:00
Alexander Couzens ae167fcc9a Convert paging response timer into an osmocom own X4 timer
All timeout values should use tdef.

Change-Id: Ic050eb49ba0c5811b43d8d8b44145a1115fd8546
2020-09-26 21:45:09 +02:00
Philipp Maier 9194b33ec1 gsm_04_08: check return code of osmo_mobile_identity_decode_from_l3()
The function gsm48_rx_cm_reest_req() is the only one where the return
code of osmo_mobile_identity_decode_from_l3() is not checked, lets check
it here too.

Change-Id: I37981205870b094b3a40a20197461208daa62698
Fixes: CID#211037
2020-09-25 10:01:36 +00:00
Neels Hofmeyr cbcfe9918b drop duplicate ran_peer_find() vs ran_peer_find_by_addr()
This is the same function existing twice with different names. Keep only one.

Change-Id: If54b54fa61ece0f95564d403e1439fc5f5ededdf
2020-09-25 01:45:08 +02:00
Keith Whyte 192fefe53d Don't Store an SMS in the database when the ESME is not Bound
We may never be able to deliver this SMS if it depends on the ESME, as we will
not resubmit the SMS to the ESME. Better to reject it at this time and have the MS
try again later.

Change-Id: I2c50904349dd4ed229b60b8468d776b817c0bd44
Related: OS#4740
2020-09-22 12:43:14 +00:00
Philipp Maier 8c472bd111 mncc_call: fix memory overrun
The struct gsm_mncc which is created and populated in mncc_call_tx_setup_ind
casted to a union mncc_msg* pointer. This leads to a memory overrun
in mncc_call_tx because the union mncc_msg is larger then the gsm_mncc struct.

To fix this, lets just declare a union mncc_msg and populate the signal
member inside it. This can be handed over to mncc_call_tx. The data in
it will look the same, except that the memory will have the proper
lenght (longer).

Change-Id: Ifff28b3375d6bd5e4f837f25c46736952f7bfa9b
Fixes: CID 214330
2020-09-18 18:08:39 +02:00
Neels Hofmeyr d4099c31c9 fix MGCP timeout timer
Timer X1 is not defined in libosmo-mgcp-client, so this tdef had no effect.
Change this to X2427.
(libosmo-mgcp-client recently moved T2427001 to X2427.)

(X2 is still used in call_leg.c itself)

Related: OS#4539
Related: If097f52701fd81f29bcca1d252f4fb4fca8a04f7 (osmo-mgw)
Change-Id: I9804fdb2c24f49910f2386e3788bd1107b8ebc40
2020-09-18 08:45:38 +00:00
Pau Espin eeda9e123f mncc: Support IPv6 addresses (new version mncc 7)
Change-Id: I6002b648bcb2055dcbbdae3f688f6e2cb7282b7f
2020-09-14 12:41:00 +02:00
Pau Espin 0632717dc1 Support handling IPv6 Transport Address in Handover Request (Ack)
Change-Id: Ie4d07826362d651cd42dc2b4e0af82368a74c774
2020-09-09 13:20:22 +02:00
Pau Espin f9c76e3aa2 Support handling IPv6 Transport Address in Assignment Complete
Change-Id: Ib650bb063404a3068b4cf3c376c6080dc29bebfe
2020-09-08 18:31:25 +02:00
Pau Espin d35abfad72 Support sending IPv6 Transport Address in Assignment Command
Change-Id: Ida43f10a41afbd275233f0ef102287522a2e7099
2020-09-08 18:31:16 +02:00
Keith Whyte 1587ffbc7b vty: allow configuring db path from cfg file
So far, the cmdline argument was the only way to set a database file.
Add a similar config to VTY as 'msc' / 'sms-database'. The cmdline arg is stronger
than the 'database' cfg item. DB is not reloaded from VTY command.

Change-Id: I18d954c30fcceb0b36a620b927fd3a93dcc79f49
2020-08-28 16:25:14 +02:00
Pau Espin c84702c571 Change default SCTP conn NULL->127.0.0.1 to localhost->localhost
"127.0.0.1" is changed to "localhost" to let local NSS decide whether to
use IPv4 or IPv6. In newish systems, IPv6 ::1 will be selected since
IPv6 takes precedence over IPv4.

Similarly, the default source addr needs to be changed from NULL to "localhost"
since for some yet unknwon reason, getaddrinfo(AF_UNSPEC, NULL) returns
first IPv4 "0.0.0.0" and later "::", which is inconsistent with
getaddrinfo("localhost") result, resulting in src=IPv4(0.0.0.0) and
dst=IPv6(::1), which is incompatible and will fail. In any case, since
the default remote address is a local one and it's the client side,
there's no real logical change since the kernel would anyway should have
taken a local address anyway.

Change-Id: I05a5c792ab1d053c6f38ba36d4b9fa6db293fbd0
2020-08-24 07:44:38 +00:00
Vadim Yanitskiy 4d75559dad mncc_builtin: log type of unhandled message in int_mncc_recv()
Change-Id: Ie65b2da4c3a13ac36132a2f8c9c85cc420c7a5a6
2020-08-24 07:35:45 +00:00
Vadim Yanitskiy 880a69391d mncc_builtin: cosmetic: fix coding style in int_mncc_recv()
Change-Id: Iffef3c094a5d030663d312a379e846a8eb917942
2020-08-24 07:35:45 +00:00
Neels Hofmeyr 667d5e0b95 fix crash for unknown MI during Paging Response
Related: OS#4724
Related: I40496bbccbbd9c496cfa57df49e26f124a2b1554 (osmo-ttcn3-hacks)
Change-Id: Ia2c8fa745cfab17ed7114d433f625ddc02ae7b11
2020-08-24 07:34:27 +00:00
Pau Espin 24a885608d Support setting rt-prio and cpu-affinity mask through VTY
Change-Id: I40cf8a86961c1e350b5cd74d6e2cf64a22b7a2b1
Depends: libosmocore.git Change-Id If76a4bd2cc7b3c7adf5d84790a944d78be70e10a
Depends: osmo-gsm-masnuals.git Change-Id Icd75769ef630c3fa985fc5e2154d5521689cdd3c
Related: SYS#4986
2020-08-20 08:44:20 +00:00
Harald Welte 544a32f271 Send "BSSMAP CommonID" to tell BSC about the IMSI
We're already sending the RANAP CommonID message to the RNC,
let's do the same using BSSMAP CommonId towards the BSC.  This
way the BSC knows about the IMSI of the served subscriber, which
is very useful for logging/debugging.

Change-Id: I2552736477663adb250c55728093500e8ae83ebb
Closes: OS#2969
Depends: libosmocore.git I353adc1aa72377f7d4b3336d2ff47791fb73d62c
2020-08-17 11:17:41 +00:00
Vadim Yanitskiy 817ad9054e vty: fix vsub reference counting: call vlr_subscr_put()
Otherwise, each time the 3GPP TS 44.014 MS test commands (TCH loop)
are invoked, both subscriber_mstest_{close,open} functions add +1
to the subscriber's reference count, but never revoke it.

Change-Id: I0cefa5b5a0cb712080ba2afd322db329f19608e3
2020-07-29 05:57:27 +07:00
Vadim Yanitskiy 72e0f09c03 gsm_04_14: fix off-by-one error in create_gsm0414_msg()
This byte is redundant, and must not be allocated in this function.
A consequence of this error is that the MS alwats interprets the
"Sub-channel" IE as test loop A regardless of the specified type.

Here is an example of malformed Close TCH loop (type C) message:

  0f 00 00 04
  x. .. .. ..  - Skip indicator (see 3GPP TS 24.007)
  .x .. .. ..  - Protocol discriminator (see 3GPP TS 24.007)
  .. xx .. ..  - Message type (CLOSE_TCH_LOOP_CMD)
  .. .. !! ..  - (!) Redundant byte from create_gsm0414_msg()
  .. .. .. xx  - (!) The actual "Sub-channel" IE (loop C, X=0)

Change-Id: Ia47225b884439dcd43be307e7351994e55fcd50d
2020-07-29 05:28:54 +07:00
Neels Hofmeyr d9fe7110ea Clear Command: set cause value to "Call Control"
So far, by failing to initialize the cause value, we always send a Clear
Command cause == 0, which actually means "Radio Interface Message Failure".
This is seen in all my logged network traces of osmo-msc lab testing.

"Call Control" seems to be the only cause value that remotely fits a normal
release procedure, even if it was not voice call related, see 3GPP TS 48.008
3.2.1.21.

Related: OS#4664
Change-Id: I1347ed72ae7d7ea73a557b866e764819c5ef8c42
2020-07-28 18:29:58 +02:00
Neels Hofmeyr 59de15614d is_reset_msg: use proper enum for rc value
Change-Id: I88b6204bc3ffac06f92bfc87639ce503b2da24bc
2020-07-09 01:20:19 +02:00
Neels Hofmeyr 5b36d13ba5 sgs_tx_loc_upd_resp_cb(): fix error handling for MI encoding
new_id_ptr should be passed as NULL if encoding the TMSI failed, so initialize
it accordingly.

Also add some bloat to better handle the case of an encoding error, even though
from code analysis that should not be possible here: there is enough buffer,
the MI is a TMSI encoded from a uint32_t...

The problem was introduced by Idfc8e576e10756aeaacf5569f6178068313eb7ea, before
which new_id_len was always 0 when no TMSI was present.

Related: CID#210894
Change-Id: I800c5dca3fdbdedf70a64d9fd5a1bdfd1397f431
2020-07-01 23:33:16 +02:00
Neels Hofmeyr b697274daa refactor: move RESET Osmux TLV parsing to ran_msg_a.c
ran_peer.c is not the proper place to parse messages, because it should be RAN
agnostic. All parsing and encoding belongs in ran_msg_a.c and ran_msg_iu.c.

Move the Osmux TLV parsing into the is_reset_msg op: add supports_osmux
out-parameter (and add a logging fi pointer). To be able to modify msg->l3h,
also make the msgb arg non-const.

In ranap_is_reset_msg(), always return non-support for Osmux.

In bssmap_is_reset_msg(), return 0 if no TLVs were parsed, 1/-1 if an Osmux TLV
was present/not present.

Update the osmux support flag directly where the ConnectionLess message is
received, so that there is only one place responsible for that.

Related: OS#4595
Change-Id: I1ad4a3f9356216dd4bf8c48fba29fd23438810a7
2020-07-01 23:33:16 +02:00
Neels Hofmeyr 83cf10c8a6 propagate Compl L3 Info Cell ID to the VLR subscriber record
As soon as the subscriber is authenticated, update the VLR entry with the
MSC-A's full CGI, including the Cell Id received from the Complete Layer 3
Information.

Thus the Cell Id will be shown by vty 'show subscriber cache' and 'show
connection'.

This is tested by osmo-ttcn3-hacks Ie410714a96353f74a52a104c56fa0a08683e0004.

Related: OS#4627
Change-Id: Iee1781985fb25b21ce27526c6a3768bf70d4dc9a
2020-06-24 19:22:30 +02:00
Neels Hofmeyr 41c0333730 vty 'show connection': show msc_a->via_cell instead of vsub->cgi
For 'show subscriber cache', we print vsub->cgi. For 'show connection', it
makes more sense to print msc_a->via_cell.

This is tested by osmo-ttcn3-hacks Ie410714a96353f74a52a104c56fa0a08683e0004.

Related: OS#4627
Change-Id: I194271af2acb37b4f8cc2d106ab2fd2b0d443589
2020-06-24 19:21:40 +02:00
Neels Hofmeyr 68f50dad76 add comments to clarify some complete l3 details
Change-Id: I6e289900d38d97c346d615b71d36656254e6f2b5
2020-06-24 14:22:52 +02:00
Neels Hofmeyr a509a22b9e add osmo-msc --vty-ref-xml: dump VTY ref XML to stdout
Add only a long option to not clutter the cmdline namespace.

To add a long option without a short letter is slightly complex: use the 'flag'
and 'val' mechanism as in 'man 3 getopt' to write an option index to
long_option.

Make sure that all VTY commands have been added before parsing cmdline options:
move various VTY init further above. For msc_vty_init(), the global msc_network
already needs to be allocated, so also move that.

Depends: Ic74bbdb6dc5ea05f03c791cc70184861e39cd492 (libosmocore)
Change-Id: I9146d5a44427509265420f52ae6540ad93eb14fc
2020-06-23 12:39:29 +00:00
Philipp Maier 7da956e4c6 msc_ho: fix CALL IDENTIFIER in HANDOVER REQUEST
When msc_ho_send_handover_request() generates the HANDOVER REQUEST
message, it does not populate the call_id struct member.

In ran_msg_a.c the struct member call_id is used, but the
call_id_present flag is not set, which also prevents the call_id being
added to the message

Change-Id: I6b1b55b3f5a3092d9557dc2512020c766a9ff744
Related: OS#4582
2020-06-22 16:00:04 +00:00
Philipp Maier f34d945f4f msc_a: add callref as call id to ASSIGNMENT REQ.
The BSSMAP message ASSIGNMENT REQUEST may contain an optional CALL
IDENTIFIER IE. While this IE is optional some BSC implementions may
require it.

Change-Id: I4288f47e4a6d61ec672f431723f6e72c7c6b0799
Related: OS#4582
2020-06-22 16:00:04 +00:00
Harald Welte 53a5ff7da9 remove empty + unused ran_up_l2.c
Change-Id: I5a0fa6a78dd8f32912afc69f4b154caad44a9e78
2020-06-22 14:22:22 +02:00
Neels Hofmeyr 9aac5c2d21 add rudimentary NRI support for MSC pooling
This patch served for a manual testing counterpart for osmo-bsc to implement
MSC pooling.

This enables a basic MSC pooling setup, but for a production setup, osmo-msc
would still lack various features related to unloading subscribers to another
MSC as explained in 3GPP TS 23.236.

Change-Id: Iafe0878a0a2c8669080d757b34a398ea75fced36
2020-06-19 03:58:13 +02:00
Neels Hofmeyr 46d526a3df use new osmo_mobile_identity API everywhere
Depends: Ic3f969e739654c1e8c387aedeeba5cce07fe2307 (libosmocore)
Change-Id: Idfc8e576e10756aeaacf5569f6178068313eb7ea
2020-06-19 03:58:13 +02:00
Philipp Maier 20a6641a3f msc_vty: remove emergency-call command from network
when the VTY write the config file ist prints the configuration line
for emergency-call in network and in msc, however the presence of the
configuration line in network leads to a parsing error on msc startup.
The vty command probably got moved to node msc and it was forgotten
to remove the printing from network.

Change-Id: I4f3dac27723e7852f8f049fcfca5cccdc027734d
Related: OS#4548
2020-06-18 11:55:52 +00:00
Neels Hofmeyr a40adf78c3 vlr_subscr_rx_id_resp(): dont assert on received MI type
The Mobile Identity type is received on the wire, we asserting on its type
constitutes a DoS vector.

Change-Id: I2b2e25ef8e878e91a165018ba49f1609cfb5cbd0
2020-06-03 15:40:39 +00:00
Pau Espin 3694631c1a ran_msg_iu.c: Avoid redefining osmo-iuh global variables
From ASAn on gcc 10.1.0:
+=================================================================
+==269368==ERROR: AddressSanitizer: odr-violation (0x559114a5b880):
+  [1] size=4 'asn1_xer_print' /git/osmo-msc/src/libmsc/ran_msg_iu.c:50:5
+  [2] size=4 'asn1_xer_print' /git/osmo-iuh/src/iu_client.c:85:5
+These globals were registered at these points:
+  [1]:
+    #0 0x7f6208d3869a in __asan_register_globals /build/gcc/src/gcc/libsanitizer/asan/asan_globals.cpp:341
+    #1 0x55911456d221 in _sub_I_00099_1 (/build/new/tmpdir/osmo-msc/tests/msc_vlr/msc_vlr_test_hlr_timeout+0x48d221)
+    #2 0x5591145e8e9c in __libc_csu_init (/build/new/tmpdir/osmo-msc/tests/msc_vlr/msc_vlr_test_hlr_timeout+0x508e9c)
+
+  [2]:
+    #0 0x7f6208d3869a in __asan_register_globals /build/gcc/src/gcc/libsanitizer/asan/asan_globals.cpp:341
+    #1 0x7f6207d8db91 in _sub_I_00099_1 (/build/new/out/lib/libosmo-ranap.so.3+0x47db91)
+    #2 0x7f62096eb0f1 in call_init.part.0 (/lib64/ld-linux-x86-64.so.2+0x110f1)
+
+==269368==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
+SUMMARY: AddressSanitizer: odr-violation: global 'asn1_xer_print' at /git/osmo-msc/src/libmsc/ran_msg_iu.c:50:5
+==269368==ABORTING

Related: OS#4556
Change-Id: I702e9748eaaf2279c3764ba67f80f00ae9f2526f
2020-05-19 20:32:18 +00:00
Pau Espin c95c0b6dd6 Use OSMO_FD_* instead of deprecated BSC_FD_*
New define is available since libosmocore 1.1.0, and we already require
1.3.0, so no need to update dependenices.
Let's change it to avoid people re-using old BSC_FD_* symbols when
copy-pasting somewhere else.

Change-Id: Ifc89fffac0443d94f3e49555684975b293ef90fb
2020-05-09 19:18:40 +02:00
Vadim Yanitskiy 3c8fc13b39 SMS-over-GSUP: notify sender in case of RPL delivery failure
Change-Id: I8436601c4314395e28829960dc753778c37b1125
2020-04-26 23:55:48 +07:00
Vadim Yanitskiy 4547cf1c99 SMS-over-GSUP: notify sender about malformed GSUP messages
Change-Id: I27f00e69ff045cbf641ef21adf44fcd55cb8f889
2020-04-26 23:55:48 +07:00
Vadim Yanitskiy b1e46b17f7 SMS-over-GSUP: notify sender about unhandled GSUP messages
Change-Id: I7970349bd9d5c56a64c409e619e8b581682fef0b
2020-04-26 23:55:48 +07:00
Vadim Yanitskiy b6ec0999f0 SMS-over-GSUP: respond with error if net->sms_over_gsup is false
Change-Id: If14f8a394e691f86e0acbffb283c3862fe62ffd2
2020-04-26 23:55:48 +07:00
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