Commit Graph

510 Commits

Author SHA1 Message Date
Pau Espin 8c7d62f6d2 stream_test: Log fake time
It allows easy verification that timing is correct and makes it easier
to debug time related race conditions.

Change-Id: I86eb1d7a8096011fd273f067255eb8d6484be65c
2019-09-19 15:42:24 +02:00
Pau Espin b6f9125141 stream_test: Use fake time
By using fake own-controlled time we get two benefits:
* Test doesn't take 9 seconds to run anymore
* More fine-grade control of different events happening (and associated
race conditions).

Change-Id: I16b2884b289bfe40dfb8d743dce01bb4c208d117
2019-09-19 15:16:02 +02:00
Pau Espin a1e9de1ec4 stream: Fix scheduling of queued messages during connecting state
If messages are sent using osmo_stream_cli_send() while the stream
is still (re)connecting, they won't have a chance to be sent until the
stream is connected, and hence they are queued until
CONNECTING->CONNECTED is done. However, at that time
(osmo_stream_cli_fd_cb), the WRITE flag was dropped unconditionally,
which meant already queued packets didn't have the opportunity to be
sent by the same callback until first message is enqueued and WRITE flag
is set (again by osmo_stream_cli_send()).
Let's make them be sent as soon as possible once the connection is
available.

Related: OS#4188
Change-Id: I289495f9aad6389c5f2623fb072d676235b7d24c
2019-09-04 17:40:22 +02:00
Pau Espin 962bf9a48e stream: Introduce API osmo_stream_cli_is_connected
Can be used by users to fetch current status of the stream.

Change-Id: I5402430e5f39eef22dfa18f33807ab6b1e771f1b
2019-09-04 17:04:18 +02:00
Pau Espin 592057bb33 Bump version: 0.5.0.2-6563-dirty → 0.6.0
Change-Id: I3af3b7aaff5c6dc3ac94e942191e27af4bf5392a
2019-08-07 20:59:51 +02:00
Oliver Smith 6563cf3399 contrib/jenkins.sh: run "make maintainer-clean"
Related: OS#3047
Change-Id: I37908c12dae9d268b8bde186e2743a2d7fd13536
2019-07-10 12:06:45 +02:00
Pau Espin f0f1ebf70e osmux: Extend osmux_out_handle and add new API to set rtp payload_type
Previously payload_type was always hardcoded to 98 for generated rtp
packets from incoming osmux frame.

Change-Id: I5cbeb494a8932953d9fd2dc24dacf8cd97fd84e4
2019-05-17 17:12:56 +02:00
Harald Welte fd339712c4 Bump version: 0.4.0.1-738f → 0.5.0
Change-Id: Iea2da939e259d0a9e7c5dad14d7a961434c276ef
2019-05-10 12:40:04 +02:00
Philipp Maier e380b38e28 amr: use sizeof(struct amr_hdr) when working with amr header length
The header of an AMR header payload is 2 bytes long. At the moment we
use just a constant of 2 when we refer to the header length, but we have a
struct amr_hdr defined. Lets use sizeof(struct amr_hdr) to make it more
clear that we are refering to the header length.

Change-Id: Ic7ca04b99a97d7d3b91717b0c3e6c55ef3001a3e
2019-03-20 15:45:05 +01:00
Max b3e34435b3 Deprecate osmo_stream_cli_open2()
This supposed to be variant of osmo_stream_cli_open() with explicit
control over reconnection logic but it's plain broken: doxygen docs
contradict the code, actual reconnection logic is affected by timeout
parameter directly which is set in different function.

It seems like we haven't been affected by this so far because we always
use it in auto-reconnection mode which is triggered by default due to
positive reconnection timeout value (5 sec) automatically used in the
absense of explicitly set timeout.

Looking at commit history, this function already been source of
confusion in the past. Instead of trying to fix this mess, let's just
deprecate it entirely and properly document use of
osmo_stream_cli_set_reconnect_timeout() to control reconnection logic.

The only known user is libosmo-sccp which won't use it as of
0a93a683f3cb8e5977eb4a666ab207db6e7d7af9 commit.

