Commit Graph

98 Commits

Author SHA1 Message Date
Pau Espin 28dd01ed25 rlcmac: Support extending log categories in the future
An initial header structure and LOG defines is created in a similar way
to those already existing for libosmo-gprs-llc and sndcp.

Related: OS#5500
Change-Id: Ic9ba207cafeada1b174f1b085e0d1d9a38c66b0a
2023-01-25 23:33:57 +01:00
Pau Espin 9a416a53fa llc: Fix spec references pointing to SNDCP instead of LLC
Change-Id: Ibe20dfcce937deb83fda2b114133173e47682cf7
2023-01-25 18:16:37 +01:00
Pau Espin c0ba710d6b llc: Initial support for GRR-UNITDATA.ind/req
This allows forwarding GRR-UNITDATA.ind/req up & down the stack, to be
on pair with the BSSGP LLC SAP.

Change-Id: I6a4454b4aa2c96e1f4ce7e2a5d5aba8ec1cf3f60
2023-01-23 20:56:41 +01:00
Pau Espin 847a26d45a sndcp: Fix missing dep link against libmath
It is already present in libosmo-gprs-sndcp.pc.in Libs.private, but it
was forgotten at compile time.
That makes it fail under some systems when linking against it (like jenkins):
/build/deps/install/stow/libosmo-gprs/lib/libosmo-gprs-sndcp.so: undefined reference to `ceil'

Change-Id: Iba9629b323b50b28cc4c54cf35b2e39ee89bc192
2023-01-17 14:33:11 +01:00
Pau Espin 94dfdc8bfd llc: Allow app provided callbacks to retain ownership of passed primitive
This way the app can, for instance, simply forward the primtiive pointer
from LLC callback to SNDCP layer, which will in the end take the
ownership of the primitive and free it.

Change-Id: I6ea91b8f190a399c4bcf6c7cba9a65809aaf3ddb
2023-01-12 15:38:32 +01:00
Pau Espin df5a72f556 llc: Log error loading gprs chiper plugins
Change-Id: Ie0438b444c2aff8991736806256fb67b59ee8bcc
2023-01-12 15:38:32 +01:00
Pau Espin f4256b74d3 sndcp: Initial support for async SN-XID.ind and SN-XID.rsp
Before this patch, the response was being crafted synchronously through
a direct function call. This patch provides initial support to trigger
the primitives so that the application using the SNDCP layer can handle
the indication and submit a response.
The different XID L3 params are still not being passed to the app, that
will be done in a subsequent patch.

Change-Id: I0a5069fd3dc0d6c3dd28aeae09b51c49dd8be92d
2023-01-12 15:38:32 +01:00
Pau Espin 80a74d3a4c sndcp: Fix wrong prim op passed in osmo_gprs_sndcp_prim_alloc_sn_xid_rsp()
Change-Id: I0644bf481c06a2cfc1d9f57995eefedf36e8b839
2023-01-12 15:38:16 +01:00
Pau Espin 9a425c8070 sndcp: Fix wrong field used printing nsapi
Change-Id: If16665af02369fcb8da8e996ba17f11d8987956e
2023-01-09 14:38:33 +01:00
Pau Espin 03287fe673 tests/llc: Test gprs_llc_is_retransmit()
Imported from osmo-sgsn.git 4398ac073b7fc8363882b5f7414470b73d4f446a
./tests/gprs/gprs_test.c.

Change-Id: I4104ee9cc458b7d169ee9761e02369442058675a
2023-01-04 14:54:04 +00:00
Pau Espin 24a100bac8 sndcp: Initial libosmo-gprs-sndcp support
This commit follows a similar approach to Change-Id
I588eb576b2703262f4ab9566ec362920d8390cfd, this time targeting the SNDCP
layer, creating a new library for it.
This new library depends on headers from libosmo-gprs-llc since the
SNDCP spec takes the interface towards lower interfaces from same
llc_prim. It doesn't really call any API from the libosmo-gprs-llc
library to dispatch the primitive, that's left for the application, so
that it can be reused against other implementations.

Most of the SNDCP data structures and APIs are kept private and used
only internally. The Higher/lower layers are expected to interact with
it through the sndcp_prim API.

This commit also implements some of the code paths of the public API by
means on importing SNDCP code from osmo-sgsn.git commit
57b63875c762a784127a13becd1c2549ca6c5454.
The import of code cannot be done in a separate commit since existing code
in osmo-sgsn.git is low quality and has tons of layer violations in all
directions.
Hence, this commit aims at being an initial point of having some working
SNDCP stack by means of a few unit tests, but by no means aims to be a
total working implementation. Some code paths are missing; bugs are
expected at this point.

Change-Id: Ie05b5d721cf0a6147ed45c1feb75ad829865252b
2023-01-04 14:54:04 +00:00
Vadim Yanitskiy fc11417ce6 tests/rlcmac: make linter happy: use const char * const
Change-Id: I26748681d13441fdfb9c46d9a476ea669b308ff7
2023-01-03 00:27:38 +07:00
Vadim Yanitskiy 36a6ff60f0 rlcmac: rename s/SI_13_t/SI13_RestOctets_t/
Change-Id: I74ed534b9b52b70cdf8e4e2d4d960bb1d9aaf27b
2023-01-02 12:56:38 +00:00
Vadim Yanitskiy 79a945feba rlcmac: use OSMO_ASSERT instead of plain assert()
Change-Id: Ia834285cbaba34e2f0783bf83bd2f3934d74d778
2023-01-02 12:56:38 +00:00
Vadim Yanitskiy 3095b63610 rlcmac: remove unneeded includes
Change-Id: Ie82fb9e5fe607f925bb8a698a789ef79f168add2
2023-01-02 12:56:38 +00:00
Vadim Yanitskiy caef6c1b13 rlcmac: implement the missing IA_MultiBlock_PktDlAss_t
Add missing definition for the <Multiple Blocks Packet Downlink
Assignment> structure.  It's not 100% complete, but should serve
a good starting point if we ever need to support this.

Change-Id: I544245f690fdd14a94f858a5f3cd8f8d39d17611
Related: OS#5500
2023-01-02 12:56:38 +00:00
Vadim Yanitskiy d2edff76d0 rlcmac: rename s/IA_EGPRS_00_t/IA_EGPRS_PktUlAss_t/
Use a self-explanatory name instead of the one with magic numbers.
It's safe to rename it because this API is not used anywhere yet.

Change-Id: I884cba359bfda21cf45fa846e5b7ff20d129bdf7
Related: OS#5500
2023-01-02 12:56:38 +00:00
Vadim Yanitskiy 376f2a1297 rlcmac: fix coding of EGPRS Packet Uplink Assignment in IA RestOctets
Thanks to the unit tests, it was found that decoding of the LH part,
specifically the EGPRS Packet Uplink Assignment structure, is done
incorrectly.  This patch fixes incorrect decoding.

Double usage of the UnionType element in the IA_EGPRS_t has a side
effect: the M_UINT actually consumes one bit, so the remaining bit
stream is shifted and decoded incorrectly.

Replace a combination of M_UINT and M_CHOICE with two M_UNIONs.
Remove struct IA_EGPRS_t, which is not used anywhere yet.

For reference, see 3GPP TS 44.018, table 10.5.2.16.1.

Change-Id: I7fedbad1ac4d744d1d3941553e573d4202e9d24a
Fixes: I39a29dc9b5b22ce4374ae33336696014e326d012
Related: OS#5500
2023-01-02 12:56:38 +00:00
Vadim Yanitskiy 84b385d15c rlcmac: add decoder and test vectors for IA Rest Octets
This new API is needed for the MS side GPRS implementation in order
to be able to establish an Uplink TBF.  Both wireshark and osmo-pcu
rely on hand-written code for parsing and generating the IA Rest
Octets IE, making no use of the CSN.1 codec.

We already have some (mostly commented out) CSN.1 definitions needed
for decoding the IA Rest Octets IE, inherited as-is from wireshark.
Ths patch adds the missing bits and a few unit test vectors.

Note that decoding of the LH part, specifically the EGPRS Packet
Uplink Assignment structure, is currently done incorrectly because
there is a problem in the IA_EGPRS_t definition.  This will be
fixed in a follow-up patch.

For reference, see 3GPP TS 44.018, table 10.5.2.16.1.

Change-Id: I39a29dc9b5b22ce4374ae33336696014e326d012
Related: OS#5500
2023-01-02 12:56:38 +00:00
Pau Espin 0d9bbbc7e5 osmo_gprs_llc_bssgp_prim: cell_id is always RAI + CI
As per what's specified in 3GPP TS 48.018 section 11.3.9 Cell
Identifier.

Change-Id: I1efcdbe3e42be35e191bcb1ae513c768d63096aa
2022-12-23 18:03:00 +01:00
Pau Espin f2c6bb980d llc: Initialize gprs_cipher
Change-Id: Ifac6239a3695b69f694eb55574de64a62b0787ed
2022-12-23 13:32:44 +01:00
Pau Espin 91c87d6907 llc: Proper separation of public & private APIs, Introduce llc_prim API
Most of the existing (and added) data structures are kept private, since
most of those don't really need to be used outside internal code in the
library.

Most if not all the interaction from upper and lower layers  towards LLC
is now done through the new llc_prim pubic interface. This interface is
based on 3GPP TS 44.064 section 7.1.2.

This commit also implements some of the code paths of the public API by
means on importing LLC code from osmo-sgsn.git commit
57b63875c762a784127a13becd1c2549ca6c5454.
The import of code cannot be done in a separate commit since existing code
in osmo-sgsn.git is low quality and has tons of layer violations in all
directions.
Hence, this commit aims at being an initial point of having some working
LLC stack by means of a few unit tests, but by no means aims to be a
total working implementation. Some code paths are missing; bugs are
expected at this point.

Related: OS#5502
Change-Id: I588eb576b2703262f4ab9566ec362920d8390cfd
2022-12-21 04:49:08 +07:00
Pau Espin f6e4b3be4c llc: rework logging, add LOGLLC macro
Change-Id: I8ad3267f890a21b6c935b36b256b00bd0a4da8d6
Related: OS#5502
2022-12-21 04:49:08 +07:00
Pau Espin 9f7a142868 llc: split up enum osmo_gprs_llc_prim_type
Change-Id: Ic5b7a2fb8d028a6e2031fb805189be4e92d80b9f
Related: OS#5502
2022-12-21 04:49:08 +07:00
Pau Espin 05a16204f9 llc: add enum osmo_gprs_llc_{location,prim_sap}
Change-Id: I5606c0b41196f25adbc00cfdce9927daaed9a901
Related: OS#5502
2022-12-21 04:48:19 +07:00
Pau Espin 1868001ee0 llc: add libosmogsm dependency
libosmogsm is needed for the follow-up patch [1].

Change-Id: Iee45fb87905ea29df02a48003396bde27e6c550c
Related: [1] I588eb576b2703262f4ab9566ec362920d8390cfd
Related: OS#5502
2022-12-21 03:46:08 +07:00
Pau Espin 3681629a29 llc: libosmo-gprs-llc.pc.in: add 'Requires.private: talloc'
This is needed for the follow-up patch [1].

Change-Id: Ie8ba61b124585e55accdaf2713b72e3ace78772f
Related: [1] I588eb576b2703262f4ab9566ec362920d8390cfd
Related: OS#5502
2022-12-21 03:45:41 +07:00
Pau Espin 384172005c llc: fix typo: OSMO_GPRS_LLC_SAPI_SNDCP{12->11}
Change-Id: Icee190d0e20044d3808a8b1beb237a987a795d8e
Related: OS#5502
2022-12-21 03:16:08 +07:00
Vadim Yanitskiy 4f1ee42c60 Add -Werror=implicit-int -Werror=int-conversion -Werror=old-style-definition
... if --enable-werror is used

Change-Id: I6d37291f66afacfc2d9cb7133f7240bbf87c0003
2022-11-05 03:52:41 +07:00
Vadim Yanitskiy 9987fd5592 contrib/jenkins.sh: build with --enable-werror
Change-Id: Ib61a8b464ae55ef055a3ea5a0de9b6b2d4a9044b
2022-11-05 03:52:35 +07:00
Vadim Yanitskiy 7768003cce tests/rlcmac/ts_44_018_test: do not depend on libosmogsm
Header file <osmocom/gsm/protocol/gsm_04_08.h> belongs to libosmogsm.
However, file 'contrib/libosmo-gprs.spec.in' does not list this lib
as a build dependency.  So building the RPM package currently fails.

We could have listed libosmogsm as 'BuildRequires', but given that
the only thing we use from this lib is the GSM_MACBLOCK_LEN macro,
there is no real need to depend on it.

Change-Id: Ieac350e7a05965c64e8ccf8dd17a569f0afd9514
2022-10-11 04:28:18 +07:00
Vadim Yanitskiy 4c624aaff8 tests/llc/pdu_codec_test: use const char * const
Not really important, just makes the linter happy.

Change-Id: I9b952b05fed11f26d2839314270e2862db3d036a
2022-09-28 23:01:16 +07:00
Vadim Yanitskiy 1880e28bbc llc: implement Exchange Identification (XID) codec
Change-Id: I16b3f7ab82c489144098aad0dccc4c67d8382c67
2022-09-28 23:01:16 +07:00
Vadim Yanitskiy 11d55e8fc4 llc: add missing enum osmo_gprs_llc_xid_type values
See 3GPP TS 44.064 version 16.0.0 Release 16, table 6.

Change-Id: Ifdca0c742727a030008a01848153c23e0e0017bd
2022-09-26 17:12:34 +07:00
Vadim Yanitskiy ed231df931 llc: add value-string for enum osmo_gprs_llc_xid_type
Change-Id: I90b6a1aa4e13984f4c43245df1308d0c3f82636f
2022-09-26 17:12:34 +07:00
Vadim Yanitskiy 38dce83bf6 llc: fix warning: 'struct msgb' declared inside parameter list
Change-Id: Idecb64f4838106a166f6a5cba5536a61de71c152
2022-09-26 17:12:34 +07:00
Vadim Yanitskiy ea26c243fc .gitignore: add missing debian/libosmo-gprs-llc*
Change-Id: I31ad48b75a5e2dfdce05731ab90146d66c776581
2022-09-26 17:12:34 +07:00
Vadim Yanitskiy 0b5a816356 llc: make logging category configurable
Similar to Icfef6de126304da81120f1d7b212992ead3409aa, let's add
osmo_gprs_llc_set_log_cat() allowing the API users to change
logging category for libosmo-gprs-llc (DLGLOBAL is default).

Change-Id: I9deb794db1c80257ba81523f815232208381bc27
2022-09-22 01:54:07 +07:00
Vadim Yanitskiy 22189e7329 llc: add definitions of service primitive parameters
Change-Id: Iaa520a818b05c962e0d3be9607d3a8c5991f539e
2022-09-22 01:02:21 +07:00
Vadim Yanitskiy f981c629d5 llc: rename enum osmo_gprs_llc_{primitive->prim_type}
Change-Id: Ie0f9cd174934c54940217b89e46568a7c1b76b96
2022-09-22 01:02:21 +07:00
Vadim Yanitskiy 4a108f3a89 llc: separate enum osmo_gprs_llc_primitive to llc_prim.h
Change-Id: Ida9ce56f48474313064d798ea7b9a72e9b99bb8d
2022-09-22 01:02:21 +07:00
Vadim Yanitskiy 19799d106e tests: reorganize llc/rlcmac specific dirs and files
Change-Id: I8592cea020dbbf64940266cd6af14b14d34be3a6
2022-09-22 01:02:21 +07:00
Vadim Yanitskiy 76ac335541 llc: osmo_gprs_llc_hdr_dump[_buf](): also print SAPI name
Change-Id: I95763e622bb3c3678c06901ddaecfc200d359d8d
2022-09-22 01:02:21 +07:00
Vadim Yanitskiy 0963447322 llc: add struct value_string osmo_gprs_llc_sapi_names[]
Change-Id: I8ae048ab9e6b63697951fa3f74ce671c88328f5f
2022-09-22 01:02:21 +07:00
Vadim Yanitskiy c892acda1f llc: re-define value-string API as static inline functions
Using static inline functions allows for type checking at compile-time.

Change-Id: I1b3245f62f5182aa91dbad7958d89220f7107337
Fixes: I6d0e1a878fb80c57a901da08798620a6ea4471a4
2022-09-22 01:00:37 +07:00
Vadim Yanitskiy c1ca5406bc llc: implement LLC PDU codec based on code from osmo-sgsn.git
osmo-sgsn.git 13ccbc1e6120fe78f6f9f950d7242090920ca41b

Change-Id: I61d7e2e6d0a8f2cdfc2113e637e447dc428cc70d
2022-09-22 00:56:15 +07:00
Vadim Yanitskiy bae1ec285b llc: add -export-symbols-regex '^osmo_' to CFLAGS
Change-Id: I7fac3ef730ea4b2719002dd61289b22c424f43f4
2022-09-18 20:45:44 +07:00
Vadim Yanitskiy 4762fcc885 llc: import FCS (CRC24) calculation API from osmo-sgsn.git
osmo-sgsn.git fb6cf3221ef4989441c09a650011e4a334c37d12

Changes made:

* Add 'osmo_' prefix to gprs_llc_fcs(),
* osmo_gprs_llc_fcs() takes size_t and returns uint32_t,
* crc24_calc() takes size_t.

Change-Id: Ib4465c289d9ef2a1b8ef5730c559bc799bb1f012
2022-09-18 20:45:44 +07:00
Vadim Yanitskiy fcd76ba2d1 llc: add definitions from 3GPP TS 44.064 section 6.4
Change-Id: I6d0e1a878fb80c57a901da08798620a6ea4471a4
2022-09-18 20:45:44 +07:00
Vadim Yanitskiy 8ab2897836 llc: add missing LLE <-> (RLC/MAC,BSSGP) primitives
3GPP TS 44.064, section 7.1.2, Table 7: "LLC layer service primitives".

Change-Id: I10bb63220585424584185ce2bde2d9f8fd0d8342
2022-09-18 20:45:44 +07:00