Commit Graph

4558 Commits

Author SHA1 Message Date
Mychaela N. Falconia 0e17d57495 libosmocoding.map: export gsm0503_tch_hr_decode2()
In commit 57a3b3a51f I added new function gsm0503_tch_hr_decode2(),
but I forgot to add it to libosmocoding.map - and without the latter,
osmo-bts-trx and other applications can't use the new function.
Fix that omission.

Related: OS#5688
Change-Id: I6e75ca95409b5c368e8e04d0e0aba41e0331d9e6
2023-05-23 19:02:53 +00:00
Mychaela N. Falconia 57a3b3a51f gsm0503_tch_hr_decode2(): new function, emits TS101318 format
The original design of gsm0503_tch_hr_{en,de}code() functions contains
a mistake in that a pseudo-RFC5993 format was chosen for HR codec frame
input and output, instead of "pure" (agnostic to outer RTP encoding)
form of 14 bytes.  We would like to change this design so that we can
feed pure 14-byte HR codec frames to the channel coding function and
get such frames back from the channel decoding function - however,
we cannot break libosmocoding API for existing users.  In the decoding
direction, create a new function that emits TS 101 318 format, and
turn the legacy gsm0503_tch_hr_decode() API into a wrapper function
for backward compatibility.

Related: OS#5688
Change-Id: If28ddb20789e8993b7558ca08020478615b4c708
2023-05-23 16:42:01 +00:00
Mychaela N. Falconia 8d8d5af957 gsm0503_tch_hr_encode(): accept both TS101318 and RFC5993 payloads
The original design of gsm0503_tch_hr_{en,de}code() functions contains
a mistake in that a pseudo-RFC5993 format was chosen for HR codec frame
input and output, instead of "pure" (agnostic to outer RTP encoding)
form of 14 bytes.  We would like to change this design so that we can
feed pure 14-byte HR codec frames to the channel coding function and
get such frames back from the channel decoding function - however,
we cannot break libosmocoding API for existing users.  In the encoding
direction, make the new format our preferred one, but support the
extra-octet format for backward compatibility.

Related: OS#5688
Change-Id: I13eaad366f9f68615b9e9e4a5f87396a0e9dea0f
2023-05-23 16:41:05 +00:00
Mychaela N. Falconia 920c0ed86f gsm0503_tch_hr_decode(): look at all 8 stealing bits
This function needs to look at hl and hu stealing bits in order to
decide if it should decode FACCH/H instead of TCH/HS traffic.
However, out of the 8 (in total) hl and hu bits that get set when
FACCH/H stealing takes place, the function only looked at 7 of them
- one was missed.  Fix this bug.

Change-Id: I08c4358b26d69910190f89a53b654bc58c2efea9
2023-05-23 14:06:53 +00:00
Neels Hofmeyr a9c29b45ea gsm_04_08_gprs: add IEI "GMM TMSI Based NRI Container"
OsmoHNBGW will need to obtain the NRI from GMM Attach Request and GMM
RAU Request to implement CN pooling.

Related: SYS#6412
Change-Id: Id661abfdb2c81a92c9046542bbc08d6ccd39f073
2023-05-22 15:35:02 +00:00
Harald Welte 1dffb53aac gsm_08_58.h: Add 'struct rsl_ie_nch_drx_info'
This adds the definition of 'struct rsl_ie_nch_drx_info' representing
the bit-field of the 'NCH DRX Information IE' of A-bis RSL.

Change-Id: I9586b5cb8514010d9358fcfc97c3d34741294522
Related: OS#5781
2023-05-22 10:33:10 +00:00
Harald Welte 8079a0636e cosmetic: Fix spec reference in RSL header file
Change-Id: I671ee927b49099f7c8cc1fbd5f8b19f94ba1af81
2023-05-22 10:33:10 +00:00
Harald Welte 1192687620 Add osmo_gsm48_si1ro_nch_pos_{encode,decode} functions
These functions encode/decode the NCH position field within the SI1
rest octets.  This is used within ASCI (VBS/VGCS).

