Commit Graph

920 Commits

Author SHA1 Message Date
Harald Welte 4f155022d8 cbsp: Add osmo_cbsp_segmentation_cb for message segmentation
This call-back can for example be used as segmentation call-back
for libosmo-netif stream_cli/stream_srv or directly for osmo_io.

Related: OS#5755
Change-Id: I5e922c54b3431d759b38e81e55076125c5a34008
2024-03-02 20:48:23 +01:00
Alexander Couzens 3938dfba5c gsup.h: define newly added PCO IE
PCO - Protocol Configuration Options 3GPP TS 24.008 / 10.5.6.3.
The PCO will be used by the osmo-epdg to pass PCO internally.
The PCO will be passed towards to the PGW in the Session Request.

Related: OS#6369
Related: osmo-gsm-manuals.git Change-Id Id912ead4e1205f84a40af6505a5ddf050d1e086d
Change-Id: I0f9de90c7c67fe194b441a9d118eba70f09afb5e
2024-02-27 17:08:18 +00:00
Pau Espin 74ee02420a gsup: Convert PDP-Type IE to PDP-Address IE
The previous PDP-Type IE should have been a PDP-Address from the
start, since having only PDP-Type with no address is only a specific
case (dynamic addressing).
This becomes clear by looking at other similar protocols like:
* MAP: APN-Configuration IE has servedPartyIP-IP{v4,v6}-Address IEs
* Diameter S6b, 3GPP TS 29.272 7.3.35 APN-Configuration contains
  Served-Party-IP-Address AVPs
* Diameter SWx, 3GPP TS 29.273 APN-Configuration.
* GTPv1C Ts 29.060 7.7.29 PDP Context containing PDP Address.

Since PDP-Type on its own really makes no sense, being it a special case
of PDP-Address, let's keep the IE by renaming it (keeping old name too
for API backward compat) and extend it to support lengths > 2 bytes.

Old implementation of libosmogsm gsup actually ignored lengths > 2
bytes, so we are safe acting against older implementations here, both
on the sending and receiving side on the wire.

The big drawback of this commit is that it breaks ABI compatibility due
to adding "struct osmo_sockaddr pdp_address[2];" to struct
osmo_gsup_pdp_info, which in turn affects shift of fields in struct
osmo_gsup_message. Unfortunately, there's not much that can be done to
improve the situation when adding the missing field, due to existing API
having the same struct for all messages. Ideally we'd have 1 union with
structs per message type inside, this way the ABI break would be far
less pronounced.

The GSUP test output change is becaue we now accept some of the len>2
cases for PDP-Type/Address IE which were being rejected since a couple
commits ago.

libosmogsm gsup code is now disabled in EMBEDDED mode, since it nows
depends on core/socket.h (struct osmo_sockaddr) which is not available
in EMBEDDED, and hence fails during build:
"""
In file included from /build/include/osmocom/gsm/gsup.h:45,
                 from /build/src/gsm/gsup_sms.c:28:
/build/include/osmocom/core/socket.h:15:10: fatal error: arpa/inet.h: No such file or directory
   15 | #include <arpa/inet.h>
      |          ^~~~~~~~~~~~~
"""

Related: OS#6091
Change-Id: I775ff9c3be165d9f30d6ab55d03f99b6104eadd6
2024-01-20 00:31:28 +01:00
Pau Espin 68a04dfc88 gsup: Deprecate field pdp_type in favour of pdp_type_nr and pdp_type_org
Having both fields in an uin16_t integer makes it difficult and
confusing for users for no good reason. Let's have separate fields for
each of them.

The new fields are defined so that they are ABI compatible with previous
uin16 field.

Change-Id: Ie31c6080c90e468c01186259f2c42621e39b5cc6
2024-01-20 00:31:28 +01:00
Pau Espin f2be74b67b gsup: Fail decoding if len of PDP Type IE is less than 2 bytes
As documented in gsup.adoc, this field is expected to be 2 bytes.

This is only a intermediate step to showcase the related test scenarios
submitting IE with len > 2. The logic will be changed in a follow-up
patch when changing the IE to also encode/decode the missing Address
part.

