6813 Commits

Author SHA1 Message Date
Pau Espin Pedrol
1fd205f0b8 ranap: Take into account RNC availability during paging
Avoid transmitting a RANAP paging message to an RNC if we already know
it's not currently available over SCCP.
Take into account that information when deciding/printing whether the
paging could be sent or not.

Take the chance to clean up the iu paging function helpers inherited
from osmo-iuh iu_client.c to better fit the data domain in osmo-sgsn
(iu_rnc).

Change-Id: I24e5446bcf4c958028577230b231960acea9e5b9
2025-09-02 18:55:03 +02:00
Pau Espin Pedrol
b062c3647e stats: Introduce stats sgsn.iu_peers.{total,active}
Change-Id: I51b5227d92027f1251dc4debbbf59737e7c1a9ba
2025-09-02 18:55:03 +02:00
Pau Espin Pedrol
d6c29beaf3 Introduce iu_rnc FSM
This FSM is similar to the already existing ran_peer_fsm in osmo-msc,
which already had better logic around SCCP and RANAP state handling.
Similarly, osmo-sgsn's struct ranap_iu_rnc maps to osmo-msc's struct ran_peer.

With this FSM we can currently track the RANAP link state towards a given
RNC peer:
* Reject (RANAP Error Indication) all UE-related messages until a RANAP
  RESET from RNC is received first.
* Tear down all subsriber connections whenever the RANAP peer sends us a
  RESET message.
* Tear down all subscriber connections whenever the SCCP link towards
  RNC becomes unavailable.
* Send a RESET towards RNC peer once the SCCP link towrdards it becomes
  available again.

This commit only implements so far the Rx path of the FSM, ie. when
receiving events/messages from a peer over SCCP and pushing them locally
up the stack (RANAP). The Tx side will be implemented in a follow-up
commit, which will allow discarding messages if the lower layers towards
a given RNC are known to be down.

Related: OS#3403
Change-Id: I18b7803500163e78ff6a684095194174b0fb6ee1
2025-09-02 18:55:03 +02:00
Pau Espin Pedrol
a24ebc7051 iu_rnc: Introduce helper API iu_rnc_discard_all_ue_ctx()
This is a preparation commit to introduce iu_rnc_fsm in follow-up patch.
The helper API will be used whenever the entire RNC is considered reset.

* Code inside handle_notice_ind() is moved to its own function
  iu_rnc_discard_all_ue_ctx().
* Dependent helper ue_ctx_link_invalidated_free() API is properly
  prefixed/renamed to ue_conn_ctx_link_invalidated_free(), where methods
  for ue_conn_ctx object are placed.
* ue_conn_ctx_find() is properly prefixed/renamed to
  sgsn_scu_iups_ue_conn_ctx_find() and made available to functions in
  other files.

Change-Id: Ie3a4732a85a69d115dd5756bfa64b296e9e5edd2
2025-09-02 18:55:02 +02:00
Pau Espin Pedrol
611b32811e Store scu_iups in iu_rnc instead of ue_ctx
All the ue_ctx belong to a given peer RNC, which holds the SCCP User to
talk to it.

Change-Id: I3969af765b7b0d1375b5e6ad8f3f2e9845f939ef
2025-09-02 18:53:17 +02:00
Pau Espin Pedrol
7673bbd7ad ranap: Create iu_rnc upon rx RESET
RANAP RESET, the first message an SGSN usually receives from an RNC,
contain the GlobalRNC-ID we can already use to register the iu_rnc
object.
This allows keeping track of peers since first message, before first
InitialUE message is received.
Once we start tracking peer RNC state within osmo-sgsn (as we already do
in other osmo-* programs), this will be needed.

Change-Id: Iaf31271feb4d88881382ed8594d0d8e20e22b194
2025-09-02 18:51:43 +02:00
Pau Espin Pedrol
b9c9271a1f ranap: Improve error handling in Rx RESET
* Verify the CN Indicator is set to PS to avoid reacting on content from
  unexpected peers (eg. IuCS). If none is set, be permissive on rx and
  assume PS.

* If GlobalRNC-ID IE is missing, reject the RESET with an Error
  Indication towards the peer to notify about the rejection.
  Same if we couldn't decode properly it.

* Introduce Tx helpers for generic SCCP UNITDATA.req and RANAP Error
  Indication helpers to simplify code and avoid duplication.