Change-Id: I24a0095ac6eee0197f9d9ef9895c7795df6cdc49
Related: OS#5781
2023-05-22 10:33:10 +00:00
Vadim Yanitskiy 242ef1bdea coding: declare gsm0503_tch_f96_[de]interleave()
Change-Id: I9a631db088a4e279668beb962c98cc1a0929f44d
Related: OS#1572
2023-05-20 19:06:11 +07:00
Vadim Yanitskiy 548990bf6c coding: gsm0503_tch_f96_[de]interleave() not applicable to TCH/F2.4
According to 3GPP TS 45.003, section 3.6.4, the interleaving for
TCH/F2.4 is done as specified for the TCH/FS in subclause 3.1.3.

Change-Id: I52078263cd593503a9e8f024e51e18d7b0906131
Related: OS#1572
2023-05-20 19:06:11 +07:00
Vadim Yanitskiy c0305b685a coding: use GSM_MACBLOCK_LEN gsm0503_tch_fr_decode()
Change-Id: I488ca3db1ca093d19abcfba78c1516509870715d
Related: OS#1572
2023-05-20 19:05:41 +07:00
Daniel Willmann cbbd17e3f4 osmo_io: Support detecting non-blocking connect()
libosmo-netif does a non blocking connect(), which as per definition of
 the socket API is signalled from the OS to the user by marking the file
descriptor writable.

osmo_io needs to signal this somehow. Previously osmo_io would only call
the write_cb if actual data has been sent. This patch changes the behaviour
so that calling osmo_iofd_write_enable() will call write_cb() on a writable
socket even if the write queue is empty.

Change-Id: I893cbc3becd5e125f2f06b3654578aed0aacadf3
2023-05-19 12:50:21 +00:00
Daniel Willmann d4d03705f9 osmo_io: Improve handling and documentation of segmentation_cb
The read length is not needed in the segmentation callback, msgb
already has all the necessary information, the parameter previously was
just msgb_length(msg).

Also handle negative return values (except -EAGAIN) of the callback as
errors which cause the msg to be dropped. -EAGAIN will defer the msg.

Change-Id: I6a0eebb8d4490f09a3cc6eb97d4ff47b4a8fd377
2023-05-19 12:50:21 +00:00
arehbein 0c374c68a1 core: Add function to update osmo_io_ops field for osmo_io_fd
Added, because the field 'io_ops' of 'struct osmo_io_fd' is not a
reference, so subsequent changes to the osmo_io_ops structure that was
used to set it up aren't automatically reflected in the osmo_io_fd
structure that got its copy.

Change-Id: Ie45402ad8e86e3cecf75ad78a512c17e61e68b19
2023-05-19 12:50:24 +02:00
Vadim Yanitskiy 03590fcee4 copyright: fix typo: sysmocom s/s.m.f.c./s.f.m.c./ GmbH
Change-Id: Ia0952b3b0ce6871e92fa02a3c6ea69c211a0c04d
2023-05-19 08:48:48 +00:00
Mychaela N. Falconia f3e4745603 coding: fix decoding of EFR triplicated bits
In GSM 05.03 channel coding for EFR, there are 4 bits out of the
244-bit EFR codec frame that are triplicated before FR-like encoding,
and the decoder needs to apply a 2-out-of-3 majority voting function
to each of these triplicated bits after the FR-like decoding step.
For one of those 4 bits, this majority voting function was wrong
in the decoder implemented in gsm0503_tch_fr_decode() - fix it.

Change-Id: I47def75cdb066ed6372df4567404cc828589ed53
2023-05-19 08:44:35 +00:00
Pau Espin d9d61b0188 cosmetic: codec/Makefile.am: list sources one file per line
Change-Id: I299fdb887f640151bf57d6423b0e08ffa8cd02f8
2023-05-18 10:54:26 +02:00
Mychaela N. Falconia 5eb356be99 codec: replace GSM-FR ECU with new implementation
The original GSM-FR ECU implementation from 2017 exhibits a lot of
defects, as detailed in OS#6027.  Replace it with a new implementation
based on Themyscira libgsmfrp (a complete Rx DTX handler for GSM-FR),
but reduced to just the ECU function, without the comfort noise
generator function.  (These two functions are coupled together in the
classic GSM architecture, but not in libosmocodec ECU model.)

