Commit Graph

1488 Commits

Author SHA1 Message Date
Oliver Smith c7c40c9648 codec_filter_set_ran: prepare for CSD
Related: OS#4394
Change-Id: I467a7bd461dcac2fff93a3777d4090d6b7d3d041
2023-06-15 15:06:46 +02:00
Oliver Smith a35abb761c codec_filter_init: prepare for CSD
Related: OS#4394
Change-Id: I1270b00464456abc5300fd47e6087a0ba6243d03
2023-06-15 15:06:46 +02:00
Oliver Smith 0b70b20a89 Cosmetic: gsm48_cc_tx_setup: remove TODO comment
Remove the comment as trans->bearer_cap will be used in CSD code to
differentiate between speech and data.

Related: OS#4394
Change-Id: I0539632f464bc44945599bec52dc2a4df2f0115f
2023-06-15 15:03:55 +02:00
Oliver Smith e545b9d3d6 Cosmetic: gsm48_cc_tx_setup: tweak comment
Remove the misleading "We must not pass bearer_cap to
codec_filter_init()" part of the comment. The function doesn't accept a
bearer_cap parameter, it cannot be passed to the function:

  void codec_filter_init(struct codec_filter *codec_filter)
  {
  	*codec_filter = (struct codec_filter){};
  }

Related: OS#4394
Change-Id: I87a1e371e108d8da514b30f1726aad0f85ea4111
2023-06-15 14:25:24 +02:00
Oliver Smith 5375f78ebb codec_filter_set_ms_from_bc: prepare for CSD
In all the places where codec_filter_ functions get called, for CSD we
will need to filter the bearer services. Add a new
transaction_cc.c file for functions that either combine the
codec_filter_ function with logic for CSD and voice calls or just call
the existing codec_filter function and a new csd_filter function.

Start with moving codec_filter_set_ms_from_bc to this new file, it will
be extended with a case for CSD in a future patch.

Related: OS#4394
Change-Id: If225f2a299ce6bc9ae35a17d6f591d889f49155e
2023-06-15 14:25:24 +02:00
Oliver Smith b1a1588f6e ran_a_channel_type_to_speech_codec_list: add CSD
Related: OS#4394
Change-Id: I336e6aa735f894aa35b2ccfe24a54eb171d7ad10
2023-06-15 10:29:29 +02:00
Oliver Smith b4b9ec805a codec_mapping: add clearmode
Related: OS#4394
Change-Id: Ieeaca6a00dc332424d443e44251f3219245511db
2023-06-15 10:29:29 +02:00
Pau Espin 9e3bab9e97 Use new mgcp_client_conf_alloc() API to alloc mgcp_client_conf
Depends: osmo-mgw.git Change-Id Iba0853ed099a32cf1dde78c17e1b34343db41cfc
Change-Id: I382046bba67646a7365d9290d604b97c9d886e02
2023-06-14 14:09:11 +02:00
Vadim Yanitskiy 999a593efb copyright: fix typo: sysmocom s/s.m.f.c./s.f.m.c./ GmbH
Change-Id: I81687235fedcbbb686db7def59318e891e00ced7
2023-05-18 17:22:26 +07:00
Neels Hofmeyr 388d7c9374 3G: decapsulate IuUP to AMR at the MGW; allow 3G<-AMR->2G
For all 3G calls, convert IuUP <-> plain AMR/RTP on the MSC's MGW hop
like this:

Before this patch:

 hNodeB <--IuUP--> MGW@hnbgw <--IuUP--> MGW@msc <--IuUP--> other call leg

After this patch:

 hNodeB <--IuUP--> MGW@hnbgw <--IuUP--> MGW@msc <--AMR--> other call leg
                                                    ^

This allows, in principle, 2G to 3G calls without expensive transcoding,
like this:

 hNodeB <--IuUP--> MGW@hnbgw <--IuUP--> MGW@msc <--AMR--> MGW@msc <--AMR--> MGW@bsc <--AMR--> 2G-BTS
                                                    ^
(So far only proven to work with AMR-FR at 12k2.)

