Commit Graph

178 Commits

Author SHA1 Message Date
Pau Espin 05ff552f25 stream_{cli,srv}: Add 'res' param to read_cb2
Notify user about read errors, similar to what is supported in the
earlier ofd cb backend of osmo_stream_cli/srv:
https://osmocom.org/issues/6405#note-15

Related: OS#6405
Fixes: 5fec34a9f2
Fixes: 0245cf5e07
Change-Id: I395c75ff1e9904757ce1d767a9ac2f779593c4c8
2024-04-18 10:55:13 +02:00
Pau Espin a423e12284 stream: Define types for each API callback
The amount and complexity of callbacks is increasing over time.
Use typedefs to define each of them so that callbacks:
- Are easier to identify (which types is used where)
- Are easier to document (have a 1st class place to write doxygen
  documentation)

Change-Id: Ib0c4a9713fa4c755e457b8c2cbde6a7724d36e28
2024-04-17 13:53:57 +02:00
Harald Welte ed62d190b6 docs: Improve/clean-up doxygen for datagram.[ch]
* make sure datagram.h is part of the group
* don't expose private #defines from C files to API documentation

Change-Id: I64a9ee3306bcc01ba785da476aea581ce31150bd
2024-03-19 14:20:15 +01:00
Harald Welte 2136d599af docs: various osmux API documentation updates
Let's make sure
* only exported / user-relevant #defines appear in the manual
* deprecated functions are marked in a way doxygen can mark them
* descriptive comments are using doxygen syntax

Change-Id: I5af0133322ddd5345a13380f1c007474c0bea117
2024-03-19 14:20:15 +01:00
Harald Welte 34a657d1e1 introduce osmo_stream_cli_get_iofd() API
Using this, a user can obtain the osmo_io_fd, for example in order to
perform configuration like osmo_iofd_set_alloc_info() or
osmo_iofd_set_txqueue_max_length().

Change-Id: Ie19c8294ddb12dfe5e0fd44e047c47e6f9cbd384
2024-03-17 17:41:22 +00:00
Harald Welte 912360157d docs: Split Stream Server and Stream Client into separate groups
This provides us with proper logical separation between client and
server in the documentation.

Change-Id: I9e037fedaecb78396f435577b1652284b4951ded
2024-03-15 14:14:07 +01:00
Harald Welte 472354b693 docs: Use \defgroup and avoid repeated boilerplate text
Change-Id: I1196c3b035f495c5dbaa4d47ce3f79a08d0727f2
2024-03-15 14:13:31 +01:00
Pau Espin a5722bb75d prim: Introduce osmo_prim_srv{_link}_set_name APIs
This allows a user setting a name on the underlaying stream which
in turns allows easily identifying the socket.

Change-Id: Iba683e4d65e0aba81e13bdf1b9d5a9065b1fc89c
2024-03-13 11:57:47 +00:00
Pau Espin 36eb157ed6 stream: Add osmo_stream_*_get_name() APIs
This allows users to retrieve a previously set name.

Change-Id: If5054d3c207f8f5d58a448f1e58266ad9c4386dd
2024-03-13 11:57:47 +00:00
Harald Welte 7e6d2e0f99 stream_{cli,srv}: Add support for SCTP in OSMO_IO mode
Let's enable the OSMO_IO_FD_MODE_RECVMSG_SENDMSG mode for SCTP
sockets, allowing OSMO_STREAM_MODE_OSMO_IO to be used with SCTP.

Change-Id: I6cf5bad5f618e71c80017960c38009b089dbd6a1
Depends: libosmocore Change-Id: I89eb519b22d21011d61a7855b2364bc3c295df82
Closes: OS#5753
2024-02-29 13:23:13 +01:00
Pau Espin 5aa00fe885 stream_cli: Introduce API osmo_stream_srv_get_sockname()
Similar to what osmo_stream_srv_link and osmo_stream_cli already have.

Change-Id: I171befd1fdf40c3cbb3fc7e4c3eedf82128b0712
Related: SYS#5580
2023-12-08 18:43:31 +01:00
Pau Espin a7650de412 netif: sctp.h: Introduce value_string for enum sctp_sstat_state
This can be used by apps retrieving struct sctp_status through
getsockopt(SCTP_STATUS).
The relevant field is spinfo_state: osmo_sctp_sstat_state_str(st.sstat_state);

