Commit Graph

4499 Commits

Author SHA1 Message Date
Harald Welte b394d6fc85 New osmo-gsmtap-logsend utility
This utility can be used to "pipe" stdin or some file as log lines
via GSMTAP logging.

Change-Id: Ida96e87d84e0c349c5069edc67fec1c3cf19d1ab
2023-03-15 11:53:08 +00:00
Neels Hofmeyr 5761c44609 error log: osmo_sock_init2_multiaddr() v4/v6 mix
Provide some more information for the error case when local and remote
addresses mix v4 and v6.

Change-Id: I0fd12b08e0788ce3af6dc519ff8c82ad196a115f
2023-03-14 20:15:05 +00:00
Neels Hofmeyr e1c4f24cb9 contrib/talloc_count.sh: improve hexadecimal masking
Also mask hexadecimal without leading 0x. But take care to not match on
every letter a-f,A-F in normal words and names.

before:

    10 map_rua(NffffNfNecN-example-com-RUA-N)[N]
    10 map_sccp(NffffNfNecN-example-com-SCCP-N)[N]
    17 map_rua(NffffNcN-example-com-RUA-N)[N]
    17 map_sccp(NffffNcN-example-com-SCCP-N)[N]
    18 map_rua(NffffNeNbN-example-com-RUA-N)[N]
    18 map_sccp(NffffNeNbN-example-com-SCCP-N)[N]
    82 map_rua(NffffNfNdN-example-com-RUA-N)[N]
    82 map_sccp(NffffNfNdN-example-com-SCCP-N)[N]
    85 map_rua(NffffNfN-example-com-RUA-N)[N]
    85 map_sccp(NffffNfN-example-com-SCCP-N)[N]
   224 struct hnbgw_context_map

after:

   224 map_rua(N-example-com-RUA-N)[N]
   224 map_sccp(N-example-com-SCCP-N)[N]
   224 struct hnbgw_context_map

Change-Id: I1b42ce3e67c7ed2d38d3e5c9cbfa90ba185a07b7
2023-03-14 20:12:57 +00:00
Neels Hofmeyr 141dffddf5 fix 'make vty-test' for --disable-external-tests --enable-gb
Change-Id: I80ac270bfb563a769a7746d8fbceac09e267ce03
2023-03-14 18:08:35 +00:00
Neels Hofmeyr 439ffc2a3e fix 'make vty-test' for --disable-gb
Change-Id: Ib6aec784d3b20cd56cb6bfab9ff17da35a282406
2023-03-14 18:08:35 +00:00
Oliver Smith b46cfba995 on_dso_load_select: run after on_dso_load_ctx
Add priorities to ensure on_dso_load_select runs after on_dso_load_ctx.
Otherwise osmo_ctx->global (used via define OTC_GLOBAL) points to NULL
and causes a segfault in osmo_fd_lookup_table_extend.

Use numbers 101 and 102, as "0 to 100 are reserved for the
implementation" and cause an error from GCC.

Fixes: OS#5946
Fixes: c46a15d8 ("select: Optimize osmo_fd_get_by_fd")
Change-Id: Ia2518e82530b93c535f8f5105513e21559b895ba
2023-03-14 15:22:20 +00:00
Pau Espin fc37650381 logging.c: Sanitize calls to osmo_fd_unregister()
It makes no sense to call osmo_fd_unregister() on a negative fd.
Let's also make sure we set fd to negative value after unregistering +
closing, even if the struct is going to be freed afterwards.

Change-Id: I0790a63e603028c11cc475d483c6528e4d9aa9ab
2023-03-14 14:32:54 +01:00
Pau Espin ff666997b2 tests/Makefile.am: Move LDADD to right position
LDADD var contains both local and system libraries. Use it at the right
place (after list of local libs, before list of system libs).

Change-Id: Ifb3686f78432ac877c596004646506c540b23c53
2023-03-14 14:20:21 +01:00
Pau Espin 34537d4de8 tests/Makefile.am: Drop duplicated libosmogb.la in LDADD
Change-Id: I20e815ba5dc473c644e1098f2347b183f215a51a
2023-03-14 14:13:07 +01:00
Pau Espin 6020d139eb tests/Makefile.am: Move system libs at the end of list
Change-Id: Iad6b9e39e3587849ccfd475899cbd610bf7145cd
2023-03-14 14:09:43 +01:00
Pau Espin 6fd7f41672 select.c: osmo_fd_unregister(): Avoid assert hit with old buggy users of the API
Change-Id: If77b84d603a42a216d550d9708eb62f645634a61
2023-03-14 13:13:47 +01:00
Pau Espin 3b450f0233 configure.ac: Fix typo in enable flag description
Change-Id: Ida390c50379a429a4b42434e32954eeb832a11ff
2023-03-14 13:13:40 +01:00
Pau Espin 5ef158fbbb configure.ac: Fix logic enabling osmo_fd fd checks
The logic testing the and setting the define was inverted, which made it
enabled by default.