Related: OS#6027
Change-Id: I0200e423ca6165c1313ec9a4effc3f3047f5f032
2023-05-17 13:53:20 +00:00
Mychaela N. Falconia 8fa13c66ac codec cosmetic: move old FR ECU code to ecu_fr_old.c
The current FR codec ECU implementation consists of two parts:
there is a pair of functions that implement the actual functionality,
and these functions are also made public as a now-deprecated legacy
API - and there is the new ECU abstraction.  If the FR ECU
implementation behind the generic ECU abstraction is to be changed
to a different one, the old implementation still has to be retained
for those public legacy osmo_ecu_fr_reset() and osmo_ecu_fr_conceal()
API functions to remain available and unbroken.  Move this legacy
ECU implementation to its own C module in preparation for changing
the preferred ECU implementation.

Related: OS#6027
Change-Id: Ia169b8bcc6331227a11b78eb7ffca0c7ab838c69
2023-05-17 13:53:20 +00:00
Pau Espin 8f026bf3b7 ns2: Count transmitted/dropped in each layer implementation
This allows better control on how the counters are ticked.
For instance, since nowadays the writing in ns2_udp is done
asyncrhonously, most probable failures occur at a later point and not
when returning to the caller.

Change-Id: I8109cee07f157ebf1806f82a071f58de3a2dcc9c
2023-05-16 08:04:40 +00:00
Daniel Willmann fa3a9ce9fd gpsr_ns2_udp: Use osmo_io_fd instead of osmo_fd
Change-Id: Id776d2d9f35c304620f3d5b94492148dd987f5a0
2023-05-16 08:04:23 +00:00
Vadim Yanitskiy fed02e01d9 coding: fix doxygen doc for _xcch_encode_cB()
Change-Id: I09ed28bd3060b9c2c958f0f465a92af7d6bacadd
2023-05-15 16:50:08 +00:00
Daniel Willmann a4b958bda2 osmo_io: Avoid read of uninitialized variable
Change-Id: Ica8087c73fc10f01026fdbe692b172ad07fe593d
Fixes: CID#315618
2023-05-15 18:10:25 +02:00
Mychaela N. Falconia f86ec508e9 codec: add osmo_gsm611_silence_frame[] datum
Table 1 in section 6 of 3GPP TS 46.011 (FR codec, substitution and
muting of lost frames) specifies a silence frame in the form of
GSM 06.10 parameters - add a const datum to libosmocodec embodying
this GSM 06.11 silence frame in GSM-FR RTP encoding.

Related: OS#6027
Change-Id: Idf31051ea783435268944286a71d2b0ac342a4b5
2023-05-10 18:18:42 +00:00
Daniel Willmann 37b2ebfc84 tests: Add initial osmo_io tests
Change-Id: Ia67629e53f4d2e5784177250d58e268fdfcaa0c2
2023-05-10 06:06:03 +00:00
Harald Welte 8857f3b798 Add osmo_io with initial poll backend
* make backend configurable for later
* segmentation callback for chunked streams
* logging target for osmo_io
* support partial writes

Change-Id: I50d73cf550d6ce8154bf827bf47408131cf5b0a0
Related: SYS#5094, OS#5751
2023-05-10 06:04:57 +00:00
arehbein 99653047d7 core: Check return value of osmo_fd_register()
Change-Id: I15bb456c42d5033c9cf4c0937df22fa02b6a6086
2023-05-09 23:37:34 +00:00
Mychaela N. Falconia 341c4ec3a4 codec: add osmo_{fr,efr}_is_any_sid() inline functions
Recently added osmo_{fr,efr}_sid_classify() functions classify FR
(EFR) codec frames according to the rules of GSM 06.31 (06.81)
section 6.1.1.  Both of these specs also define the term "accepted
SID frame", encompassing both valid and invalid SID frames, but not
regular speech frames.  A boolean check for this wider category of
"accepted SID frame" is a useful function - many existing calls to
legacy osmo_{fr,efr}_check_sid() functions should be converted
to this "accepted SID frame" check for full correctness.  Add wrapper
functions for convenience, and to allow this transition to be made
without adding bloat to every use instance.

