Commit Graph

4710 Commits

Author SHA1 Message Date
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 259a0b7e88 tests/testsuite.at: remove copy-pasted 'touch experr'
Doing this after creating a file yields nothing.

Change-Id: Ib3bdaf6db25e4a2995abdff5c859d4be023d45a9
2023-11-19 10:21:14 +00:00
arehbein 90d79f4eac gmstap_util: Fix sending out gsmtap messages
Previously undetected, because the vty command 'gsmtap log ...' never used write queue mode

Change-Id: I88ba8984518d2d0327cfacd0d2cdf33c7e1d091b
2023-11-17 18:52:58 +01:00
arehbein f67e45828d gsmtap_util: Simplify sink
- Instead of using the osmo_fd API to call read() on the socket's file
   descriptor each time (unused) data is received, simply open the
   socket and never read

Related: OS#6213
Change-Id: I4025920d5f62d17133e9b5fe81cd34a88c4f20b5
2023-11-15 21:29:23 +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
Andreas Eversberg 913a783ff2 LAPD: Flush TX queue, if remote peer enters busy condition or rejects
In case of a busy condition or a reject (sequence error) from the remove
peer, the messages in the TX queue are obsolete and will be flushed.

Related: OS#4074
Change-Id: Iaaf9aaabb958ef889e252ddd0026ff82cfac981f
2023-11-15 21:28:22 +00:00
Andreas Eversberg cc63aae030 LAPD: Prepare lapd_send_i() for RTS support
When RTS is used, lapd_send_i() is called very frequently. (for every
PH-READY-TO-SEND primitive) The logging output can be suppressed in this
case.

As there is no complete lctx (lapd context) when calling lapd_send_i()
at RTS, take the stored lctx.

Related: OS#4074
Change-Id: I3109b7aa15c0f75f4a7458fc1c5d0ce633100f76
2023-11-15 21:28:22 +00: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 a995269c6d coding: gsm0503_tch_a[fh]s_encode(): improve cmr/ft checks
Change-Id: If03d5b015ab1c8db56a4c67bdc8e36e260c06562
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
arehbein f38077ee6a gsmtap_util: Use Osmo IO instead of Osmo write queues
- Adapt decl. of 'struct gsmtap_inst' for usage of Osmo IO while maintaining backwards compatibility
 - Maintain legacy behavior without any message queues if osmo_io_mode is zero

Related: OS#6213
Change-Id: Iadbbef74e3add7001d84dd6b68f51eac293e44d0
2023-11-09 12:48:07 +00:00
Daniel Willmann f2629675aa logging_gsmtap: Temporarily disable logging when sending the logs
This avoids an infinite recursion when sending a gsmtap log message
causes a log message.
Temporarily set target->loglevel higher than LOGL_FATAL, which
effectively disables logging for that target. Other targets like stderr
will still log this message so there is still an indication that
something went wrong.

Change-Id: I19203cadbad6019a3834793b8ac816d903fe088e
Related: OS#6213
2023-11-09 19:34:37 +07:00
Manawyrm 11a416827d logging: ensure ANSI color escape is sent in same line/before newline
This fixes multi-line color clobbering in logging daemons like
systemd-journald, which work with single-lines only.

Change-Id: Ia7de9d88aa5ac48ec0d5c1a931a89d21c02c5433
Closes: OS#6249
2023-11-07 16:50:22 +00: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
Pau Espin e4f34d8d0a socket.c: Fix compilation with --disable-libsctp
Fixes: 64ba9edf17
Related: OS#6234
Change-Id: I988d01461822d18b7350a6e69e3b504f7fd5b84f
2023-10-23 09:58:50 +00:00
Andreas Eversberg 676b361fa7 LAPDm: Correctly count expiry of T200 during estabishment/release
After T200 expires N200+1 times, the link establishment or relase
fails. The counting must be performed prior check.

Related: OS#5970
Change-Id: Icf44e26420fc91312e7c8972a2f3ed475e42fc48
2023-10-23 09:07:28 +00:00
arehbein a59e8d7c1d write_queue: Fix Doxygen comment
Change-Id: Ib2508411ae46e2456466beaae63d3f401e34d0d4
2023-10-20 20:55:54 +00:00
arehbein 2e2a0a1561 osmo_io_poll: Handle -EAGAIN in case of OSMO_FD_WRITE
Related: OS#6213
Change-Id: I59c86370d13f2bb33c289d1b177df895726975cb
2023-10-20 10:00:32 +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
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 9519d8d27a Fix typo in libosmocore.map
Fixes: 64ba9edf17
Change-Id: I0fb13fb4ef8160f3ac2cb1cb4dd6ea57fd04b5be
2023-10-05 16:50:32 +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
Daniel Willmann 2386e9a7e2 osmo_io: Only allow reading/writing if the relevant callback is set
Allow the callbacks to be NULL, but then sending/receiving is disabled.
There are some cases where we only care about writing to or reading from
an fd.

