Commit Graph

4290 Commits

Author SHA1 Message Date
Pau Espin 0cdd0abd53 cbsp: Add enum and value string for Cause
Change-Id: I35592bb4fff2e7b442d0e0cd537b66687862baf2
2022-06-09 18:17:43 +02:00
Pau Espin 6d6d22ea34 iuup: Fix IPTIs_present not set to 0 if no IPTIs received
Related: SYS#5969
Change-Id: I503dc509ad8619f13cd83ae03261a2297e2b9fc7
2022-05-27 14:30:30 +02:00
Vadim Yanitskiy b57e6392fb coding: separate gsm0503_tch_a[fh]s_decode_inband()
These functions can be re-used for parsing in-band data from DTX
specific frames like SID_FIRST, SID_UPDATE, SID_ONSET, etc.

Change-Id: I0106de7a7f87517006e323299b2dc08457d1c6cf
Related: OS#5570
2022-05-27 08:31:30 +00:00
Vadim Yanitskiy cc4213e927 coding: add gsm0503_detect_a[fh]s_dtx_frame2()
The new functions accept an additional mode_id poiner, which is
currently set for the following frames: AFS_ONSET, AHS_ONSET,
AHS_SID_FIRST_P2 with N * 16 - M bit pattern.

Also, the new API accepts soft-bits instead of hard-bits.
Converting bits from soft to hard is now performed internally.

Change-Id: Ibcac395f800bb64150c97fcdaca3523ecfc5fcee
Related: OS#5570
2022-05-27 08:31:30 +00:00
Pau Espin fe1dcebe3a cosmetic: iuup.h: Fix indentation
Change-Id: I10a2d2a872fd6fdae8b4af94995300af3144b551
2022-05-25 19:43:13 +02:00
Pau Espin 510f4c9d63 iuup: Rework API to support RFCI IDs != RFCI index
The initially merged IuUP API and implementation assumed that RFCI with
ID was always in the position of its ID inside the list of RFCIs. This
was the case for messages sent by ip.access nano3g as well as our own
osmocom implementation. However it was noticed that other nodes from
other vendors actually use other order, as allowed by the IuUP message
format.
Hence, we need to break the assumption and provide explicit ID
information in the list.

NOTICE: This commit breaks API and ABI compatibility with older versions
of libosmogsm, but not with any previous release of libosmocore since
the API is only available in master so far (it was added in
9fe1f9fb0b).
Similary, it's only user (osmo-mgw) only uses the API in master, so
there's no API breakage with older releases.

Related: SYS#5969
Change-Id: Ib21cee2e30bf83dff4e167f79541796007af9845
2022-05-25 14:10:17 +00:00
Vadim Yanitskiy d6dca0c2f9 coding: do not reset codec ID on receipt of DTX frames
Parsing of CMI/CMC/CMR from AMR's special DTX frames is currently
not implemented.  It's better to keep the old stored value rather
than resetting it to 0 every time we receive such a frame.
Add TODO comments for each DTX frame type.

Change-Id: Ic4edbb8ab873fe0bdd69a8710803628bc4f447d0
Related: OS#5570
2022-05-25 13:34:31 +00:00
Vadim Yanitskiy 7790459c8e coding: fix decoding of AHS_SID_UPDATE frames (BER ~50%)
As was demonstrated in [1], there is a TCH/AHS specific problem in
libosmocoding causing unexpected BER ~50% in decoded AHS_SID_UPDATE
frames.  The reason is that A[H]S_SID_UPDATE employs quite tricky
interleaving algorithm, which is different from the algorithm used
by normal TCH/AHS speech frames or A[F]S_SID_UPDATE frames.

An AHS_SID_UPDATE frame consists of two halves (228 bits each):

  +---------+--------------------|---------+--------------------+
  | in-band |     SID marker     | in-band |     coded data     |
  +---------+--------------------|---------+--------------------+
  | 16 bits |      212 bits      | 16 bits |      212 bits      |

