Commit Graph

2793 Commits

Author SHA1 Message Date
Harald Welte c9527763c2 Makefile.am: Make libraries depend on .map files
Without this, an update to the .map file doesn't re-trigger a re-link of
the library.

Change-Id: If0ea6f41730a28b04562d45efa6ca376abaf3f6b
2023-03-06 17:07:48 +00:00
Pau Espin 3e5609ade6 gsm: gsm_gsmtime2fn(): constify param
Change-Id: Ib29d5a8e7dcf50fb086f967857b0afa076573163
2023-03-06 13:59:40 +01:00
Harald Welte d4d78bce7b libosmocore.map: Add two missing entries for gsmtap*2() API
Those functions were introduced in I51b3604ba79e42c474aa17007e7e308a12afcea8
but the recent introduction of libosmocore.map didn't list them

Change-Id: I4ac14aae13ff60c110444da989761cd1e86f8925
Fixes: I13169c00a59fb59513dfc598de5a71d094492422
2023-03-05 18:25:07 +01:00
Neels Hofmeyr 593d20d637 add gsm0808_amr_modes_from_cfg
Provide the definitions from 3GPP TS 28.062, Table 7.11.3.1.3-2 as
generally usable API.

Likely users:
- upcoming patch to improve conversion between S0-S15 and MultiRate
  config, I900fda192742fa8f6dd54e9131ef1704b14cc41a
- osmo-msc to figure out conversion between SDP AMR mode-set and 3GPP TS
  48.008 Permitted Speech S0-S15.
- osmo-bsc to choose AMR modes for channel activation from cfg /
  permitted speech from MSC.

Related: SYS#5066
Change-Id: Icef7dd626d3d4641c66b8dd87e2047fc0ab547d1
2023-02-28 23:00:45 +00:00
Vadim Yanitskiy 64277a0217 doxygen: fix various typos in commands \param and \returns
Change-Id: If87cec3739449c6a54e24fb2cb81e746d8244da2
2023-02-28 18:48:56 +00:00
Oliver Smith 5566b2ea65 libosmocore.map: add tall_{ctr/msgb}_ctx
These should not be used, but add them for backwards compatibility with
building older versions of osmo-bsc, osmo-iuh, osmo-pcap against current
libosmocore.

Fixes: 213fc420 ("Add libosmocore.map")
Change-Id: I4cfccf3622844d0923818bb8d8ce206f70e44a0d
2023-02-28 11:33:10 +01:00
Max edb5f3374f GSMTAP: add missing parameter docstrings
Change-Id: I774b89e0358bdcf7c71c7fd9c9940f634a7d3822
2023-02-28 09:00:47 +00:00
Daniel Willmann 213fc420e0 Add libosmocore.map
Generated with:
nm src/core/.libs/libosmocore.so --defined-only  |grep " T \| D \| B " | cut -c 20-  >> src/core/libosmocore.map

Change-Id: I13169c00a59fb59513dfc598de5a71d094492422
2023-02-27 17:11:08 +00:00
Oliver Smith 57d4fae832 gsm0808_enc/dec_channel_type: fix transparent flag
According to 3GPP TS 48.008 3.2.2.11, it is inverted.

0: Transparent service
1: Non-transparent service

Change-Id: I2e5786ad053ee871079b4a8d95caccd6b03b59b6
2023-02-27 13:49:34 +00:00
Harald Welte 6345333fb1 Interleaving for CSD
This patch adds the [de]interleaving for CSD (circuit switched data),
nominally for TCH/F 9.6, but the same is also used for TCH/F 4.8,
TCH/H 4.8, TCH/F 2.4 and TCH/F 14.4.

Related: OS#4396, OS#1572
Change-Id: I6b16c2d0d7febf3883da662b2c7fec543335de12
2023-02-27 13:34:43 +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
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
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
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 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 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 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
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
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
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
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
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
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 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
Pau Espin 8a5014be08 Introduce netns API
Write a new API and implementation to manage network namespace related
operations.

This will be used by the upcoming tundev module.

Change-Id: I0f2fba2fa42250a07211a7b7f479498f27c529da
2023-01-24 12:38:20 +01:00
Harald Welte 4ce820ab8d isdndlc: Fix documentation
The documentation was copied 1:1 from the Linux kernel, where it
already was wrong and apparently described an earlier implementation.

Change-Id: Ib5def2ae3c79f408f2ee0bb4c20fba1437d30c64
2023-01-21 22:41:57 +01:00
Harald Welte d55a209d1c create libosmoisdn sub-library
There are some parts of libosmogsm which are not really GSM specific,
but rather ISDN bits that were inherited by GSM.  This includes the
I.460 multiplex as well as the core LAPD protocol.

Let's move those bits to its own libosmoisdn library, before we add
more ISDN specific bits to the wrong place.

Backwards-compatibility is created by making libosmogsm depend on
libosmoisdn, and by providing wrapper include files for source
compatibility.

Change-Id: Ib1a6c762322fd5047be3188b1df22408ef06aa50
2023-01-21 22:41:57 +01:00
Pau Espin 88955fb550 Fix all references to config.h
config.h is created in $(top_buildir)/config.h.
Let's make sure all CPPFLAGS add correct -Ipath includes,
and that all code includes the correct file.

Change-Id: Ie9ea38bb009bc715b01cde4d66d181f7bec2e7bd
2023-01-18 19:04:36 +01:00
Pau Espin a50ed5fda8 Makefile.am: Remove unexsiting all_includes variable
Change-Id: I9bc7de6f85558e55265c6cc965bc7fe97a6736ee
2023-01-18 19:04:36 +01:00
Pau Espin 1162a24454 src/core/Makefile.am: reformat SOURCES list
Have one per line and order items in an alphabetical order.

Change-Id: Ib14396e9a1a744cdad2f35f7241eb2ab3212c0cb
2023-01-18 17:30:08 +01:00
Pau Espin d4c3dc8d59 Move src/*.{c,h} to src/core/
This way we have all libosmocore.so in an own subdir instead of having
lots of files in the parent dir, which also contains subdirs to other
libraries.
This also matches the schema under include/osmocom/.

Change-Id: I6c76fafebdd5e961aed88bbecd2c16bc69d580e2
2023-01-18 17:14:06 +01:00
Pau Espin cc296c9293 socket.h: Introduce API osmo_sockaddr_netmask_to_prefixlen()
Implementation is imported from osmo-ggsn.git
97f60e3dca581797007524e0006ca9fafad59713 in46a_netmasklen() and adapter
to work with an osmo_sockaddr.

This will be used by osmocom-bb's "modem" app.

Change-Id: I75e75e251c6776801fffdde745aebedf21c68799
2023-01-17 10:53:09 +01:00
Philipp Maier a13d5662b7 gsm_utils: improve gsm_gsmtime2fn()
The function gsm_gsmtime2fn() uses a hack to account for the truncated
modulo implementation of C/C++. libosmocore offers proven modulo
functions, so lets use OSMO_MOD_FLR() instead. Also arrange the formula
so that it looks more like the one in the spec.

Also add better spec references and a final modulo GSM_MAX_FN to
prevent frame number results that exceed the valid range.

Change-Id: Ibf94bca8223f1f7858a6dd67bf27de0ab6feab20
2023-01-12 15:30:24 +01:00
Pau Espin e709bd4814 ctrl: error if program forgot to initialize the ctr handler before installing cmds
Change-Id: Icf3873f33470499fed3150ff51922a36aa0f023e
2023-01-11 15:33:41 +00:00