Commit Graph

1667 Commits

Author SHA1 Message Date
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
Andreas Eversberg 5560c040bd Fix union abis_rsl_chan_nr and abis_rsl_link_id
All bit fields in a union will overlap in memory, as all elements in a
union do. To prevent the bit fields from overlapping, wrap them into a
packed structure.

Change-Id: I5ef5aa62be8310da4ebe9ea73ebbedcbcc2ba49c
2023-11-29 10:15:33 +00: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 49b7087360 LAPD: Add support for RTS based polling and T200
The T200 timer is started when the current frame is polled at
PH-READY-TO-SEND event.

A flag is used to enable this feature. The user of LAPD core must track
frame numbers to check the timeout condition. Then it must call the
external timeout function.

Related: OS#4074
Change-Id: Ib961b5a44911b99b0487641533301749c0286995
2023-11-27 16:25:53 +00:00
Vadim Yanitskiy d4b94ceb88 soft_uart: fix spelling in doxygen docs
Change-Id: Ib719d1fe4ee6c058860e861c91ec2417d9dff0af
2023-11-24 03:00:02 +07:00
Harald Welte 38d8170fa4 osmo_io: rename unsupported SCTP mode to OSMO_IO_FD_MODE_SCTP_RECVMSG_SEND
The two functions of the SCTP socket interface we use in osmo-* are
sctp_send() and sctp_recvmsg().  We do not use sctp_sendmsg() at all,
so let's make sure the mode is named correctly.

Change-Id: Ie2d1c7ce6f211dbe025a0e843ad733443102ea15
Related: OS#5751
2023-11-22 12:20:12 +00:00
Harald Welte 641cc3c60d add new osmo_sockaddr_from_str_and_uint() function
The function is basically a shortcut for getaddrinfo with storing the
output data into our 'struct osmo_sockaddr'.

Change-Id: I6b5c0bf8ca97e6358d992fb2ff45ffd53ba15197
Related: SYS#6657
2023-11-22 12:18:26 +00:00
Vadim Yanitskiy 0d78a00b9f soft_uart: implement OSMO_SUART_PARITY_{MARK,SPACE}
Change-Id: I4c8fe5bfdcc2f4eb52c259d1e62d06684cd8f823
Related: OS#4396
2023-11-21 20:17:11 +07:00
Vadim Yanitskiy 03f0ed78ef soft_uart: allow manually flushing the receive buffer
Change-Id: Id600a2db99e6cb84866cbdcfcd4f78265e067291
Related: OS#4396
2023-11-21 18:50:09 +07:00
Vadim Yanitskiy c9fc77f541 soft_uart: implement the transmitter
Change-Id: Ibcd9643227e5616efd8bbd7a1430feda6fcef45c
Related: OS#4396
2023-11-21 00:58:53 +07:00
Vadim Yanitskiy 82a1ae785e soft_uart: make osmo_soft_uart_alloc() accept *cfg
Let the API user pass their own default config when allocating
a soft-UART.  Make the default config publicly accessible.

Change-Id: I7e78d60c747a8805064d5e4bacfd47a30bc65cba
Related: OS#4396
2023-11-21 00:58:53 +07:00
Vadim Yanitskiy cdde67186b soft_uart: split osmo_soft_uart_enable()
The problem with a single function controlling both Rx and Tx is
that enabling/disabling one of the directions requires knowing
state of the other one.  In other words, disabling Tx requires
knowing the state of Rx, which may be inconvenient.

Change-Id: Ieacc7e639304eeb14fdb298c7e14d772c136ca6e
Related: OS#4396
2023-11-21 00:58:53 +07:00
Vadim Yanitskiy 877cfed3b2 soft_uart: add osmo_soft_uart_free()
Change-Id: I2fdcf6116144d8f16cf4167c37cfa7215d16337f
Related: OS#4396
2023-11-21 00:58:53 +07:00
Harald Welte dc023cfc2e core: Add software UART implementation
This patch brings a Work-in-Progress implementation of the software
UART (Universal Asynchronous Receiver/Transmitter) to libosmocore.

Not only it will be useful in the context of retro-networking, but
also it's needed for the MS-side CSD implementation (see OS#4396).

It should be noted that the definition of struct osmo_soft_uart
is intentionally kept private, since the API is not stable yet.

Currently, the following limitations apply:

* Only the receiver part is implemented, the transmitter is TBD.
* Parity checking is not implemented in the receiver part.
* Software flow control is not implemented.

These missing components will be addressed in subsequent patches.