The first half contains coded in-band signalling data (16 bits) and
the identification marker (212 bits), which allows to detect that
it's an AHS_SID_UPDATE.  This half is carried by even bits of the
first two bursts and odd bits of the last two bursts.

The other half also contains the in-band data (16 bits), while the
remaining 212 bits contain encoded SID_UPDATE (212 bits).  This
half is carried by even bits of the last two bursts and odd bits
of the first two bursts.

Current implementation does not use odd bits of the first two
bursts at all, so buffer cB[] in gsm0503_tch_ahs_decode_dtx()
contains only 114 out of 228 bits.

This patch changes the logic, so that gsm0503_tch_ahs_decode_dtx()
would not split AHS_SID_UPDATE onto two frames anymore like its
TCH/AFS equivalent does, but attempt to deinterleave the second
half and attempt to decode the payload immediately.

Change-Id: I8686d895e96fa0e606c1898b6574cc80a8f46983
Related: [1] I434157e2091a306c039123cea08d84bd8533c937
Related: SYS#5853
2022-05-25 13:34:31 +00:00
Philipp Maier 9802c14489 reader: more meaningful null pointer check in get_sw
At the moment msgb_apdu_de(resp) is used to check if the msgb that is
handed over to get_sw is properly populated with data.

However, since msgb_apdu_de() is just adding an offset, which cannot be
0 to ->l2h the returned value also can never be NULL. This means that we
cannot use msgb_apdu_de() to detect if resp contains a nullpointer.

Lets check if ->l2h is not NULL instead. This will make sure that ->l2h
is populated.

Change-Id: I32bc56c9264c01911a4f4b4f911b09e955205010
Related: OS#5560
2022-05-24 17:59:40 +02:00
Vadim Yanitskiy 32aff359ae tests/dtx: test tagging of FACCH/[FH] frames
This patch adds a new test confirming that [1] actually fixes the bug.

Change-Id: I3d295a15d4446b3e440fbf4c90a1688d6c7275ae
Related: [1] I2e6f4b748c6445725211e264ab5f3f5a2712087a
Related: SYS#5853
2022-05-19 20:25:53 +03:00
Vadim Yanitskiy f673fd59c1 tests/dtx: test detection/decoding of A[FH]S_SID_UPDATE
This patch extends the existing unit test coverage for AMR's special
DTX frames.  The new tests confirm that the problem with unexpected
BER in decoded AFS_SID_UPDATE frames has been actually fixed [1].

Additionally this patch demonstrates another TCH/AHS specific problem,
which negatively affects RxQual-SUB measurements in osmo-bts-trx: the
actual content of AHS_SID_UPDATE_CN is decoded with ~50% BER, because
the burst buffer contains only half of the burst bits.

Change-Id: I434157e2091a306c039123cea08d84bd8533c937
Related: [1] I813081a4c0865958eee2496fe251ae17235ac842
Related: SYS#5853
2022-05-19 20:20:58 +03:00
Harald Welte b17cc809fb fsm_vty: use unsigned int when left-shifting 31 bits!
fsm_vty.c:64:8: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Change-Id: I637bce52fae947922cbb8642a0313d174c827422
2022-05-17 09:09:19 +00:00
Vadim Yanitskiy a2bee8bc88 coding: prevent marking FACCH frames as AMR's special DTX frames
Both gsm0503_tch_a[fh]s_decode_dtx() functions accept an optional
'dtx' pointer, which is used to indicate type of a received AMR
block to the caller in DTX mode of operation.  If not NULL, it's
expected to be updated by gsm0503_detect_a[fh]s_dtx_frame() every
time one of the mentioned functions is called.

However, in case of FACCH both functions return early, so the value
of dtx remains unchanged and thus FACCH frames may be misinterpreted
as AMR's special DTX frames.  This is rather critical during the DTX
silence periods, when all special DTX frames (e.g. SID_UPDATE) are
being treated as SUB frames.  Each unsuccessful FACCH decoding
attempt will 'poison' SUB measurements, causing unexpected RxQual-
SUB values in the Uplink measurement reports.

