Commit Graph

417 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
5b289e83cf GMM: split parsing of a RA Update Request in a separate file
gprs_gmm.c is huge. Further split the general validation
and parsing of the message into an own function.

Change-Id: I413da1b6b4b7c0c4781393acd8564661bc74ce2d
2024-10-22 10:25:51 +02:00
Alexander Couzens
8a2ed97336 move gsm48_gmm_att_tlvdef into gprs_gmm_util
The gprs_gmm.c is huge. Move message parsing into gprs_gmm_util.c.

Change-Id: I67dcdb986fd01dc093501d324b5c376246a5d30d
2024-10-22 10:25:49 +02:00
Alexander Couzens
72283a1686 Refactor diffing same GMM messages
gprs_gmm_attach_req_ies() isn't specific for the attach request.
It also did not cover the full message because of a fixed message length
when comparing both messages.

A diff of the old and new GMM message is required to figure out
if the MS/UE is retransmitting an old message or starting
a new procedure.

Change-Id: Ie698d3a6894a5796663c22c8bfd12b47acda57e6
2024-10-21 20:53:52 +02:00
Alexander Couzens
e7303adc8d Implement correct Routing Area based paging
Previous the SGSN would not support multiple BSS within the
same routing area.
Add support paging of a whole routing area.

Change-Id: I181da9f656e394ccfcb8999021a5b7e13ca0419f
2024-10-21 20:53:52 +02:00
Alexander Couzens
e8c82d9cd1 Add Routing Areas
Add a routing area layer which tracks routing area and
cells within a routing area.

Change-Id: I2474b19a7471a1dea3c863ddf8372b16180211aa
2024-10-21 20:53:52 +02:00
Alexander Couzens
12ed86d17a Replace gprs_ra_id with modern osmo_routing_area_id
The new modern osmo_routing_area_id is more flexible
and allow to access PLMN, LAC more convient.

Depends: Iaef54cac541913534af00f40483723e9952a6807 (libosmocore)
Change-Id: Ia41eb8f51d3836b1bc65325ff1ec6bdb16e20c7e
2024-08-20 14:08:14 +02:00
Pau Espin Pedrol
868d818e6e Fix double free during RAU with unexpected Old RAI
If an MS which had an MMCTX at the SGSN sent RAU update with an
unexpected Old RA field, the RAU was rejected and LLME (LLC layer)
unassigned (freed), because no MMCTX was found matching the wrong old
RA.
However, an MMCTX may actually exist pointing to that LLME, and hence
when the LLME is freed, it stayed unnoticed with a dangling pointer to
the freed LLME in ctx->gb.llme.
Let's try to harder to avoid this kind of bugs which make osmo-sgsn
crash.

Once we properly split the code into separate independent layers (LLC,
MMCTX, etc.) each holding their own structs, this kind of bugs shouldn't
happen anymore.

Related: OS#6441
Change-Id: I5a4328c6e945b85dd815215724feecadba59c435
2024-08-19 18:20:53 +02:00
Alexander Couzens
9650961c4b includes: add forward declartion of external types
Change-Id: Ifbf0a045a6391694155f6627967f2d92b930d765
2024-08-04 19:52:35 +02:00
Alexander Couzens
c05dad1035 includes: sgsn.h: use full path include for gtp.h
The gtp header of ggsn have been moved to osmocom/gtp/gtp.h for a while.
Use the full path to prevent clashs with older versions

Change-Id: I764644110c0f332b18117e1e8311ddc55eafd5fa
2024-08-04 17:44:37 +02:00
Pau Espin Pedrol
7d5337fe80 Handle rx UpdatePDPCtxReq with Tunnel Direct Flags EI=1
GGSN informed us that it received an Error Indication when sending DL data to the RNC.
This probably means the RNC lost its state, aka crashed or was rebooted.
Mark the subscriber as PMM-IDLE, release Iu and point GTPU back to SGSN.
Then page the UE so it hopefully re-creates the state at the RNC.

Related: OS#6512
Related: OS#6519
Related: SYS#5435
Depends: osmo-ggsn.git Change-Id Ic80a9a928c55b6ff85be96014920bb42793cb943
Change-Id: I76d4c387730fdbfb9e7e0dd23a5afb9e762228b1
2024-08-01 11:39:00 +02:00
Pau Espin Pedrol
2cd06e28f4 Announce SGSN own TEID during UpdatePDPCtxReq after UE goes PMM-IDLE
When the UE/RNC closes the Iu conn (while keeping the PDP Context
activated), the SGSN updates the GGSN to point the GTPU tunnel to
itself. Unfortunately, only the IP address was being updated while the
TEID was kept the same (the one from the RNC).

As a result, when new MT data arrived at the GGSN, it would forward it
over GTPU to the SGSN using the incorrect RNC TEID, which the libgtp
stack at osmo-sgsn would silently drop due to not being known (because
it was >PDP_MAX=1024).