Change-Id: Id7d8a9ad7b32406ac603e520b33809d7ae5c762f
Related: SYS#6636
2023-12-08 17:45:20 +01:00
Pau Espin 1810e12df3 netif: sctp.h: Introduce value_string for enum sctp_spinfo_state
This can be used by apps retrieving struct sctp_paddrinfo through
getsockopt(SCTP_GET_PEER_ADDR_INFO).
The relevant field is spinfo_state: osmo_sctp_spinfo_state_str(pinfo.spinfo_state);

Related: SYS#6636
Change-Id: I78a0bd8279a04f4011c7273e0f542981308e482f
2023-12-08 17:45:07 +01:00
Pau Espin 14dd5ba329 stream: Add missing osmo_stream_srv_link_get_fd() API
osmo_stream_srv and osmo_stream_cli already had that API introduced in
order to use it instead of *_get_ofd(), since the later will eventually
be deprecated due to incoming osmo_io.

Change-Id: I1bd3f790d93af74c150938a59108b882ad2820f3
2023-12-06 17:56:46 +01:00
Harald Welte 5ccee1e1b1 Introduce generic osmo_stream_{cli,srv}_get_fd() API
The old osmo_stream_{cli,srv}_get_ofd() API only works for streams
in OSMO_FD mode.  However, it is legitimate for an application
wanting to get low-level access to the file descriptor, for example
to issue some {get,set}sockopt() calls on it.

Change-Id: Ib0737f21150f6ac8d524b92c7ddb098f2afdeaab
Related: OS#5753
2023-11-21 20:25:21 +01:00
arehbein 106b63907a stream: Add and use helper function osmo_ipa_push_headers()
Related OS#5753, OS#5751

Change-Id: I61e1fe59166c46595efe8c1f32b8f2607cb6c529
2023-10-09 12:49:36 +00:00
arehbein bc496b1db0 stream: Add client-side (segmentation) support for IPA
With this commit, IPA segmentation is taken care of by setting the
segmentation callback provided by libosmo-netif.

The ipa-stream-server example needs to prepend IPA headers now because
those are stripped by the segm. cb on both sides.

Depends: libosmocore.git I3a639e6896cc3b3fc8e9b2e1a58254710efa0d3f

Related: OS#5753, OS#5751
Change-Id: I822abf52c6ae396c90b5c50228a0a39c848d3de6
2023-10-02 13:40:01 +00:00
arehbein 35fcd6025d ipa: Don't break strict aliasing rule
Somehow gcc doesn't always warn about this rule being broken.
We are breaking the strict aliasing rule here and libosmo-netif
currently does not make use of the '-fno-strict-aliasing' flag.

It's possible that this has also been causing nondeterministic
timestamps in libosmo-netif stream tests every once in a while.

Related: OS#6164, OS#5753
Change-Id: Ibed543cdfcdda8c0256ce7d8818ff96d6d46e9b0
2023-09-19 12:30:19 +02:00
Pau Espin 745c0e2a0f stream: Add new stream_{cli,srv_link} parameters to set SCTP_INITMSG sockopt values
This will allow osmo_stream users (like libosmo-sccp) to set
SCTP_INITMSG related parameters, like number on inbound/outbound
streams, connect attempts, connect timeout.

Related: SYS#6558
Change-Id: I5343c7659881b29e0201e72badbc2d07e1ef2dca
2023-09-12 00:01:00 +02:00
Pau Espin efd56fb2a2 stream: Introduce API to set several transport parameters
This will allow extending capabilitites to set different parameters at
the lower layers as we need them.

This commit changes the behavior of osmo_stream_{cli,srv_link}: It now
doesn't enable by default SCTP AUTH/ASCONF features using setsockopt. It
is left up to the user of the API (libosmo-sccp in this case) to set it.
Since this unilateral use of setsockopt() has only been added recently
and we didn't release yet, it's fine changing it. libosmo-sccp will be
changed to unconditionally set its using setsockopt. It is left up to
the user of the API (libosmo-sccp in this case) to set it.

Related: SYS#6501
Related: SYS#6558
Change-Id: I2607c1c926a625986cd851adc65dd8b4de83d6ab
2023-09-08 17:53:21 +02:00
arehbein f990b307bd stream: Add server-side (segmentation) support for IPA
With this commit, IPA segmentation can be taken care of by setting
the segmentation callback osmo_ipa_segmentation_cb().

Depends: libosmocore.git I3a639e6896cc3b3fc8e9b2e1a58254710efa0d3f

