Commit Graph

24 Commits

Author SHA1 Message Date
Harald Welte 637025b2f7 migrate to osmo_fd_{read,write}_{enable,disable}()
Change-Id: Ia8ffcbc61883a4e1615c101dbd3307771ae33974
Depends: libosmocore.git Change-Id Idb89ba7bc7c129a6304a76900d17f47daf54d17d
2021-02-11 15:40:54 +01:00
Harald Welte bd775e4adb cosmetic: Fix whitespace (use tab instead of 8x space)
Change-Id: I2b8d80fb771336d4d2c4a9ea1749935bdf14a37b
2020-10-21 14:03:29 +02:00
Harald Welte eb96eb7d68 Use osmo_fd_setup() wherever applicable
Change-Id: Ifb90e00036cc51ef02f3cf4dda1ff7dcd1f8a5b5
2020-10-18 23:12:20 +02:00
Pau Espin b988f2bb36 Use OSMO_FD_* instead of deprecated BSC_FD_*
New define is available since libosmocore 1.1.0, and we already require
1.3.0, so no need to update dependenices.
Let's change it to avoid people re-using old BSC_FD_* symbols when
copy-pasting somewhere else.

Change-Id: I269690c1c9e4d19b5b69eef206b95e71f7931188
2020-05-09 19:14:17 +02:00
Harald Welte bea215a565 Add SPDX-License-Identifier + Copyright statements
Change-Id: I43bb1c4a889421907a1a08eb29c96f2330ab00ec
2017-11-13 01:21:03 +09:00
Harald Welte 61b5b65deb some more Doxygen header text for datagram, osmux and stream module
Change-Id: Ied83e6b117a420d734a88e3aff925a874c3dd520
2017-10-27 19:57:37 +02:00
Max 1bfbf98f06 cosmetic: print textual error from recv()
Change-Id: Ic9557c6519b44b5985daf7d2d14ec063790441fb
2017-10-13 18:24:37 +02:00
Max a2b50809c7 cosmetic: relax UDP length check
Previously recv() returning 0 for UDP socket was considered as error
although it's legitimate return value for empty UDP packets. Relax the
error check to avoid confusing error messages.

The function behavior is the same:
* msg is not altered while receiving 0-length UDP packet
* return value is 0

The only result of the relaxed error check is the absense of error log
message for 0-length UDP packet.

Change-Id: I32e5fcbf5ed92cc923660ac59e6a37fd3f0703a7
Fixes: OS#2219
2017-10-13 18:19:32 +02:00
Holger Hans Peter Freyther 4e93766a4b misc: Call the variable ctx like in all other places
We couldn't figure out what "crx" as supposed to mean and assume
it is a typo. Fix the code and call it ctx, this is fixing the
API documentation as well.

Change-Id: I27ed1178fdbbcf3fc0e1070dc19b4ecf9a327a04
2017-04-29 11:56:14 +00:00
Harald Welte 7cee4b67e9 stream/datagram: Ensure reliable close/destroy
* when using osmo_*_destroy(), always call *_close() internally to
  make sure we don't free memory holding references to sockets that are
  still open
* when closing the socket, always make sure to set the fd to -1 in all
  cases, to avoid attempts to avoid later close() on a new file using
  the same fd number as the socket closed previously.

Change-Id: I29c37da6e8f5be8ab030e68952a8f92add146821
2017-04-10 06:52:59 +00:00
Harald Welte 0bacc71fc2 stream/datagram: Consistently use osmo_talloc_replace_string()
during osmo_*_set_addr(), we must make sure to talloc_free() any old
address before copying in the new address.  Not all functions did this,
and those that did implemented it manually.  Let's use
osmo_talloc_replace_string() which is exactly intended for this case.

Change-Id: Ie1b140a160c66e8b62c745174865d5ba525cb2c2
2017-04-10 06:47:28 +00: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
Nikola Kolev 2f1ddb2709 Fix the compilation on FreeBSD. 2015-02-25 15:52:14 +01:00
Pablo Neira Ayuso 4aa540ae27 dgram: add osmo_dgram_get_data 2012-10-21 03:08:37 +02:00
Pablo Neira Ayuso ad2e9d637e src: shorter names for datagram sockets
%s/_conn_/_/g
%s/_conn//g
%s/_server_/_tx_/g
%s/_client_/_rx_/g
%s/_SERVER_/_TX_/g
%s/_CLIENT_/_RX_/g
%s/_RECONFIG/_RECONF/g
2012-08-15 20:16:09 +02:00
Pablo Neira Ayuso 59b4f79946 datagram: minor cleanup
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2012-02-23 19:50:47 +01:00
Pablo Neira Ayuso c43bb08906 datagram: add osmo_dgram_conn_recv
We provide osmo_dgram_conn_recv(...) which allows you to take control
on the message allocation and receival process. Instead of hiding this
details inside the datagram infrastructure.

Providing more control to clients of this code means more flexibility.
2011-10-17 12:34:40 +02:00
Pablo Neira Ayuso 4b83212dfb datagram: reconfiguration is only required if address and port change
We allow to change the callback and data pointers in runtime safely
without the need to reconfig.
2011-10-17 12:09:29 +02:00
Pablo Neira Ayuso 370794a4a7 datagram: use LOGL_DEBUG in osmo_dgram_server_conn_read
This removes spamming message that is currently displayed with
LOGL_NOTICE loglevel.
2011-10-14 20:53:39 +02:00
Pablo Neira Ayuso 6e0415a9cc datagram: change prototype of osmo_dgram_conn_set_read_cb
This patch changes the prototype of osmo_dgram_conn_set_read_cb.

Now it takes one callback to a generic struct osmo_dgram_conn
instead of osmo_dgram_server_conn. This is useful in case that
you want to reply to one message using the datagram socket (without
this change is not possible).
2011-10-14 20:51:19 +02:00
Pablo Neira Ayuso dae8f28374 datagram: support calling dgram_*_open() multiple times for reconfigurations
This patch allows you to call dgram_*_open(..) as many times as
you want to trigger reconfigurations.
2011-10-09 20:44:28 +02:00
Pablo Neira Ayuso f47752fbff datagram: add osmo_ prefix to all functions
Modify examples as well to use the new API.
2011-10-09 18:27:28 +02:00
Pablo Neira Ayuso ddb9bf65f4 add generic datagram socket infrastructure and examples
This patch adds new datagram socket infrastructure and it reworks
the previous examples (now it's LAPD over datagram).
2011-10-05 13:43:10 +02:00