Commit Graph

51 Commits

Author SHA1 Message Date
Neels Hofmeyr 46c06e28c1 add LOG_RAN_CONN() to use the conn->fi->id for context
For each conn, set a default logging category, to distinguish categories for
BSSMAP and RANAP based conns.

LOG_RAN_CONN(): log with the conn's default category,

LOG_RAN_CONN_CAT(): log with a manually set category (mostly for keeping
previous DMM logging on the same category).

In some places, replace LOGP() using manual context with LOG_RAN_CONN(), and
remove the manual context info, now provided by the conn->fi->id.

This is loosely related to inter-BSC and inter-MSC handover: to speed up
refactoring, I want to avoid the need for manual logging context and just use
this LOG_RAN_CONN().

Change-Id: I0a7809840428b1e028df6eb683bc5ffcc8df474a
2019-01-12 09:51:22 +00:00
Neels Hofmeyr 7814a83298 use osmo_rat_type from libosmocore
Replace locally defined enum ran_type with libosmocore's new enum
osmo_rat_type, and value_string ran_type_names with osmo_rat_type_names.

The string representations change, which has cosmetic effects on the test suite
expectations.

Depends: I659687aef7a4d67ca372a39fef31dee07aed7631 (libosmocore)
Change-Id: I2c78c265dc99df581e1b00e563d6912c7ffdb36b
2019-01-04 17:26:14 +00:00
Neels Hofmeyr 85cb2538f4 Revert "move ASS-COMPL MGCP handling out of a_iface_bssap.c"
Two reasons:

- the caller of msc_mgcp_ass_complete() from Iu, iucs_rx_rab_assign(), failed
  to be adjusted, breaking IuCS, as an --enable-iu --enable-werror build shows.
  Unfortunately our gerrit verification doesn't --enable-werror for osmo-msc.

- the condition of requiring ST_MDCX_RAN is faulty, breaking GSM CS.

This reverts commit 212c0c9bda.

Change-Id: I8348675c2f7c8856ea1682d05ee54160d4cfeb96
2018-12-11 19:52:30 +01:00
Neels Hofmeyr 212c0c9bda move ASS-COMPL MGCP handling out of a_iface_bssap.c
BSSMAP Assignment Complete: sort MGCP handling upon Assignment Complete to the
proper locations. a_iface_bssap.c is not the right place to invoke the MGCP
related procedures.

- in a_iface_bssap.c only decode the IEs.
- call ran_conn_assign_compl() and pass decoded values.
- drop msc_assign_compl(), it was dead code; instead:
- add ran_conn_assign_compl()
- pass on all MGCP related info to msc_mgcp_ass_complete()
- move all MGCP ctx related handling from a_iface_bssap.c to msc_mgcp.c.

I'm dropping some comments to save some time, because if I adjust them IMHO
they would still anyway restate the obvious.

ran_conn_assign_compl() is now quite a thin shim, but it makes sense to have
it:

- This is the place that should tear down the ran_conn in case assignment
  failed, left for a future patch.

- In the light of upcoming inter-MSC handover, ran_conn_assign_compl() will be
  the place where the Assignment Complete message might be relayed to a remote
  MSC.

Change-Id: I8137215c443239bddf3e69b5715839a365b73b6c
2018-12-10 14:20:59 +01:00
Neels Hofmeyr 4e0dd536b4 ASS-COMPL: do not fire Sec Mode Compl event
BSSMAP Assignment Complete:
Do not invoke ran_conn_rx_sec_mode_compl(), that's just weird.

Instead this should call msc_assign_compl(), which is currently dead code and
does nothing ... and there are some more strings attached, being resolved in a
subsequent patch.

Change-Id: I448fdb783364628005437b3d866d1a076a9767d7
2018-12-07 15:04:33 +01:00
Neels Hofmeyr 7992122bac combine several small .h in msc_common.h
For hysterical raisins, there are some header files that contain few
declarations, and where the name doesn't reflect the content. Combine them to
new msc_common.h:

