Commit Graph

4414 Commits

Author SHA1 Message Date
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
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 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 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
Philipp Maier b6a3836ad2 gsm0408_test: add unittest for gsm_gsmtime2fn()
The function gsm_gsmtime2fn(), which is used to compute a frame number
value from given starting time values T1, T2 and T3 has no unit test.
Due to to the modulo that is used the computation can be a bit tricky.
Lets add a unit-test to make sure the function works as expected.

Change-Id: I8b9b71c8dcccf3b44326b5e61229f4637689d763
2023-01-12 13:06:24 +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
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
Eric Wild 555c293867 bitgen test: fix concat macro
..compilers might not like concatenating "nothing", and it looks weird.

Change-Id: Ibcd49a5c5c4f4fd0406fa1697edfd59307eac6f7
2023-01-11 09:01:18 +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
Oliver Smith a42f4a51c0 utils/osmo-stat-dummy: check for ENABLE_UTILITIES
Don't attempt to build osmo-stat-dummy, unless ENABLE_UTILITIES is set.
We check for this in utils/Makefile.am too.

Fix for currently failing master-osmo-ccid-firmware job, at
cross-compiling libosmocore:
  make[3]: *** No rule to make target '../../src/vty/libosmovty.la', needed by 'osmo-stat-dummy'.  Stop.

Fixes: 7a79dd3d ("osmo-stat-dummy: add rate counters and statsd tester")
Change-Id: I44e49b5646518bd07b2628ca488e4bf74586852c
2022-12-21 10:34:50 +01: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
Max 7a79dd3dab osmo-stat-dummy: add rate counters and statsd tester
It's handy for testing rate counters as well as statsd metrics.

Related: OS#5671
Change-Id: Ibd8b17aa3ba9ceb527c6231310f01d736fb542a7
2022-12-20 14:20:05 +03:00
Max 23a7d0740c rate_ctr: drop rate estimation code
Drop the code which tried to estimate the value for the next timeframe:
it accumulated error over time which only adds confusion.

N. B: this means that long-term intervals (day, hour) will show the rate of 0 until
corresponding timeframe passes. This matches how other monitoring software [1] behaves.

[1] https://learn.netdata.cloud

Fixes: OS#5671
Change-Id: I07232e9ff8bd62403ae82d9bd60d967d40b54ebc
2022-12-19 15:51:42 +00:00
Vadim Yanitskiy 6db830f316 gsm0808: use new gsm0808_enc_speech_codec[_list]2() API
The motivation behind adding and using the new API is explained in
the preceeding change [1].  Whenever any of the encoding functions
fails to encode either a Speech Codec or a Codec List IE, free()
the msgb and return NULL.

Change-Id: I28219b61b9347f0652f9fd0c717f6cdf3c63e8f9
Related: [1] I199ffa0ba4a64813238519178155dfc767aa3975
Related: SYS#6229
2022-12-14 03:24:51 +07: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
Vadim Yanitskiy c2f1ed1dd0 gsm0808: remove over-defensive assert()s for function parameters
I believe the gsm0808_* API is mature enough to avoid assert()ing
pointers accepted via function parameters.  We can assume the caller
never passes NULL, as we do in almost all public API.

Change-Id: If9b4c92ace68191f5ddcc0a8a340fccbfe0f3dc0
2022-12-14 02:18:21 +07:00
Vadim Yanitskiy 90b64a1d70 gsm0808: remove redundant assert() in enc_speech_codec()
This assert can be dropped because the switch statement above does
not leave any sc->type >= 0x0f for type_extended == false.

Change-Id: Iafb45ed66378f2c9c2480f81371e92c6d1da71a7
2022-12-14 02:08:40 +07:00
Vadim Yanitskiy 061b7ec434 gsm0808: remove unneeded assignment in enc_speech_codec()
Change-Id: Ifc6d109e27cdada0d08d2a8fc1c354f3de04f15c
2022-12-14 02:06:06 +07:00
Vadim Yanitskiy 8e962451fc gsm0808: cosmetic: switch is not a function
Change-Id: I2f58711675c5c9511c4f4fe4bf0d6e6f7dd093b1
2022-12-14 01:13:19 +07:00
Max 7c1b6cb4cd rate_ctr: convert to timerfd
Use timerfd to schedule 1-second periodic timer once
instead rescheduling every second in timer callback.

Related: OS#5671
Change-Id: I2525fd691caa380a862d305cfcb4fa3cc50b70d0
2022-12-05 22:07:50 +03:00
Max af35eb203c telnet_init_dynif: don't allow negative port
Binding to a negative port should not be allowed.
Using signed value for unsigned parameter is a mistake to begin with.

Change-Id: I24f957641f2d8e230ccceb331a719496df0fdb1f
2022-12-04 11:44:54 +00:00
Max 6d261343fa telnet_init_dynif: propagate error
Return actual error from osmo_sock_init_ofd() to the caller.

Change-Id: Ib09f4315b3868ec031ecbced8a63069e7c2de7da
2022-12-04 11:39:46 +00:00
Max 5b37642818 vty: fix doc typo
Change-Id: I9f1112fc27dfe967b4a007648ddda1050e9bd9fa
2022-12-04 10:03:13 +00:00
Max a840ad5e19 jenkins_arm.sh: disable external tests
We don not run 'make check' at all so configuring with external tests support is pointless.

Related: OS#5671
Change-Id: If96756a85ab3b01a786838a4882884efe33f968b
2022-12-04 10:03:13 +00: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
Max a9ddb834e6 osmo-ns-dummy: add ctrl interface
It's handy for rate_ctr tests with follow-up patches.

Related: OS#5671
Change-Id: If6e06d9433e438b92f1ed1ef0f892308e031779b
2022-11-30 18:47:32 +00:00
Neels Hofmeyr f4854f39c6 osmo_tdef_get(): clarify API doc on val_if_not_present
Change-Id: I2301aad86d6d165a3b51c6849bcd8fe02972e0a3
2022-11-28 15:19:47 +01:00
Max 2b283b1a1a LAPD: move tx_hist code into static functions
Related: OS#4074
Change-Id: Ibf3b08c8d874416796b94ba3a672a02d614313b1
2022-11-26 13:59:09 +00: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
Vadim Yanitskiy 8fbaad6903 */Makefile.am: do not mix up AM_CFLAGS with AM_CPPFLAGS
Change-Id: I2c1d5f9c61714f487fbbe60603b2682f2c0a4c6b
2022-11-10 16:07:03 +00:00
Harald Welte 6dda35a80f Fix typos in copyright statements.
Change-Id: I783c56bb1d216ce3a47a19da230ee5f50aca2ab3
2022-11-09 16:54:50 +01:00
Harald Welte 88bb5ed7fa Add -Werror=implicit-int -Werror=int-conversion -Werror=old-style-definition
... if --enable-werror is used

Change-Id: I8acd1b276f1ff8f015856d70fd582e457915ea11
2022-11-08 16:30:58 +00:00