Depends: osmo-iuh.git Change-Id I58c75b3e0e0f33f48d077385ffac820a6b2be59e
Change-Id: I2a53e10c3903992a42d081e3ec300fbdb9b3c34c
2025-09-02 18:51:43 +02:00
Pau Espin Pedrol
dfcb514076 iu_rnc: Split iu_rnc_register API into 2 steps
Split lookup+allocation from RAI updating.
This will be needed once we start creating iu_rnc objects upon SCCP
rx RANAP RESET messages, which hold Global RNC-ID but no RAI
information.

Change-Id: I3761cc539c63a7ed680b04bb8136a43d397c10aa
2025-09-02 18:51:43 +02:00
Pau Espin Pedrol
009c25f968 ranap: Reject InitialUE without RAC IE
According to 3GPP TS 25.413 clauses 8.22.2 and 9.1.33,
RAC IE is mandatory in PS domain.

Change-Id: I7d6b996ddf1c5a7cde1bf06b500d3ed19c6090c6
2025-09-02 18:51:43 +02:00
Pau Espin Pedrol
202039ed02 iu_rnc: Use API osmo_sccp_addr_ri_cmp() to compare addresses
Change-Id: I04fb37f28b52da9eecb1f8ea40c38ee3eced1c29
2025-09-02 18:51:43 +02:00
Pau Espin Pedrol
ecaa198fa0 Apply uniform prefix to remaining APIs in gprs_ranap.h
Change-Id: I4f253f35013085bdebf80e94ab0d2f771e40dba6
2025-09-02 18:51:43 +02:00
Pau Espin Pedrol
eb5959f6b9 Split Iu RANAP conn release over different layers
Move and rename functions acting on mmctx to mmctx.{c,h}.
From there, call functions acting on ranap ue_ctx.

Change-Id: I4acdbc857df36b7409c8210d364758192dfdb0bb
2025-09-02 18:51:43 +02:00
Pau Espin Pedrol
c1f2de5790 Split Iu RANAP RAB PS act/deact over different layers
Properly separate logic acting on objects vs logic building and
generating RANAP msg on the wire.

Change-Id: I98788468b7e50619cfd99b3aef2311bb601fb6be
2025-09-02 18:51:43 +02:00
Pau Espin Pedrol
a0203ce7ff ranap: Clean up RANAP rx path param passing
Use the osmo-iuh ranap_cn_rx_*_decode2() APIs directly. This
allows getting rid of extra "ctx" temporary structs and another level of
cb indirection.

Take the chance to update most pointers consitfying them.

Depends: osmo-iuh.git Change-Id I667dc2ef377c1ceb5b11315458f00b282c143c81
Change-Id: Ib3c00b5105b7ba4bb1a2dad1a14bea233a03c358
2025-09-02 18:51:43 +02:00
Pau Espin Pedrol
20d032bdd2 iu_rnc: Constify function params
Change-Id: I288bc21d24aa5abd3d9bd97e796ac9f8590290bd
2025-09-02 18:51:43 +02:00
Pau Espin Pedrol
203676d047 sccp: Introduce helper func sgsn_scu_iups_tx_data_req()
This avoid code deduplication plus moving SCCP SAP logic into sccp.c.

Change-Id: Id34f86b4f5e40ddceac4066ec18ebc60529cafab
2025-09-02 18:51:43 +02:00
Pau Espin Pedrol
265bc33b05 Split most of iu_client.{c,h} into sccp.{c,h} and iu_rnc.{c,h}
* iu_rnc is easily spotted as an object class in the data domain which
  can be put into its own file, handling its specific logic and data.

* SCCP code can also be moved into own specific file, which eases
  self-containment of the layer logic and data.

* As a result, lots of RANAP Rx/Tx code in iu_client.{c,h} can also be
  moved to the already existing gprs_ranap.{c,h}.

All these changes improve a lot readibility of code and makes it a lot
easier to improve/extend the different layers/objects in future patches.

Change-Id: I4c792ae665720460b5a954b5c7cbfe5acbc37473
2025-09-02 18:51:08 +02:00
Pau Espin Pedrol
77cf72ea91 Move gsm0408_gprs_rcvmsg_iu to gprs_gmm.{c,h}
It belongs to that layer, same as existing gsm0408_gprs_rcvmsg_gb()
counterpart.