- common.h
- common_cs.h
- osmo_msc.h

Change-Id: I9e3a587342f8d398fb27354a2f2475f8797cdb28
2018-11-30 22:46:15 +01:00
Neels Hofmeyr 3c20a5ee74 rename some RAN conn related stuff to ran_conn_*
Following previous rename of gsm_subscriber_connection:

Some functions and #defines are still called like "msc_conn" or just "msc_",
while they are clearly about a RAN conn.

To avoid confusion with the future separate concepts of MSC roles and a RAN
connection, rename all those to match the common "ran_conn" prefix.

Change-Id: Ia17a0a35f11911e00e19cafb5d7828d729a69640
2018-11-30 22:46:13 +01:00
Neels Hofmeyr c036b79918 rename gsm_subscriber_connection to ran_conn
In preparation for inter-BSC and inter-MSC handover, we need to separate the
subscriber management logic from the actual RAN connections. What better time
to finally rename gsm_subscriber_connection.

* Name choice:

In 2G, this is a connection to the BSS, but even though 3GPP TS commonly talk
of "BSS-A" and "BSS-B" when explaining handover, it's not good to call it
"bss_conn": in 3G a BSS is called RNS, IIUC.

The overall term for 2G (GERAN) and 3G (UTRAN) is RAN: Radio Access Network.

* Rationale:

A subscriber in the MSC so far has only one RAN connection, but e.g. for
inter-BSC handover, a second one needs to be created to handover to. Most of
the items in the former gsm_subscriber_connection are actually related to the
RAN, with only a few MM and RTP related items. So, as a first step, just rename
it to ran_conn, to cosmetically prepare for moving the not strictly RAN related
items away later.

Also:

- Rename some functions from msc_subscr_conn_* to ran_conn_*
- Rename "Subscr_Conn" FSM instance name to "RAN_conn"
- Rename SUBSCR_CONN_* to RAN_CONN_*

Change-Id: Ic595f7a558d3553c067f77dc67543ab59659707a
2018-11-30 22:45:42 +01:00
Neels Hofmeyr d03e728915 drop msc_compl_l3() return value
msc_compl_l3() always returns MSC_CONN_ACCEPT, because the conn FSM handles (or
should handle) all reject cases. The accept/reject return value is a legacy
from libbsc internally passing a conn over to libmsc, in osmo-nitb.

Drop enum msc_compl_l3_rc.
Change msc_compl_l3_rc() to return void.
Change all callers to always act like for acceptance, as they always did anyway.
Drop some local variables now no longer needed.
Adjust the comment to msc_compl_l3().
Drop a bunch of #if-0'd code from msc_compl_l3().

Change-Id: I759d15f4e820d5fc16397ed7210ce92308e52a09
2018-11-30 22:44:23 +01:00
Philipp Maier 54729d6e5e osmo_msc: remove unused parameter from msc_dtap()
The parameter link_id in the function msc_dtap() is unused. Lets remove
it.

Change-Id: I7ba67b0cb514c91bc87a7b396ed3962b7a68e7da
2018-11-23 10:04:29 +00:00
Max 58099f699f Use libosmocore to function to parse cipher mode reject cause
This allow us to handle both regular and extended cause transparently.

Change-Id: I7742ac41dd0642a5a40ce79d23250f8d9e6ae556
Related: OS#3187
2018-11-20 17:27:40 +00:00
Max f1329c533d Use BSSAP-specific TLV parser from libosmocore
Change-Id: Iae1a3ffcebf1b0b95e61cd5dffe7ef734796fcfc
2018-11-20 15:24:54 +00:00
Max 366390d81a Add counters for BSSMAP cipher mode messages
Count COMPLETE and REJECT messages. Besides general troubleshooting
that's also useful for TTCN-3 tests to check that OsmoMSC processed
those messages as expected.

Change-Id: I5822b2b38b64f1a691b26c926a8e2bece21dc624
Related: OS#3187
2018-11-02 22:06:09 +00:00
Max 662e2ba73e Properly parse cause in cipher mode reject
Use appropriate TLV routines to get and log the value of rejection
cause.