Change-Id: I0d024a9a4fb10beeff39ac33a9d2ed02f88f4580
2024-01-20 00:31:28 +01:00
Vadim Yanitskiy 90df3f40f1 gsm: fix osmo_mobile_identity_decode(): init *mi on error
Change-Id: I1c1503120c6c0e5479d8350fe762470bdb6266b8
2024-01-08 21:38:47 +07:00
Vadim Yanitskiy 0cddf19b0b gsm48_ie: fix various issues in doxygen docs
Change-Id: Id168c5115588b2dbc48605ee0bba13ccc9913bbe
2024-01-07 16:33:34 +07:00
Vadim Yanitskiy 704d9e50fc gsm0808_utils: use osmo_strbuf API, drop APPEND_{THING,STR,CELL_ID_U}
This code predates 2cbe25f4, adding osmo_strbuf API and so using its
own append-to-strbuf implementation.  Let's use the new generic API.

Change-Id: Ifdfd18eeef6a0932995063259f9f179b22e781de
2024-01-05 15:36:40 +00:00
Harald Welte 7f2b22b5fc rlp: Add support for 576bit RLP frames
The code so far only supported 240bit RLP frames; Add support for
576bit in this patch.  We still only support versions 0+1 and not
version 2.

Change-Id: Idfdcabb19fe8733fb9c5ee76a39b0bf4cdf60c2c
2023-12-17 10:48:58 +00:00
Pau Espin ca540be807 ipa_ccm_tlv_to_unitdata(): free previous string if present before allocating new one
Change-Id: I66cbd900676875145810ad1d5c07e719311852fb
2023-12-14 15:14:35 +00:00
Alexander Couzens 75cc2466b0 gsup: fix error log message
The error happened in auth info and not in PDP info

Change-Id: I37ac6b5d7d34ba2ab0f83bcc1701b86b1a245014
2023-12-05 18:36:29 +00:00
Harald Welte be3c38ca55 Add a GSM RLP decoder and encoder
This code implements a decoder and encoder for the RLP (Radio Link
Protocol) as used in the bearer channel of GSM CSD (Circuit Switched
Data).

Change-Id: I2d9bd8eb4f0cd0f72c436996767b199429596917
2023-11-29 14:35:36 +00:00
Andreas Eversberg 285f3693de Add flag to enable RTS based polling
RTS based polling in LAPDm code is disabled by default. Make libosmogsm
stay compatible with existing applications that do not use RTS based
polling.

This patch fixes the issue that LAPDM_ENT_F_POLLING_ONLY did enable RTS
based polling too, which breaks existing applications like older
versions of osmo-bts.

Change-Id: I2a75c192bbc24e85bfc1656b2be21cea7a92814a
2023-11-29 14:19:48 +01:00
Alexander Couzens 505f70552a gsup: add message type for osmo-epdg CEAI interface
The CEIA interface is an interface between osmo-epdg and
strongswan.
It is used by the osmo-epdg to synchronize state.

Related: OS#6091
Change-Id: I6f7c20340c99f94b1326a8a7dc99c86cf6a0dbc3
2023-11-28 17:05:22 +00:00
Andreas Eversberg bd2b897b72 LAPDm: Add a flag to enable suppression of subsequent REJ frame
This behaviour was default in earlier versions of LAPDm/LAPD. Because it
is only required for osmocom-bb, a flag is added to enable it there.

Related: OS#5969
Change-Id: I93994dbbd1fc2c9edb8f3015c6b18ecd0fce0565
2023-11-27 16:25:53 +00:00
Andreas Eversberg f51f916e1c LAPDm: Add an extra queue for UI frames
The extra queue is used to transmit the UI frame only when there is no
frame in the regular TX queue. This allows to give LAPD frames prioity
over UI frame.

Related: OS#4074
Change-Id: I00c8ee73be8b7c564a4dee3fca3e893484f567da
2023-11-27 16:25:53 +00:00
Andreas Eversberg 2d7119d85b LAPDm: Add support for RTS based polling
The lower layer must set the 'POLLING_ONLY' flag and provide frame
number when polling a frame. If T200 is pending, it is started with a
timeout frame number in advance to given frame number.

