aboutsummaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2023-11-22add new osmo_sockaddr_from_str_and_uint() functionHarald Welte2-0/+22
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-21osmo_io: Assert that iofd mode is correct when calling *_write_msgbDaniel Willmann1-0/+1
Change-Id: Ief82ba7f9b280f85d66d68c358c36ba9866fe47a Fixes: OS#6264
2023-11-21soft_uart: check n_bits against 0 in osmo_soft_uart_tx_ubits()Vadim Yanitskiy1-0/+4
Currently calling this function with n_ubits == 0 would result in requesting one character from the application (via the .tx_cb()), but not actually transmitting anything. Make it return early. Change-Id: Icbf99a9f2f6fa64dd71a5f37922f9001577c6c97 Related: OS#4396
2023-11-21soft_uart: fix pulling a small number of Tx bitsVadim Yanitskiy1-9/+19
Change-Id: I454c8786697a6f2389d56b350e6e20ca953fe859 Related: OS#4396
2023-11-21soft_uart: implement OSMO_SUART_PARITY_{MARK,SPACE}Vadim Yanitskiy1-0/+18
Change-Id: I4c8fe5bfdcc2f4eb52c259d1e62d06684cd8f823 Related: OS#4396
2023-11-21soft_uart: fix handling of num_data_bits < 8Vadim Yanitskiy1-0/+3
Change-Id: Ife13b1f2d9063ba7253d01523ca9ecb15e9eaf07 Related: OS#4396
2023-11-21soft_uart: fix Rx buffer flushing logic in suart_rx_ch()Vadim Yanitskiy1-4/+5
Whenever we encounter a parity and/or a framing error, we should call the .rx_cb() immediately, even if this was the first character in the receive buffer. Change-Id: I73fab1a5c196d2dbdfe98b0c20d8dadbd22f4f64 Related: OS#4396
2023-11-21soft_uart: allow manually flushing the receive bufferVadim Yanitskiy2-6/+8
Change-Id: Id600a2db99e6cb84866cbdcfcd4f78265e067291 Related: OS#4396
2023-11-21soft_uart: implement the transmitterVadim Yanitskiy2-26/+80
Change-Id: Ibcd9643227e5616efd8bbd7a1430feda6fcef45c Related: OS#4396
2023-11-21soft_uart: implement parity checking for the receiverVadim Yanitskiy1-3/+21
Change-Id: I28be2ca19d423447a718fb518566d52ae1967ec7 Related: OS#4396
2023-11-21soft_uart: rework osmo_uart_rx_bit() to use flow stateVadim Yanitskiy1-34/+41
Change-Id: I40ab5d12b6f7087daa51405468f5c4ea639561ea Related: OS#4396
2023-11-21soft_uart: make osmo_soft_uart_alloc() accept *cfgVadim Yanitskiy2-6/+8
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-21soft_uart: split osmo_soft_uart_enable()Vadim Yanitskiy2-9/+18
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-21soft_uart: add doxygen documentationVadim Yanitskiy1-6/+32
Change-Id: Ib0dcea0c35619bda5626cf75044000951b26485b Related: OS#4396
2023-11-21soft_uart: add osmo_soft_uart_free()Vadim Yanitskiy2-0/+15
Change-Id: I2fdcf6116144d8f16cf4167c37cfa7215d16337f Related: OS#4396
2023-11-21core: Add software UART implementationHarald Welte3-0/+276
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-17gmstap_util: Fix sending out gsmtap messagesarehbein1-5/+10
Previously undetected, because the vty command 'gsmtap log ...' never used write queue mode Change-Id: I88ba8984518d2d0327cfacd0d2cdf33c7e1d091b
2023-11-15gsmtap_util: Simplify sinkarehbein1-43/+7
- 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-15LAPD: Always update N(R) in pending TX frames if V(R) is incrementedAndreas Eversberg2-8/+11
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-15LAPD: Flush TX queue, if remote peer enters busy condition or rejectsAndreas Eversberg1-1/+16
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-15LAPD: Prepare lapd_send_i() for RTS supportAndreas Eversberg1-20/+23
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-14coding: gsm0503_tch_a[fh]s_encode(): make *codec constVadim Yanitskiy1-2/+2
Change-Id: I9e37a47c080cf57005e0205aa0d3cd25755a75f0
2023-11-14coding: gsm0503_tch_a[fh]s_encode(): improve cmr/ft checksVadim Yanitskiy1-26/+10
Change-Id: If03d5b015ab1c8db56a4c67bdc8e36e260c06562
2023-11-09gsmtap_util: Use Osmo IO instead of Osmo write queuesarehbein1-37/+40
- 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-09logging_gsmtap: Temporarily disable logging when sending the logsDaniel Willmann1-0/+5
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-07logging: ensure ANSI color escape is sent in same line/before newlineManawyrm1-1/+9
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-10-23socket.c: Fix compilation with --disable-libsctpPau Espin Pedrol1-0/+2
Fixes: 64ba9edf173cc16f9d94c94a423a8b7a5904efaf Related: OS#6234 Change-Id: I988d01461822d18b7350a6e69e3b504f7fd5b84f
2023-10-23LAPDm: Correctly count expiry of T200 during estabishment/releaseAndreas Eversberg1-4/+4
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-20write_queue: Fix Doxygen commentarehbein1-1/+1
Change-Id: Ib2508411ae46e2456466beaae63d3f401e34d0d4
2023-10-20osmo_io_poll: Handle -EAGAIN in case of OSMO_FD_WRITEarehbein1-0/+4
Related: OS#6213 Change-Id: I59c86370d13f2bb33c289d1b177df895726975cb
2023-10-17gsm48_ie.c: change bearer cap structure in outgoing CSD callsManawyrm1-1/+1
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-17gsm48_ie.c: add 3.1kHz audio bearer capability for CSD callsManawyrm1-0/+2
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-13gsmtap: Hide implementation of gsmtap_instarehbein2-2/+26
- 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-05Fix typo in libosmocore.mapPau Espin Pedrol1-1/+1
Fixes: 64ba9edf173cc16f9d94c94a423a8b7a5904efaf Change-Id: I0fb13fb4ef8160f3ac2cb1cb4dd6ea57fd04b5be
2023-10-03socket: Introduce APIs osmo_sock_multiaddr_{add,del}_local_addr()Pau Espin Pedrol2-0/+154
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-09-28osmo_io: Only allow reading/writing if the relevant callback is setDaniel Willmann1-1/+30
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-27osmo_io: Init struct msghdr to zeroDaniel Willmann1-4/+6
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-24APDU parsing support for GlobalPlatform GET RESPONSEKarsten Ohme1-0/+1
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-19write_queue: Enable updating max_length fieldarehbein2-0/+21
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-12Bump version: 1.8.0.252-13c29 → 1.9.01.9.0Pau Espin Pedrol8-8/+8
Change-Id: I6f8eccbccb73c6c094f13f2d4bdee931cf5b9010
2023-09-12LAPDM: Use correct offset to short header on recevied frameAndreas Eversberg1-1/+1
The offset of the short header on main DCCH is 0, not 2. Change-Id: I8345776768fdf2a700b2ca1d117f9ef4b15777cc
2023-09-12ASCI: Add BCC call state definitionsAndreas Eversberg1-2/+2
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-12gsm_12_21.h: fix typo: NM_IPAC_F_CHANT_P{C->D}CHFVadim Yanitskiy1-1/+1
Change-Id: I35ee30978820f2038f562b7703ca886852a4f708 Fixes: a7d7cf28 "gsm_12_21.h: add flags for NM_ATT_IPACC_SUPP_FEATURES"
2023-09-08socket: Support setsokopt SCTP_INITMSG in osmo_sock_init2_multiaddr2()Pau Espin Pedrol1-0/+54
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-08socket: Remove OSMO_SOCK_F_SCTP_ASCONF_SUPPORTED, add ↵Pau Espin Pedrol2-9/+51
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-05gsm_12_21.h: add flags for NM_ATT_IPACC_SUPP_FEATURESVadim Yanitskiy2-0/+102
Change-Id: Ia4208e10d61843dd6ae77398f6624c918dc81ea4
2023-08-31osmo_io: Use local variable to reference msghdr->msgDaniel Willmann1-7/+8
Change-Id: I336ef7a5460dd18bf8e0f4ac5e97747f9fec5a35
2023-08-31osmo_io: Change parent of msghdr to iofd (instead of msg)Daniel Willmann1-1/+1
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-30ns2: Add VTY option to change the max write queue size for UDPDaniel Willmann4-0/+43
Ensure that existing binds are updated as well. In some cases the default max length of the osmo_io txqueue could be too small. Set it to 128 by default and add a VTY option to change it for an NSI (program-wide). Change-Id: I993b87fd6b83b3981f5e293f70b931075afec715 Related: SYS#6550
2023-08-28socket: Avoid aborting socket creation if setsockopt for ASCONF failsPau Espin Pedrol1-2/+4
Avoid aborting the entire socket creation, since those sockopt are fairly new in the kernel (v5.4), and the feature can still be enabled in older versions system-wide with sysctl. The worst it can happen is that the ability to submit address updates (such as Peer Primary Address) doesn't work, which is not really critical. Related: SYS#6501 Change-Id: Iff261c8592b6b3c4237c90c84b4e8e921e3c4a65