Change-Id: I26b3eb0deff6dbd217b23d284bbc6e6a9eebc8e6
Fixes: OS#3187
2018-11-02 22:06:09 +00:00
Philipp Maier 8ad3dacebb mgcp: use codec information returned with ASSIGNMENT COMPL.
When the assignment completes a choosen codec is returned. At the
moment we do not use this information.

- add struct members for codec info (both, RAN and CN)
- parse codec info in BSSMAP ASSIGNMENT COMPLETE
- use codec info on mgcp

Since the MNCC API is not complete yet, we currently only use the
codec info only on the internal MNCC yet.

Change-Id: I9d5b1cd016d9a058b22a367d0e5e9f2ef447931a
Related: OS#2728
2018-08-07 16:51:30 +00:00
Philipp Maier f913e5f575 a_reset: cleanup + remove dead code
a_reset.c/h was originally developed to be used in both, bsc and
msc without changes. Unfortunately no suitable library has been
found for a_reset.c/h so the file ended up as duplicated code in
both split brances. Eventually we decided to specialize the
generalized code again, which means some of the functions needed
only by osmo-bsc are removed.

- Remove dead code
- Fix timer identification number (T16)
- use fi->priv to hold context info
- Minor cosmetic fixes

Change-Id: I8e489eb494d358d130e51cb2167929edeaa12e92
Depends: libosmocore I36d221c973d3890721ef1d376fb9be82c4311378
Related: OS#3103
2018-05-17 20:14:01 +00:00
Neels Hofmeyr 2a5cd93d8f fix BSC Clear Request
On receiving a Clear Request, don't send a Clear Command "out of band", let the
FSM do the release handling by invoking msc_subscr_conn_mo_close().

Fixes: ttcn3 MSC_Tests.TC_lu_clear_request
Change-Id: I168b889ac7989641cc679b781dcffb87ff13a710
2018-04-11 21:39:44 +00:00
Neels Hofmeyr 4068ab278b properly receive BSSMAP Clear Complete and Iu Release Complete
When sending a BSSMAP Clear or Iu Release, do not immediately discard the conn,
but wait until a BSSMAP Clear Complete / Iu Release Complete has been received.

Hence we will no longer show in the log that an incoming Release/Clear Complete
belongs to an unknown subscriber, but will still be around to properly log the
release.

Related: OS#3122
Change-Id: Ie4c6aaba3866d6e5b98004e8870a215e8cf8ffc1
2018-04-11 21:39:44 +00:00
Harald Welte 0e2fa5dcb5 DTAP: Ensure proper DLCI is used in MSC-originated DTAP
The DLCI field of the DTAP header indicates the SAPI as well as the
data link (main DCCH or SACCH).  We must make sure to use the correct
DLCI when sending DTAP to the BSC.

We achieve this by
* storing the DLCI in the msgb->cb while parsing the DTAP header
* storing the received DLCI (from msgb->cb) in the transaction for
  mobile-originated transactions
* using the trans->dlci to sent msgb->cb when transmitting L3
* filling the DTAP DLCI value from msgb->cb when transmitting DTAP

For MSC-originated transactions, we choose a DLCI value corresponding
to the service (SAPI=0 for CC, SAPI=3 for SMS) and store that in
trans->dlci.

Closes: OS#3150
Change-Id: If511b20f52575054cab1346d99a8cb68d827fdbf
2018-04-09 16:41:10 +02:00
Neels Hofmeyr 93c7463fce unify allocation of gsm_subscriber_connection
The current msc_subscr_con_allocate() was in fact only used by msc_vlr_tests,
while both a_iface_bssap.c and iucs.c did their own duplicate code of
allocating the gsm_subscriber_connection struct. Unify.

Drop the old msc_subscr_con_allocate(), instead add msc_subscr_conn_alloc().
The new function also takes via_ran and lac arguments directly.