The lower layer must call lapdm_t200_fn() after a frame has been
received or if a frame has not been received. Also it must be called
after a TCH frame has been received. LAPDm uses this to check the T200
timeout condition.

A new function is used to set the frame number based timeout values.

Related: OS#4074
Change-Id: I6ebe83f829d7751ea9de1d90eb478c7a628db64c
2023-11-27 16:25:53 +00:00
Andreas Eversberg 1bb0b99552 LAPD: Always update N(R) in pending TX frames if V(R) is incremented
The outcome of the update function is still used to indicate if an RR
frame must be sent or not. Only if there is no I frame in the TX queue,
RR frame must be sent.

Related: OS#4074
Change-Id: I71676c709878105bfd18b9370fecc61b92796a6f
2023-11-15 21:28:22 +00:00
Manawyrm 714843a455 gsm48_ie.c: change bearer cap structure in outgoing CSD calls
Outgoing CSD calls were previously encoded with the
Bearer Capability 1 - Octet 4 "Structure" field set to
3 - Unstructured. Many Nokia, Sony Ericsson and Huawei devices
won't accept incoming CSD calls with these bits set.

Set them to 0 - Service data unit integrity for now, which
seems to work and make all tested devices happy.

Change-Id: Ieb5bca3d3578abd28e18808752e1c312ce7c4ce0
2023-10-17 11:22:10 +00:00
Manawyrm de776d7bc0 gsm48_ie.c: add 3.1kHz audio bearer capability for CSD calls
GSM48_BCAP_ITCAP_3k1_AUDIO should be handled just like fax or
unregistricted digital CSD calls. The transfer capability just
indicates that an (external) interworking function should convert
the call into an analog modem call on the network edge.
The CSD call is still regular V.110/RLP non-transparent data.

Change-Id: I44b76be0f6a891bc1d8f55ede1ef140ea0a19e3d
2023-10-17 11:22:03 +00:00
Pau Espin aca2c724ae Bump version: 1.8.0.252-13c29 → 1.9.0
Change-Id: I6f8eccbccb73c6c094f13f2d4bdee931cf5b9010
2023-09-12 13:15:54 +02:00
Andreas Eversberg 16ad6c29fe LAPDM: Use correct offset to short header on recevied frame
The offset of the short header on main DCCH is 0, not 2.

Change-Id: I8345776768fdf2a700b2ca1d117f9ef4b15777cc
2023-09-12 10:42:48 +00:00
Andreas Eversberg 0267b34290 ASCI: Add BCC call state definitions
BCC and GCC share same call states, except for two states that have same
value, but different state names and conditions.

Related: OS#5364
Change-Id: I2180b43b940542565188f52c554c960858fe2a95
2023-09-12 10:42:48 +00:00
Vadim Yanitskiy 13c29c7c73 gsm_12_21.h: fix typo: NM_IPAC_F_CHANT_P{C->D}CHF
Change-Id: I35ee30978820f2038f562b7703ca886852a4f708
Fixes: a7d7cf28 "gsm_12_21.h: add flags for NM_ATT_IPACC_SUPP_FEATURES"
2023-09-12 05:16:32 +07:00
Vadim Yanitskiy a7d7cf284d gsm_12_21.h: add flags for NM_ATT_IPACC_SUPP_FEATURES
Change-Id: Ia4208e10d61843dd6ae77398f6624c918dc81ea4
2023-09-05 19:04:58 +07:00
Pau Espin 45ab0d7335 lapdm: Update public lapdm_msg_ctx upon CCCH data ind
This allows uses accessing the updated fields such as fn from the l3_cb
when receiving a msg from CCCH, eg: "le->datalink[DL_SAPI0].mctx.fn;"

Related: OS#3626
Change-Id: Icabc3759c47b0f7cfe61f1b7a96f08f36714262e
2023-08-24 13:48:19 +00:00
Pau Espin 0ef0a1cb1e Revert "rsl: Introduce new osmocom extension IE RSL_IE_OSMO_ABS_FRAME_NUMBER"
This reverts commit 54b1b3be37.