Change-Id: I09c19689fd7016b76ebeee821b551427965b7cf1
2025-08-27 14:44:34 +02:00
Pau Espin Pedrol
ad61ccd07b debug.h: Remove unused log category DIUCS
It's used nowhere, not even defined in the initialization array of
categories, because IuCS has no place in SGSN.

Change-Id: I0f7c6bedaf3b7f909c3e27175ca99967492ab7c3
2025-08-26 17:51:43 +02:00
Alexander Couzens
02fbdb59c2 Re-introduce Iu/UTRAN support
Add support for UTRAN routing areas.

Change-Id: I1b1aedd2a7c358bd388aa3d8a9f3c6a0011b4889
2025-08-21 23:08:52 +02:00
Alexander Couzens
b1444a6c11 [4/4] iu_client: start using adopted iu_client
Use internal headers.
Use renamed event names/types.

Change-Id: I7c99ad0498c6f885361562c54fcf0ebdc086616b
2025-08-21 18:40:49 +02:00
Alexander Couzens
6043666db5 [3/4] iu_client: hide symbols to prevent clashes
Change-Id: Ide2f7767b90501790a5d609222185918da66336b
2025-08-21 18:40:43 +02:00
Alexander Couzens
6534fdbf27 [2/4] iu_client: rename symbols to prevent clashes with libosmo-ranap
While moving the iu_client into osmoSGSN, it's not allowed to have
the same global symbols in the library as in osmoSGSN.

Change-Id: I2af29b38f110b80f69ef598c8e2700ff323a9d7c
2025-08-21 18:10:25 +02:00
Alexander Couzens
2d4fe639cc [1/4] Adopt iu_client from osmo-iuh
iu_client was original written to have an abstraction
for Iu. However the MSC stopped using iu_client a long
time ago because the abstraption didn't fit well.
There was never time to rewrite SGSN to direct talk RANAP
using the primitives.
Adopt iu_client for now, but with the plan to rewrite
it in a similar way as osmo-msc is doing IuCS.

Adopted from osmo-iuh:
1631c8ac5a2f ("iu_client: fix linter issues")
Related: OS#5487

Change-Id: I9c0d9667ddcb57b52eae34da942acfc1688c1418
2025-08-21 18:10:21 +02:00
Alexander Couzens
4ba6638840 routing area: prefix GERAN functions with geran
Make it easier to understand the purpose
of the functions.

Change-Id: Ic616bd8f9afe6cd3702cd4af08706b7b36987f42
2025-08-06 15:00:40 +02:00
Alexander Couzens
bae75b9a60 BSSGP: reset cells when receiving a Reset on Signal BVC
When a PCU sends a BVC Reset over BSSGP on the Signal BVC,
all cells which has been set up previously via PtP BVCs
has to be removed.

They might be introduced after the Signal BVC reset procedure
has finished.

Change-Id: I380c8f9ef90d8c7face5c380d923ab5168f5b484
2025-08-06 14:46:34 +02:00
Alexander Couzens
c156925405 tests: RA: add test for a GERAN cell to change its BVCI
Change-Id: Idcada8364bf62aae2244b92e0d7a43c120c9c0ad
2025-08-01 17:44:33 +02:00
Alexander Couzens
2422c0375b routing area: sgsn_ra_geran_page_ra: make argument rai const
The second argument mmctx can't made const because of the paging info,
which uses non-const fields.

Change-Id: I21d7e66e433f2b891c94bae91697aa46198fb20c
2025-08-01 17:44:33 +02:00
Alexander Couzens
fec2e5884a routing area: add LOGRA() logging macro
Prepend the routing area in the log message.

Change-Id: Ib287b70c34b21ce64bc864f69fcf6af5fa0698b9
2025-08-01 17:44:33 +02:00
Alexander Couzens
4b894f1a85 routing area: introduce sgsn_ra_find_or_create()
If the RA is the same, return the RA, but if the ran type is different,
return NULL instead of allocating a second RA in the other
RAT.

Change-Id: I6955a09d9d8f3ba4dc3a14d7ed5cd9798d929c61
2025-08-01 17:43:57 +02:00
Alexander Couzens
328edfd6f8 routing area: move cell.cell_id behind a geran union
To prepare for Iu support, use the SGSN RA cell for both,
a GERAN Cell and a UTRAN Service Area.

