Commit Graph

4454 Commits

Author SHA1 Message Date
Vadim Yanitskiy 94e0af0a6d doxygen: also generate documentation for libosmo{sim,usb}
We do have API documentation for all libraries, excepte these two.

Change-Id: I2ec5803bc219b9ceaf0d52d41a03ab78f580e689
2023-02-27 11:14:40 +00:00
Vadim Yanitskiy 85e24a6410 debian/control: fix typo
Change-Id: Ia9f99016dcf2a9584b59a253d19f391e8f5e5abb
2023-02-27 11:14:40 +00:00
Vadim Yanitskiy dbd61f077f debian/control: make libosmocore-doc depend on libosmo{ctrl,gb}-doc
Change-Id: Icd84afcd035bdca9aabb4ea2b91c1227c4786da7
2023-02-27 11:14:40 +00:00
Vadim Yanitskiy 7184511754 gsm: use OSMO_ASSERT() in osmo_iuup_msgb_alloc_c()
This patch is a preparation for the upcoming change making use of
the built-in static_assert(), which is available since C11.

When using built-in static_assert(), gcc v12.2.1 fails:

iuup.c: In function 'osmo_iuup_msgb_alloc_c':
iuup.c:194:33: error: expression in static assertion is not constant
  194 |         osmo_static_assert(size > IUUP_MSGB_HEADROOM_MIN_REQUIRED, iuup_msgb_alloc_headroom_bigger);
