Commit Graph

331 Commits

Author SHA1 Message Date
Harald Welte 635984c5e1 link libosmo-netif against libosmogsm
The recently-introduced dependency to libosmogsm symbols needed
some explicit addition of linker flags to avoid user applications
to fail linking with
/usr/bin/ld: /usr/local/lib/libosmonetif.so: undefined reference to `ipa_ccm_id_resp_parse'

Change-Id: I07a28f8970b90f82736e2de783bafc9d2c5ea0e5
2018-08-01 18:02:04 +02: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
Neels Hofmeyr d5a35ed932 fix strncpy bug in rs232.c
Change-Id: I2f3b7888acb4f25da22ffef4391e1d0831485483
2018-07-27 18:51:59 +02:00
Pau Espin 322dbbeaa2 Bump version: 0.2.0.6-ac33-dirty → 0.3.0
Change-Id: Ic9bbe8427c44ef2a9ee02537f17821048f177cdd
2018-07-27 18:31:43 +02:00
Harald Welte ac33f6fbd2 stream.c: Use non-blocking connect in osmo_stream_cli
When establishing a client-side stream connection via libosmo-netif,
we must using non-blocking connect if we want to avoid blocking/stalling
the entire process.  The libosmocore socket API provides the
OSMO_SOCK_F_NONBLOCK flag for this.  Make use of it!

Change-Id: I9bfcb39b5801a36ef32ca0d1f3eb8236687d7ed6
Related: OS#3383
2018-07-05 14:07:25 +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 7839556ca9 osmux: change log lvl of batch full to debug
This message is expected as all code filling batches call
osmux_batch_enqueue() and checks for error to know if it must tell the
user of the lib to call osmux_xfrm_input_deliver.

Change-Id: I3d8227f2281f6ca92fd2502d3e328765dc7ecfe9
2018-05-15 17:09:19 +02:00
Pau Espin 7b7562a713 jibuf: Fix out-of-order seq queue around syncpoints
Fixes: OS#3262

Change-Id: Ib8c61dbe6261cf73d6efcd7873e23b7656117556
2018-05-15 16:49:50 +02:00
Pau Espin e38ee9b808 Bump version: 0.1.1.38-ef190-dirty → 0.2.0
Change-Id: Ic8a9e44b2f930fed024040777eab58699fdcaadc
2018-05-03 16:55:21 +02:00
Harald Welte ef19001517 osmux: Fix use of uninitialized memory in osmux_out_handle
In Change-Id: I2efed6d726a1b8e77e686c7a5fe1940d3f4901a7 we're adding a
new member to 'struct osmux_out_handle' which is not initialized.

Rather than initializing this single new member, let's do a memset()
over the entire osmux_out_handle at the beginnign of
osmux_xfrm_output_init().

Change-Id: I751e9414c6de2413a9f977e5ae5655ebfd114f45
Closes: OS#3219
2018-04-28 13:36:40 +02:00
Pau Espin e259c8ab18 osmux: Set Marker bit on osmux frame loss detected
Until this patch, we didn't notify in any way to the RTP reader when an
Osmux frame was lost. Instead, we updated the seq&timestamp as if there
was no lost, and as a result the RTP reader would only see a steady
increase of delay every time an osmux frame was lost.

As the batch_factor for the lost packet is unknown, we cannot assume any
number of amr payloads lost, and thus we cannot simply increment seq and
timestamp for a specific amount. Instead, the only viable solution seems
to set the M marker bit in the first rtp packet generated after a
non-consecutive osmux frame is received.

The implementation may act differently with the first generated RTP
packet based on the first osmux seq number used for the stream. In case
0 it's used as first osmux seq number, M will be set depending on
request from original RTP packet having the M bit set. If it's not 0,
the first RTP packer will unconditionally have the M bit. That's not an
issue because it's anyway expect for receiver to sync on the first
packet.

Related: OS#3185

Change-Id: I2efed6d726a1b8e77e686c7a5fe1940d3f4901a7
2018-04-19 18:24:25 +02:00
Pau Espin dbf8e53192 osmux: Add new API osmux_xfrm_output_sched to fix rtp generation issues
With old implementation, in conditions with jitter we could end up
scheduling RTP generated packets from two consecutive osmux frames in an
interleaved way (from seq field point of view).

This new implementation should make it easier for any RTP
reader/playback to have better results in those conditions.

Old APIs osmux_xfm_output and osmux_tx_sched are marked as deprecated in
favour of the new one, which has a better control of generated RTP
packets. However, they are still usable despite the implementation changes
done to support the new API.

Related: OS#3180

Change-Id: I4e05ff141eb4041128ae77812bbcfe84ed4c02de
2018-04-19 18:24:25 +02:00
Pau Espin e9e6200d84 jibuf: Estimate src clock skew
Change-Id: Ifae633d53107417a8e2f9b0f200d2711db72d199
2018-04-13 16:13:17 +02:00
Pau Espin 13c01178c5 jibuf: re-sync clock out of sync timestamps
Change-Id: I33556b33d7549654442d9bdd7f31128792506652
2018-04-13 16:13:17 +02:00
Pau Espin 1ad87f26a1 jibuf: Take RTP marker into account
Change-Id: Ie142acfb45650e0af775f58226fd191beaf8178e
2018-04-13 16:13:08 +02:00
Pau Espin ce820763c1 jibuf: Add initial implementation of Jitter Buffer
Change-Id: I9688ba9c4d5b733b9f29d0f15f73750f9271ef55
2018-04-13 15:51:43 +02:00
Pau Espin 23148b069f osmux: osmux_xfrm_output_pull: Improve checks and log of malformed packets
Change-Id: I143805bb5ee9f5e3ada46114e380a03ede80df9f
Related: SYS#4182
2018-04-12 19:33:53 +00:00
Pau Espin c71c9516dd stream.c: osmo_stream_cli_open2: Remove wrong assumption in reconnect decision
Documentation of osmo_sock_init2 doesn't provide information of any
specific value of errno set/expected after running the function. It is
incorrect to expect a specific value of errno and looking at the
implementation it is actually not a good idea to check it.

If reconnect flag is set, let's reconnect always instead of looking at
errno to decide.

Change-Id: I25b33f4cdc496ae31ff240d445b9b2805091845c
2018-04-05 18:07:41 +02:00
Pau Espin ce439fc945 osmux: Use correct log category DLMUX
Change-Id: I77f4593941207689f714d15304dcce40b21d4bd8
2018-03-07 13:13:28 +01:00
Stefan Sperling f27fdf89dc add support for flushing and destroying a server-side stream
Introduce osmo_stream_srv_set_flush_and_destroy() which marks a
stream to be 'flushed and destroyed'. No new messages will be
received on this stream, and no new messages can be queued.
Once the Tx queue has been drained, the connection is destroyed.

The API user is given a chance to perform cleanup operations
in the closed_cb() callback for the connection.

The same mechanism will be added for client-side connections
in a follow-up patch.

Change-Id: I8ed78fe39c463e9018756700d13ee5ebe003b57f
Related: OS#2789
Suggested-by: Harald Welte
2018-02-22 19:48:36 +01:00
Neels Hofmeyr c72be77aa3 osmo_stream_{cli,srv}_destroy: fix mem leak: empty msgb queue
On destroying a client or server stream, deallocate any msgbs that are still
pending in the queue.

In libosmo-sccp, the ss7_test.c in test_as(), messages are queued and were,
before this, left floating after the stream was destroyed, causing a sanitizer
memory leak. This patch fixes the leak.

Depends: Ia291832ca445d4071f0ed9a01730d945ff691cf7 (libosmocore)
Change-Id: Iaad35f03e3bdfabf3ba82b16e563c0a5d1f03639
2017-11-20 16:23:59 +00:00
Pau Espin 6d4acefb69 stream: Avoid re-creating and leaking socket when unneeded
In previous implementation, if no reconfiguring is needed, a new socket
would be created without closing the old one, leaking the previous
socket. Instead, if we don't need reconfiguring, we return 0 as no
operation is required.

Change-Id: I6c1a7fff63e44840fb5e2bc7ace5e9a61e304987
2017-11-17 15:17:07 +01:00
Harald Welte bea215a565 Add SPDX-License-Identifier + Copyright statements
Change-Id: I43bb1c4a889421907a1a08eb29c96f2330ab00ec
2017-11-13 01:21:03 +09:00
Harald Welte fb31c0953c src/rs232.c: Fix accidential reference to GPLv3+ instead of GPLv2+
Change-Id: I5fa2696c5090994c417ca882c5225cbd7c1be2c7
2017-11-13 01:11:46 +09:00
Harald Welte bdfe9682fe Don't link library against libosmogsm, we don't use any symbols of it
This fixes a related dpkg-shlibdeps warning

Change-Id: I0325e7a6dea5195f1634230930570bf4dfe3810c
2017-10-28 10:18:44 +00:00
Harald Welte c2c8b5c557 Tag/Release Version 0.1.0
Short changelog:
* Add Doxygen documentation
* SCTP support in stream.c
* new udp-test-client and udp-test-server programs
* better / more verbose error handling in examples
* new osmo_dgram_tx_set_local_{addr,port}() functions
* use IPA definitions from libosmogsm, rather than repeating them
* encode RTP header M field of RFC3550/4867 in OSMUX header
* new osmo_stream_srv_link_set_nodelay()
* new osmo_stream_srv_link_set_proto()
* new osmo_stream_cli_set_nodelay()
* new osmo_stream_cli_set_proto()
* new osmo_stream_cli_set_local_addr()
* new osmo_stream_cli_set_local_port()
* new osmo_stream_cli_reconnect()
* new osmo_stream_cli_open2() with reconnect argument
* more vrebose osmux_snprintf()
* remove mistaken reference to AGPL in rs232.c
* fix memory leak in osmo_stream_srv_link_set_addr()
* add osmo-pcap-test for SLL and Ethernet
* extend osmux-test

Change-Id: Ibf75fcd6643351ce3946faa155ae1db8c33a5e35
2017-10-27 20:21:20 +02: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
Pau Espin d8f2b38eb9 osmux_snprintf: Add doxygen doc
Change-Id: Idb3fcf25be9558bfc2f822352c07ebc2cb7d5caa
2017-10-24 12:37:44 +02:00
Pau Espin 77d08a67b5 osmux_snprintf: Support different types of Osmux frames
Previous implementation handled all types as if they were Osmux AMR
frames. For Dummy frames, we account the padding but we don't care about
the padding content. For Signalling ones, as they are not in the
specification yet, it is better avoid using unespecified fields and
return an error because it's still not known how extra data will be
handled in the input msgb.

Change-Id: I48565472b47c2a0e5db50881fbb005537af8c70d
2017-10-24 12:36:00 +02:00
Pau Espin 05bb1c2b2e osmux_snprintf: Split logic parsing osmux header and AMR payload
The current code still expects to parse only AMR osmux frames, but that
will be fixed in following patches.

Change-Id: Ic2f4d1d3cc88af912bb43c8ecd90eacc6ff7190f
2017-10-23 17:16:01 +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
Harald Welte c98bf1b880 rs232.c: Don't #include <osmocom/abis/e1_input.h>
There's no need for the rs232 code to include a files from
libosmoabis. The only users of libosmoabis left now are the LAPD
examples:
	examples/lapd-over-datagram-network.c
	examples/lapd-over-datagram-user.c

Change-Id: Ie1bc0dd811362cec546486edc41d632740ed19cd
2017-10-05 08:41:52 +08:00
Pablo Neira Ayuso 5994198208 src: _snprintf() helper functions nul-terminate buffers, if possible
This patch inconditionally initializes the buffer we get to
nul-terminate it, whenever possible. It's a very simple solution to
catch three overly corner cases:

1) snprintf() returns -1, very much unlikely in practise.

2) msg->len == 0: In such case, I would expect this function is never
   called with an empty message, but let's be safe in this case too.

3) If your buffer is empty, it doesn't nul-terminate the buffer.

Change-Id: I97e517f2d98e83894ea707c63489559302ff6bd2
2017-09-12 13:28:41 +02:00
Pablo Neira Ayuso 14af167a55 osmux: fix buffer management mess in snprintf() calls
SNPRINTF_BUFFER_SIZE() looks too complex, previous version maintains two
different variables to account for the remaining space in the buffer,
one of them is always decremented based on what snprintf() returns,
which may result in underflow. These variables are swapped - not used
consistently - all over this code.

Replace this macro by a simplified version, with one single parameter to
account for remaining space. This macro also deals with two corner
cases:

1) snprintf() fails, actually never happens in practise, but
   documentation indicates it may return -1, so let's catch this case
   from here to stick to specs.

2) There is not enough space in the buffer, in that case, keep
   increasing offset, so we know how much would have been printed, just
   like snprintf() does.

Thanks to Pau Espin for reporting, and Holger for clues on this.
I have run osmux_test and, at quick glance, it looks good.

Change-Id: I5b5d6ec57a02f57c23b1ae86dbd894bad28ea797
2017-09-11 18:06:37 +00:00
Pablo Neira Ayuso 9c5f01e7b2 rtp: return offset in osmo_rtp_snprintf()
Instead of the result of the last snprintf() call.

Change-Id: I10066d73387be96a4e1f3349d700405beb138076
2017-09-05 14:57:52 +02:00
Pau Espin e786055567 osmux: Slightly improve output format of osmux_snprintf
The buffer for osmux_test is increased as the former doesn't seem to be
able to cope with the whole output.

Change-Id: Ic838dd9d7ad89b4510ccfa58c0390c69a075b616
2017-08-14 17:24:11 +02:00
Pau Espin 7cca0da1cc osmux: Fix buffer overflow in osmux_snprintf
When running osmux_test on my PC, the process was aborted with a "stack
smashing detected" error.

Change-Id: I8a7cc422c181c0c5712ac8976a5be5f0ad44a9c0
2017-08-14 17:24:11 +02:00
Pau Espin 728c2df796 rtp.c: Fix print format
Fixes compilation warning

Change-Id: I0146a19bf852c9e27d265a098dc9d7a337424e10
2017-07-13 21:32:26 +02:00
Pablo Neira Ayuso 57b5f82491 src: use osmo_timer_setup()
Use new function available in libosmocore to set up timers. Compile
tested only.

Change-Id: Id3dd32102c7362f3b280d2c058c2decebccb357a
2017-06-07 18:40:35 +02:00
Harald Welte 31b1dbd894 somo_stream_srv_fd_cb(): close socket if NODELAY fails
We didn't check for cases where setsockopt_nodelay() fails.  Let's check
for that and bail out + close the socket.

Change-Id: I0adbc4cec35be7c36bdf01d4d8fefd6097e9be5d
Fixes: coverity CID#166970
2017-05-14 21:51:26 +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
Pau Espin a18caad5fd osmux: Fix delay between RTP packets
AMR frame contains 160 samples at 8000Hz -> 20 ms long

Change-Id: I36dc69f9caf591dd1b578bc914a2ce426c7f2813
2017-04-28 08:15:52 +00:00
Pau Espin 3460ad7f31 osmux: Use osmo_gettimeofday for testing puroposes
This way we can use fake time and osmux_test take 700ms instead of
>2sec to run.

Change-Id: Ic39cab74400aca8262a00c0d06884230b1a15ca3
2017-04-27 08:50:01 +00:00
Pau Espin e98afe5808 osmux: Add RTP marker bit support
According to RFC4867 (RTP payload format for AMR):
"The RTP header marker bit (M) SHALL be set to 1 if the first frameblock
carried in the packet contains a speech frame which is the first in a
talkspurt.  For all other packets the marker bit SHALL be set to zero (M=0)."

This information bit provides a way for the receiver to better
synchronize the delay with ther sender.

This is specially useful if AMR DTX features are supported and
enabled on the sender.

Change-Id: I0315658159429603f1d80a168718b026015060e9
2017-04-27 08:50:01 +00:00
Pau Espin a67c47cab4 osmux: Check batch_factor overflow in osmux_batch_enqueue
This commit should fix a bug present if for instance batch_factor < 8
and osmux_batch_enqueue is called from osmux_replay_lost_packets and
enough packets were lost from last received packet.

Change-Id: I5d643810949aeca4762f0cad05eed534d35087f7
2017-04-27 08:50:01 +00:00
Pau Espin a15d00ca57 osmux: use uint8_t everywhere for batch_factor
Change-Id: I9fcc8e94b2fcd843b10cb3f8f009f2348eb3a4af
2017-04-27 08:50:01 +00:00
Harald Welte c108c9db96 SCTP: Don't enable sender_dry_event for SCTP, as it breaks Linux SCTP
Enabling sender_dry_event in SCTP_FLAGS breaks reliable delivery of DATA
chunks to the scoket user on Linux.  Let's avoid enabling that, while
still enabling various other interesting events.

See https://bugzilla.redhat.com/show_bug.cgi?id=1442784 for all related
details.

Change-Id: Ib616cd07a6044ca2ee7e05093b22df3369c62b56
2017-04-17 16:05:22 +02:00
Harald Welte c200a95615 stream.c: Fix SCTP_NODELAY setting
We were using the wrong variable when setting the SCTP_NODELAY,
resulting in the setsoctkopt() fialing.

Change-Id: Ic04cb8bb5ff41f177f7f5b7f7e2a2ecc686dd4c0
2017-04-16 23:34:28 +02:00
Neels Hofmeyr 719d1a38c6 osmo_stream_srv_fd_cb(): don't leak socket FDs on errors
So far we seem to assume that the accept_cb does all handling of socket
fd cleanup. However, there are cases where there is no accept_cb set,
the accept_cb returns error, or an earlier sctp_sock_activate_events()
or the activation of non-blocking mode fails.

For those cases, close the socket and return an error code.

Fixes: CID#57915
Change-Id: I3a3ce9194ab7ca5c1921fc79c2a1c9e10a552cf0
2017-04-14 11:06:09 +02:00
Harald Welte 5ae42bca91 SCTP: Fix PPID byte width
In a659590e29 we fixed endianness issues
with the Stream ID field, but at the same time mistook the PPID field
for 16bits.  In reality it is 32bits, and hence our 'htons' is rendering
wrong PPID values.

Change-Id: I1b60523044835ee630dba9a43d26af4f1ebd1ced
2017-04-12 12:08:45 +02:00
Harald Welte 9ec26583cd Add osmo_stream_{cli,srv_link}_set_nodelay() function
Using this function, the user can configure if sockets related to the
respective stream client or server should have the NODELAY socket
option set in order to avoid Nagle algorithm or related algorithms
that may introduce packet delay on the transmitter side.

Change-Id: Ibeb9ba227bab18f7f4f16518c0022c4f003cc8e9
2017-04-11 19:54:07 +02:00
Harald Welte a659590e29 stream.c: Fix endianness handling of PPID and STREAM_ID
In their infinite wisdom, the inventors of SCTP designed an API (the
sockets API described in RFC6458), where some members are in host byte
order (like the stream identifier), while other members are in network
byte order (like the PPID).

Let's handle this properly (we assumed both are network byte order), and
also use 16-bit htons/ntohs fo the PPID, rather than htonl/ntohl.

Change-Id: I777174ca2915c6de0063db41a745c71b4a09bbec
2017-04-10 17:48:42 +02: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 edad98b4a0 doc: Add Doxygen group for OSMUX related functions
Change-Id: I87e08bd84236ae5d5c057bca96d122e568a6b52a
2017-04-08 20:13:14 +02: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
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
Max 5fd93e02f8 Fix potential NULL dereference
Change-Id: I5baf369dbf3948565614476980a32be59abaf42a
2017-02-07 11:46:41 +01:00
Harald Welte 3bb118270b rs232.c: Fix license to GPLv2-or-later. libosmo-netif is GPLv2-or-later
Change-Id: I7c73d1a0b15cfb2a729687cde6f9a8e62a230fd7
2016-12-22 14:19:32 +00: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 3dd57f737c rs232: Don't pass negative number to strerror()
Change-Id: Ia777221cd0472cd1e7aa79e5146b07048a545dd8
Fixes: Coverity CID 57860
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 2904f82f99 osmux: Add function to delete all msgs pending for a circuit
Use this function in osmux_batch_del_circuit() since msgs are stored in a list
per circuit. After the circuit is free()d the msgs are lost.
Before this patch any messages enqueued inside a batch when the circiut is
deleted were leaking.

Change-Id: Ib0311652183332d0475bf7347023d518d38487ef
Ticket: OS#1733
Reviewed-on: https://gerrit.osmocom.org/120
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-26 12:05:42 +00:00
Daniel Willmann d5235e5e51 osmux: Pass circuit to _batch_del_circuit() and use it from _xfrm_input_fini()
Change-Id: If224980123d4a369133499ab7b577d02511f4055
Ticket: OS#1733
Reviewed-on: https://gerrit.osmocom.org/119
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-25 20:42:41 +00: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
Holger Hans Peter Freyther faf5faeb7a libosmovty: Drop dependency as no VTY code is written here
Do not link to libosmovty as we don't need it.
2015-11-03 09:35:44 +01:00
Pablo Neira Ayuso e479f25a9b osmux: rename batch->dummy field to batch->ndummy
This is basically a counter that tells us how many circuits need the padding,
so better rename this to ndummy.

Suggested by Holger.
2015-08-19 00:21:43 +02:00
Pablo Neira Ayuso 0d90dd1563 build: bump library release number
I have added two new interfaces to add and to delete circuits from osmux input
handles. The client application needs to be adapted to use them otherwise it
will break. That's why I'm making this library release incompatible with the
previous generation.
2015-07-21 17:10:14 +02:00
Pablo Neira Ayuso e1aefad278 osmux: kill osmux_get_hdr()
Never used, so let's get rid of this function. We can recover it later on in
case we need it.
2015-07-21 11:05:41 +02:00
Pablo Neira Ayuso ea549806c9 osmux: introduce osmux_xfrm_input_open_circuit()
This new function allows you to create a circuit on an existing input handle.

We don't create the circuit anymore from the first packet seen, instead the
client application is in full control of opening and closing the circuit.

This change includes a new feature to pad a circuit until we see the first
packet that contains voice data. This is useful to preallocate bandwidth on
satellite links such as Iridium/OpenPort.
2015-07-21 09:59:49 +02:00
Pablo Neira Ayuso b3fc27423a osmux: introduce osmux_xfrm_input_close_circuit()
Add this new function to explicitly remove an existing circuit. Thus, the
client application (openbsc) is in full control to release circuits.

Before this patch, the circuit object was added when the first RTP messages was
seen, and it was removed when transforming the list of pending RTP messages to
the Osmux message (once the timer expired).

Moreover, check circuit->nmsgs to account bytes that are consumed by the osmux
header, given that !circuit doesn't mean "this is the first packet" anymore.
2015-07-21 09:59:49 +02:00
Pablo Neira Ayuso ab898deea3 osmux: count pending messages to be transformed in the batch
Add a new field to count the number of messages in the batch that are pending
to be transformed to osmux. Use this new field to check when to enable the
osmux timer.

The follow up patch keeps circuit objects in the batch until they are closed,
so we won't be able to rely on this to know when to enable the timer anymore.
2015-07-21 09:59:49 +02:00
Pablo Neira Ayuso d886bd0503 osmux: pass up struct osmux_batch
Instead of struct osmux_in_handle. This object contains the internal batching
state information.
2015-07-21 09:59:49 +02:00
Pablo Neira Ayuso f3016f29dd osmux: rename circuit->list to circuit->rtp_list
A circuit object contains a list of pending RTP messages to be converted to the
osmux format.
2015-07-21 09:59:49 +02:00
Pablo Neira Ayuso 22026a4b9b osmux: rename struct batch_list_node to osmux_circuit
I think this is a better name for this object. Basically, an input handle
represents a batch that is composed of one or more circuit objects.

Each circuit object contains a list of RTP messages that are pending to be
converted to the osmux format in one single batch.
2015-07-21 09:59:48 +02:00
Pablo Neira Ayuso 75df57e15f osmux: add circuit helper functions
Add osmux_batch_add_circuit() and osmux_batch_find_circuit() helper functions.
2015-07-21 09:58:48 +02:00
Pablo Neira Ayuso 752a9c68e5 osmux: add osmux_input_state structure
This new structure serves as container of the internal osmux state during
transformation from RTP AMR to the compressed osmux format.

This reduces the footprint of several functions and it makes them easier to
extend if we need to pass new information between functions.
2015-07-17 22:03:31 +02:00
Pablo Neira Ayuso f67d1126ab osmux: discard non voice osmux message
We only support voice osmux messages by now. Discard unsupported types.
2015-07-17 22:03:31 +02:00
Andreas Rottmann c55d867508 build: fix regarding missing CFLAGS constituents
When libosmo-abis is installed in a distinct prefix, the build failed
with non-found headers, for example:

../../src/rs232.c:38:35: fatal error: osmocom/abis/e1_input.h: No such file or directory
 #include <osmocom/abis/e1_input.h>
2015-06-19 21:01:51 +02: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
Nikola Kolev 5da504d9eb Fix typo. 2015-02-25 15:52:05 +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
Jan Engelhardt de816861cb build: put dependency libraries in the right place in Makefiles
Libs must be in _LDADD/_LIBADD and not in _LDFLAGS.
2014-10-02 23:22:43 +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
Holger Hans Peter Freyther dd337a3c87 Prepare new upstream release 2014-09-08 07:52:08 +02:00
Pablo Neira Ayuso 0316aa6060 osmux: export OSMUX_BATCH_DEFAULT_MAX
This allows you to set the default batch size when initializing the
osmux input handle.
2014-08-29 15:30:29 +02:00
Pablo Neira Ayuso 9de1521ca9 osmux: fix more leaks in osmux_xfrm_input() in the error path
Return 0 to the caller, which believes that we have put the message
in the batch. But if it is malformed, silently release it.
2014-08-28 20:19:13 +02:00
Pablo Neira Ayuso c7f110fe73 osmux: stop batch timer in osmux_xfrm_input_fini()
Make sure we don't release a osmux handle with an armed batch timer.

==9753== Invalid read of size 4
==9753==    at 0x4043CA2: rb_first (rbtree.c:293)
==9753==    by 0x403E172: osmo_timers_check (timer.c:256)
==9753==    by 0x403E69E: osmo_select_main (select.c:124)
==9753==    by 0x804EBD3: main (bsc_nat.c:1613)
==9753==  Address 0x4302670 is 56 bytes inside a block of size 108 free'd
==9753==    at 0x4023B6A: free (vg_replace_malloc.c:366)
==9753==    by 0x40494CF: talloc_free (talloc.c:609)
==9753==    by 0x40AB279: osmux_xfrm_input_fini (osmux.c:620)
==9753==    by 0x80651FC: osmux_disable_endpoint (mgcp_osmux.c:96)
==9753==    by 0x805CAFF: mgcp_release_endp (mgcp_protocol.c:1540)
==9753==    by 0x805DD35: handle_delete_con (mgcp_protocol.c:1274)
==9753==    by 0x805E998: mgcp_handle_message (mgcp_protocol.c:415)
==9753==    by 0x804CFF1: mgcp_do_read (bsc_mgcp_utils.c:972)
==9753==    by 0x403F96D: osmo_wqueue_bfd_cb (write_queue.c:48)
==9753==    by 0x403E724: osmo_select_main (select.c:158)
==9753==    by 0x804EBD3: main (bsc_nat.c:1613)
2014-08-28 20:00:06 +02:00
Pablo Neira Ayuso bf42dd6b23 osmux: fix leaks in osmux_xfrm_input() error path
If it is not possible to put the RTP message into the batch in case that:

1) The message is malformed.
2) The message is duplicated.
3) OOM.
4) The batch is already full.

Osmux releases the messages and gets back to the upper layer with an OK
to give another chance to follow up RTP messages.

This patch also fixes a use-after-free that was possible when the batch
was full. The message was released and osmux_batch_add() was returning 0
osmux_xfrm_input(), which resulted in accessing the released message
when updating the statistics.
2014-08-28 19:33:45 +02:00
Pablo Neira Ayuso 217336c2ec osmux: fix osmux_xfrm_output() due to 62d8a18
Fix accidental inclusion of list_add in debugging message area
in ("62d8a18 osmux: hide spamming debug log messages behind ifdef")
that broke osmux.
2014-08-28 18:39:35 +02:00
Pablo Neira Ayuso 355f95b0a3 osmux: more hide spamming debug log 2014-08-28 17:30:12 +02:00
Pablo Neira Ayuso 62d8a18787 osmux: hide spamming debug log messages behind ifdef
This is ugly, with many ifdefs, but they don't want any debug message
that can be spamming. I don't want to remove these because there is
no dissector for osmux, and this can be useful for troubleshooting.
2014-08-28 17:18:11 +02:00
Pablo Neira Ayuso 843c23098a osmux: add statistics to osmux_in_handle struct
Add statistics to the osmux input handle, which translates the RTP
messages to osmux batch.
2014-08-28 16:14:16 +02:00
Pablo Neira Ayuso 7a990e8e53 osmux: disable timing reconstruction debugging
Should be enabled only in case you consider that Osmux should
is lagging when reconstructing RTP messages. I haven't seen
any issue regarding this so far. Let's disable it by default.
2014-08-28 15:17:41 +02:00
Pablo Neira Ayuso d8947e37b0 osmux: allow to specify the osmux frame size
This patch adds a new field to the struct osmux_in_handle that allows
you to specify the osmux frame size. If not specified, the default
size assumes your nic uses a mtu of 1500 bytes.
2014-08-28 15:01:03 +02:00
Pablo Neira Ayuso 0b44016ef6 osmux: fix leak in osmux_replay_lost_packets()
The original RTP header has been already sanity check. Therefore,
we can assume the clone is sane.
2014-08-28 14:30:53 +02:00
Pablo Neira Ayuso 3789791b6b osmux: revisit osmux_batch_enqueue() in case of batch full
1) Force batch delivery in case it is full.

2) Skip padding with more RTP clone in case of message lost if the
   batch is full.
2014-08-28 14:27:54 +02:00
Pablo Neira Ayuso 0143d6ec18 osmux: add osmux_xfrm_input_fini()
To clean up the osmux input handle.
2014-08-28 12:45:04 +02:00
Holger Hans Peter Freyther 85edfd12de debian: Attempt to build a package with just the DSO
Follow the debian rule to package the DSOs separately.
2014-04-28 21:35:04 +02:00
Holger Hans Peter Freyther 0a9213464b debian: Prepare a new debian release and bump SO version 2014-04-28 20:51:19 +02:00
Pablo Neira Ayuso 512db84622 osmux: cleanup debugging message
Remove message that is printed twice and reword the messages to
make it more clear the traffic flow when compressing and
decompressing the RTP AMR traffic.
2014-04-25 15:02:26 +02:00
Pablo Neira Ayuso a040773d57 osmux: (really) validate AMR FT field
(dc898ab osmux: don't trust AMR FT field) was not correctly
validating the AMR FT field as it was comparing the same
value twice calculated in different ways.

Use osmo_amr_bytes(amrh->ft) to obtain the expected length
and check if it is what we got. Use the output of
osmo_rtp_get_payload() as it also includes the RTP payload
stripping possible extensions.
2013-12-16 13:49:42 +01:00
Pablo Neira Ayuso dc898ab983 osmux: don't trust AMR FT field
Sanity check that that we have enough bytes in the AMR payload for
this frame-type.
2013-12-16 13:05:31 +01:00
Pablo Neira Ayuso 0094d98b04 osmux: limit RTP messages per batch
The ctr field of the osmux header is 3 bits long, make sure we
don't run over that boundary. This should not happen in practise
unless we have to deal with network congestion or broken RTP
stacks, but osmux should not crash in that case.
2013-12-16 12:55:28 +01:00
Pablo Neira Ayuso d8a8c0db20 osmux: fix handling of old RTP messages
Make sure that osmux_replay_lost_packets() doesn't try to fill gaps
if we see RTP messages whose sequence number is in the past.
2013-12-16 12:55:28 +01:00
Pablo Neira Ayuso 88eae20dc2 osmux: pass rtp header to osmux_batch_add()
This patch is a cleanup. Pass the pointer to the header, so we don't
need to obtain it from the message buffer again.
2013-12-15 22:35:28 +01:00
Pablo Neira Ayuso 84fffecba5 osmux: fix handling of too big RTP message in osmux_xfrm_input()
With this patch, osmux_xfrm_input() returns 0 (means "message has been
processed") instead of 1 (means "retry") if the RTP message is too big
to fit into one osmux batch. This fixes a likely infinite loop in the
caller, which will retry forever for a message does not fit into the
batch.

Unlikely to happen in normal scenario, as RTP+AMR messages are way
smaller than the interface MTU.
2013-12-15 22:27:18 +01:00
Pablo Neira Ayuso ec4beebc07 amr: use AMR_FT_MAX instead of hardcoded number
Use AMR_FT_MAX instead of 9. This patch is a cleanup.
2013-12-14 22:41:03 +01:00
Pablo Neira Ayuso 55033742a1 osmux: don't print messages with wrong AMR FT
The AMR FT field is used to infer the length of the payload, if
a value higher than 8 (SID) is received, skip it.

This fixes a possible crash in osmux_snprintf() in case we receive
a malformed osmux header.

This is also addresses the crash described in c733ae5b6e.
2013-12-14 22:36:00 +01:00
Pablo Neira Ayuso c733ae5b6e osmux: fix crash in osmux_snprintf when handling multi-batch messages
valgrind reports the following crash backtrace:

!<001c> osmux.c:687 No room for OSMUX payload: only 49 bytes
==12800==
==12800== Process terminating with default action of signal 11 (SIGSEGV)
==12800==  Access not within mapped region at address 0xDFA8E473
==12800==    at 0x4073FD2: osmux_snprintf (osmux.c:628)
==12800==    by 0x80524F1: osmux_deliver (osmux.c:50)
==12800==    by 0x407371C: osmux_xfrm_input_deliver (osmux.c:302)
==12800==    by 0x4073792: osmux_batch_timer_expired (osmux.c:312)
==12800==    by 0x405A4A0: osmo_timers_update (timer.c:243)
==12800==    by 0x405A79A: osmo_select_main (select.c:133)
==12800==    by 0x8049A53: main (mgcp_main.c:307)

The problem is that osmux_snprintf() is not handling multi-batch
messages (ie. messages that contain several osmux batches). More
specifically, the offset to print the osmux batches was reset
when parsing every osmux batch.

The problem also manifested with wrong outputs.

Reported by Mattias Lundstrom.
2013-12-14 22:01:25 +01:00
Pablo Neira Ayuso 87b3eeaed7 osmux: delete message from output list before calling tx_cb
Valgrind complains about a possible use after free:

==12800== Invalid read of size 4
==12800==    at 0x4073DF6: osmux_tx_sched (linuxlist.h:119)
==12800==    by 0x8052B0F: osmux_read_from_bsc_nat_cb (osmux.c:261)
==12800==    by 0x453F967: ???
==12800==  Address 0x453f710 is 48 bytes inside a block of size 145
+free'd
==12800==    at 0x402750C: free (vg_replace_malloc.c:427)
==12800==    by 0x4064ADE: talloc_free (talloc.c:609)
==12800==    by 0x405AAAA: msgb_free (msgb.c:72)
==12800==    by 0x8052492: scheduled_tx_bts_cb (osmux.c:196)
==12800==    by 0x4072CF8: osmux_tx_cb (osmux.c:554)
==12800==    by 0x4073F03: osmux_tx_sched (osmux.c:582)
==12800==    by 0x8052B0F: osmux_read_from_bsc_nat_cb (osmux.c:261)
==12800==    by 0x453F967: ???

The problem is that osmux_tx_sched may immediately call osmux_tx_cb for
the first extracted RTP message from the osmux batch, which releases the
message after that.

Remove the message from our list of messages to be transmitted before
the message is passed to the tx callback.

Reported by Mattias Lundstrom.
2013-12-13 15:23:04 +01:00
Pablo Neira Ayuso ceda50fa70 osmux: add artificial limit for cloned RTP packets
Avoid spamming lots of cloned RTP packets in case of severe
gaps.
2013-09-12 13:19:32 +02:00
Pablo Neira Ayuso 7b37afba33 osmux: sanity check too big RTP/RTCP messages as input
Holger spotted that the caller may loop forever in case it receives
big RTP/RCTP packets, that are likely to be spoofed.
2013-08-27 17:15:27 +02:00
Pablo Neira Ayuso ce4bc15a9c ipa_unit: use talloc_strdup
Reported by Holger.
2013-08-25 14:24:46 +02:00
Pablo Neira Ayuso 8c1f31a3dc osmux: disable timing debugging
Disable timing debugging by default.
2013-05-27 01:30:36 +02:00
Pablo Neira Ayuso 390872055d osmux: nul-terminate all strings generated by _snprintf
Make sure all strings are null-terminated.

Spotted by Holger Hans Peter Freyther.
2013-05-24 12:51:02 +02:00
Pablo Neira Ayuso 70214a15d1 osmux: further sanity checkings for AMR FT
According to RFC3267, AMR FT upper 9 should be discarded. This patch
adds extra validation to make sure that input RTP traffic encapsulating
AMR payload and OSMUX amr_ft field are OK with regards to that
restriction.
2013-05-24 12:16:49 +02:00
Pablo Neira Ayuso b1f92341c3 amr: add AMR FT SID definition
According to RFC3267, AMR FT 8 is reserved to SID and its size is
8 bytes.
2013-05-24 11:18:40 +02:00
Pablo Neira Ayuso 1ee6d39921 osmux: add sanity checking in osmux_xfrm_output_pull
Osmux infers the size of the AMR payload from the FT type.
Make sure we get enough data from the network according to
what we expect.
2013-05-24 10:47:59 +02:00
Pablo Neira Ayuso dd34adea7a osmux: remove trailing line break from osmux_snprintf 2013-05-23 20:59:13 +02:00
Pablo Neira Ayuso 92b9a4c6a2 rtp: fix wrong time arithmetics in osmo_rtp_build
rtp.c:154:26: warning: The left operand to '/' is always 0
        frame_diff = (usec_diff / 20000);
                      ~~~~~~~~~ ^
rtp.c:157:43: warning: The left operand to '-' is always 0
                long int frame_diff_excess = frame_diff - 1;
                                             ~~~~~~~~~~ ^
rtp.c:153:39: warning: The right operand to '+' is always 0
        usec_diff = tv_diff.tv_sec * 1000000 + tv_diff.tv_usec;
                                             ^ ~~~~~~~~~~~~~~~
rtp.c:153:29: warning: The left operand to '*' is always 0
        usec_diff = tv_diff.tv_sec * 1000000 + tv_diff.tv_usec;
                    ~~~~~~~~~~~~~~ ^
4 warnings generated.

Reported by Holger Hans Peter Freyther.
2013-05-22 12:21:29 +02:00
Pablo Neira Ayuso 3cf3a732ea osmux: fix warning spotted by clang --analyze
osmux.c:622:20: warning: Value stored to 'osmuxh' during its
      initialization is never read
        struct osmux_hdr *osmuxh = (struct osmux_hdr *)msg->data;
                          ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reported by Holger Hans Peter Freyther.
2013-05-22 02:06:33 +02:00
Pablo Neira Ayuso 56c4681d83 osmux: replay last RTP packet seen under packet loss scenario
If osmux notices a gap between two RTP packets, fill it with
the last RTP packet seen. Without this patch, 10% of packet loss
is enough to get garbage, with it we get glitches in the conversation
with 30%, and pretty much broken conversation with 40% of it.
2013-05-21 00:48:13 +02:00
Pablo Neira Ayuso a9ab95c2c4 osmux: use ccid to identify batches instead of the RTP SSRC
This should reduce the amount of batch nodes that are created
by the maximum number of allowed circuit IDs.
2013-05-20 22:37:31 +02:00
Pablo Neira Ayuso a2c7f909ef osmux: add sanity checking to osmux_snprintf
Add sanity checking to avoid crashes on malformed OSMUX packets
2013-05-12 20:44:00 +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 e0ae0d25c0 osmux: RTP payload type for voice is dynamic
Don't make any assumption on the payload type.
2013-02-19 16:14:32 +01:00
Pablo Neira Ayuso 5cbdd8797a osmux: add talloc context
Good for debugging leaks.
2013-02-19 13:18:48 +01:00
Pablo Neira Ayuso 01537a3678 osmux: initialize batch appropriately in osmux_xfrm_input_init
Use talloc_size not talloc. Should fix:

0xb779401a in rb_erase (node=0x200200, root=0xb779c908) at rbtree.c:230
0xb779401a in rb_erase (node=0x200200, root=0xb779c908) at rbtree.c:230
0xb778ee48 in osmo_timer_del (timer=0x94aacd0) at timer.c:110
0xb778ef65 in osmo_timer_add (timer=0x94aacd0) at timer.c:72
0xb778f03c in osmo_timer_schedule (timer=0x94aacd0, seconds=0, microseconds=64000)
0xb77360ff in osmux_xfrm_input (h=0x94a4280, msg=0x94b8a50, ccid=18) at osmux.c:390

Due to uninitialization batch structures.
2013-02-19 13:17:02 +01:00
Pablo Neira Ayuso 92601d0a20 osmux: use ft instead of the cmr
The cmr is the requested codec for the other peer, the ft actually
contains the current codec mode. cmr may contain 15 which means
"don't care".
2013-02-12 19:29:42 +01:00
Pablo Neira Ayuso c92810eccd osmux: remove arrays from osmux_out_handle
there will be one osmux_out_handle per endpoint.
2013-02-12 17:24:13 +01:00
Pablo Neira Ayuso 7ff7a5cd6d osmux: allow to pass data to osmux_deliver 2013-02-11 22:49:27 +01:00
Pablo Neira Ayuso 0f1f41411f osmux: fix missing data set in osmux_tx_sched 2012-10-21 04:12:29 +02:00
Pablo Neira Ayuso 4aa540ae27 dgram: add osmo_dgram_get_data 2012-10-21 03:08:37 +02: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