3G to 3G calls now look like this:

 hNodeB <--IuUP--> MGW@hnbgw <--IuUP--> MGW@MSC <--AMR--> MGW@MSC <--IuUP--> MGW@hnbgw <--IuUP--> hNodeB
                                                    ^

Implementatino: get rid of the shim that was put in place to still send
IuUP (VND.3GPP.IUFP) to the CN. So now, for all 3G voice, the IuUP gets
decapsulated to plain AMR/RTP at the MSC's MGW hop.

What is proven to work with this patch:
successful voice call between 2G and 3G with these conditions:
- a hNodeB that stubbornly accepts only 12k2 AMR;
- a 2G BTS configured to use only TCH/F and only FR3, with only 12k2 as
  allowed AMR rate.

We have not yet seen a call working for TCH/H HR3 <-> 3G, because of the
lab hNodeB's limitation to 12k2.

Future work we probably need:
- properly request and negotiate AMR rates via SDP fmtp:mode-set.
- request more RFCIs in our RANAP RAB Assignment requests
  (see I61e0e9e75e3239662846fd797532acdefa9f73dc).
- Convert IuUP to AMR already at the HNBGW's MGW?
Solving this is not part of this patch.

Related: SYS#5092
Change-Id: I386a6a426c318040b019ab5541689c67e94672a1
2023-04-05 13:47:46 +00:00
Oliver Smith 40d3c793ce msc_main: close SMS db on startup error
When the SMS sqlite db is opened and not closed properly, sqlite will
print a trace on the next OsmoMSC startup while restoring the database.
This happens when e.g. attempting to bind OsmoMSC on an IP that is not
available (yet) and then restarting OsmoMSC.

db.c:521 Init database connection to 'sms.db' using SQLite3 lib version 3.34.1
db.c:318 SQLITE3: (283) recovered 37 frames from WAL file /var/lib/osmocom/sms.db-wal
backtrace.c:42 backtrace() returned 22 addresses
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(+0x36a56) [0x7f1518c00a56]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(sqlite3_log+0x9e) [0x7f1518c00b3e]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(+0x5f4f4) [0x7f1518c294f4]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(+0x5fbb3) [0x7f1518c29bb3]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(+0x7ee02) [0x7f1518c48e02]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(+0x7f908) [0x7f1518c49908]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(+0xb9a5f) [0x7f1518c83a5f]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(+0xcddac) [0x7f1518c97dac]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(+0xcddef) [0x7f1518c97def]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(+0xf537d) [0x7f1518cbf37d]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(+0xb479e) [0x7f1518c7e79e]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(+0xb79b6) [0x7f1518c819b6]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(+0xb8116) [0x7f1518c82116]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(+0xb853f) [0x7f1518c8253f]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(sqlite3_prepare_v2+0x16) [0x7f1518c826a6]
backtrace.c:53         /lib/x86_64-linux-gnu/libsqlite3.so.0(sqlite3_exec+0xb4) [0x7f1518c8fce4]
backtrace.c:53         /usr/bin/osmo-msc(+0x1bf13) [0x564f81946f13]
backtrace.c:53         /usr/bin/osmo-msc(+0x524c0) [0x564f8197d4c0]
backtrace.c:53         /usr/bin/osmo-msc(+0x1324e) [0x564f8193e24e]
backtrace.c:53         /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xea) [0x7f1518991d0a]
backtrace.c:53         /usr/bin/osmo-msc(+0x13fea) [0x564f8193efea]

Related: SYS#6360
Change-Id: I9bb799048db5fcdb2a2520107bd75d5f7a865459
2023-04-05 11:26:55 +02:00
Oliver Smith 30cfe7174a msc_mgw_setup: use mgcp_client_pool_empty()
Don't fall back to the legacy config if the pool is configured but no
connection to any pool member can be established.

Depends: osmo-mgw I009483ac9dfd6627e414f14d43b89f40ea4644db
Related: OS#5993
Change-Id: I44e7b2723d801ceb03aaa2e5546802b4eb56b3c3
2023-04-04 16:08:52 +00:00
Neels Hofmeyr b091d2138d HO Req: include IE Codec List (MSC Preferred)
This will make the 10 inter-MSC HO tests in MSC_Tests.ttcn pass again.