osmo-bts is forwarding the msgbs as they come from lapdm to the RSL on
the wire, which means we end up sending the osmocom-specific IEs on the
wire, something which was not envisioned when adding this IE.

Change-Id: Id9029ef378970322063478e9ce888daf335d6103
Related: OS#6142
2023-08-23 17:13:34 +00:00
Pau Espin 06da40bdb3 Revert "lapdm: Append RSL_IE_OSMO_ABS_FRAME_NUMBER to RSLms msgs towards upper layers"
This reverts commit d981794113.

osmo-bts is forwarding the msgbs as they come from lapdm to the RSL on
the wire, which means we end up sending the osmocom-specific IEs on the
wire, something which was not envisioned when adding this IE.

Change-Id: I0ab0d5b545b4862e72eb1842edd07ca2e4955311
Related: OS#6142
2023-08-23 17:13:34 +00:00
Pau Espin d981794113 lapdm: Append RSL_IE_OSMO_ABS_FRAME_NUMBER to RSLms msgs towards upper layers
This makes it possible to track GSM time in the upper layers.
The existing RSL_IE_FRAME_NUMBER and RSL_IE_STARTNG_TIME cannot be used
there, since those are 16bit fields containing Relative FN values.

The IE needs to be added before the L3_INFO one, because user code
usually assumes the msgb->l3 pointing to L3_INFO value extends until the
end of the message, using msgb3_len(msg). Regarding having an extra IE
at the middle, it's not a big problem since the libosmocore version
submitting this commit to the upper layers is the same which will also
be parsing it through rsl_tlv_parse() later on by the app.

Related: OS#3626
Change-Id: Id62c18f49f270449067b25b7104eb8b47f1955ec
2023-08-21 14:34:55 +00:00
Pau Espin 54b1b3be37 rsl: Introduce new osmocom extension IE RSL_IE_OSMO_ABS_FRAME_NUMBER
This will be used in RSLms to provide Absolute Frame Number information
of the primitive indications being sent to upper layers, so that it's
possible to track GSM time in the upper layers.
The existing RSL_IE_FRAME_NUMBER and RSL_IE_STARTNG_TIME cannot be used
there, since those are 16bit fields containing Relative FN values.

Related: OS#3626
Change-Id: Ia28caa24dd141b1162b6e11500d753353fe6500d
2023-08-21 14:34:55 +00:00
Pau Espin aea78a2483 gsm: Introduce functions to convert between FN and RFN (Reduced FN)
Implementation ported from osmo-pcu.git
e98b315d12fb009359410809f4169f9380f3d933, function bts_rfn_to_fn().

This functionality can be used by osmo-pcu, libosmo-gprs or any other
related code which needs to handle RFNs.

Change-Id: Ib71e8da976f6cc84c3a4ab17b0a8c2101492e243
2023-08-11 20:46:04 +02:00
Pau Espin 1247aa1fc0 lapdm: Track fn of primitives in struct lapdm_msg_ctx
This field will be used in follow-up commits to provide FN information
in RSLms primitives towars upper layers. This is needed for instance on
the MS side when a CCCH_DATA.ind is received containing a TBF ImmAss
with a relative FN indicating the Starting Time. Without tracking FN
advance, the uppers layers are not capable of figuring out the absolute
FN of the TBF Starting time.

The struct lapdm_msg_ctx is not really used outside of libosmocore, so
we are safe extending it.

Related: OS#3626
Change-Id: Icf986f4202703eb452bedc1b749bb8ce0c73706f
2023-08-11 17:37:07 +02:00
Pau Espin f6ebc8a9d0 cosmetic: lapdm: Fix typo in comment
Change-Id: I5cf9aea6ba072bd1ccb3e894c0a311844bcad8df
2023-08-09 18:57:35 +02:00
Andreas Eversberg 209bc38974 ASCI: Add missing check for return value of gsm0808_enc_speech_codec_list2()
Fixes: CID#318987
Change-Id: I771b8ee8dfe1588d0af1c4957489f723447a7054
2023-07-26 12:52:30 +00:00
Vadim Yanitskiy d0be3909b8 gsm48_ie: fix gsm48_encode_bearer_cap(): encode bcap->data.transp
Currently this function is hard-coding the "Connection element (octet
6c)" (see Table 10.5.101h/3GPP TS 24.008) to "Transparent" (0).  This
breaks non-transparent data calls.

