Commit Graph

35 Commits

Author SHA1 Message Date
Neels Hofmeyr 1c24962946 sockaddr_str: add conversion to,from osmo_sockaddr
Add functions to pass struct osmo_sockaddr to the
osmo_sockaddr_str_{to,from}* API directly.

So far the interface to osmo_sockaddr_str_ is:

  osmo_sockaddr_str_from_sockaddr(&my_sa_str, &my_osa->u.sas);

I'm working a lot with osmo_sockaddr at the moment, and the cumulated
time of forgetting to add 'u.sas' and having another compilation cycle
because of those is justifying this additional API.

Change-Id: I0df84b4bb8cb5d8434b735fa3a38e7f95be43e91
2024-03-28 03:42:07 +01:00
Eric Wild 43018ec161 Revert "Revert "logging: add log level cache""
This reverts commit 7f1fb3ea81 - slightly
amended with the new log_cache_enalbe() function.  The cache is hence
disabled by default, and applications can enable it, if they wish to
benefit from it.

Reason for the original revert was: some fallout expected due to log
manipulation in test code

Change-Id: I539872fc9e3c50b407e6bc388f1e091fa2c826c3
2024-03-20 14:57:13 +01:00
Harald Welte 09ab041b42 osmo_io: Log error message in case call-backs incompatible with mode
Change-Id: I50ba6a76c0144f249d67488874a6c4edf01ec6f2
2024-03-07 15:51:48 +01:00
Harald Welte f574aea38f osmo_io: Add osmo_io_get_ioops() function
This function can be used by user code to obtain the currently-set io
operations, it's the inverse of osmo_io_set_ioops().

Change-Id: I03398c811b9534f50c6644b21eea89a04be29fb0
2024-02-29 09:15:43 +01:00
Harald Welte 1047ed7255 osmo_io: sendmsg/recvmsg support
Add support osmo_io operations resembling sendmsg() and recvmsg() socket
operations.  This is what will enable the implementation of higher-layer
functions like equivalents of sctp_recvmsg() and sctp_send() in
libosmo-netif and/or other users.

Change-Id: I89eb519b22d21011d61a7855b2364bc3c295df82
Related: OS#5751
2024-02-28 16:42:57 +01:00
Eric Wild 7f1fb3ea81 Revert "logging: add log level cache"
This reverts commit 7dc6d4a629.

Reason for revert: other tests are failing

Change-Id: Ife4c49d1bb933e983ac68c57970c9c49b40e08be
2024-01-09 16:37:05 +00:00
Eric Wild 7dc6d4a629 logging: add log level cache
This ensures multithreaded logging attempts, in particular ones that do
nothing, do not hold the lock just for checking the level, which
interferes with other logging attempts.

Closes: OS#5818

Change-Id: I35f8dd9127dd6e7feae392094fd6b3ce2d32558d
2024-01-09 15:28:29 +00:00
Pau Espin 19f27bb551 socket: Introduce API osmo_sock_sctp_get_peer_addr_info()
This is a convenience helper to reetrieve the whole set of remote
addresses and call getsockopt() on them, making it easy for users to
analyse the full set of remote addresses of a socket simply providing an
fd.

Related: SYS#6636
Change-Id: I3e1c84526b006baff435bbbca49dc6cf7d201cf5
2023-12-11 11:11:16 +01:00
Pau Espin 5ac8aa5852 socket: Introduce API osmo_sock_multiaddr_get_name_buf()
An extra osmo_multiaddr_ip_and_port_snprintf() API is introduced which
is used by osmo_sock_multiaddr_get_name_buf() but which will also be
used by other app uers willing to use
osmo_sock_multiaddr_get_ip_and_port() according to its needs (eg. only
printing the local side).

Related: SYS#6636
Change-Id: I48950754ed6f61ee5ffa04a447fab8903f10acc0
2023-12-07 13:23:06 +00:00
Pau Espin 6a2975c858 socket: Introduce API osmo_sock_multiaddr_get_ip_and_port()
This API will be used internally by osmo_sock_multiaddr_get_name_buf()
in a follow-up patch.
This API can also be used directly by user who wish to obtain a list of
local/remote IP addresses and port from an SCTP socket.

Related: SYS#6636
Related: OS#5581
Change-Id: I19d560ab4aadec18a4c0f94115675ec1d7ab14d7
2023-12-07 13:23:06 +00:00
Neels Hofmeyr d511a9d664 util: add osmo_strbuf macros to manipulate the strbuf tail
Upcoming patch adopts osmo_strbuf in logging.c, which sometimes needs to
steal and re-add trailing newline characters, and also needs to let
ctime_r() write to the buffer before updating the osmo_strbuf state.