Change-Id: Id988ed0274b363db049f59cbf6a193727c8c3c8a
2019-03-19 13:40:55 +00:00
Oliver Smith 1ab218d28f tests: AM_LDFLAGS = -noinstall for all tests
Fix a symbol lookup error when building a new test on systems where
a previous libosmonetif.so is installed. Symptoms described here in
detail: https://osmocom.org/issues/3812#note-10

-no-install causes libtool to generate output files that link against
libraries in the build tree, instead of linking against the future
installation paths and generating a wrapper script. The wrapper script
should override the library paths, but at least on Debian, it does not
work as it should. Test binaries won't be installed anyway, so we can
safely use -no-install and work around the problem.

See also:
https://autotools.io/libtool/wrappers.html
https://www.gnu.org/software/libtool/manual/html_node/Link-mode.html

Related: OS#3812
Change-Id: I94ccff42dfba71aaf59bb30ca312db0bac58c27d
2019-03-14 12:03:29 +00:00
Oliver Smith 3d8022adf0 gitignore: add amr_test
Change-Id: I1ea7aad144a505412969c6c301349f8d47964422
2019-03-14 12:03:14 +00:00
Philipp Maier 5ca043655a amr: be sure result of osmo_amr_bwe_to_oa() fits into int buf
osmo_amr_bwe_to_oa() uses an internal buffer with static size to store
intermediate results. The buffer is large enough for any real world
situation, but the check that tests if the result would fit into the
internal buffer is incorrect. It checks if there is enough room for the
existing payload, but does not include the expected growth of the
payload. Eventually the buffer could be overrun by one byte if one would
put a 256 byte long AMR payload.

Fixes: CID#195926
Change-Id: I4d7ac570a0b48368a82183673c46bca5f235f228
2019-03-12 09:29:06 +01:00
Philipp Maier 3e77d57281 amr: cosmetic: correct sourcecode formatting
Change-Id: Ie4ad6b1a2382da4dc21e66a45c2a96224cab5752
2019-03-12 09:29:06 +01:00
Philipp Maier fa7df87260 AMR: add functions to convert between bw-efficient and octet-aligned
RFC 3267 describes two different AMR frame formats. Octet Aligned and
Bandwidth efficient mode. In Bandwith efficient mode the padding bits,
which are used to align CMR, TOC and payload on octet boundaries are
saved and the fielda are packed directly one after another.

- Add functions to convert from one mode to the other and vice versa.
- Add function to detect in which mode an AMR frame is encoded.

Change-Id: I5b5a0fa644d8dbb1f04f9d7e35312683c7b3d196
Related: SYS#4470
2019-03-07 10:22:22 +01:00
Philipp Maier 0fe9b3664a AMR: add define constants for AMR payload length
AMR uses different payload sizes, those sizes are well defined in RFC
3267. Lets add define constants and replace the magic values with the
define constants.

Also correct the value for AMR_FT_SID in amr_ft_to_bytes from 6 to 5
(39bits / 8 = 4.875 bytes ==> 5 byte, see also RFC 3267, chapter 3.6)

Change-Id: I65b5da920d58015b875d6dcf17aacdc04b58955e
2019-03-01 09:12:20 +01:00
Harald Welte 05db1909c8 debian: Add BuildDepends on libpcap0.8-dev
The debian packaging wants to execute "make check" which in turn
wants to build the jitterbuffer tests, which in turn require pcap.h
to be present, which is provided by libpcap0.8-dev.

Closes: OS#3818
Change-Id: Iab471de9fb276a436332241337539eab544f965a
2019-02-28 11:58:35 +01:00
Philipp Maier a8733cb6c7 AMR: add spec reference for AMR frame types
Change-Id: I39a602ae96570c9609680ff67e0946a696091cbe
2019-02-27 12:08:54 +01: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 fe3527da2a Add stream client/server test
Previously stream client and server code were only used in examples
which means regressions could be easily introduced unnoticed until they
trigger bugs in external code which relies on osmo_stream_*()

Fix this by adding basic client-server interaction tests with and
without reconnection.

