13 Commits

Author SHA1 Message Date
Alexander Couzens
d46d0cc368 gtp: add support for SGSN Context Req/Resp/Ack
To handle both incoming and outgoing SGSN Context via GTPv1.
Introduce a FSM which handles the state of SGSN Context to simplify
the API for the SGSN which uses libgtp as well as the external SGSN
which communicates via GTP.

Change-Id: Idb8ed0bb87200a68bb8caedd734fc070df9179c0
2025-07-05 01:20:59 +02:00
Alexander Couzens
a564344d54 gsn: fix coding style issue
Remove a space between callbacks.

Change-Id: I1d978ed32619b626e82aa70887ac94b82c4de378
2025-07-04 22:28:33 +02:00
Alexander Couzens
90309f958a gtpie: make ies const for getter
Getter's don't modify the ie.
Making it const is compatible with previous versions.

Change-Id: I43195314b1cf416a1f2fd4d3ddd48c4eee462b0b
2025-07-04 22:28:33 +02:00
Oliver Smith
34cb772bb4 Generate a version.h file
Related: OS#6626
Change-Id: If3972eb4e56073f8faf58b09d014a811d4a5f401
2025-06-23 16:39:14 +02:00
Alexander Couzens
71fefdad09 gtpie: add gtp_encaps a modern encapsulation method
No idea why the previous ones started at the second IE.
Further add more length arguments to the encapsulation method.

Change-Id: I8bb086c568e07052c52d880df06049490346e91e
2025-01-12 21:03:27 +01:00
Alexander Couzens
446dd65de1 gtp_new(): use talloc instead of calloc/free
Required for SGSN Context Req fsm which is using talloc.
Adds a new api to set the libgtp talloc context via gtp_set_talloc_ctx()

Change-Id: I7c4a29c4bb1ef3c7bf506e59e99b3a804cabe34b
2025-01-07 13:35:54 +01:00
Alexander Couzens
04f5ea4ffa gtp.h: add more GTP cause code from 29.060 v15.3.30
Change-Id: I1571286f01a24adf10243c9551ca81bacc12f8f9
2024-11-25 16:29:08 +01:00
Pau Espin Pedrol
0828b2afc3 gtp: Allow setting callback to receive update_context_ind
This will be used by:
* SGSN: Get to know that RNC has gonne down according to GGSN (re-attempt
  Direct Tunnel or go back to tun SGSN<->GGSN).
* GGSN: Maybe find out that Direct Flags are used (should be handled
  internally directly in the rx path probably)

Related: OS#6512
Change-Id: Ic80a9a928c55b6ff85be96014920bb42793cb943
2024-07-31 17:23:59 +02:00
Pau Espin Pedrol
7ce14f5e93 gtp: Allow tx Direct Tunnel Flags in UpdatePDPCtx{Req,Resp}
In Update PDP Ctx Response, only SGSN is expected to transmit Direct
Tunnel Flags in the message.

Related: SYS#5435
Change-Id: I36d93619e2fe9cafd3092515df18b82d29099d2d
2024-07-31 17:20:54 +02:00
Oliver Smith
519a2e401d gtp/gtp_internal.h: new file
While at it, move internal functions of gtp.h to a separate file too.
Make all functions that are only used inside gtp.c static.

The following APIs are unexpectedly public:
* imsi_gtp2str gets used by pdp.h
* gsna2in_addr, gtp_echo_req gets used by osmo-sgsn

Change-Id: I72c40cbdec33449ca8104fb3cad8df1a9e07dfd7
2024-05-14 11:13:45 +02:00
Oliver Smith
68f5b086ad gtp: remove unused conversion functions
Remove ipv42eua and eua2ipv4, which are in the "internal functions"
section of gtp.h, but are not used anywhere in the code anymore. This is
in preparation of moving the internal functions that are used in
multiple .c files into a separate header file, and to make the other
internal functions static. (Compiler complains about unused static
functions.)

Change-Id: I90e2750f6a6e3e6122e9c562103fda77d7326932
2024-05-14 11:13:41 +02:00
Oliver Smith
bad5eeba0f gtp/gsn_internal.h: new file
Change-Id: I999462e39411fc4ec7e50bd0212e870006fbc4f1
2024-05-13 15:16:58 +02:00
Oliver Smith
1dd16fa12f libgtp: move includes to osmocom/include/gtp
Move all includes from /usr/include/….h to
/usr/include/osmocom/gtp/….h to be more consistent with other Osmocom
projects, and to not "pollute" the top include directory if we add more
header files.

Also the new directory structure makes more obvious, which headers are
public and which ones aren't.

Adjust libgtp.pc.in so both #include <gtp.h> (legacy)
and #include <osmocom/gtp/gtp.h> can be used.

Related: OS#6373
Change-Id: If7e01c61168819bf7120667344e40c857da5490b
2024-05-13 15:16:58 +02:00