Related: OS#5753, OS#5751
Change-Id: I6c91ff385cb5f36ab6b6c96d0e44997995d0d24c
2023-08-25 13:26:46 +00:00
Pau Espin deafe50cef stream: Refactor sctp_recvmsg_wrapper() logging
*Move the helper function to stream.c and pass a logging prefix string
so that it can be used by both client and server.
* Adapt log level based on message type.
* Rework logging code to log everything in one line

Change-Id: I0ed84cc2effb71b6ef1f6efb3f8b663c602a5a31
2023-08-21 10:25:01 +02:00
Pau Espin a49a2b4d70 stream_srv: Log SCTP REMOTE_ERROR events
The event was enabled but was not being logged.

Change-Id: I49f5a648fd474e320101424fb6873a37442339bf
2023-08-07 19:16:24 +02:00
Pau Espin 7d1430152f sctp: Document relevant RFC specs
Change-Id: Iae325b787fdb7fc95aa6922975a7e1fcf368527a
2023-08-07 19:16:24 +02:00
arehbein 8355b65d9b ipa: Add segmentation callback
Related: OS#5753
Change-Id: I87ef4c7023126b783dd79e7ed47be31e1b76f975
2023-08-07 17:46:53 +02:00
arehbein 8712af589c examples: Add extension header octet to example
Mainly to make data/packets look (pseudo-)correct in Wireshark.

Also: Add helper for allocating message buffers with extended headroom for IPA.

Change-Id: I962b9edcba65cdc98da00d2f8753dc5acd481502
2023-08-07 16:50:22 +02:00
Pau Espin 7fe21f67f6 stream: Split cli/srv specific code out of stream.c
The dev/user in general is only interested about one side of the stream
when looking at the code. Since the stream.c file is tarting to be quite
large/bloated, this patch splits its content into stream_cli.c and
stream_srv.c to make it easier to improve/extend and review.
Keep common code between cli and srv in stream.c, and add a private header
to contain references to it.

Change-Id: I22af01bba2040eb320ba48fd1b46c090c98be159
2023-08-04 13:28:50 +02:00
Pau Espin 832c086852 stream: Drop name param from recently added API osmo_stream_srv_create2()
It was later decided that since setting a name is not really required,
it is best to leave it out of the create() function and let the user use
the osmo_stream_srv_set_name() API if needed (otherwise a dynamic name
based on socket is selected)

Change-Id: I5d677ef57b7db0aedd8c43282568c845097cb12b
2023-06-20 13:50:44 +02:00
Pau Espin 08e9b6c612 stream: Drop recently added API osmo_stream_cli_create2
It was later decided that since setting a name is not really required,
it is best to leave it out of the create() function and let the user use
the osmo_stream_cli_set_name() API if needed (otherwise a dynamic name
based on socket is selected).

Change-Id: I2a2fad318ef22c2ac117f95588a078ca3beccea5
2023-06-20 13:49:37 +02:00
Pau Espin 64c241be5d stream: Allow setting name printed during logging
Depends: libosmocore.git Change-Id If2772a3ccaa98616e0189862a49ab0243435e343
Change-Id: I539a0d29d11348efe702f971965a55cf56db5c59
2023-06-20 09:05:24 +00:00
Daniel Willmann 0e7028f742 Add osmo_io support to osmo_stream_cli and osmo_stream_srv
Change-Id: I2f52c7107c392b6f4b0bf2a84f8c873c084a200c
2023-06-14 17:33:35 +02:00
Daniel Willmann 2d340403f2 stream: Properly name osmo_stream_srv read callback
Change-Id: I12d74e9b407f1ea7af83fb3ec4d03ad7228a27cf
2023-06-08 13:44:44 +02:00
Oliver Smith 605fb80c08 rtp.h: add RTP_PT_CSDATA
Related: OS#4393
Change-Id: I2ea378ba4d17e977da25ef9e6e86b3de2ccd0ad7
2023-02-27 08:29:51 +00:00
Oliver Smith 1d129ae24b Run struct_endianness.py
Ensure there is no diff to prepare to run this in CI.

Related: OS#5884
Change-Id: Ib3459ebb2414dd1798dfda6d3c585232ceff741b
2023-02-20 09:49:45 +01:00
Max 50d4a66e34 Add osmo_stream_srv_link_is_opened()
We use file descriptor of -1 as an indicator for unopened link internally.
However, since all the structs of libosmo-netif are opaque, using it from external
applications looks like a leaky abstraction.

Let's remedy this by adding function which properly check this for the library user.

