Commit Graph

65 Commits

Author SHA1 Message Date
Pau Espin 3b0991e80f osmux: Allocate struct osmux_out_handle through API
Until now, the osmux_out_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, openbsc) can still work fine, since there's no change on the
struct osmux_out_handle. However, they will somehow break next time the
struct is changed until they are ported to the same API (easy to do).

Related: OS#5987
Change-Id: Ie8df581f375c9a183a7af60b431561bda82f6e34
2022-09-02 11:29:05 +02:00
Pau Espin bc45a8f599 examples/osmux-test-output: Avoid using deprecated Osmux API
Change-Id: I408bfc84b9c1740df946fa29191f0e286f5b46e1
2022-08-31 16:19:25 +02:00
Harald Welte fa74cc5c68 Don't depend on libosmo-abis (by default)
The only reason we have a libosmo-netif -> libosmo-abis
dependency is the lapd examples whihc are built but not even installed.

Let's build those only if --enable-lapd-examples is specified at the
command line, and remove the dependency to libosmo-abis in all other
cases.

Change-Id: Ida8157cd9111b196e4bf08782c45d0e3d393f1c9
Closes: OS#4726
2021-02-11 15:40:54 +01:00
Harald Welte eb96eb7d68 Use osmo_fd_setup() wherever applicable
Change-Id: Ifb90e00036cc51ef02f3cf4dda1ff7dcd1f8a5b5
2020-10-18 23:12:20 +02:00
Daniel Willmann 384b8f15cb examples: Use osmo_stream_*_set_nodelay in ipa examples
We have functions to help with/abstract the nodelay settings so use
those.

Change-Id: Icb143c6e5fc3063f942a744deb576865674a4c62
2020-10-14 18:05:40 +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 6a7ebcc1e3 Stream examples: fix typos in error message
Likely a copy-paste error from corresponding client example code.

Change-Id: I47cc8c7340eb188d85a49d4f41c295bed0e1bee4
2019-02-06 08:09:27 +00: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 dee873489f Stream examples: print accepted client address
Display socket information for accepted client.

Change-Id: I5aa6757be79754cf7ffa4a276dae1cfb80fe904e
2019-02-05 15:09:28 +00:00
Max 4ce53ff107 Stream examples: fix server's endless loop
Stream server example had an error which resulted in infinite loop on
client disconnect. Fix this by properly handling client closing
connection to allow it to reconnect multiple times.

Change-Id: Icfc2cf7f971b9e3a4abc34cc18d8a44c811c5617
2019-01-29 18:20:34 +01: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
Harald Welte da5f41cdad Migrate from osmo_ipa_idtag_parse() to ipa_ccm_id_resp_parse()
In libosmocore Change-ID I1834d90fbcdbfcb05f5b8cfe39bfe9543737ef8f
we have introduced ipa_ccm_id_resp_parse() as a bugfixed replacement
of ipa_ccm_idtag_parse().

The main difference is that the returned "value" parts now have
a correct reported "length", whereas before this commit they all
reported a one-byte too-long "length" for each IE.

Let's use this opportunity to remove the copy+pasted
osmo_ipa_idtag_parse() function from the libosmo-netif codebase.

Change-Id: I4626d247626543e032593bf226b6c233f6678562
2018-08-01 17:36:21 +02:00
Harald Welte e2fbd3dee4 remove "channel" layer
The "channel" layer on top of IPA client + server was introduced in
2011 but never used in any osmocom program/project so far.  Contrary
to the several other IPA multiplex related implementations in libosmo*,
it did not deal properly with segmented IPA messages, i.e. where a
single TCP segment (and hence recv/read call) does not contain a full
IPA message.

So rather than fixing it up and having yet another IPA related API in
our libraries, let's remove it.

