Commit Graph

29 Commits

Author SHA1 Message Date
Pau Espin 668c804197 stream: Provide caller with SCTP flags during osmo_stream_*_recv()
The user may want to check the flags in order to know if the content
pointed at by msgb is an sctp_notification structure, and not in-band
data.
This is useful for the user in order to gain connection state such as
SCTP RESET notification, which means the client reconnected reusing the
same socket, loosing all higher layers state.

The MSG_NOTIFICATION from netinet/sctp.h is not reused, and instead an
osmocom specific flag (and bitmask) is used. This is done in order to
fit the flags in one byte, since for instance MSG_NOTIFICATION requires
2 bytes in my system (0x8000).

Related: SYS#6113
Change-Id: I0ee94846a15a23950b9d70eaaef1251267296bdd
2022-09-19 14:50:34 +02:00
Pau Espin b2b5f1c6bf stream: Add support for AF_UNIX sockets
Change-Id: I5237a8121be05a9a31a39ca38a6a139062f258c4
2021-12-09 13:47:41 +01:00
Pau Espin c3a6c75cea stream: osmo_stream_cli: Support setting multiple addr
This API will be later used to set multiple addresses for SCTP sockets.

Depends: libosmocore.git Ic8681d9e093216c99c6bca4be81c31ef83688ed1
Related: OS#3608

Change-Id: I09f0d989f2309abdeb304fe570355abed2cd107b
2019-10-15 13:11:54 +02:00
Pau Espin f254ef80f2 stream: osmo_stream_srv_link: Support setting multiple addr
This API will be later used to set multiple addresses for SCTP sockets.

Depends: libosmocore.git Ic8681d9e093216c99c6bca4be81c31ef83688ed1
Related: OS#3608
Change-Id: I0fe62f518e195db4e34f3b0ad1762bb57ba9d92a
2019-10-15 13:11:51 +02:00
Pau Espin 962bf9a48e stream: Introduce API osmo_stream_cli_is_connected
Can be used by users to fetch current status of the stream.

Change-Id: I5402430e5f39eef22dfa18f33807ab6b1e771f1b
2019-09-04 17:04:18 +02:00
Max b3e34435b3 Deprecate osmo_stream_cli_open2()
This supposed to be variant of osmo_stream_cli_open() with explicit
control over reconnection logic but it's plain broken: doxygen docs
contradict the code, actual reconnection logic is affected by timeout
parameter directly which is set in different function.

It seems like we haven't been affected by this so far because we always
use it in auto-reconnection mode which is triggered by default due to
positive reconnection timeout value (5 sec) automatically used in the
absense of explicitly set timeout.

Looking at commit history, this function already been source of
confusion in the past. Instead of trying to fix this mess, let's just
deprecate it entirely and properly document use of
osmo_stream_cli_set_reconnect_timeout() to control reconnection logic.

The only known user is libosmo-sccp which won't use it as of
0a93a683f3cb8e5977eb4a666ab207db6e7d7af9 commit.

Change-Id: Id988ed0274b363db049f59cbf6a193727c8c3c8a
2019-03-19 13:40:55 +00:00
Max af63d87a76 Stream client: add disconnect callback
It's similar to connect_cb() but called once client has been
disconnected.

Change-Id: I905adb2d6191216551a3bcdcd1aec1f96f01612a
2019-02-20 17:33:32 +01:00
Max 732652b5b7 Add socket name functions to stream client/server
Add functions to get the description of a server link or client
connection which examine data on corresponding socket.

Those functions use static buffers and intended for single use in
log/printf statements as illustarted by corresponding example changes.

Change-Id: If9a8e211da85956781479862a63c4fc6e53ed6be
2019-02-05 16:25:20 +00:00
Max a720365c02 Cosmetic: use #pragma once as include guard
Change-Id: I2c1a13252730294597a7a9fb5726aae928f41bfd
2019-01-31 16:21:07 +01:00
Max de81cedffe Add missing include
stream.h uses msgb from libosmocore without corresponding #include
It's odd that we haven't hit this issue earlier.

Change-Id: Ib8b4f4965af0fefa7dac3f2a56a5a4b76a03fd57
2019-01-31 16:19:23 +01:00
Stefan Sperling f27fdf89dc add support for flushing and destroying a server-side stream
Introduce osmo_stream_srv_set_flush_and_destroy() which marks a
stream to be 'flushed and destroyed'. No new messages will be
received on this stream, and no new messages can be queued.
Once the Tx queue has been drained, the connection is destroyed.

The API user is given a chance to perform cleanup operations
in the closed_cb() callback for the connection.

The same mechanism will be added for client-side connections
in a follow-up patch.

Change-Id: I8ed78fe39c463e9018756700d13ee5ebe003b57f
Related: OS#2789
Suggested-by: Harald Welte
2018-02-22 19:48:36 +01:00
Pau Espin 56add1e780 stream.h: Add missing stdint.h include
This header uses uint16_t, which is provided by stdint.h.

Change-Id: I399e2986c9d8cb5b3dd31673a6b4bf63070a4770
2017-05-02 07:26:30 +00:00
Harald Welte 73a44d2348 stream.h: Add missing stdbool.h include
Functions introduced in 9ec26583cd are
using the bool type without referencing stdbool.h as include file.