The issue can be triggered in test SGSN_Tests_Iu.TC_pmm_idle_rx_mt_data.

Related: OS#5773
Related: SYS#5435
Change-Id: I782aa43c71569922a945bd44544bb1388bf8c878
2024-07-30 21:38:41 +02:00
Pau Espin Pedrol
4ced617eb6 Fix DeactPDPCtxAcc when UE goes PMM ENABLED but lost its PDP context
Scenario: UE activates a PDP context, then after a while goes PMM IDLE
(Iu conn is destroyed but PDP is kept).
When UE connects through Iu again, it sends eg. RAU or ServiceRequest
with pdp_status bitmask statis the active NSAPIs.
If some NSAPI (PDP context) is enabled at SGSN but doesn't show up in
the bitmask, SGSN will destroy the PDP context with GGSN
(DeletePDPContextReq) towards GGSN prior to re-creating it.
When SGSN receives the DeletePDPContextResp, it would forward a
DeactivatePDPContextReq to the UE for a PDP context which was not known
by the UE anymore, this is wrong.

With this patch, the state of the NSAPI/PDP at the UE side is tracked,
and used to know whether when the PDP gets deleted on the GGSN side then
it needs to also be deleted on the Iu side.

Change-Id: I0ccd9228d71c29248b5f510356dbfdb09565dc30
2024-07-30 21:36:01 +02:00
Pau Espin Pedrol
dc4c294f94 gsup: 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.

Change-Id: I0d03d368e73ab62ec631420769f6af91f2ff9987
Related: OS#6091
Depends: libosmocore.git Change-Id 70be3560659c58f24b8db529c4fc85da4bb0ec04
2024-01-29 11:07:03 +01:00
Philipp Maier
e746b0bef6 sgsn_rim: forward message based on RIM ROUTING ADDRESS
At the moment we parse the RAN TRANSPARENT CONTAINER to look at the
destination RIM ROUTING INFORMATION. This is not correct. The SGSN
should not decode the RAN TRANSPARENT CONTAINER and use the RIM ROUTING
ADDRESS / RIM ROUTING ADDRESS DISCRIMINATOR IE to make the routing
decision.

Related: OS#6095
Depends: libosmocore.git Ibca1f08906c4ffeecdae80d4e91c6c7b05fe4f8a
Change-Id: Ifd2b915ed2f05130cff8ee77714b82005c17de3d
2023-09-18 21:53:39 +02:00
Philipp Maier
7840375d51 sgsn_rim: get rid of MME check in sgsn_rim_rx_from_gtp:
There is no point in checking the MME any further. When the message has
reached this code path it is about to be forwarded to BSSGP, so the MME
does not play a role in the following code pathes.

The check also relys on the source RIM ROUTING INFORMATION IE inside the
RAN TRANSPARENT CONTAINER, which we are not supposed to decode.

Change-Id: I97c89aeb11537ae54d1fbea48c75619d8a92af61
Related: OS#6095
2023-08-10 10:23:06 +02:00
Pau Espin Pedrol
86b630cfe1 vty: Introduce encryption cipher-plugin-path command
The load of plugins will eventually be moved to libosmo-gprs
implementation, and path will be passed as a parameter. Once it's moved
inside libosmo-gprs, it will be more strict on load failures, which can
cause internally if the path doesn't exist (unless NULL is passed).
Hence, add a VTY config to allow configuring the right path, and have it
disabled by default.

Change-Id: I4f965c7afafa193f4d7486750dd3e43cca22bb65
2023-01-11 12:58:23 +01:00
Pau Espin Pedrol
93bc518b53 Move global mmctx list into struct sgsn_instance
Change-Id: Idf8458902321da03b9b0831dad3ad383a9c7afa1
2023-01-11 12:58:23 +01:00
Pau Espin Pedrol
58101ea587 Split gprs_sgsn.{c,h} -> {auth,mmctx,sgsn}.{c,h}
Some level of split already existed, like sgsn_auth.c, but headers were
entangled together.
Let's clearly separate application centric code (sgsn.c/h), auth related
code (auth.c/h) and mmctx related code (mmctx.c/h).

Change-Id: I048a082851c1275c959649942904205b02acce2a
2023-01-11 12:58:15 +01:00
Pau Espin Pedrol
6aad14c3fa gtphub.h: Remove dependency on sgsn/gprs_sgsn.h
It is only really needed to import define GSM_APN_LENGTH, which is
actually also available in libosmogsm. Hence simply use the one from
libosmogsm.

Change-Id: I4c6110feeeaa1adfb6b1f0147eeb56dfe34636ec
2023-01-11 12:51:38 +01:00
Pau Espin Pedrol
f44dfa8a0e Rename bscconfig.h -> config.h
Change-Id: I007103be34c1aaab7a9375c44b226d4590fe5b24
2023-01-11 12:51:38 +01:00
Pau Espin Pedrol
e931b39b3c Move LOGGSUBSCRP to gprs_subscriber.h
The define belongs to gprs_subscriber.h header.