Change-Id: I0c24d98dd699748842dca271b93e58d27cf02285
2025-08-01 14:27:43 +02:00
Alexander Couzens
9eb1f7e006 use variable name rai for struct osmo_routing_area_id
Be consistent with variable naming if a single
`struct osmo_routing_area_id *` area id is used.

Change-Id: I946983d4857035e06c68af378654466b35025014
2025-08-01 14:25:48 +02:00
Alexander Couzens
f34503289e routing area: introduce ran_type on the RA
A Routing Area should be uniquely identified by the RAI.
Following this, it is forbidden to have a RAI which is valid
in both, GERAN and UTRAN.

Change-Id: I59c35f1a4912ff11574bb31e4fe424816993548c
2025-08-01 14:25:16 +02:00
Alexander Couzens
dda9c6780b ranap: split mmctx related iu events into own function
In preparation of Routing Areas for Iu, split
off mmctx related events into an own function.
All mmctx related events must contain a valid ctx or are
otherwise invalid.

Change-Id: Ie6f131d29da299f09e897240ec5c39a395ce6f1b
2025-07-17 11:42:24 +02:00
Alexander Couzens
234da0eed4 mmctx: LOGIUP: allow ue to be NULL
In certain cases, the ue can be NULL.
E.g. when receiving a new Iu event without a context.

Change-Id: Ie569fa100abe518cb63c1b918ad7748a7ea3bb99
2025-07-17 11:41:35 +02:00
Alexander Couzens
b79797d056 gprs_gmm: fix endianess of GSM48_IE_GMM_PDP_CTX_STATUS
The pdp_status is actually encoded as little endian,
but there is no tlvp_val16le yet.

Change-Id: Ib9bee2f8d0b1f89986d15cf3ce6404ad76378c8c
2025-07-14 17:39:22 +02:00
Alexander Couzens
34182d28a4 GMM: implement IMEI SV on auth/ciph response
The SGSN is requesting the IMEI SV on an auth/ciphering response.
Parse the answer of the MS/UE.

Change-Id: Ia8b428967a4ce3132a4a63ae10fe610de81c3a29
2025-02-17 23:13:43 +01:00
Alexander Couzens
901ca02e0e Assign MME GroupId/Code to remote MMEs
In preparation to route SGSN Context Req/Resp/Ack the SGSN
need to route GTP messages based on the MME GroupId and MME Code.

Change-Id: I881aeba904fb6ca815842d36e466a2459ad81913
2025-02-17 23:13:42 +01:00
Alexander Couzens
944b6dfb8d gprs_gmm_util: use a RAU specific TLV dictionary
Limit the known and allowed TLVs according to the spec.

Change-Id: I460971deeebc9977a984937c542b263d941e78df
2025-01-31 16:44:58 +01:00
Alexander Couzens
27dd6d84ec gprs_gmm_util: add parsing of GMM Attach Requests
This will be used in the following commit.

Change-Id: I4a82e0c4070da982efd6c2f15fd145393423772b
2025-01-31 16:43:43 +01:00
Alexander Couzens
028c299bb2 Add include prefix for all libgtp related includes
The libgtp includes contain all the prefix osmocom/gtp.
The old non-prefix was used in the old OpenGGSN code base.

Change-Id: I5ea50c9766f719e1eea89cbf6783fafc2093773d
2025-01-28 00:17:16 +01:00
Alexander Couzens
d3b037ccfa gprs_ms_net_cap_gea_mask(): protect against empty MS Network Capabilities
When the MS Network Capability is empty, expect to support at least
unencrypted communications.
This shouldn't be empty at all, as the minimum length of it is 2 when
the MS/UE is doing an Attach Request.
But when receiving a MS/UE SGSN Context via Gn, the field
is optional.
The MS/UE shall include it into the Routing Area Request,
but not must.

Change-Id: Ieef2e3eeaaadc90c35fff6f20d47bd36aaa4b9e6
2025-01-28 00:17:15 +01:00
Alexander Couzens
921af3d428 Refactor mmctx_is_r99 into mmctx.c
It is related to the mmctx and should be in mmctx.c instead
of the GMM message parsing or handling.

Change-Id: I198a3c9d49667c70e8995808b3fcb5ea26e8f17a
2025-01-28 00:17:15 +01:00
Alexander Couzens
0e8f055631 GMM: rework PDP context status
Use an uint16 instead of an pointer with an unknown length.
Also encode the current active PDP context (e.g. on 2G/4G
mobilty this could change). It resynchronizes the UE with the SGSN
state.