../../include/osmocom/core/utils.h:86:24: note: in definition of macro 'osmo_static_assert'
   86 |         static_assert((exp), "(" #exp ") failed")
      |                        ^~~

This one is not really a *static* assert(), because it operates on the
user supplied argument 'size', which is not guaranteed to be an integer
literal.  Neither it triggers a compilation failure as expected, nor
does it abort at run-time.  It simply does nothing.

Change-Id: I53db679728250e0c60ed277efb18142073ffe9c4
2023-02-27 09:58:46 +00:00
Vadim Yanitskiy 22ade291ad msgb: use OSMO_ASSERT in msgb_alloc_headroom[_c]()
This patch is a preparation for the upcoming change making use of
the built-in static_assert(), which is available since C11.

When using built-in static_assert(), gcc v12.2.1 fails:

include/osmocom/core/msgb.h: In function 'msgb_alloc_headroom_c':
include/osmocom/core/msgb.h:532:33: error: expression in static assertion is not constant
  532 |         osmo_static_assert(size >= headroom, headroom_bigger);
include/osmocom/core/utils.h:86:24: note: in definition of macro 'osmo_static_assert'
   86 |         static_assert((exp), "(" #exp ") failed")
      |                        ^~~
include/osmocom/core/msgb.h: In function 'msgb_alloc_headroom':
include/osmocom/core/msgb.h:554:33: error: expression in static assertion is not constant
  554 |         osmo_static_assert(size >= headroom, headroom_bigger);
include/osmocom/core/utils.h:86:24: note: in definition of macro 'osmo_static_assert'
   86 |         static_assert((exp), "(" #exp ") failed")
      |                        ^~~

These are not really *static* assert()s, because they operate on the
user supplied arguments 'size' and 'headroom', which are not guaranteed
to be integer literals.  Neither they trigger compilation failures
as expected, nor do they abort at run-time.  They simply do nothing.

Change-Id: I17ef4f3283ce20a5b452b7874c826acfb02a0123
2023-02-27 09:58:46 +00:00
Harald Welte 65e0edc73f convolutional coding for CSD
This patch adds the convolutional code definitions for CSD (circuit
switched data) on TCH/F channels with user bit rates of 2400, 4800, 9600
and 14400 bps.

Related: OS#4396, OS#1572
Change-Id: I412131d7ee2e676402bf8d88394af17c4447b664
2023-02-25 19:37:44 +01:00
Vadim Yanitskiy 7b9b3074a2 gsm/{bsslap,bssmap_le}: zero-initialize structs using memset()
In the unit tests we're using memcmp() to compare decoding results
against the expected results.  This is a reasonable approach, but
there is a pitfall: not only the struct fields are compared, but
also the padding bytes preceding/following them.

When using gcc's extension zero-initializer {} or even the standard
approved { 0 } zero-initializer, padding bytes are not guaranteed
to be zeroed.  Even worse, according to [1], the init behavior is
inconsistent between gcc and clang and optimization levels.

All decoding functions in {bsslap,bssmap_le}.c currently use gcc's
extension zero-initializer {}.  This is not a problem when building
with CC=gcc, but with CC=clang the bssmap_le_test fails due to
mismatch of padding bytes in struct lcs_cause_ie:

  [4] PERFORM LOCATION RESPONSE: ERROR: decoded PDU != encoded PDU
  [5] PERFORM LOCATION RESPONSE: ERROR: decoded PDU != encoded PDU
  [6] PERFORM LOCATION ABORT: ERROR: decoded PDU != encoded PDU

Out of the known struct initialization methods, only the memset()
has consistent behavior and sets all bytes to zero, including the
padding ones.  Using it fixes the bssmap_le_test for CC=clang.

[1] https://interrupt.memfault.com/blog/c-struct-padding-initialization

Change-Id: Ib16964b16eb04315efc416164ed46c15b5dc7254
Fixes: OS#5923
2023-02-25 08:15:11 +00:00
Philipp Maier 6b69b554f7 i460_mux: add define constant for maximum number of subchannels
Lets get rid of the magic number in struct osmo_i460_timeslot and
replace it with a define constant.

Change-Id: Id3a3782927c7dcbc873223d56129f291c04fee26
Related: OS#5198
2023-02-24 13:38:22 +00:00
Vadim Yanitskiy 82001ebc2a gsm: ensure completeness of osmo_bts_features_{descs,names}[]
It already happened several times [1][2] that new features were added
to enum osmo_bts_features, but the osmo_bts_features_{descs,names}[]
were left unchanged.  Let's add static_assert()s to prevent this.

Change-Id: I8e3b7d3996e9f3e16c6d4e0d1d406fa538d5e9be
Related: [1] f4f5d54ea2
Related: [2] 18c6a8183f
2023-02-24 17:06:21 +07:00
Vadim Yanitskiy f4f5d54ea2 gsm: add missing features to osmo_bts_features_names[]
Change-Id: I0ff47a79d611cd1c2d23ac5b4d53dca27e402821
Fixes: 812dfbf3a7
2023-02-24 16:28:05 +07:00
Neels Hofmeyr ba1e20055f add osmo_prim_operation_name()
Also remove the explicit array dimension from the .h file.

Change-Id: I9f43428af654a5674ac3035fe4db1394aac7a7af
2023-02-22 16:45:14 +00:00
Harald Welte 9b7c9ae6ca Rename OSMO_AUTH_ALG_XOR to OSMO_AUTH_ALG_XOR_3G
Let's disambiguate.  Our existing OSMO_AUTH_ALG_XOR was always only
the XOR-3G algorithm.  Now that we recently introduced XOR-2G,
let's rename (with backwards compatibility #define).

Change-Id: I446e54d0ddf4a18c46ee022b1249af73552e3ce1
2023-02-22 09:45:15 +01:00
Harald Welte 4cc60a166c New unit test for XOR-2G authentication
Let's test if the XOR-2G algorithm does what it's supposed to do.

Change-Id: I7014258751624ff18c51912b6348c3cd876bb23f
2023-02-22 09:45:11 +01:00
Harald Welte e93c5e99b6 Implement the XOR-2G authentication algorithm
We've so far only been supporting XOR-3G algorithm as specified
in TS 34.108 (in both 3G and 2G-derivation mode).

However, XOR-3G used for 2G auth is different from the XOR-2G algorithm
as defined in Annex A of TS 51.010-1.  Let's add support for that one,
too.

Change-Id: I0ee0565382c1e4515d44ff9b1752685c0a66ae39
2023-02-21 22:25:04 +01:00
Oliver Smith 8d9ed738a7 tests: add test_gsm0808_enc_dec_channel_type_sign
Verify that we have the spare byte when encoding the signalling type.

Related: OS#5911
Change-Id: Ied6e451d2e884412104cd9d530d0cd1b39f17f27
2023-02-21 08:17:42 +00:00
Oliver Smith dcaab85795 gsm0808_dec_channel_type: fix dec of ch_rate_type
According to 3GPP TS 48.008 V16.0.0 § 3.2.2.11, the "Channel and rate
type" fills the whole octet 4, so don't cut it off.

This fixes decoding of e.g. GSM0808_SIGN_FULL_PREF_NO_CHANGE, which I
noticed while writing a test.

Related: OS#5911
Change-Id: Ib5fba18eb82736c4f52f315ae1197159b7090e69
2023-02-21 08:17:42 +00:00
Pau Espin 2bb8a1219c libosmogb.pc.in: Fix missing dependency on libosmogsm
Change-Id: I5efa04d1c5cabc65b42de624b26fdbf9ebe746b1
2023-02-20 12:21:30 +01:00
Pau Espin 0158b05337 Move libosmogsm TS 44.060 declarations under include/osmocom/gsm/
Currently there's a big mess where include dir osmocom/gprs/ is used by
both libosmogsm and libosmogb.
Most of the header files under osmocom/gprs/ are actually all the
headers of libosmogb (there's no osmocom/gb/ dir). But a couple files
are actually RLC/MAC (TS 44.060) related are are also stored in there.
Those files have no relation/use in Gb, and are actually interused with
GSM (eg System Information 13 Rest Octets).
Hence, it makes sense to have the RLC/MAC related parts inside
osmocom/gsm/ as they should be in libosmogsm (and they actually are,
see gprs_rlc.h function implemented in src/gsm/gsm48_rest_octets.c).

The fact that some libosmogsm headers were placed in osmocom/gprs
instead of osmocom/gsm already created some issues, like
libosmocore.spec.in putting "%_includedir/%name/osmocom/gprs/" under
libosmogb, which is wrong.

As a first step to fix the mess, we move the 2 RLC/MAC headers currently
under osmocom/gprs/{gprs_rlc,protocol/gsm_04_60}.h under a single header
gsm/protocol/gsm_44_060.h
The two old headers are left existing for backward compatibility and now
simply include the new libosmogsm header, plus a warning asking users to
switch to the new header so we can eventually get rid of them.
This means libosmogb depends on libosmogsm, which is fine and was
already the case beforehand (libosmogb using functions like
gsm48_encode_ra() and linking against it in src/gb/Makefile.am).

Change-Id: I70cc21bf25a7081070738abacb409ed19094c3b2
2023-02-20 12:21:30 +01:00
Philipp Maier ce4a86525c gsmtap_util: remove whitespace at the end of line
Change-Id: Ib7afbfb1f7a95beab16fed11d07ae244b4fcfcdc
2023-02-20 11:03:27 +00:00
Max a747d36166 GSMTAP: add gsmtap_source_init*2()
Those allow selecting source host:port for UDP socket sending GSMTAP data.
It's handy when you have several GSMTAP sources operating simultaneously.

Change-Id: I51b3604ba79e42c474aa17007e7e308a12afcea8
2023-02-20 11:03:05 +00:00
Matan Perelman 310b107284 gsm0808_enc_channel_type: Add spare byte
Related: OS#5911
Change-Id: I6e05e4989924b2258122113eb134e946e9cf0107
2023-02-20 10:57:54 +00:00
Oliver Smith 48706d64e4 Run struct_endianness.py
Ensure there is no diff to prepare to run this in CI.

Related: OS#5884
Change-Id: I194f3affeb969d485348c46a6dabbe5f8e47e780
2023-02-20 10:54:13 +00:00
Pau Espin 66188dc3c2 gsm_04_60.h: Better describe origin of enum osmo_gprs_nmo
Change-Id: Ied6c11aa92ea5a2e18a6045cefddfd4e40108174
2023-02-20 10:16:09 +00:00
Max ef5d3bcb79 GSMTAP: fix typo
Change-Id: I152c605a01069117563d9502046fa5540fa148d9
2023-02-20 09:44:59 +00:00
Vadim Yanitskiy 2617815ffc gsm: fix invalid check in gsm48_decode_ssversion()
Change-Id: I648a4b052d0ec7af97d513630aa4279884436dda
Fixes: OS#5910
2023-02-19 16:18:32 +07:00
Philipp Maier 54e1782e71 i460_mux: make osmo_i460_subchan_count public
There may be situations where we must check if there are still I.460
subchannels active, so lets make the function osmo_i460_subchan_count
public

Change-Id: I0454ffe5809f21504c1e263a781c06596d452d4b
Related: OS#5198
2023-02-18 08:38:00 +00:00
Oliver Smith 0b5c09b3f0 Fix typo endianess -> endianness
Rename contrib/struct_endianess.py to contrib/struct_endianness.py, and
fix the typo everywhere. This is in preparation to call the script in
CI on all repositories.

Related: OS#5884
Change-Id: Idc4af9098ba1de26243464c772d6ea8be330646a
2023-02-17 10:37:40 +01:00
Philipp Maier 8930911c00 i460_mux.c fix apidoc
Change-Id: Ib701e3f8f4261087c2fd2719a52e4d785db11ddc
2023-02-16 16:39:37 +00:00
Max db7cb69736 socket: propagate error in osmo_sock_unix_init() to the caller
Change-Id: Ia90d2ca3106b58dc5953d930f13df829d5b6966f
2023-02-15 14:02:50 +00:00
Oliver Smith f047a4a04a gsm0808_enc/dec_channel_type: support data
Related: OS#4393
Change-Id: Ib7b75c9d86aace329decf20003b68de459021c64
2023-02-13 08:09:48 +00:00
Neels Hofmeyr 6939169de9 add contrib/talloc_count.sh
When a user reports a memory leak with a talloc report, this script is
useful to quickly get a handle of what is being leaked. The alternative
is eyeballing the talloc report for a very long time.

Change-Id: I5b3242dd6e0649925ac6abfd1e96625c682b8934
2023-02-10 21:40:21 +01:00
Oliver Smith 96a8b559bb gsm0808_chan_indicator: add SPEECH_CTM_TEXT_TELEPHONY
Add it, so a follow-up patch can use it in gsm0808_dec_channel_type
where 3GPP TS 48.008 § 3.2.2.11 refers to "if octet 3 indicates speech
or speech + CTM Text Telephony".

Related: OS#4393
Change-Id: Iaf12202c89b68290c2121bc016d08b9200a7278a
2023-02-09 10:37:07 +01:00
Oliver Smith 02b909537f test_gsm0808_enc_dec_channel_type -> …_speech
Rename the function in preparation for a new test for _data.

Related: OS#4393
Change-Id: Ifa6654cc0a38f160268698efaa4bb867be3f7701
2023-02-09 10:37:00 +01:00
Oliver Smith 81e5a6f7e4 gsm0808_dec_channel_type: add missing len check
Stop iterating if the extension bit (0x80) is set but elem is too short
to read another byte.

Related: OS#4393
Change-Id: Id37109dba0f5d40f4b83f0cef9b1dbd9d6bb2c68
2023-02-09 10:36:55 +01:00
Pau Espin 5f15e4199c Bump version: 1.7.0.119-b31a-dirty → 1.8.0
Change-Id: I5e953cedc041371a9c192f58348b673a787f542e
2023-02-07 11:20:42 +01:00
Pau Espin 672e8d1041 debian/rules: Fix moved path crc*gen.c
Fixes: d4c3dc8d59
Change-Id: I89b4e77e3a7e2de9ec56af4dc348ec060df8da4d
2023-02-07 11:16:09 +01:00
Max b31a2b5f6d Add SI10 support
Add data structures and checks for System information Type 10.

Related: OS#5783
Change-Id: I3a5da543f083f31e873c67b5ec1b5a439187d8f3
2023-02-04 10:07:28 +00:00
Pau Espin 5c7eaa671a gprs_ns2_fr: use osmo_netdev to monitor and operate network device
As a result libosmogb doesn't depend directly on libmnl anymore, but
through libosmocore.

Change-Id: Ib0e499e09c50135a5c4a361332d6120f660a1a45
2023-02-02 10:21:17 +00:00
Oliver Smith 52d8df1e3f gsm_08_08.h: fix typo in GSM0808_DATA_FULL_PREF
Change-Id: I25f46bf3893bb68203414300587756cf2fdb04f7
2023-01-31 11:43:33 +00:00
Max bc12728679 SI: add missing header
Previous SI10 patch added function without exposing it via public header.
Let's fix this.

Fixes: 600d4eeab7
Change-Id: Ia7530e9c8a21f6f99f3aac7baea5cbb38763c4f3
2023-01-30 18:52:41 +00:00
arehbein 0aa84cfde4 libosmocore: Transition to use of 'telnet_init_default'
Replace remaining calls of telnet_init_dynif() by telnet_init_default()

Related: OS#5809
Change-Id: Ie762d0c642021db1a6ef95333cd771351de86845
2023-01-27 00:49:45 +01:00
Pau Espin d3455fa620 tun: Fix potential unpaired call to osmo_netns_switch_exit()
Fixes: Coverity CID#307429
Change-Id: Iadfc9eb48c6342433eee8da3e4d00ee496df3c75
2023-01-26 17:41:44 +00:00
Max 1466daf75d Fixup .gitignore
Update to match new location of generated crc* code.

Change-Id: I33b62047ff5bca7f5834df0961f3637cb319c80d
2023-01-26 12:17:07 +00:00
Oliver Smith 8d92d9cdbe d/control: libosmocore-dev: depend on libmnl-dev
Let libosmocore-dev depend on libmnl-dev, as we build the debian package
without --disable-libmnl and so libosmocore.pc lists libmnl in requires.
This patch should fix the following error when trying to build any
debien package depending on libosmocore-dev:

  Package 'libmnl', required by 'libosmocore', not found

A similar change in the rpm spec is not be needed, as rpm adds depends
from pc files automatically.

Fixes: 4eb89afa ("configure --enable-libmnl: Add libmnl to libosmocore.pc.in Requires")
Change-Id: I7fd578fcc22c0ea6ac04bdc26dc1741e4e26767c
2023-01-26 09:19:29 +01:00
Pau Espin 7d79fa4542 netdev: Fix compilation building with --disable-libmnl
netdev.h doesn't expose its use of libmnl publicly. It could actually be
implemented using other subsystems internally, such as ioctl() or other
OS-dependent APIs.
Hence, if --disable-libmnl is used, still make the API available but
make it fail with -ENOTSUP on functionalities which are only implemented
through libmnl so far.

Change-Id: I62bdea075afb9e0cc2bbcec6dd3a930e8f7bbc40
2023-01-25 17:12:07 +01:00
Pau Espin 4eb89afa80 configure --enable-libmnl: Add libmnl to libosmocore.pc.in Requires
Change-Id: I8ad8418ada95e79bb6079f34c6b57817c6f6ab11
2023-01-25 17:12:07 +01:00
Pau Espin 51e9dde95e Introduce tundev API
The data structre is held private so that it can be easily extended in
the future.

Change-Id: I6f8324da9ba49b9249682e2ec5b45297f18dd8c2
2023-01-25 16:08:35 +01:00
Pau Espin 9d0321d041 Introduce netdev API
This module provides several operations on network devices
(interfaces), like monitoring changes, setting addresses, routes, link
state, etc.
It also supports managing network interfaces on several different netns
concurrently.

These functionalitites will be used by the tun module included in a
follow-up patch.

Change-Id: I7a00c0445a89e088676a4897061b65196d9197f1
2023-01-25 16:06:55 +01:00
Max 600d4eeab7 SI: add RR short PD message types
Related: OS#5783
Change-Id: Ifbd0aabe826298fa4715eb4eb2ff8363e765933d
2023-01-25 09:09:35 +00:00
Max 812dfbf3a7 ASCI: add VBS/VGCS support to BTS features list
Related: OS#5783
Change-Id: I583a170070c192c6c47fae41ce923a7439561b4f
2023-01-25 09:09:35 +00:00