Related: OS#5529
Change-Id: Ifcf719c5fc9e11749aafbd97bafda7f6f50973ea
2023-03-18 03:05:34 +01:00
Neels Hofmeyr b6c11c43bb codecs: compose HO Req Ch Type from cc.codecs
Change-Id: Iba7a1a87ec5e6b487f763e84d60ed285da7b8fe1
2023-03-18 03:05:34 +01:00
Neels Hofmeyr 1c0650767a mncc_recvmsg(): log caller file,line
Change-Id: I3755eb35b504f2f2580e0ba43dfa41f16087decc
2023-03-18 03:05:34 +01:00
Neels Hofmeyr bd5f8e900b do CN CRCX first
In order to send the MSC's RTP endpoint IP address+port in the initial
SDP, move the MGCP CRCX up to an earlier point in the sequence of
establishing a voice call.

Update the voice call sequence chart to show the effects.

Though the semantic change is rather simple, the patch is rather huge --
things have to happen in a different order, and async waits have to
happen at different times.

The new codec filter helps to carry codec resolution information across
the newly arranged code paths.

Related: SYS#5066
Change-Id: Ie433db1ba0c46d4b97538a969233c155cefac21c
2023-03-18 03:05:34 +01:00
Neels Hofmeyr 11a746acd3 [codecs filter] use codecs filter on crcx ok
Change-Id: I03753df567d1dc24852e6fbb681fbba81d2a545d
2023-03-18 03:05:34 +01:00
Neels Hofmeyr 8dd1646f0b [codecs filter] send + receive SDP via MNCC
Transmit and receive full SDP information via MNCC, to accurately pass
codecs choices between the call legs.

In msc_vlr_test_call.c test_call_mt(), show that when receiving MNCC,
the codec information in SDP overrules the Bearer Cap codec information
-- we expect to still receive inaccurate Bearer Cap from e.g.
osmo-sip-connector, because we have chosen to add SDP to MNCC instead of
trying to fix the codecs represented in Bearer Cap.

For internal MNCC, the MT call leg now knows which codec the MO has
chosen and assigned.

For external MNCC, osmo-sip-connector receives SDP about our codecs
choices and sends it in SIP messages, and we also receive the full SDP
information from the remote SIP leg.

Update the SDP in codec_filter every time it is received, to always have
the latest SDP information from the remote leg.

 CC              MNCC
 | ---ALERTING--> |     add local side SDP to MNCC msg
 | <--ALERTING--- |     store remote side SDP
 | <--SETUP-RESP- |     store remote side SDP
 | --SETUP-CNF--> |     add local side SDP to MNCC msg
 | -RTP-CREATE--> |     use codec_filter, add local side SDP to MNCC msg
 | <-RTP-CONNECT- |     store remote side SDP

There still is one problem: when initiating MNCC, we do not yet know the
RTP address and port to be used for the CN side, because the CN CRCX
happens later. So far we send 0.0.0.0:0 as RTP endpoint in the SDP,
until the CN CRCX is done. A subsequent patch moves CN CRCX to an
earlier time, adding proper RTP information right from the start.

Related: SYS#5066
Change-Id: Ie0668c0e079ec69da1532b52d00621efe114fc2c
2023-03-18 03:05:34 +01:00
Neels Hofmeyr 006b0ee50a [codecs filter] use filter result in Assignment
So far, patches have set up rtp_stream to allow setting multiple codecs,
and collected the codecs information into the codecs filter struct.
Now actually use the codecs filter result to choose a codec.

Setting up the call leg FSMs and codecs still looks rather confusing in
this patch, because this is an incremental step in a larger series. The
upcoming patch 'do CN CRCX first' clarifies this substantially.

The resulting codecs behavior is tested in upcoming patch
I879ec61f523ad4ffc69a0b02810591f7c0261ff9. (The test ideally should have
come before this patch, but my time to rework this branch is up.)

With the codecs filter in place, we are ready for sending and receiving
full SDP via MNCC, see upcoming Ie0668c0e079ec69da1532b52d00621efe114fc2c
and Ie433db1ba0c46d4b97538a969233c155cefac21c