Change-Id: I5e6e91baf18440af01dccc6ac0171476a8a5c71c
2023-05-09 07:51:12 +00:00
Neels Hofmeyr e25786ab6a gsm: add osmo_mobile_identity_decode_from_l3_buf()
We have osmo_mobile_identity_decode_from_l3(), which takes a msgb as
argument, and decodes msg->l3h. Not all callers have their data in this
form. Offer a more flexible API for the same decoding.

For example, before the new function, osmo-hnbgw, which extracts a NAS
PDU from asn.1 packed data for CN pooling, would allocate a new msgb and
copy the NAS data just to pass a data pointer as argument.

Related: SYS#6412
Change-Id: I9bd99ccd01f0eedc091fe51687ff92ae1fdff60b
2023-05-06 03:49:08 +00:00
Neels Hofmeyr e4b84738b5 vty: move struct vty_parent_node to private API
Change-Id: Id2070f03b09feea966c5342361d409551e557d38
2023-05-06 03:49:08 +00:00
Neels Hofmeyr 67d84d2131 vty: fix vty->index for implicit go_parent_node
After this patch, most vty_go_parent() functions are really obsolete, as
originally intended: A vty_go_parent() is only needed if the program
requires an action to run on VTY node exit.

vty_transcript_test.vty shows the fixed behavior.

For details, see preceding patch
"vty: show bug in implicit go_parent_node"
I2472daed7436a1947655b06d34eb217e595bc7f3

Change-Id: Id408c678d18ba19b1c1394c3fb657536153d2094
2023-05-06 03:49:08 +00:00
Neels Hofmeyr cc9b699931 vty: show bug in implicit go_parent_node
Add test to show a problem in VTY node exiting.

Back in 2017 when I introduced VTY config file scopes by indenting [1],
I actually mistook the vty->priv for the vty->index that we use
everywhere to link to the state for our VTY nodes.

The intention was that each VTY node child level has its own object
linked to it by the vty->index pointer. When the config file leaves a
scope, the vty->index should reflect the parent object.

Instead I implemented that for the vty->priv pointer only, but we don't
use that.

Why did this bug not show? A problem happens only if:
- a node that uses vty->index is nested inside a node that also uses
  vty->index.
- config sets parent node attributes after a child node.
- there is no legacy vty_go_parent() function that sets the correct
  index via a switch().

[1]
"VTY: implicit node exit by de-indenting, not parent lookup"
4a31ffa2f0
I24cbb3f6de111f2d31110c3c484c066f1153aac9

Change-Id: I2472daed7436a1947655b06d34eb217e595bc7f3
2023-05-06 03:49:08 +00:00
Philipp Maier 4cf72df3f9 codec: add define constants for RFC5993 and TS101318
The difference between the RFC5993 and the TS101318 format is only that
RFC5993 has one additional ToC (Table of contents) byte at the
beginning. However it can be difficult to remember which of the two
formats has the ToC byte at at the beginning and which hasn't.

Let's add a constant that defines the length for both formats so that we
can make it more clear in the code which format we are refering to.

Related: OS#5688
Change-Id: I125ef9cdab98c073971841c175b1a7dcd927f9c2
2023-05-04 00:10:47 +00:00
Pau Espin beb7c1741e Fix 'Fix parsing of TLV_TYPE_SINGLE_TV'
A commit was merged recently attempting to fix decoding of
TLV_TYPE_SINGLE_TV. It did mostly a good job, but missed updating the
o_tag pointer used to fill in the structures.
This commit fixes that specific part missing.

Fixes: 559a6ee683
Change-Id: Id619459c17976b77cd2c7e4179123bb06807285c
2023-05-02 15:20:53 +02:00
Pau Espin e2217ee098 tlv: Show bug in decoded tlv_parsed for type TLV_TYPE_SINGLE_TV
A commit was merged recently attempting to fix decoding of
TLV_TYPE_SINGLE_TV. It did mostly a good job, but missed updating the
o_tag pointer used to fill in the structures.
This new unit test showcases the mentioned problem.
A follow-up patch will fix the bug.

