Commit Graph

32 Commits

Author SHA1 Message Date
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
Daniel Willmann 5fe77a4656 stream.c: Handle SCTP in osmo_stream_srv_recv()
Change-Id: If0875cfa3eba9ef36acc0c4bfd0d168a45c380b9
2017-03-29 15:23:52 +02:00
Harald Welte db9808e883 stream client: Ensure client is notified on reconnection
without setting the BSC_FD_* flags prior to reconnection, the re-connect
would happen silently and the client program would not be notified via the
connect_cb().

Change-Id: Iaf8ec8662cf83476eee1b76fa41dc57f063f0ad3
2017-03-20 01:32:06 +00: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 f2174ef1a2 stream: When destroying, make sure to kill reconnect timer
if osmo_stream_cli_destroy() is called while the reconnect timer is
running, we would end up in a crash.

Change-Id: If6597130f472f1e2b8d9682002250ecd54675bb0
2017-03-17 12:07:19 +01:00
Harald Welte a4c1a73250 stream: don't crash in _close() when fd is not initialized
We use the magic value '-1' in case the file descriptor is not yet
initialized.  If somebody calls osmo_stream_*_close() before this
changes, we used to crash.  Let's check for this and avoid a crash.

Also, after close let's change the fd to -1 again to mark the fd
invalidity.

Change-Id: I3aa04999ab01cb7971ee2dad45dfc31ab4142868
2017-03-17 12:06:24 +01:00
Harald Welte 781e7b38f8 stream_client: Actually use/honor the reconect parameter
The reconnect behavior was likely broken in commit
de3f57a8293a5b39435d6f283da23e0172bad8bb

If the user requests a re-connect, we should start it. Not only in case
the connection drops later, but also if the initial connection itself
fails.

Change-Id: I817e026404cbd9145cae2ce90bc57a1db1d2e12b
2017-03-17 00:24:23 +01:00
Harald Welte 29d6cd4134 osmo_stream_cli_open2(): Fix bogus EINPROGRESS handling
osmo_sock_init() never returns -1 + errno EINPROGRESS. It will return a
positive fd in case the connect operation is in progress. Therefore,
the related code in osmo_stream_cli_open2() was impossible to execute.

Change-Id: Id3483d1d1d4d2eabba94729ea29e5c93b33abff0
Fixes: Coverity CID 57861
2016-12-01 15:52:54 +01:00
Harald Welte b2b2fe643f sctp_sock_activate_events(): Print error message on error
When the setsockopt() in sctp_sock_activate_events() indicates an error,
let's print an error message in the log about this.

Change-Id: I5920154e23debe6d01eaa156005db0842f1a18cc
Fixes: Coverity CID 57634
2016-11-26 16:41:06 +00:00
Arran Cudbard-Bell 5b0ad8bd85
Set SO_NOSIGPIPE on SCTP connections, for patforms which support it (macOS, FreeBSD etc...)
Change-Id: If4f2a99b2baf143551a7122f40ed1f9088c5936c
Signed-off-by: Arran Cudbard-Bell <a.cudbardb@freeradius.org>
2016-11-02 13:22:24 -04:00
Daniel Willmann 10f981a4a1 stream: Use macros to access data and length 2016-02-19 09:23:31 +01:00
Harald Welte 2b03b8c07c stream.c: ensure to zero-initialize sctp_sndrcvinfo
caught by valgrind:
==3150== Syscall param sendmsg(msg.msg_control) points to uninitialised byte(s)
==3150==    at 0x60DC0D0: __sendmsg_nocancel (syscall-template.S:81)
==3150==    by 0x5DF3413: sctp_send (in /usr/lib/x86_64-linux-gnu/libsctp.so.1.0.16)
==3150==    by 0x65AA066: osmo_stream_srv_write (stream.c:540)
2015-12-25 17:47: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 b60edf05a6 stream.c: Fix another 'link' variable / symbol mismatch 2015-12-22 23:53:55 +01:00
Harald Welte b36fd0b912 osmo_stream_cli_destroy: call talloc_free on right object
'link' turns out to be a really bad variable name, as the symbol
resolves to the global link(2)...
2015-12-22 23:40:47 +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
Nikola Kolev 2f1ddb2709 Fix the compilation on FreeBSD. 2015-02-25 15:52:14 +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 e57c7e1e3f stream: don't destroy server connection on error
This patch includes a minor fix. We don't destroy connection on
errors, it should be the caller which must control this.
2011-11-08 11:17:38 +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 96dbb24b50 stream: reconfiguration is only required if address and port change
No need to force reconfiguration if any of the callback or data
pointers are changed.
2011-10-17 12:52:39 +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 60eb983964 stream: use debug loglevel instead of notice for spamming debug message 2011-10-17 12:10:30 +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 cc7a948d3e stream: support calling stream_*_open() multiple times for reconfigurations
This patch allows you to call stream_*_open(..) as many times as
you want to trigger reconfigurations.
2011-10-09 20:44:09 +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 7c20d4ef1e stream: remove internal stream_msg_recv()
Remove stream_msg_recv(...), now we use recv(...) directly. This fixes
since we were calling msgb_put(...) twice.
2011-10-05 13:43:18 +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