Change-Id: I736cb04629d516c10c7d5f42f792ed3d5ae6658f
2017-04-12 15:06:37 +02:00
Harald Welte 9ec26583cd Add osmo_stream_{cli,srv_link}_set_nodelay() function
Using this function, the user can configure if sockets related to the
respective stream client or server should have the NODELAY socket
option set in order to avoid Nagle algorithm or related algorithms
that may introduce packet delay on the transmitter side.

Change-Id: Ibeb9ba227bab18f7f4f16518c0022c4f003cc8e9
2017-04-11 19:54:07 +02:00
Harald Welte a2c2b59165 stream+datagram: Allow local bind + connect for client sockets
This uses the new osmo_sock_init2() features introduced in libosmocore
Change-Id Idab124bcca47872f55311a82d6818aed590965e6 to bind *and*
connect a given socket during creation.

Change-Id: I013f4cc10b26d332d52d231f252bb0f03df8c54b
2017-04-10 06:40:14 +00:00
Harald Welte d0f9bd600c Add minimal doxygen documentation for stream + datagram modules
We should have doxygen documentation for all libosmo-* APIs.

libosmo-netif is currently devoid of any API docs. Let's start with the
stream and datagram socket related functions.

Change-Id: I589a5e60d9df2b8a65fbaf68f80e3ae0039d8c2a
2017-04-08 20:13:14 +02:00
Harald Welte d8c820570b stream: Export osmo_stream_cli_reconnect()
In case the application is using the read-callback and a read returns 0,
then the application itself would want to trigger the reconnect.  This
is different from the osmo_stream_cli_recv() case where the reconnect
can be handled internally to the library.

Change-Id: I41314bad4a9f44e8a61b9d2ba33d1a76b25bd145
2017-03-17 12:07:19 +01:00
Harald Welte cc4ce39fc6 fix/complete stream client re-connect logic
So far, when the first connection attempt failed in
osmo_stream_cli_open(), we returned a terminal errro without any
re-connection attempts.  While this may be useful in some cases, our
general idea of the stream client logic is to handle the reconnection
attempts insid the library.  We introduce a new osmo_stream_cli_open2()
function while keping the old behavior for backwards compatibility.
2015-12-22 23:54:21 +01:00
Harald Welte fb3e20b4b2 SCTP support for osmo_stream_{cli,srv} code
Wih this change, osmo_stream_ client and server API can be used not only
for TCP but also for SCTP.  The latter is needed in SIGTRAN ad Iuh
applications, for example.
2015-12-21 20:54:19 +01:00
Pablo Neira Ayuso 5abf7f2ea4 stream: add osmo_stream_srv_get_master
To obtain the information of the server data that this connection
belongs to.
2012-08-19 18:35:10 +02:00
Pablo Neira Ayuso cee5fb36da src: shorter stream function names
%s/_client_conn_/_cli_/g
%s/_server_conn_/_srv_/g
%s/_client_/cli/g
%s/server/srv/g
%s/RECONFIG/RECONF/g
%s/SERVER/SRV/g
%s/CLIENT/CLI/g
2012-08-15 23:34:35 +02:00
Pablo Neira Ayuso 2b5d3ce7c6 src: add generic channel infrastructure and A-bis IPA server support
This patch adds the generic channel infrastructure that allows to
create channel of different types. Each channel has their own
configuration functions.

  struct osmo_chan *chan;
  chan = osmo_chan_create(tall_example, CHAN_ABIS_IPA_SERVER);
  ...

  /* specific configuration functions per supported channel. */
  osmo_chan_abis_ipa_server_set_cb_signalmsg(chan, signal_msg_cb);
  osmo_chan_abis_ipa_unit_add(chan, 1801, 0);

  /* open channel. */
  osmo_chan_open(chan);

The input path requires a callback to be registered. The output path
is handled through:

  int osmo_chan_enqueue(struct osmo_chan *c, struct msgb *msg);

The msg->dst must be set (it can be taken from the original message
to route one reply).

This patch also adds A-bis IPA server support. It has been tested with
e1inp_ipa_bsc_test available in libosmo-abis.
2011-11-08 11:17:44 +01:00
Pablo Neira Ayuso d3ba14648c stream: allow to set reconnect timeout
This patch allows to set reconnect timeout. If zero, it will try
immediately. If negative, it will skip retrying.
2011-11-08 11:13:22 +01:00
Pablo Neira Ayuso 1434e40951 stream: add osmo_stream_*_conn_get_ofd(...) functions
To obtain the file description.
2011-10-17 22:12:37 +02:00
Pablo Neira Ayuso 98ec00d8d2 stream: add osmo_stream_*_conn_recv
Like c43bb08906 but for stream
sockets.
2011-10-17 12:51:18 +02:00
Pablo Neira Ayuso 2bd6adfd86 stream: add *_get_data() function to obtain private data
Add new functions:

osmo_stream_server_link_get_data
osmo_stream_server_conn_get_data
osmo_stream_client_conn_get_data

To obtain private data from osmo_stream_* handlers.

This patch also introduces missing osmo_stream_server_conn_set_data.
2011-10-09 21:35:51 +02:00
Pablo Neira Ayuso ad2eca4768 stream: add osmo_ prefix to all functions
Modify examples as well to use the new API.
2011-10-09 18:00:53 +02:00
Pablo Neira Ayuso 57d86b7d28 stream: remove includes from stream.h header
The should be uses in the client program. They are not required by
the generic stream socket infrastructure.
2011-10-05 13:43:15 +02:00
Pablo Neira Ayuso 8bf16493f6 initial commit 2011-10-04 02:36:46 +02:00