Change-Id: I11ce072510b591f7881d09888524426579bd0169
2023-09-28 17:51:05 +02:00
Daniel Willmann 435856be51 osmo_io: Init struct msghdr to zero
Avoid uninitialized read, found with valgrind

Syscall param recvmsg(msg) points to uninitialised byte(s)
   at 0x49FD865: __recvmsg_syscall (recvmsg.c:27)
   by 0x49FD865: recvmsg (recvmsg.c:41)
   by 0x4891FAE: iofd_poll_ofd_cb_recvmsg_sendmsg (osmo_io_poll.c:66)
   by 0x48921B2: iofd_poll_ofd_cb_dispatch (osmo_io_poll.c:119)
   by 0x48941F1: poll_disp_fds (select.c:419)
   by 0x4894299: _osmo_select_main (select.c:457)
   by 0x4894304: osmo_select_main (select.c:496)
   by 0x10DC3E: test_segm_ipa_stream_srv_run (stream_test.c:628)
   by 0x10E2A5: main (stream_test.c:879)
 Address 0x1ffefffa68 is on thread 1's stack
 in frame #1, created by iofd_poll_ofd_cb_recvmsg_sendmsg (osmo_io_poll.c:45)

Change-Id: I21114ad57784126cfdeb4a932ed44dbf23946fbe
2023-09-27 11:14:02 +02: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
Karsten Ohme 433218a6ef APDU parsing support for GlobalPlatform GET RESPONSE
This patch adds GET RESPONSE support for GlobalPlatform command. Android is using
this to get the response data on SGP.22 eUICCs.
simtrace2-cardem-pcsc is failing otherwise e.g. on an xingtera camera with Android.

Change-Id: I5ae3165f172f9c949550ee4a07fe70e91f1a037c
2023-09-24 17:48:13 +00: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
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 84d5a825a4 ASCI: Add definition for TALKER INDICATION and UPLINK RELEASE
Change-Id: I5ab196d46cdee160e59ee4ecf72c79aa1b25815f
2023-09-12 10:42:48 +00: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
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
Vadim Yanitskiy d0cb0d585b tests/{v110,gsm44021}: change naming: 'test_' -> '_test'
Ensure that the test binaries do not show up in `git status`:

tests/gsm44021/test_frame_csd
tests/v110/test_frame
tests/v110/test_ra1

The new naming complies to the 'tests/*/*_test' pattern in .gitignore.

Change-Id: I7bbcec2ec6887a2e6c9b37e2e5b3d9ee489654ce
2023-09-04 17:47:41 +07:00
Vadim Yanitskiy cb7d603d8b .gitignore: add include/osmocom/core/socket_compat.h
Ensure that this auto-generated file does not show up in `git status`.

Change-Id: Id7c245579f5a3288a9ea62589ca802e427e54720
2023-09-04 17:47:08 +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 ec7d491589 osmo_io: Use local variable to reference msghdr->msg
Change-Id: I336ef7a5460dd18bf8e0f4ac5e97747f9fec5a35
2023-08-31 14:28:13 +00:00
Daniel Willmann f39c23f918 osmo_io: Change parent of msghdr to iofd (instead of msg)
msg was made a parent of msghdr after discussion in change
I3a279b55a3adff96948120683c844e1508d0ba94

It turns out this violates some assumptions made in osmo_io,
specifically that the user read callback shall free msg, but we expect
msghdr to remain valid until after that callback returns.

In general I think it is cleaner to make iofd a parent of msghdr.

Change-Id: I41277190e3020cd8fa625bd57a743973e2a65c4b
2023-08-31 14:28:13 +00:00
Oliver Smith 405e7cc971 debian: fix build on ubuntu 20.04 without liburing
Ubuntu 20.04 is based on debian 11, but does not have liburing. Extend
the logic to cover this distribution too, so building packages for it
isn't stuck anymore on libosmocore not being able to resolve the
liburing-dev dependency.

I have verified that this makes libosmocore properly build with/without
liburing on debian 10, 11 and ubuntu 20.04 and 22.04.

Fixes: e486e012 ("debian: depend on liburing-dev for debian >= 11")
Change-Id: If18d6543fae9537c8b188e90499491bda3fdfe59
2023-08-31 14:48:49 +02:00