Compare commits

...

708 Commits

Author SHA1 Message Date
Oliver Smith 46f1069220 debian/postinst: add checks, be verbose
Do not attempt to change permissions/ownership if the package gets
upgraded from a version higher than the next release.

Do not fail if the user deleted the config file.

Be verbose when changing permissions.

Related: OS#4107
Change-Id: I2b01a7625cf66fbb7d203f939ddcc1cbab43cf33
2024-05-14 15:21:05 +02:00
Oliver Smith 3b7cfe9f60 contrib: remove rpm spec file
Related: https://osmocom.org/news/255
Related: OS#6446
Change-Id: I703e115a426ac1012c80d2e1576ee6dcfbe191a5
2024-05-08 14:41:07 +02:00
Oliver Smith 5a140652b2 .deb/.rpm: various fixes related to non-root
* Explicitly chown /var/lib/osmocom to osmocom:osmocom, instead of
  relying on systemd to do it when the service starts up. This does not
  work with the systemd versions in debian 10 and almalinux 8.
* deb: Use "useradd" instead of the interactive "adduser" perl script
  from Debian. This makes it consistent with how we do it in rpm, and
  avoids the dependency on "adduser".
* deb: Consistently use tabs through the file, instead of mixing tabs
  and spaces.
* deb: Remove support for the "dpkg-statoverride --list" logic. This
  seems to be a rather obscure feature to override permissions for
  certain files or directories, for which it does not seem to be a good
  idea to make the postinst script less maintainable. Something similar
  can be achieved by using your own Osmocom config file in a different
  path with different permissions.

Related: OS#4107
Change-Id: I406ff0d625b02991d580c8382aa4be04dba45a00
2024-04-26 15:08:45 +02:00
Max 62e16d334b .deb/.rpm: add osmocom user during package install
Created osmocom user & group during package installation.
Fix the configuration dir/files permission to match.

Related: OS#4107
Tweaked-By: Oliver Smith <osmith@sysmocom.de>
Change-Id: I41d47c0884d09d4674ec806d77e43bc8f08d9b64
2024-04-24 11:52:39 +02:00
Neels Hofmeyr c19f8fe917 fixup for re-est: do not succeed on acceptance fail
Fix a bug introduced in commit
 implement CM Re-Establish for voice calls
 ae98b97382
 Neels Hofmeyr <neels@hofmeyr.de>
 Thu Jul 29 22:40:59 2021 +0200
 I6fa37d6ca9fcb1637742b40e37b68d67664c9b60

We should only succeed when conn_accepted == true!

Related: SYS#5130
Change-Id: I3679162143e8d7d8c0878de2102faa11eadfccfc
2024-04-03 20:56:10 +02:00
Neels Hofmeyr 0cc03ca427 never page for TMSI with 'no assign-tmsi'
With 'no assign-tmsi', regard any TMSI as invalidated at the end of a
Location Updating procedure. Hence, avoid paging by TMSI.

When 'no assign-tmsi' is set, osmo-msc does not actively assign a new
TMSI at the end of the Location Updating. However, it stores any TMSI
identity that the MS sends in a Location Updating Request. So far, this
caused osmo-msc to use the TMSI that the MS had sent in subsequent
Paging, which goes unanswered by the MS.

(After the long standing evil twin problem regarding TMSI MI has been
fixed in recent Ifdabe0b65bffafbf7b8e5cc10e2d225d1ed1cecd, there is no
longer an evil twin risked by clearing out a TMSI.)

Related: SYS#6860 OS#4721
Change-Id: I583682d1a35a70b008d7bb2d89ba7c3109a60b21
2024-03-28 04:06:58 +01:00
Neels Hofmeyr 2fd69e15d3 fix VLR evil twin on LU with unknown TMSI
When a subscriber first attaches by TMSI only, and later tells the IMSI
via ID Response, it may turn out that this IMSI already exists in the
VLR database. If this happens, the TMSI that the subscriber issued was
not known in the existing VLR entry, indicating that the subscriber has
in the meantime camped on a different core. Which means we can assume
that there cannot be any active connections, and the old subscriber can
be discarded, for the benefit of the new one.

(We could also discard the new one, but it is more complex to reparent
the ongoing FSMs for Compl L3 than to copy some dormant VLR state.)

In vlr_subscr_set_imsi(), check for an existing IMSI entry in the VLR.

If such exists, copy any pending Paging and auth tuple state to the new
subscriber, and discard the old one from the VLR.

In order to safely discard a vlr subscriber by force, add a new vlr_ops
function: subscr_inval(), to tell the MSC that a vlr_subscr is no longer
valid.

Upcoming patch I583682d1a35a70b008d7bb2d89ba7c3109a60b21 better clears
TMSI state from the VLR, making it more likely to hit the evil twin
situation this patch fixes; hence this is, sort of, preparation.

Related: SYS#6860 OS#4721
Change-Id: Ifdabe0b65bffafbf7b8e5cc10e2d225d1ed1cecd
2024-03-28 04:06:58 +01:00
Neels Hofmeyr 72ef7d8bb0 invalidate vsub->msc_conn_ref when msc_a is discarded
We have an msc_conn_ref pointer from vlr_subscr to an active msc_a
instance. So far, we just keep it pointing at discarded memory. Instead,
make sure it goes back to NULL when the msc_a instance deallocates.

This way the VLR can reliably tell whether a given VLR entry still has
an active connection or is just inactively caching the subscriber.

Related: SYS#6860 OS#4721
Change-Id: Ic63d01d220b63453976fe06a7c6b606f97172c99
2024-03-26 03:20:00 +01:00
Harald Welte c35f3074e5 README.md: Add links to forum + issue tracker
Change-Id: I1cad803af112241cef1c83a5ab7c19ae36c439df
2024-03-23 12:47:12 +01:00
Harald Welte 6c0479725f README.md: More hyperlinks and add more interfaces / features
Change-Id: Ic7e64d157969d466b3e1d423e20be5513a7c17fd
2024-03-23 12:45:16 +01:00
Harald Welte 475e70f44f Add funding link to github mirror
see https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/displaying-a-sponsor-button-in-your-repository

Change-Id: Id0aeb6d5c9a6bf0019eb96f25eb119fa0b5e583e
2024-03-23 12:36:00 +01:00
Vadim Yanitskiy b03001199a msc_a_up_call_assignment_complete(): handle all CSD modes
Change-Id: I92f7ab11ebc2e53700b27c38e91679c2c6f72050
2024-03-01 07:11:47 +00:00
Vadim Yanitskiy f09832a395 libsmpputil: fix -Wtautological-constant-out-of-range-compare
* 'sizeof(sms->user_data)' evaluates to 256
* 'ud_len' is of type 'uint8_t' and cannot be greater than 256

Change-Id: Ia71a0b6b9421911dc5113782d2f555a640fd90ed
2024-03-01 07:11:47 +00:00
Vadim Yanitskiy d851b2c029 libmsc: fix -Wenum-conversion in subscr_conn_toss()
This commit simply fixes a -Wenum-conversion thrown by clang.
No idea why are we using the SM (GPRS Session Management) cause values.
msc_a_release_mo() does not even use the given SM cause value.

Change-Id: Iade6bf97466ab2b3b39e9ea123fc90d06c0f6a9b
2024-03-01 07:11:47 +00:00
Vadim Yanitskiy 398cb299f9 libvlr: fix auth_fsm_term(): use proper value-string for cause
Change-Id: Ia0868dce2da5cb78c30cf518870c3d91144499b9
2024-03-01 07:11:47 +00:00
Vadim Yanitskiy d8b75fbfc8 libvlr: fix wrong cause value passed to auth_fsm_term()
This was found thanks to clang (-Wenum-conversion):

warning: implicit conversion from enumeration type
         'enum gsm48_gmm_cause' to different enumeration type
         'enum gsm48_reject_value' [-Wenum-conversion]

Change-Id: I0b820bb2a8e561682a8158fc51bd9565f5912d56
2024-03-01 07:11:47 +00:00
Vadim Yanitskiy 3b82d2c226 libvlr: auth_fsm_wait_ai(): cosmetic: drop redundant break
Change-Id: Iaa2962bfe67902f6b4aa944b73fa97db46bc9c54
2024-03-01 07:11:47 +00:00
Harald Welte 1b1a39bea1 Fix license headers: Should have been AGPLv3+, not GPLv2+
I'm not sure why so many files (particularly written by Neels)
did contain a GPLv2+ header, instead of the AGPLv3+ which is the
actual overall project license.  I consider it a mistake.

In any case, any copyrightable contribution to those files was done by
sysmocom employees, so I as managing directory can legally make a
license change, whther or not it was a mistake early on or not.

The only GPLv2-or-later file remaining is mncc_internal.c, as it has
more contributors and a longer history.

Change-Id: I8650697592b3160c4d0a7c61ae9c46d4aacb3bef
2024-02-19 20:49:43 +00:00
Neels Hofmeyr 0ebc911814 pick up all *.vty in EXTRA_DIST
(Same as osmo-bsc I47c9011b5e0e2886d221e34e6aa281d1dd0495c7)

*.vty tests are picked up by the Makefile.am by means of a wildcard --
they are run when they are there. So when you forget to add it to
EXTRA_DIST, it will be run in your local build tree, but it will be
silently omitted from a distribution tar, and nothing will complain
about it gone missing.

Instead, also use a *.vty wildcard in EXTRA_DIST. So any *.vty test
added to the git source will both be run *and* included in distribution
tars implicitly.

So far, test_neighbor_ident.vty was missing from the distribution.

Change-Id: Id28e020fc59b83d1b4cd0e5b72314a46bea62259
2024-02-13 18:28:16 +00:00
Neels Hofmeyr c8bf895a04 cosmetic: rename to sdp_audio_codecs_foreach()
Better match the pattern of sdp_audio_codecs_* instead of having
foreach_ in the front. Prepare for prepending osmo_ some day, because I
plan to move the SDP API to a separate library.

Change-Id: Ia96190e0bdb513886663be1c8c12be3b403b71c9
2024-02-08 23:42:17 +01:00
Neels Hofmeyr 100f8f9027 report caller's file,line in trans_cc_filter_run()
When we get the codec filter result logged, it is most interesting to
know the caller. So wrap a file-line macro around trans_cc_filter_run().

Change-Id: I243404487c1871e921b08098086ef2fc78a5561d
2024-02-08 23:42:17 +01:00
Neels Hofmeyr fb18315bdc msc_vlr_test_call.c: fix misleading comments
The comments indicating which two "members" are identical are
inaccurate. (One of them is a macro pointing at the other.)

Change-Id: Ifaa2f361db77cd0ed3ad39d6ca197195b9354ea1
2024-02-08 23:42:17 +01:00
Neels Hofmeyr bc0865b17b tweak apidoc for sdp_audio_codecs_remove()
Change-Id: I1d281f61497336783126aef39165426523b22112
2024-02-08 23:42:17 +01:00
Neels Hofmeyr 28672a5370 cosmetic: tweak sdp_audio_codecs_by_payload_type()
No functional change, only more readable code.

Change-Id: I3c4e29cb240e2a9a00bc9dd065ec85a5e8d8fe38
2024-02-08 23:42:17 +01:00
Neels Hofmeyr bd8ac51b60 cosmetic: move check for CSD further above
Currently the CSD check is in the middle of figuring out the voice codec
for normal voice calls. Rather do the CSD check first, and then do voice
in one coherent section.

(prep for upcoming change in this code, to support AMR rate selection.)

Change-Id: Ibd21f0bb46c66a406904105564ce961a8760cbe7
2024-02-08 23:42:17 +01:00
Neels Hofmeyr 1a07bcd1bb fix misnomer in msc_a.c: codec_cn -> codec_assigned
Before the codec filter, it would have been the CN side codec, but now
it is only the codec that the RAN reports as assigned, fed into the
codecs filter.

(prep for upcoming change in this code, to support AMR rate selection.)

Change-Id: Ie7966099c5565013018734b0c2028484c24341a7
2024-02-08 23:42:17 +01:00
Neels Hofmeyr b58024ee88 tweak example osmo-msc.cfg: 001 01
We have support for leading zeros there, so let's show it off.

Change-Id: I96c3495d0ab098535e34915f13979fb82b2e85cb
2024-02-08 23:42:17 +01:00
Pau Espin 6f2749ce0d vlr: Use new libosmogsm struct osmo_gsup_pdp_info fields
This also makes sure it doesn't compile against older libosmogsm gsup
versions which would break ABI.

Related: OS#6091
Depends: libosmocore.git Change-Id 70be3560659c58f24b8db529c4fc85da4bb0ec04
Change-Id: Ia002fd6e0334d56de34d352a0bf1a8604e2e9fd3
2024-01-26 18:07:43 +00:00
Vadim Yanitskiy 9d3635f7f7 build: include README.md into the release tarball
Change-Id: I43ad599c9a8eb21fb8713704cc8cb117512e086f
2024-01-26 23:36:01 +07:00
Andreas Eversberg b4573e57fa ASCI: Remove debug line, used during development process
Change-Id: Ie297353146cf30360a7030a2d5ee03e3391cce64
2024-01-24 08:50:12 +00:00
Andreas Eversberg 79e7b7d213 Add LLC and HLC information forwarding to MNCC interface
low/high layer compatibility are used for capability checking between
caller and called entitiy. The transcoding is performed by libosmogsm.

Related: OS#6152
Depends: libosmocore.git Ia6a2159ecf810a02f85b558026edf20b934567de
Change-Id: I760980a7e17e2fa81615adc69ef85797eb0c07f1
2024-01-24 08:50:12 +00:00
Andreas Eversberg 934f43bd1f Add LLC and HLC information to MNCC interface definiton
low/high layer compatibility are used for capability checking between
caller and called entitiy.

The information is added to the end of struct gsm_mncc increases, so
that the version number needs not to be incremented.

Related: OS#6152
Change-Id: I15f5afcf069ee6c1c4641108ceacc837bee311b5
2024-01-24 08:50:12 +00:00
Pau Espin a456583d50 cosmetic: vlc: Fix whitespace formatting in struct sgsn_subscriber_pdp_data
Change-Id: If6194e778dc5a4a140c7893a74cafcb6511d5803
2024-01-19 21:09:27 +01:00
Vadim Yanitskiy 8236184ef0 SMS-over-GSUP: set Source Name IE for *all* messages
We do include this IE in result and error messages, but somehow
not in the request messages.  For the sake of consistency, let's
ensure that the Source Name IE is present in all SMS related PDUs.

This additionally brings osmo-msc in sync with ttcn3-msc-test, which
was modified to expect the Source Name IE in all receive templates,
and makes the following testcases pass [again]:

* MSC_Tests.TC_gsup_mo_sms
* MSC_Tests.TC_gsup_mo_smma
* MSC_Tests.TC_gsup_mo_mt_sms_rp_mr

Change-Id: I65f5e3b7a0688e258979bb2679598659881a4321
Related: osmo-ttcn3-hacks.git Ic24d3082fe3dce08e43e8f3ecb6d6132503c55c6
Related: OS#6135
2024-01-09 22:26:43 +07:00
Vadim Yanitskiy 4fa6c2f636 VTY: always print MNCC handler type (internal/external)
... so that it's clear which MNCC handler is used by looking
at the output of `show running-config`.

Change-Id: Id1fe7aecc1c8445db48ff5fddcf6df0f05ba5e2e
2024-01-06 18:35:38 +00:00
Mychaela N. Falconia d0880faf79 GSUP: set default ipa-name at application level
Prior to this change, if there was no explicit ipa-name configuration
in OsmoMSC, OsmoHLR would see the GSUP connection as MSC-00-00-00-00-00-00.
However, this default is constructed somewhere deep in IPA libraries
and is not visible to the GSUP client application, in this case OsmoMSC.
This situation creates a problem for SMS-over-GSUP routing: when we get
MT-forwardSM.req from an SMSC, we have to send a GSUP response, and this
response needs to get back to the MT-sending SMSC.  Because OsmoHLR
applies only passive routing for these responses, we have to set
source_name when generating MT-forwardSM.res in OsmoMSC - but we cannot
do so if don't know our own IPA name.

Change the default OsmoMSC ipa-name from MSC-00-00-00-00-00-00 to
unnamed-MSC, mirroring OsmoHLR default of unnamed-HLR, and set it
at our application level rather than deep in the libraries.

Related: OS#6135
Change-Id: I7bacd001b81326c32bc262c7d0c0491ded822fa8
2023-12-18 03:46:11 +00:00
Neels Hofmeyr 82fad5dd46 sdp: allow more space for fmtp
In osmo-mgw, we recently chose 256 for maximum fmtp length.
Adjust to that here, too.

Change-Id: Ib9b9608d8d8f7ce34596a950dbc480e8a72ebf97
2023-12-13 01:52:22 +00:00
Neels Hofmeyr b80d93d57a test_call: codecs: test specific PT from MO to MT
Previously added codecs tests uses non-default PT number sent by MT and
adopted by MO. Also test the other direction, i.e. a non-standard PT
from MO is adopted by MT.

Related: OS#6258
Change-Id: I8fbabe242982441d676d09f4d0ed7557c8349f2c
2023-12-13 01:52:22 +00:00
Neels Hofmeyr d655cd0031 test_call: codecs: allow specific PT numbers [2/2]
In msc_vlr_test_call.c, allow to tell MO non-default payload type
numbers in the SDP, to verify that it adopts the other call leg's PT
numbers.

Actually apply the non-default payload type number (AMR=96 instead of
the default of 112 from codec_mapping.c) and see the effects in
msc_vlr_test_call.err.

The diff shows that, as intended, the change in payload type number
should result in modifying the MGW endpoint to change the earlier '112'
to the modified '96' used in this test.

Related: OS#6258
Change-Id: I25df2ed7ad792fbe66dfd0fbf08182c9cf6cfc5b
2023-12-13 01:52:22 +00:00
Neels Hofmeyr 636b4a9a1b test_call: codecs: allow specific PT numbers [1/2]
In msc_vlr_test_call.c, allow to tell MO non-default payload type
numbers in the SDP, to verify that it adopts the other call leg's PT
numbers.

This test differs only slightly from the first codecs test, so in this
patch add the test as a 1:1 copy of the first test. The next patch [2/2]
will then show only the difference the new test makes.

Related: OS#6258
Change-Id: I618e3cf1b412985589a0c63bd76b7a60202f17b9
2023-12-13 01:52:22 +00:00
Neels Hofmeyr e38f1ebc71 add comment in codec_mapping.c
Related: OS#6258
Change-Id: I0905a1264cd8f940c7a9964addf241091425fe72
2023-12-13 01:52:22 +00:00
Neels Hofmeyr b51c35e846 msc_vlr_test_call: codecs: properly test new codec matching
In patch I8760feaa8598047369ef8c3ab2673013bac8ac8a, osmo-msc learns to
handle codec mismatches reported by MT. For simplicity, that patch cuts
short the msc_vlr codecs tests by validating only the first codec.

Now test the full list of codecs properly.
This also introduces testing the re-assignment that MO does to match
MT's codec limitations, and removes the "EXPECTED FAILURE" markers.

Related: OS#6258
Change-Id: Ib933554f826c1b4347dfa3f6c4f6fe086be8b133
2023-12-13 01:52:22 +00:00
Neels Hofmeyr 11c04ae383 msc_vlr_test_call: drop misleading log
It was true once, but not since "do CN CRCX first"
Ie433db1ba0c46d4b97538a969233c155cefac21c

Related: OS#6258
Change-Id: I94e430e4e5b5bf18dbb155258d82f599ada453e6
2023-12-13 01:52:22 +00:00
Neels Hofmeyr d767c73a1f implement re-assignment to match codecs
This is the last missing piece that allows osmo-msc to make good TFO
codecs choices.

Since the codec_filter, osmo-msc properly gathers codec options and
limitations. But the MO call leg still assigns a voice channel before
getting a response from the MT call leg, and is then stuck with that.

Add the capability to adjust the MO call leg's codec in case the MT side
needs a different codec for TFO.

This is only relevant for 2G; on 3G we always have AMR/IuUP.

For inter-MSC handover, keep the behavior unchanged: offer only the
currently assigned codec to the remote side. Codec-changing HO should be
equally trivial to implement, but that is for another day.

msc_vlr_test_call's codec tests are adjusted to test the new feature in
Ib933554f826c1b4347dfa3f6c4f6fe086be8b133. For now, avoid change in
these tests by validating the first codec in SDP lists only.

Related: OS#6258
Related: osmo-ttcn3-hacks I402ed0523a2a87b83f29c5577b2c828102005d53
Change-Id: I8760feaa8598047369ef8c3ab2673013bac8ac8a
2023-12-13 01:52:22 +00:00
Neels Hofmeyr cefe594c72 add sdp_audio_codec_to_speech_codec_list()
Used by I8760feaa8598047369ef8c3ab2673013bac8ac8a to add just a single
codec to a speech codec list, instead of a list.

Change-Id: I6ac23c54bc26939e048ff2df06eb987421cfb1c5
2023-12-13 01:52:22 +00:00
Neels Hofmeyr cbabe1e32d cc: remove code dup for / fix reading codecs from MNCC
To parse and handle SDP included in incoming MNCC, use rx_mncc_sdp()
everywhere. So now rx_mncc_sdp() is the single implementation for
parsing the SDP string and taking action for codecs if needed.

One current dup of this code has a fall-back to use legacy bearer cap --
absorb that into rx_mncc_sdp(), so that we now also do that fall-back
for all of the incoming MNCC that contains bcap.

This is a cosmetic preparation for implementing MO Re-Assignment to
match MT's codec limitations.

Change-Id: I94ae11654e1f88fbd64361b639a4c583836dc13e
2023-12-13 01:52:22 +00:00
Vadim Yanitskiy 2984d13e03 silent_call: check return value of trans_alloc() against NULL
We're checking the result of trans_alloc() 6 out of 7 times, so check
it in gsm_silent_call_start() too, for the sake of consistency.

Change-Id: Ie989cd8146d66d9531cf3f3d84f46a2c6fcc2e5c
Fixes: CID#322140
2023-12-12 22:34:22 +07:00
Andreas Eversberg c9801ed14a Use uniform log format for default config files
Related: OS#6272
Change-Id: Ic710873f9203414b343b216097785cef36ca05a9
2023-12-01 12:48:30 +01:00
Neels Hofmeyr d7d3eced56 call_leg: silence some false errors
"[ESTABLISHED] transition to state ESTABLISHED not permitted"

i.e. don't complain when we already are in the established state.

Change-Id: I9b1fd63ed1ee7ed2877a4b2059386354598f4ea4
2023-11-23 00:12:25 +01:00
Neels Hofmeyr ed226ed6e6 fix codec mapping for GSM-HR
The cfg bits are for AMR-HR, not GSM-HR. The function
gsm0808_enc_speech_codec_list2() will return -EINVAL when it encounters
GSM-HR with non-zero cfg bits.

It appears this mapping was never used before, and my testing of call
re-assignment to match MT's codecs (it allows more than just the
assigned codec, because it can re-assign) has uncovered this bug
via MSC_Tests.TC_ho_inter_msc_out. I don't fully understand all the
details why we didn't see this before; anyway, the fix is obvious.

Change-Id: I19cff847a0f618ad000d12c1df54c55ef2f79699
2023-11-17 04:38:09 +01:00
Philipp Maier 1759ed5709 manuals: add section about the SGs interface.
The SGs interface is currently only casually mentioned in the chapter
running, even though the SGs interface is a prominent and often
requested feature. Let's give the SGs interface its own section so that
users can find the info about it quicker.

Related: OS#6008
Change-Id: Ic7c17511ee19cb7f6d5069b27beb661ecb4b0be8
2023-10-30 17:51:33 +01:00
Philipp Maier 656354b818 vlr_sgs: fix VTY setting for SGs counter.
When trying to modify the value of an SGs counter (eg. ns11), then the
setting is never stored. The reason for this is that OsmoMSC uses the
wrong string table to compare the user input.

Related: OS#6008
Change-Id: I0358c1ec0026c37fda6db1f3af3145393df25cfd
2023-10-30 17:12:46 +01:00
Andreas Eversberg 1d3e48febf ASCI: Reject TERMINATION, if MS is not the originator
Only the originator may terminate the VGCS/VBS call. This will not
happen in real life, because the UI of the MS should not allow
termination of a recevied VGCS call.

Change-Id: Ibe289920fa3ea50dd3e7d5c1371456dca9b72604
Related: OS#4854
2023-10-19 13:18:06 +02:00
Manawyrm 2984235454 csd_bs: force rate adaptation mode for CSD calls to V.110
Certain calls (seen on very old Nokias) won't have the rate adaptation flag
set on "analog" CSD calls. The field for the intermediate rate (after RA) is
still filled correctly.
Workaround this by setting the RA to V.110 whenever the RA is unset but an
intermediate rate is specified.

Change-Id: I5b3e5649fe071636f1becddfbfee06f9175a5f17
2023-10-17 11:25:59 +00:00
Manawyrm 1ed12eac93 libmsc: add 3k1_AUDIO and FAX_G3 bearer cap
Bearer capability 3k1_AUDIO and FAX_G3 are only important
for the interworking function, the MSC should handle
these calls the same as CSD calls with unrestricted digital
bearer capability.

Change-Id: I198aa867a8f236b8ddd05d3b2356f64b876fd4c1
2023-10-14 17:23:04 +02:00
Oliver Smith 1792ba92c1 Bump version: 1.11.0.7-dbe88 → 1.11.1
Change-Id: Ia7a90b7c192702bb71ee55df92cb05030fe5dd03
2023-09-28 13:53:08 +02:00
Mychaela N. Falconia dbe8889120 SMS over GSUP: set source_name in GSUP reply messages
For MO-forwardSM and MT-forwardSM request messages, OsmoHLR applies
routing based on the SMSC address for MO or based on the IMSI for MT.
However, reply messages following these requests are routed passively
based on the destination_name IE.  This passive message routing path
requires the source_name IE to be set as well - implement this
source_name setting.

Related: OS#6135
Change-Id: I0b7f4760bdce8a38d43d3860086c6dfb7b390701
2023-09-25 05:20:02 +00:00
Mychaela N. Falconia 02c49373f3 SMS over GSUP: correctly route GSUP responses to MT SMS
When OsmoMSC is used with OsmoHLR rather than a GSUP-to-MAP gateway,
MT-forwardSM.req GSUP messages delivering MT SMS will be coming from
a separate SMSC relayed via OsmoHLR, rather than from OsmoHLR itself.
When we reply to these messages, in order for these replies to reach
the MT-sending SMSC via OsmoHLR, we need to save source_name from
the request and regurgitate it into destination_name in our response
messages.  Implement this logic.

Related: OS#6135
Change-Id: I436e333035b8f6e27f86a49fe293ea48ea07a013
2023-09-25 05:13:49 +00:00
Mychaela N. Falconia 8de4ea6567 gsup_client_mux: set destination_name in error reply function
If the GSUP request message to which we are replying is an MT SMS
delivery from an SMSC relayed via OsmoHLR, we must set destination_name
in our reply - otherwise our reply won't make it back to the SMSC.

Related: OS#6135
Change-Id: I892fe87a733a78ed9d5761a8ce238caa135dea1e
2023-09-24 18:14:16 +00:00
Andreas Eversberg 2d4f0eaa76 ASCI: Remove duplicated CLEAR COMMAND from VGCS/VBS channel handling
Change-Id: I5e4891091c2ce56d4fd4a7f5f67156a94ade852d
Related: OS#4854
2023-09-24 17:47:26 +00:00
Mychaela N. Falconia 9b7de7480f CC: don't start guard timer on mid-call MNCC messages
The intent of the guard timer is to clear hung or stuck states
during call setup or teardown.  However, there are some MNCC
messages that will be exchanged between OsmoMSC (passing CC
messages to and from the MS) and the external MNCC agent during
the active call state, not related to setup or teardown: DTMF
start and stop, plus call hold and retrieve operations for call
waiting.  Unpatched OsmoMSC restarts the guard timer on every
received MNCC message, even those that pass through to CC without
affecting any state, and the result is breakage for users.

Consider the case of an IVR where you have to press some DTMF keys
before you can be transferred to a human operator.  You press the
needed keys, get the human operator, and start talking.  Then
3 minutes into your conversion (default guard timer duration)
your call unceremoniously disconnects without any warning.

Fix: look at the MNCC message type, and skip the call to start
the guard timer for known-benign MNCC messages.

Change-Id: Ibe2dd53f8e9e06d175b64df67d2a2e3e2d4155aa
2023-09-16 19:49:56 +00:00
Neels Hofmeyr e80f556cd4 make two functions static
Change-Id: I1de0f35f1606c997777f34bbf4033e069aadbc64
2023-09-15 04:30:32 +02:00
Neels Hofmeyr b5fe9732c5 fix codecs in internal call bridge
This is a fixup for the patch
'3G: decapsulate IuUP to AMR at the MGW; allow 3G<-AMR->2G'
I386a6a426c318040b019ab5541689c67e94672a1

After above patch, osmo-msc intelligently decides which codecs to run on
which legs of the RTP streams. In the meantime, it seems the necessary
matching changes to call_leg_local_bridge() had been lost somehow.

Testing 3G to 3G voice now, I noticed that call_leg_local_bridge()
overwrites the intelligent choices made earlier.

The history of an MGW endpoint that should convert from IUFP to plain
AMR, extracted from a pcap, looks like this:

    <- CRCX None None
    -> CRCX-OK audio 4050 RTP/AVP 112 None
    <- MDCX audio 4056 RTP/AVP 112 AMR
    -> MDCX-OK audio 4050 RTP/AVP 112 AMR
    <- MDCX audio 4056 RTP/AVP 96 VND.3GPP.IUFP
    -> MDCX-OK audio 4050 RTP/AVP 96 VND.3GPP.IUFP

So after call_leg_local_bridge(), there is an extra MDCX + MDCX-OK that
switches the codec from 112 AMR back to 96 IUFP.

That is because call_leg_local_bridge() copies the *RAN* side's codec to
both CN sides, which used to be ok when RAN and CN codecs were always
identical.

Instead, adjust only the CN sides of the MGW endpoints, and adjust them
so that both CN sides are identical. osmo-mgw should then be able to
trivially translate the codecs appropriately.

Change-Id: I130bcd77ec57e332370c487a11b0b973b6e1089d
2023-09-15 04:27:25 +02:00
Pau Espin 7eefae4b01 Bump version: 1.10.0.125-92caa-dirty → 1.11.0
Change-Id: Ifc4bfe8b4154fa892a4d15d54cee34b501038c20
2023-09-12 16:46:12 +02:00
Oliver Smith 92caa1cd6d gsm48_cc_tx_call_proc_…: verify bcap.transfer
Fail if MNCC tries to switch the Information Transfer Capability from
CSD to speech, so it is obvious that something is wrong here. I ran into
this while writing a test.

Related: OS#4394
Change-Id: Ibb76d08cad1ac3bc3320391c89766150a2e605c3
2023-08-23 17:16:02 +02:00
Oliver Smith f3941518dc msc_a_up_call_assignment_complete: check CSD codec
Reject any other codec than GSM0808_SCT_CSD in Assignment Complete from
RAN, if OsmoMSC is preparing a CSD call.

Related: OS#4394
Change-Id: I94de84df41bcd050d0e7b4e4fea1c6a6551ef7d3
2023-08-23 17:15:58 +02:00
Oliver Smith cfa37cb70b msc_ho_send_handover_request: support CSD
Related: OS#4394
Change-Id: I5fea299bdc19d2979b5c222d8dd265dac2068307
2023-08-23 16:42:24 +02:00
Oliver Smith 6de3d6cbae csd_bs_list_to_gsm0808_ct: assert -> ret -EINVAL
Instead of asserting on an empty list of bearer services, return
-EINVAL. This makes the function more similar to
sdp_audio_codecs_to_gsm0808_channel_type which also doesn't assert if
an empty list of codecs is passed.

Related: OS#4394
Change-Id: I15a389e1f7a9d3d17b6531c9836d3d5f9d148267
2023-08-23 16:42:24 +02:00
Oliver Smith e355d948f8 Cosmetic: fix typo
Change-Id: Ib707fa66ae789abfa8795b4e521a16e24c77647d
2023-08-23 16:42:24 +02:00
Pau Espin 7521a5877b trans_lcls_compose(): Set PLMN fron cell currently in use
The MS in general provides the Selected PLMN ID (IE) in the Complete
Layer 3 Information message. osmo-msc handles that message in
msc_a_ran_dec_from_msc_i() and stores the information of the PLMN in
msc_a->via_cell. If no PLMN information is provided in the message, then
at that same place the PLMN configured in the VTY is taken as an implicit
default.

This patch changes trans_lcls_compose() to use the PLMN stored in
msc_a->via_cell instead of the VTY configured one, meaning the PLMN
provided by the MS (through the RAN in use) is used if available
(otherwise the VTY-configure one is still used, as before).

With this patch the PLMN VTY config option use is relegated to a single
point of use in msc_a_ran_dec_from_msc_i() where the Complete Layer 3
Information is used. As a result, it becomes clear now that the VTY
config is only applied in the scenario where no PLMN is provided at that
time.

Related: SYS#6360
Change-Id: Ibad0005a1d7cef64dd8fefa3e554ba99a06c3666
2023-08-08 16:12:53 +02:00
Pau Espin aecf85705c Tx Loc UPD ACC: Use PLMN provided by subscr
The MS in general provides the Selected PLMN ID (IE) in the Complete
Layer 3 Information message. osmo-msc handles that message in
msc_a_ran_dec_from_msc_i() and stores the information of the PLMN in
msc_a->via_cell. If no PLMN information is provided in the message, then
at that same place the PLMN configured in the VTY is taken as an implicit
default.

The PLMN information stored in msc_a->via_cell is then finally stored
into vsub->cgi in evaluate_acceptance_outcome().

This patch changes gsm0408_loc_upd_acc() to avoid re-applying the PLMN
configured at the VTY again, and instead use whatever is already in
vsub->cgi. This is more correct since the PLMN provided by the MS takes
precedence over the implicitly configured one, meaning several PLMNs can
be handled. Otherwise, the code is always overwriting the PLMN announced
by the network on a specific RAN with the one in the MSC, which may end
up with unexpected results.

Related: SYS#6360
Change-Id: I421bd63a264db2bf6e1c4a4eea976f389e87b332
2023-08-08 16:04:04 +02:00
Andreas Eversberg 1c98031203 ASCI: Add missing transaction ID to SET PARAMETER message
Change-Id: I1b692cee894826a306885253a53a351f952d52dc
Related: OS#4854
2023-07-28 15:21:57 +02:00
Andreas Eversberg cc7b7b8548 ASCI: Add debugging and error logging to VGCS/VBS call control
Change-Id: I3fbce71e47e9670f58e46e7c2a0f26a1bbc1a46e
Related: OS#4854
2023-07-28 15:21:57 +02:00
Vadim Yanitskiy fc4bc785ff csd_bs_list_to_bearer_cap(): add default branch for safety
Otherwise we may fail to initialize cap->data.{user,interm}_rate.

Change-Id: Ibfb71d1ece502585b55db0f28069a6aa0666b9df
Related: OS#6110, OS#4394
2023-07-26 03:01:15 +07:00
Vadim Yanitskiy ab2845ac87 csd_bs_list_to_bearer_cap(): properly initialize bcap fields
Currently this function fails to initialize all bcap fields properly,
so the resulting CC Setup message generated by osmo-msc has some
fields set to reserved/invalid values.

With these changes I am able to establish a data call on TCH/F9.6:

* cap->{mode,coding}: assign default values explicitly;
* cap->radio: value 0 is reserved, set GSM48_BCAP_RRQ_FR_ONLY;
* cap->data.sig_access: value 0 is reserved, set GSM48_BCAP_SA_I440_I450;
* cap->data.transp: this is not a bool, set GSM48_BCAP_TR_{TRANSP,RLP};
* cap->data.{nr_{data,stop}_bits,parity}: set 8N1 by default;
* cap->data.modem_type: explicitly assign default value;
* cap->data.interm_rate: value 0 is reserved, set GSM48_BCAP_IR_{8k,16k}.

The related libosmocore.git patch additionally fixes encoding of the
"Connection element (octet 6c)", so that bcap->data.transp is used.

Change-Id: If49c89e4f867bac92ad062c062b9f36bab2b4531
Related: libosmocore.git I7339908864e8a2aef6f2b48a108650167e413c7f
Related: OS#6110, OS#4394
2023-07-26 02:47:24 +07:00
Vadim Yanitskiy 9145531d7f codec_mapping: codec_map[]: add missing speech codec for CLEARMODE
Without the gsm0808_speech_codec functions:

* codec_mapping_by_gsm0808_speech_codec_type(), and
* codec_mapping_by_gsm0808_speech_codec()

fail to find the codec mapping for CLEARMODE.

Change-Id: I87b3aedaf7ff7bbbcb381e94158566dc765e3ae6
Related: OS#6110, OS#4394
2023-07-25 18:56:20 +07:00
Vadim Yanitskiy cc8743c05b ran_a_channel_type_to_speech_codec_list(): set PI/PT for CSD
As per 3GPP TS 48.008, section 3.2.2.103, the Codec Type is valid if
at least one of FI, PI or PT is set to '1'.  Otherwise the Speech
Codec Element is considered invalid and shall be ignored.

Change-Id: Ibc452d37d4215c961a7946eef3ba2e7efdba078b
Related: OS#6110, OS#4394
2023-07-25 18:55:58 +07:00
Vadim Yanitskiy 9d69655729 ran_a_mgcp_codec_from_sc(): map GSM0808_SCT_CSD to CODEC_CLEARMODE
Change-Id: I4095124be8ffb293863f35bea440cd465048a9fd
Related: OS#6110, OS#4394
2023-07-25 04:43:46 +07:00
Vadim Yanitskiy 803ab19ad3 ran_a_mgcp_codec_from_sc(): cosmetic: remove unneeded breaks
Change-Id: I23d94c2d81c929deb819c02f4ddac3a702a3867d
Related: OS#6110, OS#4394
2023-07-25 04:43:10 +07:00
Keith Whyte c54ce6a4b5 SMPP: Fix Memory leaks
Whenever we call build_tlv() we must
call destroy_tlv() after we are finished with it.

Similarly, smpp34_unpack() makes calls to smpp34_malloc()
and these need to be free'd by us later.

Change-Id: Ic2abcbe78cf7cf7b6ce36fe09aa9b4f8daee973f
2023-07-21 21:11:14 +01:00
Andreas Eversberg 482f0bd5a1 ASCI: Point to correct state machine when calling ran_encode_and_send()
Fixes: CID#322139
Change-Id: I8de1fce76ba36a06384581e3a1af706b41cad1fe
2023-07-21 11:16:16 +00:00
Andreas Eversberg b865c62d33 ASCI: Fix Null pointer dereference bug in gsm44068_bcc_gcc_trans_free()
Fixes: CID#322142
Change-Id: Iab0b66dfcfdb870eaec4611720ce3a5f2089bd21
2023-07-21 11:16:16 +00:00
Andreas Eversberg 33a433a561 ASCI: Check if codec mapping exists for given codec
Fixes: CID#322143
Change-Id: I65cdf2b7feaa72167c8002cd4d47183f99cab761
2023-07-21 11:16:16 +00:00
Andreas Eversberg d63776051e ASCI: Fix wrong check for Null pointer in vgcs_cell_fsm_null()
Fixes: CID#322145, CID#322141
Change-Id: Iec0820f612450cde772076131b07fe7819d35790
2023-07-21 11:16:16 +00:00
Andreas Eversberg 7e65ed9091 ASCI: Null pointer bug fix in trans_create_bcc_gcc
Fixes: CID#322147
Change-Id: I1676d3cbf844930a6a433253f055a3f8fe3c210b
2023-07-21 11:16:16 +00:00
Andreas Eversberg 23b53e544f ASCI: Receive messages from MSC-A role related to VGCS/VBS
Voice group call and voice broadcast call messages as well as assignment
result are forwarded to VGCS/VBS call control.

Change-Id: Ie68eedb8fcb064a55cd71b58630d7a8c8b5f29ad
Related: OS#4854
2023-07-21 11:16:16 +00:00
Vadim Yanitskiy 57b36e58cb msc_vty: support spaces in short/long network name
Change-Id: If55c92669f06f0d038e8d90088a6bd76133055a2
2023-07-21 11:06:27 +00:00
Andreas Eversberg b265247171 ASCI: Clear VGCS call and channel on BSSMAP reset message
When sending or receiving BSSMAP reset msg, the ongoing VGCS/VBS SCCP
connections are cleared. E.g. this happens if the BSC is restarted and
there is an ongoing VGCS/VBS call at this BSC.

Change-Id: Ib0b309150b82148098d05cfb1fb18767283e654e
Related: OS#4854
2023-07-21 12:28:06 +02:00
Andreas Eversberg 06497197ad ASCI: Add reception of UPLINK RELEASE on dedicated channel
When the calling phone releases the uplink before it has been assigned
to the group channel, it will send an UPLINK RELEASE message on the
dedicated channel.

This message is forwarded to VGCS state machine to handle the release
there.

Change-Id: Ie8f7338da18eaaefbb022c09b96f18a3d78f8a95
Related: OS#4854
2023-07-21 12:28:05 +02:00
Andreas Eversberg f8ac734849 ASCI: Add VTY to configure GCR (Group Call Register)
Change-Id: I5bd034a62fc8b483f550d29103c2f7587198f590
Related: OS#4854
2023-07-21 12:28:03 +02:00
Andreas Eversberg e2a4088619 ASCI: Remove check for trans->msc_a to be set in _assign_complete()
trans->msc_a is always set when ASSIGNMENT COMPLETE is received.

Fixes: CID#322144
Change-Id: I0fe16e59959b48d08d95aefa6d4415f78dcf1eb4
2023-07-19 17:17:21 +02:00
Andreas Eversberg cc72929fad ASCI: Check return code of osmo_mobile_identity_decode()
Fixes: CID#322146
Change-Id: I15a6cf97a901cbb6c99ec2269051a351b504d338
2023-07-19 17:14:54 +02:00
Andreas Eversberg cd8bd45b3b ASCI: Add option to switch on or off ASCI support
Switching ASCI support is controled via VTY. This added in a later
patch. (Chg-Id: I5bd034a62fc8b483f550d29103c2f7587198f590)

Change-Id: Id68deb69f7395f0f8f50b3820e9d51052a34f753
Related: OS#4854
2023-07-19 08:23:23 +00:00
Andreas Eversberg 6c8db1d27c ASCI: Add function to receive VGCS/VBS messages from BSS
A voice group/broadcast call has no SCCP connection that is related 1:1
to a calling or called subscriber. Instead there are multiple connections
between MSC and BSS. Some of them control the uplink for each BSS and
some of them assign the channels for each BTS.

SCCP connections are maintained by the VGCS call control. Message from the
RAN are directly forwarded to the VGCS call control.

Change-Id: Ie4a2f19ba75140a6f2de02b709597239c01f02a2
Related: OS#4854
2023-07-19 08:23:23 +00:00
Oliver Smith 80654ed67d csd_bs_to_gsm0808: add T 300 / proper ch_rate_type
There is no GSM0808_DATA_RATE_TRANSP_300 (not in libosmocore and not in
3GPP TS 48.008 § 3.2.11 on which the enum is based). As I understand it,
we need to use GSM0808_DATA_RATE_TRANSP_600.

As pointed out in review, either TCH/H2.4 or TCH/F2.4 would work for
rates below 9600, so use GSM0808_DATA_FULL_PREF.

Use GSM0808_DATA_FULL_BM instead of GSM0808_SPEECH_FULL_BM. The value is
0x8 for both, but this is the correct name.

Related: OS#4394
Change-Id: I7297cc481fbe36355b5231ca800cf566a1ee93c0
2023-07-18 11:14:48 +02:00
Andreas Eversberg f7c6f1424f ASCI: Add decoder for VGCS/VBS messages to msc_a.c
VGCS/VBS messages from BSS are decoded and a receiver funktion for
the GCC/BCC (VGCS/VBS call control) is selected.

Change-Id: Ief6259ba3914eeaceb063b562a0bcbc48349ce60
Related: OS#4854
2023-07-17 12:29:42 +00:00
Andreas Eversberg e24636c6bb ASCI: Add call control for VGCS/VBS
Change-Id: I9947403fde8212b66758104443c60aaacc8b1e7b
Related: OS#4854
2023-07-17 12:29:42 +00:00
Andreas Eversberg 9bbdc34a65 ASCI: Add callref to assignment command
The (optional) call reference is required to assign a calling subscriber
to a voice group/bcast channel. The BSC can then determine to which
existing VGCS/VBS channel the MS is assigned to.

This IE is part of the GSM standard TS 48.008 (see §3.2.1.1)

Change-Id: I7955c6e0eebc930f85f360dda46be17cbd39e181
Related: OS#4854
2023-07-17 12:29:42 +00:00
Andreas Eversberg 2d27e2ccb1 ASCI: Add functions to transcode VGCS/VBS messages on A-interface
Change-Id: I6b1f088201e7ef4a58762937855a1d358973882c
Related: OS#4854
2023-07-17 12:29:42 +00:00
Andreas Eversberg cd605f30b7 ASCI: Add simple implementation of Group Call Register
This is a built-in data structure to store and handle voice group calls.

The GCR will be used by VGCS/VBS call control.
 (Chg-Id: I9947403fde8212b66758104443c60aaacc8b1e7b)

The GCR will be used by VTY code.
 (Chg-Id: I5bd034a62fc8b483f550d29103c2f7587198f590)

Change-Id: Ia74a4a865f943c5fb388cd28f9406005c92e663e
Related: OS#4854
2023-07-17 12:29:42 +00:00
Oliver Smith 429ab7bb97 mncc_builtin: permit data bearer types
Related: OS#4394
Change-Id: I7bd6fa836e5a5c05c5d2358a9b8fd2b61981dd5f
2023-07-12 09:54:57 +00:00
Oliver Smith fa006b8a36 csd_bs_list_remove: fix removal logic
Related: OS#4394
Change-Id: I638d4e063fee6bad45ab14d8ad6b9ad847a7127a
2023-07-10 07:03:29 +00:00
Oliver Smith f543548505 test: add csd_test
Show that csd_bs_list_remove() is currently broken, the next patch will
fix it.

Related: OS#4394
Change-Id: Icc98de75e97c75216a71caf94355d09330c95cba
2023-07-10 07:02:59 +00:00
Andreas Eversberg 5b1ab541a2 ASCI: Allow transaction without subscriber associated
Generally a transaction is linked with a subscriber (vsub).

A voice group call transaction may not have a subscriber associated. The
vsub field of the transaction will be NULL. If the group call is
initiated by a calling subscriber, the vsub field is set until the
calling subscriber is assigned to the voice group channel. If the group
call is initiated via VTY, vsub field is not set on creation of the
transaction.

Change-Id: I2b9afe95db4c106c141f4b7bd199ec74e197e523
Related: OS#4854
2023-07-09 07:41:33 +00:00
Andreas Eversberg 456c6f7e4d ASCI: Add two new transaction types for VGCS and VBS
- TRANS_GCC is used for the voice group call.
- TRANS_BCC for the voice broadcast call.

This also includes the use counters for transaction and CM service
request usage:
- MSC_A_USE_GCC
- MSC_A_USE_BCC
- MSC_A_USE_CM_SERVICE_BCC
- MSC_A_USE_CM_SERVICE_GCC

Change-Id: Iddd11f813582ac2ac2bdee91cc3a525986deb514
Related: OS#4854
2023-07-09 07:41:33 +00:00
Andreas Eversberg 7e4b032b88 ASCI: Add transaction type to trans_find_by_callref()
A transaction can be identified by the callref and the type. Because
transactions with different types may share the same callref value,
it is required to include the type in the trans_find_by_callref()
parameters.

E.g. a voice group call may have the same callref as a voice broadcast
call, but they are different calls. They also may not be confused with
other transaction types having eventually equal callref value, like
GSM 04.08 calls, SMS or supplementary services transactions.

By adding the transaction type to trans_find_by_callref(), we
essentially now use the (type, callref) tuple as unique ID for
transactions, instead of just callref.

Change-Id: Ic0b82033a1aa3c3508ad610c690a5f29073006c1
Related: OS#4854, OS#3294
2023-07-09 07:41:33 +00:00
Andreas Eversberg bcb4d6b26f ASCI: Allow usage of rtp_stream with other FSM
Allow the caller of rtp_stream_alloc() to define what events will be
dispatched to the parent FSM. This allows other state machines to use
rtp_stream. It is required for using RTP stream process with VGCS FSM.

Drop the unused parent_call_leg member.

Change-Id: I0991927b6d00da08dfd455980645e68281a73a9e
Related: OS#4854
2023-07-09 07:41:33 +00:00
Andreas Eversberg 58fe2e03c8 ASCI: rtp_stream_commit(): Also update MGW on conn mode change
So far rtp_stream_commit() triggers an MGCP MDCX message only when
codecs or the RTP address changed.
Do the same for mode changes. ('sendrecv', 'recvonly', 'sendonly',...)

Change-Id: I7a5637d0a7f1df13133e522fc78ba75eeeb2873e
Related: OS#4854
2023-07-09 07:41:33 +00:00
Andreas Eversberg 712b28e695 ASCI: Use a unique call-id for RTP streams
The MGCP protocol features the 'C' (call-id) to identify which
connections belong to the same call. They may be used by MGW for
accounting or management procedures.

So far we sent the MNCC callref as call-id. Instead, add a separate
unique call_id number space. Assign a unique call_id to each
transaction.

Change-Id: I36c5f159fa0b54fb576ff8bd279928b895554793
Related: OS#4854
2023-07-09 07:41:33 +00:00
Andreas Eversberg 0452cf9467 ASCI: Add log category for VGCS/VBS call and channel FSM
Change-Id: Icebc855fdc3f6ca7034ad3576b1acb5aed6bc435
Related: OS#4854
2023-07-09 07:41:33 +00:00
Andreas Eversberg b9162c7cc6 ASCI: Add log categories for GCC/BCC (call control)
Change-Id: I4c5d002b5bb1c2ebf2fac777ab784559fc265e7c
Related: OS#4854
2023-07-09 07:41:33 +00:00
Oliver Smith 412cf92d3c gsm48_cc_tx_setup: use MNCC bcaps for CSD
Use the MNCC bearer capabilities in CC setup for CSD, if available.

Note that in the MNCC_F_BEARER_CAP code path sdp_audio_codecs_set_csd()
also gets called by trans_cc_set_remote_from_bc().

Related: OS#4394
Change-Id: I56e49ebc41696912a81b8f4f63fbc36d0b605e9e
2023-07-06 14:52:06 +02:00
Oliver Smith 8d0aa26166 mncc_test: fix talloc_named_const
Change-Id: I0f0a5497eb37b9f9b9102e01cee8c1bda85c5dfe
2023-07-06 12:58:14 +02:00
Oliver Smith 8e16e8b338 gsm48_cc_tx_alerting: check rc of sdp_msg_from_sdp_str
Fixes: CID#321280
Change-Id: Id372d2d844446d6667a00dae22bdf8ed36c599ba
2023-06-23 10:55:55 +00:00
Oliver Smith 17399803a4 csd_bs_list_to_gsm0808_channel_type: fix rc check
Check the return code before writing it to unsigned ct->data_rate, as
"ct->data_rate < 0" is never true.

Fixes: CID#321277
Fixes: 106321 ("Add initial CSD support with external MNCC")
Change-Id: I5d77da71b60748818ba631229126c1bf061a9c7d
2023-06-23 10:38:46 +00:00
Oliver Smith 0d4607d90d msc_ho_send_handover_request: fix check_after_deref
Fixes: CID#211073
Change-Id: I9389cc9c4af987c11652c6fe9a0ff4289a7781c9
2023-06-22 14:53:17 +02:00
Oliver Smith 6a8dae666c smpp_msc: submit_to_sms: check ud_len > sms_msg_len
Fixes: CID#240727
Change-Id: Ie01ac84816f6ac3ba5631a643d486fb0dfb05eb2
2023-06-22 12:15:15 +02:00
Oliver Smith d0980a4e8b sdp_msg_test: fix dereference after null check
Fixes: CID#274690
Change-Id: Ic59252e4f1d4daf5f86c6b73ec951e02109df9bc
2023-06-22 11:56:11 +02:00
Oliver Smith 79d824f7f4 smpp_handle_bind_tx: initialize tlv
Fixes: CID#272977
Change-Id: I22da1aa95bf19a9bb1d8e0875f3b68356d801c70
2023-06-22 11:42:23 +02:00
Oliver Smith 1063213b38 Add initial CSD support with external MNCC
Implement and use CSD bearer service logic (with similar audio codec code):
* csd_filter (codec_filter)
* csd_bs (sdp_audio_codec)
* csd_bs_list (sdp_audio_codecs)

Related: OS#4394
Change-Id: Ide8b8321e0401dcbe35da2ec9cee0abca821d99a
2023-06-20 12:47:05 +02:00
Oliver Smith 64f3930c72 gsm48_cc_tx_setup: set trans->bearer_cap.transfer early
Prepare to use trans->bearer_cap.transfer in trans_cc_filter_run() to
differentiate between speech and data (CSD).

Related: OS#4394
Change-Id: Id0476a4882bcb27413d033f2de2c5288954f0b95
2023-06-15 15:06:46 +02:00
Oliver Smith 8a8ce714ff msc: add trans_cc_set_remote_from_bc
Prepare to set remote CSD bearer services in a future patch.

Related: OS#4394
Change-Id: I71a8ff6167e2adf3ee609883730e5f67b7539185
2023-06-15 15:06:46 +02:00
Oliver Smith c63c3a0cc5 transaction: move cc.codecs.result -> cc.local
Prepare for CSD where this will be used too.

Related: OS#4394
Change-Id: Iaf954be0455625faa06a64c19905b79b7045f8e4
2023-06-15 15:06:46 +02:00
Oliver Smith 593cd88535 transaction: move cc.codecs.remote -> cc.remote
Move remote out of codecs, as it will be used by CSD code as well.
Otherwise we would need to store it twice (in cc.codecs.remote and
cc.csd.remote).

Related: OS#4394
Change-Id: I5d2e078db3b3437cb6feae40d8955912d7a297e4
2023-06-15 15:06:46 +02:00
Oliver Smith ceca8e6d2d codec_filter_run: prepare for CSD
Related: OS#4394
Change-Id: I18b396193ad25a3905cc8c1853c9680dab0a2d44
2023-06-15 15:06:46 +02:00
Oliver Smith 1c7f1787bd codec_filter_set_bss: prepare for CSD
Related: OS#4394
Change-Id: I931db33820d9da81147bda84002ada0b80f11186
2023-06-15 15:06:46 +02:00
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
Pau Espin 11c420a2fa Write explicit role & sctp-role fields in ASP configurations
Change-Id: I4901ea309cd5975117480642d068df3ca2f73662
2023-06-08 19:39:13 +02:00
Vadim Yanitskiy d3abcabdb3 tests/{ctrl,vty}_test_runner.py: raise an exception if proc's rc != 0
Change-Id: I4ed672d369bd379871a6a9fba5ff2da817e362d7
Depends: osmo-python-tests.git I1e11fcb6c5a587c27fc00920b6e157862d972fd9
Related: OS#5665
2023-06-01 20:08:02 +07:00
Vadim Yanitskiy 912f3501f2 fixup: contrib/jenkins: create workspace.tar.xz on error
cat-testlogs.sh does "exit 1", so no workspace.tar.xz is created.
Call this script after archiving the workspace.

Change-Id: Ibcb842f32418e66a186d6b21bb5861cf4a0b7c4a
Fixes: 799d972132 "contrib/jenkins: create workspace.tar.xz on error"
Related: OS#5665
2023-05-28 03:04:51 +07:00
Oliver Smith 902fb947b6 systemd: depend on networking-online.target
Related: SYS#6400
Change-Id: Ib6c78c76c5f13b9482428ce653a61b03b2aca1d3
2023-05-26 15:32:04 +00:00
Pau Espin 1c841f8a95 UserManual: Include sigtran*.adoc from osmo-gsm-manuals.git
They were only included in osmo-stp so far.

Change-Id: I37e36e7919d6996a79533b62564c5d82908b57f7
2023-05-26 14:11:01 +02:00
Oliver Smith 799d972132 contrib/jenkins: create workspace.tar.xz on error
In order to figure out why we sometimes get a coredump in the jenkins
master jobs, add a quick hack to get all relevant binaries on libraries
on error.

Related: OS#5665
Change-Id: If7b4eb050e2b3f763b5cfddf1a5b6a18bb41f46e
2023-05-23 16:21:04 +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
Oliver Smith e4aa86514e debian: set compat level to 10
Related: OS#5958
Change-Id: I9776c48f4f913dd7f7cde3afc6fe32bd0e9ba1b0
2023-04-25 16:48:30 +02:00
Neels Hofmeyr 85d7ba3d34 TODO-RELEASE: add note on osmo-sip-connector and SDP
Change-Id: I37fb5e18f06a5379d0320ee7d47885c9283cbd06
2023-04-15 21:57:22 +00:00
Vadim Yanitskiy 5d0bc330a0 tests: $(BUILT_SOURCES) is not defined, depend on osmo-msc
Change-Id: I3676a744bbe13d5d17caa94e9bd9e21c5c53de87
2023-04-14 11:16:51 +00: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 7a5c8b5257 coverity: sdp_msg_test.c: check rc of sdp_msg_from_sdp_str()
Related: CID#310975
Change-Id: I69d8972c58fb7cde965ff0b231947dd26247c2c7
2023-03-28 03:55:23 +00:00
Neels Hofmeyr 6a1faa9f78 fix msc_vlr_test_call SDP mncc_rtp
In msc_vlr_test_call, we fail to send the right MNCC struct for
MNCC_RTP_CREATE. We should pass a struct gsm_mncc_rtp. Fix that.

Change-Id: Ia0b3253f85c716e45f925da3f58f025af1f15ec9
2023-03-26 00:03:50 +01: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 3c323dcfb1 [codecs filter] msc_vlr_test_call: test codecs resolution
Show that the codecs filter now works as expected in call messaging.

Related: SYS#5066
Change-Id: I879ec61f523ad4ffc69a0b02810591f7c0261ff9
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 81938fd9a7 msc_vlr_tests: confirm crcx by RAN/CN side separately
Upcoming patch 'do CN CRCX first' changes the ordering of MGCP. To
properly show the change in behavior in the msc_vlr_test_call, first
clarify which side is expected to do MGCP when.

Related: SYS#5066
Change-Id: I972e7426006e5b62f81ccfe4fa224ee9eed7a7ac
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 8159c95637 msc_vlr_test_call: include RAN RTP addr in ass compl
I noticed by chance that the Assignment Complete message generated in
the test lacks a remote RTP address for the RAN side.

Make the test more realistic by adding a remote RTP address and port. It
doesn't have any bearing on the tests besides more accurately showing
RTP stream setup in the logs.

Change-Id: Ia428762a16dcc17f036d725a00e0b3767418289b
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 4c57bb0476 [codecs filter] add trans.cc.codecs
Add the central codecs_filter for Call Control. The new member is not
used in this patch yet, subsequent patches will start to populate the
various stages of this codec filter, one by one.

Related: SYS#5066
Change-Id: Ib3fdeff8d1e1ea0760168d63ee6e1b1fb993aa5f
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 fe90aff554 tests: use -no-install libtool flag to avoid ./lt-* scripts
This option should be used for any executables which are used only
for testing, or for generating other files and are consequently never
installed.  By specifying this option, we are telling Libtool that
the executable it links will only ever be executed from where it is
built in the build tree.  Libtool is usually able to considerably
speed up the link process for such executables.

Also take a chance to add the missing $(COVERAGE_LDFLAGS).

Change-Id: I664a9d5abed2777deee302f9d3afd1bbfde7a844
2023-03-11 04:54:09 +07: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 c5572acb73 add voice_call_internal_mncc.msc
Same as voice_call_external_mncc.msc, but run with internal MNCC. Shows
some curious differences like the MNCC_LCHAN_MODIFY that internal MNCC
sends, but external doesn't.

Change-Id: Ic003322dc4e3fce24a8413688cfe18198a4dc08a
2023-03-09 01:56:33 +01:00
Neels Hofmeyr ec9a022dcf update doc/sequence_charts/voice_call_external_mncc.msc
Re-run the msc_log_to_ladder.py on an actual 2G-2G voice call log, to
see if anything changed in the meantime, to prepare for upcoming changes
to the sequencing of establishing voice calls.

Also shows recent improvements on picking up RTP ports from MGCP and
MNCC.

Change-Id: I9dcf980ad24d5921c291c9aada211b37f6f3db7f
2023-03-09 01:56:33 +01:00
Neels Hofmeyr e4febd2697 charts: Rename voice_call_full.msc to voice_call_external_mncc.msc
Because I will soon add an _internal_mncc one as well.

Change-Id: Ic90a93d749ea936a632a45e615007a58104eeedd
2023-03-09 01:56:33 +01:00
Neels Hofmeyr 075ca60b06 msc_log_to_ladder.py: various tweaks
(multiple changes in one patch because who cares about this script)

tweak regexes -- they worked ok, but some of the '[^:]' should really be
'[^:)]', and they also look happier that way.

don't skip RAN=NONE, so we also see messages before Complete Layer 3.

s/sip/mncc, to generally be valid for both internal and external MNCC.

pick up RTP port information from MGCP OK

pick up RTP port information from MNCC rx and tx

add --verbose flag, to be able to check whether the regex rules are
still working (getting any hits).

fix rule_imsi_detach: should return True to be counted in --verbose.

tweak comment 'Generated by...' to include the full git path.

Change-Id: If619182ba76c6b238a1fa105a3c3449d7f473dd1
2023-03-09 01:56:33 +01: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 c259be4ebe make: doc/sequence_charts: use wildcards for EXTRA_DIST and CLEANFILES
Both EXTRA_DIST and CLEANFILES had missing entries. It is easy to
forget to keep them up to date. Rather use wildcards to always pick up
all relevant files.

(Not adding *.dot because there are no .dot charts here, yet.)

Change-Id: I3a18e4608a310169d7c9cd9c1b8ac9015a990920
2023-03-09 00:28:08 +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
Pau Espin 964ce6f46c Bump version: 1.9.0.58-1289-dirty → 1.10.0
Change-Id: Ifff00a3107447da911629948e9f3061c93b6ac86
2023-02-07 17:28:17 +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
Oliver Smith f5a0c4b662 contrib/jenkins.sh: use enable-werror with IU too
Now that the warnings in osmo-iuh have been fixed, we should be able to
build the IU version of OsmoMSC with --enable-werror too.

Related: OS#4462
Change-Id: Id54be9dd1aa66cc27eb5ee4010be9e495865b331
2022-11-15 12:57:24 +01: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 68d2a671c6 doc: Include mgwpool.adoc from osmo-gsm-manuals
This way we document the recently gained support for MGW pooling.

Related: SYS#5987
Depends: osmo-gsm-manuals.git Change-Id Ieda0d4bfe6fc90da6e19c791d8ec2da89427ba3b
Change-Id: I9d8116a74a63591599c4cbafa60f9a313e6ab19c
2022-10-20 16:24:34 +02: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 ef70bb202a Use new mgcp-client VTY commands under mgw node
New VTY commands have been added recently to the "mgw" node which drop
the redundant "mgw" prefix on each fo them.

Change-Id: I8ac11388e9493416b644812638e1374251725584
Depends: osmo-mgw.git Change-Id: Id55af13d2ecde49d968b9dca6a2f8108a17ec484
Related: SYS#5987
2022-10-19 18:27:50 +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
Pau Espin add5a7f771 tests/test_nodes.vty: Avoid listing commands provided by lib
Those commands are not controlled/implemented in this repository, so
it's a bad idea having them show up here, since they may change. be
modified, become deprecated, etc.

They are actually becoming deprecated now in libosmo-mgcp-client
(osmo-mgw.git Change-Id Id55af13d2ecde49d968b9dca6a2f8108a17ec484) and
hence they don't appear anymore when listing the node.

Change-Id: I5d908f9e3023f725d49ed039158bd3d09828f12c
2022-10-19 18:24:47 +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 be768ac302 Set working directory in systemd service file
By default systemd will execute service with root directory (or home directory for user instance) which might result in
attempts to create files in unexpected place. Let's set it to 'osmocom' subdir of state directory (/var/lib for system instance) instead.

Fixes: OS#5661
Change-Id: I0f942545d9e920ba8a2d8645512ec3414ab27418
2022-08-30 19:37:20 +07:00
Vadim Yanitskiy 088043fae4 contrib/jenkins.sh: do not override parallel make for libsmpp34
Parallel build has been fixed [1] and re-enabled [2] back in 2018.

Change-Id: I13d2d6f3b5ffae390cf429e41bf9035b8c551f66
Related: [1] I5a9d7dbd7b992d322ed0d852ebf8ca2252b51a12 libsmpp34.git
Related: [2] Id41fbcb5a96093eb6c3dc00bcacbd379111ada70 libsmpp34.git
2022-08-29 00:43:09 +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 3948fcc476 tests: use common stubs for SMS queue test
Related: OS#5568
Change-Id: Ic854eb919e6fcc82bd0245f62c72985b938c6b7a
2022-08-01 13:53:37 +00: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 7038dd0e05 Ignore .deb build byproducts
Change-Id: I0ff10ef5766edf5f2aacf62acc98f25f01706ab4
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
Pau Espin 5b06a8d6a5 Bump version: 1.8.0.43-2eaaf-dirty → 1.9.0
Change-Id: Iacb839715290b27f1f3d302e13f219f5f0e1d161
2022-06-29 11:32:12 +02:00
Harald Welte 2eaaf6f305 fix RPM build failures due to README -> README.md rename
This fixes a bug I introduced in I98e09e8900c359382e2a90b187f0c6f22a1cf81d

Change-Id: I9d7bc0aea404499315e212a2ebb92d54df85d812
2022-06-21 09:50:53 +02:00
Harald Welte 1b6289adce Convert + Expand README file
README.md in-line with that of other osmocom CNI projects:
* markdown syntax
* link to manuals, issue tracker, gerrit contributions, etc.

Change-Id: I98e09e8900c359382e2a90b187f0c6f22a1cf81d
2022-06-18 13:34:24 +02:00
Harald Welte 3b13edf48f update git URLs (git -> https; gitea)
Change-Id: I0d7a9140ccbe5adecddde1901703e49243ee0b92
2022-06-18 12:27:10 +02: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
Oliver Smith 6a0ab76d67 tests/msc_vlr/Makefile.am: drop -ldbi
Fix for:
  /usr/bin/ld: cannot find -ldbi

Fixes: d43c22 ("switch from libdbi to lbsqlite3")
Change-Id: I8dcce119a8121881d56cb18328b5f702763b43ea
2022-05-18 14:07:57 +02: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 d677f51187 tests: Remove sms.db{-wal,-shm} files, not just sms.db
ERROR: files left in build directory after distclean:
./sms.db-shm
./tests/sms.db-shm
./tests/sms.db-wal
./sms.db-wal

Change-Id: Iecd380f598edbd1635361e4c340d54d092739919
2022-05-16 17:44:01 +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
Vadim Yanitskiy c628c9e256 tests: use 'check_PROGRAMS' instead of 'noinst_PROGRAMS'
When using 'check_PROGRAMS', autoconf/automake generates smarter
Makefiles, so that the test programs are not being compiled during
the normal 'make all', but only during 'make check'.

Change-Id: I13b519e61ca0d9ce038e8c989ddac012de4a6c61
2022-04-13 19:55:35 +03: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 0557ca268d Drop unneeded ax_check_compile_flag.m4
The macro is no longer used since efa6c5b7d6.

Change-Id: I58130ad70b5109a5720fc1b5702863cc503e6345
2022-01-11 18:11:41 +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
Pau Espin b7f97ea8a0 Bump version: 1.7.0.43-aefbf-dirty → 1.8.0
Change-Id: I37aa63e1c4ed021c5cc8b186f073cf01ab9a9cb6
2021-11-16 17:44:54 +01: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
Vadim Yanitskiy 3caede7498 manuals: remove deprecated -C / --no-dbcounter options
Change-Id: I0a7bc537ed84c5f3e203d106893b1cf1ee8b599a
2021-11-12 19:12:41 +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
Oliver Smith efa6c5b7d6 Revert "Turn some compiler warnings into errors"
Do not turn some compiler warnings into errors by default. This patch
was added before --enable-werror was available.

We build with --enable-werror during development and in CI. If the code
is built with a different compiler that throws additional warnings, it
should not stop the build.

This reverts commit 34f012639d.

Related: OS#5289
Change-Id: Ideff462157a034e053e5e7049605dd8d24440905
2021-11-04 13:03:20 +00: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
Oliver Smith 4ac59538e9 contrib/osmo-msc.spec.in: require libosmo-ranap >= 0.7.0
Sync with configure.ac, debian/control. Nowadays osmo-release.sh
complains about this.

Related: I8dbbd63fdbd35f5f90f20dcd7e710078f2d9e12a
Change-Id: Ib3b9d6af8f9d4e807ff4106f95f0a5b13834a126
2021-09-16 14:34:18 +02:00
Philipp Maier ce1f973283 msc_vlr_test: remove DLMGCP log messages from unit test output
The log output of libosmo-mgcp-client has changed. This change causes
the unit tests to fail because the log output does not match anymore.
Lets disable the DLMGCP log output since it is of minor importance
for VLR testing anyway.

Change-Id: Id197e4ab9ba12e284299ef520edee9c362513bf1
Related: SYS#5091
2021-09-14 12:06:45 +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 13f17c13c3 vlr_sgs.h: Set proper logic order of items in enum sgs_ue_fsm_state
Set order of states in the same order as they appear in the specs (see
chapter 4.2.2 mentioned above the enum).
Furthermore, from FSM state transition point of view it also makes sense
to put them in this new order, since one should pass through
SGS_UE_ST_LA_UPD_PRES to get to SGS_UE_ST_ASSOCIATED.

Change-Id: Ia9216965e9f30caedffa3cb53d14da7f7fd37b4e
2021-08-24 11:49:05 +02:00
Pau Espin 25b6847f46 cosmetic: fix typos in comments
Change-Id: I89e8eba379f83bcf3061601b02af9f10dbca0f22
2021-08-24 11:42:15 +02:00
Philipp Maier 945b0606cf running.adoc: add section about MGCP configuration
The manual seems to lack a section about how the MGW is set up. In the
osmo-bsc manual we have a "Configure MGCP to connect to an MGW" section
under the "Configure primary links" section. We should have the same
thing in the osmo-msc manual as well.

Change-Id: I5501739e63860c436ff606bc2758b495258cd2b9
Depends: osmo-mgw I47e7ff858d5067b46d52329be5f362ff61c0dff8
2021-08-03 11:36:25 +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
Neels Hofmeyr 0c076bc75a add sequence_charts/call_reestablishment.msc
Change-Id: I6ebc3a0555ef82e1c027ca75b45f8147a3e07ee6
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
Oliver Smith 5a44e5f46e contrib/osmo-msc.spec.in: depend on dbd-sqlite3
Add the missing runtime dependency to the sqlite3 driver of libdbd.
The library does not provide a pkgconfig file, so using "pkgconfig(...)"
as done in the BuildRequires is not possible. Write both the OpenSUSE
and CentOS name with an if..else.

Fixes:
  <0009> db.c:648 Failed to create database connection to sqlite3 db 'sms.db';
                  Is the sqlite3 database driver for libdbi installed on this system?

Change-Id: Ia972944c300aecbb6ec460b2362aabff459baefd
2021-03-09 14:48:59 +01:00
Pau Espin 13c2153c94 configure.ac: Depend on newer libosmo-ranap
I forgot to ammend the release previous release commit with this.

Change-Id: I8dbbd63fdbd35f5f90f20dcd7e710078f2d9e12a
2021-02-23 20:47:57 +01:00
Pau Espin 59764b6f3e Bump version: 1.6.1.98-cad22-dirty → 1.7.0
Change-Id: I1bf25c0c01efd6f93df8ac2b26868dd1579b3531
2021-02-23 20:22:34 +01:00
Pau Espin cad22fde22 tests: Replace deprecated API log_set_print_filename
Change-Id: I4c1116aafb155b5fb216b01054332dcb91c18401
2021-02-19 14:11:26 +01:00
Pau Espin 8d02d99158 tests: Explicitly drop category from log
Let's disable category here since we don't care about its formatting here.

In any case, every test relying on logging output validation should
always explicitly state the config to avoid issues in the future if
default values change.

Change-Id: I089c0001fc75e81558c3e860827e4d434cf1eab3
Related: OS#5034
2021-02-19 14:10:50 +01:00
Neels Hofmeyr ac6ccd9295 gsm_network: drop unused neighbor_list member
Change-Id: I57463ab94773de1377526f9a1c72fe3d37a31827
2021-02-18 14:16:18 +01: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
Neels Hofmeyr dbb3c723a4 msc_vlr_tests: make independent of libosmocore talloc
The msc_vlr_tests verify whether any of the tests run contain msgb or
talloc memory leaks. So far they did so by fixating a specific number of
talloc blocks, which may break by library implementations changing.

Instead, verify that the test leaks no allocations by comparing talloc
blocks before and after each test.

When a leak is detected, print the full talloc report to stderr, which
makes the expected output mismatch the actual output and fails the test.

Related: OS#4311
Change-Id: I8537fa76d460c951302932a1bad4299f7fe398c9
2021-02-07 23:59:59 +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 46de4aafa6 .gitignore: Ignore new autofoo tmp files
Change-Id: Ifb9dfe84575451fdfc9d059bab428da82b448107
2021-02-04 12:51:41 +01:00
Oliver Smith 09dac13c4d configure.ac: set -std=gnu11
Change-Id: Ie93915f06a8907a80b4f081a00c1cde395015595
2021-01-28 09:28:26 +00:00
Oliver Smith 716a2615f5 contrib/jenkins: don't build osmo-gsm-manuals
Related: OS#4912
Change-Id: I0f4d3b444c22c772498299f7d209fc28080af8c3
2021-01-13 13:17:28 +01:00
Harald Welte 644be61c4a README update. Explain more what it is than just the history
Change-Id: I7368a8a0927fa301dfbbe550b8090e783ab7be2e
2021-01-06 13:13:46 +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
Harald Welte e188010474 debian/control: Recommend installation of osmo-mgw
osmo-msc is pretty useless without osmo-mgw these days.  Let's not
make it a strong dependency, as the mgw could of course be running
on different machines.

Change-Id: I76c1bf30c733cf2fd596a8971ccb8bac4220be66
2020-11-07 17:42:53 +01: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
Pau Espin 5a58cefab7 contrib/jenkins: Enable parallel make in make distcheck
Change-Id: I8f112ed6de4b1b7c28fbb790fede0e1a387a4e22
Related: OS#4421
2020-10-12 19:37:24 +02: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 754def9c7d fix comment in ran_peer.h
Change-Id: Iff985dfe28265d32cae6a931636d5018a439d39e
2020-09-25 01:45:08 +02: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 047c5d9dc8 tests: Fix VTY results after switch to newer libosmo-mgcp-client
In this case we are fine with simply updating test result because anyway
ABI breakage in some libosmo-mgcp-client structs was needed, so new
versions of osmo-msc will require new versions of libosmo-mgcp-client.

Change-Id: I1fbdb95f71d3b9a2dc88e1ba79892ae16485aa99
2020-09-09 13:18:40 +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
Pau Espin d54e07f8bd configure.ac: Drop trailing whitespace
Change-Id: I48dee161f6951777dc86b61da13793d6309b86bb
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 a908b43e59 debian/control: change maintainer to the Osmocom team / mailing list
Change-Id: I8c4e1749e6b4903877962b2da87be472e63c8de0
2020-08-13 16:09:02 +07: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 458fe3d789 manuals: generate vty reference xml at build time
Move 'doc' subdir further down to "make sure" the osmo-msc binary is built
before the docs.

Remove msc_vty_reference.xml from the source tree.

In manuals/Makefile.am use the new BUILT_REFERENCE_XML feature recently added
to osmo-gsm-manuals, and add a build target to generate the XML using the new
osmo-msc --vty-ref-xml cmdline switch.

Depends: I613d692328050a036d05b49a436ab495fc2087ba (osmo-gsm-manuals)
Change-Id: Ib872e7979c5b5a9da1347a3f326307844cf76536
2020-07-12 12:30:28 +00: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 1139ca352b make vty-transcrip-test: use $VTY_TEST var like osmo-bsc
Adopt the same way to run manual vty transcript tests as in
osmo-bsc/test/Makefile.am.

There are different ways to select a specific test to run in osmo-bsc and here
in osmo-msc. The osmo-bsc way is more convenient when building outside the src
tree, because it does not need the full absolute path of the test file.

Change-Id: If1e2abfa321a5e9fb60358d1f0e4e448b33184af
2020-06-25 20:08:58 +00: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
Harald Welte a4a45252df osmo-msc.spec.in: Use %config(noreplace) to retain current config file
Change-Id: I00c3152b774a826230a112eae93b0e7c4d4f4c7a
2020-06-23 20:07:56 +00: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 0ec7b23ee3 msc_vlr_test_gsm_ciph.c: fix IMEISV MI: even number of digits, clear odd bit
There is an invalid Mobile Identity in the msc_vlr_test_gsm_ciph test data.
This became apparent when applying the new osmo_mobile_identity API (in a
following patch). Current Mobile Identity API ignores the error.

Change-Id: Ib1d54c59acc8b716de471ca275f54f9d22da3574
2020-06-15 03:14:03 +02:00
Harald Welte 5c38c817f2 contrib/osmo-msc.spec.in: Enable SMPP in RPM builds
The SPEC file already included a build dependency to libsmpp34, but
then the compilation of osmo-msc didn't actually pass --enable-smpp
along, resulting in binaries without SMPP support - unlike the Debian
binaries, which do contain that part.

Change-Id: I223be7a735e97b32f7c0ff246cf826f109b0f686
2020-06-13 14:40:32 +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
Neels Hofmeyr 346a3b956f manual: link to new common cs7-config.adoc, remove some dup of that
Related: OS#2767
Depends: Ia2508d4c7b0fef9cdc57e7e122799a480e340bf7 (osmo-gsm-manuals)
Change-Id: Ie88dd2c7f7318a31ae04fbd6930346d92141fde5
2020-06-03 12:51:38 +00:00
Neels Hofmeyr 92b0246301 manual: Multiple Instances: tweak MNCC, add missing SGs doc
Change-Id: Ice610e3db132dc50b7ddc3f3e324e8ad1bba5864
2020-05-26 23:14:01 +02:00
Oliver Smith 201372616f Makefile.am: EXTRA_DIST: debian, contrib/*.spec.in
Change-Id: I83cf6ee3f974733e45b01c79242214fa32479416
2020-05-22 13:42:12 +02:00
Oliver Smith 0314593aa7 contrib: integrate RPM spec
Remove OpenSUSE bug report link, set version to @VERSION@, make it build
with CentOS 8 etc.

Related: OS#4550
Change-Id: If5499e11d872e629a018fc77d5adf5d0cb863d48
2020-05-20 08:50:18 +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
Oliver Smith b092589ed1 contrib: import RPM spec
Copy the RPM spec file from:
https://build.opensuse.org/project/show/home:mnhauke:osmocom:nightly

Related: OS#4550
Change-Id: Ief0917ad6e7ce193a54fd0d2a5e665b56ff8bbea
2020-05-14 11:48:32 +02: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
Philipp Maier 72b8c38287 doc: do not use random ip-address for MGW
The example configs suggest to use a random ip-address as MGW address.
Lets use a loopback address here. This will suit the usual case where
MGW and MSC run together on the same machine.

Change-Id: Ie2b2094fdcfed45353d9ba22cb07eed626fd143c
2020-04-14 13:14:35 +00:00
Eric Wild b73ecbfab1 configure.ac: fix libtool issue with clang and sanitizer
As pointed out at https://github.com/libexpat/libexpat/issues/312
libtool does not play nice with clang sanitizer builds at all.
For those builds LD shoud be set to clang too (and LDFLAGS needs the
sanitizer flags as well), because the clang compiler driver knows how
linking to the sanitizer libs works, but then at a later stage libtool
fails to actually produce the shared libraries and the build fails. This
is fixed by this patch.

Addtionally LD_LIBRARY_PATH has no effect on conftest runs during
configure time, so the rpath needs to be set to the asan library path to
ensure the configure run does not fail due to a missing asan library,
i.e.:

SANS='-fsanitize=memory -fsanitize-recover=all -shared-libsan'
export CC=clang-10
ASANPATH=$(dirname `$CC -print-file-name=libclang_rt.asan-x86_64.so`)
export LDFLAGS="-Wl,-rpath,$ASANPATH $SANS $LDFLAGS"

Change-Id: I17d95c416e26dae6ca8bec57df01d3e7b7061058
2020-04-11 01:19:12 +02:00
Neels Hofmeyr d233104a04 manual: add missing mention of MGCP in "Multiple instances"
Change-Id: I91d06921e4dca08428bf45fc1a3fd6e124599371
2020-03-18 01:12:42 +01: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 2c889056f5 libmsc/gsm_04_11.h: remove unused sms_deliver definition
Change-Id: Icd4b0c45d994dd02d9118890eb5a1261a2008eca
2020-01-29 00:03:40 +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 064a1e0c54 msc/sccp_ran.h: fix: do not pass -1 to osmo_rat_type_name()
The problem is that osmo_rat_type_name() calls get_value_string(),
so we first cast -1 to 'const enum osmo_rat_type' and then to
'uint32_t'. Let's rather use OSMO_RAT_UNKNOWN.

Found by GCC with -Wextra in CFLAGS:

  warning: operand of ?: changes signedness from ‘int’ to
	   ‘const enum osmo_rat_type’ due to unsignedness
	   of other operand [-Wsign-compare]

Change-Id: I63ba355102d3cc035ba90121e06aba7cf1776aa0
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 4b4a1a13bc msc/signal.h: remove unused (since the NiTB split up) signals
Change-Id: I3848d0db3c62de7613f609ad632641eb54453817
2020-01-20 11:40:45 +00: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
Vadim Yanitskiy ecfcd99c4b libvlr: remove unused 'periodic_lu_timer' from struct vlr_subscr
It's never used anywhere in the code.

Change-Id: I1b322b57fa0fd17ae2ebe1a2af2d8a93d81e14f0
2020-01-19 03:59:10 +07:00
Vadim Yanitskiy 95c46b11e9 manuals/vty: update the VTY reference to reflect recent changes
Change-Id: I14a5c9adff649406b4a079a75f86167ae6b95db4
2020-01-18 19:25:11 +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
Pau Espin 4a5ba81f7d Bump version: 1.6.0.3-02dd2 → 1.6.1
Change-Id: I3ac4ca12139230863607980cd29250c12df319b7
2020-01-09 12:29:08 +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
Pau Espin 6a0c4d9d24 Bump version: 1.5.0.72-6e72-dirty → 1.6.0
Change-Id: I315ba8c67fbb5bec520f1bc42aedd25d47e4ca95
2020-01-03 18:51:37 +01: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
Oliver Smith 6dbdf1454d osmoappdesc.py, tests: switch to python 3
Make build and external tests work with python3, so we can drop
the python2 dependency.

This should be merged shortly after osmo-python-tests was migrated to
python3, and the jenkins build slaves were (automatically) updated to
have the new osmo-python-tests installed.

Related: OS#2819
Depends: osmo-python-tests I3ffc3519bf6c22536a49dad7a966188ddad351a7
Change-Id: I53ccde96dd3785098df0f7d693c504c8b8302e90
2019-12-12 09:29:19 +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
Vadim Yanitskiy c6b088bf38 counters: polish documentation of cm_service_request / paging_resp
Change-Id: I273bc4165c70cd54ed94ff5f99377189f3306f51
2019-12-02 08:44:42 +00:00
Vadim Yanitskiy 1448052f37 counters: clarify documentation for MSC_CTR_CALL_* entries
Change-Id: Iad1ef917a229c3be51bd8fbe155f009f81e7d72a
2019-12-02 08:44:42 +00:00
Vadim Yanitskiy bc7dabd38d counters: clarify documentation for MSC_CTR_LOC_UPDATE_* entries
Change-Id: I4f4a0d644db0a2dd7c8eefd846ea6913c0b780ce
2019-12-02 08:44:42 +00:00
Vadim Yanitskiy 1ce842de39 counters: clarify documentation for MSC_CTR_SMS_* entries
Please note that counter "sms:delivered" assumes "Delivered MT SMS",
but actually counts total number MT SMS delivery attempts. This
change describes its _actual_ (erroneous) behaviour.

Change-Id: I081cf962ce2658ceab02699f3cdee19658d00939
Related: OS#4273
2019-12-02 08:44:42 +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 22d0ba860d manual: Fix copy+paste error
Change-Id: I2c03d8424c218155dae9038dd7cc5660a290c5c8
2019-12-01 15:31:52 +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 11bf0bc09c msc_vlr_test_call: rename lu_utran_tmsi
Change-Id: I46a41321e6d1be3672a56a6e3cc36f013fdcd396
2019-11-28 02:52:55 +01:00
Neels Hofmeyr 35fb679ab0 msc_vlr_tests: log descriptions in color with -v
Change-Id: I2b28a94a5b27932e343952ba82e7e11c46f5e87d
2019-11-28 02:52:55 +01:00
Neels Hofmeyr 07351d8f78 msc_vlr_test_call.c: add MNCC logging
Change-Id: I03b25c134553c620d3fa9d23a67ad39414546861
2019-11-28 02:52:55 +01:00
Neels Hofmeyr e0f906c42c msc_vlr_tests: better err logging for dtap msgs
Change-Id: I3edd90be40555dd648e9f16db5b6040665a19a95
2019-11-28 02:52:55 +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 3f391dd77d fix msc_vlr_test_call.c
Substantial parts of the CC / MNCC call establishment were so far completely
missing from the msc_vlr_test_call.c tests. With my new insights on CC and MNCC
procedures, complete the tests.

Root reason: since I am going to re-order the sequence of events to enable
codec negotiation via SDP in MNCC, I want to have comprehensive tests of the CC
procedures to see the effect as diffs in the test output.

Change-Id: Ie995e264eb1e3dd9558a1753ff6f9b55c1d084e1
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 82f58fed6a charts: add full MO and MT voice call diagram
Add voice_call_full.msc, generated from a real 2G<->3G voice call log fed to
msc_log_to_ladder.py.

The idea is to document how the voice call sequence of events changes in
upcoming patches.

Change-Id: I8a907d6a4ece1f3ad78da75a8c3e3e76afd5418d
2019-11-01 17:35:17 +01:00
Neels Hofmeyr 0f6664bb3d add msc_log_to_ladder.py
Add script that reads in an osmo-msc log output and extracts the interesting
information for displaying a sequence chart of voice call log, in mscgen
format.

I want to visualize how the sequence of messages changes across patches. It is
error prone to do it manually, and re-doing the sequence chart for every patch
(and patch rework) would be prohibitively time consuming.

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

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

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

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

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

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

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

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

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

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

Change-Id: I1495dd562a06cf6c1e9453a1fe111bdf8f4be081
2019-10-29 16:46:32 +01:00
Oliver Smith a7ec369a28 tests: only check IU configs if IU is enabled
Fix vty tests that are failing since libosmocore change
Ic225232fbfca49ba868427eaf898e1f6e34e1ca8. If OsmoMSC is built without
IU support, it fails with "cs7-instance-iu" in the config.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This error was seen a lot at CCCamp2019.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes: CID#203651
Change-Id: I98fe5860c49751ade1af10d99487aba259504f23
2019-09-02 11:07:49 +02:00
Neels Hofmeyr be5f033475 msc_vlr_tests: GSUP: don't care about extra IEs
To not break the msc_vlr tests by new GSUP IEs added to some of the GSUP
messages, make msc_vlr_tests only match the start of the GSUP message and not
care about extra IEs. The extra IEs are anyway seen in the expected logs.

The reason to drop the msgb_eq_data_print() is because it is useless for
mismatching lengths. It will always print only the length mismatch, instead we
need to be able to compare with what was expected.

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

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

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

Rather send a temporary failure cause code.

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

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

Crash:

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

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

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

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

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

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

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

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

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

Adjust/add to test_nodes.vty transcript tests.

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

Change-Id: Icd02c669cfee6dd7e6b154e303cd0f4c148c83c4
2019-08-12 08:41:34 +00:00
Pau Espin 0218814c8c Bump version: 1.4.0 → 1.5.0
Change-Id: I9b79805c703f4bb860a07bf521ddbf8cb9b29d23
2019-08-08 16:01:38 +02:00
Pau Espin b0504632c5 Fix dependency version requirements
libosmocore 1.1.0 0e8df1c7e48bcae2285c7c138bd50f932049bd24  osmo_use_count()
Fixes: 7c5346cd70

libosmocore 1.2.0 cdac620579b5bf44970b5f4bb11734fdfdf5bf59 GSM23003_MSISDN_MAX_DIGITS
Fixes: 8b0737fa71

libosmo-sccp 1.1.0 21ff9ae4264de159784a59ce4421365007bde08d osmo_sccp_addr_ri_cmp()
Fixes: c4628a3ad4

osmo-mgw 1.6.0 538d2c53d90074267e7a70a90c773baa03d6ec04 mgcp_client_endpoint_fsm.h
Fixes: c4628a3ad4

libosmo-netif 0.6.0 needed by osmo-mgw 1.6.0

libsmpp34 1.14.0 required due to needed heap allocation function overrides from smpp34_heap.h

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

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

Change-Id: I11106cb108a4b1406ff9a8b8ff5761440a274dad
2019-08-08 02:08:55 +02:00
Neels Hofmeyr 7ea0db8f29 doc/sequence_charts: fix naming of mncc_fsm to mncc_call
mncc_fsm.[hc] were renamed to mncc_call.[hc] during patch review, which failed
to carry through to this sequence chart.

Also fix the MNCC_ST_* to MNCC_CALL_ST_* and MNCC_EV_* to MNCC_CALL_EV_*.

Change-Id: I03ee1b43ab95dca3c43fdb9e92dc158aad5a4203
2019-08-05 23:25:17 +02:00
Neels Hofmeyr 62c0a2a4ab doc/sequence_charts/mncc_fsm.msc: add SIP messages, tweak
- add SIP messages, taken from OS#1683
- change some wording and clarify some message ordering
- have a separate sipcon1 and sipcon2 for the MO and MT sides

Change-Id: I6782e416dbd8ee88d093cbef722b0c5084f3865c
2019-08-05 23:25:16 +02:00
Neels Hofmeyr 14c34d8bec add msc_vlr tests for UMTS without ciphering
Following I04ecd7a3b1cc603b2e3feb630e8c7c93fc36ccd7, have tests for UMTS
authentication both for cases with and without encryption.

- Rename test_umts_authen_utran to test_umts_auth_ciph_utran() (uses
  encryption).
- Again add test_umts_authen_utran() not using encryption.
- Likewise with test_umts_authen_resync_utran().

Some permutations are still missing, like UMTS AKA on GERAN with encryption
enabled; not bothering at the moment.

Related: OS#2783
Change-Id: I54227f1f08c38c0bf69b9c48924669c4829b04b9
2019-08-05 23:24:47 +02:00
Neels Hofmeyr a4d7a76816 do not force encryption on UTRAN
Remove the conditions that always enable encryption on UTRAN.

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

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

Adjust manual and vty doc.

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

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

The Release indication needs to have the Coding Standard set.

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

Change-Id: Ib28b62a41d433e231cff5910d19455296b284df6
2019-08-02 08:08:33 +00:00
Neels Hofmeyr 4014e481d4 minor comments in msc_vty.c
Change-Id: I83d8c778190adb1e74debc8f8ddac6996de7c513
2019-07-29 18:39:50 +02:00
Pau Espin 637fc0218b doc: Add Osmux documentation to User Manual
Depends: osmo-gsm-manuals.git f3a734e6777a902abfb03257277454c7a879aeb7
Change-Id: I70c488c3d9b05599b834a8608e6361c8aa43ef31
2019-07-25 10:39:07 +00:00
Oliver Smith c0a5e71d0e vlr_lu_fsm.c: don't send LU reject twice
Don't call tx_lu_rej() in the "vlr_lu_compl" FSM. It is always getting
called in the parent "lu" FSM and is therefore redundant:

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

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

[1] I836f76242463789c4c003feec757714827f2a31b (osmo-ttcn3-hacks)
Change-Id: I127b27937613ea0ff29d67991c0414fca6d441d9
2019-07-24 09:08:22 +02:00
Eric Wild fdda613af5 turn -Werror=null-dereference into a warning
There is unfortunately no way to suppres this witha pragma,
and gcc 9 uncovers quite a few new instaces with enabled LTO that can't/won't be fixed

Related: OS#4123
Change-Id: I615bb5be3671022c6b821575a61f945b50e8f2a5
2019-07-22 19:56:56 +00:00
Alexander Couzens efa7b97133 replace osmo_counter with stat_items
osmo_counter will be soon deprecated. Use the newer and more flexible
osmo_stat_item instead.

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

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

This change makes the failing SMS related test cases pass.

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

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

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

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

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

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

Change-Id: I2ead2241a3394dbdd5417f4554190df3fd698af2
2019-06-19 14:36:28 +07:00
Vadim Yanitskiy 188dd5f4df tests/msc_vlr: fix: do not pass RAT type to expect_bssap_clear()
The function name implies OSMO_RAT_GERAN_A, and it has nothing
to do with other OSMO_RAT_* types. Found using clang:

  warning: too many arguments in call to 'expect_bssap_clear'
           expect_bssap_clear(OSMO_RAT_GERAN_A);
	                      ^^^^^^^^^^^^^^^^

Change-Id: Id3a3af33fcc5da4ca4c48a2f589a69f3568d2586
2019-06-19 02:05:08 +07:00
Daniel Willmann 7a2c9c91e9 manuals: Include overview chapter about counters
Change-Id: I8c3e8bcda27f35118ab0e3d75621a02eec86f15c
2019-06-18 18:07:43 +02:00
Daniel Willmann fb73e0c654 manuals: Update counter/vty documentation
Change-Id: I1ef0e8ae166d7fdc5e85716a961e8387d26bdd2c
Related: OS#1700
2019-06-18 12:51:07 +00:00
Daniel Willmann a794ff4f46 manuals: Add script to update vty/counter documentation from docker
Change-Id: I3f5573f81460b40d4606fbcf0febcfd078a7bdca
Related: OS#1700
2019-06-18 12:51:07 +00:00
Vadim Yanitskiy b3bdc768be libmsc/gsm_09_11.c: do not suppress rc of gsup_client_mux_tx()
Change-Id: Ide2440188fb6fe1c54681fef8ec4fed9e6da66e2
2019-06-17 22:23:09 +07:00
Vadim Yanitskiy 6632251572 libmsc/gsm_09_11.c: do not abuse LOG_TRANS() in gsm0911_rcv_nc_ss()
If we 100% sure that trans == NULL, it makes more sense to use
generic LOGP(DSS, LOGL_*, ...) call, so the logs can reflect
more information than such dummy prefix:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  SELECT .. FROM SMS ORDER BY valid_until LIMIT 1;

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

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

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

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

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

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

[1] I545967464c406348b8505d1729213cfb4afcd3e2

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

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

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

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

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

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

Change-Id: Ibbd588545e1a4817504c806a3d02cf59d5938ee2
Related: OS#3684
2019-06-06 19:45:20 +00:00
Pau Espin 4474f35770 db_sms_test: Remove libdbi expected driver load errors
Newer versions of libdbi print to stderr unconditionally when trying to
load drivers from /usr/lib/dbd. This makes test output to change
depending on host/distro set up (installed modules).

Let's get those messages out to make it easier for people having tests
pass.

We swap stderr/stdout instead of mixing to avoud future possible race
conditions if both get content writen into them.

Change-Id: Iec78826d28435f464be22e81b3776a6ae8326d59
2019-06-05 17:01:06 +00:00
Vadim Yanitskiy f523f22899 debian/control: add missing libdbd-sqlite3 to Build-Depends
The libdbd-sqlite3 provides SQLite3 driver for libdbi. We use it
by default for the built-in SMS Centre. Since [1], we have unit
test coverage for the db_sms_* API, thus we need libdbd-sqlite3
to be installed at build-time.

[1] Id94ad35b6f78f839137db2e17010fbf9b40111a3

Change-Id: Ice9fb11f5b8a39abecee426d2fadcf62b7ee47c4
2019-06-05 18:31:53 +07:00
Pau Espin 17aa464b99 db_sms_test: Do not print exact memcmp result
man memcp doesn't define exact values for returned integer, it only
specifices a meaning for the sign of it.
So it happens that different versions/implementations actually return
different values when this test is run, making it fail.
Let's simply drop that info from logs since anyways it's not useful.

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

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

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

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

  ...

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

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

Observed with:

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

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

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

  - db_sms_store(),
  - db_sms_get(),

  - db_sms_get_next_unsent(),
  - db_sms_mark_delivered(),

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

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

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

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

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

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

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

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

Change-Id: Id94ad35b6f78f839137db2e17010fbf9b40111a3
2019-06-03 17:28:35 +07:00
Vadim Yanitskiy 98f0675ffc tests: share stubs.h from msc_vlr_test as stubs.c
We also need stubs for the upcoming db_sms tests.

Due to a known bug of automake [1], we cannot use 'subdir-objects',
so as a side effect this change introduces some autoreconf warnings.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752993

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

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

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

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

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

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

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

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

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

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

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

  show connection trans

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

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

another example is:

  show subscriber cache conn+trans

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

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

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

Change-Id: I5e58b56204c3f3d019e8d4c3c96cefdbb4af4d47
2019-06-03 07:18:41 +00:00
Oliver Smith a2273f5f1d debian: create -doc subpackage with pdf manuals
I have verified, that the resulting debian packages build in my own OBS
namespace (see the -doc packages):
https://download.opensuse.org/repositories/home:/osmith42/Debian_9.0/all/
https://build.opensuse.org/project/show/home:osmith42

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

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

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

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

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

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

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

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

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

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

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

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

[1] Change-Id I256224194c3b8caf2b58a88d11dccd32c569201f

Related: OS#2542
Change-Id: I02e7b66848bf7dddb31b105e2ae981432817ae1e
2019-05-15 10:57:43 +02:00
Oliver Smith d103705f01 vlr: fix IMEI length
Set the length of vlr_subscr->imei to
	GSM23003_IMEI_NUM_DIGITS_NO_CHK (14)
instead of
	GSM23003_IMEISV_NUM_DIGITS (16).

Note that there is also GSM23003_IMEI_NUM_DIGITS (15), which includes
an additional checksum digit. This digit is not intended for digital
transmission, so we don't need to store it. Also by not storing it, we
can simply copy the IMEI-part from the IMEISV to the IMEI without
worrying about the checksum (will be done in a follow up patch).

A good overview of the IMEI/IMEISV structure is here:
https://en.wikipedia.org/wiki/International_Mobile_Equipment_Identity#Structure_of_the_IMEI_and_IMEISV_(IMEI_software_version)

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

Related: OS#2542, OS#3755
Change-Id: I256224194c3b8caf2b58a88d11dccd32c569201f
2019-05-15 08:43:39 +00:00
Vadim Yanitskiy d24c46a38b libmsc/ran_peer.c: avoid unreasonable use of goto in ran_peer_down_paging()
Change-Id: I3320240d8f1dc318e516162bb32e01ddafc7e30e
2019-05-14 21:49:47 +07:00
Vadim Yanitskiy ede95d18b3 libmsc/ran_peer.c: fix msgb memleaks in ran_peer_down_paging()
Change-Id: I1e76b5eab7cfa091375bd9c76d8dcdec8d16ffe5
2019-05-14 21:41:06 +07:00
Sylvain Munaut 762bb042ec make LOG_TRANS() NULL-safe again
Previous patch [1] removed NULL-safety from LOG_TRANS(). Fix that.

In case a trans is NULL, it is fine to log in the DMSC category, since the
context should still be general (erratic message or other initial problems).

[1] 7f85acea9b / I6dfe5b98fb9e884c2dde61d603832dafceb12123
    "LOG_TRANS: store subsys in trans, unify USSD logging back to DMM"

Change-Id: I6e36c47bf828dd073b36c6301bbeabcc28e101e6
2019-05-14 09:18:10 +00:00
Oliver Smith ffd522ec6f vlr_lu_fsm.c: assert for invalid events
In state machine callback functions, instead of logging an error when
an invalid event arrives, do OSMO_ASSERT(0).

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

Change-Id: I278bb72660634c2d535e1bd3d7fce5696da23575
Fixes: CID#198450 Out-of-bounds access
2019-05-13 20:15:04 +00:00
Vadim Yanitskiy 18e8b39fcd libmsc/ran_msg_a.c: refactor ran_a_decode_lcls_notification()
We basically need to make sure that one of two possible IEs
is not NULL, while another is NULL (eXclusive OR). This can
be done using at least two conditional branches.

Change-Id: Ie0f9b5c1bbbfb744e0615da07d76037d91b0abc8
Fixes: CID#198444 Logically dead code
2019-05-13 20:15:04 +00:00
Vadim Yanitskiy bfe8eb7620 libmsc/ran_msg_a.c: avoid ternary operator in struct initialization
For some reason, having ternary operator there makes Coverity think
that 'n->geran.chosen_encryption' is dereferenced before checking
against NULL. Let's make it happy, and move the assignment.

Change-Id: I95051d0f02e2fdd3ec8da3a506109e7b23e99b4b
Fixes: CID#198454 Dereference before null check
2019-05-13 20:15:04 +00:00
Vadim Yanitskiy 36c8153999 libmsc/gsm_04_11.c: fix NULL-pointer dereference in gsm340_rx_tpdu()
Change-Id: I1e9b351e949efe596295d18f98c8a73c8e013763
Fixes: CID#198451
2019-05-13 20:15:04 +00:00
Vadim Yanitskiy 678354f6ba sms_queue_test: assert return value of osmo_use_count_get_put()
Change-Id: I9381e88435ccd856ec619135ca9999c15c25d436
Fixes: CID#198416
2019-05-13 20:15:04 +00:00
Vadim Yanitskiy 4dd477f16c libmsc/msc_a.c: fix possible NULL-pointer dereferences
Change-Id: Id5c95fbf318a2e51e7ffee2e08ceab3042b26cc9
Fixes: CID#198411, CID#198414
2019-05-13 20:15:04 +00:00
Vadim Yanitskiy a870faf674 libmsc/msc_ho.c: fix unreacheable check of MSC-T role allocation
Change-Id: I46fa37ff27e8a4576fdc8edad894ee16759a6e7a
Fixes: CID#198413
2019-05-13 20:15:04 +00:00
Vadim Yanitskiy 48a24cd85b libmsc/sgs_server.c: do not override rc in case of SCTP_SHUTDOWN_EVENT
Change-Id: I06215a7d3dc33f2e8adb77fa1b3f2ac5198dee26
Fixes: CID#190867
2019-05-13 20:15:04 +00:00
Vadim Yanitskiy dcd709948c tests/.../Makefile.am avoid redundant linkage with librt
The librt is required for old glibc < 2.17 to get clock_gettime().
Since we do check the availability of this function libosmocore
and conditionally link it against librt, there is no need to do
such unconditional and redundant linkage here.

Change-Id: If587d16d2db677b97e3a0641027eb735af9c9c30
2019-05-13 16:56:02 +07:00
Vadim Yanitskiy 59ed7920eb libmsc/gsm_04_11_gsup.c: cosmetic: drop useless variable
Change-Id: I102e1bd0f8365e77bbc9203158909aad8dcf214b
2019-05-12 15:48:51 +00:00
Vadim Yanitskiy 4456065dfe libmsc/gsm_04_08.c: clarify IMEI rejection in gsm48_rx_mm_serv_req()
Change-Id: I65277aee1f52a8b4fd4b970e992482bbadd94d39
2019-05-12 10:35:18 +00:00
Vadim Yanitskiy b380a8c938 libmsc/gsm_04_08.c: refactor CM Service Request parsing
In gsm48_rx_mm_serv_req() we need to make sure that a given message
buffer is large enough to contain both 'gsm48_hdr' and
'gsm48_service_request' structures.

Comparing msg->data_len with size of pointer if wrong because:

  - we actually need to compare with size of struct(s),
  - we need msgb_l3len(), not length of the whole buffer.

Moreover, since we have to use the pointer arithmetics in order
to keep backwards compatibility with Phase1 phones, we also
need to check the length of both Classmark2 and MI IEs.

Change-Id: I6e7454d7a6f63fd5a0e12fb90d8c58688da0951e
2019-05-12 10:35:18 +00:00
Vadim Yanitskiy 2fca80ea56 libmsc/gsm_04_08.c: fix: print proper length value
Since in parse_umts_auth_resp() we are checking the length of
GSM48_IE_AUTH_RES_EXT TLV, we need to print its length, but
not the length of the whole L3.

Change-Id: I2bfebce6d017be834bfe7628ffa2b341eb82c11c
2019-05-12 10:35:18 +00:00
Neels Hofmeyr 0a437be0e3 silence error messages about HANDOVER_END not permitted
The MSC_A_EV_HANDOVER_END exists as parent term event for the msc_ho_fsm, but
it is not actually required as functional event, since all cleanup is handled
in msc_ho_fsm_cleanup().

That's why I never bothered to add the event to msc_a_fsm, but of course that
means we get an error message after each (successful and unsuccessful)
handover, that the MSC_A_EV_HANDOVER_END is not permitted.

Allow the event and ignore it to silence the error message.
Explain in a comment.

Change-Id: Ie8dc0c0a631b7da43111f329562007766a21b134
2019-05-12 10:33:20 +00:00
Neels Hofmeyr 979b057ad7 add DSS logging category
Change-Id: Id7e04c9f5088334cd5ec6cfdb6a9b3a2a7e7fda0
2019-05-12 10:32:42 +00:00
Vadim Yanitskiy 6a689b2b5b libmsc/gsm_04_11.c: cosmetic: restructure gsm411_mm_send()
Change-Id: I22e99f40ab2252a0b716969091e4d24b3b4268a2
2019-05-12 04:17:45 +07:00
Vadim Yanitskiy c11342ec4e libmsc/gsm_04_11.c: fix double init of both SMR and SMC FSMs
Change-Id: I23700a2c575a96057ef22bc5d8ab6271104d619b
2019-05-12 04:17:20 +07:00
Harald Welte 4dd150afa3 Iu: Send SMS over SAPI-3
After neels/ho was merged, SMS over IuCS/RANAP was failing in both
MO and MT direction.  The reason was that all mobile-terminated SMS-CP
layer messages were sent in RANAP with SAPI-0 instaed of SAPI-1.

Change-Id: I98e6eddb52d5c61c4e2d34bdfcd43cf460296ad7
Closes: OS#3993
2019-05-10 23:56:49 +02:00
Neels Hofmeyr f50d13045e call_leg: document the parent_event_* items
Change-Id: Ib099178a0f6ab218646c67c0e7a3d360c81af684
2019-05-10 07:13:53 +00:00
Neels Hofmeyr 265a4c7489 call_leg: remove unused event MSC_EV_CALL_LEG_RTP_RELEASED
The event is actually never dispatched and useless, because when an RTP stream
releases, the call_leg terminates directly anyway (which wasn't apparent when
starting to design the call_leg FSM yet).

Change-Id: I6b2fc1225c960fa2f7c46adf241520217a07821c
2019-05-10 07:13:41 +00:00
Harald Welte c0847d641c SMPP: Don't accept password or system-id exceeding spec length
The SMPP 3.4 specification defines the password field as a
"Variable-length octet string with maximum length of 9", and according
to table 3-1 this means including the terminating NUL-byte.

However, OsmoMSC allows to configure longer passwords in the ESME
configuration. Those passwords will then never match, as libsmpp34
performs length validation and generates a parser error for anyone
trying to send a longer password via SMPP.

The same applies for system-id, where we have to permit only 15
characters with zero termination, but not 16 characters.

Change-Id: I81ef593e84bf1e15f6746386fc145495fae29354
Closes: OS#3166
2019-05-10 07:07:00 +00:00
Neels Hofmeyr 7f85acea9b LOG_TRANS: store subsys in trans, unify USSD logging back to DMM
Instead of calling trans_log_subsys() for each LOG_TRANS() log line, rather
store in trans->log_subsys once on trans_alloc() and use that.

Do not fall back to the RAN's own subsystem (DBSSAP / DIUCS), it makes little
sense and may cause logging to switch subsystems depending on the RAN state.

In trans_log_subsys(), add missing switch cases:

- Log silent call transactions also on CC.
- Log USSD on DMM.

About USSD: we currently have no dedicated USSD logging category. As a result,
after LOG_TRANS() was introduced [1], USSD logged on DBSSAP/DIUCS or DMSC,
depending on whether a RAN was associated with the trans or not. Before that
change, USSD always logged on DMM, so, until we have a separate logging
category for USSD, consistenly use DMM again.

[1] in I2e60964d7a3c06d051debd1c707051a0eb3101ba / ff7074a0c7

Related: coverity CID 198453
Change-Id: I6dfe5b98fb9e884c2dde61d603832dafceb12123
2019-05-10 07:04:50 +00:00
Neels Hofmeyr da3ce717b8 no HO call forwarding if no RTP stream
Fixes: coverity CID 198447
Related: OS#3992 (does not fix, just related)
Change-Id: Ia223c2e20e625879ab71fc5c8afd0305fd224c58
2019-05-10 07:04:50 +00:00
Neels Hofmeyr 911e5979ed make msc_a_vsub() and others NULL-safe
Fixes: coverity CID 198451
Change-Id: Icd146ae512236a09cad080ed3eb85944e8f5cee4
2019-05-10 07:04:50 +00:00
Neels Hofmeyr 4deb8c9ea0 ran_a_make_handover_request(): allow no encryption
Fixes: coverity CID 198454
Change-Id: Ifb83ab2a8b6148b457224687ffada2dff4c3204f
2019-05-10 07:04:50 +00:00
Vadim Yanitskiy 4eca09fdb1 libmsc/gsm_04_11.c: properly handle TP-User-Data-Length
As per 3GPP TS 03.40, section 9.2.3.16 "TP-User-Data-Length (TP-UDL)",
if the TP-User-Data is coded using the GSM 7-bit default alphabet,
the TP-User-Data-Length field indicates the *number of septets*
within the TP-User-Data field to follow. Otherwise, i.e. in case
of 8-bit or UCS-2 encoded data, the *number of octets* is indicated.

Since we store the original TP-UDL value (as received), we might
need to convert septets to octets before passing it to memcpy().
Otherwise this would lead to a buffer overrun.

Also, as we receive TPDU from untrusted source (i.e. subscriber),
the TP-UDL value needs to be checked against the corresponding
maximum (160 septets or 140 octets) and truncated if needed.

Please note that buffer overrun is still possible, e.g. when an
indicated TP-UDL value is grather than the remaining TPDU length.
Preventing this would require adding an additional check.

Change-Id: I4b08db7665e854a045129e7695e2bdf296df1688
Depends-on: (core) I54f88d2908ac47228813fb8c049f4264e5145241
2019-05-10 03:22:32 +07:00
Vadim Yanitskiy 53d3e0e54a libmsc/ran_peer.c: fix msgb memleak in ran_peer_rx_reset()
It was noticed that SCCP_RAN_MSG_RESET_ACK message is not freed after
sending. Since ran_peer_rx_reset() calls sccp_ran_down_l2_cl(), which
then calls osmo_sccp_user_sap_down_nofree(), which doesn't free the
message buffer (what's clear from its name).

  OsmoMSC# show talloc-context application full filter msgb
  full talloc report on 'osmo_msc' (total  20155 bytes in  88 blocks)
    msgb                  contains   4640 bytes in   5 blocks (ref 0)
      bssmap: reset ack   contains   1160 bytes in   1 blocks (ref 0)
      bssmap: reset ack   contains   1160 bytes in   1 blocks (ref 0)
      bssmap: reset ack   contains   1160 bytes in   1 blocks (ref 0)

Let's free it after sending (or in case of error).

Change-Id: Ic174f6eecd6254af597dfbdc1c9e3d65716f0a76
2019-05-10 02:56:07 +07:00
Neels Hofmeyr f839967f91 comment: apply function renames to message cycle explanation
The misnomed 'nas_decode' and 'nas_encode' APIs have been renamed to
'ran_decode' and 'ran_encode', which was forgotten in the large comment
explaining the message path in sccp_ran.h. Apply the rename there.

Change-Id: I742fb4844ac8a9ad76f59883ae9447eb8819b82d
2019-05-09 11:45:59 +00:00
Harald Welte db6855c9f9 msub_check_for_release(): Initialize msc_role_a_c
This fixes the following compiler error:

msub.c: In function ‘msub_fsm_active’:
msub.c:85:35: error: ‘msc_role_a_c’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
   || (msc_role_a_c && msc_role_a_c->ran->type == OSMO_RAT_EUTRAN_SGS)))
                       ~~~~~~~~~~~~^~~~~
msub.c:59:26: note: ‘msc_role_a_c’ was declared here
  struct msc_role_common *msc_role_a_c;
                          ^~~~~~~~~~~~

Change-Id: Id518dea77d01ed0518ca7cba6b1b363f1c8e6543
2019-05-09 08:42:48 +00:00
Neels Hofmeyr 880b950862 vty/cfg: add missing write-back of inter-BSC and inter-MSC HO config
Add missing 'show running-config' test to test_neighbor_ident.vty transcript
test.

Change-Id: Ie3b084e169da9509b37f6ab91ade79440c1b36d2
2019-05-09 02:06:42 +02:00
Neels Hofmeyr 5255874529 fix regression: fix internal MNCC operation
While developing the inter-MSC handover refactoring, I was annoyed by the fact
that mncc_tx_to_cc() receives an MNCC message struct containing a msg_type, as
well as a separate msg_type argument, which may deviate from each other. So, as
a first step I wanted to make sure that all callers send identical values for
both by inserting an OSMO_ASSERT(msg_type == msg->msg_type). Later I was going
to remove the separate msg_type argument.

I then forgot to
- carry on to remove the argument and
- to actually test with internal MNCC (it so happens that all of our ttcn3
  tests also use external MNCC).

As a result, the "large refactoring" patch for inter-MSC Handover breaks
internal MNCC operation.

Fix that: remove the separate msg_type argument and make sure that all callers
of mncc_tx_to_cc() indeed pass the desired msg_type in msg->msg_type, and hence
also remove the odd duality of arguments.

Various functions in mncc_builtin.c also exhibit this separate msg_type
argument, which are all unused and make absolutely no sense. Remove those as
well.

Related: OS#3989
Change-Id: I966ce764796982709ea3312e76988a95257acb8d
2019-05-09 01:23:09 +02:00
Harald Welte e39f6cd752 smpp: Make libsmpp34 use talloc for its allocations
We are just introducing smpp34_set_memory_functions() in libsmpp34
to allow applications like OsmoMSC to provide their own heap allocator
callback functions.  Let's used this to integrate with talloc and
hence allow talloc tracking/debugging for libsmpp34 internal
allocations.

Depends: libsmpp34 Change-Id I3656117115e89638c093bfbcbc4369ce302f7a94
Change-Id: Ie2725ffab6a225813e65768735f01678e2022128
Related: OS#3913
2019-05-08 23:49:45 +02:00
Neels Hofmeyr 4ac8009c29 rename bscconfig.h to config.h, cleanup
Get rid of the legacy name bscconfig.h from osmo-nitb times.

Remove the #include from some of the files that aren't actually using it.

Instead of '#include "../../config.h"', use plain '#include "config.h"'
because we're anyway passing $top_srcdir as -I during compilation.

Change-Id: Id4f683be1f36f0630c83da54e02868aae847aeec
2019-05-08 17:02:32 +02:00
Neels Hofmeyr e27fa15022 GSUP: include terminating nul in inter-MSC source/destination name
Before, I was testing with osmo-hlr patch
I01a45900e14d41bcd338f50ad85d9fabf2c61405 applied, but that patch is currently
in an abandoned state.

This is the counterpart implemented in osmo-msc: always include the terminating
nul char in the "blob" that is the MSC IPA name.

The dualities in the formats of routing between MSCs is whether to handle it as
a char*, or as a uint8_t* with explicit len (a blob).

In the VTY config to indicate target MSCs for inter-MSC handover, we have
strings. We currently even completely lack a way of configuring any blob-like
data as a VTY config item.

In osmo-hlr, the IPA names used for routing are currently received as a char*
which *includes* the terminating nul char. So in osmo-msc, if we also always
include the nul char, it works.

Instead, we could just send the char* part without the nul char, and apply
above mentioned osmo-hlr patch. That patch would magically match a name that
lacks a nul with a name that includes one. I think it is better to agree on one
format on the GSUP wire now, instead of making assumptions in osmo-hlr on the
format of the source/target names for routing. This format, from the way GSUP
so far transmits the IPA SERNO tag when a client attaches to osmo-hlr, happens
to include the terminating nul char.

Change-Id: I9ca8c9eef104519ed1ea46e2fef46dcdc0d554eb
2019-05-08 17:02:32 +02:00
Neels Hofmeyr c4628a3ad4 large refactoring: support inter-BSC and inter-MSC Handover
3GPP TS 49.008 '4.3 Roles of MSC-A, MSC-I and MSC-T' defines distinct roles:
- MSC-A is responsible for managing subscribers,
- MSC-I is the gateway to the RAN.
- MSC-T is a second transitory gateway to another RAN during Handover.

After inter-MSC Handover, the MSC-I is handled by a remote MSC instance, while
the original MSC-A retains the responsibility of subscriber management.

MSC-T exists in this patch but is not yet used, since Handover is only prepared
for, not yet implemented.

Facilitate Inter-MSC and inter-BSC Handover by the same internal split of MSC
roles.

Compared to inter-MSC Handover, mere inter-BSC has the obvious simplifications:
- all of MSC-A, MSC-I and MSC-T roles will be served by the same osmo-msc
  instance,
- messages between MSC-A and MSC-{I,T} don't need to be routed via E-interface
  (GSUP),
- no call routing between MSC-A and -I via MNCC necessary.

This is the largest code bomb I have submitted, ever. Out of principle, I
apologize to everyone trying to read this as a whole. Unfortunately, I see no
sense in trying to split this patch into smaller bits. It would be a huge
amount of work to introduce these changes in separate chunks, especially if
each should in turn be useful and pass all test suites. So, unfortunately, we
are stuck with this code bomb.

The following are some details and rationale for this rather huge refactoring:

* separate MSC subscriber management from ran_conn

struct ran_conn is reduced from the pivotal subscriber management entity it has
been so far to a mere storage for an SCCP connection ID and an MSC subscriber
reference.

The new pivotal subscriber management entity is struct msc_a -- struct msub
lists the msc_a, msc_i, msc_t roles, the vast majority of code paths however
use msc_a, since MSC-A is where all the interesting stuff happens.

Before handover, msc_i is an FSM implementation that encodes to the local
ran_conn. After inter-MSC Handover, msc_i is a compatible but different FSM
implementation that instead forwards via/from GSUP. Same goes for the msc_a
struct: if osmo-msc is the MSC-I "RAN proxy" for a remote MSC-A role, the
msc_a->fi is an FSM implementation that merely forwards via/from GSUP.

* New SCCP implementation for RAN access

To be able to forward BSSAP and RANAP messages via the GSUP interface, the
individual message layers need to be cleanly separated. The IuCS implementation
used until now (iu_client from libosmo-ranap) did not provide this level of
separation, and needed a complete rewrite. It was trivial to implement this in
such a way that both BSSAP and RANAP can be handled by the same SCCP code,
hence the new SCCP-RAN layer also replaces BSSAP handling.

sccp_ran.h: struct sccp_ran_inst provides an abstract handler for incoming RAN
connections. A set of callback functions provides implementation specific
details.

* RAN Abstraction (BSSAP vs. RANAP)

The common SCCP implementation did set the theme for the remaining refactoring:
make all other MSC code paths entirely RAN-implementation-agnostic.

ran_infra.c provides data structures that list RAN implementation specifics,
from logging to RAN de-/encoding to SCCP callbacks and timers. A ran_infra
pointer hence allows complete abstraction of RAN implementations:

- managing connected RAN peers (BSC, RNC) in ran_peer.c,
- classifying and de-/encoding RAN PDUs,
- recording connected LACs and cell IDs and sending out Paging requests to
  matching RAN peers.

* RAN RESET now also for RANAP

ran_peer.c absorbs the reset_fsm from a_reset.c; in consequence, RANAP also
supports proper RESET semantics now. Hence osmo-hnbgw now also needs to provide
proper RESET handling, which it so far duly ignores. (TODO)

* RAN de-/encoding abstraction

The RAN abstraction mentioned above serves not only to separate RANAP and BSSAP
implementations transparently, but also to be able to optionally handle RAN on
distinct levels. Before Handover, all RAN messages are handled by the MSC-A
role.  However, after an inter-MSC Handover, a standalone MSC-I will need to
decode RAN PDUs, at least in order to manage Assignment of RTP streams between
BSS/RNC and MNCC call forwarding.

ran_msg.h provides a common API with abstraction for:

- receiving events from RAN, i.e. passing RAN decode from the BSC/RNC and
  MS/UE: struct ran_dec_msg represents RAN messages decoded from either BSSMAP
  or RANAP;
- sending RAN events: ran_enc_msg is the counterpart to compose RAN messages
  that should be encoded to either BSSMAP or RANAP and passed down to the
  BSC/RNC and MS/UE.

The RAN-specific implementations are completely contained by ran_msg_a.c and
ran_msg_iu.c.

In particular, Assignment and Ciphering have so far been distinct code paths
for BSSAP and RANAP, with switch(via_ran){...} statements all over the place.
Using RAN_DEC_* and RAN_ENC_* abstractions, these are now completely unified.

Note that SGs does not qualify for RAN abstraction: the SGs interface always
remains with the MSC-A role, and SGs messages follow quite distinct semantics
from the fairly similar GERAN and UTRAN.

* MGW and RTP stream management

So far, managing MGW endpoints via MGCP was tightly glued in-between
GSM-04.08-CC on the one and MNCC on the other side. Prepare for switching RTP
streams between different RAN peers by moving to object-oriented
implementations: implement struct call_leg and struct rtp_stream with distinct
FSMs each. For MGW communication, use the osmo_mgcpc_ep API that has originated
from osmo-bsc and recently moved to libosmo-mgcp-client for this purpose.
Instead of implementing a sequence of events with code duplication for the RAN
and CN sides, the idea is to manage each RTP stream separately by firing and
receiving events as soon as codecs and RTP ports are negotiated, and letting
the individual FSMs take care of the MGW management "asynchronously". The
caller provides event IDs and an FSM instance that should be notified of RTP
stream setup progress. Hence it becomes possible to reconnect RTP streams from
one GSM-04.08-CC to another (inter-BSC Handover) or between CC and MNCC RTP
peers (inter-MSC Handover) without duplicating the MGCP code for each
transition.

The number of FSM implementations used for MGCP handling may seem a bit of an
overkill. But in fact, the number of perspectives on RTP forwarding are far
from trivial:
- an MGW endpoint is an entity with N connections, and MGCP "sessions" for
  configuring them by talking to the MGW;
- an RTP stream is a remote peer connected to one of the endpoint's
  connections, which is asynchronously notified of codec and RTP port choices;
- a call leg is the higher level view on either an MT or MO side of a voice
  call, a combination of two RTP streams to forward between two remote peers.

  BSC                 MGW                PBX
                CI          CI
                [MGW-endpoint]
  [--rtp_stream--]          [--rtp_stream--]
  [----------------call_leg----------------]

* Use counts

Introduce using the new osmo_use_count API added to libosmocore for this
purpose. Each use token has a distinct name in the logging, which can be a
globally constant name or ad-hoc, like the local __func__ string constant.  Use
in the new struct msc_a, as well as change vlr_subscr to the new osmo_use_count
API.

* FSM Timeouts

Introduce using the new osmo_tdef API, which provides a common VTY
implementation for all timer numbers, and FSM state transitions with the
correct timeout. Originated in osmo-bsc, recently moved to libosmocore.

Depends: Ife31e6798b4e728a23913179e346552a7dd338c0 (libosmocore)
         Ib9af67b100c4583342a2103669732dab2e577b04 (libosmocore)
	 Id617265337f09dfb6ddfe111ef5e578cd3dc9f63 (libosmocore)
	 Ie9e2add7bbfae651c04e230d62e37cebeb91b0f5 (libosmo-sccp)
	 I26be5c4b06a680f25f19797407ab56a5a4880ddc (osmo-mgw)
	 Ida0e59f9a1f2dd18efea0a51680a67b69f141efa (osmo-mgw)
	 I9a3effd38e72841529df6c135c077116981dea36 (osmo-mgw)
Change-Id: I27e4988e0371808b512c757d2b52ada1615067bd
2019-05-08 17:02:32 +02:00
Neels Hofmeyr 56f90132b8 gsm_04_11: use gsm48_decode_bcd_number2(), evaluate rc
Avoid deprecation warning: use gsm48_decode_bcd_number2() instead of
gsm48_decode_bcd_number().

Validate the return value and add error handling.

Change-Id: Ibef71c46d72d2d43123e68f73e5ed554a69243d8
2019-05-08 01:51:06 +02:00
Neels Hofmeyr 5b1e0309b5 fix various missing line endings in logging
Change-Id: I013eb0eeb5673c06034465020e5dc5230f45ddf5
2019-05-06 23:45:28 +02:00
Neels Hofmeyr 08aae21fca vlr subscr get/put: also check against NULL
Change-Id: I36929a4ba4abb46909181068d1d0af967b1f5a94
2019-04-26 18:55:25 +00:00
Vadim Yanitskiy 03e8754960 libmsc/gsm_04_11.c: clarify implicit CP-ACK handling
Change-Id: I3c5327a5019590c65d0ccb33a52f07b3988ea952
2019-04-25 20:01:19 +00:00
Vadim Yanitskiy baccf3a74b libmsc/db.c: print info about database name and libdbi version
Change-Id: Iaed452548eb2d847738b78d3489bf6f507a2e3c1
2019-04-25 21:24:19 +02:00
Vadim Yanitskiy bfd45d514d configure.ac: drop useless SQLite3 dependency
We don't use SQLite3 directly, we use libdbi and libdbdsqlite3.

Change-Id: Ibf4eb53e60a2957eca99a2c8e613f75a8c43ac89
2019-04-25 21:23:35 +02:00
Philipp Maier bb5ba8b7df vlr_sgs_fsm: make sure vsub is marked used when LA is present
When the LU is accepted and the subscriber (vsub) is not claimed as "in
use" in the ref counting system.

- Make sure vlr_subscr_get() is called when the LU is accepted.

Change-Id: Iba90be095569cc5212c61ab8e8a9bfd4ae51fd44
Related OS#3934
2019-04-17 12:50:07 +02:00
Vadim Yanitskiy a45e7458e3 configure.ac: drop rudimentary check for -fvisibility=hidden
This looks like a rudiment from OpenBSC, where we have:

  #define BSC_API __attribute__((visibility("default")))

However, we don't use this attribute in OsmoMSC.

Change-Id: Ie2f18e9b47eca478f6e4702606068814546e34ce
2019-04-15 15:04:48 +00:00
Neels Hofmeyr 0714002e28 smpp: fix vlr_subscr use count bugs
In smpp_openbsc.c submit_to_sms(), "get" the appropriate use count upon
assigning sms->receiver, fixing a -1 use count upon sms_free().

Also, avoid a "put" of a NULL subscriber in the same function.

Related: OS#3930
Change-Id: Idaf01cd3cfa08088ce0d543d0576db957dc94262
2019-04-15 13:46:47 +02:00
Omar Ramadan e2bd9eb37d Allow MME name preformatted as FQDN in SGsAP
Change-Id: I2d55f9524b9fc15d661e5cb6b5df6d715c52ccf9
2019-04-13 21:55:18 +00:00
Neels Hofmeyr c65cfe8696 gsm_04_08_cc: improve logging for CC trans
Pass trans around more functions as log context.
Add missing "rx" logging for two cases.

Change-Id: If79f724a2faca70023271398c618cfe490fb294e
2019-04-12 02:15:25 +02:00
Neels Hofmeyr ff7074a0c7 add LOG_TRANS, proper context for all transactions
Change-Id: I2e60964d7a3c06d051debd1c707051a0eb3101ba
2019-04-12 02:15:25 +02:00
Neels Hofmeyr 7c5346cd70 vlr_subscr: use osmo_use_count
Depends: Ife31e6798b4e728a23913179e346552a7dd338c0 (libosmocore)
Change-Id: Ib06d030e8464abe415ff597d462ed40eeddef475
2019-04-12 02:15:25 +02:00
Neels Hofmeyr d553c085e7 sms queue: avoid repeated Paging for a failed SMS
So far, sms_pending_failed() starts a new sms_queue_trigger() run. The
intention behind that might have been to fill up the queue when sending SMS has
failed, but the practical effect is actually bad:

As current ttcn3-msc-test runs show, a failed MT SMS gets triggered multiple
times in short succession, i.e. osmo-msc repeatedly sends Paging Requests for
the same subscriber.

This special case happens actually only when there are few SMS still in the DB
to be delivered. In the TTCN3 test, there is exactly one MT SMS for one
subscriber, and retriggering the queue brings up the same SMS every time.

See f_tc_lu_and_mt_sms_paging_and_nothing() and f_tc_sgsap_mt_sms_and_nothing()
which say:
"/* Expect the MSC to page exactly 10 times before giving up */"

This is bad because an MSC should send a Paging Request exactly once. Retrying
failed Paging is clearly the task of the BSC, not the MSC. The remaining code
around Paging correctly follows this paradigm, but this retrigger doesn't.

Do not immediately trigger the SMS queue on a failed MT SMS. Instead, leave it
up to the periodical SMS queue trigger to decide.

This patch will cause the MT SMS tests in ttcn3-msc-tests to fail, because the
test expectations are bogus. The patch fixing the test run is listed 'Related'
below.

Related: I7dce12942a65eaaf97f78ca69401c7f93faacb9e (osmo-ttcn3-hacks)
Change-Id: I24bf9f1c1167efe1080ae4cf47ed2ef0bd981e49
2019-04-12 02:15:25 +02:00
Neels Hofmeyr e4f7e71204 enable osmo_fsm_term_safely(), apply logging changes
Start using osmo_fsm_term_safely(true), the recently added feature of
libosmocore's fsm.c. Deallocates in slightly changed order and with slightly
modified logging. Adjust test expectations.

Depends: I8eda67540a1cd444491beb7856b9fcd0a3143b18 (libosmocore)
Change-Id: I195a719d9ec1f6764ee5a361244f59f0144dc253
2019-04-12 02:15:25 +02:00
Philipp Maier 7231edb732 sgs_iface: fix nullpointer dereference
The function sgs_tx() is using the sgs connection pointer as context,
even though it has done a check for a nullpointer in the line before.
This is very prone to lead into a segfault when the SGs connection dies.

Change-Id: I88b95e3f8cd35241ad68f08d94c6ad7067b842e6
Related: OS#3859
2019-04-11 07:32:48 +00:00
Harald Welte 5dede769e7 smpp_smsc: Call destroy_tlv() when using build_tlv()
The libsmpp34 build_tlv() function is allocating dynamic memory
which we need to release again by calling destroy_tlv().

Change-Id: Iacc74c9948fb10fa79c0dd7b0cb72d4adbefdeed
Closes: OS#3912
2019-04-10 10:53:23 +00:00
Pau Espin f8af776fba sms_queue: Print dest msisdn instead of unknown subscriber
If subscriber is NULL, vlr_subscr_msisdn_or_name() returns string
"unknown", which is less informative than printing destination msisdn
expected for the queued sms.
This happens for instance if an sms was queued with Store&Forward and
destination subscriber is not currently registered

Change-Id: I4b8b54c9c41b17d4e1fa7ece63aa91a98036ef11
2019-04-09 19:45:03 +07:00
Vadim Yanitskiy 0f52319765 msc/gsm_data.h: drop unused SMS_HDR_SIZE macro
Change-Id: Iea32a26673ebb57b18dc7e86ad321d9ed48e0948
2019-04-08 07:34:20 +00:00
Philipp Maier 4826465708 vlr_sgs: start lu expiration timer on sgs eps detach
When the subscriber is detached from SGs services (but not from 2g
services). Then the subscriber essentially becomes a regular 2g
subscriber, which means thet the lu expiration timer needs to be
started.

Change-Id: If95c63706dc1c5a537f7cd1b6481252427cbf234
Related: OS#3614
2019-04-07 18:57:39 +00:00
Philipp Maier 0803d88d9a vlr_sgs: fix SGs IMSI detech from non EPS services
When the subscriber is detached from non EPS services while the
SGs-association is not SGs-NULL, it needs to be removed from the VLR
database.

Change-Id: I575cf6036ad39468f590b2d57a06cd3512a4c31c
Related: OS#3614
2019-04-07 18:57:31 +00:00
Vadim Yanitskiy 6c766c6464 tests/sms_queue: track the use of NULL talloc memory contexts
As we don't initialize all talloc contects of libmsc, let's make
sure that there is nothing left in the NULL context after the
unit test execution is finished.

Change-Id: I99fd82750aff376e4d90eaa2402ec41f4d59ef86
2019-04-01 12:02:57 +00:00
Vadim Yanitskiy 96262a7ca6 libmsc/sms_queue.c: fix memleak in smsq_take_next_sms()
A memleak has been noticed after executing some of TTCN-3 test
cases. For example, the following ones:

  - MSC_Tests.TC_lu_and_mo_sms,
  - MSC_Tests.TC_lu_and_mt_sms.

The key point is that MSC_Tests.TC_lu_and_mo_sms basically sends
a MO SMS to a non-attached subscriber with MSISDN 12345, so this
message is getting stored in the SMSC's database.

As soon as the SMSC's queue is triggered, sms_submit_pending() would
retrieve pending messages from the database by calling function
smsq_take_next_sms() in loop and attempt to deliver them.

This function in it's turn checks whether the subscriber is attached
or not. If not, the allocated 'gsm_sms' structure would not be
free()ed! Therefore, every time smsq_take_next_sms() is called,
one 'gsm_sms' structure for an unattached subscriber is leaked.

Furthermore, there is a unit test called 'sms_queue_test', that
actually does cover smsq_take_next_sms() and was designed to
catch some potential memory leaks, but...

In order to avoid emulating the low-level SQLite API, the unit
test by design overwrites some functions of libmsc, including
db_sms_get_next_unsent_rr_msisdn(), that is being called by
smsq_take_next_sms().

The problem is that the original function in libmsc does
allocate a 'gsm_sms' structure on heap (using talloc), while
the overwriting function did this statically, returning a
pointer to stack. This critical difference made it impossible
to spot the memleak in smsq_take_next_sms() during the
unit test execution.

Let's refactor 'sms_queue_test' to use dynamic memory allocation,
and finally fix the evil memleak in smsq_take_next_sms().

Change-Id: Iad5e4d84d8d410ea43d5907e9ddf6e5fdb55bc7a
Closes: OS#3860
2019-04-01 12:02:57 +00:00
Keith Whyte 18f1138a6d Write configuration correctly from vty (alert notifications)
The default is [yes] alert-notifications, therefore write
"no alert-notifications" in the case that this has
been set, in order to preserve configuration after
write is called from vty.

Change-Id: I079aea96ee83fbf04f782dcab344d41a4ef04657
2019-03-29 22:48:38 +00:00
Vadim Yanitskiy 81635d3400 libmsc: fix: properly initialize the SGs server
It was observed that the SGs server is started before
the actual VTY configuration is parsed. For example:

  sgs
   local-port 9999
   local-ip 127.0.0.1
   vlr-name vlr.example.net

produces the following debug output:

  <0011> sgs_server.c:185 SGs socket bound to r=NULL<->l=0.0.0.0:29118
  DLSS7 NOTICE <001e> osmo_ss7.c:1284 0: ASP Restart for server not implemented yet!
  DSGS NOTICE <0011> sgs_server.c:185 SGs socket bound to r=NULL<->l=0.0.0.0:9999
  DSGS NOTICE <0011> sgs_server.c:185 SGs socket bound to r=NULL<->l=127.0.0.1:9999
  DMNCC DEBUG <0004> msc_main.c:604 Using internal MNCC handler.

The first startup is triggered by sgs_iface_init(), before reading
the VTY configuration, so the logging style is different. The next
two calls to sgs_server_open() are triggered during reading of the
VTY configuration by cfg_sgs_local_port() and cfg_sgs_local_ip().

Let's avoid starting the SGs server three times, and do it once,
after the VTY configuration is parsed. Also, keep the possibility
to change the binding parameters at run-time.

Change-Id: Ie0c31205ac48be7e50d0380a89833771b2708da4
2019-03-28 17:10:11 +07:00
Vadim Yanitskiy 1d802e2635 libmsc/sgs_vty.c: don't print SGs socket error twice
Because sgs_server_open() already does this.

Change-Id: Ifea308645c7829691dbcf53e4f59841090119006
2019-03-28 10:09:11 +00:00
Vadim Yanitskiy 4eaefc2222 libmsc/sgs_iface.c: register sgs_vlr_reset_fsm on DSO load
Change-Id: I80cd2e5645d6e391080376250c0853a3f3f821ef
2019-03-28 10:09:11 +00:00
Vadim Yanitskiy 118a0b890e libmsc/sgs_iface.c: fix copy-paste error
Change-Id: I57b773659302ad4c92b6e670c6156e90a50189ba
2019-03-28 10:09:11 +00:00
Pau Espin 0dad52d0b7 debian/control: Fix typo
Change-Id: I3392d8e184413203d27fc3d75371de4d66f205b9
2019-03-27 11:42:29 +00:00
Neels Hofmeyr 83e311fa3e vlr_subscr_name(): use OSMO_STRBUF
We now have a nicer way to compose strings in a buffer than this.
(Cosmetic preparation for inter-MSC handover patch.)

Change-Id: I7813068032475deb3850af05f7ba5a6f652e7fa2
2019-03-24 16:49:07 +00:00
Philipp Maier 8fa2dbe5b1 msc_vty: add missing header file
The symbol GSM0808_SPEECH_FULL_BM is used in msc_vty.c, but gsm_08_08.h,
where the symbol is declared is not included.

Change-Id: I31a8894031aa2321d7dbf2586d076bc303247278
2019-03-19 18:52:56 +01:00
Sylvain Munaut da9f37ed20 libvlr: Allow 2G auth tuples to be re-used without going through AUTH
If the key_seq we get in the first messages matches the last_tuple, then
both we and the MS already know the key to use and we don't need the
AUTH REQUEST/RESPONSE cycle.

Security wise ... not so good, and so IMHO the 'auth required' option
in the MSC should always be set. But this allows to turn on ciphering on
a channel without doing any MM transaction, and so the MS doesn't turn
on the T3240 timer which allows to have a ciphered silent-call channel
that won't timeout.

Change-Id: Ief840a2ae7a0ffd2bf0bf726f209a79e3f787646
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2019-03-19 15:24:01 +00:00
Harald Welte 31f4c1f927 a_iface: OSMO_ASSERT() if we ever want to send BSSAP with invalid length
Let's add a safeguard against sending BSSAP messages with invalid length
values.  This should never happen, and we'd rather see osmo-msc assert
during the development cycle than ever releasing a version which sends
invalid messages out on the wire.

Change-Id: I94327a0d276c65b528a8c7e33dde61ed53582284
Related: OS#3805
2019-03-19 13:39:14 +00:00
Philipp Maier 9286114f6f silent_call: use osmo_strlcpy() instead of strncpy()
If gsm_silent_call_start() is called with an over long string in
traffic_dst_ip, then the target string might be left unterminated. Lets
use osmo_strlcpy() so that we can be sure the result in scd->traffic_ip
is always terminated.

Fixes: CID#196068
Change-Id: Ic81842175e412ae7d97d023b612412f33411d60c
2019-03-15 09:51:15 +01:00
Sylvain Munaut 935583069d libmsc: Allow different channel types to be requested as silent calls
Change-Id: I82645708dd27864cf33ea9cc993ead0983415602
2019-03-14 12:39:31 +00:00
Neels Hofmeyr f90496f577 vty: add cmd subscriber ID sms delete-all
In ttcn3-msc-tests, so far we leave an intentionally failed MT SMS in the SMS
queue, which may cause it to re-appear in subsequent tests.

Allow removing all SMS for a given subscriber from the SMS database for good.

(I dimly remember a user report where the SMS queue spams failed SMS attempts,
and the only way to get rid of SMS for a given subscriber is to tamper with the
sms.db file directly. This should no longer be necessary with this command.)

Related: I7dce12942a65eaaf97f78ca69401c7f93faacb9e (osmo-ttcn3-hacks)
Change-Id: I637cbd7adc075a192f49752b38779391472ff06d
2019-03-08 04:51:18 +01:00
Neels Hofmeyr 34a36da3ef SMS queue: properly log failed attempts number
Change-Id: I16f2d29855eb715eccbdc5def225f43c110fab8e
2019-03-07 04:17:53 +01:00
Neels Hofmeyr 864d32c043 gsm_04_11_gsup.c: drop unused conn lookup
An earlier code state used the conn to lookup the transaction, but this is now
done by vsub. Hence the conn lookup is not used and not needed.

conn is no longer used since 36c44b2100,
change-Id I093f36d63e671e50e54fc6236e97a777cc6da77b,
"transaction: change arguments of trans_find_by_sm_rp_mr()"

Change-Id: Ia878d70138c883cb1a1d983516aff83efa6488ce
2019-03-07 04:17:47 +01:00
Neels Hofmeyr 8e2c6a31c1 use only accepted ran_conns for new transactions
In connection_for_subscriber(), do not return a ran_conn that is not yet
authenticated nor one that is already in release.

Using a ran_conn that is not yet authenticated may cause an auth/ciph
violation.

Using a ran_conn that is already in release may cause a use-after-free, see
OS#3842 for a description.

To be paranoid, upon releasing a conn, go through the transaction freeing
motions again by calling trans_conn_closed(), just in case some odd code path
added another transaction while the conn was already in release.

Related: OS#3842
Change-Id: Id957032e0ae1ff8ba055a75c3523447d3d06cbc3
2019-03-07 03:58:29 +01:00
Keith Whyte a3a8821167 Don't deliver alert notifications to ESME not yet bound.
We create a new ESME in smsc->esme_list on establishment
of a TCP connection, yet we do not know the system id 
or anything else, until the ESME identifies and authenticates.

So do not send alert notifications until
we know the bind status (and system_id)

Change-Id: Iec92d4c145ca050c2e212139572eeaae581b99df
2019-02-28 14:18:29 +00:00
Vadim Yanitskiy 477cbc6d93 libmsc/msc_vty.c: drop dead comparison against null
Since vsub->sgs.mme_name is allocated statically, comparing it
to null doesn't make sense - it's always != NULL.

Change-Id: Ib2933a20471ebff9dfe1d9fdddf39d177504c951
Fixes: CID#178166 Array compared against 0 (NO_EFFECT)
2019-02-28 00:14:21 +07:00
Vadim Yanitskiy 4d75877e61 libmsc/sgs_vty.c: always write server address and VLR name
Comparing an array to null is not useful, because the expression
will always evaluate as true. Let's just always write SGs server
address and VLR name, no mater whether default values are used
or not, same as we do for the HLR address and port.

Change-Id: If045e42fca0315b0777eb86c44bf934ce58b340b
Fixes: CID#190871 Array compared against 0 (NO_EFFECT)
2019-02-28 00:14:15 +07:00
Vadim Yanitskiy e9ef7c6b9a libmsc/sgs_iface.c: fix SGS_STATE_NS11 counter reference
The SGS_STATE_TS11 is not for counters, it's for timers!

Change-Id: Ifbb1a37e644ae8bf8e7959f6f6cd6403ac1f2f1b
Fixes: CID#190872 Out-of-bounds read (OVERRUN)
2019-02-26 23:16:45 +00:00
Vadim Yanitskiy 1396e1ca35 libmsc/ran_conn.c: add missing 'break' to OSMO_RAT_EUTRAN_SGS
Change-Id: I18dfd08ea0857f2751164a295dd9de20a2024ac3
Fixes: CID#190874
2019-02-26 23:16:10 +00:00
Oliver Smith 0dfa61e39e debian: depend on libdbd-sqlite3
Make sure that we don't fail at startup with:

<0009> db.c:621 Failed to create database connection to sqlite3 db
'sms.db'; Is the sqlite3 database driver for libdbi installed on this
system?

Tested by building the Debian package and looking at its depends.

Related: OS#3771
Change-Id: I7c099212a6ad7d87978c3dce63ce7385d8076bd1
2019-02-25 14:59:03 +01:00
Vadim Yanitskiy 64623e1848 libmsc/gsm_09_11.c: implement guard timer for NCSS sessions
It may happen that either the MS or an EUSE would become
unresponsive during a call independent SS session, e.g.
due to a bug, or a dropped message. In such cases, the
corresponding transaction would remain unfreed forever.

This change introduces a guard timer, that prevents keeping
'stalled' NCSS sessions forever. As soon as it expires, both
sides (i.e. MS and EUSE) are getting notified, and the
transaction is being released.

By default, the timer expires after 30 seconds. As soon as
either the MS, or an EUSE initiates any activity,
the watchdog timer is rescheduled.

The timeout value can be configured from the VTY:

  msc
   ...
   ! Use 0 to disable this timer
   ncss guard-timeout 30

Please note that changing the timeout value at run-time
doesn't affect the existing NCSS sessions, excepting the
case when the timer is disabled at run-time.

This change makes TC_lu_and_ss_session_timeout pass.

Change-Id: Icf4d87c45e90324764073e8230e0fb9cb96dd9cb
Related Change-Id: (TTCN) I3e1791773d56617172ae27a46889a1ae4d400e2f
Related: OS#3655
2019-02-20 03:22:38 +07:00
Harald Welte 390d140b56 a_iface: Fix hexdumping of N-DATA.req
For some reason the existing code was using msgb_hexdump_l2() while the
L2 header is not used by the BSSAP transmit code.  Let's fix this.

Change-Id: I52a1eb3a867ece63fcfa4c2a720d035ebfb90a7b
2019-02-18 13:52:09 +01:00
Harald Welte fd96d45049 a_iface: use 'const' qualifier for ran_conn whenever possible
Change-Id: I8a15c9baae2071569e2ecc4635ddaf5a0001f959
2019-02-18 13:52:09 +01:00
Harald Welte 977b5486b1 a_iface: Centralize/wrap BSSAP / N-DATA transmission
We don't want multiple callers to osmo_sccp_tx_data_msg() each having
to hex-dump a log message about the to-be-transmitted message, with
half of the caller sitest missing that printing.  Let's centralize
all calls of osmo_sccp_tx_data_msg() in a wrapper function which
takes care of the related OSMO_ASSERT() and the related printing.

Change-Id: I6159ea72cc8e0650eda6c49544acd65e9c15e817
2019-02-18 13:52:05 +01:00
Vadim Yanitskiy 2eaee70ada transaction.h: use #pragma once as include guard
Change-Id: I52787120d5ec59897329d28eab28e0fda3d0f44f
2019-02-15 02:19:30 +07:00
Vadim Yanitskiy baeeb90907 transaction: fix description of trans_assign_trans_id()
Change-Id: I80238d89e95b6fd791961c48de80aac69ff5b0e9
2019-02-15 02:19:30 +07:00
Max d8daaae91e transaction: clarify magic 0xff transaction ID
Change-Id: I2d3a6334f49989bedbb1430d26ffad8b61dfd873
2019-02-15 02:19:30 +07:00
Max 30fb97aa43 transaction: drop meaningless ti_flag of trans_assign_trans_id()
According to GSM 04.07, the TI flag takes one bit and can be
either of the following:

  '0'B - transaction is allocated by sender of a message,
  '1'B - transaction is allocated by receiver of a message.

Since we store transaction ID in gsm_trans structure, we also store
TI flag (as a part of transaction ID), which in this context means:

  '0'B - transaction is allocated by us (OsmoMSC),
  '1'B - transaction is allocated by some MS.

In 100% cases, trans_assign_trans_id() is used to assign transaction IDs
to transactions allocated by us (i.e. OsmoMSC) for MT connections. And
there is no need to use it for MO transactions, because they basically
already do contain a valid transaction ID assigned by the MS.

Change-Id: Ie11999900b1789652ee078d34636dcda1e137eb0
2019-02-15 02:19:24 +07:00
Vadim Yanitskiy 114bad8c48 libmsc/osmo_msc.c: move connection ref-counting code to 'ran_conn.c'
The connection ref-counting implementation is specific to RAN
connections, and is not applicable for anything else. Moreover,
the API of this code is declared in 'ran_conn.h', so let's
move the code to a more logical place.

Change-Id: I593675d9bf56eaef12afdaf596ee1337b9a44259
2019-02-14 09:26:47 +00:00
Vadim Yanitskiy 3acfe68b8b libmsc/gsm_04_80.c: add msc_send_ussd_release_complete_cause()
According to GSM 04.80, section 2.5.1, Release complete message
may have an optional Cause IE. Let's add a new function, that
allows to specify cause location and value.

This function will be used by the upcoming changes.

Change-Id: I3b9e8e4f473d113d5b9e9e5d33f7914202077203
Depends Change-Id: (libosmocore) Ie3ac85fcef90a5e532334ba3482804d5305c88d7
2019-02-13 12:50:14 +00:00
Vadim Yanitskiy f20c6b7bd5 libmsc/gsm_04_80.c: use gsm0480_create_release_complete()
The previous implementation of msc_send_ussd_release_complete() was
based on gsm0480_create_ussd_release_complete(), that doesn't
allow to specify GSM 04.07 transaction identifier.

The ability to specify particular transaction identifier
is required for handling multiple SS/USSD transactions.

Change-Id: Id2975c3383f18e83124ba38927c03980d67ddadb
Depends Change-Id: (libosmocore) Ie3ac85fcef90a5e532334ba3482804d5305c88d7
2019-02-13 12:50:14 +00:00
Philipp Maier 896950ab82 a_iface: Include CSFB Indication into BSSMAP CLEAR COMMAND
When a call ends that has been established in an CSFB context, we should
add a CSFB Indication IE to the BSSMAP CLEAR COMMAND to instruct the BSC
to add further CSFB related IEs into the RR RELEASE.

- Check if an SGs association exists and add CSFB Indication IE

Change-Id: I6cfa4b3becdd0138d74e2e1eddd83a0b1568c1de
Related: OS#3778
2019-02-07 10:01:46 +01:00
Harald Welte 845285077d configure.ac: Check for libsctp
Since we merged the SGs interface, we include <netinet/sctp.h>, which
is provided by libsctp.

Change-Id: Id2321e4cb3800929cea56785e5c5bd7480408806
2019-02-06 18:08:59 +00:00
Harald Welte ca292dd607 debian: depend on libsctp-dev
Since we merged the SGs interface, we include <netinet/sctp.h>, which
is provided by libsctp-dev.  This means that the Debian package should
depend on this.

It is expected that this will un-break the network:osmocom:nightly
builds.

Change-Id: I092e95ea970763c4008d3c7ff1b7028042574a64
2019-02-06 17:56:01 +00:00
Max 34d306be95 VLR tests: use msgb_eq_data_print() for comparison
This simplifies tests refactoring by showing exact byte where mismatch
happened. It also makes code more readable.

No changes in expected test output are necessary because the additional
logging will be triggered iff the test fails so the result will be
visible only during debugging of unit test issues.

Change-Id: If9771c973f2bc55580f4c146bdbeeb1609d56786
2019-02-05 16:25:03 +00:00
Harald Welte 0df904dea9 Add SGs Interface
Add an SGs interface (3GPP TS 29.118) to osmo-msc in order to support
SMS tunneling and Circuit Switched Fallback (CSFB)

Change-Id: I73359925fc1ca72b33a1466e6ac41307f2f0b11d
Related: OS#3615
2019-02-04 13:36:26 +01:00
Vadim Yanitskiy c7de62cc53 libmsc/gsm_04_11.c: introduce and use gsm411_assign_sm_rp_mr()
Initially, it was assumed that if there is no active RAN connection,
we can just start counting from 0x00, as there are no other SMS
related transactions, and transaction itself is allocated using
talloc_zero(). Until now it was looking good, but...

As soon as we establish RAN connection with subscriber, we already
have a transaction with SM-RP-MR 0x00, but conn->next_rp_ref also
remains 0x00 - it isn't being increased!

It means that we can face a SM-RP-MR conflict (or collision) if
another MT SMS would arrive to the MSC (from SMSC over GSUP)
when this transaction is still active, i.e. the first SMS is
still being sent, because conn->next_rp_ref++ would
return 0x00 again.

Moreover, there might be already a MO SMS transaction, and using
the conn->next_rp_ref counter wouldn't prevent us from having
duplicate SM-RP-MR value.

Let's get rid of this per-connection counter, and introduce a
function instead, that would iterate over existing transactions
and look for an unused SM-RP-MR value.

This change makes the following test cases pass:

  - TC_gsup_mt_sms_rp_mr,
  - TC_gsup_mo_mt_sms_rp_mr.

Discovered by: Neels Hofmeyr
Related Change-Id: (TTCN) I3a52d44f4abde9b6b471b9108c1cee905884c9bc
Related Change-Id: (TTCN) I17cbbaa64d9bce770f985588e93cd3eecd732120
Change-Id: Ife6d954c46b7d8348a4221ab677d0355eb3ee7ac
2019-02-01 18:55:54 +00:00
Vadim Yanitskiy cfd058dbf1 libmsc/gsm_04_11.c: also assign SM-RP-MR to MO transactions
Previously, SM-RP Message Reference was assigned to MT transactions
only, but not to MO transactions. As a result, this could lead to
having a few transactions with duplicate SM-RP-MR value, because
in case of MO SMS, trans->sms.sm_rp_mr would remain 0x00.

Let's parse SM-RP-MR from MO SMS messages in gsm0411_rcv_sms(),
and assign it to the new transaction after allocation.

Change-Id: I4d07354175444f9764fb0dd6ea188a64494d79fe
2019-02-01 18:55:54 +00:00
Vadim Yanitskiy 36c44b2100 transaction: change arguments of trans_find_by_sm_rp_mr()
The need to pass a pointer to RAN connection in order to find
a transaction limits possible use cases of trans_find_by_sm_rp_mr(),
e.g. when we need to find a transaction, but RAN connection is not
established yet.

Moreover, the pointer to RAN connection was only used to obtain
pointers to gsm_network and vlr_subscr, so we can just
pass them directly.

Change-Id: I093f36d63e671e50e54fc6236e97a777cc6da77b
2019-02-01 18:55:54 +00:00
Vadim Yanitskiy ce9e1f664e libmsc/ran_conn.c: cosmetic: use tabs instead of N * 8 spaces
Change-Id: I09515aea9da8e2b5836c5c6409f094fae05633d4
2019-01-26 11:36:14 +07:00
Vadim Yanitskiy e4574f09d0 transaction.c: cosmetic: use 'default' branch in trans_free()
Change-Id: Ia28ba52b0ea4771843a2a1faa346f7357604b8aa
2019-01-26 11:36:08 +07:00
Max 3614fd6d11 Various logging fixes
Log transaction allocation errors as such. While at it, use proper
subsystem to log missing VLR subscriber.

Change-Id: I617be8793b9416ccd49022c72f7d93df7f4fb4d9
2019-01-24 19:08:07 +00:00
Max 80d8ffda8c Handle LCLS-NOTIFICATION message from BSS
Change-Id: Ibf5f9cad1f70aee56d5bca8fe09a24ca417e7a63
Related: OS#2487
2019-01-24 17:37:08 +00:00
Harald Welte 41e7cf115d Bump version: 1.3.0 → 1.3.1
Change-Id: I624144d6f8919d1dd237cdffc9122f685a8e4d6b
2019-01-22 16:02:11 +01:00
Neels Hofmeyr a92025e8fd fix build: apply msgb_wrap_with_TL() rename
After libosmocore commit
If1e851ac605c8d2fde3da565b0bd674ea6350c2e
b27e6feb699712345373e87a48187dc622e4fa92
the osmo-msc master build is broken.

Apply the msgb_wrap_with_TL() rename to msgb_push_tl() to unbreak the build.

Change-Id: I1d4675e0c907b2f92f2ec79b02356391a6d72aa8
2019-01-22 01:58:55 +01:00
254 changed files with 65387 additions and 30225 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1 @@
open_collective: osmocom

15
.gitignore vendored
View File

@ -1,12 +1,19 @@
debian/*.log
debian/autoreconf.*
debian/*.substvars
debian/tmp
debian/files
debian/.debhelper
debian/osmo-msc*/
*.o
*.lo
*.a
.deps
Makefile
Makefile.in
bscconfig.h
bscconfig.h.in
config.h
config.h.in
*.pc
*.*~
@ -15,6 +22,7 @@ bscconfig.h.in
*.pyc
*.gcda
*.gcno
*~
#configure
aclocal.m4
@ -72,3 +80,6 @@ doc/manuals/generated/
doc/manuals/osmomsc-usermanual.xml
doc/manuals/common
doc/manuals/build
doc/manuals/vty/msc_vty_reference.xml
contrib/osmo-msc.spec

View File

@ -9,15 +9,21 @@ AM_CPPFLAGS = \
$(NULL)
SUBDIRS = \
doc \
include \
src \
doc \
contrib \
tests \
$(NULL)
BUILT_SOURCES = $(top_srcdir)/.version
EXTRA_DIST = git-version-gen osmoappdesc.py .version
EXTRA_DIST = \
.version \
README.md \
debian \
git-version-gen \
osmoappdesc.py \
$(NULL)
AM_DISTCHECK_CONFIGURE_FLAGS = \
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)

24
README
View File

@ -1,24 +0,0 @@
About OsmoMSC
=============
OsmoMSC originated from the OpenBSC project, which started as a minimalistic
all-in-one implementation of the GSM Network. In 2017, OpenBSC had reached
maturity and diversity (including M3UA SIGTRAN and 3G support in the form of
IuCS and IuPS interfaces) that naturally lead to a separation of the all-in-one
approach to fully independent separate programs as in typical GSM networks.
OsmoMSC was one of the parts split off from the old openbsc.git. Before, it was
the libmsc part of the old OsmoNITB. Since a true A interface and IuCS for 3G
support is available, OsmoMSC exists only as a separate standalone entity.
OsmoMSC exposes
- GSUP towards OsmoHLR (or a MAP proxy);
- A over IP towards a BSC (e.g. OsmoBSC);
- IuCS towards an RNC or HNB-GW (e.g. OsmoHNBGW) for 3G voice;
- MNCC (Mobile Network Call Control derived from GSM TS 04.07);
- SMPP 3.4 (Short Message Peer-to-Peer);
- The Osmocom typical telnet VTY and CTRL interfaces.
Find OsmoMSC issue tracker and wiki online at
https://osmocom.org/projects/osmomsc
https://osmocom.org/projects/osmomsc/wiki

110
README.md Normal file
View File

@ -0,0 +1,110 @@
osmo-msc - Osmocom MSC Implementation
=====================================
This repository contains a C-language implementation of a GSM **Mobile Switching
Centre (MSC)** for 2G (GSM) and 3G (UMTS). It is part of the
[Osmocom](https://osmocom.org/) Open Source Mobile Communications
project.
OsmoMSC exposes
* *A over IP* towards BSCs (e.g. [osmo-bsc](https://osmocom.org/projects/osmobsc/wiki): 3GPP AoIP or SCCPlite
* *IuCS over IP* towards RNCs / HNBGW (e.g. [osmo-hnbgw](https://osmocom.org/projects/osmohnbgw/wiki))
* *MGCP* towards a co-located [osmo-mgw](https://osmocom.org/projects/osmo-mgw/wiki) for the RTP streams
* *[GSUP](https://osmocom.org/projects/cellular-infrastructure/wiki/GSUP)* (instead of 3GPP MAP) towards [osmo-hlr](https://osmocom.org/projects/osmo-hlr/wiki)
* *SMPP* towards any external SMS sending/receiving applications
* *[MNCC](https://osmocom.org/projects/osmomsc/wiki/MNCC)* as external call-control interface towards e.g.
[osmo-sip-connectr](https://osmocom.org/projects/osmo-sip-conector/wiki)
* The Osmocom typical telnet *VTY* and *CTRL* interfaces.
* The Osmocom typical *statsd* exporter.
OsmoMSC implements
* mobility management
* call control (either via built-in MNCC handler or external osmo-sip-connector)
* voice group call ([VGCS](https://osmocom.org/projects/cellular-infrastructure/wiki/Voice_Group_Call)) and
voice broadcast calls ([VBS](https://osmocom.org/projects/cellular-infrastructure/wiki/Voice_Broadcast_Call)) as used in GSM-R
* USSD (exposed via GSUP)
* SMS (either via built-in SMSC or external via GSUP)
Homepage
--------
You can find the OsmoMSC home page and wiki online at
<https://osmocom.org/projects/osmomsc/wiki>.
GIT Repository
--------------
You can clone from the official osmo-msc.git repository using
git clone https://gitea.osmocom.org/cellular-infrastructure/osmo-msc
There is a web interface at <https://gitea.osmocom.org/cellular-infrastructure/osmo-msc>
Documentation
-------------
User Manuals and VTY reference manuals are [optionally] built in PDF form
as part of the build process.
Pre-rendered PDF version of the current "master" can be found at
[User Manual](https://ftp.osmocom.org/docs/latest/osmomsc-usermanual.pdf)
as well as the [VTY Reference Manual](https://ftp.osmocom.org/docs/latest/osmomsc-vty-reference.pdf)
Forum
-----
We welcome any osmo-msc related discussions in the
[Cellular Network Infrastructure -> 2G/3G CN](https://discourse.osmocom.org/c/cni/2g-3g-cn)
section of the osmocom discourse (web based Forum).
Mailing List
------------
Discussions related to osmo-msc are happening on the
openbsc@lists.osmocom.org mailing list, please see
<https://lists.osmocom.org/mailman/listinfo/openbsc> for subscription
options and the list archive.
Please observe the [Osmocom Mailing List
Rules](https://osmocom.org/projects/cellular-infrastructure/wiki/Mailing_List_Rules)
when posting.
Issue Tracker
-------------
We use the [issue tracker of the osmo-msc project on osmocom.org](https://osmocom.org/projects/osmomsc/issues) for
tracking the state of bug reports and feature requests. Feel free to submit any issues you may find, or help
us out by resolving existing issues.
Contributing
------------
Our coding standards are described at
<https://osmocom.org/projects/cellular-infrastructure/wiki/Coding_standards>
We us a gerrit based patch submission/review process for managing
contributions. Please see
<https://osmocom.org/projects/cellular-infrastructure/wiki/Gerrit> for
more details
The current patch queue for osmo-msc can be seen at
<https://gerrit.osmocom.org/#/q/project:osmo-msc+status:open>
History
-------
OsmoMSC originated from the [OsmoNITB](https://osmocom.org/projects/osmonitb/wiki/OsmoNITB)
project, which started as a minimalistic all-in-one implementation of the GSM Network. In 2017, OsmoNITB had
reached maturity and diversity (including M3UA SIGTRAN and 3G support in the form of IuCS and IuPS interfaces)
that naturally lead to a separation of the all-in-one approach to fully independent separate programs as in
typical GSM networks.
OsmoMSC was one of the parts split off from the old openbsc.git.

View File

@ -1,6 +1,6 @@
To run the configuration parsing and output (VTY) test suite, first install
git://git.osmocom.org/python/osmo-python-tests
https://gitea.osmocom.org/cellular-infrastructure/osmo-python-tests
and pass the following configure options here:

10
TODO-RELEASE Normal file
View File

@ -0,0 +1,10 @@
# When cleaning up this file: bump API version in corresponding Makefile.am and rename corresponding debian/lib*.install
# according to https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info
# In short:
# LIBVERSION=c:r:a
# If the library source code has changed at all since the last update, then increment revision: c:r + 1:a.
# If any interfaces have been added, removed, or changed since the last update: c + 1:0:0.
# If any interfaces have been added since the last public release: c:r:a + 1.
# If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line
libosmogsm >1.9.0 ABI breakage in struct osmo_gsup_pdp_info, use new fields pdp_type_* and pdp_address.

View File

@ -9,6 +9,8 @@ AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE([dist-bzip2])
AC_CONFIG_TESTDIR(tests)
CFLAGS="$CFLAGS -std=gnu11"
dnl kernel style compile messages
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
@ -22,6 +24,11 @@ AC_PROG_CC
AC_PROG_INSTALL
LT_INIT
dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
AS_CASE(["$LD"],[*clang*],
[AS_CASE(["${host_os}"],
[*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])])
dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
@ -29,22 +36,30 @@ if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
fi
PKG_PROG_PKG_CONFIG([0.20])
dnl check for AX_CHECK_COMPILE_FLAG
m4_ifdef([AX_CHECK_COMPILE_FLAG], [], [
AC_MSG_ERROR([Please install autoconf-archive; re-run 'autoreconf -fi' for it to take effect.])
])
PKG_CHECK_MODULES(LIBSQLITE3, sqlite3)
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.9.0)
PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.9.0)
PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.9.0)
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.9.0)
PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 1.5.0)
PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 1.4.0)
PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 1.8.0)
PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 1.8.0)
PKG_CHECK_MODULES(LIBOSMOMGCPCLIENT, libosmo-mgcp-client >= 1.12.0)
PKG_CHECK_MODULES(LIBOSMOGSUPCLIENT, libosmo-gsup-client >= 1.7.0)
AC_CHECK_FUNC([timegm], [AC_DEFINE(HAVE_TIMEGM, 1, Define if libc implements timegm)])
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.0.0)
PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.0.0)
PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.0.0)
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.0.0)
PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.6.0)
PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.4.0)
PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 1.0.0)
PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 1.0.0)
PKG_CHECK_MODULES(LIBOSMOMGCPCLIENT, libosmo-mgcp-client >= 1.5.0)
PKG_CHECK_MODULES(LIBOSMOGSUPCLIENT, libosmo-gsup-client >= 1.0.0)
old_LIBS=$LIBS
AC_SEARCH_LIBS([sctp_send], [sctp], [
AC_DEFINE(HAVE_LIBSCTP, 1, [Define 1 to enable SCTP support])
AC_SUBST(HAVE_LIBSCTP, [1])
if test -n "$ac_lib"; then
AC_SUBST(LIBSCTP_LIBS, [-l$ac_lib])
fi
], [
AC_MSG_ERROR([sctp_send not found in searched libs])])
LIBS=$old_LIBS
AC_ARG_ENABLE(sanitize,
[AS_HELP_STRING(
@ -80,7 +95,7 @@ fi
AC_ARG_ENABLE([smpp], [AS_HELP_STRING([--enable-smpp], [Build the SMPP interface])],
[osmo_ac_build_smpp="$enableval"],[osmo_ac_build_smpp="no"])
if test "$osmo_ac_build_smpp" = "yes" ; then
PKG_CHECK_MODULES(LIBSMPP34, libsmpp34 >= 1.13.0)
PKG_CHECK_MODULES(LIBSMPP34, libsmpp34 >= 1.14.0)
AC_DEFINE(BUILD_SMPP, 1, [Define if we want to build SMPP])
fi
AM_CONDITIONAL(BUILD_SMPP, test "x$osmo_ac_build_smpp" = "xyes")
@ -91,42 +106,12 @@ AC_ARG_ENABLE([iu], [AS_HELP_STRING([--enable-iu], [Build 3G support, aka IuPS a
[osmo_ac_iu="$enableval"],[osmo_ac_iu="no"])
if test "x$osmo_ac_iu" = "xyes" ; then
PKG_CHECK_MODULES(LIBASN1C, libasn1c >= 0.9.30)
PKG_CHECK_MODULES(LIBOSMORANAP, libosmo-ranap >= 0.3.0)
PKG_CHECK_MODULES(LIBOSMORANAP, libosmo-ranap >= 1.5.0)
AC_DEFINE(BUILD_IU, 1, [Define if we want to build IuPS and IuCS interfaces support])
fi
AM_CONDITIONAL(BUILD_IU, test "x$osmo_ac_iu" = "xyes")
AC_SUBST(osmo_ac_iu)
dnl checks for header files
AC_HEADER_STDC
AC_CHECK_HEADERS(dbi/dbd.h,,AC_MSG_ERROR(DBI library is not installed))
found_sqlite3=yes
PKG_CHECK_MODULES(SQLITE3, sqlite3, ,found_sqlite3=no)
AM_CONDITIONAL(HAVE_SQLITE3, test "$found_sqlite3" = yes)
AC_SUBST(found_sqlite3)
dnl Checks for typedefs, structures and compiler characteristics
# The following test is taken from WebKit's webkit.m4
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fvisibility=hidden "
AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
[ AC_MSG_RESULT([yes])
SYMBOL_VISIBILITY="-fvisibility=hidden"],
AC_MSG_RESULT([no]))
CFLAGS="$saved_CFLAGS"
AC_SUBST(SYMBOL_VISIBILITY)
AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"])
AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"])
AX_CHECK_COMPILE_FLAG([-Werror=null-dereference], [CFLAGS="$CFLAGS -Werror=null-dereference"])
AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"])
AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"])
# Coverage build taken from WebKit's configure.in
AC_MSG_CHECKING([whether to enable code coverage support])
AC_ARG_ENABLE(coverage,
@ -174,7 +159,7 @@ if test "x$enable_ext_tests" = "xyes" ; then
AM_PATH_PYTHON
AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
AC_MSG_ERROR([Please install git://osmocom.org/python/osmo-python-tests to run the VTY/CTRL tests.])
AC_MSG_ERROR([Please install https://gitea.osmocom.org/cellular-infrastructure/osmo-python-tests to run the VTY/CTRL tests.])
fi
fi
AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
@ -243,25 +228,32 @@ AC_MSG_RESULT([CFLAGS="$CFLAGS"])
AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
dnl Generate the output
AM_CONFIG_HEADER(bscconfig.h)
AM_CONFIG_HEADER(config.h)
AC_OUTPUT(
include/Makefile
include/osmocom/Makefile
include/osmocom/msc/Makefile
include/osmocom/smpp/Makefile
src/Makefile
src/libmsc/Makefile
src/libvlr/Makefile
src/libsmpputil/Makefile
src/osmo-msc/Makefile
src/utils/Makefile
tests/Makefile
tests/atlocal
tests/smpp/Makefile
tests/db_sms/Makefile
tests/sms_queue/Makefile
tests/msc_vlr/Makefile
tests/sdp_msg/Makefile
tests/mncc/Makefile
tests/csd/Makefile
doc/Makefile
doc/examples/Makefile
doc/manuals/Makefile
doc/sequence_charts/Makefile
contrib/Makefile
contrib/systemd/Makefile
Makefile)

View File

@ -5,6 +5,7 @@
# * IU: configure 3G support (values: "--enable-iu", "--disable-iu")
# * WITH_MANUALS: build manual PDFs if set to "1"
# * PUBLISH: upload manuals after building if set to "1" (ignored without WITH_MANUALS = "1")
# * IS_MASTER_BUILD: set to 1 when running from master-builds (not gerrit-verifications)
#
if ! [ -x "$(command -v osmo-build-dep.sh)" ]; then
@ -12,6 +13,14 @@ if ! [ -x "$(command -v osmo-build-dep.sh)" ]; then
exit 2
fi
exit_tar_workspace() {
if [ "$IS_MASTER_BUILD" = "1" ]; then
tar -cJf "/tmp/workspace.tar.xz" "$base"
mv /tmp/workspace.tar.xz "$base"
fi
cat-testlogs.sh
}
set -ex
@ -35,23 +44,19 @@ export PATH="$inst/bin:$PATH"
osmo-build-dep.sh libosmo-abis
osmo-build-dep.sh libosmo-netif
osmo-build-dep.sh libosmo-sccp
PARALLEL_MAKE="" osmo-build-dep.sh libsmpp34
osmo-build-dep.sh libsmpp34
osmo-build-dep.sh osmo-mgw
osmo-build-dep.sh osmo-hlr
enable_werror=""
if [ "x$IU" = "x--enable-iu" ]; then
osmo-build-dep.sh libasn1c
#osmo-build-dep.sh asn1c aper-prefix # only needed for make regen in osmo-iuh
osmo-build-dep.sh osmo-iuh
else
enable_werror="--enable-werror"
fi
# Additional configure options and depends
CONFIG=""
if [ "$WITH_MANUALS" = "1" ]; then
osmo-build-dep.sh osmo-gsm-manuals
CONFIG="--enable-manuals"
fi
@ -65,17 +70,18 @@ set -x
cd "$base"
autoreconf --install --force
./configure --enable-sanitize $enable_werror --enable-smpp $IU --enable-external-tests $CONFIG
./configure --enable-sanitize --enable-werror --enable-smpp $IU --enable-external-tests $CONFIG
$MAKE $PARALLEL_MAKE
LD_LIBRARY_PATH="$inst/lib" $MAKE check \
|| cat-testlogs.sh
|| exit_tar_workspace
LD_LIBRARY_PATH="$inst/lib" \
DISTCHECK_CONFIGURE_FLAGS="$enable_werror --enable-smpp $IU --enable-external-tests $CONFIG" \
$MAKE distcheck \
|| cat-testlogs.sh
DISTCHECK_CONFIGURE_FLAGS="--enable-werror --enable-smpp $IU --enable-external-tests $CONFIG" \
$MAKE $PARALLEL_MAKE distcheck \
|| exit_tar_workspace
if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then
make -C "$base/doc/manuals" publish
fi
$MAKE $PARALLEL_MAKE maintainer-clean
osmo-clean-workspace.sh

View File

@ -4,10 +4,16 @@ Wants=osmo-hlr.service
Wants=osmo-mgw.service
After=osmo-hlr.service
After=osmo-hnbgw.service
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
Restart=always
StateDirectory=osmocom
WorkingDirectory=%S/osmocom
User=osmocom
Group=osmocom
ExecStart=/usr/bin/osmo-msc -c /etc/osmocom/osmo-msc.cfg
RestartSec=2

819
debian/changelog vendored
View File

@ -1,3 +1,822 @@
osmo-msc (1.11.1) unstable; urgency=medium
[ Neels Hofmeyr ]
* fix codecs in internal call bridge
* make two functions static
[ Mychaela N. Falconia ]
* CC: don't start guard timer on mid-call MNCC messages
* gsup_client_mux: set destination_name in error reply function
* SMS over GSUP: correctly route GSUP responses to MT SMS
* SMS over GSUP: set source_name in GSUP reply messages
[ Andreas Eversberg ]
* ASCI: Remove duplicated CLEAR COMMAND from VGCS/VBS channel handling
-- Oliver Smith <osmith@sysmocom.de> Thu, 28 Sep 2023 13:53:07 +0200
osmo-msc (1.11.0) unstable; urgency=medium
[ arehbein ]
* Transition to use of 'telnet_init_default'
[ Neels Hofmeyr ]
* sdp_msg.c: fix missing rate in sdp_audio_codecs_add()
* comment: clarify L3 Info processing
* IuCS: remove IuUP LOOPBACK hack
* make: doc/sequence_charts: use wildcards for EXTRA_DIST and CLEANFILES
* tweak MNCC logging, add RTP info
* msc_log_to_ladder.py: various tweaks
* charts: Rename voice_call_full.msc to voice_call_external_mncc.msc
* update doc/sequence_charts/voice_call_external_mncc.msc
* add voice_call_internal_mncc.msc
* add codec_mapping.h,c
* MNCC: use codec_mapping, drop mgcp_codec_to_mncc_payload_msg_type()
* [codecs filter] add codec_filter.h,c
* [codecs filter] add trans.cc.codecs
* [codecs filter] store BSS codec list from Compl L3
* [codecs filter] MO call: apply BSS codec list
* [codecs filter] MT call: apply BSS codec list
* [codecs filter] MT call: apply remote call leg codecs
* [codecs filter] MT call: store MS Bearer Cap from CC Call Conf
* msc_vlr_test_call: include RAN RTP addr in ass compl
* [codecs filter] apply BSS codecs from Assignment Complete
* add ran_infra.force_mgw_codecs_to_ran
* rtp_stream: allow multiple codecs / use codec filter from Assignment
* in ran_msg, return gsm0808_speech_codec (intra-MSC)
* in ran_msg, return gsm0808_speech_codec (inter-MSC)
* [codecs filter] use filter result in MT DTAP CC Setup
* [codecs filter] use filter result in Assignment
* [codecs filter] send + receive SDP via MNCC
* msc_vlr_tests: confirm crcx by RAN/CN side separately
* [codecs filter] use codecs filter on crcx ok
* do CN CRCX first
* mncc_recvmsg(): log caller file,line
* [codecs filter] msc_vlr_test_call: test codecs resolution
* codecs: compose HO Req Ch Type from cc.codecs
* HO Req: include IE Codec List (MSC Preferred)
* fix msc_vlr_test_call SDP mncc_rtp
* coverity: sdp_msg_test.c: check rc of sdp_msg_from_sdp_str()
* 3G: decapsulate IuUP to AMR at the MGW; allow 3G<-AMR->2G
* TODO-RELEASE: add note on osmo-sip-connector and SDP
[ Vadim Yanitskiy ]
* src/Makefile.am: remove unneeded AM_LDFLAGS with LIBS
* tests: use -no-install libtool flag to avoid ./lt-* scripts
* tests: $(BUILT_SOURCES) is not defined, depend on osmo-msc
* copyright: fix typo: sysmocom s/s.m.f.c./s.f.m.c./ GmbH
* fixup: contrib/jenkins: create workspace.tar.xz on error
* tests/{ctrl,vty}_test_runner.py: raise an exception if proc's rc != 0
* msc_vty: support spaces in short/long network name
* ran_a_mgcp_codec_from_sc(): cosmetic: remove unneeded breaks
* ran_a_mgcp_codec_from_sc(): map GSM0808_SCT_CSD to CODEC_CLEARMODE
* ran_a_channel_type_to_speech_codec_list(): set PI/PT for CSD
* codec_mapping: codec_map[]: add missing speech codec for CLEARMODE
* csd_bs_list_to_bearer_cap(): properly initialize bcap fields
* csd_bs_list_to_bearer_cap(): add default branch for safety
[ Pau Espin Pedrol ]
* mncc_sock: Call osmo_fd_unregister() before closing and changing bfd->fd
* rtp_stream: Update id after modifying fields upon Tx of MGCP msg
* rtp_stream: Fix remote_osmux_cid_sent_to_mgw never set to true
* UserManual: Include sigtran*.adoc from osmo-gsm-manuals.git
* Write explicit role & sctp-role fields in ASP configurations
* Use new mgcp_client_conf_alloc() API to alloc mgcp_client_conf
* Tx Loc UPD ACC: Use PLMN provided by subscr
* trans_lcls_compose(): Set PLMN fron cell currently in use
[ Oliver Smith ]
* msc_mgw_setup: use mgcp_client_pool_empty()
* msc_main: close SMS db on startup error
* debian: set compat level to 10
* contrib/jenkins: create workspace.tar.xz on error
* systemd: depend on networking-online.target
* codec_mapping: add clearmode
* ran_a_channel_type_to_speech_codec_list: add CSD
* codec_filter_set_ms_from_bc: prepare for CSD
* Cosmetic: gsm48_cc_tx_setup: tweak comment
* Cosmetic: gsm48_cc_tx_setup: remove TODO comment
* codec_filter_init: prepare for CSD
* codec_filter_set_ran: prepare for CSD
* codec_filter_set_bss: prepare for CSD
* codec_filter_run: prepare for CSD
* transaction: move cc.codecs.remote -> cc.remote
* transaction: move cc.codecs.result -> cc.local
* msc: add trans_cc_set_remote_from_bc
* gsm48_cc_tx_setup: set trans->bearer_cap.transfer early
* Add initial CSD support with external MNCC
* smpp_handle_bind_tx: initialize tlv
* sdp_msg_test: fix dereference after null check
* smpp_msc: submit_to_sms: check ud_len > sms_msg_len
* msc_ho_send_handover_request: fix check_after_deref
* csd_bs_list_to_gsm0808_channel_type: fix rc check
* gsm48_cc_tx_alerting: check rc of sdp_msg_from_sdp_str
* mncc_test: fix talloc_named_const
* gsm48_cc_tx_setup: use MNCC bcaps for CSD
* test: add csd_test
* csd_bs_list_remove: fix removal logic
* mncc_builtin: permit data bearer types
* csd_bs_to_gsm0808: add T 300 / proper ch_rate_type
* Cosmetic: fix typo
* csd_bs_list_to_gsm0808_ct: assert -> ret -EINVAL
* msc_ho_send_handover_request: support CSD
* msc_a_up_call_assignment_complete: check CSD codec
* gsm48_cc_tx_call_proc_…: verify bcap.transfer
[ Andreas Eversberg ]
* ASCI: Add log categories for GCC/BCC (call control)
* ASCI: Add log category for VGCS/VBS call and channel FSM
* ASCI: Use a unique call-id for RTP streams
* ASCI: rtp_stream_commit(): Also update MGW on conn mode change
* ASCI: Allow usage of rtp_stream with other FSM
* ASCI: Add transaction type to trans_find_by_callref()
* ASCI: Add two new transaction types for VGCS and VBS
* ASCI: Allow transaction without subscriber associated
* ASCI: Add simple implementation of Group Call Register
* ASCI: Add functions to transcode VGCS/VBS messages on A-interface
* ASCI: Add callref to assignment command
* ASCI: Add call control for VGCS/VBS
* ASCI: Add decoder for VGCS/VBS messages to msc_a.c
* ASCI: Add function to receive VGCS/VBS messages from BSS
* ASCI: Add option to switch on or off ASCI support
* ASCI: Check return code of osmo_mobile_identity_decode()
* ASCI: Remove check for trans->msc_a to be set in _assign_complete()
* ASCI: Add VTY to configure GCR (Group Call Register)
* ASCI: Add reception of UPLINK RELEASE on dedicated channel
* ASCI: Clear VGCS call and channel on BSSMAP reset message
* ASCI: Receive messages from MSC-A role related to VGCS/VBS
* ASCI: Null pointer bug fix in trans_create_bcc_gcc
* ASCI: Fix wrong check for Null pointer in vgcs_cell_fsm_null()
* ASCI: Check if codec mapping exists for given codec
* ASCI: Fix Null pointer dereference bug in gsm44068_bcc_gcc_trans_free()
* ASCI: Point to correct state machine when calling ran_encode_and_send()
* ASCI: Add debugging and error logging to VGCS/VBS call control
* ASCI: Add missing transaction ID to SET PARAMETER message
[ Keith Whyte ]
* SMPP: Fix Memory leaks
-- Pau Espin Pedrol <pespin@sysmocom.de> Tue, 12 Sep 2023 16:46:11 +0200
osmo-msc (1.10.0) unstable; urgency=medium
[ Keith Whyte ]
* Don't let this osmo-msc operate on a libdbi database
* Turn off secure_delete in sqlite
* Update MNCC field validation mask.
* Change CC_CAUSE returned on unanswered MT Call
* LCLS: Fix Global Call Reference generation
[ Neels Hofmeyr ]
* fix typo in msgb name for CC SETUP
* missing whitespace in gsm_04_08_cc.c
* err log: fix reverse statement in msc_a call handling
* cosmetic: log actual MNCC msg in tch_rtp_connect()
* sdp_msg: s/_name_/_to_str_/g
* in sdp logging: add payload type number like 'AMR#111'
* sdp_msg: add sdp_audio_codecs_cmp(), add compare flags
* sdp_msg: s/sdp_audio_codec_/sdp_audio_codecs_
* msc_a,vlr: rename ciphering_required to is_ciphering_to_be_attempted
* msc_a,vlr: add is_ciphering_required (accurately named)
* vlr_lu_fsm: clarify naming of static functions
* vlr: auth_fsm: clarify success/failure result
* vlr: auth_fsm: rename AUTH_RES to AUTH_SUCCESS
* vlr_auth_fsm: add result no_auth_info_event
* vlr: implement fallback to no-auth
* sdp_msg: when NULL, do not crash but return empty SDP str
* log CC timeouts
* add sdp_audio_codec_is_set
* add some comments to sdp_msg.c,h
* sdp_msg.c: parse send/recv mode
* fix sdp_msg_to_sdp_str(), never add fmtp for unset codec
* rtp_stream_commit: check missing MGW ep only when ready for RTP
* rtp_stream: set_remote_addr: do nothing when unchanged
[ Max ]
* SMPP: clarify (re)start logic
* Ignore .deb build byproducts
* ESME: use osmo_sock_get_name() for logging
* tests: use common stubs for SMS queue test
* Introduce libsmpputil
* Add ESME-specific logging
* Set working directory in systemd service file
* Make esme struct shared
* Use libsmpputil functions in smpp_mirror tool
* cosmetic: use proper name for SMPP handlers
* SMPP: remove duplicate g_smsc definition
* smpp_mirror: fix compiler warning
* SMPP: use default port from libsmpp34
* SMPP: fix possible NULL pointer dereference
* SMPP: make smpp_smsc_stop() static
* ctrl: take both address and port from vty config
* SMPP: use proper type for boolean variables
[ Vadim Yanitskiy ]
* contrib/jenkins.sh: do not override parallel make for libsmpp34
* mncc: move MNCC_F_ALL from mncc.c to mncc.h
* mncc: cosmetic: fix coding style in mncc_prim_check_sign()
* libmsc: check return value of gsm0808_create_ass2()
* msc_main: fix wrong comment: HLR is a separate project
* fix msc_vty_go_parent(): add missing case for MGW_NODE
[ Pau Espin Pedrol ]
* tests/test_nodes.vty: Avoid listing commands provided by lib
* Introduce support for libosmo-mgcp-client MGW pooling
* vty: Make use of new mgcp_client_pool_config_write() API
* Use new mgcp-client VTY commands under mgw node
* call_leg: Fix EV_MGW_ENDPOINT_GONE not processed in RELEASE state
* doc: Include mgwpool.adoc from osmo-gsm-manuals
[ Oliver Smith ]
* contrib/jenkins.sh: use enable-werror with IU too
-- Pau Espin Pedrol <pespin@sysmocom.de> Tue, 07 Feb 2023 17:28:16 +0100
osmo-msc (1.9.0) unstable; urgency=medium
[ Alexander Couzens ]
* utran: use new UTRAN encryption enum
* libmsc/gsm_04_08: refactor require ciphering into an own function
* ran_msg_iu: do not pass UEA0 to ranap_new_msg_sec_mod_cmd2()
[ Vadim Yanitskiy ]
* VTY: clarify deprecation message for cfg_net_per_loc_upd_cmd
* libmsc: fix memory leak (struct gsm_sms) in gsm340_rx_tpdu()
* libmsc: fix another memleak (struct gsm_sms) in gsm340_rx_tpdu()
* libvlr: vlr_set_ciph_mode(): avoid redundant check
* libvlr: fix is_ciph_required(): always send SecModeCmd for UTRAN
* libmsc: ran_iu_make_security_mode_command(): improve readability
* libmsc: ran_iu_make_security_mode_command(): clarify UIA mask
* libmsc: fix memory leak (struct msgb) in msc_i_ran_enc()
* tests: use 'check_PROGRAMS' instead of 'noinst_PROGRAMS'
[ Oliver Smith ]
* treewide: remove FSF address
* tests/msc_vlr/Makefile.am: drop -ldbi
[ Pau Espin Pedrol ]
* Announce IuFP audio codec for UTRAN conns in CRCX towards MGW
* Avoid setting audio codec if not available during assignment_complete (MDCX)
* ran_msg_iu.c: Set proper codec in Assignment Complete
* Drop unneeded ax_check_compile_flag.m4
* call_leg: local_bridge: Avoid null pointer access if CN-side not ready
[ Neels Hofmeyr ]
* fix crash on CM Serv Rej: fix use count mismatch
[ Harald Welte ]
* call rate_ctr_init() to make rate counters work properly
* switch sqlite3 to single-threaded mode
* sms_queue: Annotate each function with some comment
* vlr: Split vlr_subscr_rx_imsi_detach()
* vlr: Add rate counters and stat items
* sms_queue: Introduce rate_ctr / stat_item
* smpp: Fix use-after-free bug when ESME disconnects but has write pending
* smpp: don't enqueue write messages if ESME is disconnected
* sms_queue: refactor sms_pending add/remove code
* sms_queue: merge sms_pending_add into sms_pending_from
* tests: Remove sms.db{-wal,-shm} files, not just sms.db
* switch from libdbi to lbsqlite3
* db: Switch from 'synchronous = FULL' to 'synchronous = NORMAL'
* sms: Encapsulate SMS queue related config parameters
* sms: Give smsc its own VTY config node
* sms_queue: Use local variable rather than 9x pointer de-ref in function
* sms_queue: Make deletion of messages from DB VTY-configurable
* smpp: Parse and use SMPP-provided validity period
* sms: Make default SMS validity period configurable via VTY
* sms: Introduce VTY-configurable minimum SMS validity period
* update git URLs (git -> https; gitea)
* Convert + Expand README file
* fix RPM build failures due to README -> README.md rename
-- Pau Espin Pedrol <pespin@sysmocom.de> Wed, 29 Jun 2022 11:32:11 +0200
osmo-msc (1.8.0) unstable; urgency=medium
[ Pau Espin Pedrol ]
* configure.ac: Depend on newer libosmo-ranap
* Fill Last Used E-UTRAN PLMN Id when in CSFB
* Use new osmo stat items/ctr APIs
* sgs: Use available API to set vlr subscr LastUsedEutranPLMNId
* vlr_sgs: Drop recorded LastEutranPlmnId when UE no longer associated
* sgs_iface.c: Improve logging when paging over SGs
* msc_a.c: Allow MSC_A_EV_CN_CLOSE in state MSC_A_ST_RELEASING
* cosmetic: fix typos in comments
* vlr_sgs.h: Set proper logic order of items in enum sgs_ue_fsm_state
* vlr_auth_fsm.c: Simplify function auth_fsm_wait_ai_resync
* vlr_sgs.c: Fix missing use_count decrease in vlr_sgs_imsi_detach
* vlr_sgs: Balance use_count incremented in vlr_sgs_loc_update
* cosmetic: Fix typo in comment
[ Oliver Smith ]
* contrib/osmo-msc.spec.in: depend on dbd-sqlite3
* contrib/osmo-msc.spec.in: require libosmo-ranap >= 0.7.0
* Revert "Turn some compiler warnings into errors"
[ Vadim Yanitskiy ]
* SMS-over-GSUP: notify sender if no transaction found
* msc_tx_common_id(): fix potential NULL pointer dereference
* libmsc: fix NULL pointer dereference in trans_lcls_compose()
* libmsc: struct smsc: drop 'const' qualifier from bind_addr
* smpp_smsc: use osmo_talloc_replace_string() in smpp_smsc_conf()
* mncc: rework passing GCR over the MNCC interface
* manuals: remove deprecated -C / --no-dbcounter options
* Do not mention deprecated -M / --mncc-sock-path options
* Do not mention deprecated -l / --database options
[ Neels Hofmeyr ]
* osmo-msc main: use osmo_select_shutdown()
* ran_msg_a.c: use gsm0808_create_cipher2()
* support A5/4 in Cipher Mode Command
* support A5/4 in inter-BSC handover
* improve logging on encryption, for Ciphering and HO
* add sequence_charts/call_reestablishment.msc
* add vlr_subscr_find_by_mi
* implement CM Re-Establish for voice calls
[ Eric Wild ]
* vty: allow A5/4 encryption in config
[ Philipp Maier ]
* running.adoc: add section about MGCP configuration
* msc_vlr_test: remove DLMGCP log messages from unit test output
[ Harald Welte ]
* smpp: Fix help string in vty for "alert-notifications"
* smpp_mirror: Factor-out reset of SMPP read state
* smpp_mirror: Don't allocate msgb's for unrealistic amounts of memory
* Fix enabling of UMTS UEA encryption
* Make UTRAN encryption algorithms configurable
[ Keith Whyte ]
* Add support for LCLS to the MSC
[ Alexander Couzens ]
* Validate the choosen UTRAN encryption algorithm
-- Pau Espin Pedrol <pespin@sysmocom.de> Tue, 16 Nov 2021 17:44:54 +0100
osmo-msc (1.7.0) unstable; urgency=medium
[ Keith Whyte ]
* Use GSM411_RP_* and not GSM48_CC_*
* Trivial: code simplification, return early
* vty: allow configuring db path from cfg file
* Don't Store an SMS in the database when the ESME is not Bound
[ Pablo Neira Ayuso ]
* libmsc: SMS, Avoid premature RP-ACK to MS
[ Vadim Yanitskiy ]
* manuals/vty: update the VTY reference to reflect recent changes
* libvlr: remove unused 'periodic_lu_timer' from struct vlr_subscr
* osmo-msc: fix: properly initialize default values for MGW timers
* msc/signal.h: remove unused (since the NiTB split up) signals
* VTY: mark 'subscriber create imsi' command as deprecated
* VTY: add osmo_tdef introspection and configuration commands
* libvlr: use generic osmo_tdef API for T3250, T3260, and T3270
* libmsc: move subscriber expiration timer T3212 to libvlr
* vlr: remove unused parameter 'log_level' of auth_fsm_start()
* vlr_sgs_fsm: add missing break, do not call to_null() twice
* msc/sccp_ran.h: fix: do not pass -1 to osmo_rat_type_name()
* VTY: cosmetic: make struct cmd_node for GSMNET_NODE static
* libmsc/gsm_04_08: make use of msc_a in gsm48_rx_rr_app_info()
* libmsc/gsm_04_08: use DRR in gsm48_rx_rr_pag_resp(), not DMM
* libmsc/gsm_04_11.h: remove unused sms_deliver definition
* osmo-msc: use stderr to print error messages, not stdout
* libmsc/sdp: cosmetic: fix less-than-zero comparison of an unsigned value
* SMS-over-GSUP: clarify error message about unexpected MO/MT SMS
* SMS-over-GSUP: move net->sms_over_gsup check to gsm411_gsup_rx()
* SMS-over-GSUP: respond with error if net->sms_over_gsup is false
* SMS-over-GSUP: notify sender about unhandled GSUP messages
* SMS-over-GSUP: notify sender about malformed GSUP messages
* SMS-over-GSUP: notify sender in case of RPL delivery failure
* gsm_04_14: fix off-by-one error in create_gsm0414_msg()
* vty: fix vsub reference counting: call vlr_subscr_put()
* debian/control: change maintainer to the Osmocom team / mailing list
* mncc_builtin: cosmetic: fix coding style in int_mncc_recv()
* mncc_builtin: log type of unhandled message in int_mncc_recv()
* main: add --vty-ref-mode, use vty_dump_xml_ref_mode()
* submit_to_sms(): fix the use of deprecated gsm_septets2octets()
* ran_a_decode_cipher_mode_reject(): use gsm0808_get_cause()
* fix _gsm48_cc_trans_free(): send MNCC REL.ind on Clear Request
[ Neels Hofmeyr ]
* fix segfault: unsolicited Paging Response
* manual: add missing mention of MGCP in "Multiple instances"
* manual: Multiple Instances: tweak MNCC, add missing SGs doc
* manual: link to new common cs7-config.adoc, remove some dup of that
* vlr_subscr_rx_id_resp(): dont assert on received MI type
* msc_vlr_test_gsm_ciph.c: fix IMEISV MI: even number of digits, clear odd bit
* use new osmo_mobile_identity API everywhere
* add rudimentary NRI support for MSC pooling
* add osmo-msc --vty-ref-xml: dump VTY ref XML to stdout
* add comments to clarify some complete l3 details
* vty 'show connection': show msc_a->via_cell instead of vsub->cgi
* propagate Compl L3 Info Cell ID to the VLR subscriber record
* make vty-transcrip-test: use $VTY_TEST var like osmo-bsc
* refactor: move RESET Osmux TLV parsing to ran_msg_a.c
* sgs_tx_loc_upd_resp_cb(): fix error handling for MI encoding
* is_reset_msg: use proper enum for rc value
* manuals: generate vty reference xml at build time
* Clear Command: set cause value to "Call Control"
* fix crash for unknown MI during Paging Response
* fix MGCP timeout timer
* drop duplicate ran_peer_find() vs ran_peer_find_by_addr()
* fix comment in ran_peer.h
* msc_vlr_tests: make independent of libosmocore talloc
* gsm_network: drop unused neighbor_list member
[ Eric ]
* configure.ac: fix libtool issue with clang and sanitizer
[ Philipp Maier ]
* doc: do not use random ip-address for MGW
* msc_vty: remove emergency-call command from network
* msc_a: add callref as call id to ASSIGNMENT REQ.
* msc_ho: fix CALL IDENTIFIER in HANDOVER REQUEST
* mncc_call: fix memory overrun
* gsm_04_08: check return code of osmo_mobile_identity_decode_from_l3()
[ Harald Welte ]
* vlr_auth_fsm: Fix compilation with gcc-10
* contrib/osmo-msc.spec.in: Enable SMPP in RPM builds
* remove empty + unused ran_up_l2.c
* osmo-msc.spec.in: Use %config(noreplace) to retain current config file
* Send "BSSMAP CommonID" to tell BSC about the IMSI
* Use osmo_fd_setup() whenever applicable
* debian/control: Recommend installation of osmo-mgw
* Use osmo_fd_*_{disable,enable}
* README update. Explain more what it is than just the history
[ Pau Espin Pedrol ]
* Use OSMO_FD_* instead of deprecated BSC_FD_*
* ran_msg_iu.c: Avoid redefining osmo-iuh global variables
* configure.ac: Drop trailing whitespace
* Support setting rt-prio and cpu-affinity mask through VTY
* Change default SCTP conn NULL->127.0.0.1 to localhost->localhost
* Support sending IPv6 Transport Address in Assignment Command
* Support handling IPv6 Transport Address in Assignment Complete
* tests: Fix VTY results after switch to newer libosmo-mgcp-client
* Support handling IPv6 Transport Address in Handover Request (Ack)
* mncc: Support IPv6 addresses (new version mncc 7)
* contrib/jenkins: Enable parallel make in make distcheck
* main: generate coredump and exit upon SIGABRT received
* .gitignore: Ignore new autofoo tmp files
* tests: Explicitly drop category from log
* tests: Replace deprecated API log_set_print_filename
[ Oliver Smith ]
* contrib: import RPM spec
* contrib: integrate RPM spec
* Makefile.am: EXTRA_DIST: debian, contrib/*.spec.in
* contrib/jenkins: don't build osmo-gsm-manuals
* configure.ac: set -std=gnu11
[ Alexander Couzens ]
* Convert paging response timer into an osmocom own X4 timer
-- Pau Espin Pedrol <pespin@sysmocom.de> Tue, 23 Feb 2021 20:22:34 +0100
osmo-msc (1.6.1) unstable; urgency=medium
[ Vadim Yanitskiy ]
* libmsc/gsm_04_08.c: fix: verify MI before calling vlr_subscr_rx_id_resp()
[ Neels Hofmeyr ]
* vlr_gsup_rx: fix uninitialized rc
* vlr.c: fix condition to check MSISDN presence
-- Pau Espin Pedrol <pespin@sysmocom.de> Thu, 09 Jan 2020 12:29:08 +0100
osmo-msc (1.6.0) unstable; urgency=medium
[ Philipp Maier ]
* cosmetic: make function mncc_tx_to_gsm_cc static
* sgs_iface: do not use SGsAP-MO-CSFB-INDICATION for CSFB return
* msc_a: switch RAN type back to SGs when a CSFB-Call is cleared
* sgs_iface: Accept messages with unknown TLV elements
* paging: Send SGsAP-SERVICE-ABORT-REQUEST on paging timeout
[ Neels Hofmeyr ]
* add 'encryption uea 1 2' cfg / fix ttcn3 iu tests
* mncc: send payload type matching chosen codec
* memleak on cc setup errors
* cc trans: make sure bearer cap is empty
* fix segfault: don't send CC REL on NULL msc_a
* vlr_lu_fsm: ignore ID_IMEISV during VLR_ULA_S_WAIT_HLR_UPD
* tweak CC cause for incoming call to unattached nr
* log, cosmetic: add "RR" to "Ciphering Mode Complete"
* msc_vlr_tests: GSUP: don't care about extra IEs
* gsm48_tch_rtp_create(): check against NULL mgcp_info
* msc_a.c, CC trans: change a comment to a debug log
* cosmetic: fix call_leg_ensure_ci() decl. arg name to match impl.
* vlr: don't log about "gratuitous ID RESPONSE"
* ran_dec logging: log message sizes on errors
* msc_a fsm: ignore state chg to same state
* fix error on BSSMAP Cipher Mode Complete L3 msg IE
* catch GSUP auth result without auth_fsm
* LOG_TRANS for CC: always log CC state
* log which DTAP messages are sent to RAN
* log: drop duplicate MNCC log
* also log MNCC_SETUP_REQ
* BSSMAP log tweak
* log: RANAP encode: use RANAP message names instead of BSSAP
* log: ran_msg_a: tweak a message name
* send MNCC REL only if MNCC has actually started
* fsm: use deferred deallocation
* rtp_stream: sanely cancel MGW endpoint FSM notify
* use osmo_sockaddr_str_is_nonzero()
* CC: add error handling for CRCX responses
* add msc_log_to_ladder.py
* charts: add full MO and MT voice call diagram
* cc trans: remove unused tch_rtp_create
* fix msc_vlr_test_call.c
* BSSMAP: decode Codec List (BSS Supported)
* fail on invalid RTP address from MGW
* msc_a CC: add some basic sanity tests
* fix incoming call while Paging
* add sdp_msg API: SDP parsing/composition
* MNCC v6: add optional SDP to the socket protocol
* msc_vlr_tests: better err logging for dtap msgs
* msc_vlr_test_call.c: add MNCC logging
* msc_vlr_tests: log descriptions in color with -v
* msc_vlr_test_call: rename lu_utran_tmsi
* gsup: indicate CN-Domain in SendAuthInfo Requests
* sms db: when storing an SMS, retrieve the ID
* sms log tweak
[ Vadim Yanitskiy ]
* libvlr/vlr.c: cosmetic: move message_type assignment
* counters: clarify documentation for MSC_CTR_SMS_* entries
* counters: clarify documentation for MSC_CTR_LOC_UPDATE_* entries
* counters: clarify documentation for MSC_CTR_CALL_* entries
* counters: polish documentation of cm_service_request / paging_resp
* libmsc: fix potential NULL-pointer dereferences detected by GCC's LTO
* libmsc/gsm_04_11_gsup.c: do not init a buffer in gsm411_gsup_mo_fwd_sm_req()
* libmsc/gsm_04_11_gsup.c: fix SM-RP-OA encoding for MO SMS over GSUP
[ Alexander Couzens ]
* smpp_openbsc.c: check acl before deref it
* vlr: gmm_cause_to_fsm_and_mm_cause() drop fsm_cause_p argument
* make vlr_gmm_cause_to_mm_cause public
* vlr_auth_fsm: on SAI use the GSUP provided GMM cause code
[ Keith Whyte ]
* Implement a global switch on the network to disable call waiting.
[ Pau Espin Pedrol ]
* vty: fix access to wrong argv in paging response-timer
[ Oliver Smith ]
* tests: only check IU configs if IU is enabled
* osmoappdesc.py, tests: switch to python 3
[ Martin Hauke ]
* Fix some typos
[ Harald Welte ]
* check for osmo_ss7_init() error return value
* manual: Fix copy+paste error
* Check for osmo_fsm_register() error return value
* msc: exit(2) on unsupported positional arguments on command line
-- Pau Espin Pedrol <pespin@sysmocom.de> Fri, 03 Jan 2020 18:51:37 +0100
osmo-msc (1.5.0) unstable; urgency=medium
[ Max ]
* Handle LCLS-NOTIFICATION message from BSS
* Various logging fixes
* VLR tests: use msgb_eq_data_print() for comparison
* transaction: drop meaningless ti_flag of trans_assign_trans_id()
* transaction: clarify magic 0xff transaction ID
[ Vadim Yanitskiy ]
* transaction.c: cosmetic: use 'default' branch in trans_free()
* libmsc/ran_conn.c: cosmetic: use tabs instead of N * 8 spaces
* transaction: change arguments of trans_find_by_sm_rp_mr()
* libmsc/gsm_04_11.c: also assign SM-RP-MR to MO transactions
* libmsc/gsm_04_11.c: introduce and use gsm411_assign_sm_rp_mr()
* libmsc/gsm_04_80.c: use gsm0480_create_release_complete()
* libmsc/gsm_04_80.c: add msc_send_ussd_release_complete_cause()
* libmsc/osmo_msc.c: move connection ref-counting code to 'ran_conn.c'
* transaction: fix description of trans_assign_trans_id()
* transaction.h: use #pragma once as include guard
* libmsc/gsm_09_11.c: implement guard timer for NCSS sessions
* libmsc/ran_conn.c: add missing 'break' to OSMO_RAT_EUTRAN_SGS
* libmsc/sgs_iface.c: fix SGS_STATE_NS11 counter reference
* libmsc/sgs_vty.c: always write server address and VLR name
* libmsc/msc_vty.c: drop dead comparison against null
* libmsc/sgs_iface.c: fix copy-paste error
* libmsc/sgs_iface.c: register sgs_vlr_reset_fsm on DSO load
* libmsc/sgs_vty.c: don't print SGs socket error twice
* libmsc: fix: properly initialize the SGs server
* libmsc/sms_queue.c: fix memleak in smsq_take_next_sms()
* tests/sms_queue: track the use of NULL talloc memory contexts
* msc/gsm_data.h: drop unused SMS_HDR_SIZE macro
* configure.ac: drop rudimentary check for -fvisibility=hidden
* configure.ac: drop useless SQLite3 dependency
* libmsc/db.c: print info about database name and libdbi version
* libmsc/gsm_04_11.c: clarify implicit CP-ACK handling
* libmsc/ran_peer.c: fix msgb memleak in ran_peer_rx_reset()
* libmsc/gsm_04_11.c: properly handle TP-User-Data-Length
* libmsc/gsm_04_11.c: fix double init of both SMR and SMC FSMs
* libmsc/gsm_04_11.c: cosmetic: restructure gsm411_mm_send()
* libmsc/gsm_04_08.c: fix: print proper length value
* libmsc/gsm_04_08.c: refactor CM Service Request parsing
* libmsc/gsm_04_08.c: clarify IMEI rejection in gsm48_rx_mm_serv_req()
* libmsc/gsm_04_11_gsup.c: cosmetic: drop useless variable
* tests/.../Makefile.am avoid redundant linkage with librt
* libmsc/sgs_server.c: do not override rc in case of SCTP_SHUTDOWN_EVENT
* libmsc/msc_ho.c: fix unreacheable check of MSC-T role allocation
* libmsc/msc_a.c: fix possible NULL-pointer dereferences
* sms_queue_test: assert return value of osmo_use_count_get_put()
* libmsc/gsm_04_11.c: fix NULL-pointer dereference in gsm340_rx_tpdu()
* libmsc/ran_msg_a.c: avoid ternary operator in struct initialization
* libmsc/ran_msg_a.c: refactor ran_a_decode_lcls_notification()
* libmsc/ran_msg_a.c: prevent chosen_encryption->key buffer overrun
* libmsc/mncc_call.c: fix uninitialized access of stack memory
* libmsc/ran_peer.c: fix msgb memleaks in ran_peer_down_paging()
* libmsc/ran_peer.c: avoid unreasonable use of goto in ran_peer_down_paging()
* libmsc/msc_vty.c: fix: use msub_for_vsub() in subscr_dump_full_vty()
* libmsc/msc_vty.c: fix documentation of 'show subscriber id'
* libmsc/msc_vty.c: use llist_count() in subscr_dump_full_vty()
* libmsc/rtp_stream.c: prevent NULL-pointer dereference
* libmsc/gsm_04_11.c: properly handle MMTS indication
* transaction: accept trans_type enum in trans_log_subsys()
* Use GSM23003_MSISDN_MAX_DIGITS from libosmogsm
* libmsc/msc_vty.c: refactor 'show subscr / conn / trans' commands
* libmsc/msc_vty.c: do not abuse strlen() to check char buffers
* tests: share stubs.h from msc_vlr_test as stubs.c
* Introduce initial unit test for db_sms_* API
* libmsc/db.c: fix storing SMS with empty TP-User-Data
* debian/control: add missing libdbd-sqlite3 to Build-Depends
* libmsc/db.c: fix potential integer overflow
* libmsc/db.c: introduce and use parse_sm_ud_from_result()
* libmsc/db.c: warn user about SMS text truncation
* libmsc/db.c: get rid of hard-coded SMS expiry threshold
* libmsc/mncc_builtin.c: drop dummy switch in int_mncc_recv()
* libmsc/gsm_0(4|9)_11_gsup.c: print error message if subscr is not known
* gsup_client_mux_tx_error_reply(): fix: do not override IMSI
* gsup_client_mux_tx_error_reply(): fix: do not omit session IEs
* gsup_client_mux_tx_error_reply(): fix: do not omit message class IE
* gsup_client_mux_tx_error_reply(): fix: do not omit SM-RP-MR IE
* libmsc/gsm_09_11.c: fix: return trans from establish_nc_ss_trans()
* libmsc/gsm_09_11.c: send GSUP PROS_SS ERROR message when needed
* libmsc/gsm_04_08.c: clean up unused leftover includes
* libmsc/msc_a.c: fix: remove dummy allstate_action of msc_a_fsm
* libmsc/paging.c: avoid double zero-initialization
* libmsc/paging.c: cosmetic: actually use default branch of switch
* libmsc/paging.c: cosmetic: remove leading space in log line
* libmsc/gsm_09_11.c: do not abuse LOG_TRANS() and early trans allocation
* libmsc/gsm_09_11.c: log network-originated session establishment error
* libmsc/gsm_09_11.c: drop rudimentary vsub->cgi.lai.lac check
* libmsc/gsm_09_11.c: drop meaningless check for concurrent paging
* libmsc/msc_net_init.c: pass pointer to gsm_network directly
* libmsc/gsm_09_11.c: inform HLR/EUSE if Paging has failed
* libmsc/gsm_09_11.c: properly handle OSMO_GSUP_MSGT_PROC_SS_ERROR
* libmsc/gsm_09_11.c: avoid double zero-initialization of gsup_msg
* libmsc/gsm_09_11.c: fix broken reference counting for vsub
* libmsc/gsm_09_11.c: do not abuse LOG_TRANS() in gsm0911_rcv_nc_ss()
* libmsc/gsm_09_11.c: do not suppress rc of gsup_client_mux_tx()
* tests/msc_vlr: fix: do not pass RAT type to expect_bssap_clear()
* libvlr/vlr.c: do not expire subscribers if periodic LU is disabled
* gsm_04_11_gsup.c: fix broken reference counting for vsub
* libmsc/gsm_04_11.c: do not abuse LOG_TRANS() in gsm411_alloc_mt_trans()
* libmsc/ran_msg_iu.c: fix: properly handle SAPI IE of RANAP_DirectTransfer
* Fix: add missing semicolons to OSMO_ASSERT statements
* libmsc/msc_vty.c: print subscriber expiration time
[ Harald Welte ]
* Add SGs Interface
* debian: depend on libsctp-dev
* configure.ac: Check for libsctp
* a_iface: Centralize/wrap BSSAP / N-DATA transmission
* a_iface: use 'const' qualifier for ran_conn whenever possible
* a_iface: Fix hexdumping of N-DATA.req
* a_iface: OSMO_ASSERT() if we ever want to send BSSAP with invalid length
* smpp_smsc: Call destroy_tlv() when using build_tlv()
* smpp: Make libsmpp34 use talloc for its allocations
* msub_check_for_release(): Initialize msc_role_a_c
* SMPP: Don't accept password or system-id exceeding spec length
* Iu: Send SMS over SAPI-3
[ Philipp Maier ]
* a_iface: Include CSFB Indication into BSSMAP CLEAR COMMAND
* silent_call: use osmo_strlcpy() instead of strncpy()
* msc_vty: add missing header file
* vlr_sgs: fix SGs IMSI detech from non EPS services
* vlr_sgs: start lu expiration timer on sgs eps detach
* sgs_iface: fix nullpointer dereference
* vlr_sgs_fsm: make sure vsub is marked used when LA is present
* sgs_iface: detect and react to VLR/HLR failure
[ Oliver Smith ]
* debian: depend on libdbd-sqlite3
* vlr_lu_fsm.c: assert for invalid events
* vty: make retrieve-imeisv-early configurable
* vlr: fix IMEI length
* vlr: when setting IMEISV, also set IMEI
* vlr: optionally send IMEI early to HLR
* debian: create -doc subpackage with pdf manuals
* contrib/jenkins.sh: run "make maintainer-clean"
* vlr_lu_fsm.c: don't send LU reject twice
[ Keith ]
* Don't deliver alert notifications to ESME not yet bound.
* Write configuration correctly from vty (alert notifications)
[ Neels Hofmeyr ]
* use only accepted ran_conns for new transactions
* gsm_04_11_gsup.c: drop unused conn lookup
* SMS queue: properly log failed attempts number
* vty: add cmd subscriber ID sms delete-all
* vlr_subscr_name(): use OSMO_STRBUF
* enable osmo_fsm_term_safely(), apply logging changes
* sms queue: avoid repeated Paging for a failed SMS
* vlr_subscr: use osmo_use_count
* add LOG_TRANS, proper context for all transactions
* gsm_04_08_cc: improve logging for CC trans
* smpp: fix vlr_subscr use count bugs
* vlr subscr get/put: also check against NULL
* fix various missing line endings in logging
* gsm_04_11: use gsm48_decode_bcd_number2(), evaluate rc
* large refactoring: support inter-BSC and inter-MSC Handover
* GSUP: include terminating nul in inter-MSC source/destination name
* rename bscconfig.h to config.h, cleanup
* fix regression: fix internal MNCC operation
* vty/cfg: add missing write-back of inter-BSC and inter-MSC HO config
* comment: apply function renames to message cycle explanation
* ran_a_make_handover_request(): allow no encryption
* make msc_a_vsub() and others NULL-safe
* no HO call forwarding if no RTP stream
* LOG_TRANS: store subsys in trans, unify USSD logging back to DMM
* call_leg: remove unused event MSC_EV_CALL_LEG_RTP_RELEASED
* call_leg: document the parent_event_* items
* add DSS logging category
* silence error messages about HANDOVER_END not permitted
* build osmo-msc: add "missing" LIBASN1C_LIBS
* minor comments in msc_vty.c
* manual: adjust and fix auth and ciph docs
* do not force encryption on UTRAN
* add msc_vlr tests for UMTS without ciphering
* doc/sequence_charts/mncc_fsm.msc: add SIP messages, tweak
* doc/sequence_charts: fix naming of mncc_fsm to mncc_call
* vlr_lu_fsm: fix missing event for IMEISV
[ Sylvain Munaut ]
* libmsc: Allow different channel types to be requested as silent calls
* libvlr: Allow 2G auth tuples to be re-used without going through AUTH
* make LOG_TRANS() NULL-safe again
[ Pau Espin Pedrol ]
* debian/control: Fix typo
* sms_queue: Print dest msisdn instead of unknown subscriber
* ran_peer: Move rx_reset_ack logic into its own func
* vty: Add option to enable osmux towards BSCs
* bssap: Detect BSC Osmux support on RESET (ACK) recv
* a_iface: Announce Osmux support on RESET (ACK) send
* Request Osmux CID and forward it in Assign Req and Assign Compl
* db: Fix call to mempcy with NULL src ptr
* db_sms_test: Do not print exact memcmp result
* db_sms_test: Remove libdbi expected driver load errors
* sms_queue.c: Improve misleading log line
* doc: Add Osmux documentation to User Manual
* Remove undefined param passed to logging_vty_add_cmds
* Fix dependency version requirements
[ Omar Ramadan ]
* Allow MME name preformatted as FQDN in SGsAP
[ Alexander Couzens ]
* remove msc specific db counters
* replace osmo_counter with stat_items
[ Eric Wild ]
* libvlr: fix sgsn tmsi creation, replace constant with define
* turn -Werror=null-dereference into a warning
[ Daniel Willmann ]
* manuals: Add script to update vty/counter documentation from docker
* manuals: Update counter/vty documentation
* manuals: Include overview chapter about counters
[ Thorsten Alteholz ]
* fix spelling detected by lintian
[ Keith Whyte ]
* Set coding in mncc_set_cause()
-- Pau Espin Pedrol <pespin@sysmocom.de> Thu, 08 Aug 2019 16:01:38 +0200
osmo-msc (1.3.1) unstable; urgency=medium
[ Neels Hofmeyr ]
* fix build: apply msgb_wrap_with_TL() rename
-- Harald Welte <laforge@gnumonks.org> Tue, 22 Jan 2019 16:02:11 +0100
osmo-msc (1.3.0) unstable; urgency=medium
[ Philipp Maier ]

2
debian/compat vendored
View File

@ -1 +1 @@
9
10

44
debian/control vendored
View File

@ -1,35 +1,38 @@
Source: osmo-msc
Section: net
Priority: extra
Maintainer: Alexander Couzens <lynxis@fe80.eu>
Build-Depends: debhelper (>=9),
Maintainer: Osmocom team <openbsc@lists.osmocom.org>
Build-Depends: debhelper (>= 10),
dh-autoreconf,
autotools-dev,
autoconf,
automake,
libtool,
pkg-config,
libdbi-dev,
libsqlite3-dev,
libsctp-dev,
libtalloc-dev,
libsmpp34-dev (>= 1.12),
libasn1c-dev (>= 0.9.28),
libosmocore-dev (>= 0.10.0),
libosmo-sccp-dev,
libosmo-sigtran-dev (>= 0.8.0),
libosmo-abis-dev,
libosmo-mgcp-client-dev (>= 1.1.0),
libosmo-gsup-client-dev (>= 0.2.1),
libosmo-netif-dev (>= 0.1.0),
libosmo-ranap-dev (>= 0.2.0)
libsmpp34-dev (>= 1.14.0),
libasn1c-dev (>= 0.9.30),
libosmocore-dev (>= 1.9.0),
libosmo-sccp-dev (>= 1.8.0),
libosmo-sigtran-dev (>= 1.8.0),
libosmo-abis-dev (>= 1.5.0),
libosmo-mgcp-client-dev (>= 1.12.0),
libosmo-gsup-client-dev (>= 1.7.0),
libosmo-netif-dev (>= 1.4.0),
libosmo-ranap-dev (>= 1.5.0),
osmo-gsm-manuals-dev (>= 1.5.0)
Standards-Version: 3.9.8
Vcs-Git: git://git.osmocom.org/osmo-msc.git
Vcs-Browser: https://git.osmocom.org/osmo-msc/
Vcs-Git: https://gitea.osmocom.org/cellular-infrastructure/osmo-msc
Vcs-Browser: https://gitea.osmocom.org/cellular-infrastructure/osmo-msc
Homepage: https://osmocom.org/projects/osmomsc
Package: osmo-msc
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Recommends: osmo-mgw
Description: OsmoMSC: Osmocom's Mobile Switching Center for 2G and 3G circuit-switched mobile networks
The Mobile Switching Center (MSC) is the heart of 2G/3G
circuit-switched services. It terminates the A-interface links from the
@ -59,5 +62,14 @@ Description: OsmoMSC: Osmocom's Mobile Switching Center for 2G and 3G circuit-sw
towards a HLR, but the much simpler Osmocom GSUP protocol, which can
be translated to MAP if needed.
.
This package contains the debug symbols for osmo-mgw in order to
This package contains the debug symbols for osmo-msc in order to
generate meaningful backtraces in bug-reports.
Package: osmo-msc-doc
Architecture: all
Section: doc
Priority: optional
Depends: ${misc:Depends}
Description: ${misc:Package} PDF documentation
Various manuals: user manual, VTY reference manual and/or
protocol/interface manuals.

2
debian/copyright vendored
View File

@ -1,6 +1,6 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: osmo-msc
Source: git://git.osmocom.org/osmo-msc
Source: https://gitea.osmocom.org/cellular-infrastructure/osmo-msc
Files: *
Copyright: 2008 Daniel Willmann <daniel@totalueberwachung.de>

1
debian/osmo-msc-doc.install vendored Normal file
View File

@ -0,0 +1 @@
usr/share/doc/osmo-msc-doc/*.pdf

38
debian/postinst vendored Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh -e
case "$1" in
configure)
# Create the osmocom group and user (if it doesn't exist yet)
if ! getent group osmocom >/dev/null; then
groupadd --system osmocom
fi
if ! getent passwd osmocom >/dev/null; then
useradd \
--system \
--gid osmocom \
--home-dir /var/lib/osmocom \
--shell /sbin/nologin \
--comment "Open Source Mobile Communications" \
osmocom
fi
# Fix permissions of previous (root-owned) install (OS#4107)
if dpkg --compare-versions "$2" le "1.12.0"; then
if [ -e /etc/osmocom/osmo-msc.cfg ]; then
chown -v osmocom:osmocom /etc/osmocom/osmo-msc.cfg
chmod -v 0660 /etc/osmocom/osmo-msc.cfg
fi
if [ -d /etc/osmocom ]; then
chown -v root:osmocom /etc/osmocom
chmod -v 2775 /etc/osmocom
fi
mkdir -p /var/lib/osmocom
chown -R -v osmocom:osmocom /var/lib/osmocom
fi
;;
esac
# dh_installdeb(1) will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#

6
debian/rules vendored
View File

@ -46,7 +46,7 @@
# debmake generated override targets
# Set options for ./configure
CONFIGURE_FLAGS += --enable-iu --enable-smpp --with-systemdsystemunitdir=/lib/systemd/system
CONFIGURE_FLAGS += --enable-iu --enable-smpp --with-systemdsystemunitdir=/lib/systemd/system --enable-manuals
override_dh_auto_configure:
dh_auto_configure -- $(CONFIGURE_FLAGS)
#
@ -61,3 +61,7 @@ override_dh_strip:
# Print test results in case of a failure
override_dh_auto_test:
dh_auto_test || (find . -name testsuite.log -exec cat {} \; ; false)
# Don't create .pdf.gz files (barely saves space and they can't be opened directly by most pdf readers)
override_dh_compress:
dh_compress -X.pdf

View File

@ -1,4 +1,5 @@
SUBDIRS = \
examples \
manuals \
sequence_charts \
$(NULL)

View File

@ -1,21 +1,30 @@
!
! OsmoMSC configuration saved from vty
!
log stderr
logging color 1
logging print category-hex 0
logging print category 1
logging timestamp 0
logging print file basename last
logging print level 1
line vty
no login
!
network
network country code 1
mobile network code 1
network country code 001
mobile network code 01
short name OsmoMSC
long name OsmoMSC
encryption a5 0
rrlp mode none
mm info 1
mgw 0
remote-ip 127.0.0.1
remote-port 2427
local-port 2728
msc
mgw remote-ip 10.23.24.1
mgw remote-port 2427
mgw local-port 2728
assign-tmsi
auth-tuple-max-reuse-count 3
auth-tuple-reuse-on-error 1

View File

@ -1,6 +1,14 @@
!
! OsmoMSC configuration saved from vty
!
log stderr
logging color 1
logging print category-hex 0
logging print category 1
logging timestamp 0
logging print file basename last
logging print level 1
line vty
no login
!
@ -12,16 +20,19 @@ network
encryption a5 0
rrlp mode none
mm info 1
mgw 0
remote-ip 127.0.0.1
remote-port 2427
local-port 2728
cs7 instance 0
point-code 0.23.1
asp asp-clnt-OsmoMSC-A-Iu 2905 0 m3ua
! where to reach the STP:
remote-ip 127.0.0.5
! local-ip 10.23.24.1
!local-ip 10.23.24.1
role asp
sctp-role client
msc
cs7-instance-a 0
cs7-instance-iu 0
mgw remote-ip 10.23.24.1
mgw remote-port 2427
mgw local-port 2728
assign-tmsi

View File

@ -1,6 +1,14 @@
!
! OsmoMSC configuration saved from vty
!
log stderr
logging color 1
logging print category-hex 0
logging print category 1
logging timestamp 0
logging print file basename last
logging print level 1
line vty
no login
!
@ -12,18 +20,23 @@ network
encryption a5 0
rrlp mode none
mm info 1
mgw 0
remote-ip 127.0.0.1
remote-port 2427
local-port 2728
cs7 instance 0
point-code 0.23.1
asp asp-clnt-OsmoMSC-A 2905 0 m3ua
remote-ip 127.0.0.5
role asp
sctp-role client
cs7 instance 1
point-code 0.23.2
asp asp-clnt-OsmoMSC-Iu 2905 0 m3ua
remote-ip 127.0.0.6
role asp
sctp-role client
msc
cs7-instance-a 0
cs7-instance-iu 1
mgw remote-ip 10.23.24.1
mgw remote-port 2427
mgw local-port 2728
assign-tmsi

View File

@ -1,6 +1,7 @@
EXTRA_DIST = osmomsc-usermanual.adoc \
osmomsc-usermanual-docinfo.xml \
osmomsc-vty-reference.xml \
regen_doc.sh \
chapters \
images \
vty
@ -13,5 +14,11 @@ if BUILD_MANUALS
VTY_REFERENCE = osmomsc-vty-reference.xml
include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.vty-reference.inc
BUILT_REFERENCE_XML = $(builddir)/vty/msc_vty_reference.xml
$(builddir)/vty/msc_vty_reference.xml: $(top_builddir)/src/osmo-msc/osmo-msc
mkdir -p $(builddir)/vty
$(top_builddir)/src/osmo-msc/osmo-msc --vty-ref-xml > $@
OSMO_REPOSITORY = osmo-msc
include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.common.inc
endif

View File

@ -1,5 +1,8 @@
// autogenerated by show asciidoc counters
These counters and their description based on OsmoMSC UNKNOWN (OsmoMSC).
These counters and their description based on OsmoMSC 1.4.0 (OsmoMSC).
=== Rate Counters
// generating tables for rate_ctr_group
// rate_ctr_group table mobile switching center
@ -7,27 +10,41 @@ These counters and their description based on OsmoMSC UNKNOWN (OsmoMSC).
[options="header"]
|===
| Name | Reference | Description
| loc_update_type:attach | <<msc_loc_update_type:attach>> | Received location update imsi attach requests.
| loc_update_type:normal | <<msc_loc_update_type:normal>> | Received location update normal requests.
| loc_update_type:periodic | <<msc_loc_update_type:periodic>> | Received location update periodic requests.
| loc_update_type:detach | <<msc_loc_update_type:detach>> | Received location update detach indication.
| loc_update_resp:failed | <<msc_loc_update_resp:failed>> | Rejected location updates.
| loc_update_resp:completed | <<msc_loc_update_resp:completed>> | Successful location updates.
| sms:submitted | <<msc_sms:submitted>> | Received a RPDU from a MS (MO).
| sms:no_receiver | <<msc_sms:no_receiver>> | Counts SMS which couldn't routed because no receiver found.
| sms:delivered | <<msc_sms:delivered>> | Global SMS Deliver attempts.
| sms:rp_err_mem | <<msc_sms:rp_err_mem>> | CAUSE_MT_MEM_EXCEEDED errors of MS responses on a sms deliver attempt.
| sms:rp_err_other | <<msc_sms:rp_err_other>> | Other error of MS responses on a sms delive attempt.
| sms:deliver_unknown_error | <<msc_sms:deliver_unknown_error>> | Unknown error occured during sms delivery.
| call:mo_setup | <<msc_call:mo_setup>> | Received setup requests from a MS to init a MO call.
| call:mo_connect_ack | <<msc_call:mo_connect_ack>> | Received a connect ack from MS of a MO call. Call is now succesful connected up.
| call:mt_setup | <<msc_call:mt_setup>> | Sent setup requests to the MS (MT).
| call:mt_connect | <<msc_call:mt_connect>> | Sent a connect to the MS (MT).
| call:active | <<msc_call:active>> | Count total amount of calls that ever reached active state.
| call:complete | <<msc_call:complete>> | Count total amount of calls which got terminated by disconnect req or ind after reaching active state.
| call:incomplete | <<msc_call:incomplete>> | Count total amount of call which got terminated by any other reason after reaching active state.
| loc_update_type:attach | <<msc_loc_update_type:attach>> | Received Location Update (IMSI Attach) requests.
| loc_update_type:normal | <<msc_loc_update_type:normal>> | Received Location Update (LAC change) requests.
| loc_update_type:periodic | <<msc_loc_update_type:periodic>> | Received (periodic) Location Update requests.
| loc_update_type:detach | <<msc_loc_update_type:detach>> | Received IMSI Detach indications.
| loc_update_resp:failed | <<msc_loc_update_resp:failed>> | Rejected Location Updates requests.
| loc_update_resp:completed | <<msc_loc_update_resp:completed>> | Successful Location Update procedures.
| cm_service_request:rejected | <<msc_cm_service_request:rejected>> | Rejected CM Service Requests.
| cm_service_request:accepted | <<msc_cm_service_request:accepted>> | Accepted CM Service Requests.
| paging_resp:rejected | <<msc_paging_resp:rejected>> | Rejected Paging Responses.
| paging_resp:accepted | <<msc_paging_resp:accepted>> | Accepted Paging Responses.
| sms:submitted | <<msc_sms:submitted>> | Total MO SMS received from the MS.
| sms:no_receiver | <<msc_sms:no_receiver>> | Failed MO SMS delivery attempts (no receiver found).
| sms:deliver_unknown_error | <<msc_sms:deliver_unknown_error>> | Failed MO SMS delivery attempts (other reason).
| sms:delivered | <<msc_sms:delivered>> | Total MT SMS delivery attempts.
| sms:rp_err_mem | <<msc_sms:rp_err_mem>> | Failed MT SMS delivery attempts (no memory).
| sms:rp_err_other | <<msc_sms:rp_err_other>> | Failed MT SMS delivery attempts (other reason).
| call:mo_setup | <<msc_call:mo_setup>> | Received MO SETUP messages (MO call establishment).
| call:mo_connect_ack | <<msc_call:mo_connect_ack>> | Received MO CONNECT messages (MO call establishment).
| call:mt_setup | <<msc_call:mt_setup>> | Sent MT SETUP messages (MT call establishment).
| call:mt_connect | <<msc_call:mt_connect>> | Sent MT CONNECT messages (MT call establishment).
| call:active | <<msc_call:active>> | Calls that ever reached the active state.
| call:complete | <<msc_call:complete>> | Calls terminated by DISCONNECT message after reaching the active state.
| call:incomplete | <<msc_call:incomplete>> | Calls terminated by any other reason after reaching the active state.
| nc_ss:mo_requests | <<msc_nc_ss:mo_requests>> | Received MS-initiated call independent SS/USSD requests.
| nc_ss:mo_established | <<msc_nc_ss:mo_established>> | Established MS-initiated call independent SS/USSD sessions.
| nc_ss:mt_requests | <<msc_nc_ss:mt_requests>> | Received network-initiated call independent SS/USSD requests.
| nc_ss:mt_established | <<msc_nc_ss:mt_established>> | Established network-initiated call independent SS/USSD sessions.
| bssmap:cipher_mode_reject | <<msc_bssmap:cipher_mode_reject>> | Number of CIPHER MODE REJECT messages processed by BSSMAP layer
| bssmap:cipher_mode_complete | <<msc_bssmap:cipher_mode_complete>> | Number of CIPHER MODE COMPLETE messages processed by BSSMAP layer
|===
== Osmo Stat Items
// generating tables for osmo_stat_items
== Osmo Counters
// generating tables for osmo_counters
// ungrouped osmo_counters
.ungrouped osmo counters
@ -35,6 +52,5 @@ These counters and their description based on OsmoMSC UNKNOWN (OsmoMSC).
|===
| Name | Reference | Description
| msc.active_calls | <<ungroup_counter_msc.active_calls>> |
| msc.active_nc_ss | <<ungroup_counter_msc.active_nc_ss>> |
|===

View File

@ -101,32 +101,56 @@ operating system on which OsmoMSC is running.
=== Authentication
Authorized subscribers must be entered in the HLR database, see the _OsmoHLR
reference manual_ <<userman-osmohlr>>. If authentication tokens (such as KI for
2G, or K and OP/OPC for UMTS) are present in the HLR, OsmoMSC will only attach
a subscriber after successful authentication.
A subscriber's IMSI must be entered in the HLR database to be able to attach. A
subscriber-create-on-demand feature is also available, see the _OsmoHLR
reference manual_ <<userman-osmohlr>>.
If no authentication keys are present in the HLR for a given subscriber,
OsmoMSC will attach the subscriber _without_ authentication. You can reject
subscribers that lack authentication info in the HLR with this setting:
A known IMSI in the HLR may or may not have authentication keys associated,
which profoundly affects the ability to attach and the algorithms used to
negotiate authentication, as the following sections explain for 2G and 3G.
==== Authentication on 2G
If authentication tokens (such as KI for 2G, or K and OP/OPC for UMTS) are
present in the HLR, OsmoMSC will only attach a subscriber after successful
authentication. Note that the 3G authentication keys are also used on 2G when
the MS indicates UMTS AKA capability, in which case the full UMTS style mutual
authentication may indeed take place on 2G (GERAN).
On 2G, if no authentication keys are present in the HLR for a given subscriber,
OsmoMSC will attach the subscriber _without_ authentication. Subscribers that
lack authentication keys can always be rejected with this setting:
----
network
authentication required
----
==== Authentication on 3G
3G (UTRAN) always requires authentication (a.k.a. Integrity Protection) by
specification, and hence authentication keys must be present in the HLR for a
subscriber to be able to attach on 3G.
OsmoMSC always indicates UIA1 and UIA2 as permitted Integrity Protection
algorithms on 3G.
=== Ciphering
To enable ciphering on the radio link, authentication must take place first:
the Kc resulting from authentication is the key used for ciphering. Hence, all
subscribers must have authentication tokens available in the HLR for ciphering.
the Kc resulting from authentication is the key used for ciphering. Hence, to
be able to use ciphering, a subscriber must have authentication tokens
available in the HLR.
==== Ciphering on 2G
The MS, BTS and MSC must agree on a ciphering algorithm to use.
- The MS sends its supported ciphering algorithms via Classmark IEs during
Location Updating.
- Typically the BSC needs to know which A5 ciphers are supported by connected
BTSes.
BTSes, see the `network / encryption a5` configuration item for OsmoBSC
<<vty-ref-osmobsc>>.
- Finally, OsmoMSC may impose that specific A5 ciphers shall not be considered.
It is the responsibility of the BSC to then pick an A5 cipher that satisfies
@ -143,12 +167,43 @@ network
+
----
network
encryption a5 3
encryption a5 1 3
----
- Never use A5/2: it is an "export grade cipher" and has been deprecated for
its low ciphering strength.
NOTE: At the time of writing, OsmoMSC supports setting only a single A5 cipher,
while it should be able to allow a set of ciphers. This is subject to ongoing
development.
- To allow either no encryption or any of A5/1 or A5/3 based on the presence of
authentication keys and abilities of the MS, SIM and BSC configuration, it is
recommended to enable all ciphers in OsmoMSC. The highest available A5 cipher
will be used; the order in which the A5 options are configured does not
affect the choice.
+
----
network
encryption a5 0 1 3
----
==== Ciphering on 3G
While authentication is always required on 3G, ciphering is optional.
So far OsmoMSC allows switching ciphering on 3G either on or off -- the default
behavior is to enable ciphering. (Individual choice of algorithms may be added
in the future.)
Disable 3G ciphering:
----
network
encryption uea 0
----
Enable 3G ciphering (default):
----
network
encryption uea 1 2
----
OsmoMSC indicates UEA1 and UEA2 as permitted encryption algorithms on 3G.

View File

@ -0,0 +1,65 @@
include::{commondir}/chapters/osmux/osmux.adoc[]
=== Osmux Support in {program-name}
==== {program-name} in a A/IP with IPA/SCCPlite network setup
In this kind of setup, the CN side of BSC co-located MGW is managed by the MSC,
meaning the use of Osmux is transparent to BSC since MSC takes care of both peer
MGW connections. Moreover, in this case the MSC has no dynamic information on
Osmux support in the BSC co-located MGW until `CRCX` time, which means
configuration on both nodes need to be carefully set up so they can work
together.
Osmux usage in {program-name} in managed through the VTY command `osmux
(on|off|only)`. Since there's no dynamic information on Osmux support, it may be
required in the future to have an extra VTY command which can be set per BSC to
fine-tune which ones should use Osmux and which shouldn't.
{program-name} will behave differently during call set up based on the VTY
command presented above:
* `off`: {program-name} won't include an `X-Osmux` extension to `CRCX` sent to
the BSC co-located MGW when configuring the CN side of the MGW endpoint. If
the MGW answers with a `CRCX ACK` containing an `X-Osmux`, {program-name} will
cancel the call establishment.
* `on`: {program-name} will initially configure its co-located MGW to use Osmux, then
similarly send a `CRCX` with an `X-Osmux` extension towards the BSC co-located
MGW. Under this configuration, if the BSC co-located MGW didn't support Osmux,
it could send a `CRCX ACK` without `X-Osmux` extension or fail (depending on
its own configuration), and {program-name} could choose to re-create its local
connection as non-Osmux (RTP) (and possibly try again against BSC co-located
MGW), but this behavior is currently not implemented. As a result, currently
`on` behaves the same as `only`.
* `only`: {program-name} will configure its co-located MGW as well as the BSC
co-located MGW to use Osmux by including the `X-Osmux` MGCP extension. If MGW
rejects to use Osmux, {program-name} will reject the call and the call
establishment will fail.
==== {program-name} in a 3GPP AoIP network setup
Osmux usage in {program-name} in managed through the VTY command `osmux
(on|off|only)`. Once enabled (`on` or `only`), {program-name} will start
appending the vendor specific _Osmux Support_ IE in _BSSMAP RESET_ and _BSSMAP
RESET-ACK_ message towards the BSC in order to announce it supports Osmux, and
BSC will do the same. This way, {program-name} can decide whether to use Osmux
or not based on this information when setting up a call (this time using _Osmux
CID_ IE). It should be noted that this option should not be enabled unless BSCs
managed by {program-name} support handling this extension IE (like OsmoBSC),
3rd-party BSCs might otherwise refuse the related _RESET_/_RESET-ACK_ messages.
{program-name} will behave differently during call set up based on the VTY
command presented above:
* `off`: {program-name} won't use Osmux. That is, it will send a _BSSMAP Assign
Request_ without the _Osmux CID_ IE, and will send a `CRCX` without `X-Osmux`
extension towards its co-located MGW.
* `on`: If BSC announced Osmux support to {program-name} during _BSSMAP RESET_
time, then {program-name} will set up the call to use Osmux (by adding
`X-Osmux` to MGCP `CRCX` and _Osmux CID_ IE to _BSSMAP Assign Request_). If
the BSC didn't announce Osmux support to {program-name}, then {program-name}
will use RTP to set up the call (by avoiding addition of previously described
bits).
* `only`: Same as per `on`, except that {program-name} will allow to set up only
Osmux calls on the CN-side, this is, it will reject to set up voice calls for
BSC which didn't announce Osmux support.

View File

@ -5,14 +5,14 @@ arguments:
=== SYNOPSIS
*osmo-msc* [-h|-V] [-d 'DBGMASK'] [-D] [-c 'CONFIGFILE'] [-s] [-T] [-e 'LOGLEVEL'] [-l 'DATABASE'] [-M 'SOCKETPATH'] [-C]
*osmo-msc* [-h|-V] [-d 'DBGMASK'] [-D] [-c 'CONFIGFILE'] [-s] [-T] [-e 'LOGLEVEL']
=== OPTIONS
*-h, --help*::
Print a short help message about the supported options
*-V, --version*::
Print the compile-time version number of the OsmoBTS program
Print the compile-time version number of the program
*-d, --debug 'DBGMASK','DBGLEVELS'*::
Set the log subsystems and levels for logging to stderr. This
has mostly been superseded by VTY-based logging configuration,
@ -35,16 +35,6 @@ arguments:
Set the global log level for logging to stderr. This has mostly
been deprecated by VTY based logging configuration, see
<<logging>> for more information.
*-l, --database 'DATABASE'*::
Specify the file name of the SQLite3 database to use as SMS storage
*-M, --mncc-sock-path*::
Enable the MNCC socket for an external MNCC handler. See
<<mncc>> for further information.
*-m, --mncc-sock*::
Same as option -M (deprecated).
*-C, --no-dbcounter*::
Disable the regular periodic synchronization of statistics
counters to the database.
=== Multiple instances
@ -74,9 +64,18 @@ smpp
More on SMPP configuration in <<smpp-config-global>>.
The external MNCC handler is configured by the `--mncc-sock` commandline
argument. Choose a different such socket path for each OsmoMSC instance running
on the same file system. See more in <<mncc-external>>.
The external MNCC handler is a UNIX domain socket that is created when external MNCC handling is configured. A separate
path must be used per osmo-msc instance:
----
msc
mncc external /tmp/mncc_socket
----
More on MNCC in <<mncc-external>>.
The SGs interface by default listens on 0.0.0.0:29118 (SCTP). Each instance of OsmoMSC must use a different IP address
and/or port. For details about the configuration of the SGs interface, see section <<sgs>>.
For the following links, OsmoMSC acts as a client and does not listen/bind to a
specific interface, and will hence not encounter conflicts for multiple instances
@ -84,55 +83,47 @@ running on the same interface:
- The SCCP/M3UA links are established by OsmoMSC contacting an STP.
- The GSUP link is established by OsmoMSC contacting an HLR.
- The MGCP link is established by OsmoMSC contacting an MGW.
=== Configure primary links
==== Configure SCCP/M3UA to accept _A_ and _IuCS_ links
OsmoMSC will contact an STP instance to establish an SCCP/M3UA link. BSC and
HNBGW will then reach the MSC via this link. By default, an STP instance is
assumed to listen on the default M3UA port (2905) on the local host.
OsmoMSC acts as client to contact an STP instance and establish an SCCP/M3UA
link.
Establishing an SCCP/M3UA link towards an STP instance not on the local host
can be configured as follows:
An example configuration of OsmoMSC's SCCP link:
----
cs7 instance 0
asp my-OsmoMSC 2905 0 m3ua
! IP address of the remote STP:
remote-ip 10.23.24.1
point-code 0.23.1
asp asp-clnt-OsmoMSC-A-Iu 2905 0 m3ua
remote-ip 127.0.0.1
role asp
sctp-role client
----
This configuration is explained in detail in <<cs7_config>>.
Note that _A_ and _IuCS_ may use different SCCP instances, if so desired:
----
cs7 instance 0
asp my-OsmoMSC-A 2905 0 m3ua
remote-ip 10.23.42.1
role asp
sctp-role client
cs7 instance 1
asp my-OsmoMSC-Iu 2905 0 m3ua
remote-ip 10.23.42.2
role asp
sctp-role client
msc
cs7-instance-a 0
cs7-instance-iu 1
----
A full configuration needs an `asp` on an `as` -- an Application Server Process
running on an Application Server -- as well as a local point code and routing
configuration. The SCCP VTY automatically creates those parts that are missing,
by assuming sane defaults. A complete configuration would look like this:
----
cs7 instance 0
point-code 0.23.1
asp my-OsmoMSC-A-Iu 2905 0 m3ua
remote-ip 127.0.0.1
as my-as-for-OsmoMSC-A-Iu m3ua
asp my-OsmoMSC-A-Iu
routing-key 0 0.23.1
----
==== Configure GSUP to reach the HLR
OsmoMSC will assume a GSUP server (OsmoHLR) to run on the local host and the
@ -146,3 +137,36 @@ hlr
! default port is 4222, optionally configurable by:
remote-port 1234
----
==== Configure MGCP to connect to an MGW
OsmoMSC uses a media gateway (typically OsmoMGW) to direct RTP streams. By
default, an MGW is expected to receive MGCP requests on the IANA-registered
default port for MGCP (2427) on local host (127.0.0.1).
Here is an example configuration for a remote MGW:
----
network
mgw 0
remote-ip 10.9.8.7
remote-port 2427
reset-endpoint rtpbridge/* <1>
----
<1> The 'reset-endpoint' setting instructs the OsmoMGW to send a wildcarded
DLCX to the media gateway. This helps to clear lingering calls from the
media gateway when the OsmoMSC is restarted.
OsmoMSC is also able to handle a pool of media gateways for load
distribution. See also <<mgw_pooling>>.
[NOTE]
====
Previous versions of OsmoMSC (1.9.0 and below) didn't have the 'mgw' VTY node and
hence didn't support the MGW pooling feature. Therefore, historically the MGW
related commands where placed under the `msc` VTY node. The MGW related commands
under the `msc` VTY are still parsed and used but its use is deprecated and
hence discouraged in favour of the new `mgw` node. Writing the config to a file
from within OsmoMSC will automatically convert the config to use the new `mgw`
node.
====

View File

@ -0,0 +1,55 @@
[[sgs]]
== SGs interface
OsmoMSC offers an SGs interface using the SGsAP protocol. The SGs interface is an
optional interface between a 2G (GERAN) / 3G (UTRAN) MSC and an 4G (EUTRAN) MME.
Its purpose is to facilitate both CSFB (Circuit-Switched Fall Back) and SMSoS
(SMS over SGs). It is used for Mobility management (MM) and paging procedures
between the EPS (Evolved Packet Services) and CS (Circuit Switched) domain.
=== VTY configuration
The SGs interface implementation in OsmoMSC is automatically active and requires
only minimal configuration. When no specific configuration is provided OsmoMSC
will listen on 0.0.0.0:29118 (SCTP) for incoming connections.
This is sufficient in the most configurations, but in larger installations,
where services are either tied to specific interfaces and/or more instances of
OsmoMSC run in parallel, a custom configuration is necessary.
The user has the option to configure the IP address (`local-ip`) and the SCTP
port (`local-port`) and also the `vlr-name` that OsmoMSC uses to identify itself
towards the MME. It should be noted that the `vlr-name` is usually the DNS name
for the IP address of the VLR/MSC, so IP address used and the `vlr-name` should
match the DNS server entry.
----
sgs
local-ip 127.0.0.1
local-port 29118
vlr-name vlr.example.net
----
In order to fine tune the behavior of the SGs interface the user also has
control over the relevant timers (`ts5`, `ts6-2`, `ts7`, `ts11`, `ts14`, `ts15`)
and counters (`ns7`, `ns11`). Each timer and counter has to be configured
separately. In the following example we change the value of ts and ns11.
----
sgs
timer ts7 23
counter ns11 100
----
[NOTE]
====
In case multiple instances of OsmoMSC run in parallel, it is advised to use a
different `vlr-name` for each instance. In any case it must be ensured that the
SGs interface of each instance is bound to a different IP address and/or port.
====
=== Connection monitoring
The user can use the VTY command `show sgs-connections` to list the MMEs that
are currently connected to OsmoMSC.

View File

@ -14,22 +14,38 @@ include::{srcdir}/chapters/running.adoc[]
include::{srcdir}/chapters/control.adoc[]
include::./common/chapters/counters-overview.adoc[]
include::{srcdir}/chapters/counters.adoc[]
include::./common/chapters/vty.adoc[]
include::./common/chapters/logging.adoc[]
include::./common/chapters/sigtran-osmocom.adoc[]
include::./common/chapters/cs7-config.adoc[]
include::./common/chapters/cs7-config.adoc[]
include::{srcdir}/chapters/net.adoc[]
include::./common/chapters/smpp.adoc[]
include::./common/chapters/mncc.adoc[]
include::{srcdir}/chapters/osmux_msc.adoc[]
include::./common/chapters/mgwpool.adoc[]
include::{srcdir}/chapters/sgs.adoc[]
include::./common/chapters/control_if.adoc[]
include::./common/chapters/gsup.adoc[]
include::./common/chapters/vty_cpu_sched.adoc[]
include::./common/chapters/port_numbers.adoc[]
include::./common/chapters/bibliography.adoc[]
@ -37,4 +53,3 @@ include::./common/chapters/bibliography.adoc[]
include::./common/chapters/glossary.adoc[]
include::./common/chapters/gfdl.adoc[]

17
doc/manuals/regen_doc.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh -x
if [ -z "$DOCKER_PLAYGROUND" ]; then
echo "You need to set DOCKER_PLAYGROUND"
exit 1
fi
SCRIPT=$(realpath "$0")
MANUAL_DIR=$(dirname "$SCRIPT")
COMMIT=${COMMIT:-$(git log -1 --format=format:%H)}
cd "$DOCKER_PLAYGROUND/scripts" || exit 1
OSMO_MSC_BRANCH=$COMMIT ./regen_doc.sh osmo-msc 4254 \
"$MANUAL_DIR/chapters/counters_generated.adoc" \
"$MANUAL_DIR/vty/msc_vty_reference.xml"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
all:
echo "built only on manual invocation, needs mscgen and dot (graphviz) programs: invoke 'make charts'"
charts: msc dot
EXTRA_DIST = \
$(srcdir)/*.msc \
$(NULL)
CLEANFILES = \
$(builddir)/*.png \
$(NULL)
msc: \
$(builddir)/mncc_call_fsm.png \
$(builddir)/inter_bsc_ho.png \
$(builddir)/inter_msc_ho.png \
$(builddir)/voice_call_external_mncc.png \
$(builddir)/voice_call_internal_mncc.png \
$(builddir)/call_reestablishment.png \
$(NULL)
dot: \
$(NULL)
$(builddir)/%.png: %.msc
mscgen -T png -o $@ $<
$(builddir)/%.png: $(srcdir)/%.dot
dot -Tpng $< > $@
.PHONY: poll
poll:
while true; do $(MAKE) msc dot; sleep 1; done

View File

@ -0,0 +1,33 @@
msc {
hscale="2";
ms[label="MS"],cell1[label="Cell 1 (BTS+BSC)"],cell0[label="Cell 0 (BTS+BSC)"],__msc[label="MSC"];
ms rbox __msc [label="Call Re-Establishment"];
ms note __msc [label="Ongoing voice call: MM is established"];
...;
ms -x cell0 [label="radio link fails"];
ms x- cell0;
__msc abox __msc [label="Keep MM until timeout"];
ms => cell1 [label="Channel Required"];
ms <= cell1 [label="Immediate Assignment"];
ms => cell1 [label="Complete Layer3"];
cell1 => __msc [label="Complete Layer3:\nCM Re-Establishment Request"];
cell0 <= __msc [label="Clear Command"];
cell0 => __msc [label="Clear Complete"];
cell1 <= __msc [label="Authentication Request"];
cell1 => __msc [label="Authentication Response"];
cell1 <= __msc [label="Cipher Mode Commad"];
cell1 => __msc [label="Cipher Mode Complete"];
cell1 <= __msc [label="Assignment Request\nthis Assignment ACKs the CM Re-Establishment"];
ms <= cell1 [label="RR Assignment Command"];
ms => cell1 [label="RR Assignment Complete"];
cell1 => __msc [label="Assignment Complete"];
}

View File

@ -0,0 +1,36 @@
msc {
hscale=2;
bsca [label="BSC-A"], i[label="MSC-I"], a[label="MSC-A"], t[label="MSC-T"], bscb[label="BSC-B"];
i note t [label="'MSC-A,I,T' are explained in 3GPP TS 49.008 '4.3 Roles of MSC-A, MSC-I and MSC-T'"];
i note i [label="I = Internal; the MSC that does BSSMAP to the BSC (may change to a remote MSC-B after HO)"];
a note a [label="A = first; the MSC that has MM control BSSMAP to the BSC (never changes)"];
t note t [label="T = transitory; the MSC that a handover is going towards (may be MSC-A for inter-BSC HO, may be a remote MSC-B)"];
bsca => i [label="BSSMAP Handover Required"];
i -> a [label="BSSMAP Handover Required"];
a -> t [label="MAP Prepare Handover"];
t => bscb [label="BSSMAP Handover Request"];
t <= bscb [label="BSSMAP Handover Request ACK"];
a <- t [label="MAP Prepare Handover Response"];
i <- a [label="MAP Prepare Handover Response"];
bsca <= i [label="BSSMAP Handover Command"];
--- [label="MS sends RACH to new cell"];
t <= bscb [label="BSSMAP Handover Detected"];
a <- t [label="MAP Access Signaling Request"];
t <= bscb [label="BSSMAP Handover Complete"];
a <- t [label="MAP Send End Signal"];
a abox a [label="MSC-A accepts the new BSC"];
i note t [label="previous MSC-I gets dropped, MSC-T becomes the new MSC-I"];
i abox i [label="discard"];
t abox t [label="MSC-I"];
bsca <= i [label="BSSMAP Clear Command"];
}

View File

@ -0,0 +1,82 @@
msc {
hscale=2;
bsca [label="BSC-A"], ai[label="MSC-I (at MSC-A)"], a[label="MSC-A"], bt[label="MSC-T (at MSC-B)"], bi[label="MSC-I (at MSC-B)"], bscb[label="BSC-B"],
ct[label="MSC-T (at MSC-C)"], bscc[label="BSC-C"];
ai note bt [label="'MSC-A,I,T' are explained in 3GPP TS 49.008 '4.3 Roles of MSC-A, MSC-I and MSC-T'"];
ai note ai [label="I = Internal; the MSC that does BSSMAP to the BSC (may change to a remote MSC-B after HO)"];
a note a [label="A = first; the MSC that has MM control (never changes)"];
bt note bi [label="B = second; the MSC that acts as BSS relay for MSC-A"];
bt note bt [label="T = transitory; the MSC that a handover is going towards (may be MSC-A for inter-BSC HO, may be a remote MSC-B)"];
bsca => ai [label="BSSMAP Handover Required"];
ai -> a [label="BSSMAP Handover Required"];
a rbox a [label="MSC-A routes all MSC-T messages to remote MSC-B."];
a => bt [label="MAP Prepare Handover"];
a note bt [label="in Osmocom, MAP messages are actually sent as GSUP, to the HLR"];
bt rbox bt [label="MSC-B routes all MSC-A type messages back to MSC-A."];
bt rbox bt [label="MSC-B generates a Handover MSISDN"];
bt => bscb [label="BSSMAP Handover Request"];
bt <= bscb [label="BSSMAP Handover Request ACK"];
a <= bt [label="MAP Prepare Handover Response"];
a => bt [label="establish SIP call to Handover MSISDN via external MNCC"];
ai <- a [label="BSSMAP Handover Command"];
bsca <= ai [label="BSSMAP Handover Command"];
--- [label="MS sends RACH to new cell"];
bt <= bscb [label="BSSMAP Handover Detected"];
a <= bt [label="MAP Access Signaling Request"];
bt <= bscb [label="BSSMAP Handover Complete"];
a <= bt [label="MAP Send End Signal"];
bt rbox bt [label="MSC-B drops the generated Handover MSISDN"];
a abox a [label="MSC-A accepts the new MSC-B and BSC"];
ai note bt [label="previous MSC-I (A) gets dropped, MSC-T (B) becomes the new MSC-I"];
ai rbox a [label="MSC-A performs all MSC-I tasks via MAP at remote MSC-B's MSC-I."];
bt abox bi [label="MSC-I"];
ai abox ai [label="discard"];
bsca <= ai [label="BSSMAP Clear Command"];
...;
...;
--- [label="Another inter-MSC handover"];
a note bi [label="MSC-A remains in charge"];
bscb => bi [label="BSSMAP Handover Required"];
bi => a [label="BSSMAP Handover Required"];
a rbox a [label="MSC-A routes all MSC-T messages to remote MSC-C."];
a => ct [label="MAP Prepare Handover"];
ct rbox ct [label="MSC-C routes all MSC-A type messages back to MSC-A."];
ct => bscc [label="BSSMAP Handover Request"];
ct <= bscc [label="BSSMAP Handover Request ACK"];
a <= ct [label="MAP Prepare Handover Response"];
a => bi [label="MAP Prepare Handover Response"];
bscb <= bi [label="BSSMAP Handover Command"];
--- [label="MS sends RACH to new cell"];
ct <= bscc [label="BSSMAP Handover Detected"];
a <= ct [label="MAP Access Signaling Request"];
ct <= bscc [label="BSSMAP Handover Complete"];
a <= ct [label="MAP Send End Signal"];
a abox a [label="MSC-A accepts the new MSC-C and BSC"];
bi note ct [label="previous MSC-I (B) gets dropped, MSC-T (B) becomes the new MSC-I"];
ai rbox a [label="MSC-A performs all MSC-I tasks via MAP at remote MSC-C's MSC-I."];
ct abox ct [label="MSC-I"];
bi abox bi [label="discard"];
bscb <= bi [label="BSSMAP Clear Command"];
}

View File

@ -0,0 +1,104 @@
msc {
hscale=3;
msc1[label="osmo-msc"], mncc1[label="MNCC FSM\n(osmo-msc mncc_call.c)"], sipcon1[label="osmo-sip-connector"], sip[label="PBX"], sipcon2[label="osmo-sip-connector"], mncc2[label="MNCC FSM\n(osmo-msc mncc_call.c)"], msc2[label="osmo-msc"];
msc1 note sipcon1 [label="MO call"];
sipcon2 note msc2 [label="MT call"];
mncc1 abox mncc1 [label="MNCC_CALL_ST_NOT_STARTED"];
msc1 rbox msc1 [label="mncc_outgoing_start()"];
msc1 -> mncc1 [label="MNCC_CALL_EV_OUTGOING_START"];
mncc1 abox mncc1 [label="MNCC_CALL_ST_OUTGOING_WAIT_PROCEEDING"];
mncc1 => sipcon1 [label="MNCC_SETUP_IND
\n callref, IMSI, called and calling number, SDP"];
sipcon1 => sip [label="SIP INVITE
\n from, to, SDP"];
sipcon1 <= sip [label="SIP 100 Trying"];
mncc1 <= sipcon1 [label="MNCC_RTP_CREATE
\n callref"];
mncc1 rbox mncc1 [label="mncc_rx_rtp_create()"];
mncc1 => sipcon1 [label="MNCC_RTP_CREATE
\n callref, RTP IP address and port"];
mncc1 <= sipcon1 [label="MNCC_CALL_PROC_REQ
\n callref, RTP IP address and port"];
mncc1 abox mncc1 [label="MNCC_CALL_ST_OUTGOING_WAIT_COMPLETE"];
sip => sipcon2 [label="SIP INVITE
\n from, to, SDP"];
sipcon2 => sip [label="SIP 100 Trying"];
msc2 <= sipcon2 [label="MNCC_SETUP_REQ
\n callref, called and calling number
\n SDP"];
mncc2 abox mncc2 [label="MNCC_CALL_ST_NOT_STARTED"];
msc2 rbox msc2 [label="mncc_incoming_start()"];
msc2 -> mncc2 [label="MNCC_CALL_EV_INCOMING_START"];
mncc2 abox mncc2 [label="MNCC_CALL_ST_INCOMING_WAIT_COMPLETE"];
mncc2 => sipcon2 [label="MNCC_CALL_CONF_IND
\n callref, bearer capabilities, cccap and IMSI, SDP?"];
mncc2 <= sipcon2 [label="MNCC_RTP_CREATE
\n callref"];
mncc2 rbox mncc2 [label="mncc_rx_rtp_create()"];
mncc2 => sipcon2 [label="MNCC_RTP_CREATE
\n callref, RTP IP address and port, SDP?"];
mncc2 => sipcon2 [label="MNCC_ALERT_IND
\n callref"];
sipcon2 => sip [label="SIP 180 Ringing
\n SDP"];
sipcon1 <= sip [label="SIP 180 Ringing
\n SDP"];
mncc1 <= sipcon1 [label="MNCC_ALERT_REQ
\n callref and progress"];
sipcon1 => sip [label="SIP PRACK 180 Ringing"];
sipcon1 <= sip [label="SIP PRACK 200"];
mncc1 <= sipcon1 [label="MNCC_RTP_CONNECT
\n callref, RTP IP and port"];
mncc1 rbox mncc1 [label="mncc_rx_rtp_connect()"];
msc1 <- mncc1 [label="rtp_stream_set_remote_addr()"];
mncc2 => sipcon2 [label="MNCC_SETUP_CNF
\n callref, imsi and connected number, SDP?"];
sipcon2 => sip [label="SIP 200 OK
\n SDP"];
mncc2 <= sipcon2 [label="MNCC_RTP_CONNECT
\n callref, RTP IP and port"];
mncc2 rbox mncc2 [label="mncc_rx_rtp_connect()"];
mncc2 <= sipcon2 [label="MNCC_SETUP_COMPL_REQ
\n callref"];
mncc2 abox mncc2 [label="MNCC_CALL_ST_TALKING"];
sipcon1 <= sip [label="SIP 200 OK INVITE"];
mncc1 <= sipcon1 [label="MNCC_SETUP_RSP
\n callref"];
mncc1 => sipcon1 [label="MNCC_SETUP_COMPL_IND
\n callref"];
mncc1 abox mncc1 [label="MNCC_CALL_ST_TALKING"];
sipcon1 => sip [label="SIP ACK"];
...;
... [label="Call goes on for a while..."];
...;
mncc1 rbox mncc1 [label="mncc_release()"];
mncc1 => sipcon1 [label="MNCC_DISC_IND
\n callref and cause"];
mncc1 abox mncc1 [label="MNCC_CALL_ST_WAIT_RELEASE_ACK"];
sipcon1 => sip [label="SIP BYE"];
sipcon1 <= sip [label="SIP 200 OK"];
mncc1 <= sipcon1 [label="MNCC_REL_REQ
\n callref and cause"];
sip => sipcon2 [label="SIP BYE"];
sip <= sipcon2 [label="SIP 200 OK"];
mncc2 <= sipcon2 [label="MNCC_DISC_REQ
\n callref and cause"];
mncc2 => sipcon2 [label="MNCC_REL_IND
\n callref and cause"];
mncc2 abox mncc2 [label="terminated"];
mncc1 => sipcon1 [label="MNCC_REL_CNF
\n callref"];
mncc1 abox mncc1 [label="terminated"];
}

View File

@ -0,0 +1,753 @@
#!/usr/bin/env python3
doc=r'''
Reading a log, it can be hard to figure out what is the important bit going on.
This is a tool that reads an osmo-msc log and tries to compose a ladder diagram from it automatically.
'''
import argparse
import sys
import re
import tempfile
import os
def error(*msg):
sys.stderr.write('%s\n' % (''.join(msg)))
exit(1)
def quote(msg, quote='"'):
return '"%s"' % (msg.replace('"', r'\"'))
class Entity:
def __init__(self, name, descr=None, attrs={}):
self.name = name
self.descr = descr
self.attrs = attrs
class Arrow:
def __init__(self, mo_mt, left, arrow, right, descr=None, attrs={}, ran_conn=None, imsi=None, tmsi=None):
self.mo_mt = mo_mt
self.left = left
self.arrow = arrow
self.right = right
self.descr = descr
self.attrs = attrs
self.ran_conn = ran_conn
self.imsi = imsi
self.tmsi = tmsi
def __repr__(self):
return 'Arrow(%s %s %s %s: %s IMSI=%s)' % (self.mo_mt, self.left, self.arrow, self.right, self.descr, self.imsi)
class Separator:
def __init__(self):
self.separator = None
self.descr = None
self.attrs = {}
class EmptyLine:
def __init__(self):
self.count = 1
MS = 'ms'
UE = 'ms' #'ue'
MS_UE_UNKNOWN = 'ms' #None
MSC = 'msc'
MGW = 'mgw'
MNCC = 'mncc'
MO = 'mo'
MT = 'mt'
MO_MT_UNKNOWN = None
class OutputBase:
def __init__(self, write_to, start_with_re=None):
self._write_to = write_to
self.start_with_re = None
if start_with_re is not None:
self.start_with_re = re.compile(start_with_re)
def head(self):
self.writeln('# Generated by osmo-msc.git/doc/sequence_charts/msc_log_to_ladder.py')
def tail(self):
pass
def render(self, diagram):
self.head()
if diagram.root_attrs:
self.root_attrs(diagram.root_attrs)
self.entities(diagram.entities)
started = (self.start_with_re is None)
for line in diagram.lines:
if not started:
if hasattr(line, 'descr') and self.start_with_re.match(line.descr):
started = True
else:
continue
self.add(line)
self.tail()
def entities(self, entities):
for entity in entities:
self.entity(entity)
def write(self, line):
self._write_to.write(line)
def writeln(self, line):
self.write('%s\n' % line)
def emptyline(self, emptyline):
self.write('\n' * emptyline.count);
def add(self, thing):
func = getattr(self, thing.__class__.__name__.lower())
func(thing)
class OutputLadder(OutputBase):
def indent_multiline(self, s):
return s.replace('\n', '\n\t')
def attrs_str(self, attrs, prefix=' '):
if not attrs:
return ''
return '%s{%s}' % (prefix or '', ','.join('%s=%s' % (k,v) for k,v in attrs.items()))
def root_attrs(self, attrs):
self.writeln(self.attrs_str(attrs, prefix=None))
def entity(self, entity):
self.writeln('%s = %s%s' % (entity.name, self.indent_multiline(entity.descr), self.attrs_str(entity.attrs)))
def arrow(self, arrow):
mo_mt = arrow.mo_mt or MO
def prepend_mo_mt(name):
if name in ('.', MNCC):
return name
return '%s%s' % (mo_mt, name)
self.writeln('%s %s %s%s%s%s'
% (prepend_mo_mt(arrow.left),
arrow.arrow,
prepend_mo_mt(arrow.right),
'\t' if arrow.descr else '',
self.indent_multiline(arrow.descr or ''),
self.attrs_str(arrow.attrs)))
def separator(self, sep_str, descr, attrs):
self.writeln('%s%s%s%s'
% (separator.separator,
' ' if separator.descr else '',
self.indent_multiline(separator.descr or ''),
self.attrs_str(separator.attrs)))
class OutputMscgen(OutputBase):
ARROWS = {
'>' : '=>>',
'->' : '=>',
'-->' : '>>',
'~>' : '->',
'=>' : ':>',
'-><' : '-x',
'<' : '<<=',
'<-' : '<=',
'<--' : '<<',
'<~' : '<-',
'<=' : '<:',
'><-' : 'x-',
'<>' : 'abox',
'()' : 'rbox',
'[]' : 'note',
}
def head(self):
super().head()
self.writeln('msc {')
def tail(self):
self.writeln('}')
def entities(self, entities):
estr = []
for entity in entities:
estr.append('%s%s' % (entity.name, self.attrs_str(self.all_attrs(entity.descr, entity.attrs), prefix='')))
if not estr:
return
self.writeln('%s;' % (','.join(estr)))
def attrs_list_str(self, attrs):
if not attrs:
return ''
def escape(s):
return s.replace('\n', r'\n').replace('\r', '').replace('\t', r'\t')
return ','.join('%s="%s"' % (k,escape(v)) for k,v in attrs.items())
def attrs_str(self, attrs, prefix=' '):
attrs_list_str = self.attrs_list_str(attrs)
if not attrs_list_str:
return ''
return '%s[%s]' % (prefix or '', attrs_list_str)
def root_attrs(self, attrs):
if not attrs:
return
self.writeln('%s;' % self.attrs_list_str(attrs))
def all_attrs(self, descr, attrs):
a = {}
if descr:
a['label'] = descr
a.update(attrs)
return a
def entity(self, entity):
error('OutputMscgen.entity() should not be called')
def arrow_txlate(self, arrow):
txlate = OutputMscgen.ARROWS.get(arrow)
if not txlate:
error('Unknown arrow: %r' % arrow)
return txlate
def arrow(self, arrow):
mo_mt = arrow.mo_mt or MO
def prepend_mo_mt(name):
if name in ('.', MNCC):
return name
return '%s%s' % (mo_mt, name)
l = prepend_mo_mt(arrow.left)
r = arrow.right
if r == '.':
r = l
else:
r = prepend_mo_mt(r)
a = {'label': arrow.descr}
a.update(arrow.attrs)
attrs = self.attrs_str(a)
self.writeln('%s %s %s%s;'
% (l, self.arrow_txlate(arrow.arrow), r,
self.attrs_str(self.all_attrs(arrow.descr, arrow.attrs), prefix='\t')))
def separator(self, sep_str, descr, attrs):
self.writeln('%s%s%s%s;'
% (separator.separator,
self.attrs_str(self.all_attrs(descr, attrs), prefix='\t')))
def emptyline(self, emptyline):
self.write('\n' * emptyline.count);
def ms_from_ran(ran_type_or_conn):
if ran_type_or_conn.startswith('UTRAN-Iu'):
return UE
if ran_type_or_conn.startswith('RANAP'):
return UE
if ran_type_or_conn.startswith('GERAN-A'):
return MS
if ran_type_or_conn.startswith('BSS'):
return MS
return MS_UE_UNKNOWN
class Diagram:
def __init__(self):
self.root_attrs = {}
self.entities = []
self.lines = []
self.mo_mt_unknown_lines = []
def add_line(self, line):
self.lines.append(line)
def resolve_unknown_mo_mt(self):
def try_match(a, b):
if a < 0 or a >= len(self.lines):
return False
if b < 0 or b >= len(self.lines):
return False
la = self.lines[a]
lb = self.lines[b]
if not hasattr(lb, 'mo_mt'):
return False
if lb.mo_mt == MO_MT_UNKNOWN:
return False
for match_attr in ('imsi', 'tmsi', 'ran_conn'):
if not hasattr(la, match_attr):
continue
if not hasattr(lb, match_attr):
continue
la_attr = getattr(la, match_attr)
if la_attr is None:
continue
lb_attr = getattr(lb, match_attr)
if la_attr == lb_attr:
la.mo_mt = lb.mo_mt
return True
return False
while True:
changes = 0
for i in range(len(self.lines)):
line = self.lines[i]
if not hasattr(line, 'mo_mt'):
continue
if line.mo_mt is not MO_MT_UNKNOWN:
continue
# don't know MO/MT, try to resolve from near messages
for j in range(1,100):
if try_match(i, i-j):
break
if try_match(i, i+j):
break
if line.mo_mt is not MO_MT_UNKNOWN:
changes += 1
if not changes:
break
re_source_file_last = re.compile(r'(.*) \(([^):]+:[0-9]+)\)$')
class Rule:
def __init__(self, name, re_str, handler):
self.name = name
self.re = re.compile(re_str)
self.handler = handler
def match(self, line):
m = self.re.match(line)
if not m:
return False
return self.handler(m)
def mo_mt_from_l3type(l3type):
if l3type == 'PAGING_RESP':
return MT
elif l3type == 'CM_SERVICE_REQ':
return MO
else:
return MO_MT_UNKNOWN
def int_to_hex(val, bits):
return hex((int(val) + (1 << bits)) % (1 << bits))
class Callref:
MAX = 0x7fffffff
MIN = -0x80000000
BITS = 32
def int_to_hex(val):
return int_to_hex(val, Callref.BITS)
def hex_to_int(hexstr):
val = int(hexstr, 16)
if val > Callref.MAX:
val = Callref.MIN + (val & Callref.MAX)
return val
class Parse:
def __init__(self, output, mask_values=False):
self.diagram = Diagram()
self.output = output
self.linenr = 0
self.rules = []
self.rules_hit = {}
self.seen_udtrace_mncc = False
self.callrefs_mo_mt = {}
self.mask_values = mask_values
self.masked_values = {}
for member in dir(self):
if not member.startswith('rule_'):
continue
func = getattr(self, member)
if not callable(func):
continue
docstr = func.__doc__
if not docstr:
continue
re_str = docstr.splitlines()[0]
self.rules.append(Rule(name=member, re_str=re_str, handler=func))
self.rules_hit[member] = 0
def error(self, *msg):
error('line %d: ' % self.linenr, *msg)
def start(self):
self.diagram.root_attrs = {'hscale': '3'}
for name, descr in (
('moms', 'MS,BSS (MO)\\nUE,hNodeB (MO)'),
#('moue', 'UE,hNodeB (MO)'),
('momgw', 'MGW for MSC (MO)'),
('momsc', 'MSC (MO)'),
('mncc', 'MNCC'),
('mtmsc', 'MSC (MT)'),
('mtmgw', 'MGW for MSC (MT)'),
('mtms', 'BSS,MS (MT)\\nhNodeB,UE (MT)'),
#('mtue', 'hNodeB,UE (MT)'),
):
self.diagram.entities.append(Entity(name, descr))
def end(self):
self.diagram.resolve_unknown_mo_mt()
self.output.render(self.diagram)
def mask_value(self, name, val):
if not self.mask_values:
return val
if not val:
return val
name_dict = self.masked_values.get(name)
if not name_dict:
name_dict = {}
self.masked_values[name] = name_dict
masked_val = name_dict.get(val)
if masked_val is None:
masked_val = '%s-%d' % (name, len(name_dict) + 1)
name_dict[val] = masked_val
return masked_val
def add_line(self, line):
self.linenr += 1
if line.endswith('\n'):
line = line[:-1]
if line.endswith('\r'):
line = line[:-1]
self.interpret(line)
def interpret(self, line):
m = re_source_file_last.match(line)
if m:
line = m.group(1)
for rule in self.rules:
if rule.match(line):
self.rules_hit[rule.name] = self.rules_hit.get(rule.name, 0) + 1
break
RE_DTAP_NAME = re.compile('.*GSM48_MT_([^_]+)_(.+)')
def rule_paging(self, m):
r'.*ran_peer\(([^:]+):.* Paging for ([^ ]+) on ([^ ]+)'
ran_type, subscr, cell = m.groups()
self.diagram.add_line(Arrow(MT, ms_from_ran(ran_type), '<', MSC, 'Paging'))
return True
RE_IMSI = re.compile('IMSI-([0-9]+)')
RE_TMSI = re.compile('TMSI-0x([0-9a-fA-F]+)')
def rule_dtap(self, m):
r'.*msc_a\(([^)]*):([^:]+):([^:]+)\).* (Dispatching 04.08 message|Sending DTAP): (.+)$'
subscr, ran_conn, l3type, rx_tx, dtap = m.groups()
tx = (rx_tx == 'Sending DTAP')
m = self.RE_DTAP_NAME.match(dtap)
if m:
dtap = '%s %s' % m.groups()
if 'IMSI_DETACH_IND' in dtap:
# detecting IMSI Detach separately, because this log line does not contain the IMSI.
# By using the rule_imsi_detach(), we can accurately put it on the MO/MT side.
return True
if l3type == 'NONE' and not tx and dtap.endswith('PAG_RESP'):
e = MT
else:
e = mo_mt_from_l3type(l3type)
imsi = None
for m in Parse.RE_IMSI.finditer(subscr):
imsi = m.group(1)
tmsi = None
for m in Parse.RE_TMSI.finditer(subscr):
tmsi = m.group(1)
self.diagram.add_line(Arrow(e, ms_from_ran(ran_conn), '<' if tx else '>', MSC, dtap,
ran_conn=ran_conn, imsi=imsi, tmsi=tmsi))
return True
def rule_imsi_detach(self, m):
r'.*IMSI DETACH for IMSI-([0-9]+):.*'
imsi = m.group(1)
e = MO_MT_UNKNOWN
self.diagram.add_line(Arrow(e, MS_UE_UNKNOWN, '>', MSC, 'IMSI Detach', imsi=imsi))
return True
def rule_mgcp_tx(self, m):
r'.*mgw-endp\([^)]*:([^:]+):([^:]+)\).* (rtpbridge[^ ]+) .* RTP_TO_(RAN|CN)( CI=([^:]+)|): ([^ :]+).*: Sending'
ran, l3type, endp, rtp_to, cond_ci, ci, verb = m.groups()
e = mo_mt_from_l3type(l3type)
if '*' not in endp:
endp = self.mask_value('EP', endp)
ci = self.mask_value('CI', ci)
ci_str = ''
if ci:
ci_str = ' %s' % ci
self.diagram.add_line(Arrow(e, MGW, '<', MSC, 'for %s: %s\\n%s%s' % (rtp_to, verb, endp, ci_str)))
return True
def rule_mgcp_rx(self, m):
r'.*mgw-endp\(([^)]+):([^:)]+):([^:)]+)\).* (rtpbridge[^ ]+) .* RTP_TO_(RAN|CN)( CI=([^:]+)|).*: received successful response to ([^:]+): RTP=[^:]+:([0-9.:]+)'
subscr, ran_conn, l3type, endp, rtp_to, cond_ci, ci, verb, rtp = m.groups()
e = mo_mt_from_l3type(l3type)
endp = self.mask_value('EP', endp)
ci = self.mask_value('CI', ci)
ci_str = ''
if ci:
ci_str = ' %s' % ci
rtp = self.mask_value('IP:port', rtp)
self.diagram.add_line(Arrow(e, MGW, '>', MSC, 'for %s: %s OK\\n%s%s %s' % (rtp_to, verb, endp, ci_str, rtp)))
return True
def rule_ran_tx(self, m):
r'.*msc_a\(([^)]+):([^:)]+):([^:)]+)\).* RAN encode: ([^: ]+): (.+)$'
subscr, ran_conn, l3type, ran_type, msg_type = m.groups()
if msg_type in ('DTAP', 'DirectTransfer'):
# will get DTAP details from rule_dtap() instead, not from BSSMAP logging
return True
if msg_type.startswith('Tx'):
# skip 'Tx RANAP SECURITY MODE COMMAND to RNC, ik 47...'
return True
if '=' in msg_type:
# skip 'RAB Assignment: rab_id=1, rtp=192.168.178.66:50008, use_x213_nsap=1'
return True
e = mo_mt_from_l3type(l3type)
imsi = None
for m in Parse.RE_IMSI.finditer(subscr):
imsi = m.group(1)
tmsi = None
for m in Parse.RE_TMSI.finditer(subscr):
tmsi = m.group(1)
self.diagram.add_line(Arrow(e, ms_from_ran(ran_conn), '<', MSC, '(%s) %s' % (ran_type, msg_type),
ran_conn=ran_conn, imsi=imsi, tmsi=tmsi))
return True
def rule_ran_rx(self, m):
r'.*msc_a\(([^)]+):([^:)]+):([^:)]+)\).* RAN decode: ([^: ]+) (.+)$'
subscr, ran_conn, l3type, ran_type, msg_type = m.groups()
if msg_type in ('DTAP', 'DirectTransfer', 'DirectTransfer RAN PDU'):
# will get DTAP details from rule_dtap() instead, not from BSSMAP logging
return True
e = mo_mt_from_l3type(l3type)
imsi = None
for m in Parse.RE_IMSI.finditer(subscr):
imsi = m.group(1)
tmsi = None
for m in Parse.RE_TMSI.finditer(subscr):
tmsi = m.group(1)
self.diagram.add_line(Arrow(e, ms_from_ran(ran_type), '>', MSC, '(%s) %s' % (ran_type, msg_type),
ran_conn=ran_conn, imsi=imsi, tmsi=tmsi))
return True
def rule_cc_state(self, m):
r'.*trans\(CC[^) ]* [^ )]+:([^:)]+) callref-([^ ]+) [^)]+\) new state ([^ ]+) -> ([^ ]+)'
l3type, callref_hex, from_state, to_state = m.groups()
e = mo_mt_from_l3type(l3type)
self.callrefs_mo_mt[callref_hex] = e
self.diagram.add_line(Arrow(e, MSC, '<>', '.', 'CC state:\\n%s' % to_state))
return True
def rule_log_mncc_no_rtp(self, m):
r'.*trans\(CC[^) ]* [^ )]+:([^:)]+) callref-([^ ]+) [^)]+\) (tx|rx) (MNCC_[^ ]*)$'
l3type, callref_hex, tx_rx, mncc_msg = m.groups()
if self.seen_udtrace_mncc:
# If no udtrace is present, take the MNCC logging.
# But if there is udtrace logging available, we should not duplicate those MNCC lines.
return True
tx = (tx_rx == 'tx')
try:
e = self.callrefs_mo_mt.get(callref_hex, MT)
except:
e = MT
self.diagram.add_line(Arrow(e, MSC, '>' if tx else '<', 'mncc', mncc_msg))
return True
def rule_log_mncc_with_rtp(self, m):
r'.*trans\(CC[^) ]* [^ )]+:([^:)]+) callref-([^ ]+) [^)]+\) (tx|rx) (MNCC_[^ ]*) \(RTP=([^){]+)(|{.*})\)$'
l3type, callref_hex, tx_rx, mncc_msg, rtp, codec = m.groups()
if self.seen_udtrace_mncc:
# If no udtrace is present, take the MNCC logging.
# But if there is udtrace logging available, we should not duplicate those MNCC lines.
return True
tx = (tx_rx == 'tx')
try:
e = self.callrefs_mo_mt.get(callref_hex, MT)
except:
e = MT
rtp = self.mask_value('IP:port', rtp)
self.diagram.add_line(Arrow(e, MSC, '>' if tx else '<', 'mncc', f'{mncc_msg}\\n{rtp}'))
return True
RE_MNCC_RTP = re.compile(' ip := ([^, ]+), rtp_port := ([0-9]+),')
RE_MNCC_CALLREF = re.compile(' callref := ([^ ,]+), ')
# detecting MNCC with udtrace has the advantage that we also get an indication whether RTP information is
# present
def rule_udtrace_mncc(self, m):
r'.*(write|recv).* (Tx|Rx): \{ msg_type := ([^ ]+) .* u := \{ (.*) \} \}$'
write_recv, tx_rx, msg_type, u = m.groups()
self.seen_udtrace_mncc = True
tx = (tx_rx == 'Tx')
callref_intstr = None
for m in Parse.RE_MNCC_CALLREF.finditer(u):
callref_intstr = m.group(1)
if not callref_intstr:
# log only MNCC that has a callref
return True
try:
e = self.callrefs_mo_mt.get(Callref.int_to_hex(callref_intstr), MT)
except:
e = MT
descr = msg_type
for m in Parse.RE_MNCC_RTP.finditer(u):
ip_str, port_str = m.groups()
try:
if int(ip_str) == 0 or int(port_str) == 0:
break
except:
break
ip_hex = int_to_hex(ip_str, 32)
ip = []
ip_val = int(ip_hex, 16)
for byte in range(4):
ip.insert(0, (ip_val & (0xff << (8*byte))) >> (8*byte))
rtp_info = '%s:%s' % ('.'.join(str(b) for b in ip), port_str)
rtp_info = self.mask_value('IP:port', rtp_info)
descr = '%s\\n%s' % (descr, rtp_info)
break
self.diagram.add_line(Arrow(e, MSC, '>' if tx else '<', 'mncc', descr))
return True
def rule_cc_timer(self, m):
r'.*trans\(CC.*IMSI-([0-9]+):.*\) (starting|stopping pending) (guard timer|timer T[0-9]+)( with ([0-9]+) seconds|)'
imsi, start_stop, t, with_cond, s = m.groups()
start = (start_stop == 'starting')
e = MO_MT_UNKNOWN
if start:
self.diagram.add_line(Arrow(e, MSC, '[]', '.', 'CC starts %s (%ss)' % (t, s), imsi=imsi))
else:
self.diagram.add_line(Arrow(e, MSC, '[]', '.', 'CC stops %s' % (t), imsi=imsi))
return True
def translate(inf, outf, cmdline):
if cmdline.output_format == 'mscgen':
output = OutputMscgen(outf, cmdline.start_with_re)
else:
output = OutputLadder(outf, cmdline.start_with_re)
parse = Parse(output, cmdline.mask_values)
parse.start()
while inf.readable():
line = inf.readline()
if not line:
break;
parse.add_line(line)
parse.end()
if cmdline.verbose:
for name, count in parse.rules_hit.items():
print(f" {name}: {count}")
def open_output(inf, cmdline):
if cmdline.output_file == '-':
translate(inf, sys.stdout, cmdline)
else:
with tempfile.NamedTemporaryFile(dir=os.path.dirname(cmdline.output_file), mode='w', encoding='utf-8') as tmp_out:
translate(inf, tmp_out, cmdline)
if os.path.exists(cmdline.output_file):
os.unlink(cmdline.output_file)
os.link(tmp_out.name, cmdline.output_file)
def open_input(cmdline):
if cmdline.input_file == '-':
open_output(sys.stdin, cmdline)
else:
with open(cmdline.input_file, 'r') as f:
open_output(f, cmdline)
def main(cmdline):
open_input(cmdline)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=doc)
parser.add_argument('-i', '--input-file', dest='input_file', default="-",
help='Read from this file, or stdin if "-"')
parser.add_argument('-o', '--output-file', dest='output_file', default="-",
help='Write to this file, or stdout if "-"')
parser.add_argument('-t', '--output-format', dest='output_format', default="mscgen",
choices=('mscgen','ladder'),
help='Pick output format: mscgen format or libosmocore/contrib/ladder_to_msc.py format')
parser.add_argument('-m', '--mask-values', dest='mask_values', action='store_true',
help='Do not output specific values like IP address, port, endpoint CI, instead just indicate that a value is'
' present. This makes the output reproducible across various logs.')
parser.add_argument('-s', '--start-with', dest='start_with_re', default=None,
help='Skip until the first message with this label (regex), e.g. -s "CC SETUP"')
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
help='show some debug info, like which regex rules were hit and which were not.')
cmdline = parser.parse_args()
main(cmdline)
# vim: shiftwidth=8 noexpandtab tabstop=8 autoindent nocindent

View File

@ -0,0 +1,124 @@
# Generated by osmo-msc.git/doc/sequence_charts/msc_log_to_ladder.py
msc {
hscale="3";
moms[label="MS,BSS (MO)\nUE,hNodeB (MO)"],momgw[label="MGW for MSC (MO)"],momsc[label="MSC (MO)"],mncc[label="MNCC"],mtmsc[label="MSC (MT)"],mtmgw[label="MGW for MSC (MT)"],mtms[label="BSS,MS (MT)\nhNodeB,UE (MT)"];
moms =>> momsc [label="(BSSMAP) Complete Layer 3 Information"];
moms =>> momsc [label="MM CM_SERV_REQ"];
moms <<= momsc [label="MM AUTH_REQ"];
moms =>> momsc [label="MM AUTH_RESP"];
moms <<= momsc [label="(BSSMAP) CIPHER_MODE_COMMAND"];
moms =>> momsc [label="(BSSMAP) Ciphering Mode Complete"];
moms <<= momsc [label="(BSSMAP) COMMON_ID"];
moms =>> momsc [label="RR CIPH_M_COMPL"];
moms =>> momsc [label="CC SETUP"];
momsc note momsc [label="CC starts guard timer (180s)"];
momsc abox momsc [label="CC state:\nINITIATED"];
momgw <<= momsc [label="for CN: CRCX\nrtpbridge/*@msc"];
momgw =>> momsc [label="for CN: CRCX OK\nEP-1 CI-1 IP:port-1"];
momsc =>> mncc [label="MNCC_SETUP_IND\nIP:port-1"];
momgw <<= momsc [label="for RAN: CRCX\nEP-1"];
momsc <<= mncc [label="MNCC_RTP_CREATE"];
momgw =>> momsc [label="for RAN: CRCX OK\nEP-1 CI-2 IP:port-2"];
moms <<= momsc [label="(BSSMAP) ASSIGNMENT_COMMAND"];
moms =>> momsc [label="(BSSMAP) Assignment Complete"];
momgw <<= momsc [label="for RAN: MDCX\nEP-1 CI-2"];
momsc =>> mncc [label="MNCC_RTP_CREATE\nIP:port-1"];
momsc <<= mncc [label="MNCC_CALL_PROC_REQ"];
momsc note momsc [label="CC stops guard timer"];
momsc note momsc [label="CC starts guard timer (180s)"];
momsc abox momsc [label="CC state:\nMO_CALL_PROC"];
moms <<= momsc [label="CC CALL_PROC"];
mtmsc <<= mncc [label="MNCC_SETUP_REQ\nIP:port-1"];
mtms <<= mtmsc [label="Paging"];
momgw =>> momsc [label="for RAN: MDCX OK\nEP-1 CI-2 IP:port-2"];
mtms =>> mtmsc [label="(BSSMAP) Complete Layer 3 Information"];
mtms =>> mtmsc [label="RR PAG_RESP"];
mtms <<= mtmsc [label="MM AUTH_REQ"];
mtms =>> mtmsc [label="MM AUTH_RESP"];
mtms <<= mtmsc [label="(BSSMAP) CIPHER_MODE_COMMAND"];
mtms =>> mtmsc [label="(BSSMAP) Ciphering Mode Complete"];
mtms <<= mtmsc [label="(BSSMAP) COMMON_ID"];
mtmsc note mtmsc [label="CC starts timer T303 (30s)"];
mtmsc abox mtmsc [label="CC state:\nCALL_PRESENT"];
mtms <<= mtmsc [label="CC SETUP"];
mtms =>> mtmsc [label="RR CIPH_M_COMPL"];
mtms =>> mtmsc [label="CC CALL_CONF"];
mtmsc note mtmsc [label="CC stops timer T303"];
mtmsc note mtmsc [label="CC starts timer T310 (30s)"];
mtmgw <<= mtmsc [label="for CN: CRCX\nrtpbridge/*@msc"];
mtmsc abox mtmsc [label="CC state:\nMO_TERM_CALL_CONF"];
mtmsc =>> mncc [label="MNCC_CALL_CONF_IND"];
mtmsc <<= mncc [label="MNCC_RTP_CREATE"];
mtmgw =>> mtmsc [label="for CN: CRCX OK\nEP-2 CI-3 IP:port-3"];
mtmgw <<= mtmsc [label="for RAN: CRCX\nEP-2"];
mtmgw =>> mtmsc [label="for RAN: CRCX OK\nEP-2 CI-4 IP:port-4"];
mtms <<= mtmsc [label="(BSSMAP) ASSIGNMENT_COMMAND"];
mtms =>> mtmsc [label="(BSSMAP) Assignment Complete"];
mtmgw <<= mtmsc [label="for RAN: MDCX\nEP-2 CI-4"];
mtmsc =>> mncc [label="MNCC_RTP_CREATE\nIP:port-3"];
mtmgw =>> mtmsc [label="for RAN: MDCX OK\nEP-2 CI-4 IP:port-4"];
mtms =>> mtmsc [label="CC ALERTING"];
mtmsc note mtmsc [label="CC stops timer T310"];
mtmsc note mtmsc [label="CC starts timer T301 (180s)"];
mtmsc abox mtmsc [label="CC state:\nCALL_RECEIVED"];
mtmsc =>> mncc [label="MNCC_ALERT_IND\nIP:port-3"];
momsc <<= mncc [label="MNCC_ALERT_REQ"];
momsc note momsc [label="CC stops guard timer"];
momsc note momsc [label="CC starts guard timer (180s)"];
momsc abox momsc [label="CC state:\nCALL_DELIVERED"];
moms <<= momsc [label="CC ALERTING"];
mtms =>> mtmsc [label="CC CONNECT"];
mtmsc note mtmsc [label="CC stops timer T301"];
mtmsc abox mtmsc [label="CC state:\nCONNECT_REQUEST"];
mtmsc =>> mncc [label="MNCC_SETUP_CNF\nIP:port-3"];
mtmsc <<= mncc [label="MNCC_RTP_CONNECT\nIP:port-1"];
mtmgw <<= mtmsc [label="for CN: MDCX\nEP-2 CI-3"];
mtmsc <<= mncc [label="MNCC_SETUP_COMPL_REQ"];
mtmsc note mtmsc [label="CC starts guard timer (180s)"];
mtmsc abox mtmsc [label="CC state:\nACTIVE"];
mtmsc note mtmsc [label="CC stops guard timer"];
mtms <<= mtmsc [label="CC CONNECT_ACK"];
momsc <<= mncc [label="MNCC_RTP_CONNECT\nIP:port-3"];
momgw <<= momsc [label="for CN: MDCX\nEP-1 CI-1"];
momsc <<= mncc [label="MNCC_SETUP_RSP"];
momsc note momsc [label="CC stops guard timer"];
momsc note momsc [label="CC starts guard timer (180s)"];
momsc note momsc [label="CC starts timer T313 (30s)"];
momsc abox momsc [label="CC state:\nCONNECT_IND"];
moms <<= momsc [label="CC CONNECT"];
mtmgw =>> mtmsc [label="for CN: MDCX OK\nEP-2 CI-3 IP:port-3"];
momgw =>> momsc [label="for CN: MDCX OK\nEP-1 CI-1 IP:port-1"];
moms =>> momsc [label="CC CONNECT_ACK"];
momsc note momsc [label="CC stops timer T313"];
momsc abox momsc [label="CC state:\nACTIVE"];
momsc note momsc [label="CC stops guard timer"];
momsc =>> mncc [label="MNCC_SETUP_COMPL_IND"];
moms =>> momsc [label="CC DISCONNECT"];
momsc abox momsc [label="CC state:\nDISCONNECT_IND"];
momsc =>> mncc [label="MNCC_DISC_IND"];
momsc <<= mncc [label="MNCC_REL_REQ"];
momsc note momsc [label="CC starts guard timer (180s)"];
momsc note momsc [label="CC starts timer T308 (10s)"];
momsc abox momsc [label="CC state:\nRELEASE_REQ"];
moms <<= momsc [label="CC RELEASE"];
mtmsc <<= mncc [label="MNCC_DISC_REQ"];
mtmsc note mtmsc [label="CC starts guard timer (180s)"];
mtmsc note mtmsc [label="CC starts timer T306 (30s)"];
mtmsc abox mtmsc [label="CC state:\nDISCONNECT_IND"];
mtms <<= mtmsc [label="CC DISCONNECT"];
mtms =>> mtmsc [label="CC RELEASE"];
mtmsc note mtmsc [label="CC stops timer T306"];
mtms <<= mtmsc [label="CC RELEASE_COMPL"];
mtmsc =>> mncc [label="MNCC_REL_IND"];
mtmsc abox mtmsc [label="CC state:\nNULL"];
mtmsc note mtmsc [label="CC stops guard timer"];
mtms <<= mtmsc [label="(BSSMAP) CLEAR_COMMAND"];
mtms =>> mtmsc [label="(BSSMAP) Clear Complete"];
moms =>> momsc [label="CC RELEASE_COMPL"];
momsc note momsc [label="CC stops timer T308"];
momsc =>> mncc [label="MNCC_REL_CNF"];
momsc abox momsc [label="CC state:\nNULL"];
momsc note momsc [label="CC stops guard timer"];
moms <<= momsc [label="(BSSMAP) CLEAR_COMMAND"];
moms =>> momsc [label="(BSSMAP) Clear Complete"];
}

View File

@ -0,0 +1,129 @@
# Generated by osmo-msc.git/doc/sequence_charts/msc_log_to_ladder.py
msc {
hscale="3";
moms[label="MS,BSS (MO)\nUE,hNodeB (MO)"],momgw[label="MGW for MSC (MO)"],momsc[label="MSC (MO)"],mncc[label="MNCC"],mtmsc[label="MSC (MT)"],mtmgw[label="MGW for MSC (MT)"],mtms[label="BSS,MS (MT)\nhNodeB,UE (MT)"];
moms =>> momsc [label="(BSSMAP) Complete Layer 3 Information"];
moms =>> momsc [label="MM CM_SERV_REQ"];
moms <<= momsc [label="MM AUTH_REQ"];
moms =>> momsc [label="MM AUTH_RESP"];
moms <<= momsc [label="(BSSMAP) CIPHER_MODE_COMMAND"];
moms =>> momsc [label="(BSSMAP) Ciphering Mode Complete"];
moms <<= momsc [label="(BSSMAP) COMMON_ID"];
moms =>> momsc [label="RR CIPH_M_COMPL"];
moms =>> momsc [label="CC SETUP"];
momsc note momsc [label="CC starts guard timer (180s)"];
momsc abox momsc [label="CC state:\nINITIATED"];
momgw <<= momsc [label="for CN: CRCX\nrtpbridge/*@msc"];
momgw =>> momsc [label="for CN: CRCX OK\nEP-1 CI-1 IP:port-1"];
momsc =>> mncc [label="MNCC_SETUP_IND\nIP:port-1"];
momsc <<= mncc [label="MNCC_CALL_PROC_REQ"];
momsc note momsc [label="CC stops guard timer"];
momsc note momsc [label="CC starts guard timer (180s)"];
momsc abox momsc [label="CC state:\nMO_CALL_PROC"];
moms <<= momsc [label="CC CALL_PROC"];
momsc <<= mncc [label="MNCC_LCHAN_MODIFY"];
momsc note momsc [label="CC stops guard timer"];
momsc note momsc [label="CC starts guard timer (180s)"];
mtmsc <<= mncc [label="MNCC_SETUP_REQ\nIP:port-1"];
mtms <<= mtmsc [label="Paging"];
momgw <<= momsc [label="for RAN: CRCX\nEP-1"];
momgw =>> momsc [label="for RAN: CRCX OK\nEP-1 CI-2 IP:port-2"];
moms <<= momsc [label="(BSSMAP) ASSIGNMENT_COMMAND"];
mtms =>> mtmsc [label="(BSSMAP) Complete Layer 3 Information"];
mtms =>> mtmsc [label="RR PAG_RESP"];
mtms <<= mtmsc [label="MM AUTH_REQ"];
moms =>> momsc [label="(BSSMAP) Assignment Complete"];
momgw <<= momsc [label="for RAN: MDCX\nEP-1 CI-2"];
momsc =>> mncc [label="MNCC_RTP_CREATE\nIP:port-1"];
momgw =>> momsc [label="for RAN: MDCX OK\nEP-1 CI-2 IP:port-2"];
mtms =>> mtmsc [label="MM AUTH_RESP"];
mtms <<= mtmsc [label="(BSSMAP) CIPHER_MODE_COMMAND"];
mtms =>> mtmsc [label="(BSSMAP) Ciphering Mode Complete"];
mtms <<= mtmsc [label="(BSSMAP) COMMON_ID"];
mtmsc note mtmsc [label="CC starts timer T303 (30s)"];
mtmsc abox mtmsc [label="CC state:\nCALL_PRESENT"];
mtms <<= mtmsc [label="CC SETUP"];
mtms =>> mtmsc [label="RR CIPH_M_COMPL"];
mtms =>> mtmsc [label="CC CALL_CONF"];
mtmsc note mtmsc [label="CC stops timer T303"];
mtmsc note mtmsc [label="CC starts timer T310 (30s)"];
mtmgw <<= mtmsc [label="for CN: CRCX\nrtpbridge/*@msc"];
mtmsc abox mtmsc [label="CC state:\nMO_TERM_CALL_CONF"];
mtmsc =>> mncc [label="MNCC_CALL_CONF_IND"];
mtmsc <<= mncc [label="MNCC_LCHAN_MODIFY"];
mtmsc note mtmsc [label="CC starts guard timer (180s)"];
mtmgw =>> mtmsc [label="for CN: CRCX OK\nEP-2 CI-3 IP:port-3"];
mtmgw <<= mtmsc [label="for RAN: CRCX\nEP-2"];
mtmgw =>> mtmsc [label="for RAN: CRCX OK\nEP-2 CI-4 IP:port-4"];
mtms <<= mtmsc [label="(BSSMAP) ASSIGNMENT_COMMAND"];
mtms =>> mtmsc [label="(BSSMAP) Assignment Complete"];
mtmgw <<= mtmsc [label="for RAN: MDCX\nEP-2 CI-4"];
mtmsc =>> mncc [label="MNCC_RTP_CREATE\nIP:port-3"];
mtmgw =>> mtmsc [label="for RAN: MDCX OK\nEP-2 CI-4 IP:port-4"];
mtms =>> mtmsc [label="CC ALERTING"];
mtmsc note mtmsc [label="CC stops timer T310"];
mtmsc note mtmsc [label="CC starts timer T301 (180s)"];
mtmsc abox mtmsc [label="CC state:\nCALL_RECEIVED"];
mtmsc =>> mncc [label="MNCC_ALERT_IND\nIP:port-3"];
momsc <<= mncc [label="MNCC_ALERT_REQ\nIP:port-3"];
momsc note momsc [label="CC stops guard timer"];
momsc note momsc [label="CC starts guard timer (180s)"];
momsc abox momsc [label="CC state:\nCALL_DELIVERED"];
momgw <<= momsc [label="for CN: MDCX\nEP-1 CI-1"];
moms <<= momsc [label="CC ALERTING"];
momgw =>> momsc [label="for CN: MDCX OK\nEP-1 CI-1 IP:port-1"];
mtms =>> mtmsc [label="CC CONNECT"];
mtmsc note mtmsc [label="CC stops timer T301"];
mtmsc abox mtmsc [label="CC state:\nCONNECT_REQUEST"];
mtmsc =>> mncc [label="MNCC_SETUP_CNF\nIP:port-3"];
mtmsc <<= mncc [label="MNCC_SETUP_COMPL_REQ"];
mtmsc note mtmsc [label="CC stops guard timer"];
mtmsc note mtmsc [label="CC starts guard timer (180s)"];
mtmsc abox mtmsc [label="CC state:\nACTIVE"];
mtmsc note mtmsc [label="CC stops guard timer"];
mtms <<= mtmsc [label="CC CONNECT_ACK"];
momsc <<= mncc [label="MNCC_SETUP_RSP\nIP:port-3"];
momsc note momsc [label="CC stops guard timer"];
momsc note momsc [label="CC starts guard timer (180s)"];
momsc note momsc [label="CC starts timer T313 (30s)"];
momsc abox momsc [label="CC state:\nCONNECT_IND"];
moms <<= momsc [label="CC CONNECT"];
mtmgw <<= mtmsc [label="for CN: MDCX\nEP-2 CI-3"];
mtmgw =>> mtmsc [label="for CN: MDCX OK\nEP-2 CI-3 IP:port-3"];
moms =>> momsc [label="CC CONNECT_ACK"];
momsc note momsc [label="CC stops timer T313"];
momsc abox momsc [label="CC state:\nACTIVE"];
momsc note momsc [label="CC stops guard timer"];
momsc =>> mncc [label="MNCC_SETUP_COMPL_IND"];
moms =>> momsc [label="CC DISCONNECT"];
momsc abox momsc [label="CC state:\nDISCONNECT_IND"];
momsc =>> mncc [label="MNCC_DISC_IND"];
momsc <<= mncc [label="MNCC_REL_REQ"];
momsc note momsc [label="CC starts guard timer (180s)"];
momsc note momsc [label="CC starts timer T308 (10s)"];
momsc abox momsc [label="CC state:\nRELEASE_REQ"];
moms <<= momsc [label="CC RELEASE"];
mtmsc <<= mncc [label="MNCC_DISC_REQ"];
mtmsc note mtmsc [label="CC starts guard timer (180s)"];
mtmsc note mtmsc [label="CC starts timer T306 (30s)"];
mtmsc abox mtmsc [label="CC state:\nDISCONNECT_IND"];
mtms <<= mtmsc [label="CC DISCONNECT"];
mtms =>> mtmsc [label="CC RELEASE"];
mtmsc note mtmsc [label="CC stops timer T306"];
mtms <<= mtmsc [label="CC RELEASE_COMPL"];
mtmsc =>> mncc [label="MNCC_REL_IND"];
momsc <<= mncc [label="MNCC_REL_REQ"];
momsc note momsc [label="CC stops guard timer"];
momsc note momsc [label="CC starts guard timer (180s)"];
mtmsc abox mtmsc [label="CC state:\nNULL"];
mtmsc note mtmsc [label="CC stops guard timer"];
mtms <<= mtmsc [label="(BSSMAP) CLEAR_COMMAND"];
mtms =>> mtmsc [label="(BSSMAP) Clear Complete"];
moms =>> momsc [label="CC RELEASE_COMPL"];
momsc note momsc [label="CC stops timer T308"];
momsc =>> mncc [label="MNCC_REL_CNF"];
momsc abox momsc [label="CC state:\nNULL"];
momsc note momsc [label="CC stops guard timer"];
moms <<= momsc [label="(BSSMAP) CLEAR_COMMAND"];
moms =>> momsc [label="(BSSMAP) Clear Complete"];
}

View File

@ -1,3 +1,4 @@
SUBDIRS = \
msc \
smpp \
$(NULL)

View File

@ -1,8 +1,13 @@
noinst_HEADERS = \
a_iface.h \
a_iface_bssap.h \
call_leg.h \
cell_id_list.h \
codec_filter.h \
codec_mapping.h \
csd_bs.h \
csd_filter.h \
db.h \
debug.h \
e_link.h \
gsm_04_08.h \
gsm_04_11.h \
gsm_04_11_gsup.h \
@ -12,22 +17,45 @@ noinst_HEADERS = \
gsm_data.h \
gsm_data_shared.h \
gsm_subscriber.h \
iucs.h \
iucs_ranap.h \
iu_dummy.h \
gsup_client_mux.h \
mncc.h \
mncc_call.h \
mncc_int.h \
msc_a.h \
msc_a_remote.h \
msc_common.h \
msc_ifaces.h \
msc_mgcp.h \
a_reset.h \
msc_ho.h \
msc_vgcs.h \
msc_i.h \
msc_i_remote.h \
msc_roles.h \
msc_t.h \
msc_t_remote.h \
msub.h \
neighbor_ident.h \
osmux.h \
paging.h \
ran_conn.h \
ran_infra.h \
ran_msg.h \
ran_msg_a.h \
ran_msg_iu.h \
ran_peer.h \
rrlp.h \
rtp_stream.h \
sccp_ran.h \
sdp_msg.h \
sgs_iface.h \
sgs_server.h \
sgs_vty.h \
signal.h \
silent_call.h \
smpp.h \
sms_queue.h \
transaction.h \
transaction_cc.h \
vlr.h \
vlr_sgs.h \
vty.h \
asci_gcr.h \
asci_vty.h \
$(NULL)

View File

@ -1,83 +0,0 @@
/* (C) 2017 by Sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <osmocom/msc/a_reset.h>
#include <osmocom/msc/transaction.h>
#include <osmocom/msc/vlr.h>
#include <osmocom/gsm/protocol/gsm_08_08.h>
/* A struct to keep a context information about the BSCs we are associated with */
struct bsc_context {
struct llist_head list;
/* Holds a copy of the sccp address of the BSC,
* this address will become known as soon as
* a remote BSC tries to make a connection or
* sends a RESET request via UNIDATA */
struct osmo_sccp_addr bsc_addr;
/* Holds a copy of the our local MSC address,
* this will be the sccp-address that is associated
* with the A interface */
struct osmo_sccp_addr msc_addr;
/* A pointer to the reset handler FSM, the
* state machine is allocated when the BSC
* is registerd. */
struct osmo_fsm_inst *reset_fsm;
/* A pointer to the sccp_user that is associated
* with the A interface. We need this information
* to send the resets and to send paging requests */
struct osmo_sccp_user *sccp_user;
};
/* Initalize A interface connection between to MSC and BSC */
int a_init(struct osmo_sccp_instance *sccp, struct gsm_network *network);
/* Send DTAP message via A-interface, take ownership of msg */
int a_iface_tx_dtap(struct msgb *msg);
/* Send Cipher mode command via A-interface */
int a_iface_tx_cipher_mode(const struct ran_conn *conn,
struct gsm0808_encrypt_info *ei, int include_imeisv);
/* Page a subscriber via A-interface */
int a_iface_tx_paging(const char *imsi, uint32_t tmsi, uint16_t lac);
/* Send assignment request via A-interface */
int a_iface_tx_assignment(const struct gsm_trans *trans);
/* Send clear command via A-interface */
int a_iface_tx_clear_cmd(struct ran_conn *conn);
int a_iface_tx_classmark_request(const struct ran_conn *conn);
/* Clear all RAN connections on a specified BSC
* (Helper function for a_iface_bssap.c) */
void a_clear_all(struct osmo_sccp_user *scu, const struct osmo_sccp_addr *bsc_addr);
void a_start_reset(struct bsc_context *bsc_ctx, bool already_connected);
/* Delete info of a closed connection from the active connection list
* (Helper function for a_iface_bssap.c) */
void a_delete_bsc_con(uint32_t conn_id);

View File

@ -1,41 +0,0 @@
/* (C) 2017 by sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <osmocom/msc/a_iface.h>
/* Note: The structs and functions presented in this header file are intended
* to be used only by a_iface.c. */
/* A structure to hold tha most basic information about a sigtran connection
* we use this struct internally here to pass connection data around */
struct a_conn_info {
struct bsc_context *bsc;
uint32_t conn_id;
struct gsm_network *network;
};
/* Receive incoming connection less data messages via sccp */
void a_sccp_rx_udt(struct osmo_sccp_user *scu, const struct a_conn_info *a_conn_info, struct msgb *msg);
/* Receive incoming connection oriented data messages via sccp */
int a_sccp_rx_dt(struct osmo_sccp_user *scu, const struct a_conn_info *a_conn_info, struct msgb *msg);

View File

@ -0,0 +1,55 @@
/* Group Call Register (GCR) */
/*
* (C) 2023 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* SPDX-License-Identifier: AGPL-3.0+
*
* Author: Andreas Eversberg
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
/* Group Call Register */
struct gcr {
struct llist_head list;
enum trans_type trans_type;
char group_id[9];
uint16_t timeout;
bool mute_talker;
struct llist_head bss_list;
};
struct gcr_bss {
struct llist_head list;
int pc;
struct llist_head cell_list;
};
struct gcr_cell {
struct llist_head list;
uint16_t cell_id;
};
struct gcr_cell *gcr_add_cell(struct gcr_bss *bss, uint16_t cell_id);
struct gcr_cell *gcr_find_cell(struct gcr_bss *bss, uint16_t cell_id);
void gcr_rm_cell(struct gcr_bss *bss, uint16_t cell_id);
struct gcr_bss *gcr_add_bss(struct gcr *gcr, int pc);
struct gcr_bss *gcr_find_bss(struct gcr *gcr, int pc);
void gcr_rm_bss(struct gcr *gcr, int pc);
struct gcr *gcr_create(struct gsm_network *gsmnet, enum trans_type trans_type, const char *group_id);
void gcr_destroy(struct gcr *gcr);
struct gcr *gcr_by_group_id(struct gsm_network *gsmnet, enum trans_type trans_type, const char *group_id);
struct gcr *gcr_by_callref(struct gsm_network *gsmnet, enum trans_type trans_type, uint32_t callref);

View File

@ -1,7 +1,10 @@
/* (C) 2017 by sysmocom s.f.m.c. GmbH
/*
* (C) 2023 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Philipp Maier
* SPDX-License-Identifier: AGPL-3.0+
*
* Author: Andreas Eversberg
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -15,17 +18,8 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
/* Create and start state machine which handles the reset/reset-ack procedure */
struct osmo_fsm_inst *a_reset_alloc(void *ctx, const char *name, void *cb,
void *priv, bool already_connected);
/* Confirm that we sucessfully received a reset acknowlege message */
void a_reset_ack_confirm(struct osmo_fsm_inst *reset_fsm);
/* Check if we have a connection to a specified msc */
bool a_reset_conn_ready(struct osmo_fsm_inst *reset_fsm);
void asci_vty_init(struct gsm_network *msc_network);

View File

@ -0,0 +1,83 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <osmocom/core/tdef.h>
struct osmo_fsm_inst;
struct osmo_sockaddr_str;
struct osmo_mgcpc_ep;
struct gsm_network;
struct gsm_trans;
struct rtp_stream;
enum rtp_direction;
struct sdp_audio_codecs;
extern struct osmo_tdef g_mgw_tdefs[];
/* All sides of an MGW endpoint, connecting remote RTP peers via the MGW.
*
* BSC MGW PBX
* CI CI
* [MGW-endpoint]
* [--rtp_stream--] [--rtp_stream--]
* [----------------call_leg----------------]
*
*/
struct call_leg {
struct osmo_fsm_inst *fi;
struct osmo_mgcpc_ep *mgw_endpoint;
/* Array indexed by enum rtp_direction. */
struct rtp_stream *rtp[2];
/* Array indexed by enum rtp_direction. */
enum mgcp_connection_mode crcx_conn_mode[2];
/* Events dispatched to the parent fi, see call_leg_alloc() doc. */
uint32_t parent_event_rtp_addr_available;
uint32_t parent_event_rtp_complete;
/* For internal MNCC, if RTP addresses for endpoints become assigned by the MGW, implicitly notify the other
* call leg's RTP_TO_CN side rtp_stream with rtp_stream_remote_addr_available(). */
struct call_leg *local_bridge;
/* Prevent events from deallocating for certain release code paths, to prevent use-after-free problems. */
bool deallocating;
bool ran_peer_supports_osmux;
};
enum call_leg_event {
CALL_LEG_EV_RTP_STREAM_ADDR_AVAILABLE,
CALL_LEG_EV_RTP_STREAM_ESTABLISHED,
CALL_LEG_EV_RTP_STREAM_GONE,
CALL_LEG_EV_MGW_ENDPOINT_GONE,
};
void call_leg_init(struct gsm_network *net);
struct call_leg *call_leg_alloc(struct osmo_fsm_inst *parent_fi,
uint32_t parent_event_term,
uint32_t parent_event_rtp_addr_available,
uint32_t parent_event_rtp_complete);
void call_leg_reparent(struct call_leg *cl,
struct osmo_fsm_inst *parent_fi,
uint32_t parent_event_term,
uint32_t parent_event_rtp_addr_available,
uint32_t parent_event_rtp_complete);
int call_leg_local_bridge(struct call_leg *cl1, uint32_t call_id1, struct gsm_trans *trans1,
struct call_leg *cl2, uint32_t call_id2, struct gsm_trans *trans2);
int call_leg_ensure_rtp_alloc(struct call_leg *cl, enum rtp_direction dir, uint32_t call_id,
struct gsm_trans *for_trans);
int call_leg_ensure_ci(struct call_leg *cl, enum rtp_direction dir, uint32_t call_id, struct gsm_trans *for_trans,
const struct sdp_audio_codecs *codecs_if_known,
const struct osmo_sockaddr_str *remote_addr_if_known);
struct osmo_sockaddr_str *call_leg_local_ip(struct call_leg *cl, enum rtp_direction dir);
void call_leg_rtp_stream_gone(struct call_leg *cl, struct rtp_stream *rtps);
void call_leg_release(struct call_leg *cl);

View File

@ -0,0 +1,39 @@
/* Manage a list of struct gsm0808_cell_id */
/*
* (C) 2019 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Neels Hofmeyr
*
* SPDX-License-Identifier: GPL-2.0+
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include <osmocom/core/linuxlist.h>
#include <osmocom/gsm/gsm0808_utils.h>
struct cell_id_list_entry {
struct llist_head entry;
struct gsm0808_cell_id cell_id;
};
int cell_id_list_add_cell(void *talloc_ctx, struct llist_head *list, const struct gsm0808_cell_id *cid);
int cell_id_list_add_list(void *talloc_ctx, struct llist_head *list, const struct gsm0808_cell_id_list2 *cil);
struct cell_id_list_entry *cell_id_list_find(struct llist_head *list,
const struct gsm0808_cell_id *id,
unsigned int match_nr,
bool exact_match);
void cell_id_list_del_entry(struct cell_id_list_entry *e);

View File

@ -0,0 +1,57 @@
/* Filter/overlay codec selections for a voice call, across MS, RAN and CN limitations */
/*
* (C) 2019-2022 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Neels Hofmeyr
*
* SPDX-License-Identifier: GPL-2.0+
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/gsm/mncc.h>
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/msc/sdp_msg.h>
struct gsm0808_speech_codec_list;
/* Combine various codec selections to obtain a resulting set of codecs allowed by all of them.
* Members reflect the different entities/stages that select codecs in a voice call.
* Call codec_filter_run() and obtain the resulting set of codecs in codec_filter.result. */
struct codec_filter {
/* The fixed set of codecs available on the RAN type, per definition. */
struct sdp_audio_codecs ran;
/* The codecs advertised by the MS Bearer Capabilities */
struct sdp_audio_codecs ms;
/* If known, the set of codecs the current RAN cell allows / has available.
* This may not be available if the BSC does not issue this information early enough.
* Should be ignored if empty. */
struct sdp_audio_codecs bss;
/* After a channel was assigned, this reflects the chosen codec. */
struct sdp_audio_codec assignment;
};
void codec_filter_set_ran(struct codec_filter *codec_filter, enum osmo_rat_type ran_type);
void codec_filter_set_bss(struct codec_filter *codec_filter,
const struct gsm0808_speech_codec_list *codec_list_bss_supported);
int codec_filter_run(struct codec_filter *codec_filter, struct sdp_msg *result, const struct sdp_msg *remote);
int codec_filter_to_str_buf(char *buf, size_t buflen, const struct codec_filter *codec_filter,
const struct sdp_msg *result, const struct sdp_msg *remote);
char *codec_filter_to_str_c(void *ctx, const struct codec_filter *codec_filter, const struct sdp_msg *result,
const struct sdp_msg *remote);
const char *codec_filter_to_str(const struct codec_filter *codec_filter, const struct sdp_msg *result,
const struct sdp_msg *remote);

View File

@ -0,0 +1,65 @@
/* Routines for translation between codec representations: SDP, CC/BSSMAP variants, MGCP, MNCC */
#pragma once
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/gsm/protocol/gsm_08_08.h>
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/msc/sdp_msg.h>
#include <osmocom/gsm/mncc.h>
#define NO_MGCP_CODEC 0xffffffff
extern const struct gsm_mncc_bearer_cap bearer_cap_empty;
enum codec_frhr {
CODEC_FRHR_NONE = 0,
CODEC_FRHR_FR,
CODEC_FRHR_HR,
};
struct codec_mapping {
/* The sdp.payload_type number in a mapping is not necessarily imperative, but may just reflect the usual
* payload type number for a given codec. */
struct sdp_audio_codec sdp;
/* The id that mgcp_client.h uses for this codec. Must be set in each mapping, because 0 means PCMU. */
enum mgcp_codecs mgcp;
/* Nr of used entries in speech_ver[] below. */
unsigned int speech_ver_count;
/* Entries to add to Speech Version lists when this codec is present, if any. */
enum gsm48_bcap_speech_ver speech_ver[8];
/* If applicable, one of GSM_TCHF_FRAME, GSM_TCHF_FRAME_EFR, GSM_TCHH_FRAME, GSM_TCH_FRAME_AMR; or zero. */
uint32_t mncc_payload_msg_type;
/* Set to true if gsm0808_speech_codec below reflects a meaningful value. */
bool has_gsm0808_speech_codec;
struct gsm0808_speech_codec gsm0808_speech_codec;
/* If applicable, entries to add to Permitted Speech lists when this codec is present; or zero. */
enum gsm0808_permitted_speech perm_speech;
/* If applicable, indicator whether this codec can work on a GERAN half-rate lchan, or whether full-rate is
* required. Leave zero when this codec does not apply to GERAN. */
enum codec_frhr frhr;
};
const struct codec_mapping *codec_mapping_by_speech_ver(enum gsm48_bcap_speech_ver speech_ver);
const struct codec_mapping *codec_mapping_by_gsm0808_speech_codec_type(enum gsm0808_speech_codec_type sct);
const struct codec_mapping *codec_mapping_by_gsm0808_speech_codec(const struct gsm0808_speech_codec *sc);
const struct codec_mapping *codec_mapping_by_perm_speech(enum gsm0808_permitted_speech perm_speech);
const struct codec_mapping *codec_mapping_by_subtype_name(const char *subtype_name);
const struct codec_mapping *codec_mapping_by_mgcp_codec(enum mgcp_codecs mgcp);
int bearer_cap_add_speech_ver(struct gsm_mncc_bearer_cap *bearer_cap, enum gsm48_bcap_speech_ver speech_ver);
int sdp_audio_codec_add_to_bearer_cap(struct gsm_mncc_bearer_cap *bearer_cap, const struct sdp_audio_codec *codec);
int sdp_audio_codecs_to_bearer_cap(struct gsm_mncc_bearer_cap *bearer_cap, const struct sdp_audio_codecs *ac);
int bearer_cap_set_radio(struct gsm_mncc_bearer_cap *bearer_cap);
struct sdp_audio_codec *sdp_audio_codecs_add_speech_ver(struct sdp_audio_codecs *ac,
enum gsm48_bcap_speech_ver speech_ver);
struct sdp_audio_codec *sdp_audio_codecs_add_mgcp_codec(struct sdp_audio_codecs *ac, enum mgcp_codecs mgcp_codec);
void sdp_audio_codecs_from_bearer_cap(struct sdp_audio_codecs *ac, const struct gsm_mncc_bearer_cap *bc);
int sdp_audio_codec_to_speech_codec_list(struct gsm0808_speech_codec_list *scl, const struct sdp_audio_codec *codec);
void sdp_audio_codecs_to_speech_codec_list(struct gsm0808_speech_codec_list *cl, const struct sdp_audio_codecs *ac);
void sdp_audio_codecs_from_speech_codec_list(struct sdp_audio_codecs *ac, const struct gsm0808_speech_codec_list *cl);
int sdp_audio_codecs_to_gsm0808_channel_type(struct gsm0808_channel_type *ct, const struct sdp_audio_codecs *ac);
enum mgcp_codecs sdp_audio_codec_to_mgcp_codec(const struct sdp_audio_codec *codec);

View File

@ -0,0 +1,54 @@
/* 3GPP TS 122.002 Bearer Services */
#pragma once
#include <osmocom/gsm/mncc.h>
#include <osmocom/gsm/protocol/gsm_08_08.h>
enum csd_bs {
CSD_BS_NONE,
/* 3.1.1.1.2 */
CSD_BS_21_T_V110_0k3,
CSD_BS_22_T_V110_1k2,
CSD_BS_24_T_V110_2k4,
CSD_BS_25_T_V110_4k8,
CSD_BS_26_T_V110_9k6,
/* 3.1.1.2.2 */
CSD_BS_21_NT_V110_0k3,
CSD_BS_22_NT_V110_1k2,
CSD_BS_24_NT_V110_2k4,
CSD_BS_25_NT_V110_4k8,
CSD_BS_26_NT_V110_9k6,
/* 3.1.2.1.2 */
CSD_BS_31_T_V110_1k2,
CSD_BS_32_T_V110_2k4,
CSD_BS_33_T_V110_4k8,
CSD_BS_34_T_V110_9k6,
CSD_BS_MAX,
};
struct csd_bs_list {
unsigned int count;
enum csd_bs bs[CSD_BS_MAX];
};
void csd_bs_list_add_bs(struct csd_bs_list *list, enum csd_bs bs);
int csd_bs_list_to_bearer_cap(struct gsm_mncc_bearer_cap *cap, const struct csd_bs_list *list);
void csd_bs_list_from_bearer_cap(struct csd_bs_list *list, const struct gsm_mncc_bearer_cap *cap);
int csd_bs_to_str_buf(char *buf, size_t buflen, enum csd_bs bs);
char *csd_bs_to_str_c(void *ctx, enum csd_bs bs);
const char *csd_bs_to_str(enum csd_bs bs);
int csd_bs_list_to_str_buf(char *buf, size_t buflen, const struct csd_bs_list *list);
char *csd_bs_list_to_str_c(void *ctx, const struct csd_bs_list *list);
const char *csd_bs_list_to_str(const struct csd_bs_list *list);
void csd_bs_list_add_bs(struct csd_bs_list *list, enum csd_bs bs);
void csd_bs_list_remove(struct csd_bs_list *list, enum csd_bs bs);
void csd_bs_list_intersection(struct csd_bs_list *dest, const struct csd_bs_list *other);
int csd_bs_list_to_gsm0808_channel_type(struct gsm0808_channel_type *ct, const struct csd_bs_list *list);

View File

@ -0,0 +1,53 @@
/* Filter/overlay data rates for CSD, across MS, RAN and CN limitations */
/*
* (C) 2023 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Oliver Smith
*
* SPDX-License-Identifier: GPL-2.0+
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/gsm/mncc.h>
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/msc/csd_bs.h>
#include <osmocom/msc/sdp_msg.h>
/* Combine various data rate selections to obtain a resulting set allowed by
* all of them. Members reflect the different entities/stages that select data
* rates in CSD. Call csd_filter_run() and obtain the resulting set in
* csd_filter.result. */
struct csd_filter {
/* The fixed set available on the RAN type, per definition. */
struct csd_bs_list ran;
/* The services advertised by the MS Bearer Capabilities */
struct csd_bs_list ms;
/* If known, the set the current RAN cell allows / has available. This
* may not be available if the BSC does not issue this information
* early enough. Should be ignored if empty. */
struct csd_bs_list bss;
/* After a channel was assigned, this reflects the chosen BS. */
enum csd_bs assignment;
};
void csd_filter_set_ran(struct csd_filter *filter, enum osmo_rat_type ran_type);
int csd_filter_run(struct csd_filter *filter, struct sdp_msg *result, const struct sdp_msg *remote);
int csd_filter_to_str_buf(char *buf, size_t buflen, const struct csd_filter *filter,
const struct sdp_msg *result, const struct sdp_msg *remote);
char *csd_filter_to_str_c(void *ctx, const struct csd_filter *filter, const struct sdp_msg *result, const struct sdp_msg *remote);
const char *csd_filter_to_str(const struct csd_filter *filter, const struct sdp_msg *result, const struct sdp_msg *remote);

View File

@ -1,5 +1,6 @@
/* (C) 2008 by Jan Luebbe <jluebbe@debian.org>
* (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2022 by Harald Welte <laforge@osmocom.org>
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
@ -24,11 +25,13 @@
#include "gsm_subscriber.h"
#define VSUB_USE_SMS_RECEIVER "SMS-receiver"
struct gsm_network;
struct gsm_sms;
/* one time initialisation */
int db_init(const char *name);
int db_init(void *ctx, const char *fname, bool enable_sqlite_logging);
int db_prepare(void);
int db_fini(void);
@ -37,12 +40,12 @@ int db_sms_store(struct gsm_sms *sms);
struct gsm_sms *db_sms_get(struct gsm_network *net, unsigned long long id);
struct gsm_sms *db_sms_get_next_unsent(struct gsm_network *net,
unsigned long long min_sms_id,
unsigned int max_failed);
int max_failed);
struct gsm_sms *db_sms_get_next_unsent_rr_msisdn(struct gsm_network *net,
const char *last_msisdn,
unsigned int max_failed);
int max_failed);
struct gsm_sms *db_sms_get_unsent_for_subscr(struct vlr_subscr *vsub,
unsigned int max_failed);
int max_failed);
int db_sms_mark_delivered(struct gsm_sms *sms);
int db_sms_inc_deliver_attempts(struct gsm_sms *sms);
int db_sms_delete_by_msisdn(const char *msisdn);
@ -50,10 +53,4 @@ int db_sms_delete_sent_message_by_id(unsigned long long sms_id);
int db_sms_delete_expired_message_by_id(unsigned long long sms_id);
void db_sms_delete_oldest_expired_message(void);
/* Statistics counter storage */
struct osmo_counter;
int db_store_counter(struct osmo_counter *ctr);
struct rate_ctr_group;
int db_store_rate_ctr_group(struct rate_ctr_group *ctrg);
#endif /* _DB_H */

View File

@ -6,8 +6,11 @@
enum {
DRLL,
DCC,
DBCC,
DGCC,
DMM,
DRR,
DLCLS,
DMNCC,
DPAG,
DMSC,
@ -21,5 +24,8 @@ enum {
DVLR,
DIUCS,
DBSSAP,
DSGS,
DSS,
DASCI,
Debug_LastEntry,
};

View File

@ -0,0 +1,36 @@
/* E-interface messaging over a GSUP connection */
#pragma once
#include <osmocom/gsm/gsup.h>
#include <osmocom/msc/msc_roles.h>
struct osmo_fsm_inst;
struct gsm_network;
struct vlr_instance;
/* E-interface: connection to a remote MSC via GSUP */
struct e_link {
struct osmo_fsm_inst *msc_role;
struct gsup_client_mux *gcm;
uint8_t *remote_name;
size_t remote_name_len;
};
struct e_link *e_link_alloc(struct gsup_client_mux *gcm, struct osmo_fsm_inst *msc_role,
const uint8_t *remote_name, size_t remote_name_len);
void e_link_assign(struct e_link *e, struct osmo_fsm_inst *msc_role);
void e_link_free(struct e_link *e);
int e_prep_gsup_msg(struct e_link *e, struct osmo_gsup_message *gsup_msg);
int e_tx(struct e_link *e, const struct osmo_gsup_message *gsup_msg);
const char *e_link_name(struct e_link *e);
void msc_a_i_t_gsup_init(struct gsm_network *net);
enum osmo_gsup_entity msc_role_to_gsup_entity(enum msc_role role);
enum msc_role gsup_entity_to_msc_role(enum osmo_gsup_entity entity);
int gsup_msg_assign_an_apdu(struct osmo_gsup_message *gsup_msg, struct an_apdu *an_apdu);
struct msgb *gsup_msg_to_msgb(const struct osmo_gsup_message *gsup_msg);
void gsup_msg_to_an_apdu(struct an_apdu *an_apdu, const struct osmo_gsup_message *gsup_msg);

View File

@ -4,6 +4,7 @@
#include <osmocom/gsm/gsm48.h>
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/msc/transaction.h>
struct msgb;
struct gsm_bts;
@ -12,6 +13,7 @@ struct gsm_trans;
struct ran_conn;
struct amr_multirate_conf;
struct amr_mode;
struct msc_a;
#define GSM48_ALLOC_SIZE 2048
#define GSM48_ALLOC_HEADROOM 256
@ -22,35 +24,33 @@ static inline struct msgb *gsm48_msgb_alloc_name(const char *name)
name);
}
void cm_service_request_concludes(struct ran_conn *conn,
struct msgb *msg);
void cm_service_request_concludes(struct msc_a *msc_a, struct msgb *msg, enum osmo_cm_service_type type);
/* config options controlling the behaviour of the lower leves */
void gsm0408_clear_all_trans(struct gsm_network *net, int protocol);
int gsm0408_dispatch(struct ran_conn *conn, struct msgb *msg);
void gsm0408_clear_all_trans(struct gsm_network *net, enum trans_type type);
int gsm0408_rcvmsg(struct msgb *msg, uint8_t link_id);
/* don't use "enum gsm_chreq_reason_t" to avoid circular dependency */
void gsm_net_update_ctype(struct gsm_network *net);
int gsm48_tx_simple(struct ran_conn *conn,
uint8_t pdisc, uint8_t msg_type);
int gsm48_tx_mm_info(struct ran_conn *conn);
int gsm48_tx_mm_auth_req(struct ran_conn *conn, uint8_t *rand,
uint8_t *autn, int key_seq);
int gsm48_tx_mm_auth_rej(struct ran_conn *conn);
int gsm48_tx_mm_serv_ack(struct ran_conn *conn);
int gsm48_tx_mm_serv_rej(struct ran_conn *conn,
enum gsm48_reject_value value);
int gsm48_tx_simple(struct msc_a *msc_a, uint8_t pdisc, uint8_t msg_type);
int gsm48_tx_mm_info(struct msc_a *msc_a);
int gsm48_tx_mm_auth_req(struct msc_a *msc_a, uint8_t *rand, uint8_t *autn, int key_seq);
int gsm48_tx_mm_auth_rej(struct msc_a *msc_a);
int gsm48_tx_mm_serv_ack(struct msc_a *msc_a);
int gsm48_tx_mm_serv_rej(struct msc_a *msc_a, enum gsm48_reject_value value);
int gsm48_send_rr_release(struct gsm_lchan *lchan);
int gsm48_send_rr_ciph_mode(struct gsm_lchan *lchan, int want_imeisv);
int gsm48_send_rr_app_info(struct ran_conn *conn, uint8_t apdu_id,
uint8_t apdu_len, const uint8_t *apdu);
int gsm48_send_rr_app_info(struct msc_a *msc_a, uint8_t apdu_id, uint8_t apdu_len, const uint8_t *apdu);
int gsm48_send_rr_ass_cmd(struct gsm_lchan *dest_lchan, struct gsm_lchan *lchan, uint8_t power_class);
int gsm48_send_ho_cmd(struct gsm_lchan *old_lchan, struct gsm_lchan *new_lchan,
uint8_t power_command, uint8_t ho_ref);
int gsm48_send_ho_cmd(struct gsm_lchan *old_lchan, struct gsm_lchan *new_lchan, uint8_t power_command, uint8_t ho_ref);
int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg);
void gsm48_cc_rx_setup_cn_local_rtp_port_known(struct gsm_trans *trans);
void gsm48_cc_rx_call_conf_cn_local_rtp_port_known(struct gsm_trans *trans);
int cc_on_cn_local_rtp_port_known(struct gsm_trans *trans);
int cc_on_assignment_done(struct gsm_trans *trans);
int mncc_tx_to_cc(struct gsm_network *net, void *arg);
/* convert a ASCII phone number to call-control BCD */
int encode_bcd_number(uint8_t *bcd_lv, uint8_t max_len,
@ -59,8 +59,6 @@ int decode_bcd_number(char *output, int output_len, const uint8_t *bcd_lv,
int h_len);
int send_siemens_mrpci(struct gsm_lchan *lchan, uint8_t *classmark2_lv);
int gsm48_extract_mi(uint8_t *classmark2, int length, char *mi_string, uint8_t *mi_type);
int gsm48_paging_extract_mi(struct gsm48_pag_resp *pag, int length, char *mi_string, uint8_t *mi_type);
int gsm48_lchan_modify(struct gsm_lchan *lchan, uint8_t lchan_mode);
int gsm48_rx_rr_modif_ack(struct msgb *msg);
@ -77,5 +75,14 @@ int gsm48_multirate_config(uint8_t *lv, const struct amr_multirate_conf *mr, con
int gsm48_tch_rtp_create(struct gsm_trans *trans);
int gsm48_conn_sendmsg(struct msgb *msg, struct ran_conn *conn, struct gsm_trans *trans);
struct msgb *gsm48_create_mm_info(struct gsm_network *net);
int gsm0408_rcv_cc(struct msc_a *msc_a, struct msgb *msg);
int gsm0408_rcv_mm(struct msc_a *msc_a, struct msgb *msg);
int gsm0408_rcv_rr(struct msc_a *msc_a, struct msgb *msg);
int msc_vlr_tx_cm_serv_acc(void *msc_conn_ref, enum osmo_cm_service_type cm_service_type);
int compl_l3_msg_is_r99(const struct msgb *msg);
#endif

View File

@ -7,31 +7,14 @@
struct vlr_subscr;
struct ran_conn;
struct gsm_trans;
struct msc_a;
#define UM_SAPI_SMS 3 /* See GSM 04.05/04.06 */
/* SMS deliver PDU */
struct sms_deliver {
uint8_t mti:2; /* message type indicator */
uint8_t mms:1; /* more messages to send */
uint8_t rp:1; /* reply path */
uint8_t udhi:1; /* user data header indicator */
uint8_t sri:1; /* status report indication */
uint8_t *orig_addr; /* originating address */
uint8_t pid; /* protocol identifier */
uint8_t dcs; /* data coding scheme */
/* service centre time stamp */
uint8_t ud_len; /* user data length */
uint8_t *user_data; /* user data */
uint8_t msg_ref; /* message reference */
uint8_t *smsc;
};
struct gsm_network;
struct msgb;
int gsm0411_rcv_sms(struct ran_conn *conn, struct msgb *msg);
int gsm0411_rcv_sms(struct msc_a *msc_a, struct msgb *msg);
struct gsm_sms *sms_alloc(void);
void sms_free(struct gsm_sms *sms);
@ -44,9 +27,11 @@ int gsm411_send_sms(struct gsm_network *net,
struct gsm_sms *sms);
int gsm411_send_rp_data(struct gsm_network *net, struct vlr_subscr *vsub,
size_t sm_rp_oa_len, const uint8_t *sm_rp_oa,
size_t sm_rp_ud_len, const uint8_t *sm_rp_ud);
size_t sm_rp_ud_len, const uint8_t *sm_rp_ud,
bool sm_rp_mmts_ind, const uint8_t *gsup_source_name,
size_t gsup_source_name_len);
void gsm411_sapi_n_reject(struct ran_conn *conn);
void gsm411_sapi_n_reject(struct msc_a *msc_a);
int gsm411_send_rp_ack(struct gsm_trans *trans, uint8_t msg_ref);
int gsm411_send_rp_error(struct gsm_trans *trans, uint8_t msg_ref,

View File

@ -2,6 +2,7 @@
#include <stdint.h>
struct gsup_client_mux;
struct osmo_gsup_message;
struct vlr_subscr;
struct gsm_trans;
@ -10,11 +11,9 @@ struct msgb;
int gsm411_gsup_mo_ready_for_sm_req(struct gsm_trans *trans, uint8_t sm_rp_mr);
int gsm411_gsup_mo_fwd_sm_req(struct gsm_trans *trans, struct msgb *msg,
uint8_t sm_rp_mr, uint8_t *sm_rp_da, uint8_t sm_rp_da_len);
int gsm411_gsup_mo_handler(struct vlr_subscr *vsub,
struct osmo_gsup_message *gsup_msg);
int gsm411_gsup_mt_fwd_sm_res(struct gsm_trans *trans, uint8_t sm_rp_mr);
int gsm411_gsup_mt_fwd_sm_err(struct gsm_trans *trans,
uint8_t sm_rp_mr, uint8_t cause);
int gsm411_gsup_mt_handler(struct vlr_subscr *vsub,
struct osmo_gsup_message *gsup_msg);
int gsm411_gsup_rx(struct gsup_client_mux *gcm, void *data, const struct osmo_gsup_message *gsup_msg);

View File

@ -2,14 +2,16 @@
#include <osmocom/gsm/protocol/gsm_04_14.h>
int gsm0414_tx_close_tch_loop_cmd(struct ran_conn *conn,
struct msc_a;
int gsm0414_tx_close_tch_loop_cmd(struct msc_a *msc_a,
enum gsm414_tch_loop_mode loop_mode);
int gsm0414_tx_open_loop_cmd(struct ran_conn *conn);
int gsm0414_tx_act_emmi_cmd(struct ran_conn *conn);
int gsm0414_tx_test_interface(struct ran_conn *conn,
int gsm0414_tx_open_loop_cmd(struct msc_a *msc_a);
int gsm0414_tx_act_emmi_cmd(struct msc_a *msc_a);
int gsm0414_tx_test_interface(struct msc_a *msc_a,
uint8_t tested_devs);
int gsm0414_tx_reset_ms_pos_store(struct ran_conn *conn,
int gsm0414_tx_reset_ms_pos_store(struct msc_a *msc_a,
uint8_t technology);
int gsm0414_rcv_test(struct ran_conn *conn,
int gsm0414_rcv_test(struct msc_a *msc_a,
struct msgb *msg);

View File

@ -2,12 +2,13 @@
#include <stdint.h>
struct ran_conn;
struct msc_a;
int msc_send_ussd_reject(struct ran_conn *conn,
uint8_t transaction_id, int invoke_id,
uint8_t problem_tag, uint8_t problem_code);
int msc_send_ussd_reject(struct msc_a *msc_a, uint8_t transaction_id, int invoke_id,
uint8_t problem_tag, uint8_t problem_code);
int msc_send_ussd_notify(struct ran_conn *conn, int level,
const char *text);
int msc_send_ussd_release_complete(struct ran_conn *conn);
int msc_send_ussd_notify(struct msc_a *msc_a, int level, const char *text);
int msc_send_ussd_release_complete(struct msc_a *msc_a, uint8_t transaction_id);
int msc_send_ussd_release_complete_cause(struct msc_a *msc_a,
uint8_t transaction_id,
uint8_t cause_loc, uint8_t cause_val);

View File

@ -1,7 +1,9 @@
#pragma once
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/gsup.h>
struct msc_a;
struct mgsb;
struct gsup_client_mux;
struct osmo_gsup_message;
int gsm0911_rcv_nc_ss(struct ran_conn *conn, struct msgb *msg);
int gsm0911_gsup_handler(struct vlr_subscr *vsub, struct osmo_gsup_message *gsup);
int gsm0911_rcv_nc_ss(struct msc_a *msc_a, struct msgb *msg);
int gsm0911_gsup_rx(struct gsup_client_mux *gcm, void *data, const struct osmo_gsup_message *msg);

View File

@ -10,22 +10,20 @@
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/select.h>
#include <osmocom/core/stats.h>
#include <osmocom/core/stat_item.h>
#include <osmocom/gsm/gsm48.h>
#include <osmocom/crypt/auth.h>
#include <osmocom/crypt/utran_cipher.h>
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/mgcp_client/mgcp_client_pool.h>
#include <osmocom/msc/msc_common.h>
#include <osmocom/msc/neighbor_ident.h>
#include <osmocom/msc/sms_queue.h>
#include "gsm_data_shared.h"
/* TS 48.008 DLCI containing DCCH/ACCH + SAPI */
#define OMSC_LINKID_CB(__msgb) (__msgb)->cb[3]
#include "../../bscconfig.h"
#if BUILD_IU
#include <osmocom/ranap/iu_client.h>
#endif
#include "osmux.h"
/** annotations for msgb ownership */
#define __uses
@ -33,7 +31,9 @@
struct mncc_sock_state;
struct vlr_instance;
struct vlr_subscr;
struct gsup_client_mux;
#define SMS_DEFAULT_DB_FILE_PATH "sms.db"
#define tmsi_from_string(str) strtoul(str, NULL, 10)
enum {
@ -47,6 +47,8 @@ enum {
MSC_CTR_CM_SERVICE_REQUEST_ACCEPTED,
MSC_CTR_PAGING_RESP_REJECTED,
MSC_CTR_PAGING_RESP_ACCEPTED,
MSC_CTR_CM_RE_ESTABLISH_REQ_REJECTED,
MSC_CTR_CM_RE_ESTABLISH_REQ_ACCEPTED,
MSC_CTR_SMS_SUBMITTED,
MSC_CTR_SMS_NO_RECEIVER,
MSC_CTR_SMS_DELIVERED,
@ -69,30 +71,33 @@ enum {
};
static const struct rate_ctr_desc msc_ctr_description[] = {
[MSC_CTR_LOC_UPDATE_TYPE_ATTACH] = {"loc_update_type:attach", "Received location update imsi attach requests."},
[MSC_CTR_LOC_UPDATE_TYPE_NORMAL] = {"loc_update_type:normal", "Received location update normal requests."},
[MSC_CTR_LOC_UPDATE_TYPE_PERIODIC] = {"loc_update_type:periodic", "Received location update periodic requests."},
[MSC_CTR_LOC_UPDATE_TYPE_DETACH] = {"loc_update_type:detach", "Received location update detach indication."},
[MSC_CTR_LOC_UPDATE_FAILED] = {"loc_update_resp:failed", "Rejected location updates."},
[MSC_CTR_LOC_UPDATE_COMPLETED] = {"loc_update_resp:completed", "Successful location updates."},
[MSC_CTR_CM_SERVICE_REQUEST_REJECTED] = {"cm_service_request:rejected", "Rejected CM Service Request."},
[MSC_CTR_CM_SERVICE_REQUEST_ACCEPTED] = {"cm_service_request:accepted", "Accepted CM Service Request."},
[MSC_CTR_PAGING_RESP_REJECTED] = {"paging_resp:rejected", "Rejected Paging Response."},
[MSC_CTR_PAGING_RESP_ACCEPTED] = {"paging_resp:accepted", "Accepted Paging Response."},
[MSC_CTR_SMS_SUBMITTED] = {"sms:submitted", "Received a RPDU from a MS (MO)."},
[MSC_CTR_SMS_NO_RECEIVER] = {"sms:no_receiver", "Counts SMS which couldn't routed because no receiver found."},
[MSC_CTR_SMS_DELIVERED] = {"sms:delivered", "Global SMS Deliver attempts."},
[MSC_CTR_SMS_RP_ERR_MEM] = {"sms:rp_err_mem", "CAUSE_MT_MEM_EXCEEDED errors of MS responses on a sms deliver attempt."},
[MSC_CTR_SMS_RP_ERR_OTHER] = {"sms:rp_err_other", "Other error of MS responses on a sms delive attempt."},
[MSC_CTR_SMS_DELIVER_UNKNOWN_ERROR] = {"sms:deliver_unknown_error", "Unknown error occured during sms delivery."},
/* FIXME: count also sms delivered */
[MSC_CTR_CALL_MO_SETUP] = {"call:mo_setup", "Received setup requests from a MS to init a MO call."},
[MSC_CTR_CALL_MO_CONNECT_ACK] = {"call:mo_connect_ack", "Received a connect ack from MS of a MO call. Call is now succesful connected up."},
[MSC_CTR_CALL_MT_SETUP] = {"call:mt_setup", "Sent setup requests to the MS (MT)."},
[MSC_CTR_CALL_MT_CONNECT] = {"call:mt_connect", "Sent a connect to the MS (MT)."},
[MSC_CTR_CALL_ACTIVE] = {"call:active", "Count total amount of calls that ever reached active state."},
[MSC_CTR_CALL_COMPLETE] = {"call:complete", "Count total amount of calls which got terminated by disconnect req or ind after reaching active state."},
[MSC_CTR_CALL_INCOMPLETE] = {"call:incomplete", "Count total amount of call which got terminated by any other reason after reaching active state."},
[MSC_CTR_LOC_UPDATE_TYPE_ATTACH] = {"loc_update_type:attach", "Received Location Update (IMSI Attach) requests."},
[MSC_CTR_LOC_UPDATE_TYPE_NORMAL] = {"loc_update_type:normal", "Received Location Update (LAC change) requests."},
[MSC_CTR_LOC_UPDATE_TYPE_PERIODIC] = {"loc_update_type:periodic", "Received (periodic) Location Update requests."},
[MSC_CTR_LOC_UPDATE_TYPE_DETACH] = {"loc_update_type:detach", "Received IMSI Detach indications."},
[MSC_CTR_LOC_UPDATE_FAILED] = {"loc_update_resp:failed", "Rejected Location Update requests."},
[MSC_CTR_LOC_UPDATE_COMPLETED] = {"loc_update_resp:completed", "Successful Location Update procedures."},
[MSC_CTR_CM_SERVICE_REQUEST_REJECTED] = {"cm_service_request:rejected", "Rejected CM Service Requests."},
[MSC_CTR_CM_SERVICE_REQUEST_ACCEPTED] = {"cm_service_request:accepted", "Accepted CM Service Requests."},
[MSC_CTR_PAGING_RESP_REJECTED] = {"paging_resp:rejected", "Rejected Paging Responses."},
[MSC_CTR_PAGING_RESP_ACCEPTED] = {"paging_resp:accepted", "Accepted Paging Responses."},
[MSC_CTR_CM_RE_ESTABLISH_REQ_REJECTED] = {"cm_re_establish_request:rejected", "Rejected CM Re-Establishing Requests."},
[MSC_CTR_CM_RE_ESTABLISH_REQ_ACCEPTED] = {"cm_re_establish_request:accepted", "Accepted CM Re-Establishing Requests."},
[MSC_CTR_SMS_SUBMITTED] = {"sms:submitted", "Total MO SMS received from the MS."},
[MSC_CTR_SMS_NO_RECEIVER] = {"sms:no_receiver", "Failed MO SMS delivery attempts (no receiver found)."},
[MSC_CTR_SMS_DELIVER_UNKNOWN_ERROR] = {"sms:deliver_unknown_error", "Failed MO SMS delivery attempts (other reason)."},
/* FIXME: "sms:delivered" should actually count number of _successfully_ delivered MT SMS.
* The current description reflects its current (errorneous) behaviour. */
[MSC_CTR_SMS_DELIVERED] = {"sms:delivered", "Total MT SMS delivery attempts."},
[MSC_CTR_SMS_RP_ERR_MEM] = {"sms:rp_err_mem", "Failed MT SMS delivery attempts (no memory)."},
[MSC_CTR_SMS_RP_ERR_OTHER] = {"sms:rp_err_other", "Failed MT SMS delivery attempts (other reason)."},
[MSC_CTR_CALL_MO_SETUP] = {"call:mo_setup", "Received MO SETUP messages (MO call establishment)."},
[MSC_CTR_CALL_MO_CONNECT_ACK] = {"call:mo_connect_ack", "Received MO CONNECT messages (MO call establishment)."},
[MSC_CTR_CALL_MT_SETUP] = {"call:mt_setup", "Sent MT SETUP messages (MT call establishment)."},
[MSC_CTR_CALL_MT_CONNECT] = {"call:mt_connect", "Sent MT CONNECT messages (MT call establishment)."},
[MSC_CTR_CALL_ACTIVE] = {"call:active", "Calls that ever reached the active state."},
[MSC_CTR_CALL_COMPLETE] = {"call:complete", "Calls terminated by DISCONNECT message after reaching the active state."},
[MSC_CTR_CALL_INCOMPLETE] = {"call:incomplete", "Calls terminated by any other reason after reaching the active state."},
[MSC_CTR_NC_SS_MO_REQUESTS] = {"nc_ss:mo_requests", "Received MS-initiated call independent SS/USSD requests."},
[MSC_CTR_NC_SS_MO_ESTABLISHED] = {"nc_ss:mo_established", "Established MS-initiated call independent SS/USSD sessions."},
[MSC_CTR_NC_SS_MT_REQUESTS] = {"nc_ss:mt_requests", "Received network-initiated call independent SS/USSD requests."},
@ -101,6 +106,11 @@ static const struct rate_ctr_desc msc_ctr_description[] = {
[MSC_CTR_BSSMAP_CIPHER_MODE_COMPLETE] = {"bssmap:cipher_mode_complete", "Number of CIPHER MODE COMPLETE messages processed by BSSMAP layer"},
};
enum {
MSC_STAT_ACTIVE_CALLS,
MSC_STAT_ACTIVE_NC_SS,
};
static const struct rate_ctr_group_desc msc_ctrg_desc = {
"msc",
"mobile switching center",
@ -109,6 +119,19 @@ static const struct rate_ctr_group_desc msc_ctrg_desc = {
msc_ctr_description,
};
static const struct osmo_stat_item_desc msc_stat_item_description[] = {
[MSC_STAT_ACTIVE_CALLS] = { "msc.active_calls", "Currently active calls " , OSMO_STAT_ITEM_NO_UNIT, 4, 0},
[MSC_STAT_ACTIVE_NC_SS] = { "msc.active_nc_ss", "Currently active SS/USSD sessions", OSMO_STAT_ITEM_NO_UNIT, 4, 0},
};
static const struct osmo_stat_item_group_desc msc_statg_desc = {
"net",
"network statistics",
OSMO_STATS_CLASS_GLOBAL,
ARRAY_SIZE(msc_stat_item_description),
msc_stat_item_description,
};
#define MSC_PAGING_RESPONSE_TIMER_DEFAULT 10
struct gsm_tz {
@ -135,15 +158,18 @@ struct gsm_network {
bool authentication_required;
int send_mm_info;
/* bit-mask of permitted encryption algorithms. LSB=UEA0, MSB=UEA7 */
uint8_t uea_encryption_mask;
struct rate_ctr_group *msc_ctrs;
struct osmo_counter *active_calls;
struct osmo_counter *active_nc_ss;
struct osmo_stat_item_group *statg;
/* layer 4 */
char *mncc_sock_path;
struct mncc_sock_state *mncc_state;
mncc_recv_cb_t mncc_recv;
struct llist_head upqueue;
struct osmo_tdef *mncc_tdefs;
/*
* TODO: Move the trans_list into the RAN connection and
* create a pending list for MT transactions. These exist before
@ -151,8 +177,6 @@ struct gsm_network {
*/
struct llist_head trans_list;
unsigned int paging_response_timer;
/* Radio Resource Location Protocol (TS 04.31) */
struct {
enum rrlp_mode mode;
@ -171,9 +195,6 @@ struct gsm_network {
/* control interface */
struct ctrl_handle *ctrl;
/* all active RAN connections. */
struct llist_head ran_conns;
/* if override is nonzero, this timezone data is used for all MM
* contexts. */
/* TODO: in OsmoNITB, tz-override used to be BTS-specific. To enable
@ -184,36 +205,36 @@ struct gsm_network {
/* MSC: GSUP server address of the HLR */
const char *gsup_server_addr_str;
uint16_t gsup_server_port;
struct gsup_client_mux *gcm;
struct vlr_instance *vlr;
/* Periodic location update default value */
uint8_t t3212;
/* Global MNCC guard timer value */
int mncc_guard_timeout;
/* Global guard timer value for NCSS sessions */
int ncss_guard_timeout;
struct {
struct mgcp_client_conf conf;
struct mgcp_client *client;
struct osmo_tdef *tdefs;
struct mgcp_client_conf *conf;
/* MGW pool, also includes the single MGCP client as fallback if no
* pool is configured. */
struct mgcp_client_pool *mgw_pool;
} mgw;
#if BUILD_IU
struct {
/* CS7 instance id number (set via VTY) */
uint32_t cs7_instance;
enum ranap_nsap_addr_enc rab_assign_addr_enc;
struct osmo_sccp_instance *sccp;
enum nsap_addr_enc rab_assign_addr_enc;
struct sccp_ran_inst *sri;
} iu;
#endif
struct {
/* CS7 instance id number (set via VTY) */
uint32_t cs7_instance;
/* A list with the context information about
* all BSCs we have connections with */
struct llist_head bscs;
struct osmo_sccp_instance *sccp;
struct sccp_ran_inst *sri;
} a;
struct {
@ -226,9 +247,37 @@ struct gsm_network {
* If no name is set, the IPA Serial Number will be the same as the Unit Name,
* and will be of the form 'MSC-00-00-00-00-00-00' */
char *msc_ipa_name;
/* A list of neighbor BSCs. This list is defined statically via VTY and does not
* necessarily correspond to BSCs attached to the A interface at a given moment. */
struct llist_head neighbor_ident_list;
struct {
uint64_t range_start;
uint64_t range_end;
uint64_t next;
} handover_number;
/* Whether we want to use Osmux against BSCs. Controlled via VTY */
enum osmux_usage use_osmux;
/* Whether to use call waiting on the network */
bool call_waiting;
/* Whether to use lcls on the network */
bool lcls_permitted;
/* SMS queue config parameters */
struct sms_queue_config *sms_queue_cfg;
/* ASCI feature support */
struct {
bool enable;
struct llist_head gcr_lists;
} asci;
};
struct osmo_esme;
struct smpp_esme;
enum gsm_sms_source_id {
SMS_SOURCE_UNKNOWN = 0,
@ -237,7 +286,6 @@ enum gsm_sms_source_id {
SMS_SOURCE_SMPP, /* received via SMPP */
};
#define SMS_HDR_SIZE 128
#define SMS_TEXT_SIZE 256
struct gsm_sms_addr {
@ -258,7 +306,7 @@ struct gsm_sms {
} gsm411;
struct {
struct osmo_esme *esme;
struct smpp_esme *esme;
uint32_t sequence_nr;
int transaction_mode;
char msg_id[16];

View File

@ -31,10 +31,4 @@ enum gsm_hooks {
GSM_HOOK_RR_SECURITY,
};
enum gsm_paging_event {
GSM_PAGING_SUCCEEDED,
GSM_PAGING_EXPIRED,
GSM_PAGING_BUSY,
};
#endif

View File

@ -5,46 +5,11 @@
#include <osmocom/core/linuxlist.h>
#include <osmocom/gsm/protocol/gsm_23_003.h>
#include <osmocom/gsm/protocol/gsm_29_118.h>
#include <osmocom/msc/gsm_data.h>
struct ran_conn;
struct msgb;
typedef int gsm_cbfn(unsigned int hooknum, unsigned int event, struct msgb *msg,
void *data, void *param);
/*
* Struct for pending channel requests. This is managed in the
* llist_head requests of each subscriber. The reference counting
* should work in such a way that a subscriber with a pending request
* remains in memory.
*/
struct subscr_request {
struct llist_head entry;
/* human readable label to be able to log pending request kinds */
const char *label;
/* the callback data */
gsm_cbfn *cbfn;
void *param;
};
/*
* Paging handling with authentication
*/
struct subscr_request *subscr_request_conn(struct vlr_subscr *vsub,
gsm_cbfn *cbfn, void *param,
const char *label);
void subscr_remove_request(struct subscr_request *req);
void subscr_paging_cancel(struct vlr_subscr *vsub, enum gsm_paging_event event);
int subscr_paging_dispatch(unsigned int hooknum, unsigned int event,
struct msgb *msg, void *data, void *param);
/* Find an allocated channel for a specified subscriber */
struct ran_conn *connection_for_subscr(struct vlr_subscr *vsub);
#endif /* _GSM_SUBSCR_H */

View File

@ -0,0 +1,35 @@
#pragma once
#include <osmocom/gsm/gsup.h>
#include <osmocom/msc/gsup_client_mux.h>
struct gsup_client_mux;
struct ipaccess_unit;
struct gsup_client_mux_rx_cb {
int (* func )(struct gsup_client_mux *gcm, void *data, const struct osmo_gsup_message *gsup_msg);
void *data;
};
/* A GSUP client shared between code paths for various GSUP Message Classes.
* The main task is to dispatch GSUP messages to code paths corresponding to the respective Message Class, i.e.
* subscriber management, SMS, SS/USSD and inter-MSC messaging.
* If a GSUP Message Class IE is present in the message, the received message is dispatched directly to the rx_cb entry
* for that Message Class. Otherwise, the Message Class is determined by a switch() on the Message Type.*/
struct gsup_client_mux {
struct osmo_gsup_client *gsup_client;
/* Target clients by enum osmo_gsup_message_class */
struct gsup_client_mux_rx_cb rx_cb[OSMO_GSUP_MESSAGE_CLASS_ARRAYSIZE];
};
struct gsup_client_mux *gsup_client_mux_alloc(void *talloc_ctx);
int gsup_client_mux_start(struct gsup_client_mux *gcm, const char *gsup_server_addr_str, uint16_t gsup_server_port,
struct ipaccess_unit *ipa_dev);
int gsup_client_mux_tx(struct gsup_client_mux *gcm, const struct osmo_gsup_message *gsup_msg);
void gsup_client_mux_tx_set_source(const struct gsup_client_mux *gcm, struct osmo_gsup_message *gsup_msg);
void gsup_client_mux_tx_error_reply(struct gsup_client_mux *gcm, const struct osmo_gsup_message *gsup_orig,
enum gsm48_gmm_cause cause);
int gsup_client_mux_rx(struct osmo_gsup_client *gsup_client, struct msgb *msg);

View File

@ -1,50 +0,0 @@
/* Trivial switch-off of external Iu dependencies,
* allowing to run full unit tests even when built without Iu support. */
/*
* (C) 2016,2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
*
* Author: Neels Hofmeyr <nhofmeyr@sysmocom.de>
*
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <stdint.h>
#include <stdbool.h>
#include <osmocom/core/linuxlist.h>
struct msgb;
struct RANAP_Cause;
struct osmo_auth_vector;
struct ranap_ue_conn_ctx {
struct llist_head list;
uint32_t conn_id;
};
int ranap_iu_tx(struct msgb *msg, uint8_t sapi);
int ranap_iu_tx_sec_mode_cmd(struct ranap_ue_conn_ctx *uectx, struct osmo_auth_vector *vec,
int send_ck);
int ranap_iu_page_cs(const char *imsi, const uint32_t *tmsi, uint16_t lac);
int ranap_iu_page_ps(const char *imsi, const uint32_t *ptmsi, uint16_t lac, uint8_t rac);
struct msgb *ranap_new_msg_rab_assign_voice(uint8_t rab_id, uint32_t rtp_ip,
uint16_t rtp_port,
bool use_x213_nsap);
int ranap_iu_rab_act(struct ranap_ue_conn_ctx *ue_ctx, struct msgb *msg);
int ranap_iu_tx_common_id(struct ranap_ue_conn_ctx *uectx, const char *imsi);
int ranap_iu_tx_release(struct ranap_ue_conn_ctx *ctx, const struct RANAP_Cause *cause);

View File

@ -1,14 +0,0 @@
#pragma once
#include <osmocom/msc/transaction.h>
struct ranap_ue_conn_ctx;
int gsm0408_rcvmsg_iucs(struct gsm_network *network, struct msgb *msg,
uint16_t *lac);
struct ran_conn *ran_conn_lookup_iu(struct gsm_network *network,
struct ranap_ue_conn_ctx *ue);
int iu_rab_act_cs(struct gsm_trans *trans);
uint32_t iu_get_conn_id(const struct ranap_ue_conn_ctx *ue);

View File

@ -1,7 +0,0 @@
#pragma once
struct gsm_network;
struct ranap_ue_conn_ctx;
int iucs_rx_ranap_event(struct gsm_network *network,
struct ranap_ue_conn_ctx *ue_ctx, int type, void *data);

View File

@ -1,4 +1,4 @@
/* GSM Mobile Radio Interface Layer 3 messages on the A-bis interface
/* GSM Mobile Radio Interface Layer 3 messages on the A-bis interface
* 3GPP TS 04.08 version 7.21.0 Release 1998 / ETSI TS 100 940 V7.21.0 */
/* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
@ -28,9 +28,11 @@
#include <osmocom/gsm/mncc.h>
#include <stdint.h>
#include <netinet/in.h>
struct gsm_network;
struct msgb;
struct gsm0808_channel_type;
/* One end of a call */
@ -52,7 +54,7 @@ struct gsm_call {
#define MNCC_SETUP_CNF 0x0104
#define MNCC_SETUP_COMPL_REQ 0x0105
#define MNCC_SETUP_COMPL_IND 0x0106
/* MNCC_REJ_* is perfomed via MNCC_REL_* */
/* MNCC_REJ_* is performed via MNCC_REL_* */
#define MNCC_CALL_CONF_IND 0x0107
#define MNCC_CALL_PROC_REQ 0x0108
#define MNCC_PROGRESS_REQ 0x0109
@ -122,6 +124,15 @@ struct gsm_call {
#define MNCC_F_CCCAP 0x0800
#define MNCC_F_KEYPAD 0x1000
#define MNCC_F_SIGNAL 0x2000
#define MNCC_F_GCR 0x4000
#define MNCC_F_HIGHL_COMPAT 0x8000
#define MNCC_F_LOWL_COMPAT 0x10000
/* UPDATEME when adding new MNCC_F_* entries above */
#define MNCC_F_ALL 0x1ffff
#define GSM_MAX_LOWL_COMPAT 16 /* (18 with TLV) */
#define GSM_MAX_HIGHL_COMPAT 3 /* (5 with TLV) */
struct gsm_mncc {
/* context based information */
@ -131,7 +142,7 @@ struct gsm_mncc {
/* which fields are present */
uint32_t fields;
/* data derived informations (MNCC_F_ based) */
/* data derived information (MNCC_F_ based) */
struct gsm_mncc_bearer_cap bearer_cap;
struct gsm_mncc_number called;
struct gsm_mncc_number calling;
@ -158,6 +169,26 @@ struct gsm_mncc {
unsigned char lchan_type;
unsigned char lchan_mode;
/* Global Call Reference (encoded as per 3GPP TS 29.205) */
uint8_t gcr[16];
/* A buffer to contain SDP ('\0' terminated) */
char sdp[1024];
/* Additional information that extends current socket interface version. */
/* The content requals of Low Layer compatibility IE, described in 3GPP TS 24.008 §10.5.4.18. */
struct gsm_mncc_lowl_compat {
uint8_t len;
uint8_t compat[GSM_MAX_LOWL_COMPAT];
} llc;
/* The content requals of High Layer compatibility IE, described in 3GPP TS 24.008 §10.5.4.16. */
struct gsm_mncc_highl_compat {
uint8_t len;
uint8_t compat[GSM_MAX_HIGHL_COMPAT];
} hlc;
};
struct gsm_data_frame {
@ -166,7 +197,7 @@ struct gsm_data_frame {
unsigned char data[0];
};
#define MNCC_SOCK_VERSION 5
#define MNCC_SOCK_VERSION 8
struct gsm_mncc_hello {
uint32_t msg_type;
uint32_t version;
@ -185,10 +216,10 @@ struct gsm_mncc_hello {
struct gsm_mncc_rtp {
uint32_t msg_type;
uint32_t callref;
uint32_t ip;
uint16_t port;
struct sockaddr_storage addr;
uint32_t payload_type;
uint32_t payload_msg_type;
char sdp[1024];
};
struct gsm_mncc_bridge {
@ -196,9 +227,17 @@ struct gsm_mncc_bridge {
uint32_t callref[2];
};
union mncc_msg {
uint32_t msg_type;
struct gsm_mncc signal;
struct gsm_mncc_hello hello;
struct gsm_data_frame data_frame;
struct gsm_mncc_rtp rtp;
struct gsm_mncc_bridge bridge;
};
const char *get_mncc_name(int value);
void mncc_set_cause(struct gsm_mncc *data, int loc, int val);
void cc_tx_to_mncc(struct gsm_network *net, struct msgb *msg);
/* input from CC code into mncc_builtin */
int int_mncc_recv(struct gsm_network *net, struct msgb *msg);
@ -216,5 +255,8 @@ int mncc_sock_init(struct gsm_network *net, const char *sock_path);
|| msg_type == GSM_BAD_FRAME)
int mncc_prim_check(const struct gsm_mncc *mncc_prim, unsigned int len);
int mncc_check_sdp_termination(const char *label, const struct gsm_mncc *mncc, unsigned int len, const char *sdp);
int mncc_bearer_cap_to_channel_type(struct gsm0808_channel_type *ct, const struct gsm_mncc_bearer_cap *bc);
#endif

View File

@ -0,0 +1,143 @@
/* Handle an MNCC managed call (external MNCC). */
/*
* (C) 2019 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* SPDX-License-Identifier: AGPL-3.0+
*
* Author: Neels Hofmeyr
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/msc/mncc.h>
#include <osmocom/msc/mncc_call.h>
struct osmo_fsm_inst;
struct rtp_stream;
#define LOG_MNCC_CALL(MNCC, LEVEL, FMT, ARGS...) \
LOGPFSML((MNCC) ? (MNCC)->fi : NULL, LEVEL, FMT, ##ARGS)
enum mncc_call_fsm_event {
/* An MNCC message was received from the MNCC socket. The data argument is a const union mncc_msg* pointing at
* the message contents. */
MNCC_CALL_EV_RX_MNCC_MSG,
/* The user has invoked mncc_call_outgoing_start(); this event exists to ensure that the FSM is in a state that
* allows starting a new outgoing call. */
MNCC_CALL_EV_OUTGOING_START,
/* The MNCC server has sent an MNCC_ALERT_REQ. */
MNCC_CALL_EV_OUTGOING_ALERTING,
/* The MNCC server has confirmed call setup with an MNCC_SETUP_RSP, we have sent an MNCC_SETUP_COMPL_IND. */
MNCC_CALL_EV_OUTGOING_SETUP_COMPLETE,
/* The user has invoked mncc_call_incoming_start(); this event exists to ensure that the FSM is in a state that
* allows starting a new incoming call. */
MNCC_CALL_EV_INCOMING_START,
/* MNCC server sent an MNCC_SETUP_REQ */
MNCC_CALL_EV_INCOMING_SETUP,
/* MNCC server confirmed call setup with an MNCC_SETUP_COMPL_REQ */
MNCC_CALL_EV_INCOMING_SETUP_COMPLETE,
/* MNCC server requests call release (Rx MNCC_DISC_REQ) */
MNCC_CALL_EV_CN_RELEASE,
/* osmo-msc should request call release (Tx MNCC_DISC_IND) */
MNCC_CALL_EV_MS_RELEASE,
};
/* The typical progression of outgoing and incoming calls via MNCC is shown by doc/sequence_charts/mncc_call_fsm.msc */
enum mncc_call_fsm_state {
MNCC_CALL_ST_NOT_STARTED = 0,
MNCC_CALL_ST_OUTGOING_WAIT_PROCEEDING,
MNCC_CALL_ST_OUTGOING_WAIT_COMPLETE,
MNCC_CALL_ST_INCOMING_WAIT_COMPLETE,
MNCC_CALL_ST_TALKING,
MNCC_CALL_ST_WAIT_RELEASE_ACK,
};
struct mncc_call_incoming_req {
bool bearer_cap_present;
struct gsm_mncc_bearer_cap bearer_cap;
bool cccap_present;
struct gsm_mncc_cccap cccap;
struct gsm_mncc setup_req_msg;
};
struct mncc_call;
typedef void (* mncc_call_message_cb_t )(struct mncc_call *mncc_call, const union mncc_msg *mncc_msg, void *data);
struct mncc_call {
struct llist_head entry;
struct osmo_fsm_inst *fi;
struct vlr_subscr *vsub;
struct gsm_network *net;
/* Details originally passed to mncc_call_outgoing_start(), if any. */
struct gsm_mncc outgoing_req;
uint32_t callref;
bool remote_msisdn_present;
struct gsm_mncc_number remote_msisdn;
bool local_msisdn_present;
struct gsm_mncc_number local_msisdn;
struct rtp_stream *rtps;
bool received_rtp_create;
mncc_call_message_cb_t message_cb;
void *forward_cb_data;
/* Event to dispatch to the FSM inst parent when the call is complete. Omit event dispatch when negative. See
* mncc_call_alloc()'s arg of same name. */
int parent_event_call_setup_complete;
};
void mncc_call_fsm_init(struct gsm_network *net);
struct mncc_call *mncc_call_alloc(struct vlr_subscr *vsub,
struct osmo_fsm_inst *parent,
int parent_event_call_setup_complete,
uint32_t parent_event_call_released,
mncc_call_message_cb_t message_cb, void *forward_cb_data);
void mncc_call_reparent(struct mncc_call *mncc_call,
struct osmo_fsm_inst *new_parent,
int parent_event_call_setup_complete,
uint32_t parent_event_call_released,
mncc_call_message_cb_t message_cb, void *forward_cb_data);
int mncc_call_outgoing_start(struct mncc_call *mncc_call, const struct gsm_mncc *outgoing_req);
int mncc_call_incoming_start(struct mncc_call *mncc_call, const struct mncc_call_incoming_req *incoming_req);
int mncc_call_incoming_tx_setup_cnf(struct mncc_call *mncc_call, const struct gsm_mncc_number *connected_number);
int mncc_call_set_rtp_stream(struct mncc_call *mncc_call, struct rtp_stream *rtps);
void mncc_call_detach_rtp_stream(struct mncc_call *mncc_call);
void mncc_call_rx(struct mncc_call *mncc_call, const union mncc_msg *mncc_msg);
int mncc_call_tx(struct mncc_call *mncc_call, union mncc_msg *mncc_msg);
int mncc_call_tx_msgt(struct mncc_call *mncc_call, uint32_t msg_type);
struct mncc_call *mncc_call_find_by_callref(uint32_t callref);
void mncc_call_release(struct mncc_call *mncc_call);
uint32_t mgcp_codec_to_mncc_payload_msg_type(enum mgcp_codecs codec);

235
include/osmocom/msc/msc_a.h Normal file
View File

@ -0,0 +1,235 @@
/* MSC-A role: main subscriber management */
/*
* (C) 2019 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* SPDX-License-Identifier: AGPL-3.0+
*
* Author: Neels Hofmeyr
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <osmocom/core/use_count.h>
#include <osmocom/core/tdef.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <osmocom/gsm/protocol/gsm_08_08.h>
#include <osmocom/gsm/gsm23003.h>
#include <osmocom/msc/msc_roles.h>
#include <osmocom/msc/ran_msg.h>
#include <osmocom/msc/msc_common.h>
#include <osmocom/msc/msc_ho.h>
#include <osmocom/msc/neighbor_ident.h>
struct ran_infra;
struct vgcs_bss;
struct vgcs_bss_cell;
#define MSC_A_USE_LOCATION_UPDATING "lu"
#define MSC_A_USE_CM_SERVICE_CC "cm_service_cc"
#define MSC_A_USE_CM_SERVICE_GCC "cm_service_gcc"
#define MSC_A_USE_CM_SERVICE_BCC "cm_service_bcc"
#define MSC_A_USE_CM_SERVICE_SMS "cm_service_sms"
#define MSC_A_USE_CM_SERVICE_SS "cm_service_ss"
#define MSC_A_USE_PAGING_RESPONSE "paging-response"
#define MSC_A_USE_GCC "gcc"
#define MSC_A_USE_BCC "bcc"
#define MSC_A_USE_CC "cc"
#define MSC_A_USE_SMS "sms"
#define MSC_A_USE_SMS_MMTS "sms_mmts"
#define MSC_A_USE_NC_SS "nc_ss"
#define MSC_A_USE_SILENT_CALL "silent_call"
/* These are macros to use the source file:line information from the caller in a trivial way */
#define msc_a_get(msc_a, use) \
OSMO_ASSERT(osmo_use_count_get_put(&msc_a->use_count, use, 1) == 0)
#define msc_a_put(msc_a, use) \
OSMO_ASSERT(osmo_use_count_get_put(&msc_a->use_count, use, -1) == 0)
#define msc_a_put_all(msc_a, use) do { \
int32_t has_count = osmo_use_count_by(&msc_a->use_count, use); \
if (has_count) \
OSMO_ASSERT(osmo_use_count_get_put(&msc_a->use_count, use, -has_count) == 0); \
} while(0)
enum msc_a_action_on_classmark_update_type {
MSC_A_CLASSMARK_UPDATE_NOT_EXPECTED = 0,
MSC_A_CLASSMARK_UPDATE_THEN_CIPHERING,
};
/* A Classmark Update might be required for various tasks. At the time of writing, the only use case is to determine A5
* capabilities for choosing a ciphering algorithm. This structure anticipates other Classmark Update use cases to be
* added in the future. */
struct msc_a_action_on_classmark_update {
enum msc_a_action_on_classmark_update_type type;
union {
/* State required to resume Ciphering after the Classmark Request / Classmark Update is complete. */
struct {
bool umts_aka;
bool retrieve_imeisv;
} ciphering;
/* Add more use cases here... */
};
};
struct msc_a {
/* struct msc_role_common must remain at start */
struct msc_role_common c;
enum complete_layer3_type complete_layer3_type;
struct osmo_cell_global_id via_cell;
/* Temporary storage for Classmark Information for times when a connection has no VLR subscriber
* associated yet. It will get copied to the VLR subscriber upon msc_vlr_subscr_assoc(). */
struct osmo_gsm48_classmark temporary_classmark;
/* See handling of E_MSC_A_CLASSMARK_UPDATE */
struct msc_a_action_on_classmark_update action_on_classmark_update;
uint32_t state_before_classmark_update;
/* After Ciphering Mode Complete on GERAN, this reflects the chosen ciphering algorithm and key */
struct geran_encr geran_encr;
/* Type of MI requested in MM Identity Request */
uint8_t mm_id_req_type;
/* N(SD) expected in the received frame, per flow (TS 24.007 11.2.3.2.3.2.2) */
uint8_t n_sd_next[4];
/* Call control and MSC-A side of RTP switching. Without inter-MSC handover involved, this manages all of the
* MGW and RTP switching; after an inter-MSC handover, the RAN-side of this is redirected via another MNCC
* connection to the Handover MSISDN, and a remote MSC-I role takes over RTP switching to the remote BSS.
*
* Without / before inter-MSC HO:
*
* BSS [MSC-I MSC-A] MNCC to PBX
* <--RTP---------> <--RTP-->
*
* After inter-MSC HO:
*
* BSS [MSC-I MSC-A] MNCC to PBX MSC-I BSS-B
* /--> <--RTP-->
* \-------RTP--> (ISUP) <--RTP--> <--RTP-->
*/
struct {
/* Codec List (BSS Supported) as received during Complete Layer 3 Information */
struct gsm0808_speech_codec_list compl_l3_codec_list_bss_supported;
/* All of the RTP stream handling */
struct call_leg *call_leg;
struct mncc_call *mncc_forwarding_to_remote_ran;
/* There may be up to 7 incoming calls for this subscriber. This is the currently serviced voice call,
* as in, the other person the subscriber is currently talking to. */
struct gsm_trans *active_trans;
} cc;
struct msc_ho_state ho;
struct osmo_use_count use_count;
struct osmo_use_count_entry use_count_buf[8];
int32_t max_total_use_count;
};
osmo_static_assert(offsetof(struct msc_a, c) == 0, msc_role_common_first_member_of_msc_a);
struct msc_a_ran_dec_data {
enum msc_role from_role;
const struct an_apdu *an_apdu;
const struct ran_msg *ran_dec;
};
#define LOG_MSC_A(MSC_A, LEVEL, FMT, ARGS ...) \
LOG_MSC_A_CAT(MSC_A, (MSC_A) ? (MSC_A)->c.ran->log_subsys : DMSC, LEVEL, FMT, ## ARGS)
#define LOG_MSC_A_CAT(MSC_A, SUBSYS, LEVEL, FMT, ARGS ...) \
LOGPFSMSL((MSC_A) ? (MSC_A)->c.fi : NULL, SUBSYS, LEVEL, FMT, ## ARGS)
#define LOG_MSC_A_CAT_SRC(MSC_A, SUBSYS, LEVEL, SRCFILE, LINE, FMT, ARGS ...) \
LOGPFSMSLSRC((MSC_A) ? (MSC_A)->c.fi : NULL, SUBSYS, LEVEL, SRCFILE, LINE, FMT, ## ARGS)
enum msc_a_states {
MSC_A_ST_VALIDATE_L3,
MSC_A_ST_AUTH_CIPH,
MSC_A_ST_WAIT_CLASSMARK_UPDATE,
MSC_A_ST_AUTHENTICATED,
MSC_A_ST_COMMUNICATING,
MSC_A_ST_RELEASING,
MSC_A_ST_RELEASED,
};
struct msc_a *msc_a_alloc(struct msub *msub, struct ran_infra *ran);
int msc_a_classmark_request_then_cipher_mode_cmd(struct msc_a *msc_a, bool umts_aka, bool retrieve_imeisv);
bool msc_a_is_establishing_auth_ciph(const struct msc_a *msc_a);
bool msc_a_is_accepted(const struct msc_a *msc_a);
bool msc_a_in_release(struct msc_a *msc_a);
struct gsm_network *msc_a_net(const struct msc_a *msc_a);
struct vlr_subscr *msc_a_vsub(const struct msc_a *msc_a);
struct msc_i *msc_a_msc_i(const struct msc_a *msc_a);
struct msc_t *msc_a_msc_t(const struct msc_a *msc_a);
struct msc_a *msc_a_for_vsub(const struct vlr_subscr *vsub, bool valid_conn_only);
void msc_a_pending_cm_service_req_add(struct msc_a *msc_a, enum osmo_cm_service_type type);
unsigned int msc_a_pending_cm_service_req_count(struct msc_a *msc_a, enum osmo_cm_service_type type);
void msc_a_pending_cm_service_req_del(struct msc_a *msc_a, enum osmo_cm_service_type type);
bool msc_a_is_ciphering_to_be_attempted(const struct msc_a *msc_a);
bool msc_a_is_ciphering_required(const struct msc_a *msc_a);
#define msc_a_ran_down(A,B,C) \
_msc_a_ran_down(A,B,C, __FILE__, __LINE__)
int _msc_a_ran_down(struct msc_a *msc_a, enum msc_role to_role, const struct ran_msg *ran_enc_msg,
const char *file, int line);
#define msc_a_msg_down(A,B,C,D) \
_msc_a_msg_down(A,B,C,D, __FILE__, __LINE__)
int _msc_a_msg_down(struct msc_a *msc_a, enum msc_role to_role, uint32_t to_role_event,
const struct ran_msg *ran_enc_msg,
const char *file, int line);
int msc_a_tx_dtap_to_i(struct msc_a *msc_a, struct msgb *dtap);
int msc_a_tx_common_id(struct msc_a *msc_a);
int msc_a_tx_mm_serv_ack(struct msc_a *msc_a);
int msc_a_tx_mm_serv_rej(struct msc_a *msc_a, enum gsm48_reject_value value);
int msc_a_up_l3(struct msc_a *msc_a, struct msgb *msg);
void msc_a_up_ciph_res(struct msc_a *msc_a, bool success, const char *imeisv);
bool msc_a_is_accepted(const struct msc_a *msc_a);
bool msc_a_is_establishing_auth_ciph(const struct msc_a *msc_a);
int msc_a_ensure_cn_local_rtp(struct msc_a *msc_a, struct gsm_trans *cc_trans);
int msc_a_try_call_assignment(struct gsm_trans *cc_trans);
void msc_a_tx_assignment_cmd(struct msc_a *msc_a);
const char *msc_a_cm_service_type_to_use(struct msc_a *msc_a, enum osmo_cm_service_type cm_service_type);
void msc_a_release_cn(struct msc_a *msc_a);
void msc_a_release_mo(struct msc_a *msc_a, enum gsm48_gsm_cause gsm_cause);
int msc_a_rx_vgcs_bss(struct vgcs_bss *bss, struct ran_conn *from_conn, struct msgb *msg);
int msc_a_rx_vgcs_cell(struct vgcs_bss_cell *cell, struct ran_conn *from_conn, struct msgb *msg);
int msc_a_ran_decode_cb(struct osmo_fsm_inst *msc_a_fi, void *data, const struct ran_msg *msg);
int msc_a_vlr_set_cipher_mode(void *_msc_a, bool umts_aka, bool retrieve_imeisv);
struct msgb *msc_a_ran_encode(struct msc_a *msc_a, const struct ran_msg *ran_enc_msg);
void msc_a_update_id(struct msc_a *msc_a);

View File

@ -0,0 +1,17 @@
#pragma once
#define LOG_MSC_A_REMOTE(MSC_A_REMOTE, LEVEL, FMT, ARGS ...) \
LOG_MSC_A_REMOTE_CAT(MSC_A_REMOTE, (MSC_A_REMOTE) ? (MSC_A_REMOTE)->c.ran->log_subsys : DMSC, LEVEL, FMT, ## ARGS)
#define LOG_MSC_A_REMOTE_CAT(MSC_A_REMOTE, SUBSYS, LEVEL, FMT, ARGS ...) \
LOGPFSMSL((MSC_A_REMOTE) ? (MSC_A_REMOTE)->c.fi : NULL, SUBSYS, LEVEL, FMT, ## ARGS)
#define LOG_MSC_A_REMOTE_CAT_SRC(MSC_A_REMOTE, SUBSYS, LEVEL, SRCFILE, LINE, FMT, ARGS ...) \
LOGPFSMSLSRC((MSC_A_REMOTE) ? (MSC_A_REMOTE)->c.fi : NULL, SUBSYS, LEVEL, SRCFILE, LINE, FMT, ## ARGS)
struct msub;
struct ran_infra;
struct msc_a *msc_a_remote_alloc(struct msub *msub, struct ran_infra *ran,
const uint8_t *remote_msc_name, size_t remote_msc_name_len);
int msc_a_remote_assign_handover_number(struct msc_a *msc_a);
struct msc_a *msc_a_remote_find_by_handover_number(const char *handover_number);

View File

@ -1,23 +1,68 @@
#pragma once
#include <osmocom/core/tdef.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/gsm/gsm0808.h>
struct msgb;
struct gsm_network;
struct vlr_subscr;
extern struct osmo_tdef_group msc_tdef_group[];
extern struct osmo_tdef msc_tdefs_vlr[];
#define MSC_HLR_REMOTE_IP_DEFAULT "127.0.0.1"
#define MSC_HLR_REMOTE_PORT_DEFAULT OSMO_GSUP_PORT
/* TS 48.008 DLCI containing DCCH/ACCH + SAPI */
#define OMSC_LINKID_CB(__msgb) (__msgb)->cb[3]
enum nsap_addr_enc {
NSAP_ADDR_ENC_X213,
NSAP_ADDR_ENC_V4RAW,
};
#define MAX_A5_KEY_LEN (128/8)
struct geran_encr {
/*! alg_id is in encoded format:
* alg_id == 1 means A5/0 i.e. no encryption, alg_id == 4 means A5/3.
* alg_id == 0 means no such IE was present. */
uint8_t alg_id;
uint8_t key_len;
uint8_t key[MAX_A5_KEY_LEN];
bool kc128_present;
uint8_t kc128[MAX_A5_KEY_LEN];
};
enum complete_layer3_type {
COMPLETE_LAYER3_NONE,
COMPLETE_LAYER3_LU,
COMPLETE_LAYER3_CM_SERVICE_REQ,
COMPLETE_LAYER3_PAGING_RESP,
COMPLETE_LAYER3_CM_RE_ESTABLISH_REQ,
};
extern const struct value_string complete_layer3_type_names[];
static inline const char *complete_layer3_type_name(enum complete_layer3_type val)
{
return get_value_string(complete_layer3_type_names, val);
}
struct cell_ids_entry {
struct llist_head entry;
struct gsm0808_cell_id_list2 cell_ids;
};
typedef int (*mncc_recv_cb_t)(struct gsm_network *, struct msgb *);
struct gsm_network *gsm_network_init(void *ctx, mncc_recv_cb_t mncc_recv);
void gsm_network_set_mncc_sock_path(struct gsm_network *net, const char *mncc_sock_path);
extern const struct vlr_ops msc_vlr_ops;
int msc_vlr_alloc(struct gsm_network *net);
int msc_vlr_start(struct gsm_network *net);
int msc_gsup_client_start(struct gsm_network *net);
void msc_stop_paging(struct vlr_subscr *vsub);
uint32_t msc_cc_next_outgoing_callref();

View File

@ -0,0 +1,104 @@
/* MSC Handover API */
/*
* (C) 2019 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* SPDX-License-Identifier: AGPL-3.0+
*
* Author: Neels Hofmeyr
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/core/sockaddr_str.h>
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/msc/neighbor_ident.h>
#include <osmocom/msc/ran_msg.h>
#include <osmocom/msc/mncc_call.h>
#include <osmocom/msc/sdp_msg.h>
struct gsm0808_handover_required;
struct msc_a;
struct ran_dec_handover_required;
#define LOG_HO(msc_a, level, fmt, args...) \
LOGPFSML((msc_a)? ((msc_a)->ho.fi ? : (msc_a)->c.fi) : NULL, \
level, "%s" fmt, (msc_a->ho.fi ? "" : "HO: "), ##args)
enum msc_ho_fsm_state {
MSC_HO_ST_REQUIRED,
MSC_HO_ST_WAIT_REQUEST_ACK,
MSC_HO_ST_WAIT_COMPLETE,
};
enum msc_ho_fsm_event {
MSC_HO_EV_RX_REQUEST_ACK,
MSC_HO_EV_RX_DETECT,
MSC_HO_EV_RX_COMPLETE,
MSC_HO_EV_RX_FAILURE,
MSC_HO_EV_MNCC_FORWARDING_COMPLETE,
MSC_HO_EV_MNCC_FORWARDING_FAILED,
};
struct msc_ho_state {
struct osmo_fsm_inst *fi;
struct ran_handover_required info;
unsigned int next_cil_idx;
bool subsequent_ho;
bool ready_to_switch_rtp;
bool rtp_switched_to_new_cell;
struct {
enum osmo_rat_type ran_type;
struct gsm0808_cell_id cid;
struct osmo_cell_global_id cgi;
enum msc_neighbor_type type;
union {
struct ran_peer *ran_peer;
const char *msc_ipa_name;
};
/* The RTP address from Handover Request Acknowledge.
* Might be from AoIP Transport Layer Address from a BSC RAN peer,
* or from MNCC forwarding for inter-MSC handover. */
struct osmo_sockaddr_str ran_remote_rtp;
/* The codec from Handover Request Acknowledge. */
bool codec_present;
struct gsm0808_speech_codec codec;
/* Inter-MSC voice forwarding via MNCC, to the remote MSC. The Prepare Handover Response sent us the
* Handover Number the remote MSC assigned. This is a call to that Handover Number, via PBX.
* (NULL if not an inter-MSC Handover) */
struct mncc_call *mncc_forwarding_to_remote_ran;
} new_cell;
struct {
/* Saved RTP IP:port and codec in case we need to roll back */
struct osmo_sockaddr_str ran_remote_rtp;
struct sdp_audio_codecs codecs;
} old_cell;
};
void msc_ho_start(struct msc_a *msc_a, const struct ran_handover_required *ho_req);
enum msc_neighbor_type msc_ho_find_target_cell(struct msc_a *msc_a, const struct gsm0808_cell_id *cid,
const struct neighbor_ident_entry **remote_msc,
struct ran_peer **ran_peer_from_neighbor_ident,
struct ran_peer **ran_peer_from_seen_cells);

View File

@ -0,0 +1,46 @@
#pragma once
#include <osmocom/core/utils.h>
#include <osmocom/gsm/mncc.h>
#include <osmocom/msc/msc_roles.h>
struct ran_infra;
struct mncc_call;
#define LOG_MSC_I(MSC_I, LEVEL, FMT, ARGS ...) \
LOG_MSC_I_CAT(MSC_I, (MSC_I) ? (MSC_I)->c.ran->log_subsys : DMSC, LEVEL, FMT, ## ARGS)
#define LOG_MSC_I_CAT(MSC_I, SUBSYS, LEVEL, FMT, ARGS ...) \
LOGPFSMSL((MSC_I) ? (MSC_I)->c.fi : NULL, SUBSYS, LEVEL, FMT, ## ARGS)
#define LOG_MSC_I_CAT_SRC(MSC_I, SUBSYS, LEVEL, SRCFILE, LINE, FMT, ARGS ...) \
LOGPFSMSLSRC((MSC_I) ? (MSC_I)->c.fi : NULL, SUBSYS, LEVEL, SRCFILE, LINE, FMT, ## ARGS)
struct msc_i {
/* struct msc_role_common must remain at start */
struct msc_role_common c;
struct ran_conn *ran_conn;
struct {
struct call_leg *call_leg;
struct mncc_call *mncc_forwarding_to_remote_cn;
} inter_msc;
};
osmo_static_assert(offsetof(struct msc_i, c) == 0, msc_role_common_first_member_of_msc_i);
enum msc_i_state {
MSC_I_ST_READY,
MSC_I_ST_CLEARING,
MSC_I_ST_CLEARED,
};
struct msc_i *msc_i_alloc(struct msub *msub, struct ran_infra *ran);
void msc_i_set_ran_conn(struct msc_i *msc_i, struct ran_conn *ran_conn);
void msc_i_clear(struct msc_i *msc_i);
void msc_i_cleared(struct msc_i *msc_i);
int msc_i_down_l2(struct msc_i *msc_i, struct msgb *l2);
struct gsm_network *msc_i_net(const struct msc_i *msc_i);
struct vlr_subscr *msc_i_vsub(const struct msc_i *msc_i);

View File

@ -0,0 +1,14 @@
#pragma once
#define LOG_MSC_I_REMOTE(MSC_I_REMOTE, LEVEL, FMT, ARGS ...) \
LOG_MSC_I_REMOTE_CAT(MSC_I_REMOTE, (MSC_I_REMOTE) ? (MSC_I_REMOTE)->c.ran->log_subsys : DMSC, LEVEL, FMT, ## ARGS)
#define LOG_MSC_I_REMOTE_CAT(MSC_I_REMOTE, SUBSYS, LEVEL, FMT, ARGS ...) \
LOGPFSMSL((MSC_I_REMOTE) ? (MSC_I_REMOTE)->c.fi : NULL, SUBSYS, LEVEL, FMT, ## ARGS)
#define LOG_MSC_I_REMOTE_CAT_SRC(MSC_I_REMOTE, SUBSYS, LEVEL, SRCFILE, LINE, FMT, ARGS ...) \
LOGPFSMSLSRC((MSC_I_REMOTE) ? (MSC_I_REMOTE)->c.fi : NULL, SUBSYS, LEVEL, SRCFILE, LINE, FMT, ## ARGS)
struct msub;
struct ran_infra;
struct e_link;
struct msc_i *msc_i_remote_alloc(struct msub *msub, struct ran_infra *ran, struct e_link *e);

View File

@ -1,39 +0,0 @@
#pragma once
#include <osmocom/core/msgb.h>
#include <osmocom/msc/gsm_data.h>
#include <osmocom/msc/transaction.h>
/* These are the interfaces of the MSC layer towards (from?) the BSC and RNC,
* i.e. in the direction towards the mobile device (MS aka UE).
*
* 2G will use the A-interface,
* 3G aka UMTS will use the Iu-interface (for the MSC, it's IuCS).
*
* To allow linking parts of the MSC code without having to include entire
* infrastructures of external libraries, the core transmitting and receiving
* functions are left unimplemented. For example, a unit test does not need to
* link against external ASN1 libraries if it is never going to encode actual
* outgoing messages. It is up to each building scope to implement real world
* functions or to plug mere dummy implementations.
*
* For example, msc_tx_dtap(conn, msg), depending on conn->via_iface, will call
* either iu_tx() or a_tx() [note: at time of writing, the A-interface is not
* yet implemented]. When you try to link against libmsc, you will find that
* the compiler complains about an undefined reference to iu_tx(). If you,
* however, link against libiu as well as the osmo-iuh libs (etc.), iu_tx() is
* available. A unit test may instead simply implement a dummy iu_tx() function
* and not link against osmo-iuh, see tests/libiudummy/.
*/
/* Each main linkage must implement this function (see comment above). */
extern int iu_tx(struct msgb *msg, uint8_t sapi);
int msc_tx_dtap(struct ran_conn *conn,
struct msgb *msg);
int msc_gsm48_tx_mm_serv_ack(struct ran_conn *conn);
int msc_gsm48_tx_mm_serv_rej(struct ran_conn *conn,
enum gsm48_reject_value value);
int msc_tx_common_id(struct ran_conn *conn);

View File

@ -1,65 +0,0 @@
/* (C) 2017 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/msc/gsm_data.h>
struct ran_conn;
/* MGCP state handler context. This context information stores all information
* to handle the direction of the RTP streams via MGCP. There is one instance
* of this context struct per RAN connection.
* (see also struct ran_conn) */
struct mgcp_ctx {
/* FSM instance, which handles the connection switching procedure */
struct osmo_fsm_inst *fsm;
/* RTP endpoint string. This string identifies the endpoint
* on the MGW on which the RAN and CN connection is created. This
* endpoint number is assigned by the MGW. */
char rtp_endpoint[MGCP_ENDPOINT_MAXLEN];
/* Call id of the current call. Will be derived from the callref
* of the transaction that is valid during the first CRCX. (The
* callref may change throughout the call) */
unsigned int call_id;
/* Set to true, when the context information is no longer needed */
bool free_ctx;
/* RTP connection identifiers */
char conn_id_ran[MGCP_CONN_ID_LENGTH];
char conn_id_cn[MGCP_CONN_ID_LENGTH];
/* Copy of the pointer and the data with context information
* needed to process the AoIP and MGCP requests (system data) */
struct mgcp_client *mgcp;
struct gsm_trans *trans;
mgcp_trans_id_t mgw_pending_trans;
};
int msc_mgcp_try_call_assignment(struct gsm_trans *trans);
int msc_mgcp_call_assignment(struct gsm_trans *trans);
int msc_mgcp_ass_complete(struct ran_conn *conn, uint16_t port, char *addr);
int msc_mgcp_ass_fail(struct ran_conn *conn);
int msc_mgcp_call_complete(struct gsm_trans *trans, uint16_t port, char *addr);
int msc_mgcp_call_release(struct gsm_trans *trans);

View File

@ -0,0 +1,386 @@
#pragma once
#include <osmocom/core/fsm.h>
#include <osmocom/core/utils.h>
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/gsm/gsup.h>
#include <osmocom/msc/msc_common.h>
#include <osmocom/msc/ran_infra.h>
/* Each subscriber connection is managed by different roles, as described in 3GPP TS 49.008 '4.3 Roles of MSC-A, MSC-I
* and MSC-T':
*
* MSC-A: subscriber management and control of all transactions (CC, SMS, USSD,...)
* MSC-I: "internal": the actual BSSMAP link to the BSS, or RANAP link to the RNC.
* MSC-T: "transitory": a new pending RAN link to a BSS or RNC, while handover is in progress.
* MSC-T becomes the new MSC-I once handover ends successfully.
*
* Without inter-MSC handover involved, all of the roles are managed by a single MSC instance. During inter-MSC
* handover negotiation, an MSC-T is set up at a remote MSC while MSC-A remains in the original MSC, and when handover
* concludes successfully, the remote MSC-T becomes the new remote MSC-I, replacing the local MSC-I role.
*
* Furthermore, the 3GPP specs use the following terms for naming MSC locations: MSC-A, MSC-B and MSC-B', as well as BSS
* or BSS-A, BSS-B and BSS-B':
*
* MSC-A: the first MSC the subscriber connected to.
* MSC-B: a remote MSC (if any).
* MSC-B': another remote MSC (if any, during Subsequent Handover).
*
* The full role assignments are spelled out in 3GPP TS 29.002.
*
* In Osmocom, the MAP protocol spoken between the MSCs is modeled using GSUP instead.
*
* Here are some diagrams of the lifecycle of a single subscriber's MSC-A,-I,-T roles at the locations MSC-A, MSC-B and
* MSC-B'.
*
* Initially:
*
* [MSC-A]
* BSS <-> MSC-I
*
* Then during inter-MSC handover negotiation:
*
* [MSC-A] <-MAP-> MSC-B
* BSS <-> MSC-I MSC-T <-> new BSS
*
* and when successful:
*
* [MSC-A] <-MAP-> MSC-B
* MSC-I <-> BSS
*
* Additional subsequent handover:
*
* [MSC-A] <-MAP-> MSC-B
* ^ MSC-I <-> BSS
* |
* +-------MAP-> MSC-B'
* MSC-T <-> new BSS
*
* (Here, quote, MSC-A "shall act as the target BSS towards the MSC-I and as the MSC towards the MSC-T.")
* and when successful:
*
* [MSC-A]
* ^
* |
* +-------MAP-> MSC-B
* MSC-I <-> BSS
*
* Subsequent handover back to the original MSC:
*
* [MSC-A] <-MAP-> MSC-B
* new BSS <-> MSC-T MSC-I <-> BSS
*
* and then
* [MSC-A]
* BSS <-> MSC-I
*
*
* Inter-BSC Handover is just a special case of inter-MSC Handover, where the same MSC-A takes on both MSC-I and MSC-T
* roles:
*
* [MSC-A]
* BSS <-> MSC-I
* new BSS <-> MSC-T
*
* The mechanism to take on different roles is implemented by different FSM instances. Each FSM kind has one
* implementation that acts locally, and another implementation to forward to a remote MSC. For example, in this
* scenario:
*
* [MSC-A] <-MAP-> MSC-B
* MSC-I <-> BSS
*
* the implementation is
*
* [MSC-A-----------------] [MSC-B-----------------]
* msc_a <-> msc_i_REMOTE <---GSUP---> msc_a_REMOTE <-> msc_i <--BSSMAP--> [BSS]
*
* MSC-A has a locally acting msc_a FSM implementation. The msc_i FSM implementation at MSC-A receives signals from the
* msc_a FSM and "merely" sends the MAP instructions to MSC-B.
*
* At MSC-B, in turn, the msc_a FSM's "remote" implementation receives the MAP messages and dispatches according events
* to the MSC-B's local msc_i FSM instance, which is implemented to directly act towards the BSS.
*
* To implement single-MSC operation, we have the separate MSC roles' local implementations on the same MSC instance
* instead of forwarding.
*
*
* Use of MAP procedures on GSUP towards HLR:
*
* The MSC <-> VLR communication does still happen locally in the MSC-A only. In other words, there may be MAP message
* handling between the MSCs (in the form of GSUP), but no MAP to talk to our internal VLR.
*
* From the VLR to the HLR, though, we again use GSUP for subscriber related HLR operations such as LU requesting and
* retrieving auth tokens.
*
* To complete the picture, the MSC-A <--GSUP--> MSC-B forwarding happens over the same GSUP connection
* as the VLR <--GSUP--> HLR link:
*
* OsmoMSC
* MSC-A <----------E-interface--->+--GSUP--> [IPA routing] ----E--> MSC-B
* ^ ^ (in osmo-hlr) \
* | (internal API) / \--D--> HLR
* v /
* VLR <------------D-interface-/
*/
struct inter_msc_link;
struct ran_conn;
enum msc_role {
MSC_ROLE_A,
MSC_ROLE_I,
MSC_ROLE_T,
MSC_ROLES_COUNT
};
extern const struct value_string msc_role_names[];
static inline const char *msc_role_name(enum msc_role role)
{ return get_value_string(msc_role_names, role); }
enum msc_common_events {
/* Explicitly start with 0 (first real event will be -1 + 1 = 0). */
OFFSET_MSC_COMMON_EV = -1,
MSC_REMOTE_EV_RX_GSUP,
MSC_EV_CALL_LEG_RTP_LOCAL_ADDR_AVAILABLE,
MSC_EV_CALL_LEG_RTP_COMPLETE,
MSC_EV_CALL_LEG_TERM,
/* MNCC has told us to RTP_CREATE, but local RTP port has not yet been set up.
* The MSC role should respond by calling mncc_set_rtp_stream() */
MSC_MNCC_EV_NEED_LOCAL_RTP,
MSC_MNCC_EV_CALL_PROCEEDING,
MSC_MNCC_EV_CALL_COMPLETE,
MSC_MNCC_EV_CALL_ENDED,
LAST_MSC_COMMON_EV,
};
/* The events that the msc_a_local and msc_a_remote FSM implementations can receive,
* according to specifications. Not all of these are necessarily implemented. */
enum msc_a_events {
OFFSET_MSC_A_EV = LAST_MSC_COMMON_EV - 1,
/* Establishing Layer 3 happens only at MSC-A (all-local MSC). To distinguish from the inter-MSC DTAP
* forwarding, keep this as a separate event. */
MSC_A_EV_FROM_I_COMPLETE_LAYER_3,
/* In inter-MSC situations, DTAP is forwarded transparently in AN-APDU IEs (formerly named
* BSS-APDU); see
* - 3GPP TS 49.008 4.2 'Transfer of DTAP and BSSMAP layer 3 messages on the * E-interface',
* - 3GPP TS 29.010 4.5.4 'BSSAP Messages transfer on E-Interface',
* - 3GPP TS 29.002 8.4.3 MAP_PROCESS_ACCESS_SIGNALLING service, 8.4.4 MAP_FORWARD_ACCESS_SIGNALLING service.
*
* MSC-B ---DTAP--> MSC-A MAP PROCESS ACCESS SIGNALLING request
* MSC-B <--DTAP--- MSC-A MAP FORWARD ACCESS SIGNALLING request
* (where neither will receive a "response")
*
* See 3GPP TS 49.008 6. 'BSSMAP messages transferred on the E-interface'.
* Depending on the RAN, the AN-APDU contains a BSSMAP or a RANAP encoded message.
* MSC-I to MSC-A:
* - Managing attach to one BSC+MSC:
* - CLASSMARK_UPDATE,
* - CIPHER_MODE_COMPLETE,
* - CIPHER_MODE_REJECT,
* - ASSIGNMENT_COMPLETE,
* - ASSIGNMENT_FAILURE,
* - CLEAR_REQUEST,
* - Handover related messages:
* - HANDOVER_REQUEST,
* - HANDOVER_PERFORMED,
* - HANDOVER_FAILURE,
* - Messages we don't need/support yet:
* - CHANNEL_MODIFY_REQUEST (MSC assisted codec changing handover),
* - SAPI_N_REJECT,
* - CONFUSION,
* - BSS_INVOKE_TRACE,
* - QUEUING_INDICATION,
* - PERFORM_LOCATION_REQUEST (*not* related to a Location Updating, but about passing the MS's geological
* position)
* - PERFORM_LOCATION_ABORT,
* - PERFORM_LOCATION_RESPONSE,
* - CONNECTION_ORIENTED_INFORMATION is listed in 48.008 3.2.1.70 as "(void)",
*/
MSC_A_EV_FROM_I_PROCESS_ACCESS_SIGNALLING_REQUEST,
MSC_A_EV_FROM_I_PREPARE_SUBSEQUENT_HANDOVER_REQUEST,
/* See 3GPP TS 29.002 8.4.2 MAP_SEND_END_SIGNAL service. */
MSC_A_EV_FROM_I_SEND_END_SIGNAL_REQUEST,
/* These BSSMAP messages are relevant for MSC-T -> MSC-A, i.e. from the transitory during inter-MSC handover:
*
* - Handover related messages:
* - HANDOVER_REQUEST_ACKNOWLEDGE,
* - HANDOVER_COMPLETE,
* - HANDOVER_FAILURE,
* - HANDOVER_DETECT,
* - CLEAR_REQUEST,
* - Messages we don't need/support yet:
* - CONFUSION,
* - QUEUING_INDICATION,
*/
MSC_A_EV_FROM_T_PROCESS_ACCESS_SIGNALLING_REQUEST,
/* Essentially the HO Request Ack. 3GPP TS 29.002 8.4.1 MAP_PREPARE_HANDOVER service. */
MSC_A_EV_FROM_T_PREPARE_HANDOVER_RESPONSE,
MSC_A_EV_FROM_T_PREPARE_HANDOVER_FAILURE,
/* Done establishing the radio link to the MS, for Handover.
* See 3GPP TS 29.002 8.4.2 MAP_SEND_END_SIGNAL service.
* Not to be confused with the MSC_I_EV_FROM_A_SEND_END_SIGNAL_RESPONSE that tells MSC-B to release. */
MSC_A_EV_FROM_T_SEND_END_SIGNAL_REQUEST,
/* gsm_04_08.c has successfully received a valid Complete Layer 3 message, i.e. Location Updating, CM Service
* Request, Paging Response or IMSI Detach. */
MSC_A_EV_COMPLETE_LAYER_3_OK,
/* Received a Classmark Update -- during GERAN ciphering, msc_a may have to wait for Classmark information to
* determine supported ciphers. */
MSC_A_EV_CLASSMARK_UPDATE,
/* LU or Process Access FSM have determined that the peer has verified its authenticity. */
MSC_A_EV_AUTHENTICATED,
/* A valid request is starting to be processed on the connection. Upon this event, msc_a moves from
* MSC_A_ST_AUTHENTICATED to MSC_A_ST_COMMUNICATING, and enters the only state without an expiry timeout. */
MSC_A_EV_TRANSACTION_ACCEPTED,
/* MSC originated close request, e.g. all done, failed authentication, ... */
MSC_A_EV_CN_CLOSE,
/* Subscriber originated close request */
MSC_A_EV_MO_CLOSE,
/* msc_a->use_count has reached a total of zero. */
MSC_A_EV_UNUSED,
MSC_A_EV_HANDOVER_REQUIRED,
MSC_A_EV_HANDOVER_END,
/* indicates nr of MSC_A events, keep this as last enum value */
LAST_MSC_A_EV
};
osmo_static_assert(LAST_MSC_A_EV <= 32, not_too_many_msc_a_events);
extern const struct value_string msc_a_fsm_event_names[];
enum msc_from_ran_events {
OFFSET_MSC_EV_FROM_RAN = LAST_MSC_COMMON_EV - 1,
MSC_EV_FROM_RAN_COMPLETE_LAYER_3,
/* A BSSMAP/RANAP message came in on the RAN conn. */
MSC_EV_FROM_RAN_UP_L2,
/* The RAN connection is gone, or busy going. */
MSC_EV_FROM_RAN_CONN_RELEASED,
LAST_MSC_EV_FROM_RAN
};
/* The events that the msc_i_local and msc_i_remote FSM implementations can receive.
* The MSC-I can also receive all msc_common_events and msc_from_ran_events. */
enum msc_i_events {
OFFSET_E_MSC_I = LAST_MSC_EV_FROM_RAN - 1,
/* BSSMAP/RANAP comes in from MSC-A to be sent out on the RAN conn.
* Depending on the RAN, the AN-APDU contains a BSSMAP or a RANAP encoded message.
* Relevant BSSMAP procedures, see 3GPP TS 49.008 6. 'BSSMAP messages transferred on the E-interface':
* - Managing attach to one BSC+MSC:
* - CLASSMARK_REQUEST,
* - CIPHER_MODE_COMMAND,
* - COMMON_ID,
* - ASSIGNMENT_REQUEST,
* - Handover related messages:
* - HANDOVER_REQUEST_ACKNOWLEDGE,
* - HANDOVER_FAILURE,
* - Messages we don't need/support yet:
* - CONFUSION,
* - MSC_INVOKE_TRACE,
* - QUEUING_INDICATION,
* - LSA_INFORMATION,
* - PERFORM_LOCATION_REQUEST, (*not* related to a Location Updating, but about passing the MS's geological position)
* - PERFORM_LOCATION_ABORT,
* - PERFORM_LOCATION_RESPONSE,
* - CONNECTION_ORIENTED_INFORMATION is listed in 48.008 3.2.1.70 as "(void)"
*/
MSC_I_EV_FROM_A_FORWARD_ACCESS_SIGNALLING_REQUEST,
/* MSC-A tells us to release the RAN connection. */
MSC_I_EV_FROM_A_SEND_END_SIGNAL_RESPONSE,
MSC_I_EV_FROM_A_PREPARE_SUBSEQUENT_HANDOVER_RESULT,
MSC_I_EV_FROM_A_PREPARE_SUBSEQUENT_HANDOVER_ERROR,
LAST_MSC_I_EV
};
osmo_static_assert(LAST_MSC_I_EV <= 32, not_too_many_msc_i_events);
extern const struct value_string msc_i_fsm_event_names[];
/* The events that the msc_t_local and msc_t_remote FSM implementations can receive.
* The MSC-T can also receive all msc_common_events and msc_from_ran_events. */
enum msc_t_events {
/* sufficient would be to use LAST_MSC_EV_FROM_RAN as offset. But while we have enough numbers
* available, it is a good idea to keep MSC-I and MSC-T events separate, to catch errors of
* sending wrong event kinds. */
OFFSET_MSC_T_EV = LAST_MSC_I_EV - 1,
/* BSSMAP/RANAP comes in from MSC-A to be sent out on the RAN conn.
* Relevant BSSMAP procedures, see 3GPP TS 49.008 6. 'BSSMAP messages transferred on the E-interface':
* - Handover related messages:
* - HANDOVER_REQUEST,
* - CLASSMARK_UPDATE, (?)
* - Messages we don't need/support yet:
* - CONFUSION,
* - MSC_INVOKE_TRACE,
* - BSS_INVOKE_TRACE,
*/
MSC_T_EV_FROM_A_PREPARE_HANDOVER_REQUEST,
MSC_T_EV_FROM_A_FORWARD_ACCESS_SIGNALLING_REQUEST,
/* MSC originated close request, e.g. all done, failed handover, ... */
MSC_T_EV_CN_CLOSE,
/* Subscriber originated close request */
MSC_T_EV_MO_CLOSE,
MSC_T_EV_CLEAR_COMPLETE,
LAST_MSC_T_EV
};
osmo_static_assert(LAST_MSC_T_EV <= 32, not_too_many_msc_t_events);
extern const struct value_string msc_t_fsm_event_names[];
/* All MSC role FSM implementations share this at the start of their fi->priv struct.
* See struct msc_a, struct msc_i, struct msc_t in their individual headers. */
struct msc_role_common {
enum msc_role role;
struct osmo_fsm_inst *fi;
/* For a local implementation, this is NULL. Otherwise, this identifies how to reach the remote
* MSC that this "remote" implementation forwards messages to. */
struct e_link *remote_to;
struct msub *msub;
struct gsm_network *net;
struct ran_infra *ran;
};
/* AccessNetworkSignalInfo as in 3GPP TS 29.002. */
struct an_apdu {
/* accessNetworkProtocolId */
enum osmo_gsup_access_network_protocol an_proto;
/* signalInfo */
struct msgb *msg;
/* If this AN-APDU is sent between MSCs, additional information from the E-interface messaging, like the
* Handover Number, will placed/available here. Otherwise may be left NULL. */
const struct osmo_gsup_message *e_info;
};

View File

@ -0,0 +1,60 @@
#pragma once
#include <osmocom/msc/msc_roles.h>
struct ran_conn;
struct ran_infra;
struct ran_peer;
struct gsm_mncc;
struct mncc_call;
#define LOG_MSC_T(MSC_T, LEVEL, FMT, ARGS ...) \
LOG_MSC_T_CAT(MSC_T, (MSC_T) ? (MSC_T)->c.ran->log_subsys : DMSC, LEVEL, FMT, ## ARGS)
#define LOG_MSC_T_CAT(MSC_T, SUBSYS, LEVEL, FMT, ARGS ...) \
LOGPFSMSL((MSC_T) ? (MSC_T)->c.fi : NULL, SUBSYS, LEVEL, FMT, ## ARGS)
#define LOG_MSC_T_CAT_SRC(MSC_T, SUBSYS, LEVEL, SRCFILE, LINE, FMT, ARGS ...) \
LOGPFSMSLSRC((MSC_T) ? (MSC_T)->c.fi : NULL, SUBSYS, LEVEL, SRCFILE, LINE, FMT, ## ARGS)
struct msc_t {
/* struct msc_role_common must remain at start */
struct msc_role_common c;
struct ran_conn *ran_conn;
struct {
uint8_t chosen_channel;
uint8_t chosen_encr_alg;
uint8_t chosen_speech_version;
} geran;
struct {
struct an_apdu ho_request;
struct gsm0808_cell_id cell_id_target;
uint32_t call_id;
char handover_number[16]; /* No libosmocore definition for MSISDN_MAXLEN? */
struct call_leg *call_leg;
struct mncc_call *mncc_forwarding_to_remote_cn;
} inter_msc;
struct osmo_gsm48_classmark classmark;
bool ho_success;
bool ho_fail_sent;
};
enum msc_t_state {
MSC_T_ST_PENDING_FIRST_CO_INITIAL_MSG,
MSC_T_ST_WAIT_LOCAL_RTP,
MSC_T_ST_WAIT_HO_REQUEST_ACK,
MSC_T_ST_WAIT_HO_COMPLETE,
};
struct msc_t *msc_t_alloc_without_ran_peer(struct msub *msub, struct ran_infra *ran);
int msc_t_set_ran_peer(struct msc_t *msc_t, struct ran_peer *ran_peer);
struct msc_t *msc_t_alloc(struct msub *msub, struct ran_peer *ran_peer);
int msc_t_down_l2_co(struct msc_t *msc_t, const struct an_apdu *an_apdu, bool initial);
void msc_t_clear(struct msc_t *msc_t);
struct gsm_network *msc_t_net(const struct msc_t *msc_t);
struct vlr_subscr *msc_t_vsub(const struct msc_t *msc_t);
struct mncc_call *msc_t_check_call_to_handover_number(const struct gsm_mncc *msg);

View File

@ -0,0 +1,14 @@
#pragma once
#define LOG_MSC_T_REMOTE(MSC_T_REMOTE, LEVEL, FMT, ARGS ...) \
LOG_MSC_T_REMOTE_CAT(MSC_T_REMOTE, (MSC_T_REMOTE) ? (MSC_T_REMOTE)->c.ran->log_subsys : DMSC, LEVEL, FMT, ## ARGS)
#define LOG_MSC_T_REMOTE_CAT(MSC_T_REMOTE, SUBSYS, LEVEL, FMT, ARGS ...) \
LOGPFSMSL((MSC_T_REMOTE) ? (MSC_T_REMOTE)->c.fi : NULL, SUBSYS, LEVEL, FMT, ## ARGS)
#define LOG_MSC_T_REMOTE_CAT_SRC(MSC_T_REMOTE, SUBSYS, LEVEL, SRCFILE, LINE, FMT, ARGS ...) \
LOGPFSMSLSRC((MSC_T_REMOTE) ? (MSC_T_REMOTE)->c.fi : NULL, SUBSYS, LEVEL, SRCFILE, LINE, FMT, ## ARGS)
struct msub;
struct ran_infra;
struct msc_t *msc_t_remote_alloc(struct msub *msub, struct ran_infra *ran,
const uint8_t *remote_msc_name, size_t remote_msc_name_len);

View File

@ -0,0 +1,228 @@
/* Handle a call via VGCS/VBCS (Voice Group/Broadcast Call Service). */
/*
* (C) 2023 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* SPDX-License-Identifier: AGPL-3.0+
*
* Author: Andreas Eversberg
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <osmocom/msc/transaction.h>
#define GSM44068_ALLOC_SIZE 2048
#define GSM44068_ALLOC_HEADROOM 256
static inline struct msgb *gsm44068_msgb_alloc_name(const char *name)
{
return msgb_alloc_headroom(GSM44068_ALLOC_SIZE, GSM44068_ALLOC_HEADROOM, name);
}
/* VGCS/VBS "call control" connection to each BSS */
struct vgcs_bss {
struct llist_head list; /* List entry */
struct llist_head cell_list; /* List of cells */
struct gsm_trans *trans; /* Back pointer to transaction */
struct osmo_fsm_inst *fi; /* State machine of each BSS */
struct ran_conn *conn; /* RAN ("SCCP") connection */
enum trans_type trans_type; /* Transaction type */
uint32_t callref; /* Callref */
int pc; /* Point code for debug purpose */
};
/* VGCS/VBS "resource control" connection to each cell in BSS */
struct vgcs_bss_cell {
struct llist_head list_bss; /* List entry in vgcs_bss */
struct llist_head list_mgw; /* List entry in MGW endpoint */
struct vgcs_bss *bss; /* Back pointer to vgcs_bss */
struct vgcs_mgw_ep *mgw; /* Back pointer to vgcs_mgw_ep */
struct osmo_fsm_inst *fi; /* State machine of each cell */
int cell_id; /* Id of cell (BTS) to use */
struct ran_conn *conn; /* RAN ("SCCP") connection */
enum trans_type trans_type; /* Transaction type */
uint32_t callref; /* Callref */
int call_id; /* Id of call (used for MGW connections) */
int pc; /* Point code for debug purpose */
bool assigned; /* Flags if assignment is complete */
struct rtp_stream *rtps; /* MGW connection process */
};
/* VGCS/VBS MGW endpoint for each call */
struct vgcs_mgw_ep {
struct llist_head cell_list; /* List of cells with connections */
struct llist_head list; /* List entry */
struct osmo_fsm_inst *fi; /* State machine of each cell */
struct osmo_mgcpc_ep *mgw_ep; /* MGW endpoint */
};
/* Events for the GCC/BCC state machine.
* There is no primitive definition like MNGCC-* oder MNBCC-* in the standard. */
enum vgcs_gcc_fsm_event {
/* The network sets up a call. */
VGCS_GCC_EV_NET_SETUP,
/* The network requests termination. */
VGCS_GCC_EV_NET_TERM,
/* The user sets up a call. */
VGCS_GCC_EV_USER_SETUP,
/* The user requests termination. */
VGCS_GCC_EV_USER_TERM,
/* BSS completed call establishment (all BSCs) */
VGCS_GCC_EV_BSS_ESTABLISHED,
/* Assignment was completed. */
VGCS_GCC_EV_BSS_ASSIGN_CPL,
/* Assignment failed. */
VGCS_GCC_EV_BSS_ASSIGN_FAIL,
/* BSS released call establishment (all BSCs) */
VGCS_GCC_EV_BSS_RELEASED,
/* Inactivity timeout */
VGCS_GCC_EV_TIMEOUT,
};
/* 3GPP TS 44.068 6.1.2.2 States of GCC/BCC */
enum vgcs_gcc_fsm_state {
/* No call. Initial state when instance is created. */
VGCS_GCC_ST_N0_NULL = 0,
/* An MS wants to establish a call. */
VGCS_GCC_ST_N1_CALL_INITIATED,
/* Call established in at least one cell. */
VGCS_GCC_ST_N2_CALL_ACTIVE,
/* Channel activation is requested, CONNECT already sent to MS. */
VGCS_GCC_ST_N3_CALL_EST_PROC,
/* Call termination is requested, waiting for all cells to confirm. */
VGCS_GCC_ST_N4_TERMINATION_REQ,
};
const char *vgcs_bcc_gcc_state_name(struct osmo_fsm_inst *fi);
/* Events for the VGCS/VBS "call control" state machine */
enum vgcs_bss_fsm_event {
/* Start a VGCS/VBS call using VGCS/VBS SETUP message */
VGCS_BSS_EV_SETUP,
/* VGCS/VBS SETUP ACK is received */
VGCS_BSS_EV_SETUP_ACK,
/* VGCS/VBS SETUP REFUSE is received */
VGCS_BSS_EV_SETUP_REFUSE,
/* VGCS/VBS ASSIGNMENT complete or failed */
VGCS_BSS_EV_ACTIVE_OR_FAIL,
/* Talker request */
VGCS_BSS_EV_UL_REQUEST,
/* Talker established uplink */
VGCS_BSS_EV_UL_REQUEST_CNF,
/* Talker send app data */
VGCS_BSS_EV_UL_APP_DATA,
/* Talker send signaling data */
VGCS_BSS_EV_BSS_DTAP,
/* Talker becomes listener */
VGCS_BSS_EV_UL_RELEASE,
/* Release channel towards BSS */
VGCS_BSS_EV_CLEAR,
/* Channel closed from BSS */
VGCS_BSS_EV_CLOSE,
/* Release is complete */
VGCS_BSS_EV_RELEASED,
};
/* States of the VGCS/VBS "call control" state machine */
enum vgcs_bss_fsm_state {
/* No call. Initial state when instance is created. */
VGCS_BSS_ST_NULL = 0,
/* VGCS/VBS SETUP is sent towards BSC */
VGCS_BSS_ST_SETUP,
/* VGCS/VBS ASSIGNMENT REQUEST is sent towards BSC */
VGCS_BSS_ST_ASSIGNMENT,
/* VGCS/VBS is establised */
VGCS_BSS_ST_ACTIVE,
/* CLEAR COMMAND was sent */
VGCS_BSS_ST_RELEASE,
};
/* Events for the VGCS/VBS "resource control" state machine */
enum vgcs_cell_fsm_event {
/* RTP stream gone */
VGCS_CELL_EV_RTP_STREAM_GONE,
/* RTP stream remote addr available */
VGCS_CELL_EV_RTP_STREAM_ADDR_AVAILABLE,
/* RTP stream established */
VGCS_CELL_EV_RTP_STREAM_ESTABLISHED,
/* Start a VGCS/VBS channel using VGCS/VBS ASSIGNMENT message */
VGCS_CELL_EV_ASSIGN,
/* VGCS/VBS ASSIGNMENT RESULT is received */
VGCS_CELL_EV_ASSIGN_RES,
/* VGCS/VBS ASSIGNMENT FAILURE is received */
VGCS_CELL_EV_ASSIGN_FAIL,
/* Release channel towards BSS */
VGCS_CELL_EV_CLEAR,
/* Channel closed from BSS */
VGCS_CELL_EV_CLOSE,
/* Release is complete */
VGCS_CELL_EV_RELEASED,
};
/* States of the VGCS/VBS "resource control" state machine */
enum vgcs_cell_fsm_state {
/* No call. Initial state when instance is created. */
VGCS_CELL_ST_NULL = 0,
/* VGCS/VBS ASSIGNMENT REQUEST is sent towards BSC */
VGCS_CELL_ST_ASSIGNMENT,
/* Channel is establised */
VGCS_CELL_ST_ACTIVE,
/* CLEAR COMMAND was sent */
VGCS_CELL_ST_RELEASE,
};
/* Events for the VGCS/VBS MGW endpoint state machine */
enum vgcs_mgw_ep_fsm_event {
/* MGW endpoint gone */
VGCS_MGW_EP_EV_FREE,
/* Destroy MGW endpoint */
VGCS_MGW_EP_EV_CLEAR,
};
/* States of the VGCS/VBS MGW endpoint state machine */
enum vgcs_mgw_ep_fsm_state {
VGCS_MGW_EP_ST_NULL = 0,
/* MGW endpoint allocated */
VGCS_MGW_EP_ST_ACTIVE,
};
const char *gsm44068_group_id_string(uint32_t callref);
struct gcr;
int gsm44068_rcv_rr(struct msc_a *msc_a, struct msgb *msg);
int gsm44068_rcv_bcc_gcc(struct msc_a *msc_a, struct gsm_trans *trans, struct msgb *msg);
const char *vgcs_vty_initiate(struct gsm_network *gsmnet, struct gcr *gcr);
const char *vgcs_vty_terminate(struct gsm_network *gsmnet, struct gcr *gcr);
void gsm44068_bcc_gcc_trans_free(struct gsm_trans *trans);
void vgcs_vbs_setup_ack(struct vgcs_bss *bss, const struct ran_msg *ran_msg);
void vgcs_vbs_setup_refuse(struct vgcs_bss *bss, const struct ran_msg *ran_msg);
void vgcs_vbs_assign_result(struct vgcs_bss_cell *cell, const struct ran_msg *ran_msg);
void vgcs_vbs_assign_fail(struct vgcs_bss_cell *cell, const struct ran_msg *ran_msg);
void vgcs_vbs_queuing_ind(struct vgcs_bss_cell *cell);
void vgcs_uplink_request(struct vgcs_bss *bss, const struct ran_msg *ran_msg);
void vgcs_uplink_request_cnf(struct vgcs_bss *bss, const struct ran_msg *ran_msg);
void vgcs_app_data(struct vgcs_bss *bss, const struct ran_msg *ran_msg);
void vgcs_bss_dtap(struct vgcs_bss *bss, const struct ran_msg *ran_msg);
void vgcs_uplink_release_ind(struct vgcs_bss *bss, const struct ran_msg *ran_msg);
void vgcs_vbs_assign_status(struct vgcs_bss_cell *cell, const struct ran_msg *ran_msg);
void vgcs_vbs_clear_req_channel(struct vgcs_bss_cell *cell, const struct ran_msg *ran_msg);
void vgcs_vbs_clear_cpl_channel(struct vgcs_bss_cell *cell, const struct ran_msg *ran_msg);
void vgcs_vbs_clear_req(struct vgcs_bss *bss, const struct ran_msg *ran_msg);
void vgcs_vbs_clear_cpl(struct vgcs_bss *bss, const struct ran_msg *ran_msg);
void vgcs_vbs_caller_assign_cpl(struct gsm_trans *trans);
void vgcs_vbs_caller_assign_fail(struct gsm_trans *trans);

View File

@ -0,0 +1,81 @@
#pragma once
#include <osmocom/gsm/gsm48.h>
#include <osmocom/msc/debug.h>
#include <osmocom/msc/msc_roles.h>
struct vlr_subscr;
struct gsm_network;
enum gsm48_gsm_cause;
enum complete_layer3_type;
enum osmo_gsup_access_network_protocol;
#define VSUB_USE_MSUB "active-conn"
struct msub {
struct llist_head entry;
struct osmo_fsm_inst *fi;
struct vlr_subscr *vsub;
/* role = {MSC_ROLE_A, MSC_ROLE_I, MSC_ROLE_T} */
struct osmo_fsm_inst *role[MSC_ROLES_COUNT];
struct gsm_network *net;
};
extern struct llist_head msub_list;
#define LOG_MSUB_CAT_SRC(msub, cat, level, file, line, fmt, args ...) \
LOGPSRC(cat, level, file, line, "(%s) " fmt, msub_name(msub), ## args)
#define LOG_MSUB_CAT(msub, cat, level, fmt, args ...) \
LOGP(cat, level, "msub(%s) " fmt, msub_name(msub), ## args)
#define LOG_MSUB(msub, level, fmt, args ...) \
LOG_MSUB_CAT(msub, DMSC, level, fmt, ## args)
struct msub *msub_alloc(struct gsm_network *net);
#define msub_role_alloc(MSUB, ROLE, FSM, ROLE_STRUCT, RAN) \
(ROLE_STRUCT*)_msub_role_alloc(MSUB, ROLE, FSM, sizeof(ROLE_STRUCT), #ROLE_STRUCT ":" #FSM, RAN)
struct msc_role_common *_msub_role_alloc(struct msub *msub, enum msc_role role, struct osmo_fsm *role_fsm,
size_t struct_size, const char *struct_name, struct ran_infra *ran);
const char *msub_name(const struct msub *msub);
struct msub *msub_for_vsub(const struct vlr_subscr *for_vsub);
void msub_set_role(struct msub *msub, struct osmo_fsm_inst *msc_role);
void msub_remove_role(struct msub *msub, struct osmo_fsm_inst *fi);
struct msc_a *msub_msc_a(const struct msub *msub);
struct msc_i *msub_msc_i(const struct msub *msub);
struct msc_t *msub_msc_t(const struct msub *msub);
struct ran_conn *msub_ran_conn(const struct msub *msub);
const char *msub_ran_conn_name(const struct msub *msub);
int msub_set_vsub(struct msub *msub, struct vlr_subscr *vsub);
struct vlr_subscr *msub_vsub(const struct msub *msub);
struct gsm_network *msub_net(const struct msub *msub);
int msub_role_to_role_event(struct msub *msub, enum msc_role from_role, enum msc_role to_role);
#define msub_role_dispatch(MSUB, TO_ROLE, TO_ROLE_EVENT, AN_APDU) \
_msub_role_dispatch(MSUB, TO_ROLE, TO_ROLE_EVENT, AN_APDU, __FILE__, __LINE__)
int _msub_role_dispatch(struct msub *msub, enum msc_role to_role, uint32_t to_role_event, const struct an_apdu *an_apdu,
const char *file, int line);
int msub_tx_an_apdu(struct msub *msub, enum msc_role from_role, enum msc_role to_role, struct an_apdu *an_apdu);
void msub_update_id_from_mi(struct msub *msub, const struct osmo_mobile_identity *mi);
void msub_update_id(struct msub *msub);
void msub_update_id_for_vsub(struct vlr_subscr *for_vsub);
void msub_pending_cm_service_req_add(struct msub *msub, enum osmo_cm_service_type type);
unsigned int msub_pending_cm_service_req_count(struct msub *msub, enum osmo_cm_service_type type);
void msub_pending_cm_service_req_del(struct msub *msub, enum osmo_cm_service_type type);
void msc_role_forget_conn(struct osmo_fsm_inst *role, struct ran_conn *conn);
struct msgb *msc_role_ran_encode(struct osmo_fsm_inst *role, const struct ran_msg *ran_msg);
int msc_role_ran_decode(struct osmo_fsm_inst *fi, const struct an_apdu *an_apdu,
ran_decode_cb_t decode_cb, void *decode_cb_data);

View File

@ -0,0 +1,68 @@
/* Manage identity of neighboring BSS cells for inter-BSC handover */
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/gsm/gsm0808.h>
#include <osmocom/sigtran/sccp_sap.h>
struct vty;
struct gsm_network;
enum msc_neighbor_type {
MSC_NEIGHBOR_TYPE_NONE = 0,
MSC_NEIGHBOR_TYPE_LOCAL_RAN_PEER,
MSC_NEIGHBOR_TYPE_REMOTE_MSC,
};
struct msc_ipa_name {
char buf[64];
size_t len;
};
int msc_ipa_name_from_str(struct msc_ipa_name *min, const char *name);
int msc_ipa_name_cmp(const struct msc_ipa_name *a, const struct msc_ipa_name *b);
struct neighbor_ident_addr {
enum osmo_rat_type ran_type;
enum msc_neighbor_type type;
union {
char local_ran_peer_pc_str[23];
struct msc_ipa_name remote_msc_ipa_name;
};
};
struct neighbor_ident_entry {
struct llist_head entry;
struct neighbor_ident_addr addr;
/* A list of struct cell_ids_entry. A gsm0808_cell_id_list2 would in principle suffice, but to support
* storing more than 127 cell ids and to allow storing IDs of differing types, have a list of any number of
* gsm0808_cell_id_list2. */
struct llist_head cell_ids;
};
void neighbor_ident_init(struct gsm_network *net);
const char *neighbor_ident_addr_name(const struct neighbor_ident_addr *nia);
const struct neighbor_ident_entry *neighbor_ident_add(struct llist_head *ni_list,
const struct neighbor_ident_addr *nia,
const struct gsm0808_cell_id *cid);
const struct neighbor_ident_entry *neighbor_ident_find_by_cell(const struct llist_head *ni_list,
enum osmo_rat_type ran_type,
const struct gsm0808_cell_id *cell_id);
const struct neighbor_ident_entry *neighbor_ident_find_by_addr(const struct llist_head *ni_list,
const struct neighbor_ident_addr *nia);
void neighbor_ident_del(const struct neighbor_ident_entry *nie);
void neighbor_ident_clear(struct llist_head *ni_list);
void neighbor_ident_vty_init(struct gsm_network *net);
void neighbor_ident_vty_write(struct vty *vty);

View File

@ -0,0 +1,11 @@
#pragma once
enum osmux_usage {
/* MSC won't use Osmux in call legs towards its RAN */
OSMUX_USAGE_OFF = 0,
/* MSC will use Osmux in call legs towards RAN as long as RAN announced support for it */
OSMUX_USAGE_ON = 1,
/* MSC will always use Osmux in call legs towards its RAN, and will
reject calls for RANs which didn't announce support for it */
OSMUX_USAGE_ONLY = 2,
};

View File

@ -0,0 +1,47 @@
#pragma once
#include <osmocom/core/linuxlist.h>
struct msc_a;
struct vlr_subscr;
struct gsm_trans;
/* Modeled after the RANAP PagingCause; translates to enum sgsap_service_ind and BSSMAP Channel Needed (3GPP TS 48.008
* 3.2.2.36) by collapsing e.g. all call related paging causes to SGSAP_SERV_IND_CS_CALL, etc. */
enum paging_cause {
PAGING_CAUSE_CALL_CONVERSATIONAL = 0,
PAGING_CAUSE_CALL_STREAMING,
PAGING_CAUSE_CALL_INTERACTIVE,
PAGING_CAUSE_CALL_BACKGROUND,
PAGING_CAUSE_SIGNALLING_LOW_PRIO,
PAGING_CAUSE_SIGNALLING_HIGH_PRIO,
PAGING_CAUSE_UNSPECIFIED,
};
extern const struct value_string paging_cause_names[];
static inline const char *paging_cause_name(enum paging_cause val)
{ return get_value_string(paging_cause_names, val); }
/* A successful Paging will pass a valid msc_a, an expired paging will pass msc_a == NULL. */
typedef void (* paging_cb_t )(struct msc_a *msc_a, struct gsm_trans *trans);
struct paging_request {
struct llist_head entry;
/* human readable label to be able to log pending request kinds */
const char *label;
enum paging_cause cause;
/* the callback data */
paging_cb_t paging_cb;
struct gsm_trans *trans;
};
struct paging_request *paging_request_start(struct vlr_subscr *vsub, enum paging_cause cause,
paging_cb_t paging_cb, struct gsm_trans *trans,
const char *label);
void paging_request_join_vsub(struct vlr_subscr *keep_vsub, struct vlr_subscr *discarding_vsub);
void paging_request_remove(struct paging_request *pr);
void paging_response(struct msc_a *msc_a);
void paging_expired(struct vlr_subscr *vsub);

View File

@ -3,237 +3,39 @@
#include <stdint.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/core/linuxlist.h>
#define LOG_RAN_CONN(conn, level, fmt, args ...) \
LOG_RAN_CONN_CAT(conn, (conn) ? (conn)->log_subsys : DMSC, level, fmt, ## args)
#define LOG_RAN_CONN_CAT(conn, subsys, level, fmt, args ...) \
LOGPFSMSL((conn)? (conn)->fi : NULL, subsys, level, fmt, ## args)
enum ran_conn_fsm_event {
/* Accepted the initial Complete Layer 3 (starting to evaluate Authentication and Ciphering) */
RAN_CONN_E_COMPLETE_LAYER_3,
/* Received Classmark Update, typically neede for Ciphering Mode Command */
RAN_CONN_E_CLASSMARK_UPDATE,
/* LU or Process Access FSM has determined that this conn is good */
RAN_CONN_E_ACCEPTED,
/* received first reply from MS in "real" CC, SMS, USSD communication */
RAN_CONN_E_COMMUNICATING,
/* Some async action has completed, check again whether all is done */
RAN_CONN_E_RELEASE_WHEN_UNUSED,
/* MS/BTS/BSC originated close request */
RAN_CONN_E_MO_CLOSE,
/* MSC originated close request, e.g. failed authentication */
RAN_CONN_E_CN_CLOSE,
/* The usage count for the conn has reached zero */
RAN_CONN_E_UNUSED,
};
enum ran_conn_fsm_state {
RAN_CONN_S_NEW,
RAN_CONN_S_AUTH_CIPH,
RAN_CONN_S_WAIT_CLASSMARK_UPDATE,
RAN_CONN_S_ACCEPTED,
RAN_CONN_S_COMMUNICATING,
RAN_CONN_S_RELEASING,
RAN_CONN_S_RELEASED,
};
enum integrity_protection_state {
INTEGRITY_PROTECTION_NONE = 0,
INTEGRITY_PROTECTION_IK = 1,
INTEGRITY_PROTECTION_IK_CK = 2,
};
enum complete_layer3_type {
COMPLETE_LAYER3_NONE,
COMPLETE_LAYER3_LU,
COMPLETE_LAYER3_CM_SERVICE_REQ,
COMPLETE_LAYER3_PAGING_RESP,
};
#define MAX_A5_KEY_LEN (128/8)
struct geran_encr {
uint8_t alg_id;
uint8_t key_len;
uint8_t key[MAX_A5_KEY_LEN];
};
extern const struct value_string complete_layer3_type_names[];
static inline const char *complete_layer3_type_name(enum complete_layer3_type val)
{
return get_value_string(complete_layer3_type_names, val);
}
struct gsm_classmark {
bool classmark1_set;
struct gsm48_classmark1 classmark1;
uint8_t classmark2_len;
uint8_t classmark2[3];
uint8_t classmark3_len;
uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be truncated */
};
struct ran_peer;
struct osmo_fsm_inst;
struct msgb;
/* active radio connection of a mobile subscriber */
struct ran_conn {
/* global linked list of ran_conn instances */
/* Entry in sccp_ran_inst->ran_conns */
struct llist_head entry;
/* FSM instance to control the RAN connection's permissions and lifetime. */
struct osmo_fsm_inst *fi;
enum complete_layer3_type complete_layer3_type;
struct ran_peer *ran_peer;
uint32_t sccp_conn_id;
/* usage count. If this drops to zero, we start the release
* towards A/Iu */
uint32_t use_count;
uint32_t use_tokens;
/* MSC role that this RAN connection belongs to. This will be either an msc_i (currently active
* connection) or an msc_t (transitory new connection during Handover).
* Used for usual L3 ran_conn to a subscriber. */
struct osmo_fsm_inst *msc_role;
/* The MS has opened the conn with a CM Service Request, and we shall
* keep it open for an actual request (or until timeout). */
bool received_cm_service_request;
/* libmsc/libvlr subscriber information (if available) */
struct vlr_subscr *vsub;
/* LU expiration handling */
uint8_t expire_timer_stopped;
/* SMS helpers for libmsc */
uint8_t next_rp_ref;
/* Are we part of a special "silent" call */
int silent_call;
/* back pointers */
struct gsm_network *network;
/* connected via 2G or 3G? */
enum osmo_rat_type via_ran;
/* whether to log on DBSSAP, DIUCS, ... */
int log_subsys;
uint16_t lac;
struct geran_encr geran_encr;
/* "Temporary" storage for the case the VLR asked for Cipher Mode Command, but the MSC still
* wants to request a Classmark Update first. */
/* For VGCS/VBS, we have additional N connections to BSS. When receiving messages for a group call peer,
* dispatch to the VGCS management. */
struct {
bool umts_aka;
bool retrieve_imeisv;
} geran_set_cipher_mode;
void *bss;
void *cell;
} vgcs;
/* N(SD) expected in the received frame, per flow (TS 24.007 11.2.3.2.3.2.2) */
uint8_t n_sd_next[4];
struct {
struct mgcp_ctx *mgcp_ctx;
unsigned int mgcp_rtp_endpoint;
uint16_t local_port_ran;
char local_addr_ran[INET_ADDRSTRLEN];
uint16_t remote_port_ran;
char remote_addr_ran[INET_ADDRSTRLEN];
enum mgcp_codecs codec_ran;
uint16_t local_port_cn;
char local_addr_cn[INET_ADDRSTRLEN];
uint16_t remote_port_cn;
char remote_addr_cn[INET_ADDRSTRLEN];
enum mgcp_codecs codec_cn;
} rtp;
/* which Iu-CS connection, if any. */
struct {
struct ranap_ue_conn_ctx *ue_ctx;
uint8_t rab_id;
bool waiting_for_release_complete;
} iu;
struct {
/* A pointer to the SCCP user that handles
* the SCCP connections for this subscriber
* connection */
struct osmo_sccp_user *scu;
/* The address of the BSC that is associated
* with this RAN connection */
struct osmo_sccp_addr bsc_addr;
/* The connection identifier that is used
* to reference the SCCP connection that is
* associated with this RAN connection */
uint32_t conn_id;
bool waiting_for_clear_complete;
} a;
/* Temporary storage for Classmark Information for times when a connection has no VLR subscriber
* associated yet. It will get copied to the VLR subscriber upon msc_vlr_subscr_assoc(). */
struct gsm_classmark temporary_classmark;
bool closing;
};
struct ran_conn *ran_conn_alloc(struct gsm_network *network, enum osmo_rat_type via_ran, uint16_t lac);
void ran_conn_update_id_from_mi(struct ran_conn *conn, const uint8_t *mi, uint8_t mi_len);
void ran_conn_update_id(struct ran_conn *conn);
const char *ran_conn_get_conn_id(struct ran_conn *conn);
void ran_conn_update_id_for_vsub(struct vlr_subscr *for_vsub);
void ran_conn_complete_layer_3(struct ran_conn *conn);
void ran_conn_sapi_n_reject(struct ran_conn *conn, int dlci);
int ran_conn_clear_request(struct ran_conn *conn, uint32_t cause);
void ran_conn_compl_l3(struct ran_conn *conn,
struct msgb *msg, uint16_t chosen_channel);
void ran_conn_dtap(struct ran_conn *conn, struct msgb *msg);
int ran_conn_classmark_request_then_cipher_mode_cmd(struct ran_conn *conn, bool umts_aka,
bool retrieve_imeisv);
int ran_conn_geran_set_cipher_mode(struct ran_conn *conn, bool umts_aka, bool retrieve_imeisv);
void ran_conn_cipher_mode_compl(struct ran_conn *conn, struct msgb *msg, uint8_t alg_id);
void ran_conn_rx_sec_mode_compl(struct ran_conn *conn);
void ran_conn_classmark_chg(struct ran_conn *conn,
const uint8_t *cm2, uint8_t cm2_len,
const uint8_t *cm3, uint8_t cm3_len);
void ran_conn_assign_fail(struct ran_conn *conn, uint8_t cause, uint8_t *rr_cause);
void ran_conn_init(void);
bool ran_conn_is_accepted(const struct ran_conn *conn);
bool ran_conn_is_establishing_auth_ciph(const struct ran_conn *conn);
void ran_conn_communicating(struct ran_conn *conn);
void ran_conn_close(struct ran_conn *conn, uint32_t cause);
void ran_conn_mo_close(struct ran_conn *conn, uint32_t cause);
bool ran_conn_in_release(struct ran_conn *conn);
void ran_conn_rx_bssmap_clear_complete(struct ran_conn *conn);
void ran_conn_rx_iu_release_complete(struct ran_conn *conn);
enum ran_conn_use {
RAN_CONN_USE_UNTRACKED = -1,
RAN_CONN_USE_COMPL_L3,
RAN_CONN_USE_DTAP,
RAN_CONN_USE_AUTH_CIPH,
RAN_CONN_USE_CM_SERVICE,
RAN_CONN_USE_TRANS_CC,
RAN_CONN_USE_TRANS_SMS,
RAN_CONN_USE_TRANS_NC_SS,
RAN_CONN_USE_SILENT_CALL,
RAN_CONN_USE_RELEASE,
};
extern const struct value_string ran_conn_use_names[];
static inline const char *ran_conn_use_name(enum ran_conn_use val)
{ return get_value_string(ran_conn_use_names, val); }
#define ran_conn_get(conn, balance_token) \
_ran_conn_get(conn, balance_token, __FILE__, __LINE__)
#define ran_conn_put(conn, balance_token) \
_ran_conn_put(conn, balance_token, __FILE__, __LINE__)
struct ran_conn * _ran_conn_get(struct ran_conn *conn, enum ran_conn_use balance_token,
const char *file, int line);
void _ran_conn_put(struct ran_conn *conn, enum ran_conn_use balance_token,
const char *file, int line);
bool ran_conn_used_by(struct ran_conn *conn, enum ran_conn_use token);
struct ran_conn *ran_conn_create_incoming(struct ran_peer *ran_peer, uint32_t sccp_conn_id);
struct ran_conn *ran_conn_create_outgoing(struct ran_peer *ran_peer);
const char *ran_conn_name(struct ran_conn *conn);
int ran_conn_down_l2_co(struct ran_conn *conn, struct msgb *l3, bool initial);
void ran_conn_msc_role_gone(struct ran_conn *conn, struct osmo_fsm_inst *msc_role);
void ran_conn_close(struct ran_conn *conn);
void ran_conn_discard(struct ran_conn *conn);

View File

@ -0,0 +1,36 @@
#pragma once
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/gsm/gsup.h>
#include <osmocom/msc/sccp_ran.h>
#include <osmocom/msc/ran_msg.h>
#include <osmocom/msc/sdp_msg.h>
struct osmo_tdef;
extern struct osmo_tdef msc_tdefs_geran[];
extern struct osmo_tdef msc_tdefs_utran[];
extern struct osmo_tdef msc_tdefs_sgs[];
extern const struct value_string an_proto_names[];
static inline const char *an_proto_name(enum osmo_gsup_access_network_protocol val)
{ return get_value_string(an_proto_names, val); }
struct ran_infra {
const enum osmo_rat_type type;
const enum osmo_gsup_access_network_protocol an_proto;
uint32_t ssn;
const int log_subsys;
struct osmo_tdef * const tdefs;
const struct sccp_ran_ops sccp_ran_ops;
const ran_dec_l2_t ran_dec_l2;
const ran_encode_t ran_encode;
struct sccp_ran_inst *sri;
/* To always set up the MGW endpoint facing the RAN side with specific codecs, list those here. Otherwise leave
* empty (to use the result of codecs filtering). This exists for IuCS, to always set the MGW endpoint facing
* RAN to IUFP, to decapsulate the IuUP headers. */
struct sdp_audio_codecs force_mgw_codecs_to_ran;
};
extern struct ran_infra msc_ran_infra[];
extern const int msc_ran_infra_len;

View File

@ -0,0 +1,353 @@
/* API to forward upcoming NAS events, e.g. from BSSAP and RANAP, to be handled by MSC-A or MSC-I. */
/*
* (C) 2019 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
*
* Author: Neels Hofmeyr <neels@hofmeyr.de>
*
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <osmocom/core/utils.h>
#include <osmocom/core/fsm.h>
#include <osmocom/core/sockaddr_str.h>
#include <osmocom/gsm/protocol/gsm_08_08.h>
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/msc/msc_common.h>
struct msgb;
struct osmo_fsm_inst;
#define LOG_RAN_DEC(NAS_DEC, subsys, level, fmt, args...) \
LOGPFSMSL((NAS_DEC)? (NAS_DEC)->caller_fi : NULL, subsys, level, "RAN decode: " fmt, ## args)
#define LOG_RAN_ENC(FI, subsys, level, fmt, args...) \
LOGPFSMSL(FI, subsys, level, "RAN encode: " fmt, ## args)
/* These message types are named after the BSSAP procedures in nas_a.h; most are also used for RANAP procedures of
* similar meaning in nas_iu.h. */
enum ran_msg_type {
RAN_MSG_NONE = 0,
RAN_MSG_COMPL_L3,
RAN_MSG_DTAP,
RAN_MSG_CLEAR_COMMAND,
RAN_MSG_CLEAR_REQUEST,
RAN_MSG_CLEAR_COMPLETE,
RAN_MSG_CLASSMARK_REQUEST,
RAN_MSG_CLASSMARK_UPDATE,
RAN_MSG_CIPHER_MODE_COMMAND,
RAN_MSG_CIPHER_MODE_COMPLETE,
RAN_MSG_CIPHER_MODE_REJECT,
RAN_MSG_COMMON_ID,
RAN_MSG_ASSIGNMENT_COMMAND,
RAN_MSG_ASSIGNMENT_COMPLETE,
RAN_MSG_ASSIGNMENT_FAILURE,
RAN_MSG_SAPI_N_REJECT,
RAN_MSG_LCLS_STATUS,
RAN_MSG_LCLS_BREAK_REQ,
RAN_MSG_HANDOVER_COMMAND,
RAN_MSG_HANDOVER_PERFORMED,
RAN_MSG_HANDOVER_REQUIRED,
RAN_MSG_HANDOVER_REQUIRED_REJECT,
RAN_MSG_HANDOVER_REQUEST,
RAN_MSG_HANDOVER_REQUEST_ACK,
RAN_MSG_HANDOVER_DETECT,
RAN_MSG_HANDOVER_SUCCEEDED,
RAN_MSG_HANDOVER_COMPLETE,
RAN_MSG_HANDOVER_FAILURE,
RAN_MSG_VGCS_VBS_SETUP,
RAN_MSG_VGCS_VBS_SETUP_ACK,
RAN_MSG_VGCS_VBS_SETUP_REFUSE,
RAN_MSG_VGCS_VBS_ASSIGN_REQ,
RAN_MSG_VGCS_VBS_ASSIGN_RES,
RAN_MSG_VGCS_VBS_ASSIGN_FAIL,
RAN_MSG_VGCS_VBS_QUEUING_IND,
RAN_MSG_UPLINK_REQUEST,
RAN_MSG_UPLINK_REQUEST_ACK,
RAN_MSG_UPLINK_REQUEST_CNF,
RAN_MSG_UPLINK_APPLICATION_DATA,
RAN_MSG_UPLINK_RELEASE_IND,
RAN_MSG_UPLINK_REJECT_CMD,
RAN_MSG_UPLINK_RELEASE_CMD,
RAN_MSG_UPLINK_SEIZED_CMD,
RAN_MSG_VGCS_ADDITIONAL_INFO,
RAN_MSG_VGCS_VBS_AREA_CELL_INFO,
RAN_MSG_VGCS_VBS_ASSIGN_STATUS,
RAN_MSG_VGCS_SMS,
RAN_MSG_NOTIFICATION_DATA,
};
extern const struct value_string ran_msg_type_names[];
static inline const char *ran_msg_type_name(enum ran_msg_type val)
{ return get_value_string(ran_msg_type_names, val); }
struct ran_clear_command {
enum gsm0808_cause gsm0808_cause;
bool csfb_ind;
};
struct ran_assignment_command {
const struct osmo_sockaddr_str *cn_rtp;
const struct gsm0808_channel_type *channel_type;
enum nsap_addr_enc rab_assign_addr_enc;
bool osmux_present;
uint8_t osmux_cid;
bool call_id_present;
uint32_t call_id;
struct osmo_lcls *lcls;
bool callref_present;
struct gsm0808_group_callref callref;
};
struct ran_cipher_mode_command {
const struct osmo_auth_vector *vec;
const struct osmo_gsm48_classmark *classmark;
struct {
bool umts_aka;
bool retrieve_imeisv;
uint8_t a5_encryption_mask;
/* out-argument to return the key to the caller, pass NULL if not needed. */
struct geran_encr *chosen_key;
} geran;
struct {
uint8_t uea_encryption_mask;
} utran;
};
struct ran_handover_request {
const char *imsi;
const struct osmo_gsm48_classmark *classmark;
/* A Handover Request on GERAN-A sends separate IEs for
* - permitted algorithms, here composed from the a5_encryption_mask,
* - the key, here taken from chosen_encryption->key iff chosen_encryption is present,
* - the actually chosen algorithm ("Serving"), here taken from chosen_encryption->alg_id.
*/
struct {
struct gsm0808_channel_type *channel_type;
uint8_t a5_encryption_mask;
/*! chosen_encryption->alg_id is in encoded format:
* alg_id == 1 means A5/0 i.e. no encryption, alg_id == 4 means A5/3.
* alg_id == 0 means no such IE was present. */
struct geran_encr *chosen_encryption;
} geran;
struct gsm0808_cell_id cell_id_serving;
struct gsm0808_cell_id cell_id_target;
enum gsm0808_cause bssap_cause;
bool current_channel_type_1_present;
uint8_t current_channel_type_1;
enum gsm0808_permitted_speech speech_version_used;
const uint8_t *old_bss_to_new_bss_info_raw;
uint8_t old_bss_to_new_bss_info_raw_len;
struct osmo_sockaddr_str *rtp_ran_local;
struct gsm0808_speech_codec_list *codec_list_msc_preferred;
bool call_id_present;
uint32_t call_id;
const uint8_t *global_call_reference;
uint8_t global_call_reference_len;
};
struct ran_handover_request_ack {
const uint8_t *rr_ho_command;
uint8_t rr_ho_command_len;
bool chosen_channel_present;
uint8_t chosen_channel;
/*! chosen_encr_alg is in encoded format:
* chosen_encr_alg == 1 means A5/0 i.e. no encryption, chosen_encr_alg == 4 means A5/3.
* chosen_encr_alg == 0 means no such IE was present. */
uint8_t chosen_encr_alg;
/* chosen_speech_version == 0 means "not present" */
enum gsm0808_permitted_speech chosen_speech_version;
struct osmo_sockaddr_str remote_rtp;
bool codec_present;
struct gsm0808_speech_codec codec;
bool codec_with_iuup;
};
struct ran_handover_command {
const uint8_t *rr_ho_command;
uint8_t rr_ho_command_len;
const uint8_t *new_bss_to_old_bss_info_raw;
uint8_t new_bss_to_old_bss_info_raw_len;
};
struct ran_handover_required {
uint16_t cause;
struct gsm0808_cell_id_list2 cil;
bool current_channel_type_1_present;
/*! See gsm0808_chosen_channel() */
uint8_t current_channel_type_1;
enum gsm0808_permitted_speech speech_version_used;
uint8_t *old_bss_to_new_bss_info_raw;
size_t old_bss_to_new_bss_info_raw_len;
};
struct ran_msg {
enum ran_msg_type msg_type;
/* Since different RAN implementations feed these messages, they should place here an implementation specific
* string constant to name the actual message (e.g. "BSSMAP Assignment Complete" vs. "RANAP RAB Assignment
* Response") */
const char *msg_name;
union {
struct {
const struct gsm0808_cell_id *cell_id;
const struct gsm0808_speech_codec_list *codec_list_bss_supported;
struct msgb *msg;
} compl_l3;
struct msgb *dtap;
struct {
enum gsm0808_cause bssap_cause;
#define RAN_MSG_BSSAP_CAUSE_UNSET 0xffff
} clear_request;
struct ran_clear_command clear_command;
struct {
const struct osmo_gsm48_classmark *classmark;
} classmark_update;
struct ran_cipher_mode_command cipher_mode_command;
struct {
/*! alg_id is in encoded format:
* alg_id == 1 means A5/0 i.e. no encryption, alg_id == 4 means A5/3.
* alg_id == 0 means no such IE was present. */
uint8_t alg_id;
/*! utran integrity protection. 0..15 */
int16_t utran_integrity;
/*! utran_integrity is in encoded format:
* utran_integrity == -1 means no such IE was present
* utran_integrity == 0 means no encryption. */
int16_t utran_encryption;
const char *imeisv;
const struct tlv_p_entry *l3_msg;
} cipher_mode_complete;
struct {
enum gsm0808_cause bssap_cause;
} cipher_mode_reject;
struct {
const char *imsi;
bool last_eutran_plmn_present;
struct osmo_plmn_id last_eutran_plmn;
} common_id;
struct {
enum gsm48_reject_value cause;
} cm_service_reject;
struct ran_assignment_command assignment_command;
struct {
struct osmo_sockaddr_str remote_rtp;
bool codec_present;
struct gsm0808_speech_codec codec;
bool codec_with_iuup;
const struct gsm0808_speech_codec_list *codec_list_bss_supported;
bool osmux_present;
uint8_t osmux_cid;
} assignment_complete;
struct {
enum gsm0808_cause bssap_cause;
uint8_t rr_cause;
const struct gsm0808_speech_codec_list *scl_bss_supported;
} assignment_failure;
struct {
enum gsm0808_cause bssap_cause;
uint8_t dlci;
} sapi_n_reject;
struct {
enum gsm0808_lcls_status status;
} lcls_status;
struct {
int todo;
} lcls_break_req;
struct ran_handover_required handover_required;
struct gsm0808_handover_required_reject handover_required_reject;
struct ran_handover_command handover_command;
struct {
enum gsm0808_cause cause;
} handover_failure;
struct ran_handover_request handover_request;
struct ran_handover_request_ack handover_request_ack;
struct gsm0808_vgcs_vbs_setup vgcs_vbs_setup;
struct gsm0808_vgcs_vbs_setup_ack vgcs_vbs_setup_ack;
struct {
enum gsm0808_cause cause;
} vgcs_vbs_setup_refuse;
struct gsm0808_vgcs_vbs_assign_req vgcs_vbs_assign_req;
struct gsm0808_vgcs_vbs_assign_res vgcs_vbs_assign_res;
struct gsm0808_vgcs_vbs_assign_fail vgcs_vbs_assign_fail;
struct gsm0808_uplink_request uplink_request;
struct gsm0808_uplink_request_ack uplink_request_ack;
struct gsm0808_uplink_request_cnf uplink_request_cnf;
struct gsm0808_uplink_app_data uplink_app_data;
struct gsm0808_uplink_release_ind uplink_release_ind;
struct gsm0808_uplink_seized_cmd uplink_seized_cmd;
struct gsm0808_uplink_reject_cmd uplink_reject_cmd;
struct {
enum gsm0808_cause cause;
} uplink_release_cmd;
struct {
struct gsm0808_talker_identity talker_identity;
} vgcs_additional_info;
struct gsm0808_vgcs_vbs_area_cell_info vgcs_vbs_area_cell_info;
struct gsm0808_vgcs_vbs_assign_stat vgcs_vbs_assign_stat;
struct {
struct gsm0808_sms_to_vgcs sms_to_vgcs;
} vgcs_sms;
struct gsm0808_notification_data notification_data;
};
};
/* MSC-A/I/T roles implement this to receive decoded NAS messages, upon feeding an L2 msgb to a ran_dec_l2_t matching the
* RAN type implementation. */
typedef int (* ran_decode_cb_t )(struct osmo_fsm_inst *caller_fi, void *caller_data, const struct ran_msg *msg);
struct ran_dec {
/* caller provided osmo_fsm_inst, used both for logging from within decoding of NAS events, as well as caller's
* context in decode_cb(). */
struct osmo_fsm_inst *caller_fi;
void *caller_data;
/* Callback receives the decoded NAS messages */
ran_decode_cb_t decode_cb;
};
/* NAS decoders (BSSAP/RANAP) implement this to turn a msgb into a struct ran_msg.
* An implementation typically calls ran_decoded() when done decoding.
* NAS decoding is modeled with a callback instead of a plain decoding, because some L2 messages by design contain more
* than one NAS event, e.g. Ciphering Mode Complete may include another L3 message for Identity Response, and LCLS
* Information messages can contain Status and Break Req events. */
typedef int (* ran_dec_l2_t )(struct ran_dec *ran_dec, struct msgb *l2);
int ran_decoded(struct ran_dec *ran_dec, struct ran_msg *msg);
/* An MSC-A/I/T role that receives NAS events containing DTAP buffers may use this to detect DTAP duplicates as in TS
* 24.007 11.2.3.2 Message Type Octet / Duplicate Detection */
bool ran_dec_dtap_undup_is_duplicate(struct osmo_fsm_inst *log_fi, uint8_t *n_sd_next, bool is_r99, struct msgb *l3);
/* Implemented by individual RAN implementations, see ran_a_encode() and ran_iu_encode(). */
typedef struct msgb *(* ran_encode_t )(struct osmo_fsm_inst *caller_fi, const struct ran_msg *ran_enc_msg);

View File

@ -0,0 +1,46 @@
/* Abstraction of BSSAP decoding into NAS events, to be handled by MSC-A or MSC-I, and encoding of BSSAP messages
* towards the RAN. */
/*
* (C) 2019 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
*
* Author: Neels Hofmeyr <neels@hofmeyr.de>
*
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include <osmocom/msc/ran_msg.h>
#include <osmocom/msc/paging.h>
struct msgb;
struct sccp_ran_inst;
struct msub;
struct gsm_mncc_bearer_cap;
int ran_a_decode_l2(struct ran_dec *ran_a, struct msgb *bssap);
struct msgb *ran_a_encode(struct osmo_fsm_inst *caller_fi, const struct ran_msg *ran_enc_msg);
enum reset_msg_type bssmap_is_reset_msg(const struct sccp_ran_inst *sri, struct osmo_fsm_inst *log_fi,
struct msgb *l2, int *supports_osmux);
struct msgb *bssmap_make_reset_msg(const struct sccp_ran_inst *sri, enum reset_msg_type type);
struct msgb *bssmap_make_paging_msg(const struct sccp_ran_inst *sri, const struct gsm0808_cell_id *page_cell_id,
const char *imsi, uint32_t tmsi, enum paging_cause cause);
const char *bssmap_msg_name(const struct sccp_ran_inst *sri, const struct msgb *l2);
enum mgcp_codecs ran_a_mgcp_codec_from_sc(const struct gsm0808_speech_codec *sc);
int ran_a_bearer_cap_to_channel_type(struct gsm0808_channel_type *ct, const struct gsm_mncc_bearer_cap *bc);

View File

@ -0,0 +1,36 @@
/* Abstraction of RANAP decoding into NAS events, to be handled by MSC-A or MSC-I, and encoding of RANAP messages
* towards the RAN. */
/*
* (C) 2019 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
*
* Author: Neels Hofmeyr <neels@hofmeyr.de>
*
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <osmocom/msc/ran_msg.h>
#include <osmocom/msc/paging.h>
int ran_iu_decode_l2(struct ran_dec *ran_dec_iu, struct msgb *ranap);
struct msgb *ran_iu_encode(struct osmo_fsm_inst *caller_fi, const struct ran_msg *ran_enc_msg);
enum reset_msg_type ranap_is_reset_msg(const struct sccp_ran_inst *sri, struct osmo_fsm_inst *log_fi,
struct msgb *l2, int *supports_osmux);
struct msgb *ranap_make_reset_msg(const struct sccp_ran_inst *sri, enum reset_msg_type type);
struct msgb *ranap_make_paging_msg(const struct sccp_ran_inst *sri, const struct gsm0808_cell_id *page_cell_id,
const char *imsi, uint32_t tmsi, enum paging_cause cause);
const char *ranap_msg_name(const struct sccp_ran_inst *sri, const struct msgb *l2);

View File

@ -0,0 +1,108 @@
#pragma once
#include <osmocom/core/linuxlist.h>
#include <osmocom/gsm/gsm0808.h>
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/msc/debug.h>
#include <osmocom/msc/paging.h>
struct vlr_subscr;
struct ran_conn;
struct neighbor_ident_entry;
#define LOG_RAN_PEER_CAT(RAN_PEER, subsys, loglevel, fmt, args ...) \
LOGPFSMSL((RAN_PEER)? (RAN_PEER)->fi : NULL, subsys, loglevel, fmt, ## args)
#define LOG_RAN_PEER(RAN_PEER, loglevel, fmt, args ...) \
LOG_RAN_PEER_CAT(RAN_PEER, \
(RAN_PEER) && (RAN_PEER)->sri? (RAN_PEER)->sri->ran->log_subsys : DMSC, \
loglevel, fmt, ## args)
/* A BSC or RNC with activity on a local SCCP connection.
* Here we collect those BSC and RNC peers that are actually connected to the MSC and manage their connection Reset
* status.
*
* Before we had explicit neighbor configuration for inter-BSC and inter-MSC handover, the only way to know which peer
* address corresponds to which LAC (for paging a specific LAC) was to collect the LAC from L3 messages coming in on a
* subscriber connection. We still continue that practice to support unconfigured operation.
*
* The neighbor list config extends this by possibly naming LAC and CI that have not seen explicit activity yet, and
* allows us to page towards the correct peer's SCCP address from the start.
*
* So, for paging, the idea is to look for a LAC that is recorded here, and if not found, query the neighbor
* configuration for a peer's SCCP address matching that LAC. If found, look for active connections on that SCCP address
* here.
*
* Any valid RAN peer will contact us and initiate a RESET procedure. In turn, on osmo-msc start, we may choose to
* initiate a RESET procedure towards every known RAN peer.
*
* Semantically, it would make sense to keep the list of ran_conn instances in each struct ran_peer, but since
* non-Initial Connection-Oriented messages indicate only the conn by id (and identify the ran_peer from that), the conn
* list is kept in sccp_ran_inst. For convenience, see ran_peer_for_each_ran_conn().
*/
struct ran_peer {
/* Entry in sccp_ran_inst->ran_peers */
struct llist_head entry;
struct sccp_ran_inst *sri;
struct osmo_sccp_addr peer_addr;
struct osmo_fsm_inst *fi;
/* See cell_id_list.h */
struct llist_head cells_seen;
/* Whether we detected the BSC supports Osmux (during BSSMAP_RESET) */
bool remote_supports_osmux;
};
#define ran_peer_for_each_ran_conn(RAN_CONN, RAN_PEER) \
llist_for_each_entry(RAN_CONN, &(RAN_PEER)->sri->ran_conns, entry) \
if ((RAN_CONN)->ran_peer == (RAN_PEER))
#define ran_peer_for_each_ran_conn_safe(RAN_CONN, RAN_CONN_NEXT, RAN_PEER) \
llist_for_each_entry_safe(RAN_CONN, RAN_CONN_NEXT, &(RAN_PEER)->sri->ran_conns, entry) \
if ((RAN_CONN)->ran_peer == (RAN_PEER))
enum ran_peer_state {
RAN_PEER_ST_WAIT_RX_RESET = 0,
RAN_PEER_ST_WAIT_RX_RESET_ACK,
RAN_PEER_ST_READY,
RAN_PEER_ST_DISCARDING,
};
enum ran_peer_event {
RAN_PEER_EV_MSG_UP_CL = 0,
RAN_PEER_EV_MSG_UP_CO_INITIAL,
RAN_PEER_EV_MSG_UP_CO,
RAN_PEER_EV_MSG_DOWN_CL,
RAN_PEER_EV_MSG_DOWN_CO_INITIAL,
RAN_PEER_EV_MSG_DOWN_CO,
RAN_PEER_EV_RX_RESET,
RAN_PEER_EV_RX_RESET_ACK,
RAN_PEER_EV_CONNECTION_SUCCESS,
RAN_PEER_EV_CONNECTION_TIMEOUT,
};
struct ran_peer_ev_ctx {
uint32_t conn_id;
struct ran_conn *conn;
struct msgb *msg;
};
struct ran_peer *ran_peer_find_or_create(struct sccp_ran_inst *sri, const struct osmo_sccp_addr *peer_addr);
struct ran_peer *ran_peer_find_by_addr(struct sccp_ran_inst *sri, const struct osmo_sccp_addr *peer_addr);
void ran_peer_cells_seen_add(struct ran_peer *ran_peer, const struct gsm0808_cell_id *id);
int ran_peer_up_l2(struct sccp_ran_inst *sri, const struct osmo_sccp_addr *calling_addr, bool co, uint32_t conn_id,
struct msgb *l2);
void ran_peer_disconnect(struct sccp_ran_inst *sri, uint32_t conn_id);
int ran_peers_down_paging(struct sccp_ran_inst *sri, enum CELL_IDENT page_where, struct vlr_subscr *vsub,
enum paging_cause cause);
int ran_peer_down_paging(struct ran_peer *rp, const struct gsm0808_cell_id *page_id, struct vlr_subscr *vsub,
enum paging_cause cause);
struct ran_peer *ran_peer_find_by_cell_id(struct sccp_ran_inst *sri, const struct gsm0808_cell_id *cid,
bool expecting_single_match);

View File

@ -0,0 +1,82 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <osmocom/core/sockaddr_str.h>
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/msc/sdp_msg.h>
struct gsm_trans;
struct osmo_fsm_inst;
struct call_leg;
struct osmo_mgcpc_ep;
struct osmo_mgcpc_ep_ci;
enum rtp_direction {
RTP_TO_RAN,
RTP_TO_CN,
};
extern const struct value_string rtp_direction_names[];
static inline const char *rtp_direction_name(enum rtp_direction val)
{ return get_value_string(rtp_direction_names, val); }
/* A single bidirectional RTP hop between remote and MGW's local RTP port. */
struct rtp_stream {
struct osmo_fsm_inst *fi;
uint32_t event_avail;
uint32_t event_estab;
enum rtp_direction dir;
uint32_t call_id;
/* Backpointer for callers (optional) */
struct gsm_trans *for_trans;
struct osmo_sockaddr_str local;
struct osmo_sockaddr_str remote;
bool remote_sent_to_mgw;
bool codecs_known;
struct sdp_audio_codecs codecs;
bool codecs_sent_to_mgw;
struct osmo_mgcpc_ep_ci *ci;
enum mgcp_connection_mode crcx_conn_mode;
bool mode_sent_to_mgw;
/* configured to use Osmux */
bool use_osmux;
/* Allocated by our MGW, negative means invalid, not yet known */
int local_osmux_cid;
/* Allocated by BSC MGW, negative means invalid, not yet known */
int remote_osmux_cid;
/* Whether remote_osmux_cid has been communicated to MGW */
bool remote_osmux_cid_sent_to_mgw;
};
#define RTP_STREAM_FMT "local=" RTP_IP_PORT_FMT ",remote=" RTP_IP_PORT_FMT
#define RTP_STREAM_ARGS(RS) RTP_IP_PORT_ARGS(&(RS)->local), RTP_IP_PORT_ARGS(&(RS)->remote),
struct rtp_stream *rtp_stream_alloc(struct osmo_fsm_inst *parent_fi, uint32_t event_gone, uint32_t event_avail,
uint32_t event_estab, enum rtp_direction dir, uint32_t call_id,
struct gsm_trans *for_trans);
int rtp_stream_ensure_ci(struct rtp_stream *rtps, struct osmo_mgcpc_ep *at_endpoint);
int rtp_stream_do_mdcx(struct rtp_stream *rtps);
bool rtp_stream_set_codecs_from_mgcp_codec(struct rtp_stream *rtps, enum mgcp_codecs codec);
void rtp_stream_set_one_codec(struct rtp_stream *rtps, const struct sdp_audio_codec *codec);
void rtp_stream_set_codecs(struct rtp_stream *rtps, const struct sdp_audio_codecs *codecs);
void rtp_stream_set_mode(struct rtp_stream *rtps, enum mgcp_connection_mode mode);
void rtp_stream_set_remote_addr(struct rtp_stream *rtps, const struct osmo_sockaddr_str *r);
void rtp_stream_set_remote_addr_and_codecs(struct rtp_stream *rtps, const struct sdp_msg *sdp);
void rtp_stream_set_remote_osmux_cid(struct rtp_stream *rtps, uint8_t osmux_cid);
int rtp_stream_commit(struct rtp_stream *rtps);
void rtp_stream_release(struct rtp_stream *rtps);
bool rtp_stream_is_established(struct rtp_stream *rtps);

View File

@ -0,0 +1,283 @@
/* The RAN (Radio Access Network) side of an A- or Iu-connection, which is closely tied to an SCCP connection.
* (as opposed to the NAS side.)
*
* The SCCP connection is located with the MSC-I role, while the MSC-A responsible for subscriber management may be at a
* remote MSC behind an E-interface connection. In that case we need to forward the L2 messages over the E-interface and
* the BSSAP or RANAP messages get decoded and interpreted at MSC-A.
*
* The life cycle of a DTAP message from RAN to MSC-A -- starting from the bottom left:
*
* ------------------>[ 3GPP TS 24.008 ]------------------->|
* ^ (Request) (Response) |
* | v
* msc_a_up_l3() msc_a_tx_dtap_to_i(dtap_msgb)
* ^ |
* | v
* msc_a_ran_decode_cb(struct ran_dec_msg) msc_a_ran_enc(struct ran_enc_msg)
* ^ ^ . |
* | -Decode NAS- | . NAS v
* | | . ran_infra[type]->ran_encode(struct ran_enc_msg)
* ran_a_decode_l2() ran_iu_decode_l2() . | |
* ^ ^ . v v
* | | . ran_a_encode() ran_iu_encode()
* ran_infra[type]->ran_dec_l2() | |
* ^ | -Encode BSSAP/RANAP- |
* | v v
* msc_a_ran_dec() msub_tx_an_apdu(from MSC_ROLE_A to MSC_ROLE_I)
* ^ |
* | MSC-A v
* . msc_a FSM . . . . . . . . . . . . . . . . msc_a FSM . . . . . . . . . .
* ^ |
* | MSC_A_EV_FROM_I_PROCESS_ACCESS_SIGNALLING_REQUEST v
* | data = an_apdu [possibly
* | via GSUP
* [possibly from remote MSC-A]
* via GSUP |
* to remote MSC-A] | MSC_I_EV_FROM_A_FORWARD_ACCESS_SIGNALLING_REQUEST
* ^ | data = an_apdu
* | v
* . msc_i FSM . . . . . . . . . . . . . . . . msc_i FSM . . . . . . . . . .
* ^ MSC-I |
* | MSC_EV_FROM_RAN_UP_L2 V
* | data = an_apdu msc_i_down_l2(an_apdu->msg)
* | |
* ran_peer FSM V
* ^ ran_conn_down_l2_co();
* | RAN_PEER_EV_MSG_UP_CO |
* | data = struct ran_peer_ev_ctx | RAN_PEER_EV_MSG_DOWN_CO
* | | data = struct ran_peer_ev_ctx
* ran_peer_up_l2() V
* (ran_infa->sccp_ran_ops.up_l2) ran_peer FSM
* ^ ^ |
* | | v
* sccp_ran_sap_up() sccp_ran_down_l2_co(conn_id, msg)
* ^ ^ | |
* | | |SCCP|
* |SCCP| v v
* | | <------------------------------------------------------
* BSC RNC
* | |
* BTS NodeB
* | |
* MS UE
*
* sccp_ran:
* - handles receiving of SCCP primitives from the SCCP layer.
* - extracts L2 msg
* - passes on L2 msg and conn_id by calling sccp_ran_ops.up_l2 == ran_peer_up_l2().
*
* On Connection-Oriented *Initial* message
* ========================================
*
* ran_peer_up_l2()
* - notices an unknown, new osmo_rat_type:conn_id and
* - first creates an "empty" msub with new local MSC-I and MSC-A roles;
* in this case always a *local* MSC-A (never remote on Initial messages).
* - Passes the L2 msgb containing the BSSAP or RANAP as AN-APDU
* in MSC_A_EV_FROM_I_COMPLETE_LAYER_3 to the MSC-A role FSM instance.
*
* MSC-A:
* - Receives MSC_A_EV_FROM_I_COMPLETE_LAYER_3 AN-APDU, notices an_proto indicating BSSAP or RANAP.
* - Passes L2 message to ran_infra[]->ran_dec_l2(), which decodes the BSSAP or RANAP.
* - contained information is passed to msc_a_ran_decode_cb().
* - which msc_a starts Complete-L3 and VLR procedures,
* - associates msub with a vlr_subscr,
* - sends DTAP requests back down by calling msc_a_tx_dtap_to_i() (possibly other more specialized tx functions)
* - according to ran_infra[]->ran_encode(), the ran_enc_msg gets encoded as BSSAP or RANAP.
* - passes as AN-APDU to MSC-I in MSC_I_EV_FROM_A_FORWARD_ACCESS_SIGNALLING_REQUEST signal.
*
* MSC-I, receiving AN-APDU from local MSC-A:
* - feeds L2 msgb to the ran_peer FSM as RAN_PEER_EV_MSG_DOWN_CO, passing the SCCP conn_id.
*
* sccp_ran_down_l2_co()
* - wraps in SCCP prim,
* - sends down.
*
*
* On (non-Initial) Connection-Oriented DTAP
* =========================================
*
* ran_peer_up_l2()
* - notices an already known conn_id by looking up a matching osmo_rat_type:ran_conn.
* - ran_conn already associated with an MSC-I role.
* - Now forwards AN-APDU like above, only using MSC_A_EV_FROM_I_PROCESS_ACCESS_SIGNALLING_REQUEST.
*
*
* MSC-A and MSC-I roles on separate MSC instances
* ===============================================
*
* After inter-MSC handover, the MSC-I and MSC-A roles can be on separate MSC instances, typically physically distant /
* possibly belonging to a different operator. This will never see Complete-L3.
* Assuming that both instances are osmo-msc, then:
*
* At MSC-B:
* initially, via GSUP:
* - receives Handover Request from remote MSC-A,
* - creates msub with local MSC-T role,
* - sets up the ran_conn with a new SCCP conn_id, and waits for the MS/UE to show up.
* - (fast-forward to successful Handover)
* - MSC-T role becomes MSC-I for the remote MSC-A.
*
* Then for DTAP from the MS:
*
* sccp_ran:
* - receives SCCP,
* - extracts L2 and passes on to ran_peer_up_l2().
*
* ran_peer_up_l2()
* - notices an already known conn_id by looking up a matching ran_conn.
* - ran_conn already associated with an MSC-I role and an msub.
* - forwards AN-APDU in MSC_A_EV_FROM_I_PROCESS_ACCESS_SIGNALLING_REQUEST to the MSC-A role.
*
* At MSC-B, the "MSC-A role" is a *remote* implementation,
* meaning there is an msc_a_remote FSM instance in MSC-B's msub:
*
* MSC-A-Remote:
* - msc_a_remote receives MSC_A_EV_FROM_I_PROCESS_ACCESS_SIGNALLING_REQUEST,
* - wraps AN-APDU in GSUP message,
* - sends to remote MSC-A.
*
* At MSC-A:
* Here, msub has a *remote* MSC-I role,
* meaning it is an msc_i_remote FSM instance:
*
* MSC-I-Remote:
* - msc_i_remote receives and decodes GSUP message,
* - passes AN-APDU to MSC-A FSM instance via MSC_A_EV_FROM_I_PROCESS_ACCESS_SIGNALLING_REQUEST.
*
* MSC-A role:
* - Receives MSC_A_EV_FROM_I_PROCESS_ACCESS_SIGNALLING_REQUEST, notices an_proto indicating BSSAP or RANAP.
* - Passes L2 message to ran_infra[]->ran_dec_l2(), which decodes the BSSAP or RANAP.
* - contained information is passed to msc_a_ran_decode_cb().
* - sends DTAP requests back down by calling msc_a_tx_dtap_to_i() (possibly other more specialized tx functions)
* - according to ran_infra[]->ran_encode(), the ran_enc_msg gets encoded as BSSAP or RANAP.
* - passes as AN-APDU to MSC-I in MSC_I_EV_FROM_A_FORWARD_ACCESS_SIGNALLING_REQUEST signal.
*
* MSC-I-Remote:
* - msc_i_remote wraps AN-APDU in GSUP message,
* - sends to MSC-B
*
* At MSC-B:
* MSC-A-Remote:
* - msc_a_remote receives GSUP message,
* - passes AN-APDU to msc_i in MSC_I_EV_FROM_A_FORWARD_ACCESS_SIGNALLING_REQUEST.
*
* MSC-I:
* - BSSAP or RANAP is indicated both by the AN-APDU an_proto, as well as the ran_conn state for that subscriber.
* - feeds L2 msgb to the ran_peer FSM as RAN_PEER_EV_MSG_DOWN_CO, passing the SCCP conn_id.
*
* sccp_ran_down_l2_co()
* - wraps in SCCP prim,
* - sends down.
*
*/
#pragma once
#include <stdint.h>
#include <osmocom/core/tdef.h>
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/gsm/gsm0808_utils.h>
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/msc/paging.h>
struct msgb;
struct ran_infra;
struct sccp_ran_inst;
#define LOG_SCCP_RAN_CO(sri, peer_addr, conn_id, level, fmt, args...) \
LOGP((sri) && (sri)->ran? (sri)->ran->log_subsys : DMSC, level, "(%s-%u%s%s) " fmt, \
osmo_rat_type_name((sri) && (sri)->ran ? (sri)->ran->type : OSMO_RAT_UNKNOWN), conn_id, \
peer_addr ? " from " : "", \
peer_addr ? osmo_sccp_inst_addr_name((sri)->sccp, peer_addr) : "", \
## args)
#define LOG_SCCP_RAN_CL_CAT(sri, peer_addr, subsys, level, fmt, args...) \
LOGP(subsys, level, "(%s%s%s) " fmt, \
osmo_rat_type_name((sri) && (sri)->ran ? (sri)->ran->type : OSMO_RAT_UNKNOWN), \
peer_addr ? " from " : "", \
peer_addr ? osmo_sccp_inst_addr_name((sri)->sccp, peer_addr) : "", \
## args)
#define LOG_SCCP_RAN_CL(sri, peer_addr, level, fmt, args...) \
LOG_SCCP_RAN_CL_CAT(sri, peer_addr, (sri) && (sri)->ran? (sri)->ran->log_subsys : DMSC, level, fmt, ##args)
#define LOG_SCCP_RAN_CAT(sri, subsys, level, fmt, args...) \
LOG_SCCP_RAN_CL_CAT(sri, NULL, subsys, level, fmt, ##args)
#define LOG_SCCP_RAN(sri, level, fmt, args...) \
LOG_SCCP_RAN_CL(sri, NULL, level, fmt, ##args)
extern struct osmo_tdef g_sccp_tdefs[];
enum reset_msg_type {
SCCP_RAN_MSG_NON_RESET = 0,
SCCP_RAN_MSG_RESET,
SCCP_RAN_MSG_RESET_ACK,
};
struct sccp_ran_ops {
/* Implemented to receive L2 messages (e.g. BSSAP or RANAP passed to ran_peer).
* - ConnectionLess messages: co = false, calling_addr != NULL, conn_id == 0;
* - ConnectionOriented Initial messages: co = true, calling_addr != NULL;
* - ConnectionOriented non-Initial messages: co = true, calling_addr == NULL;
*/
int (* up_l2 )(struct sccp_ran_inst *sri, const struct osmo_sccp_addr *calling_addr, bool co, uint32_t conn_id,
struct msgb *l2);
/* Implemented to finally remove a connection state. Last event in a connection-oriented exchange. If the
* N-DISCONNECT contained l2 data, it was dispatched via up_l2() before this is called. */
void (* disconnect )(struct sccp_ran_inst *sri, uint32_t conn_id);
/* Return whether the given l2_cl message is a RESET, RESET ACKNOWLEDGE, or RESET-unrelated message.
* This callback is stored in struct sccp_ran_inst to provide RESET handling to the caller (ran_peer),
* it is not used in sccp_ran.c.
* In supports_osmux, return 0 for no information, 1 for support detected, -1 for non-support detected.
*/
enum reset_msg_type (* is_reset_msg )(const struct sccp_ran_inst *sri, struct osmo_fsm_inst *log_fi,
struct msgb *l2_cl, int *supports_osmux);
/* Return a RESET or RESET ACK message for this RAN type.
* This callback is stored in struct sccp_ran_inst to provide RESET handling to the caller (ran_peer),
* it is not used in sccp_ran.c. */
struct msgb* (* make_reset_msg )(const struct sccp_ran_inst *sri, enum reset_msg_type);
/* Return a PAGING message towards the given Cell Identifier, to page for the given TMSI or IMSI.
* Page for TMSI if TMSI != GSM_RESERVED_TMSI, otherwise page for IMSI. */
struct msgb* (* make_paging_msg )(const struct sccp_ran_inst *sri, const struct gsm0808_cell_id *page_cell_id,
const char *imsi, uint32_t tmsi, enum paging_cause cause);
/* Return a human printable name for the msgb */
const char* (* msg_name )(const struct sccp_ran_inst *sri, const struct msgb *l2);
};
struct sccp_ran_inst {
struct ran_infra *ran;
struct osmo_sccp_instance *sccp;
struct osmo_sccp_user *scu;
struct osmo_sccp_addr local_sccp_addr;
struct llist_head ran_peers;
struct llist_head ran_conns;
void *user_data;
/* Compatibility with legacy osmo-hnbgw that was unable to properly handle RESET messages. Set to 'false' to
* require proper RESET procedures, set to 'true' to implicitly put a ran_peer in RAN_PEER_ST_READY upon the
* first CO message. Default is false = be strict. */
bool ignore_missing_reset;
};
struct sccp_ran_inst *sccp_ran_init(void *talloc_ctx, struct osmo_sccp_instance *sccp, enum osmo_sccp_ssn ssn,
const char *sccp_user_name, struct ran_infra *ran, void *user_data);
int sccp_ran_down_l2_co_initial(struct sccp_ran_inst *sri,
const struct osmo_sccp_addr *called_addr,
uint32_t conn_id, struct msgb *l2);
int sccp_ran_down_l2_co(struct sccp_ran_inst *sri, uint32_t conn_id, struct msgb *l2);
int sccp_ran_down_l2_cl(struct sccp_ran_inst *sri, const struct osmo_sccp_addr *called_addr, struct msgb *l2);
int sccp_ran_disconnect(struct sccp_ran_inst *ran, uint32_t conn_id, uint32_t cause);

View File

@ -0,0 +1,87 @@
/* Minimalistic SDP parse/compose API, focused on GSM audio codecs */
#pragma once
#include <osmocom/core/utils.h>
#include <osmocom/core/sockaddr_str.h>
#include <osmocom/msc/csd_bs.h>
extern const struct value_string sdp_msg_payload_type_names[];
static inline const char *sdp_msg_payload_type_name(unsigned int payload_type)
{ return get_value_string(sdp_msg_payload_type_names, payload_type); }
int sdp_subtype_name_to_payload_type(const char *subtype_name);
enum sdp_mode_e {
SDP_MODE_UNSET = 0,
SDP_MODE_SENDONLY = 1,
SDP_MODE_RECVONLY = 2,
SDP_MODE_SENDRECV = 3,
SDP_MODE_INACTIVE = 4,
};
struct sdp_audio_codec {
/* Payload type number, like 3 for GSM-FR. */
unsigned int payload_type;
/* Like "GSM", "AMR", "EFR", ... */
char subtype_name[16];
unsigned int rate;
char fmtp[256];
};
struct sdp_audio_codecs {
unsigned int count;
struct sdp_audio_codec codec[16];
};
struct sdp_msg {
struct osmo_sockaddr_str rtp;
unsigned int ptime;
enum sdp_mode_e mode;
struct sdp_audio_codecs audio_codecs;
struct csd_bs_list bearer_services;
};
#define sdp_audio_codecs_foreach(/* struct sdp_audio_codec* */ CODEC, \
/* struct sdp_audio_codecs* */ AC) \
for (CODEC = (AC)->codec; \
(CODEC - (AC)->codec) < OSMO_MIN((AC)->count, ARRAY_SIZE((AC)->codec)); \
CODEC++)
const char *sdp_msg_line_end(const char *src);
bool sdp_audio_codec_is_set(const struct sdp_audio_codec *a);
int sdp_audio_codec_cmp(const struct sdp_audio_codec *a, const struct sdp_audio_codec *b,
bool cmp_fmtp, bool cmp_payload_type);
int sdp_audio_codecs_cmp(const struct sdp_audio_codecs *a, const struct sdp_audio_codecs *b,
bool cmp_fmtp, bool cmp_payload_type);
struct sdp_audio_codec *sdp_audio_codecs_add(struct sdp_audio_codecs *ac, unsigned int payload_type,
const char *subtype_name, unsigned int rate, const char *fmtp);
struct sdp_audio_codec *sdp_audio_codecs_add_copy(struct sdp_audio_codecs *ac,
const struct sdp_audio_codec *codec);
int sdp_audio_codecs_remove(struct sdp_audio_codecs *ac, const struct sdp_audio_codec *codec);
struct sdp_audio_codec *sdp_audio_codecs_by_payload_type(struct sdp_audio_codecs *ac,
unsigned int payload_type, bool create);
struct sdp_audio_codec *sdp_audio_codecs_by_descr(struct sdp_audio_codecs *ac,
const struct sdp_audio_codec *codec);
void sdp_audio_codecs_intersection(struct sdp_audio_codecs *ac_dest, const struct sdp_audio_codecs *ac_other,
bool translate_payload_type_numbers);
void sdp_audio_codecs_select(struct sdp_audio_codecs *ac, struct sdp_audio_codec *codec);
int sdp_msg_to_sdp_str_buf(char *dst, size_t dst_size, const struct sdp_msg *sdp);
int sdp_msg_from_sdp_str(struct sdp_msg *sdp, const char *src);
int sdp_audio_codec_to_str_buf(char *buf, size_t buflen, const struct sdp_audio_codec *codec);
char *sdp_audio_codec_to_str_c(void *ctx, const struct sdp_audio_codec *codec);
const char *sdp_audio_codec_to_str(const struct sdp_audio_codec *codec);
int sdp_audio_codecs_to_str_buf(char *buf, size_t buflen, const struct sdp_audio_codecs *ac);
char *sdp_audio_codecs_to_str_c(void *ctx, const struct sdp_audio_codecs *ac);
const char *sdp_audio_codecs_to_str(const struct sdp_audio_codecs *ac);
int sdp_msg_to_str_buf(char *buf, size_t buflen, const struct sdp_msg *sdp);
char *sdp_msg_to_str_c(void *ctx, const struct sdp_msg *sdp);
const char *sdp_msg_to_str(const struct sdp_msg *sdp);
void sdp_audio_codecs_set_csd(struct sdp_audio_codecs *ac);

View File

@ -0,0 +1,93 @@
/* (C) 2018-2019 by sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Harald Welte, Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <osmocom/gsm/protocol/gsm_23_003.h>
#include <osmocom/gsm/protocol/gsm_29_118.h>
#include <osmocom/msc/vlr.h>
#include <osmocom/msc/vlr_sgs.h>
#include <osmocom/msc/paging.h>
#include <osmocom/core/socket.h>
struct msc_a;
static const unsigned int sgs_state_timer_defaults[_NUM_SGS_STATE_TIMERS] = {
[SGS_STATE_TS5] = SGS_TS5_DEFAULT,
[SGS_STATE_TS6_2] = SGS_TS6_2_DEFAULT,
[SGS_STATE_TS7] = SGS_TS7_DEFAULT,
[SGS_STATE_TS11] = SGS_TS11_DEFAULT,
[SGS_STATE_TS14] = SGS_TS14_DEFAULT,
[SGS_STATE_TS15] = SGS_TS15_DEFAULT,
};
static const unsigned int sgs_state_counter_defaults[_NUM_SGS_STATE_COUNTERS] = {
[SGS_STATE_NS7] = SGS_NS7_DEFAULT,
[SGS_STATE_NS11] = SGS_NS11_DEFAULT,
};
struct sgs_connection {
/* global list of SGs connections */
struct llist_head entry;
/* back-pointer */
struct sgs_state *sgs;
/* Socket name from osmo_sock_get_name() */
char sockname[OSMO_SOCK_NAME_MAXLEN];
/* MME for this connection, if any. This field is NULL until we
* receive the first "MME name" IE from the MME, which could be part
* of the RESET procedure, but also just a normal LU request. */
struct sgs_mme_ctx *mme;
/* represents the SCTP connection we accept()ed from this MME */
struct osmo_stream_srv *srv;
};
struct sgs_mme_ctx {
/* global list of MME contexts */
struct llist_head entry;
/* back-pointer */
struct sgs_state *sgs;
/* MME name as string representation */
char fqdn[GSM23003_MME_DOMAIN_LEN + 1];
/* current connection for this MME, if any. Can be NULL if the SCTP
* connection to the MME was lost and hasn't been re-established yet */
struct sgs_connection *conn;
/* FSM for the "VLR reset" procedure" */
struct osmo_fsm_inst *fi;
unsigned int ns11_remaining;
};
extern struct sgs_state *g_sgs;
struct sgs_state *sgs_iface_init(void *ctx, struct gsm_network *network);
int sgs_iface_rx(struct sgs_connection *sgc, struct msgb *msg);
enum sgsap_service_ind sgs_serv_ind_from_paging_cause(enum paging_cause);
int sgs_iface_tx_paging(struct vlr_subscr *vsub, enum sgsap_service_ind serv_ind);
int sgs_iface_tx_dtap_ud(struct msc_a *msc_a, struct msgb *msg);
void sgs_iface_tx_release(struct vlr_subscr *vsub);
void sgs_iface_tx_serv_abrt(struct vlr_subscr *vsub);

View File

@ -0,0 +1,53 @@
/* (C) 2018-2019 by sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Harald Welte, Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <arpa/inet.h>
#include <osmocom/gsm/protocol/gsm_29_118.h>
#define DEFAULT_SGS_SERVER_IP "0.0.0.0"
#define DEFAULT_SGS_SERVER_VLR_NAME "vlr.example.net"
/* global SGs state */
struct sgs_state {
/* list of MMEs (sgs_mme_ctx) */
struct llist_head mme_list;
/* list of SCTP client connections */
struct llist_head conn_list;
/* SCTP server for inbound SGs connections */
struct osmo_stream_srv_link *srv_link;
struct {
char local_addr[INET6_ADDRSTRLEN];
uint16_t local_port;
/* user-configured VLR name (FQDN) */
char vlr_name[SGS_VLR_NAME_MAXLEN];
/* timers on VLR side */
unsigned int timer[_NUM_SGS_STATE_TIMERS];
/* counters on VLR side */
unsigned int counter[_NUM_SGS_STATE_COUNTERS];
} cfg;
};
struct sgs_state *sgs_server_alloc(void *ctx);
int sgs_server_open(struct sgs_state *sgs);

View File

@ -0,0 +1,23 @@
/* (C) 2018-2019 by sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Harald Welte, Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
void sgs_vty_init(void);

View File

@ -28,6 +28,9 @@
#include <osmocom/core/signal.h>
struct msc_a;
struct vty;
/*
* Signalling subsystems
*/
@ -63,38 +66,24 @@ enum signal_subscr {
/* SS_SCALL signals */
enum signal_scall {
S_SCALL_SUCCESS,
S_SCALL_EXPIRED,
S_SCALL_FAILED,
S_SCALL_DETACHED,
};
/* SS_IPAC_NWL signals */
enum signal_ipaccess {
S_IPAC_NWL_COMPLETE,
};
enum signal_global {
S_GLOBAL_BTS_CLOSE_OM,
};
struct paging_signal_data {
struct vlr_subscr *vsub;
struct gsm_bts *bts;
int paging_result;
/* NULL in case the paging didn't work */
struct ran_conn *conn;
struct msc_a *msc_a;
};
struct scall_signal_data {
struct ran_conn *conn;
void *data;
struct msc_a *msc_a;
struct vty *vty;
};
struct sms_signal_data {
/* The transaction where this occured */
/* The transaction where this occurred */
struct gsm_trans *trans;
/* Can be NULL for SMMA */
struct gsm_sms *sms;
/* int paging result. Only the ones with > 0 */
int paging_result;
/* true when paging was successful */
bool paging_result;
};

View File

@ -1,12 +1,18 @@
#ifndef _SILENT_CALL_H
#define _SILENT_CALL_H
struct ran_conn;
struct gsm0808_channel_type;
struct gsm_trans;
int gsm_silent_call_start(struct vlr_subscr *vsub,
const struct gsm0808_channel_type *ct,
const char *traffic_dst_ip, uint16_t traffic_dst_port,
struct vty *vty);
extern int gsm_silent_call_start(struct vlr_subscr *vsub,
void *data, int type);
extern int gsm_silent_call_stop(struct vlr_subscr *vsub);
void trans_silent_call_free(struct gsm_trans *trans);
#if 0
extern int silent_call_rx(struct ran_conn *conn, struct msgb *msg);
extern int silent_call_reroute(struct ran_conn *conn, struct msgb *msg);

View File

@ -1,4 +0,0 @@
#pragma once
int smpp_openbsc_alloc_init(void *ctx);
int smpp_openbsc_start(struct gsm_network *net);

View File

@ -1,17 +1,32 @@
#ifndef SMS_QUEUE_H
#define SMS_QUEUE_H
#include <stdbool.h>
struct gsm_network;
struct gsm_sms_queue;
struct vty;
int sms_queue_start(struct gsm_network *, int in_flight);
struct sms_queue_config {
char *db_file_path; /* SMS database file path */
int max_fail; /* maximum number of delivery failures */
int max_pending; /* maximum number of gsm_sms_pending in RAM */
bool delete_delivered; /* delete delivered SMS from DB? */
bool delete_expired; /* delete expired SMS from DB? */
unsigned int minimum_validity_mins; /* minimum validity period in minutes */
unsigned int default_validity_mins; /* default validity period in minutes */
};
struct sms_queue_config *sms_queue_cfg_alloc(void *ctx);
#define VSUB_USE_SMS_PENDING "SMS-pending"
#define MSC_A_USE_SMS_PENDING "SMS-pending"
int sms_queue_start(struct gsm_network *net);
int sms_queue_trigger(struct gsm_sms_queue *);
/* vty helper functions */
int sms_queue_stats(struct gsm_sms_queue *, struct vty* vty);
int sms_queue_set_max_pending(struct gsm_sms_queue *, int max);
int sms_queue_set_max_failure(struct gsm_sms_queue *, int fail);
int sms_queue_clear(struct gsm_sms_queue *);
int sms_queue_sms_is_pending(struct gsm_sms_queue *smsq, unsigned long long sms_id);

Some files were not shown because too many files have changed in this diff Show More