Change-Id: I2ca95963fd5852ddb89bdd35b86b31489127fe84
2023-11-21 00:58:53 +07:00
Vadim Yanitskiy d739e257bb coding: gsm0503_tch_a[fh]s_encode(): make *codec const
Change-Id: I9e37a47c080cf57005e0205aa0d3cd25755a75f0
2023-11-14 11:57:19 +00:00
Vadim Yanitskiy e0d0fff41f msgb: fix doxygen docs for msgb_pull_u{8,16,32): end -> front
Change-Id: Ie9851683fa9cc88cd7f6b63ad708b4f78c8f37c9
2023-11-12 14:24:11 +07:00
Andreas Eversberg 4ca0f62cc4 ASCI: Add primitive to L1-SAP to switch uplink access detection on or off
Related: OS#4851
Change-Id: Ibd6a1d468a70126a8f67e944fcb916969cc3c36b
2023-10-24 17:32:15 +02:00
arehbein 1584b2ac39 gsmtap: Hide implementation of gsmtap_inst
- Use forward decl. of struct gsmtap_inst in header
 - Remove 'static inline' attributes from gsmtap_inst_fd() declaration,
   move function definition to gsmtap_util.c and mark it as deprecated
 - Add gsmtap_inst_fd2() as replacement for gsmtap_inst_fd()

Related: OS#6213
Change-Id: Ibe1a51205a6df764571b6d074e365825555609a5
2023-10-13 01:33:46 +02:00
Pau Espin 64ba9edf17 socket: Introduce APIs osmo_sock_multiaddr_{add,del}_local_addr()
These APIs are used to bind or unbind an active socket adding or
removing addresses from the existing set.

Related: OS#6077
Change-Id: Ifc6e7d643c2a0c53f479bfd0d5c36d08c0c01953
2023-10-03 18:38:02 +02:00
arehbein 2a405d4f06 osmo_io: Clean up code
- Remove osmo_io_init() from header, since it has no function definition
 - Add osmo_iofd_init() to header

Change-Id: I77f7ae2b211507f420d87c484ec75ee054fceb63
2023-09-29 15:27:11 +00:00
Vadim Yanitskiy 15b76f068d gsm: rename s/gsm0502_fn_compare/gsm0502_fncmp/
Change-Id: Ie8bb9c49c6f81b8f4a1766547d6943f9880d1186
Related: OS#5500
2023-09-26 11:03:49 +00:00
Pau Espin d9a5c8d32f sockaddr_str.h Fix OSMO_SOCKADDR_STR_FMT_ARGS_NOT_NULL syntax error
It's fine changing the define because due to the previous error it means
basically that it was never used so far, because using it triggers a
compilation error.

The error was introduced because I ended up not using this in the past
after submitting this code, and now that I want to use it it went
noticed that it fails.

Change-Id: Iee361d740845257fa62c9093e30e8079fa933827
2023-09-26 10:50:55 +00:00
Vadim Yanitskiy 5285d47548 gsm: add gsm0502_fn_compare() for comparing TDMA FNs
We need this function in:

* osmocom-bb.git for trxcon and l1gprs,
* osmo-pcu.git replacing fn_cmp().

Change-Id: I9590f2e836fc48650decf1564b6ab46306c4fe2d
Related: OS#5500
2023-09-25 23:58:40 +07:00
Manawyrm 522f51b9d8 gsmtap.h: Add definitions for ISDN PPP sub-type
This change adds a new sub-type for PPP in GSMTAP_TYPE_E1T1.

Change-Id: I17137167b2c74b6c5e53459743b6e140fc1a4386
2023-09-20 16:10:57 +00:00
arehbein ae07127f73 write_queue: Enable updating max_length field
Dequeue and free any excess messages, in case the new queue length
is shorter than the old.

Related: OS#5774
Change-Id: Ibfe51a2faf29f8ae160a9c330c9af0d09b5a9002
2023-09-19 18:46:09 +00:00
Mychaela N. Falconia d5c6651ae0 gsm/protocol/gsm_04_11.h: add SMSC-address length limit definitions
Change-Id: Iea5c29909c5be80f81dbbc2873656ff5cf590a5d
2023-09-18 19:07:51 +00:00
Andreas Eversberg 84d5a825a4 ASCI: Add definition for TALKER INDICATION and UPLINK RELEASE
Change-Id: I5ab196d46cdee160e59ee4ecf72c79aa1b25815f
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
Pau Espin a45b0be25f socket: Support setsokopt SCTP_INITMSG in osmo_sock_init2_multiaddr2()
This allows setting several socket paramets which can only be set before
SCTP INIT phase (connect()).

Since no release with osmo_sock_init2_multiaddr2() happened yet, we are
allowed to extend struct osmo_sock_init2_multiaddr_pars without bumping
the version field.

Related: SYS#6558
Change-Id: Ibc55932d954279927d1e70ccce1e8bf32b180d44
2023-09-08 13:49:59 +02:00
Pau Espin 658c509061 socket: Remove OSMO_SOCK_F_SCTP_ASCONF_SUPPORTED, add osmo_sock_init2_multiaddr2()
The OSMO_SOCK_F_SCTP_ASCONF_SUPPORTED flag was added recently to enable
use of ASCONF in osmo_sock_inti2_multiaddr. Since we didn't release yet,
we are still in time to get rid of this flag.

It turns out that we'll want to add more features which must be set
before SCTP INIT (connect()) time, like setsockopt SCTP_INITMSG, which
in turn contains a struct with several parameters.
Hence, adding flags for all those makes no sense.
Instead, add a new API which allows passing an extensible struct which
allows much more fine-grained setup from the caller.