Change-Id: I12d3110c9365132f96ef7ff8a1be22a431682c81
2025-01-28 00:16:53 +01:00
Pau Espin Pedrol
df44350b4b jenkins.sh: No need to build libosmo-sigtran with doxygen
Change-Id: Iab3d1b2e1591e66702a01def6c322f4a11970ead
2024-12-10 16:52:17 +01:00
Pau Espin Pedrol
7a45b57485 sgsn_vty: Drop unneeded use of abis/ipa.h header
The header is not needed and will eventually be deprecated.

Change-Id: I48a513b8ea63dadbc6d6d571380980f55ff04a06
2024-12-10 14:37:31 +01:00
Alexander Couzens
7d94476bde GTP: CreatePDPContext: only use IMEISV IE when IMEISV is known
The IE is optional, but if it is present, it must be 11 byte long
containing a 8 byte IMEISV. If IMEI is unknown the SGSN
would add an empty IMEISV IE which is invalid.

Change-Id: I812af1e702e77214244f32ae65663c1a03b23962
2024-12-05 12:28:05 +00:00
Pau Espin Pedrol
6668b2b29a vty: Avoid accessing gsupclient object fields directly
Use new APIs recently added.

Depends: osmo-hlr.git Change-Id I401af83232022f1c141eef1f428cbe206a8aaaa2
Change-Id: Ie443ef0bd983635a5b29e434d79b93ef3f7ce370
2024-12-03 14:32:57 +01:00
Pau Espin Pedrol
b69e326e69 gmm: Fix reject small size RAU request
A RAU Request can actually be 14 bytes long:
"""
GSM A-I/F DTAP - Routing Area Update Request
    Protocol Discriminator: GPRS mobility management messages (8)
        .... 1000 = Protocol discriminator: GPRS mobility management messages (0x8)
        0000 .... = Skip Indicator: No indication of selected PLMN (0)
    DTAP GPRS Mobility Management Message Type: Routing Area Update Request (0x08)
    Update Type
        .... 0... = Follow-on request pending: False
        .... .000 = Update type: RA updating (0)
    Ciphering Key Sequence Number
        0... .... = Spare bit(s): 0
        .111 .... = key sequence: No key is available (MS to network) (7)
    Routing Area Identification - Old routing area identification - RAI: 262-42-13135-0
        Routing area identification: 262-42-13135-0
            Mobile Country Code (MCC): Germany (262)
            Mobile Network Code (MNC): Vodafone GmbH (42)
            Location Area Code (LAC): 0x334f (13135)
            Routing Area Code (RAC): 0x00 (0)
    MS Radio Access Capability
        Length: 4
        MS RA capability 1
            0001 .... = Access Technology Type: GSM E --note that GSM E covers GSM P (1)
            .... 0001  111. .... = Length in bits: 0x0f (15)
            ...0 01.. RF Power Capability, GMSK Power Class: Not specified (1)
            A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0)
            .... ...1 = Controlled early Classmark Sending: Implemented
            0... .... = Pseudo Synchronisation: Not Present
            .0.. .... = Voice Group Call Service: no VGCS capability or no notifications wanted
            ..0. .... = Voice Broadcast Service: no VBS capability or no notifications wanted
            ...1 .... = Multislot capability struct: Present
                HSCSD multislot class: Bits are not available (0)
                GPRS multislot class: Bits are not available (0)
                SMS_VALUE (Switch-Measure-Switch): Bits are not available (0)
                ECSD multislot class: Bits are not available (0)
                EGPRS multislot class: Bits are not available (0)
                DTM GPRS Multi Slot Class: Bits are not available (0)
"""

Change-Id: I49210a04b16e6e2fc9d799b99c2fa415f28ddbba
2024-11-25 19:10:12 +00:00
Pau Espin Pedrol
11854f52ac jenkins.sh: libosmo-netif no longer depends on libosmo-abis
Change-Id: Id62040f41e9a5c233cc42eedb0bd5df9f62df418
Depends: libosmo-abis.git Change-Id I079dc3999de508301dd37ed03e399356a58d3cab
Depends: libosmo-netif.git Change-Id I13d6e88158f6d9ce017986283183ee9c2cc68cae
2024-11-21 14:54:24 +01:00