Take the chance to rename the enable flag to be "ofd" instead of
"bsc-fd" (since anyway the flag was broken).

Change-Id: I81112fa1f6ce1a8e5fe85468241ad385ed8805d3
2023-03-14 13:13:40 +01:00
Pau Espin 25729cf531 select.c: Clarify osmo_fd_unregister() can only be called on registered osmo_fds
Change-Id: I5e397e121f2fe2254c7f4b474e6eefd7aebe7a83
2023-03-14 12:26:37 +01:00
Pau Espin 153519f5fb select.c: Clarify osmo_fd_(un)register() API expectations of registered fd
Those restrictions were implicitly required for a while and most of the
users of this API already followed them, but just a few didn't. All
known users have now been fixed. Let's explicitly document the
restrictions imposed by the API to ease avoiding similar issues in the
future.

Change-Id: I53d95aad15b33dd66aa5c7dd11745a35c4481f33
2023-03-14 12:01:45 +01:00
Pau Espin c46a15d876 select: Optimize osmo_fd_get_by_fd
Optimize osmo_fd_get_by_fd() from O(n) to O(k) by means of allocating
dynamically growing array.

Make use from the fact that the kernel always tries to use the smallest
 possible unused value when allocating a new fd.

Change-Id: I8b71547df8bed84192cb160479fa3debf9b7eade
2023-03-13 15:26:21 +00:00
Vadim Yanitskiy b7bf36f81c utils/osmo-stat-dummy/Makefile.am: drop empty variables
Change-Id: I1b9497900b0eebd77fd226f52a9050cdbd9e6cdc
2023-03-11 06:49:47 +07:00
Vadim Yanitskiy a8e2e5f78a utils/Makefile.am: do not overwrite AM_CFLAGS
* $(TALLOC_CFLAGS) is already present in AM_CFLAGS,
* osmo-sim-test: do not redefine but append $(PCSC_CFLAGS).

Change-Id: I7b9af3a1a9493a432af89198e291f4523388751e
2023-03-11 06:45:06 +07:00
Vadim Yanitskiy 6160419b03 utils/Makefile.am: remove duplicate libosmogsm.la
It's already listed in $(LDADD), no need to append it again.

Change-Id: I03f5f4330e828a938dafd93b9fdb576afb2b7f12
2023-03-11 06:41:12 +07:00
Vadim Yanitskiy 9dca9027b7 coding: clean up Makefile.am
* Remove TALLOC_{CFLAGS,LIBS} - talloc is not used directly
* Keep conditional ENABLE_PSEUDOTALLOC for embedded builds

Change-Id: I18f0a65a47c37989f03928f99c4687bf8007d437
2023-03-11 06:31:50 +07:00
Pau Espin 040548f790 logging: Unregister osmo_fd before closing fd
Change-Id: I0754ac3110b63d2a380068010830af6c85b0a653
2023-03-10 13:41:17 +00:00
Pau Espin 8d1532af92 cosmetic: stats_tcp: Fix typo in comment
Take the chance to shorten a bit the lengthy lines

Change-Id: I3215dea7e3198b728745a779ad1b6ebfa3795cb5
2023-03-09 21:18:08 +00:00
Harald Welte a41bd22349 gsm_08_58: Document IPAC RTP CSD modes in at least a few words
Let's clarify what those modes mean

Change-Id: I77fc7b24ccd387f54a7c7edad666737252af6bd9
2023-03-08 20:43:15 +01:00
Harald Welte c4cfb802df gsm: TS 44.021 modified V.110 frame encoding/decoding support
3GPP TS 44.021 specifies the format for modified V.110 frames as used
on the GSM air (radio) interface.  Implement encoders and decoders for
this modified V.110 format.

Related: OS#1572
Change-Id: I60a2f2690459359437df20cf4da9043fa7c3ad11
2023-03-08 20:43:15 +01:00
Harald Welte 065dab866e isdn: Add V.110 encoder/decoder
V.110 defines a B-channel protocol for transmission of synchronous and
asynchronous serial data of V-series interfaces via terminal adapters
over ISDN.

Let's add (unoptimized but easy to debug) functions for encoding and
decoding of V.110 frames for various bit-rates.

Related: OS#1572
Change-Id: I1b5fd3847d3bfb0a0f763e0574893962ec699680
2023-03-08 20:43:15 +01:00
Eric Wild 8c505c12b2 logging: remove log_initialized(void)
This function does not exist, and was apparently accidentally added (?)
to the header.