Fix this by resetting *dtx to AMR_OTHER in the FACCH specific path.

Change-Id: I2e6f4b748c6445725211e264ab5f3f5a2712087a
Related: SYS#5853
2022-05-16 20:13:13 +03:00
Vadim Yanitskiy 71e8091c9d coding: properly handle AFS_SID_UPDATE frames in DTX mode
There are two similar values in enum gsm0503_amr_dtx_frames:

  * AFS_SID_UPDATE - precursor of SID UPDATE,
  * AFS_SID_UPDATE_CN - the actual SID UPDATE.

The former is internally used by libosmocoding to mark the current
frame as a precursor of the actual SID UPDATE frame - the later.

  +---+---+---+---+---+---+---+---+
  | _ | _ | _ | _ | a | b | c | d |  AFS_SID_UPDATE
  +---+---+---+---+---+---+---+---+
  | a | b | c | d | _ | _ | _ | _ |  AFS_SID_UPDATE_CN
  +---+---+---+---+---+---+---+---+

This is required because function gsm0503_tch_afs_decode_dtx() is
invoked by TDMA scheduler on every 4th received burst, while the
burst buffer is 8 bursts wide.

Currently, whenever gsm0503_detect_afs_dtx_frame() detects an
AFS_SID_UPDATE frame, we still attempt to decode it as a speech
or data below in gsm0503_tch_afs_decode_dtx().  This is indeed
a bug, which results in unexpected BER values:

  * expected BER 0/212,
  * actual BER 252/448.

We should return immediately once we have detected an AFS_SID_UPDATE.
This patch fixes unexpected BER-SUB values during DTXu silence periods.

Change-Id: I813081a4c0865958eee2496fe251ae17235ac842
Related: SYS#5853
2022-05-16 00:51:57 +03:00
Vadim Yanitskiy eebaccdae5 coding: use switch statement in gsm0503_tch_a[fh]s_decode_dtx()
Change-Id: Ib63b6f582b305746c3618563f2f85128fffd8e90
Related: SYS#5853
2022-05-16 00:51:57 +03:00
Vadim Yanitskiy bf2d5e9b6f coding: cosmetic: move 'dtx_prev' to the scope where it's used
Change-Id: I147f44f1c071e53febeff425a0a7837a0ff10436
Related: SYS#5853
2022-05-16 00:51:30 +03:00
Pau Espin 6c58d155eb coding: Use ARRAY_SIZE macro
Change-Id: I6b7a2a3a7be6a1d92038ff3b249e539fcd0f639e
2022-05-13 14:09:43 +02:00
Pau Espin 7fba76608f osmo-arfcn: Fix false positive in gcc 12.1.0
The pointer is initialized in all its uses, however newer gcc warns
about it:
"""
inlined from ‘main’ at /libosmocore/utils/osmo-arfcn.c:144:16:
/usr/include/bits/stdlib-float.h:27:10: error: ‘param’ may be used uninitialized [-Werror=maybe-uninitialized]
"""

Change-Id: If3eff4ab14a7b2a950386244c9b5f2b9adb32f99
2022-05-13 13:20:48 +02:00
Pau Espin d2737e6027 coding: Refactor function to avoid gcc false positive warn
"""
/libosmocore/src/coding/gsm0503_coding.c: In function 'osmo_conv_decode_ber_punctured':
/libosmocore/src/coding/gsm0503_coding.c:563:31: error: 'coded_len' may be used uninitialized [-Werror=maybe-uninitialized]
  563 |                 *n_bits_total = coded_len;
      |                 ~~~~~~~~~~~~~~^~~~~~~~~~~
/libosmocore/src/coding/gsm0503_coding.c:541:21: note: 'coded_len' was declared here
  541 |         int res, i, coded_len;
      |                     ^~~~~~~~~
"""

This error is really a false positive. However, it is true that the code
used to be a bit more complex than required, since the 2 later conditions
could be inside the first one.
Let's simply do early termination to simplify the function, and get rid
of the gcc warning.