Related: SYS#5066
Change-Id: I66e7c8c5e401f4f3a7d3d42b9525b2c6e99691d9
2023-03-18 03:05:34 +01:00
Neels Hofmeyr 909ea5218c [codecs filter] use filter result in MT DTAP CC Setup
So far, we just forwarded the Bearer Capabilities received in MNCC from
the remote MO call leg, and omitted Bearer Cap if the remote call leg
did not provide any.

Instead, always include Bearer Cap, and compose it from the codecs
filter result. Hence the Bearer Cap is now an intersection of MS, BSS
and remote call leg, instead of just the remote call leg.

Related: SYS#5066
Change-Id: I9586221ef56352b7ce4b2604ae0dc04554145a78
2023-03-18 03:05:34 +01:00
Neels Hofmeyr 7934e0d974 in ran_msg, return gsm0808_speech_codec (inter-MSC)
Get rid of enum mgcp_codecs in inter-MSC handover related code.

Change-Id: I9c649f98738a55b8637ae600d5cdf81099fd08e5
2023-03-18 03:05:34 +01:00
Neels Hofmeyr cec51b340e in ran_msg, return gsm0808_speech_codec (intra-MSC)
Do not convert to enum mgcp_codecs, but directly pass the
gsm0808_speech_codec IE from the A interface to codecs handling.

For Iu:
- RAN side: use ran_infra.force_mgw_codecs_to_ran to keep the MGW
  endpoint towards RAN on IUFP.
- CN side: introduce flag ran_msg.assignment_complete.codec_with_iuup,
  so to decide whether to forward IUFP towards CN, we don't need to test
  the RAN type, but use the flag from the ran_msg implementation.

In msc_vlr_tests, use the SDP codec string instead of enum
mgcp_codecs.

So far limit to intra-MSC related messaging, adjusting inter-MSC
handover follows in a separate patch.

Change-Id: Ia666cb697fbd140d7239089628faed93860ce671
2023-03-18 03:05:34 +01:00
Neels Hofmeyr 62bfa37eae rtp_stream: allow multiple codecs / use codec filter from Assignment
Allow configuring MGW conns with multiple codecs. The new codecs filter
can have multiple results, and MGCP can configure multiple codecs. Get
rid of this bottleneck, that so far limits to a single codec to MGW.

On Assignment Complete, set codec_filter.assignment to the assigned
codec, and use that to set the resulting codec (possibly multiple codecs
in the future) to create the CN side MGW endpoint.

Related: SYS#5066
Change-Id: If9c67b298b30f893ec661f84c9fc622ad01b5ee5
2023-03-18 03:05:34 +01:00
Neels Hofmeyr 1dc3961a0a add ran_infra.force_mgw_codecs_to_ran
Indicate in the ran_infra data structure whether a RAN needs specific
codecs to be set up on the RAN facing MGW endpoint.

This allows setting forced RAN codecs as first-class citizen in the
ran_infra data structure, instead of special cases in the code (for IuUP
on IuCS).

Will be used in subsequent commit
I37f65c36af2679ecba1040a11a9aa0eb9481d817, submitted separately for
easier readability.

Change-Id: I37f65c36af2679ecba1040a11a9aa0eb9481d817
2023-03-18 03:05:34 +01:00
Pau Espin c0f9474045 rtp_stream: Fix remote_osmux_cid_sent_to_mgw never set to true
Change-Id: I978c78976470a6c5a36da8611a203f96c9a1b2a5
2023-03-15 13:01:04 +01:00
Pau Espin a202cf43c7 rtp_stream: Update id after modifying fields upon Tx of MGCP msg
Change-Id: Ifbcab2d07df96d2a826e8235306b18df9573802c
2023-03-15 12:53:43 +01:00
Neels Hofmeyr 2d57d6eaa9 [codecs filter] apply BSS codecs from Assignment Complete
Codec List (BSS Supported) is received once in Complete Layer 3 and
again in Assignment Complete messages. Use the most recent one, i.e. the
one from Assignment Complete, when it occurs.