The conn allocation will soon be closely tied to the subscr_conn_fsm instance
allocation, so place the new function definition alongside the other
subscr_conn_fsm API, and match its naming ("conn").

Related: OS#3122
Change-Id: Ia57b42a149a43f9c370b1310e2e1f512183993ea
2018-04-05 01:10:32 +02:00
Neels Hofmeyr ae73d2b16f cosmetic: rx_bssmap: read message type once into local var
Instead of referencing msg->l3h[0] all the time, use local variable msg_type.

Related: OS#3122
Change-Id: If70c9fa00edd462d3470bded6eb2c6521e4d9234
2018-04-03 02:12:09 +02:00
Philipp Maier a2f633184b cosmetic: remove unused variable
Change-Id: Ic19d0401557d506d104b82f88b4dcf72055d62e1
2018-03-21 16:23:58 +01:00
Harald Welte 4de011561f a_iface_bssap: Treat inbound RESET as implicit RESET ACK
If both sides are sending RESET at the same time, they are not aware
of each other.  This leads to synchronization problems in wich
the remote side is transmitting e.g. a COMPL L3 INFO after receiving
a RESET ACK, but before even receiving or processing the RESET in
the inverse direction.  So let's treat receiving a RESET as an implicit
RESET ACK to any RESET we may have sent.

Change-Id: I0ae34fbb3735592bb7cffa5aaf421b14a8acc90e
2018-03-18 21:47:15 +00:00
Harald Welte 5060f563c6 BSSAP: Return error code if COMPL L3 with no or too short L3 payload
Change-Id: Ie3bf1351ed11a9eb261737c2da0361e632e7b6e5
2018-03-18 21:55:37 +01:00
Stefan Sperling be7e069810 use libosmocom to parse cell identifier in bssmap_rx_l3_compl()
Use the new gsm0808_dec_cell_id_list2() API to decode the cell
identifier in the bssap COMPLETE LAYER 3 information message.

Also, actually compare the MCC-MNC in WHOLE_GLOBAL and LAI_AND_LAC
cell identifiers to the network configuration, and drop messages
with mismatching MCC-MNC (addresses OS#2980).

Related: OS#2847
Related: OS#2980
Change-Id: I855477507e4d65fb9890da0ceea26dd2c4dfaf82
2018-03-15 10:42:07 +01:00
Neels Hofmeyr 379d5799f0 implement support for 3-digit MNC with leading zeros
Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout
the code base to be able to handle an MNC < 100 that has three digits (leading
zeros).

Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore),
         Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore)
Change-Id: I82f0016d9512ee8722a3489a3cb4b6c704a271fc
2018-02-28 19:30:14 +01:00
Pau Espin 02a79d8545 libmsc: bssap: Remove fixme and properly update msgb tail
Change-Id: I28073efd5cff58cd212341bceee784caf08d5ad8
2018-02-16 13:29:57 +01:00
Pau Espin 75559284d0 libmsc: bssap: Catch TLV parse failures
Change-Id: I1d1951f4a5daf200e85c76fea14a35e952491d27
2018-02-14 14:31:45 +01:00
Pau Espin 31776ff58f libmsc: bssap: Refactor rx paths to to avoid parse_tlv code duplication
Change-Id: I6aef9a94fa5b2e0b62a9c1744b8e18e5985f788f
2018-02-14 14:31:45 +01:00
Pau Espin 9f055f5983 libmsc: bssap: Fix typo in log message
Change-Id: I941cd7f4e9eec3e4f2786100a0e64770d5aee4a7
2018-02-14 14:13:43 +01:00
Harald Welte a172e9e231 a_iface: Fix heap-use-after-free by cleaning up msgb ownership
When we receive a msgb-wrapped primitive from the SCCP provider (stack),
it transfers msgb ownership to us (the SCCP user).  The existing code
passed the msgb ownership down into all the various downstream
functions, which each then had to take care of msgb free'ing.

Not all of the paths did eventually free the msgb.  And at least one
path used data from the primitive *after* the free

