Commit Graph

23 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
Andreas Eversberg b06e63b7c7 stream_{client,server} example: Cleanup on exit
In order to detect memory leaks while debugging, stream server/client
and keyboard is closed on exit.

Related: OS#5753
Change-Id: I9dbb7f46b2a798e88ad4df8ff73c6ee40c07b843
2024-03-07 10:28:20 +01:00
Andreas Eversberg d467b6348c stream_{cli,srv}: Fix memory leak, if sending a message fails
Also the example client/server must not access msgb after sending it,
especially if the msgb got freed due to a failure.

Change-Id: I627a71b4f0183cd83835c328a5cdd67a413ae614
2024-02-29 13:23:20 +01:00
Harald Welte 54d17d664a examples/stream-{server,client}: Generate talloc report on SIGUSR1
This can help with memleak debugging.

Change-Id: Ia16632602b937db88e2da2b053192887bdb8a986
2024-02-28 08:48:42 +00:00
Andreas Eversberg a7b687b121 examples/stream-*: Add options, to set local/remote peer
This helps to test connections via a network and failing connections.

The client may add "-r <peer>" to the command line, to set the address
of the remote peer.

The server may add "-l <peer>" to the command line, to select address
of local peer.

By default "127.0.0.1" is used.

Change-Id: Ie6da55ef248436e521c5d8f21f8053356c46a114
2024-02-28 08:47:34 +00:00
Harald Welte 15dcf5e743 examples/stream-*: Support SCTP when called with "-s" argument
Change-Id: I4137cdf1e21cb669b632fe5c126ec27475d98400
2024-02-28 08:46:00 +00: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
Daniel Willmann 8cd2c4455e examples: Set logging level to DEBUG in {,ipa-}stream-{client,server}
Change-Id: I8c37bbe3db9823a399773d6790000ba508e79377
2023-06-16 09:23:28 +00:00
Daniel Willmann c873b62929 examples: Use new stream API in {ipa-,}stream-{client,server}
Change-Id: I97a9979199c816686b32080534627f6f033e009e
2023-06-14 18:17:13 +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
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 f8767012c8 Stream examples: log sent/received bytes
Make client and server examples more verbose by logging actual bytes
sent/received.

Change-Id: I6979b2f92c96c2366f18bf31e4bc495a6709133a
2019-01-29 18:20:34 +01:00
Max 5c7bf3b23d Stream examples: filter internal logging
Set category filter to make sure internal library logging won't
interfere with example's own logging. It's also nice example
illustrating log_set_category_filter() usage.

Change-Id: I17d7878d302f011d8ff0d86708d677f5b559299e
2019-01-29 18:20:22 +01:00
Pau Espin 6fb0f4de86 examples: use osmo_init_logging2
Change-Id: I7f1f4503f254931edeebfbadf3953efa7b20f85f
2018-04-17 13:55:09 +02:00
Harald Welte e63f88146d stream-client: check read() return value before using it as length input to memcpy
Change-Id: Id962821c71b3a1c4c01c1131eb809b8ec8eaa062
Fixes: Coverity CID 57859
2016-12-01 15:52:53 +01:00
Harald Welte a47c8a3f3f stream-client: Check for osmo_fd_register() return value
Change-Id: I1b5fa97d14e69ff502b6deba0fd898a01e53420f
Fixes: Coverity CID 57633
2016-12-01 15:52:53 +01:00
Holger Hans Peter Freyther 92efd03e87 Do not use strlen on binary inpit
Coverity points out that buf might not be NULL terminated. For the
memcpy ret was already used, so use ret for msgb_put as well.

Fixes: CID#57922
2016-01-23 10:37:28 +01: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 98ec00d8d2 stream: add osmo_stream_*_conn_recv
Like c43bb08906 but for stream
sockets.
2011-10-17 12:51:18 +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 602df1ec4c examples: add stream server/client example
This patch adds a couple of examples that allow chatting between
the client and the server. For simplicity, the example only support
one client.
2011-10-05 13:43:21 +02:00