Change-Id: I31ebf0c4be61daf6395d9a9fac05c7fdceb8bcb9
2022-05-13 13:07:23 +02:00
Harald Welte 8f25fd27ed stats: don't try to save unknown stats reporter types
The point of having a public API to register further stats reporters
is to enable applications or other libraries to do so.  As we in
libosmocore don't know anything about the parameters of such a stats
reporter, don't try to do a partial save of them when saving the config
file.

Change-Id: I2986313375daec1c4959a6a914e3fb2980a5d7ca
2022-05-08 10:02:43 +02:00
Harald Welte e8e24c7be9 stats: Avoid NULL pointer deref in allocation failure paths.
We should either handle talloc returning NULL, or we should
OSMO_ASSERT().  Doing neither of the two is a bad idea.

Change-Id: I5e8d1cc22cf597f7f50c0f92bf86cb1f1413434c
2022-05-08 10:02:43 +02:00
Harald Welte 1e1436ce75 stats: Functions with no arguments should specify(void)
... otherwise callers might pass arbitrary arguments without raising
a compiler error or warning.

Change-Id: Ia2de1d13df5f00dcc42493090734a635029d76b5
2022-05-08 09:57:04 +02:00
Pau Espin 7ac0451ae8 gsm_12_21.h: Add header description pointing to TS files
Change-Id: I20d5bb659d84228a951b66228b7c172bce3ee929
2022-05-04 17:08:38 +02:00
Pau Espin 7813cc95aa gsm_12_21.h: Fix abis_nm_avail_state InTest and Failed values
This has always been wrong since at least libosmocore initial commit in
2010.

Change-Id: Ib854a1284fbd38951bb2d1cb3706c42ba7e14ccb
2022-05-04 17:08:34 +02:00
Sylvain Munaut 903705604a build: Disable libusb and libmnl for embedded builds
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ie7900098ffda7cebfab81c08b25b0001e6fd98ec
2022-04-29 07:39:43 +00:00
Pau Espin 9d3cfeff3e cosmetic: logging.h: fix indentation
Change-Id: Ia7f43e061275da1a8233f90df173d1ae18691964
2022-04-28 14:53:21 +00:00
Vadim Yanitskiy f6fd0bb7f2 coding: fix comments for detect_afs_sid_{first,update,onset}
Change-Id: I42edc3caee09c1a4bebecc41e8be46914dc7f8ef
Related: SYS#5853
2022-04-28 13:03:00 +00:00
Harald Welte 3b007f86ac vty: Add a 'skip-zero' version of 'show stats' and 'show rate-counters'
In many cases, a lot of the counters are zero, and we're likely
not interested in those, but only the non-zero counters.  Add a version
of the 'show stats' command which dumps only those items with a non-zero
total value.

Change-Id: Ie4df1c139e3c82deca1dd3cdab5d3909e0513684
2022-04-28 06:05:29 +00:00
Vadim Yanitskiy be5e838dbb Use internal <osmocom/core/talloc.h> everywhere
Change-Id: If40e1eefcfa88a2b376becfe057836acdd3a1cc2
2022-04-27 12:42:15 +00:00
Pau Espin 1dac8756fd gsm: Introduce helper rach_tx_integer_raw2val()
Change-Id: I6ef085ee92b2064cb46fa5ec3ae98a0ca59ad599
2022-04-26 17:47:57 +02:00
Pau Espin b0c2f75665 jenkins: Validate gsm 08.58 IEs are added to tlv_definition
It was recently found that several IEs which were added in the header
file were not actually added to the tlv_definition, and hence the tlv
parser failed to decode them. Let's make sure we don't foget to add new
IEs in the future.

Related: SYS#5915

Change-Id: Id8a679ca43eb0fcc4882780e9a95ec21c7f51972
2022-04-05 17:38:25 +02:00
Pau Espin 388a53a8d7 rsl: Fix tlv_parse of IPAC_DLCX_IND message
The IE was missing in rsl_att_tlvdef.