Let's restructure this in a way that no msgb ownership is transferred
down the call chain.  Instead, there's one common msgb_free() in
sccp_sap_up().  We can do this as nobody is queueing or otherwise
keeping the msgb.

Change-Id: Ie65616ccb55ec58a0224bbe3c8e004e6029ef3e6
SUMMARY: AddressSanitizer: heap-use-after-free /home/laforge/projects/git/osmo-msc/src/libmsc/a_iface.c:538 in sccp_sap_up
2018-02-09 22:21:20 +01:00
Harald Welte 1f477442dd Introduce new BSSAP logging category/subsystem
Having all BSSAP related logs in the "DMSC" category is overly
generic, and dosn't provide useful granularity.

Change-Id: Id1e52dad03840dfd026fb23f3845a8771c8cc308
2018-02-09 02:22:22 +01:00
Harald Welte c9e7859311 a_iface: Add copyright statement (after recent contributions)
Change-Id: I3f5dedb045a9ae9b93b00a8388a73ed77e67f19f
2018-02-09 02:22:22 +01:00
Harald Welte 35284469b6 cosmetic: a_iface: More logging harmonization
Change-Id: I66139862c4d821fcce0334207ce84fffbd08b4e3
2018-02-09 02:22:22 +01:00
Harald Welte c27ef65796 a_iface: centralize lookup of subscriber_conn
There's little point in resolving the gsm_subscriber_connection in each
and every function handling connection-oriented messages.  We can
resolve it once and dispatch the already-resolved conn into the
function, instead of passing the raw sccp_user and a_conn_info.

Change-Id: Iea85527ea4d4cde7b36cc28a8027362c1570518f
2018-02-09 02:22:22 +01:00
Harald Welte c65d324ea6 cosmetic: No need for 'break' after 'return'
This just makes the code longer with no added benefit.

Change-Id: If689b8284a669021219eff0397c6e90570e2aaa4
2018-02-09 02:22:22 +01:00
Harald Welte fb7ba91907 cosmetic: a_iface: Harmonize log statements
Clean up the log statements in a_iface*.c, which was very inconsistent.
For example "BSC sending" is very confusing.  We are receiving from the BSC,
and it did already send the message, it is no longer in the process of
sending it if we have already received it in the MSC.

Change-Id: Id50e964d86713ae506d4e7657159797e09501d99
2018-02-09 02:22:22 +01:00
Harald Welte 6c3e4e7934 a_sccp_rx_dt(): Don't print hexdump of message multiple times
We don't need to hexdump it in a_sccp_rx_dt() and then again in
rx_bssmap() or rx_dtap().

Change-Id: I2caa8e0af236983430155f9c808de913377d5780
2018-02-09 02:22:22 +01:00
Harald Welte 6de46595f2 a_iface_bssap.c: Use LOGPCONN() whenever possible
Change-Id: Ic1c9d14b892154d51165598338d23a924a772265
2018-02-09 02:22:22 +01:00
Harald Welte f0dc1be95b a_iface: Reduce log levels
During normal operation, regular messages occurring during processing
of a call / transaction should not be higher than LOGL_INFO.

Change-Id: Ibd04ade47b249406696c7d0b660474afc4f4adee
2018-02-09 02:22:22 +01:00
Harald Welte a41b630ae7 cosmetic: Use msgb_hexdump*() rather than manual osmo_hexdump() on msg
This requires libosmocore Change-Id I98e85397fb541ee0fd711f2e1852f63f3bb87359

Change-Id: Ieeb97a9f1eba2fdef84294b8c8c7ac0984ae5c70
2018-02-09 02:22:09 +01:00
Harald Welte 54a10efea0 Don't answer to BSC-originated RESET with another RESET
If the BSC is contacting us for the first time and sending a BSSMAP
RESET, then we should simply ACK that and transition into the
"connected" state, where connection-oriented and connectionless
procedures are permitted.

This patch is a bit large for such a seemingly simple behavioural
change, but the existing data model didn't permit a more
straight-forward implementation.