Related: SYS#5066
Change-Id: I5e66ecc7987fa926f39d8be8eaf5799b931ab20a
2023-03-14 22:41:52 +00:00
Neels Hofmeyr 10357f801b [codecs filter] MT call: store MS Bearer Cap from CC Call Conf
Related: SYS#5066
Change-Id: Ic3d0f05af57a493d500700c63b121c8114e7fbf4
2023-03-14 22:41:52 +00:00
Neels Hofmeyr af9d30eff5 [codecs filter] MT call: apply remote call leg codecs
Collect either the SDP or the Bearer Capabilites in the incoming
MNCC in the new codecs filter.

So far just collect the info and do not change the behavior, using the
filter result will follow in a subsequent patch.

Related: SYS#5066
Change-Id: I84d9bbca3e4061da622b1b2fc0bde8868e7e3521
2023-03-14 22:41:52 +00:00
Neels Hofmeyr 7ddc48c197 [codecs filter] MT call: apply BSS codec list
For MT call, initialize the codecs filter and apply the
Codec List (BSS Supported) from Compl L3.

Related: SYS#5066
Change-Id: I530409a64d11da48518a3dc60aa3a4e47c384663
2023-03-14 22:41:52 +00:00
Neels Hofmeyr f55595270f [codecs filter] MO call: apply BSS codec list
Related: SYS#5066
Change-Id: I062268406ae3f3a63a7f413db51c509c9eaf9e8a
2023-03-14 22:41:52 +00:00
Neels Hofmeyr e276ae9bc7 [codecs filter] store BSS codec list from Compl L3
The initial Compl L3 happens long before we establish a CC transaction.
Remember the Codec List (BSS Supported), so that we can feed the new
codecs filter with it. Subsequent patches implement feeding the filter.

Related: SYS#5066
Change-Id: I7cdc348218433141a43d2e42750af02591688240
2023-03-14 22:41:52 +00:00
Neels Hofmeyr 63881a3735 [codecs filter] add codec_filter.h,c
Add the infrastructure to store and filter all codec limitiations from
the different stages: MS, BSS, CN and remote call leg. Upcoming patches
will properly collect these and find an optimal codec.

No functional change, yet.

Related: SYS#5066
Change-Id: I4d90f7ca62f2307a7b93dd164aeecbf4bd98ff0a
2023-03-14 22:41:52 +00:00
Neels Hofmeyr a001a70048 MNCC: use codec_mapping, drop mgcp_codec_to_mncc_payload_msg_type()
Change-Id: I8995ef43b9f79bc1db5672362c6433e4d96dd9e0
2023-03-14 22:41:52 +00:00
Neels Hofmeyr b2ce74829a add codec_mapping.h,c
Converting between different codec representations is confusing. This
codec mapping provides a consolidated overview of all our codec
representations, and how they match up.

In particular, it adds the SDP codec representation repertoire,
preparing the use of full SDP on the MNCC interface.

Related: SYS#5066
Change-Id: Iaa307be6a8487aa8d4ba7cd59d5c5ef04818a744
2023-03-14 22:41:52 +00:00
Pau Espin c43b01e918 mncc_sock: Call osmo_fd_unregister() before closing and changing bfd->fd
Change-Id: I90f840da4cc26c1d970c3f5d18d3185678a1dba9
2023-03-14 11:44:40 +01:00
Vadim Yanitskiy 1866cd93aa src/Makefile.am: remove unneeded AM_LDFLAGS with LIBS
Change-Id: I7895f037925e0e29f52e01636a0ba157cc324e5d
2023-03-11 04:48:19 +07:00
Neels Hofmeyr 58f408839c tweak MNCC logging, add RTP info
Omit "in state FOO", because LOG_TRANS() already logs the state.

Most MNCC "rx" logging was duplicated. Log "rx" only once.

If there is RTP information passed with the MNCC message, log it:
- if there is SDP, log the SDP information.
- if there is no SDP, log the legacy MNCC RTP fields, if any.

One motivation to do this is to get RTP information in ladder diagrams
generated by msc_log_to_ladder.py without the need to add udtrace MNCC
logging to osmo-msc; and also to get RTP info for internal MNCC, where
udtrace doesn't apply, because no unix domain socket is involved in
internal MNCC operation.