Change-Id: Ia17c84059a413f80c2bcf194034ebac586ecf7e1
2023-05-02 12:11:26 +02:00
Pau Espin f6ef9ba1e9 gb: ns2: Rename parameter name in gprs_ns2_nsvc_by_sockaddr_bind()
The old name seems to describe that this function can only be used in
incoming message paths, but it can be used in transmitting context too,
so the param is actually a remote address.

Change-Id: I3f45a4ef339cadd47920ee3b36c38628b38221f6
2023-04-27 17:52:16 +02:00
Oliver Smith 779ff09fc9 debian: set compat level to 10
Related: OS#5958
Change-Id: I6ee4aace6bf7c246338408c41f790189d75d5488
2023-04-27 12:28:12 +00:00
Pau Espin 550fdf8b6b gsm_04_08_gprs.h: Add enum field for GMM 'P-TMSI type' IE
Change-Id: Ief4e03785f01f07c8d97b33bbb55c89a863baccc
2023-04-25 18:37:36 +02:00
Vadim Yanitskiy 68d5139abc libosmocore.map: add missing symbols needed for osmo-qcdiag
Change 213fc420e broke osmo-qcdiag:

  /usr/bin/ld: diagchar_hdlc.o: in function `osmo_crc16_ccitt_byte':
  src/diagchar_hdlc.c:46: undefined reference to `osmo_crc16_ccitt_table'
  /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
  collect2: error: ld returned 1 exit status
  make: *** [Makefile:8: osmo-qcdiag-log] Error 1

Change-Id: I7e84546b484db4822554681b31625d0520617d2b
Fixes: 213fc420e "Add libosmocore.map"
2023-04-23 01:48:50 +07:00
Mychaela N. Falconia 295636b320 codec: add SID preening functions for FR & EFR
Those network elements which receive a stream of codec frames that
may come from the uplink of GSM call A and which are responsible
for preparing the frame stream for the downlink of GSM call B
(OsmoMGW feeding TRAU-DL, or OsmoBTS receiving RTP and feeding DL
to its PHY) must be prepared for the possibility that their
incoming frame stream may contain corrupted SID frames, presumably
from bit errors on radio link A.  Per the rules of section 6.1.1
of GSM 06.31 for FR and GSM 06.81 for EFR, SID frames with just one
errored bit are still to be accepted as valid, whereas frames with
more corrupted bits which are still recognizable as SID are classified
as invalid SID.

In the case of a TrFO call, the entity switching from leg A UL to
leg B DL is responsible for *not* transmitting invalid SID frames
on the destination leg (they should be treated like BFIs), and any
deemed-valid SID frames that are forwarded should be preened,
correcting that one bit error they may exhibit.  The functions
added here provide that functionality.

Change-Id: Iec5c1f2619a82499f61cb3e5a7cd03ff0f020ad8
2023-04-17 17:19:25 +00:00
Mychaela N. Falconia ec65085d5f codec: add SID classification functions per GSM 06.31 & 06.81
The existing osmo_{fr,efr}_check_sid() functions detect whether or not
the frame of bits passed to them constitutes an absolutely perfect
SID frame, with each of 95 SID code word bits set to 0 for FR or
1 for EFR.  However, the rules of section 6.1.1 in GSM 06.31 & 06.81
allow up to one bit to be in error for the frame to be accepted as
valid SID, and the same rules also call out a third state (invalid SID)
in between valid SID frames and other frames that are classified as
speech.  Support for these rules cannot be patched into those familiar
osmo_{fr,efr}_check_sid() functions because doing so would alter
behavior of existing programs, hence new functions need to be added.

The new functions that implement the exact rules of section 6.1.1 of
GSM 06.31 and 06.81 will need to be used if anyone needs to construct
an outgoing TRAU-UL frame (for example, as part of implementing
TS 28.062 TFO), and they are expected to be useful as part of more
sophisticated ECU implementations.

Change-Id: Ie91a52c6f04689082d8004311517d8ce0c544916
2023-04-16 01:34:35 +00:00
Neels Hofmeyr 91f5eee672 logging vty: probe 'print' and 'logging timestamp' cmds
Upcoming patch I58c792dda3cbcf8618648ba4429c27fa398a9e15 aims to change
the timestamp configuration. Show current state before these changes.