Change-Id: Ie67e7ed20a6c42afe99bafef96d85a4e083dd057
Closes: OS#2914
2018-02-09 02:20:51 +01:00
Philipp Maier 621ba032bd mgcp: use osmo-mgw to switch rtp streams
in the current implementation we still use osmo-bsc_mgcp, which
has many problems and is also obsoleted by osmo-mgw.

integrate osmo-mgw and re-implement the current switching using
an osmo fsm.

Depends: osmo-mgw Iab6a6038e7610c62f34e642cd49c93d11151252c
Depends: osmo-iuh I3c1a0455c5f25cae41ee19229d6daf299e023062
Closes: OS#2605
Change-Id: Ieea9630358b3963261fa1993cf1f3b563ff23538
2018-02-05 22:28:43 +00:00
Neels Hofmeyr c1d69256f6 cosmetic: rename sccp_rx_udt and sccp_rx_dt to a_*
These rx functions are only used for the A interface, hence the names should
not suggest general SCCP rx (which Iu also has).

Change-Id: I6815c3d4dea4c2abfdff1cf0239ada6a9254f351
2017-12-20 16:14:50 +00:00
Neels Hofmeyr 9baedafa24 a_iface_bssap: compiler warning: cast const away from TLV val for l2h
Change-Id: Id91a4299391ff0d0e4e28ed05c2f755b9702146a
2017-12-18 23:14:58 +00:00
Max 43b01b0514 Remove rest_octets.h
The MSC should not fiddle with low-level SI details like rest octets
anyway. Unfortunately simply removing the header is impossible as it
causes massive fallout due to missing includes. Fixed it as well.

The only other parameter which required removal is cell_ro_sel_par which
is not referenced anywhere in the code anyway.

Change-Id: Ibff77330de056fad4288cd4c48d016aad8105354
2017-09-15 11:31:03 +02:00
Philipp Maier 4502f5ff58 a_iface: fix memory leaks
Fix multiple memory leaske in A/BSSMAP code

Change-Id: I90703c96e6a266a1cfa60b184139375aeb9ae32d
2017-09-11 10:14:00 +02:00
Neels Hofmeyr 6c8afe148b use separated libosmo-mgcp-client, apply rename to mgcp_client_*
After osmo-mgw changes I8e0b2d2a399b77086a36606f5e427271c6242df1 and
I99f7faab637cfcc22ece64a1dbcbe590f2042187, apply linking of new
libosmo-mgcp-client and renames to drop the "gw" from mgcp_client_*.

Also rename the gsm_network.mgcpgw to mgw, to indicate that the MGCP client is
used to contact the MGW (Media Gateway).

Depends: I8e0b2d2a399b77086a36606f5e427271c6242df1 (osmo-mgw)
         I99f7faab637cfcc22ece64a1dbcbe590f2042187 (osmo-mgw)
Change-Id: I093ad02ca0e532f659447c785e09678b3e6f220d
2017-09-08 23:47:37 +00:00
Neels Hofmeyr 9084396467 rename include/openbsc to include/osmocom/msc
Change-Id: I1f96a1285bbd1b4607614856bca935d5c26e2da9
2017-09-06 16:41:25 +02:00
Neels Hofmeyr 00e82d61ab move libiu to osmo-iuh/libosmo-ranap
Remove libiu here, use the functions from libosmo-ranap instead, by applying
the ranap_ / RANAP_ prefix.

Corresponding change-id in osmo-iuh.git is I6a3f7ad15be03fb94689b4af6ccfa828c25f45c0

To be able to run the msc_vlr tests for RAN_UTRAN_IU without Iu client headers
available, add iu_dummy.h, containing mere function signatures that match
iu_dummy.c and a mostly empty struct ranap_ue_conn_ctx.

Make sure we can build with and without --enable-iu: include osmo-iuh headers
only with --enable-iu.

Change-Id: Ib8c4fcdb4766c5e575618b95ce16dce51063206b
2017-08-29 12:51:18 +00:00