Change-Id: I4b916cb482ed441b508c6295de211a21c49cd5c1
2023-03-09 01:49:14 +01:00
Neels Hofmeyr a818153967 IuCS: remove IuUP LOOPBACK hack
Since osmo-mgw now supports IuUP properly, and since we indicate IUFP in
the MGCP CRCX towars an IuCS RAN [1], we should no longer place the MGW
endpoint in loopback mode to hack up an IuUP Initialization.

This hack should have been removed along with [1].

[1] IUFP sent to MGW since this commit:
commit 3a02d29804
Refs: 1.8.0-13-g3a02d2980
Announce IuFP audio codec for UTRAN conns in CRCX towards MGW
I7aca671e00ed27ac03f0d106b5a6b665a9bed4c1

Change-Id: I6446c64421e3e13e2b829293d031c98b99cd39a7
2023-03-04 03:58:30 +01:00
Neels Hofmeyr ede9083946 comment: clarify L3 Info processing
Related: SYS#5066
Change-Id: Ia9180eeb88b31a2cf7dea72b43affd0c7b239ccb
2023-03-04 03:58:30 +01:00
Neels Hofmeyr 8ff00e775c sdp_msg.c: fix missing rate in sdp_audio_codecs_add()
When a new entry is is added by sdp_audio_codecs_add(), also add the
proper rate.

Change-Id: I17ad8862f662975e2df72a332eb83df7fb048cad
2023-03-04 03:57:02 +01:00
arehbein ed606b4271 Transition to use of 'telnet_init_default'
Related: OS#5809
Change-Id: Icc57c68337d55c6594c1c36e9bf41624d11dab0a
2023-02-25 17:48:58 +01:00
Vadim Yanitskiy 1289c7b1bc fix msc_vty_go_parent(): add missing case for MGW_NODE
A new VTY node was added in commit [1], but bsc_vty_go_parent() was
not updated.  Because of that, commands following the MGW node may
crash osmo-msc.  See related patch [2] for more details.

Change-Id: I2422fa9152ecc8c4be1f2487ee016c3fe737e653
Fixes: [1] b44cf2d575
Related: [2] osmo-bsc.git Id3050ff7e2402c33ee76c7bf0cc83603c0cc6dfc
2023-02-05 04:21:31 +07:00
Vadim Yanitskiy 603e1fc925 msc_main: fix wrong comment: HLR is a separate project
Change-Id: I68806e2b44239a5d30126938d065500078c123e2
2023-02-05 04:13:52 +07:00
Keith Whyte 404fb1b60e LCLS: Fix Global Call Reference generation
According to 3gpp spec the Call Reference part of GCR is 5 octets,
3 octets Call ID followed by 2 octets BSS ID.

We are using our internal call reference (4 octets) and the
location area code, or optionally Cell ID as BSS ID
(2 octets). Obviously it does not fit.

Let's use only 3 octets from the call reference, dropping the MSB.

Includes code by Vadim Yanitskiy <vyanitskiy@sysmocom.de>

Change-Id: I9c33a89c819e8925d89ca833d7705ed5ced6b566
2023-02-01 03:08:37 +01:00
Max 7d28d23469 SMPP: use proper type for boolean variables
Related: OS#5568
Change-Id: I033a2c863213a44f99827ef997f541a7a77f5d8a
2023-01-17 09:15:54 +00:00
Neels Hofmeyr 91c9c2f7aa rtp_stream: set_remote_addr: do nothing when unchanged
Change-Id: I15181d84f3eb8a4ab9077cf12fcb138d51733102
2023-01-03 00:31:38 +01:00
Neels Hofmeyr a899dea9aa rtp_stream_commit: check missing MGW ep only when ready for RTP
Change-Id: I24a81a926b97c9f0fb31df782d1cf931eaff9db1
2023-01-03 00:31:38 +01:00
Neels Hofmeyr 5b1f9a2d0c fix sdp_msg_to_sdp_str(), never add fmtp for unset codec
Change-Id: I1892efd9360585f98419ebbd0df180f7f3a8160d
2023-01-03 00:31:38 +01:00
Neels Hofmeyr 01431080a3 sdp_msg.c: parse send/recv mode
Related: SYS#5066
Change-Id: I529c0bfad1cab376e26173ed48db2767c7dfaa64
2022-12-23 14:54:26 +00:00
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