Change-Id: I8e0a373496130004e453a2044c1091665fe02a05
2023-04-14 22:52:30 +00:00
Pau Espin 5e79a302d5 gsm_04_08_gprs.h: Add missing GMM IEs for T3302 and T3346
As specified in TS 24.008 9.4.4 "Attach reject"

Change-Id: I2d36d76ee6fe8ed1a36e37a7d74fbbdc9c27c2c7
2023-04-13 13:46:34 +02:00
Max 028813414c logging: print talloc report on exit from vty test
There's not much point in deallocating memory in a test fixture
which is about to terminate anyway. Having talloc report though
is handy to make sure we're not leaking smth.

Change-Id: I5739bceb90d36164fd4cbf21242bbe26bd1e7075
2023-04-05 10:41:48 +00:00
Vadim Yanitskiy 37dc995234 core: remove unnecessary #include <osmocom/core/talloc.h>
Including this header just for TALLOC_CTX is an overkill, we use
'void *' for talloc contexts in nearly all other Osmocom projects.

Change-Id: I4b9ffd7a329081df3d2c0b0ee8698a3cf759e94e
Related: OS#5960
2023-03-31 05:39:24 +07:00
Vadim Yanitskiy 48c60f9771 fixup (partial revert): "coding: clean up Makefile.am"
This is a partial revert of "9dca9027 coding: clean up Makefile.am".

Even though libosmocoding does not use talloc API, it still depends on
this library indirectly via libosmo{core,codec,gsm}.  Furthermore, some
of libosmocore's header files do #include <osmocom/core/talloc.h>, and
thus #include <talloc.h> via this internal header.

Under Slackware 14.2 talloc.h header lives in /usr/include/samba-4.0,
and without $(TALLOC_CFLAGS) compilation of libmsocoding fails due
to the preprocessor failing to find this header.  The culprit is my
recent patch 9dca9027 removing $(TALLOC_CFLAGS) and $(TALLOC_LIBS).

Put $(TALLOC_CFLAGS) back to AM_CFLAGS;  it will likely be emply under
distributions having talloc.h header in the standard include dir.  The
$(TALLOC_LIBS) does not need to be resurrected because libtool will
add '-ltalloc' automatically for each libosmo*.la in LIBADD.

Change-Id: Ic1bd82159a827af21fe36bea998f8f58f732473a
Related: OS#5960
2023-03-31 05:10:52 +07:00
Vadim Yanitskiy 89a3fc95af tests: make VTY tests depend on the respective binaries
Change-Id: I784fe3b5737b804f7b55da01d8beb619c57bafd6
2023-03-30 12:32:53 +00:00
Pau Espin ec7d5029ef gsm: Add missing TS 24.008 SM layer IEs
Change-Id: Iec0dbf617c8d0f2c8c44156d936244cedda9b303
2023-03-28 18:22:09 +02:00
Mychaela N. Falconia 7f91880534 codec: add osmo_efr_check_sid() function
Previously existing code provides osmo_fr_check_sid() and
osmo_hr_check_sid() functions for FR1 and HR1 codecs; these functions
are used by various RTP-touching programs in the Osmocom CNI suite
when they need to differentiate between speech and SID frames.
However, there was no corresponding function of this form for EFR
codec, with the result being that the same programs that handle
speech vs SID distinction correctly for FR1 and HR1 fail to do so
for EFR.

The present change adds an osmo_efr_check_sid() function to libosmocodec
that fully mirrors previously existing osmo_fr_check_sid() and
osmo_hr_check_sid(), providing the first step toward more correct
EFR handling in programs where a SID check may be needed.

Change-Id: Iab9fb60028f4135375287bc42f5da7ca7838b5f0
2023-03-25 08:04:04 +00:00
Harald Welte 8969298a77 rate_ctr: Add rate_ctr_add2() similar to rate_ctr_inc2()
The convenience wrapper relieves the caller from manually resolving
the individual counter, and instead specify just the counter group
and the index.

Change-Id: If93e8b4fb0b86a87358f32d2b45438ca1887e9f3
2023-03-24 14:08:08 +01:00