Change-Id: Icdb7e55ca8e90dd2ba79ccdb1a8ba650a3942ab3
2023-01-11 12:51:38 +01:00
Pau Espin Pedrol
fd9e82da31 Move sgsn_ctrl_cmds_install() declaration to sgsn.h
sgsn.h is the main header containing all misc app related contents.
This is another step towards shrinking gprs_sgsn.h mess.

Change-Id: I80e3a68e2e368d8c73135c850e4728bdf6cf5f09
2023-01-11 12:51:38 +01:00
Pau Espin Pedrol
f2307c483f Move gtphub header to include/osmocom/gtphub/
Change-Id: I82e1f2a3bc8e22b28747a540879bd661f1704cde
2023-01-11 12:51:38 +01:00
Pau Espin Pedrol
15a52d92c4 Move global pdp_list inside struct sgsn_instance
This way pdp contexts are managed by the lifcycle of the main global struct
sgsn_instance automatically.

Change-Id: I725218fd54adcc68dceded5eb43675f25771bb96
2023-01-11 12:51:38 +01:00
Pau Espin Pedrol
05190c36bb Move sgsn_pdp_ctx to its own file pdpctx.{c,h}
This further shrinks the mess in gprs_sgsn.h, and allows to easily see
layer violations (like pdpctx.c requiring llc.h)

Change-Id: Iad4da06efee7d8514ff48423bdaebc0f26413cc1
2023-01-11 12:51:34 +01:00
Pau Espin Pedrol
164a1eeb8a Move extern declarations of tall_sgsn_ctx to sgsn.h
Change-Id: Ifbd54b2e92db8d4a0e0cd1c569cfd83dd85165b8
2023-01-11 12:43:18 +01:00
Pau Espin Pedrol
69569879ae gtp_{ggsn,mme}: Allocate contexts under struct sgsn_instance
This way apns are managed by the lifcycle of the main global struct
sgsn_instance automatically.

Change-Id: Ie65d59632a368c6957c33dca64e856ace792b2c6
2023-01-11 12:31:23 +01:00
Pau Espin Pedrol
fd4d435442 Move global apn_list inside struct sgsn_instance
This way apns are managed by the lifcycle of the main global struct
sgsn_instance automatically.

Change-Id: I8cc8e540cfb64d0f130e9c0aaedf7b0835f8fe16
2023-01-05 19:37:07 +01:00
Pau Espin Pedrol
8ec269a0e0 Move gtp related functions to gtp.h
The functions are implemented in sgsn_libgtp.c and hence belong to
header file gtp.h

Change-Id: I7f5cf2895b05e03435769548b61051e6284ccb3c
2023-01-05 19:20:43 +01:00
Pau Espin Pedrol
4bd6f663a7 sndcp: Standarize unitdata function naming
Use sndcp_<sap>_type>_<op> so that it's easier to distinguish and
identify them.

Change-Id: Ib8825570a8f61d0a28d631f86f5244e70d3194aa
2023-01-05 19:00:56 +01:00
Pau Espin Pedrol
52c9b8e593 Move func defintions of funcs implemented in gprs_sndcp.c to gprs_sndcp.h
Move them to the correct header where they belong, so that the all the
related protocol stuff is placed together.

Change-Id: I9052f48a0af125bb445194f4ae94ebbe49508fda
2023-01-05 18:57:39 +01:00
Pau Espin Pedrol
51028e2c16 Properly split llc->sndcp->gtp unitdata pathi through extra func call
Beforehand the function handling the LL-UNITDATA primitive from LLC was
already submitting the packet to GTP code which had an SNDCP related
name, so everything was really confusing and layer separation was not
clean.

Change-Id: Ia544a9dd4c0c7647b0c1b64ca110351f40820618
2023-01-05 18:46:23 +01:00
Pau Espin Pedrol
e69f460ae7 sgsn.h: Drop declaration of non existing function
Change-Id: Idabea56d1ff89e51b517b15771a5a1ed3b050ec9
2023-01-05 18:23:03 +01:00
Pau Espin Pedrol
0e707fc83a Move struct sgsn_subscriber_pdp_data to gprs_subscriber.h
The functions driving its lifcyecles are already in gprs_subscriber.c,
and are used mainly by functions in the same file, hence move it to the
related header to further shrink gprs_sgsn.h.

Change-Id: Iff7be91af130a3317d57d3649c17e3d5d2540e7a
2023-01-05 17:48:17 +01:00
Pau Espin Pedrol
ffd6e37eb5 Move struct apn_ctx and APN related definitions to its own file
This allows further shrinking of gprs_sgsn.{c,h} and also being able to
use GSM_APN_LENGTH on different headers easily (needed by follow-up
patch).

Change-Id: Id225ed8b84e1376f4a30f17dd4b153b6b1a6efa8
2023-01-05 17:45:28 +01:00