Commit Graph

1675 Commits

Author SHA1 Message Date
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
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
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
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
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 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
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
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
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 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 4fc6118bb3 Split include/Makefile.am content into subdirs
When someone is modifying a given library there's no need to be looking
at a common file contains tons of lines from different libraries.
Furthermore, this removes the need of "nobase" autofoo prefix, hence
following the usual directive of having one Makefile per directory.

Change-Id: I785891c2f89114bf8303c799094b637d3d25ac71
2023-01-18 18:29:34 +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 94705d042a uitils: add floored and euclidian modulo functions
C/C++ only implements a so called "truncated modulo" function. Lets also
add a floored and an euclidian modulo function to be more complete.

The functions will be used to generalize the following Change:
I5fb2b0ada8d409730ac22963741fb4ab0026abdd

Change-Id: If61cd54f43643325c45f64531c57fe4c5802a9cf
2023-01-12 09:33:07 +00:00
arehbein ee7b8c5273 libosmocore: Deprecate APIs telnet_init(_dynip)()
Related: OS#5809
Change-Id: Ibd05d3bc2736256aa45e9e7ec15a98bd14a10454
2023-01-09 21:18:15 +00:00
Vadim Yanitskiy 179dec096f gsm48_ie: gsm48_decode_freq_list(): make 'cd' argument const
Change-Id: Ide9110b984d3302aec6b439c563eb10e2dcdec9e
2023-01-02 12:49:15 +00:00
Max 3f79ce8f23 ctrl: add optional port to bind command
So far ctrl interface did not allow to specify port to bind to.
Let's fix this and make it consistent with the way vty bind works.

N. B: the functions which ignore port configured via vty are marked as deprecated,
the sw which uses them should be ported to either newly added ctrl_init_default()
or simplified ctrl_interface_setup()

The similar change for vty interface will be addressed via separate patch series.

Related: OS#5809
Change-Id: I0fd87fd41fd3ac975273968d24f477daa3cd3aa9
2022-12-20 14:23:04 +03:00
Vadim Yanitskiy 5a51331729 gsm0808: add gsm0808_enc_speech_codec[_list]2()
The problem with most of the existing gsm0808_* functions in this file
is that they assert() too much, assuming that their callers always pass
perfectly valid input parameters.  But this is impossible on practice,
as there can be bugs in complex projects using them, liks osmo-bsc.

It was reported by a customer that a heavily loaded osmo-bsc crashed a
few times, dropping more than 100 sites without network coverage for
a few minutes.  As was revealed during the investigaion, it crashed
due to a failing assert at the end of enc_speech_codec():

  OSMO_ASSERT(sc->cfg == 0);

The problem is that somehow osmo-bsc is passing an unexpected sc->cfg
value to gsm0808_create_ass_compl2(), in particular 0x02, while the
given sc->type value (GSM0808_SCT_HR1) implies that there cannot be
any configuration bits on the wire.

The reason why and under which circumstances this can be happening
is not clear yet, but what we agreed on so far is that the library
API should be enforcing correctness of the input parameters in a
less agressive way, rather than aborting the process without
letting it any chance to recover.

Modify the original gsm0808_enc_speech_codec[_list]() functions, so
that a negative value is returned in case of an error.  Rename them
and add backwards compatibility wrappers, because it's public API.

A separate patch making use of the new API follows next.

Change-Id: I199ffa0ba4a64813238519178155dfc767aa3975
Related: SYS#6229
2022-12-14 03:24:51 +07:00
Harald Welte d7d4b1b7d0 gsmtap.h: Add definitions for various ISDN sub-types
We've started to encapsulate a varieth of ISDN related formats
as sub-types to GSMTAP_TYPE_E1T1 for quite some time.  Let's add
some more formats, such as V5EF, V.110, V.120, X.75 and H.221

For the HDLC based V5EF, V.110, V.120 and X.75 the payload format is
clear.  For V.110 and H.221 we will need to specify how the actual
payload looks like.

Change-Id: I8dee0f730cf91d6f9133d5c57f653e669ec8d598
2022-12-02 17:05:50 +01:00
Pau Espin 6ca0a43294 gsm: constify several readonly params
Change-Id: Ib11bfe57f546a5618f70152b9b75115808e54bf6
2022-11-24 17:09:03 +01:00
Max a9a9ce6db0 Add define for unset Frame Number
It's handy for OsmoPCU as well as upcoming LAPD T200 code.

Related: OS#4074
Change-Id: I641f1a1bf1e86ced8ffe89e88bc48afb79823393
2022-11-20 21:48:52 +00:00
Harald Welte 8d5fc1db44 vty/logging.h: Avoid -Werror=pragmas error in C++ code
The newly-introdiced pragma to disable strict-prototypes checking works
in C, but creates a -Werror=pragmas error in C++ code:

In file included from osmo-trx.cpp:45:
/build/deps/install/stow/libosmocore/include/osmocom/vty/logging.h:10:32: error: option
‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [-Werror=pragmas]
 #pragma GCC diagnostic ignored "-Wstrict-prototypes"

So let's also suppress those errors for that one line of code...

Change-Id: I85596cf4538d7a8c522f4bce1620a2d19e2a910e
2022-11-07 10:08:09 +01:00
Harald Welte be912e7c1d Disable -Wstrict-prototypes for logging_vty_add_cmds()
Since March 15th 2017, libosmocore API logging_vty_add_cmds() had its
parameter removed (c65c5b4ea0). However,
its declaration in C file didn't contain "(void)", which meant the
number of parameters is undefined and thus compiler doesn't complain.

However, in recent Change-Id I84fd99442d0cc400fa562fa33623c142649230e2
we changed the declaration to '(void)' to allow building with
-Wstrict-prototypes.  This caused downstream build-failures of osmo-mgw (1.4.0)
and osmo-e1-recorder (master).

So let's make one very small-scoped exception here.

Change-Id: Iadb54848b67db937b640dc2102dddb6e708a6a9f
2022-11-06 10:57:52 +01:00
Harald Welte e61d459cef Support building with -Werror=strict-prototypes / -Werror=old-style-definition
Unfortunately "-std=c99" is not sufficient to make gcc ignore code that
uses constructs of earlier C standards, which were abandoned in C99.

See https://lwn.net/ml/fedora-devel/Y1kvF35WozzGBpc8@redhat.com/ for
some related discussion.

Change-Id: I84fd99442d0cc400fa562fa33623c142649230e2
2022-11-03 12:44:28 +01:00
Max df5b1e17a5 msgb: introduce extended copy functions
Those are similar to existing *msgb_alloc*() functions but allows
to change the size of destination msgb provided it fits the
data from source msgb.

Change-Id: I36d4c16241d19f0f73c325be4d0e0bdef6813615
Signed-off-by: Max <msuraev@sysmocom.de>
2022-10-25 08:51:22 +00:00
Harald Welte d98a867743 logging.h: Allocate DLM2PA and DLM2UA for libosmo-sigtran
Change-Id: I106b7586bfe8ee03c052b6f8b33da4c466e05abd
2022-10-16 17:14:08 +02:00
Harald Welte 729a2c8e9a allocate VTY port number 4270 for osmo-isdntap
osmo-isdntap is a ISDN protocol + call tracing utility currently under
development, see https://gitea.osmocom.org/retronetworking/osmo-isdntap

Change-Id: I25ca4565e326ee9b0b32eeabc4a76756e2fde4ac
2022-10-16 17:14:08 +02:00
Max 7bd1670520 cosmetic: remove trailing space
Change-Id: Ibecfcccd3eabd81979b2296a2dbca1ffbbec8f1c
2022-10-11 10:57:26 +03:00
Philipp Maier 724c1625e2 msgb: do not use msgb_l4 instead of msgb_sms
The macro msgb_sms() is basically an alias for msgb_l4(). Lets use
msgb_l4() in msgb_l4len() instead of msgb_sms().

Change-Id: I90d4f5c07fbaadd9e022752a2c64c4855f0b4227
2022-10-06 07:52:09 +00:00
Philipp Maier d9d62102cc msgb: assert msgb->lXh to be not NULL
When any of l1h, l2h, l2h or l4h is set to NULL (which is the default
for newly allocated message buffers). Then the msgb_lXhlen() functions
will return the address value of msgb->tail. This can lead to unexpected
results at a later point. We should have an OSMO_ASSERT to catch the
problem early.

Change-Id: I1795c559f190713ebbabfbabf3453ab77da46a49
Related: OS#5645
2022-10-06 07:52:09 +00:00
Pau Espin 3b3955b203 socket: Introduce API osmo_sockaddr_is_any
Change-Id: I2810a889fc14052d0e0be6a2b500ad4e5088ffa9
2022-10-04 16:30:32 +02:00
Pau Espin 3c12f557bd socket.h: Reorder sockaddr APIs to have them all together
Change-Id: Iab2ee2854be8027ee5978e06a83248b530a39bf7
2022-10-04 12:31:03 +02:00
Vadim Yanitskiy 8deedfa281 gsm0502: use parentheses in GSM_TDMA_FN_{SUM,SUB} macros
This makes it possible to pass expressions to the abovementioned
macros without any side-effects.  Strictly speaking, this is only
necessary for argument 'b' of GSM_TDMA_FN_SUB, but let's also add
them to GSM_TDMA_FN_SUM for consistency.