Change-Id: I479ef8484506ff27918df9fbf6cbeda8b304bbaa
2023-03-07 14:27:59 +01:00
Eric Wild 573f2fa1b3 fix _thread order
As per gnu extension doc ->
https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/Thread-Local.html :
".. When used with extern or static, __thread must appear immediately
after the other storage class specifier."

Change-Id: Ied1d3cf3ad2ff424bd0a2682aff29a8939b419b8
2023-03-07 14:27:59 +01:00
Vadim Yanitskiy c657a5028e gsm0502: add burst length definitions from chapter 5.2
Change-Id: I1c38ccc2b64ba9046bb3b1221d99cc55ec493802
Related: OS#1572
2023-03-07 13:25:36 +00:00
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
Oliver Smith 1447100476 gsm0808: make CSD enum values consistent with RSL
Use the same 32k0, 29k0, 14k4, … notation for GSM0808_DATA_RATE, as
it is already used in RSL_CMOD_CSD. As GSM0808_DATA_RATE enumes were
just added to libosmocore and aren't used yet, don't add backwards
compatible defines.

Related: OS#4393
Change-Id: Ia965cdd9f53af756e5ffaff9b8f389b5ad629969
2023-03-03 11:14:06 +01:00
Oliver Smith 341d9e1c6b rsl: RSL_CMOD_CSD_T: make enum values consistent
Use the 32k0, 29k0, 14k4, … notation instead of 32000, 29000, 14400 etc
to make transparent data enums with non-transparent data enums where
this notation is already used.

Related: OS#4393
Change-Id: I7b7c8f175f349811b17a3db68a57577bd3f1d2df
2023-03-03 11:14:06 +01:00
Oliver Smith 9d92c6e52f rsl: put values for Channel Mode into enums
Related: OS#4393
Change-Id: I25bfd02aa1428a35492b20376a31635a442e545f
2023-03-03 10:13:45 +00:00
Daniel Willmann 45ae1c5400 Add osmo_sockaddr_size() to return the size of the variant used
Change-Id: I952b6bb752441fe019fc18f89bce4bbfbe58994a
2023-03-02 09:47:41 +00:00
Neels Hofmeyr f2c0fccb58 improve test output for gsm0808_sc_cfg_from_gsm48_mr_cfg()
Improve the test output to make it easier to confirm that the fix in an
upcoming patch (I900fda192742fa8f6dd54e9131ef1704b14cc41a) is indeed
correct.

Spell out each S0-S15 mode along with the bitmask.
Rejigger the format of printing the mr_cfg flags, so that the AMR modes
line up vertically with the S0-S15 modes.

This clearly shows that the mr_cfg <-> s15_s0 conversion is wrong.
For example, in this test only 4k75 is enabled, yet we allow configs
featuring 6 other rates:

 Input:
  cfg.smod=0 spare=0 icmi=0 nscb=0 ver=0
      m4_75=1 ------- ------- ------- ------- ------- ------- -------
 Result (fr):
  S15-S0 = 0x5701 = 0b0101011100000001
  S0   4.75
  S8   4.75            5.90
  S9   4.75            5.90    6.70
  S10  4.75            5.90    6.70    7.40
  S12  4.75            5.90    6.70                    10.2
  S14  4.75            5.90                    7.95            12.2
 Result (hr):
  S15-S0 = 0x0701 = 0b0000011100000001
  S0   4.75
  S8   4.75            5.90
  S9   4.75            5.90    6.70
  S10  4.75            5.90    6.70    7.40

In this test, an s15_s0 featuring a configuration with 6k70 allowed does
not result in m6_70 == 1:

 Input:
  S15-S0 = 0x0c12 = 0b0000110000010010
  S1   4.75            5.90            7.40                    12.2
  S4                                   7.40
  S10  4.75            5.90    6.70    7.40
  S11  4.75            5.90    6.70    7.40
 Output:
  cfg.smod=0 spare=0 icmi=1 nscb=0 ver=1
      m4_75=1 ------- m5_90=1 ------- m7_40=1 ------- ------- m12_2=1

Almost every conversion contains errors like this.

Related: I900fda192742fa8f6dd54e9131ef1704b14cc41a
Change-Id: Iec7c491d9fadd37d9e43fbaac8e709c2029f8a8e
2023-02-28 23:00:45 +00: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
Vadim Yanitskiy 2a0b121f48 doxygen: remove documentation for non-existent params
Change-Id: I8b1be37c8fdaa824637d306bdb40a3b78616f614
2023-02-28 18:48:56 +00:00
Vadim Yanitskiy ed501d3172 contrib/struct_endianness.py: simplify file extension check
Change-Id: Iaf7194fdfc3772973f9a9c806d375a9a56ff57c8
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 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