Use the value from bcap->data.transp.  The decoding equivalent of
this function needs no changes, it does populate this field already.

Change-Id: I7339908864e8a2aef6f2b48a108650167e413c7f
Related: OS#6110, OS#4394
2023-07-26 02:32:49 +07:00
Vadim Yanitskiy f93ef0c634 gsm_08_08: define GSM0808_SCT_EXT (separately)
As per 3GPP TS 48.008, section 3.2.2.103, the "Codec Type" field may
contain either a certain 3GPP Speech Codec Type directly (4 bit value),
or the so called "Codec Extension" = 0xFh, in which case the real Codec
Type follows in the next octet as "Extended Codec Type".

CSD is such an example, the encoding is defined as follows:

     8    7    6    5    4    3    2    1
  +----+----+----+----+-------------------+
  | -- | PI | PT | -- |        0xFh       |
  +----+----+----+----+-------------------+
  |      Extended Codec Type (CSData)     |
  +----+----+-----------------------------+
  | R2 | R3 |                             |
  +----+----+-----------------------------+

  CSData is coded with 0xFDh or '1111 1101' (0xfd).

Let's have the "Codec Extension" value clearly defined in the header
file, but intentionally separate from the other GSM0808_SCT_* values.

Change-Id: Iafaa25070684d2ba400c75fa33e803651a5ce857
Related: OS#6110, OS#4393, OS#4394
2023-07-25 04:23:12 +07:00
arehbein 4ff5db2839 Revert "gsm/ipa: Add segmentation callback"
It has been decided that the segmentation callback be changed
and moved to libosmo-netif, so we remove it here.

This reverts commit 2c59d1285e.

Related: OS#5753
Change-Id: I9b380326c63587fc79d6a5d8cd458188074fc55d
2023-07-18 09:55:26 +00:00
Vadim Yanitskiy 9ec7749f01 lapdm: cosmetic: simplify lapdm_phsap_up(), use OSMO_PRIM[_HDR]
Change-Id: I87dedca0a38f290ae56649373dc9172433b8e4b1
Related: OS#3626
2023-07-10 09:53:00 +00:00
Sylvain Munaut c87c6a3a73 gsm: Improve the TCH/H2.4 coding routines
The spec isn't super clear, but basically the conv coding is done
in two blocks of 72 bits.

The way it's currently implemented isn't "wrong" in the sense it will
produce correct output given no bit errors, but it's better to do the
decoding in two blocks because this then it makes use of the fact we
know the state of the encoder after the 72 bits, which improves the
corrective ability of the code.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Id2551ffe2a0ebfd0a6df0e1d288a6f0af7e1eda7
2023-07-07 16:06:26 +02:00
Vadim Yanitskiy 403dfbc345 ipa: fix a typo in ipa_ccm_rcvmsg_base(): PING -> PONG
Change-Id: I83e7326758e533a008eec28641dae619216ea84a
2023-07-05 00:54:06 +07:00
Andreas Eversberg e4c7b0adcd ASCI: Add decoding of mobile identity in TALKER INDICATION
gsm48.c provides a function to decode mobile identity from various
messages. TALKER INDICATION is sent by the talking subscriber of a voice
group call to idenitfy the current talker. The mobile identity is
required to distinguish between calling subscriber and other subscribers.

Related: OS#4854
Change-Id: I331fac82e3c15abb01f554b2e70576100f2eea2d
2023-06-28 11:54:55 +00:00
Andreas Eversberg 72ab3b5200 ASCI: Also display group/broadcast call message names
gsm48_pdisc_msgtype_name* will include group and broadcast call control
message names too.