Related: SYS#5915
Change-Id: Ib637197ef3508ec94aec05d08d4e6aa15ddea055
2022-04-05 17:32:41 +02:00
Daniel Willmann 767bfd8c87 bssgp_bvc_fsm: Add a hook to notify when a reset was acknowledged
There are cases where we want to be notified of a successful BVC reset,
e.g. for a signalling because we can then start resetting the PtP-BVCs.
With this hook it's now possible to do that.

Change-Id: If240dd13f0f674693018c93390386b2c8afb97af
Related: SYS#5908
2022-03-30 18:00:56 +02:00
Harald Welte c17546faff vty: Support platforms that don't support pthread_getname_np()
pthread_getname_np() is a non-portable extension of pthreads.  While
it exists in glibc, for example musl didn't have it until rather
recently (April 2021) and there still hasn't yet been a musl release
with this change, resulting even current OpenWRT not yet supporting
pthread_getname_np.

So let's check if pthread_getname_np is supported, and only use it
in that case.

Change-Id: Ibd01485af24e2fe574006f8d049bf37226dda966
2022-03-29 12:58:01 +00:00
Pau Espin c80a004f0b configure: Support libsctp < 1.0.17 without libsctp.pc
libsctp 1.0.17 is the first to contain a pkgconfig file in upstream.
Current OpenSure Leap 15.3 as well as our OpenEmbedded meta-telephony
layer still ship 1.0.16 which contain no pkgconfig file.

Let's attempt first finding the .pc file, and otherwise manually link
against the lib.

Related: https://bugzilla.opensuse.org/show_bug.cgi?id=1197590
Related: https://build.opensuse.org/request/show/965348
Fixes: 12eed19066
Change-Id: I241634388c2d32adffebd860c88bdd13002a6af0
2022-03-29 11:59:51 +02:00
Pau Espin 39f47983e1 libosmocore.pc.in: put libsctp in Requires.private
The libsctp use in libosmocore is internal, not exposed to applications.
Hence, it must not be in "Requires" but in "Requires.private".

Fixes: 12eed19066
Change-Id: Ic3e4e191990e6b76ec52b81e506b49980e20ce20
2022-03-29 11:23:42 +02:00
Harald Welte e1a0aaa860 libosmovty: Link libosmovty against libpthread
Ever since Change-Id If76a4bd2cc7b3c7adf5d84790a944d78be70e10a in 2020
(part of libosmocore >= 1.4.0) we have introduced cpu_sched_vty.c, which
directly uses libpthread.  As a result, libosmovty should be using
pthread compiler flags and link against libpthread.

This missing dependency is causing osmocom applications to
fail to link on OpenWRT (at leats for ath79-generic).

Change-Id: I7febbf88cbe61eacd05f46a9316e773b5c148e77
Related: SYS#4986
2022-03-27 23:31:24 +02:00
Harald Welte c73a160743 libosmocore.spec: Make libosmocore-devel require libsctp
Now that the libosmo*.pc files 'Require' the libsctp pkg-config
file to be installed, we need an explicit package dependency
from libosmocore-devel to lksctp-tools-devel, the package providing
the related libsctp.pc file.

Change-Id: I967369f6726e88946872881d298ab90440ca2c0e
2022-03-25 11:30:09 +01:00
Harald Welte 609001d089 libosmo{gb,vty}.pc.in: Add talloc to 'Requires'
Both libraries use talloc symbols so they should require it,
see https://gerrit.osmocom.org/c/libosmocore/+/27521/1/libosmogb.pc.in#9

In subsequent patches, we should move all of those to Requires.private,
but I wanted to fix it step by step.

Change-Id: I755275ce4f4148b5beffaa28a6a0ce2dd0e2d6b4
2022-03-25 09:45:42 +00:00
Harald Welte a47eefee56 debian/control: libosmocore-dev must depend on libsctp-dev and libusb-1.0-0-dev
As our pkg-config files now 'Require' libsctp, we are seeing build
failures as libsctp-dev is not installed when building
libosmocore-dependant packages.  Let's add the missing dependency.