Related: OS#5568
Change-Id: I91aa7da5f09ec4e8e2d21c827b45ed92e6b0e3d9
2023-02-10 11:43:26 +00:00
Pau Espin 99e5470ece amr: Clarify size of AMR BWE header and ToC
Change-Id: I34c76b18ee45e12dba92864715e8ef91e6de3b01
2022-12-21 21:32:25 +01:00
Pau Espin 26a02deb12 amr: constify input buffer in osmo_amr_is_oa()
Change-Id: I72ef6fc700f628ea158ea888a5f1e9dc8776ab7e
2022-12-21 18:37:45 +01:00
Pau Espin 17b1142959 amr: Add missing header stdbool.h
Change-Id: I84e447960c4912147d2f3a6170393370d354625b
2022-12-21 18:37:45 +01:00
Pau Espin 8ede0098b8 amr.h: Fix AMR_FT_{GSM,TDMA,PDC}_EFR_SID_LEN
Fixes: 678c7fc8fe
Change-Id: I63c8082bec12bf81760330d1fc0b13de23ac6a24
2022-12-21 18:37:45 +01:00
Pau Espin 678c7fc8fe amr: Support all SID and NO_DATA amr formats
Related: SYS#6161
Change-Id: I0e766b3231f03ea87d89fad6ecdce3bd14769054
2022-12-19 19:44:16 +01:00
Pau Espin 8997fe8251 amr: Add struct definition for AMR BWE header
Change-Id: I4b44257605bc5967d862ee29076ea6260d9a6bd8
2022-12-19 17:38:35 +01:00
Pau Espin c7f7090abd amr.h: Fix missing include dependencies
Needed for size_t uint8_t, etc.

Change-Id: Ia808c2b6c426de79db5c88784dd7bce6096179aa
2022-12-19 14:52:44 +01:00
Pau Espin 22b4e8159d osmux: Introduce API osmux_xfrm_input_set_name()
This will be used internally by osmux code to print more meaningful
lines.

Related: SYS#6161
Change-Id: Ibbcfdb23a6015ce45840bb64b2b560c2806f7ff6
2022-11-18 17:37:46 +01:00
Pau Espin 62a7ec137a osmux: Add data[0] field to osmux_hdr
This allows easy access to osmux_hdr payload.

Change-Id: I27750c38f12d3d84dbaac5beff166d78ffa6c45b
2022-11-15 19:55:03 +01:00
Pau Espin d8c5a906b4 stream: Introduce APIs osmo_stream_{cli,srv}_clear_tx_queue()
Related: SYS#6113
Change-Id: Iecb0a4bc281647673d2930d1f1586a2df231af52
2022-10-17 13:48:07 +02:00
Pau Espin 5bf2832145 cosmetic: stream: Fix parameter name
The param is already "cli" in the .c file.

Change-Id: I7e1e9902a39655e57e28d38a222bca850dd7de0e
2022-10-17 13:34:22 +02:00
Pau Espin c76b54ba63 stream: Improve logging of SCTP_PEER_ADDR_CHANGE notification
Related: SYS#6113
Change-Id: Ieebc6e623874b4770ec7cd8b934244ffecaa089d
2022-10-17 12:27:16 +02:00
Pau Espin f10f354e3f osmux: Introduce API osmux_xfrm_input_get_deliver_cb_data()
This API allows retrieving back the private pointer set previously by
osmux_xfrm_input_set_deliver_cb().

Change-Id: I95433b18802f73fa70e758f4aa02128eee940d88
2022-10-03 17:21:10 +02:00
Pau Espin 36ca79e708 osmux: Allocate struct osmux_out_handle through API
Until now, the osmux_in_handle was allocated by the client, and passed
to the API to initialize it. This makes it really hard to improve the
implementation without breaking the ABI.

Let's break the ABI now one last time (hopefully) by allocating the
struct through an API. With only this change, the already built users
(osmo-mgw, openbsci, osmo-bts) can still work fine, since there's no
change on the struct osmux_in_handle. However, they will somehow break
next time thestruct is changed until they are ported to the same API
(easy to do).

Change-Id: I752ab031f935f04731bb1a354333f1682a1aa5bd
Related: SYS#5987
2022-10-03 11:30:45 +02:00
Pau Espin b0369f375f osmux: Take into account configured osmux_in_handle->osmux_seq field
It was not being used anywhere, yet older applications used to set it
(always to 0, which was the default value applied internally).
Let's make use of it and apply it as first seqnum to be used on a
circuit.
This value is applied upon call to osmux_xfrm_input_open_circuit(),
hence it can be set independently for every new circuit.

Change-Id: Ia26fcba5d7364a5744b2d64d0542a2b3880eee34
2022-10-03 09:29:18 +00:00