Related: OS#6284
Related: Ib577a5e0d7450ce93ff21f37ba3262704cbf4752
Change-Id: I997707c328eab3ffa00a78fdb9a0a2cbe18404b4
2023-12-07 04:52:16 +01:00
Vadim Yanitskiy 6587dd0abb soft_uart: implement modem status lines and flow control
Change-Id: I26b93ce76f2f6b6fbf017f2684312007db3c6d48
Related: OS#4396
2023-12-04 04:23:07 +07:00
Vadim Yanitskiy 59afb8f14c soft_uart: add osmo_soft_uart_{get,set}_name()
Change-Id: Iabf29f42d876035481011fa8e8a51c0590fe63b8
Related: OS#4396
2023-12-03 02:19:33 +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 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
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 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
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
Daniel Willmann a9303f3bce osmo_io: Add function to change the maximum length of the tx_queue
Change-Id: If3d1de8bffe1123002515878655ea9e02b482888
2023-07-18 06:30:28 +00:00
Daniel Willmann e2a8dc4131 osmo_io: Add osmo_iofd_notify_connected()
Don't call write_enable() in osmo_iofd_register(). This was used to
detect whether a socket is connected or not, but would always be
enabled, even on unconnected sockets. Instead make this behaviour
explicit by calling osmo_iofd_notify_connected().

Change-Id: Ieed10bc94c8aad821c0a8f7764db0e05c054c1e3
2023-06-30 13:57:05 +02:00
Daniel Willmann 8b7e7f164f osmo_io: Remove missing functions from map file
Change-Id: I4dbc1cf9b05521325287803f00781001b80945ef
2023-06-30 13:57:05 +02:00
Pau Espin 63e45e6c6a osmo_io: Make name optional, add _set_name() API
This allows renaming the iofd at any later point in time. This is useful
for instance if the parent object holding the iofd changes its name.

Change-Id: If2772a3ccaa98616e0189862a49ab0243435e343
2023-06-20 07:16:41 +00:00
arehbein 0c374c68a1 core: Add function to update osmo_io_ops field for osmo_io_fd
Added, because the field 'io_ops' of 'struct osmo_io_fd' is not a
reference, so subsequent changes to the osmo_io_ops structure that was
used to set it up aren't automatically reflected in the osmo_io_fd
structure that got its copy.

Change-Id: Ie45402ad8e86e3cecf75ad78a512c17e61e68b19
2023-05-19 12:50:24 +02: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
Vadim Yanitskiy 68d5139abc libosmocore.map: add missing symbols needed for osmo-qcdiag
Change 213fc420e broke osmo-qcdiag:

  /usr/bin/ld: diagchar_hdlc.o: in function `osmo_crc16_ccitt_byte':
  src/diagchar_hdlc.c:46: undefined reference to `osmo_crc16_ccitt_table'
  /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
  collect2: error: ld returned 1 exit status
  make: *** [Makefile:8: osmo-qcdiag-log] Error 1

Change-Id: I7e84546b484db4822554681b31625d0520617d2b
Fixes: 213fc420e "Add libosmocore.map"
2023-04-23 01:48:50 +07:00
Harald Welte d4d78bce7b libosmocore.map: Add two missing entries for gsmtap*2() API
Those functions were introduced in I51b3604ba79e42c474aa17007e7e308a12afcea8
but the recent introduction of libosmocore.map didn't list them

Change-Id: I4ac14aae13ff60c110444da989761cd1e86f8925
Fixes: I13169c00a59fb59513dfc598de5a71d094492422
2023-03-05 18:25:07 +01:00
Oliver Smith 5566b2ea65 libosmocore.map: add tall_{ctr/msgb}_ctx
These should not be used, but add them for backwards compatibility with
building older versions of osmo-bsc, osmo-iuh, osmo-pcap against current
libosmocore.

Fixes: 213fc420 ("Add libosmocore.map")
Change-Id: I4cfccf3622844d0923818bb8d8ce206f70e44a0d
2023-02-28 11:33:10 +01:00
Daniel Willmann 213fc420e0 Add libosmocore.map
Generated with:
nm src/core/.libs/libosmocore.so --defined-only  |grep " T \| D \| B " | cut -c 20-  >> src/core/libosmocore.map

Change-Id: I13169c00a59fb59513dfc598de5a71d094492422
2023-02-27 17:11:08 +00:00