Change-Id: I1874e61c24cd8e66b74171681d22f0bfe8069158
2023-06-28 11:52:16 +00:00
Vadim Yanitskiy f0a1f41cdc gsm0502: cosmetic: use ARRAY_SIZE in gsm0502_fn2ccch_block()
Change-Id: Ideb9907fcb5eff74508f44714e478ec46d435a5d
2023-06-25 15:47:13 +07:00
Vadim Yanitskiy 418d76c2cb gsm: add gsm0502_fn2ccch_block()
This API is useful for checking whether a Downlink CCCH block belongs
to PCH or AGCH.  We need this API in osmo-bts.git and osmocom-bb.git.

Change-Id: I8cbd31226754e95887358ed83a928e2f567f4cf3
Related: OS#5500
2023-06-25 08:45:26 +00:00
arehbein 2c59d1285e gsm/ipa: Add segmentation callback
Add segmentation callback to be used by the streaming backend of libosmo-netif

Related: OS#5753, OS#5751
Change-Id: I3a639e6896cc3b3fc8e9b2e1a58254710efa0d3f
2023-06-19 18:30:47 +00:00
Andreas Eversberg cb72e74031 lapdm: Do not return an error when enqueuing a frame
If tx_ph_data_enqueue() is called, frames will be written into a queue,
if there is a pending frame or if polling of TX frames is used. In
this case the return value must be 0.

Sending a RSL_MT_UNIT_DATA_REQ from upper layer causes a call to
tx_ph_data_enqueue(). The return code is returned to the sender. The
sender must not get an error returned, if the message is enqueued.

Change-Id: Iaeaf7c66cb3cf5cc81bc8e15d468e8e7704c1407
2023-06-09 15:06:34 +00:00
Andreas Eversberg 0370018eae Add support for receiving Bter UI frames at lapdm.c
Similar to support of sending Bter frame, the same rules apply when
receiving them.

Change-Id: If04115884743455c7bf2b2bc5f7e49e74b6ffb60
2023-06-09 15:06:34 +00:00
Andreas Eversberg 6799741699 Add support for sending Bter UI frames at lapdm.c
Bter frames may be used on downlink of a main DCCH or SACCH channel.
It applies to SAPI 0 and UI frames only. It includes a short layer 2
header with 2 bits only. All other bits are used for the message. The
message size is 23 bytes on main DCCH and 21 bytes on SACCH.
The length of the L3 messsage is used to distinguish between Bter frames
and other (UI) frames.

Note that the L3 message header is different, so that the length of the
UI frame will determine which header is used.

Change-Id: Ia3a25c009d1ff09f83258bdb226a85b81466d7a1
2023-06-09 15:06:34 +00:00
Andreas Eversberg 532b8e92c5 ASCI: Add message definition and encoding according to 3GPP TS 48.008
Change-Id: Ib94c64136c31ce4af67c314a8550d93946cc844f
2023-06-09 15:06:34 +00:00
Neels Hofmeyr 8d42394c89 improve API for osmo_routing_area_id
Code review for [1] has asked for providing proper API for struct
osmo_routing_area_id.

For historical reasons, we have struct gprs_ra_id and
struct osmo_routing_area_id serving the exact same purpose: represent a
decoded 3GPP TS 24.008 § 10.5.5.15 Routing area identification.

The "better" one is struct osmo_routing_area_id: it allows using API
like osmo_plmn_cmp(), because it is made up of meaningful sub-structs.

Implement de/coding using the functions already available for the
sub-struct osmo_location_area_id, and simply add the RAC.

Add a test in gsm0408_test.c.

Note that other utility functions are already available for struct
osmo_routing_area_id: osmo_rai_name2(), osmo_rai_cmp().

There is no real need to deprecate struct gprs_ra_id, because there is
not really anything wrong with it. It just isn't as well integrated with
other utility API as struct osmo_routing_area_id is. Just add comments.

[1] osmo-hnbgw.git:
    cnpool: extract Mobile Identity from RANAP payload
    https://gerrit.osmocom.org/c/osmo-hnbgw/+/33133
    I373d665c9684b607207f68094188eab63209db51

Change-Id: Ic5e0406d9e20b0d4e1372fa30ba11a1e69f5cc94
2023-06-08 00:55:40 +02:00