Commit Graph

1716 Commits

Author SHA1 Message Date
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
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
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
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 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
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
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
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
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
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
Harald Welte 5e3aaf9f0d gsmtap.h: Define a packet type for encapsulation of GSM RLP frames
This allows us to feed RLP frames (occurring in GSM CSD) into wireshark
for dissection.

Change-Id: Ibb7f0731c31e5a5cd2911f733da5510ce0f3a1d6
2023-03-24 13:07:58 +00:00
Vadim Yanitskiy c57cc4bf64 gsm0808: handle new enum gsm48_chan_mode speech/data values
Change-Id: I87d977228b1e039c2876941d1c6df1f69d1a54d4
Related: OS#1572
2023-03-23 18:38:11 +07:00
Vadim Yanitskiy 173c84c52e gsm_04_08: add more enum gsm48_chan_mode data values
From 3GPP TS 44.018 (version 15.4.0), table 10.5.2.6.1.

Change-Id: Ia6b428e5b6aaecf151cbfa980b89eff6d0fe6006
Related: OS#1572
2023-03-23 18:38:11 +07:00
Vadim Yanitskiy 1c88ff9ba5 gsm_04_08: add more enum gsm48_chan_mode speech values
From 3GPP TS 44.018 (version 15.4.0), table 10.5.2.6.1.

Change-Id: I6adda28698c0e479ef20f5d090c1f7f76a2ec97e
Related: OS#1572
2023-03-23 18:38:11 +07:00
Vadim Yanitskiy 8c7f023784 gsm_04_08: document/clarify enum gsm48_chan_mode values
The values are defined in 3GPP TS 44.018, section 10.5.2.6.  Only the
radio interface rates for CSD (GSM48_CMODE_DATA_*) are given, but the
respective service rates can be found in 3GPP TS 45.003.

Change-Id: I716027f73ab6f20037f6de16e4a3740811aa38a2
Related: OS#1572
2023-03-23 18:38:11 +07:00
Pau Espin 559a6ee683 Fix parsing of TLV_TYPE_SINGLE_TV
The decoding path of TLV_TYPE_SINGLE_TV is wrong, since it is not
shifting right the tag before using it. On the other hand, the encoding
path (tlv_encode_one) is doing that, so it is clear there's a bug.

It seems that in order to workaround the bug some IEs in gsm_04_08.h (TS
24.008 and TS 44.018) were defined incorrectly (eg 0x80) while the spec
clearly assigns eg. "8" to it, and makes sure no full byte IEI collides.
Some other IEIs like GSM48_IE_GMM_CIPH_CKSN which are also of the same
type were already correctly defined as 0x08.

Change-Id: I799e35dc8d4d153fa63bf50563a5482cdf4de2d7
2023-03-22 14:23:51 +01: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
Pau Espin 3e5609ade6 gsm: gsm_gsmtime2fn(): constify param
Change-Id: Ib29d5a8e7dcf50fb086f967857b0afa076573163
2023-03-06 13:59:40 +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 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 2a0b121f48 doxygen: remove documentation for non-existent params
Change-Id: I8b1be37c8fdaa824637d306bdb40a3b78616f614
2023-02-28 18:48:56 +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
Philipp Maier 6b69b554f7 i460_mux: add define constant for maximum number of subchannels
Lets get rid of the magic number in struct osmo_i460_timeslot and
replace it with a define constant.

Change-Id: Id3a3782927c7dcbc873223d56129f291c04fee26
Related: OS#5198
2023-02-24 13:38:22 +00:00
Vadim Yanitskiy 82001ebc2a gsm: ensure completeness of osmo_bts_features_{descs,names}[]
It already happened several times [1][2] that new features were added
to enum osmo_bts_features, but the osmo_bts_features_{descs,names}[]
were left unchanged.  Let's add static_assert()s to prevent this.

Change-Id: I8e3b7d3996e9f3e16c6d4e0d1d406fa538d5e9be
Related: [1] f4f5d54ea2
Related: [2] 18c6a8183f
2023-02-24 17:06:21 +07:00
Neels Hofmeyr ba1e20055f add osmo_prim_operation_name()
Also remove the explicit array dimension from the .h file.

Change-Id: I9f43428af654a5674ac3035fe4db1394aac7a7af
2023-02-22 16:45:14 +00:00
Harald Welte 9b7c9ae6ca Rename OSMO_AUTH_ALG_XOR to OSMO_AUTH_ALG_XOR_3G
Let's disambiguate.  Our existing OSMO_AUTH_ALG_XOR was always only
the XOR-3G algorithm.  Now that we recently introduced XOR-2G,
let's rename (with backwards compatibility #define).

Change-Id: I446e54d0ddf4a18c46ee022b1249af73552e3ce1
2023-02-22 09:45:15 +01:00
Harald Welte e93c5e99b6 Implement the XOR-2G authentication algorithm
We've so far only been supporting XOR-3G algorithm as specified
in TS 34.108 (in both 3G and 2G-derivation mode).

However, XOR-3G used for 2G auth is different from the XOR-2G algorithm
as defined in Annex A of TS 51.010-1.  Let's add support for that one,
too.

Change-Id: I0ee0565382c1e4515d44ff9b1752685c0a66ae39
2023-02-21 22:25:04 +01:00
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