Change-Id: I7f26156813139bbb7774e1eb342c91bc84fdad38
2022-10-04 02:49:23 +07:00
Vadim Yanitskiy 395db204b4 include: use '#pragma once' everywhere
Change-Id: Iecc1754caae401aca28444d3e3d0cca04b398f26
2022-09-29 05:44:09 +00:00
Alexander Couzens 71ad530f7e gb: add bssgp2_enc_flush_ll encode FLUSH-LL
Change-Id: I76dc3b08a63cfd78c9f7657fb58c2ddfa9b4b7e2
2022-09-28 18:14:28 +02:00
Neels Hofmeyr 70093f23ad comments: gsm_08_08.h: AMR cfg: explain in much more detail
Change-Id: I1864a6beeeedc301c6dc7e2e0c52a3f94b2fef01
2022-09-25 20:26:21 +02:00
Pau Espin 812766e231 utils.h: protect param with parenthesis in OSMO_BYTES_FOR_BITS()
While at it, drop 8-1 in favour of 7. I don't think it is really more
understandable for readers to see some subtraction there...

Change-Id: I8b21eba9b9aa952f86abe7a6d4cdb1d1a61d9deb
2022-09-08 15:03:44 +02:00
Neels Hofmeyr 709da278ca Revert "Add function to guess AF_UNSPEC address"
This reverts commit a4063efa7d.

Reason for revert: It is not possible to guess the IP address
family from uninitialized memory. This function simply glorifies
random noise into an IPv6 address. It makes no sense to have it.

Change-Id: Ifadd614604cf9d0c2ed1a405493c1c3fcb37ae23
2022-08-17 14:05:18 +00:00
Neels Hofmeyr 9e4c2ebf18 Revert "Add osmo_sockaddr_strs_to_str()"
This reverts commit e145e28a91.

Reason for revert:
The function osmo_sockaddr_strs_to_str() should not be part of the
osmo_sockaddr_str API. The implementation of this should live in
the function multiaddr_snprintf() added in patch
Icef53fe4b6e51563d97a1bc48001d67679b3b6e9
and should not use dynamic allocation.

Change-Id: I263dfd68313b896c5b474025fbca13c22ce41cdc
2022-08-17 01:01:16 +00:00
Max e145e28a91 Add osmo_sockaddr_strs_to_str()
This will come in handy for working with multihomes sockets like SCTP.

Related: OS#5581
Change-Id: Ic0d7c08f669994e37a2314555ecac85d28c42c89
2022-08-14 12:21:12 +07:00
Max a4063efa7d Add function to guess AF_UNSPEC address
Sometimes we receive generic "struct sockaddr" with unspecified (AF_UNSPEC)
address family. It's handy to try to guess
the proper address (there're just 2 variants ATM in most practical applications).

Use the added function to relax input checks in osmo_sockaddr_str_from_in*()

Related: OS#5581
Change-Id: I1c90c56ce832f53b65e0d18d3cea94621c02a69a
2022-08-09 08:58:49 +00:00
Pau Espin 83287ba41c gsm: rsl: Define new osmocom extension TLV IE to pass Osmux CID
This is similar to what we already do between BSC<->MSC to pass Osmux
CID (GSM0808_IE_OSMO_OSMUX_CID).
We now want to support Osmux between BSC and Osmocom BTS, hence add an
extension IE which will be used in ipaccess CRCX messages to tell the
BTS to use Osmux.

Change-Id: I580fe99c01bc0a844d877994ec6cd954310e265d
2022-08-09 08:35:55 +00:00
Pau Espin 306400786d gsm: Add BTS feature for Osmux
This feature is used by the BTS to signal to the BSC that it supports
using Osmux instead of RTP on the BTS<->BSC(MGW) data plane.

Related: SYS#5987
Change-Id: Ie79bfb6d0a7a8fe2842d2596b3244e7b74a0d5b6
2022-08-09 08:35:55 +00:00
Pau Espin 862dd36318 tlv.h: Fix TLVP_PRESENT returning a pointer instead of a boolean
I was warned by gcc about comparing a pointer with an integer when using
TLVP_PRESENT with something like:
bool expect = ...;
if (expect != TLV_PRESENT(...))

That's indeed dangerous because TLV_PRESENT is considered to return a
boolean, as opposite to TLV_VAL.

Change-Id: I45cc2745c695e30c37b10f592903ec3775a55492
2022-08-08 20:07:15 +00:00