Change-Id: I97c378750acb1637ee032fa88a968edf68d8979f
2018-06-29 10:57:24 +02:00
Pau Espin df0ad6c1a4 osmux: Move examples and tests to use new output APIs
Change-Id: Ie69c427308eb7d81aedab7fbb71f1bdaf43f0275
2018-04-19 18:24:25 +02:00
Pau Espin 6fb0f4de86 examples: use osmo_init_logging2
Change-Id: I7f1f4503f254931edeebfbadf3953efa7b20f85f
2018-04-17 13:55:09 +02:00
Max 8440357d4c examples: add simple UDP client/server
In addition to showing basic UDP send/receive example, it helps to test
corner-case when dealing with 0-length UDP packets.

Change-Id: I08c0adf1cf9b6a6f1f7090b237d0497c2ec13cdf
Related: OS#2219
2017-10-13 18:13:14 +02:00
Neels Hofmeyr eda74fafb4 examples/stream-server.c: use read() rc instead of strlen()
Fixes: CID#57922
Change-Id: Ibaafdd49d9446a12fe7d0e2f5b2039da3ffc7ea9
2016-12-01 15:55:49 +00:00
Harald Welte 1f760e8dcc ipa-stream-{client,server}: Add missing #include <sys/socket.h>
This lead to compiler warnings on FreeBSD, as setsockopt() is undefined.

Change-Id: Ie0ee3e48adfd0cd252703ec020cef28cf76ca223
2016-12-01 16:07:23 +01: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
Harald Welte 046b12fa88 rs232-write: Check return value of osmo_fd_register()
Change-Id: If40e85600ca1dfbda5975d7aa92cccdb11f9c34d
Fixes: Coverity CID 57632
2016-12-01 15:52:53 +01:00
Harald Welte 7f0e9f1171 examples/lapd-over-datagram-network: Fix compiler warning
lapd-over-datagram-network.c:38:12: warning: ‘sapi’ defined but not used [-Wunused-variable]
 static int sapi = 63, tei = 0;
            ^~~~

Change-Id: If367deb0e0d7d5e031db2bd905179263d18703f0
2016-11-11 15:33:35 +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
Alexander Huemer d4be141ab0 teip is a pointer, not an int 2015-11-07 12:35:53 +01:00
Holger Hans Peter Freyther 86115434f1 endian: Use the new endian macros for portability
Use the new macros to deal with little/big endian. Im a bit
worried to make this change due the little test coverage in
this module but in case of a typo the elements would not be
defined.
2015-03-22 09:38:36 +01:00
Nikola Kolev 2f1ddb2709 Fix the compilation on FreeBSD. 2015-02-25 15:52:14 +01:00
Jan Engelhardt 226e994832 build: remove all_includes
This variable is never set and could therefore be removed.
2014-10-02 23:22:55 +02:00
Martin Hauke 603f6c40d5 build: rename INCLUDES to AM_CPPFLAGS in Makefile.am to avoid warnings 2014-09-11 18:22:02 +02:00
Pablo Neira Ayuso 282aee422f osmux: allow to set initial RTP SSRC
Instead of using the osmuxh->circuit_id.
2013-05-12 19:56:21 +02:00
Pablo Neira Ayuso d32caea9ea osmux: add osmux_snprintf
Useful for debugging purposes. Modify also examples to use it.
2013-02-19 17:14:33 +01:00
Pablo Neira Ayuso aeeb4399a2 examples: use DOSMUX_TEST instead of DLINP in logging messages 2013-02-19 17:13:37 +01:00
Pablo Neira Ayuso 1f43121ef0 osmux: osmux-test-input: fix compilation warning
CC     osmux-test-input.o
osmux-test-input.c:85:2: warning: initialization from incompatible pointer type [enabled by default]
osmux-test-input.c:85:2: warning: (near initialization for ‘h_input.deliver’) [enabled by default]
2013-02-19 16:21:09 +01:00
Pablo Neira Ayuso 5e9c67ea20 fix osmux-test-input
ccid array was not initialized appropriately
2013-02-12 19:53:02 +01:00
Pablo Neira Ayuso 5654c43f80 osmux: remove generic functions to register and get ccid
Remove these functions:

- osmux_xfrm_input_get_ccid
- osmux_xfrm_input_register_ccid

The ccid will be managed by the BSC and it will be stored in the
mgcp_endpoint structure.