The new struct "pars" parameter is non-const on purpose, in order to be
able to extend the struct in the future if we wish to get/obtain some
data from the socket.

Related: SYS#6501
Related: SYS#6558
Change-Id: I1f6fd09a79b0a2bd794e5669d933be25bbf1eeaa
2023-09-08 13:49:08 +02: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 c49691ff76 gsm_12_21.h: Introduce packed structs for NM_ATT_IPACC_NS_CFG values
Change-Id: Ie477b0e6d79e6d408e0004fd60307afc5feaa3b6
2023-09-02 08:51:52 +00:00
Pau Espin bbb69d3af5 gsm_12_21.h: Introduce packed structs for NM_ATT_IPACC_BSSGP_CFG values
Change-Id: Ibfd759cb8a252f801bb3a758ea7960072c96f254
2023-09-02 08:51:48 +00:00
Pau Espin 34e67c2e70 gsm_12_21.h: Introduce packed structs for NM_ATT_IPACC_RLC_CFG{,_2,_3} values
Change-Id: I60e17dedd1fadce0f705616e3ed96cabb318bcec
2023-09-02 08:51:44 +00:00
Daniel Willmann f91d2aac9d osmo_io: Add io_uring backend
Change-Id: I5152129eb84b31ccc9e02bc2a5c5bdb046d331bc
2023-08-24 17:33:19 +02: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 e83227f735 socket: Add osmo_sock_init flag to enable SCTP ASCONF features
The SCTP_ASCONF_SUPPORTED sockopt, which enables ASCONF features
for the SCTP associations managed by the SCTP socket, gets its default
value from to sysctl "net.sctp.addip_enable", which, at least up to
current kernel 6.4.8 is set to "0" (disabled) by default.
As a result, ASCONF related features such as
setsockopt(SCTP_SET_PEER_PRIMARY_ADDR) fail with -EPERM
since ASNCONF extensions where not negotiated during the SCTP init
handshake.
This commit adds support for setting SCTP_ASCONF_SUPPORTED=1 during
socket creation, since that needs to be applied before the first
bind()/connect() (before first assoc is created).

Furthermore, for ASCONF features to work properly, the assoc also needs
to announce/use the AUTH extension, as per RFC5061 section 4.2.7.
Otherwise, the peer receiving an SCTP INIT with
ExtensionFeatures=ASCONF,ASCONF_ACK but without AUTH, will reject the
assoc with an ABORT since it's not complying with spec (this behavior
can be tweaked through sysctl "net.sctp.addip_noauth_enable").

The AUTH extension is enabled through sockopt SCTP_AUTH_SUPPORTED, and
its default value is that of sysctl "net.sctp.auth_enable", which is
also disabled (0) by default.

Kernel support for those is relatively new:
SCTP_FUTURE_ASSOC added in: 80df2704a375bb4b3c9c5cce9c00052361b16d61
Follows: v5.0-rc4
Precedes: v5.1-rc1

SCTP_ASCONF_SUPPORTED added in: df2c71ffdfae58961981d7cbcccea93688fc4e96
Follows: v5.3-rc5
Precedes: v5.4-rc1

SCTP_AUTH_SUPPORTED added in: 56dd525abd56f7acd7b44a52935726e3ada4916c
Follows: v5.3-rc5
Precedes: v5.4-rc1

Related: OS#6076
Change-Id: Iac07031927b66a9d32d2bb2faab817e4c922a359
2023-08-21 10:28:11 +02: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 6df53dc769 tlv: Introduce API msgb_tv32_push()
msgb_tv32_put() already exists, but msgb_tv32_push doesn't.
The tv16 counterparts are already present, and having to pass 32bit
integers is also quite common, so let's add an API for it.

Change-Id: I68d5693a18d55ce8d0647359044157d7e5bfae50
2023-08-11 15:36:27 +00:00
Philipp Maier 3c577269c8 gprs_bssgp_rim: add decoder for RIM ROUTING ADDRESS
We have a decoder for RIM ROUTING INFORMATION (bssgp_parse_rim_ri),
let's also have a decoder for RIM ROUTING ADDRESS (bssgp_parse_rim_ra.

Related: OS#6095
Change-Id: Ibca1f08906c4ffeecdae80d4e91c6c7b05fe4f8a
2023-08-10 12:01:25 +02:00
Philipp Maier 9e75544137 gprs_bssgp_rim: allow sending of encoded RIM messages
The API function bssgp_tx_rim() accepts decoded RIM PDU structs, encodes
them and eventually sends them. However, there may be cases where the
RIM PCU already exists in its encoded form. (This is in particular the
case when the RIM PDU is forwarded from GTP to BSSGP)

Lets add an API function bssgp_tx_rim_encoded to allow sending of
already encoded RIM PDUs

Related: OS#6095
Change-Id: Id4a793bbaf32d7b9d894dcc5be3faaf2f2d91d82
2023-08-10 10:17:03 +02:00