Change-Id: I5d61149cd5b571586d426d1d6bf929e73a322fff
Fixes: I2ab1fe8e4bbfc120b471d6c9f2312a89dbc7d42b
2022-03-25 10:39:39 +01:00
Harald Welte 12eed19066 clean-up pkg-config files: Make use of "Requires" as documented
According to the pkg-config manual, "Libs" should not contain flags
for _required_ packages.  Instead, they should be expressed via
"Requires".  Let's do that

Change-Id: I2ab1fe8e4bbfc120b471d6c9f2312a89dbc7d42b
2022-03-24 14:57:22 +00:00
Vadim Yanitskiy be1338789a bssmap_le: support additional IEs in Perform Location Request
Change-Id: I8775a93cf4089b1752d040e43d2cba6b8997f955
Related: SYS#5891
2022-03-22 18:38:19 +03:00
Pau Espin 2d10ff20a6 jenkins: Validate IEs are added to tlv_definition
It was recently found that several IEs which were added in the header
file were not actually added to the tlv_definition, and hence the tlv
parser failed to decode them. Let's make sure we don't foget to add new
IEs in the future.

Related: SYS#5891
Change-Id: I1f6c274ea86b5803bbf1d845473b98078f46d1ad
2022-03-18 17:36:46 +01:00
Pau Espin 3cf475917e gsm0808: Add missing IEs in bss_att_tlvdef
Change-Id: I8660640ce50a6dc20e718c4165ccf779c5f553a4
2022-03-18 17:36:46 +01:00
Pau Espin e8b69138f7 cosmetic: gsm_08_08.h: Add space between assignment sides
This allows easier parsing of all the enum fields using scripts.

Change-Id: Iebd51985551a98978b81f76f778ac7892a440d5c
2022-03-18 17:36:46 +01:00
Pau Espin fffd7c345b gsm0808: Fix decoding of IE GSM0808_IE_LCS_CLIENT_TYPE
Change-Id: I7acafdefd105e330c466df2e17e884327651e348
2022-03-18 17:36:46 +01:00
Pau Espin a3987fcf39 gsm0808_test: Add new unit test showing dec error
This unit tests shows how decoding of such message fails. Fix will be
provided in a follow up patch to make the test pass.

Related: SYS#5891
Change-Id: Ib4ff71d5e01d464febb062c5bfe3e06ee5a19ecd
2022-03-18 17:36:43 +01:00
Vadim Yanitskiy 381dc61099 contrib/jenkins_amd64.sh: remove FreeBSD specific quirks
We don't run build verification on FreeBSD anymore.

Change-Id: Ia3a9a49cade453a937ee230163ca44930a39d639
2022-03-13 21:56:36 +00:00
Oliver Smith 5e24eea15c Cosmetic: linuxlist.h: fix misleading comment
Whenever iterating over a list and removing entries,
llist_for_each_entry_safe must be used instead of llist_for_each_entry.

The comment with "non-consecutive(!)" entries sounds like this is not
needed as long as one is iterating over the list consecutively. I guess
that might have worked with prefetch logic, however the prefetch
function is just a stub in linuxlist.h. (Also prefetch has been removed
from list.h in linux.git e66eed651fd18a961f11cda62f3b5286c8cc4f9f.)

Change-Id: I217e6871afe121edba26e4c6fd1a461e397c9e72
2022-03-13 21:36:27 +00:00
Vadim Yanitskiy 7ec19de720 libosmocodec: osmo_hr_check_sid(): simplify the logic
According to TS 101 318, section 5.2.2, a SID frame is identified
by a SID codeword consisting of 79 bits (r34..r112) which are all 1.
Given that there are no gaps in the codeword, we don't really need
to use bitvec_get_bit_pos() and check each field individually.
This brings additional complexity and negatively affects performance.

Instead, let's use bitvec_get_bit_pos() to check all bits in a row.

Change-Id: I678f8ff92317fe87f1aca511a3a062ad898e55cc
Related: SYS#5853
2022-03-10 13:57:39 +03:00