Also adjust all tests and examples using the API.
2012-10-20 20:17:28 +02:00
Pablo Neira Ayuso 4925acf297 examples: add osmux-test-input and osmux-test-output
You can use these utilities to test osmux:

1) in one console, run ./osmux-test-input
   This listens in port UDP 20000 and convert RTP traffic to osmux
   Then, it sends osmux traffic via port UDP 20001
2) in another console, run ./osmux-test-output
   This listens in port UDP 20001 and convert osmux to RTP traffic
   Then, it sends RTP traffic to UDP port 20002
3) in another console run, nc -u nc -u -l -p 20002
   This is the sink, just to avoid ICMP destination unreachable messages

Now you can run replay UDP traffic from one pcap trace that contains
RTP traffic with this tool:

http://1984.lsi.us.es/git/pcap-inject/

Example of command line invocation:

./traffic-inject /home/pablo/rtp-nanobts-2-phones-amr.pcap udp 20000

You can run wireshark in the loopback to make sure osmux is getting back
the traces looking like the original.

The tests also generate output files in AMR that you can validate via
mplayer: /tmp/output.amr and /tmp/input.amr respectively. This is to
make sure there are no reordering or problems of any sort.
2012-10-15 23:07:12 +02:00
Pablo Neira Ayuso 9ae91e594c ipa: add osmo_ipa_process_msg and remove osmo_ipa_recv_msg
This patch removes osmo_ipa_recv_msg, it performs two syscall invocations
and it's stream generic. Now we use the specific receival function
we want to use (no matter if stream or datagram based) and then we
call osmo_ipa_process_msg to check that the IPA message correct.
2012-08-19 20:14:25 +02:00
Pablo Neira Ayuso 7a3e8d01f5 consolidate ipa_unit infrastructure
Provide unified infrastructure for handling IPA units and modify
existing code to use it.
2012-08-19 20:14:17 +02:00
Pablo Neira Ayuso 060e46ea6d channel: add abis directory under channel
And move all existing A-bis channel implementation to channel/abis/
directory.

This is just a cleanup to reorganize the source code tree.
2012-08-19 01:06:57 +02:00
Pablo Neira Ayuso 775c1de089 channel: add subtype ID to osmo_chan_create
This adds the possibility to specify the variant of the channel.

This was discussed during the osmocom workshop. Harald wanted a way
to say if the channel is using TCP, UDP, DADHDI and so on.
2012-08-19 00:52:00 +02:00
Pablo Neira Ayuso b71627b1f7 channel: osmo_chan_init takes one pointer to set the talloc context
Also remove this parameter from osmo_chan_create
2012-08-19 00:50:01 +02:00
Pablo Neira Ayuso d73c757e6d channel: rename CHAN_* to OSMO_CHAN_* for correct namespace policy
Just to avoid unlikely possible problems while using this library
with any other that decided to define the CHAN_* constants.
2012-08-19 00:49:58 +02:00
Pablo Neira Ayuso c05485c90c channel: use linked list instead of array of existing channels
This also adds osmo_chan_init() that needs to initialize the
channel infrastructure.
2012-08-19 00:49:20 +02:00
Pablo Neira Ayuso 0f46263777 add ABIS IPA example as client (BTS) 2012-08-16 00:31:00 +02:00
Pablo Neira Ayuso c12d9d97e4 channel: abis-ipa: shorter function names
%s/_server_/_srv_/g
%s/osmo_chan_abis/osmo_abis/g
%s/SERVER/SRV/g
2012-08-15 23:34:38 +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 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 e142ddfd77 rtp: split osmo_rtp_parse in two functions
This patch splits osmo_rtp_parse in two functions:

osmo_rtp_get_hdr
osmo_rtp_get_payload

So we can validate corrent RTP header to access its fields. Then,
obtain the payload.
2012-07-07 17:40:17 +02:00
Pablo Neira Ayuso f52b3c8b11 rtp: remove unused rtp_handle parameter from osmo_rtp_parse
And also adjust example files to use the new function.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2012-07-03 20:03:01 +02:00