Commit Graph

48 Commits

Author SHA1 Message Date
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
Pablo Neira Ayuso 729a0917ac add rs232 support
This include an example to open /dev/ttyACM0 to receive data from
u-blox GPS and one to configure it in TIMEPULSE2 mode.
2012-04-04 19:08:27 +02:00
Pablo Neira Ayuso 4cd6689587 examples: Display more details on RTP payload in rtp-udp-test-*
Minor change, more verbose output to make sure the functions in
the library are doing OK.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2012-02-23 19:50:54 +01:00
Pablo Neira Ayuso 72cd95b352 add RTP support
This patch adds the initial RTP support for libosmo-netif, it's based
on Harald's RTP support available in openBSC.

I have also added a couple of example to show how our new channel
infrastructure interacts with the RTP layer.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2012-02-23 13:44:26 +01: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 e1a7ede826 examples: disable Nagle in ipa-stream-*.c
To emulate how openBSC behaves.
2011-10-17 23:02:39 +02:00
Pablo Neira Ayuso 20c660caec ipa: initial addition of helper functions and examples
This patch adds IPA helper function that can be use on top of stream
sockets.

The current API is just a copy and paste from libosmo-abis, it will
change in follow up patches to improve it.
2011-10-17 22:12:42 +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 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 6c3c279489 examples: update LAPD over datagram tests
Now they can be used to generate a number of messages from the
user and to measure the RTT of LAPD over datagram messages.

Still, they need to be expanded to take the origin and remote
IPs as argument from the command line, later.
2011-10-14 21:03:52 +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 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 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
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
Pablo Neira Ayuso 8bf16493f6 initial commit 2011-10-04 02:36:46 +02:00