Change-Id: I336f79970982ed8e1d73b73d54fa4c27ba8bce8e
2019-02-07 13:44:30 +01:00
Max 1a357720b5 Stream client: report reconnection event as INFO
This helps to avoid unnecessary debug output in reconnection logic tests
in follow-up patches.

Change-Id: Ic96430a9e9294e72de23b0bbacdbf3e99a453f1d
2019-02-07 13:38:22 +01:00
Max e72218c108 Ignore test binaries
Change-Id: Ice6f5aec2f22a97033a555a292a5648090fc5970
2019-02-06 08:09:39 +00: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 827d693b50 Stream client: fix disconnection logic
Previously closing the client did not alter its state, so we might
end-up with a client without any file descriptors, but being in state
STREAM_CLI_STATE_CONNECTED. Fix this inconsistency by setting
appropriate state.

Related issue is that reconnect function, which is always (at least in
the library and examples) called when some problem with the connection
is detected, closed the connection only after checking whether
reconnection is enabled. This might result in another inconsistency
fixed in this patch by moving the check below connection cleanup.

While at it, also move connection close logging to appropriate place:
it's confusing to see logs about connection being closed while in
reality it wasn't even established.

Change-Id: If41ed60bd625488c283d1e8a2b078e640f04c78e
2019-02-05 16:26:49 +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 a93bb2ca34 Stream client: update logging
Introduce logging macro wrapper to properly log current client state and
function to aid in debugging.

Change-Id: Ie22a80dcec95998cce0b25053fdf74f23eab6e53
2019-02-05 16:21:26 +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 e3366cf144 Stream client: fix doxygen typo
Change-Id: Ic45d3e0520db4060c5c24e5ef5a766a52f060a34
2019-02-04 13:23:27 +01:00
Max a720365c02 Cosmetic: use #pragma once as include guard
Change-Id: I2c1a13252730294597a7a9fb5726aae928f41bfd
2019-01-31 16:21:07 +01:00
Max de81cedffe Add missing include
stream.h uses msgb from libosmocore without corresponding #include
It's odd that we haven't hit this issue earlier.

Change-Id: Ib8b4f4965af0fefa7dac3f2a56a5a4b76a03fd57
2019-01-31 16:19:23 +01: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 c775ffe1cc Bump version: 0.3.0.6-a555 → 0.4.0
Change-Id: I99a3244f922382468251df675287520ca40d9d0d
2019-01-20 10:12:46 +01:00
Neels Hofmeyr dc8fcf5a69 logging: fix typo in stream.c
Change-Id: I5dcae1f19e18f04709ce7585943af1d582ebc7ed
2018-12-10 13:11:41 +01:00
Stefan Sperling a555a1fca2 detect freed connections in osmo_stream_srv_read()
While we are processing a read event, the connection's
callback might free the connection. Check for this and don't
attempt to process further events on an already freed connection.

Change-Id: I0a9c7d8e3263c73440f7084dbb1792a4ca5038f0
Related: OS#3685
Depends: g#11704 (for libosmo-sccp)
2018-11-09 15:33:19 +01:00
Pau Espin 7028d7387e jibuf: fix indentation in line inside conditional clause
Change-Id: I3cb356a4a13d53e7f88a5e4595899bb2eb510d20
2018-08-13 16:09:24 +02:00
Harald Welte 646d1c8204 debian/rules: Don't overwrite .tarball-version
The .tarball-version file should contain the *source version* uniquely
identifying the git commit, and not the Debian package name.

With https://gerrit.osmocom.org/#/c/osmo-ci/+/10343/ there is a correct
.tarball-version file in the .tar.xz of the nightly source packages.

Change-Id: I8915ebbf7d3a64a9474e1aeb49b1d192a388ef53
Related: OS#3449
2018-08-06 11:11:44 +02:00
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 fab0df4913 tests: jibuf_test: Add scenario to show out-of-order bug
Related: OS#3262

Change-Id: I1e78cc44f8a04dcb983352b513f8de2574b2394b
2018-05-15 16:49:50 +02:00
Pau Espin bac671eda8 tests: jibuf_test: Set some functions as static
Change-Id: I3af6db3fd74d55c5e659132fc542f22478a55eb7
2018-05-15 14:39:19 +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