path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2018-07-27Bump version: → Espin Pedrol1-1/+1
Change-Id: Ic9bbe8427c44ef2a9ee02537f17821048f177cdd
2018-07-05stream.c: Use non-blocking connect in osmo_stream_cliHarald Welte1-1/+1
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-06-29remove "channel" layerHarald Welte7-861/+1
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-05-15osmux: change log lvl of batch full to debugPau Espin Pedrol1-2/+2
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-15jibuf: Fix out-of-order seq queue around syncpointsPau Espin Pedrol1-3/+33
Fixes: OS#3262 Change-Id: Ib8c61dbe6261cf73d6efcd7873e23b7656117556
2018-05-03Bump version: → Espin Pedrol1-1/+1
Change-Id: Ic8a9e44b2f930fed024040777eab58699fdcaadc
2018-04-28osmux: Fix use of uninitialized memory in osmux_out_handleHarald Welte1-0/+1
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-19osmux: Set Marker bit on osmux frame loss detectedPau Espin Pedrol1-2/+16
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-19osmux: Add new API osmux_xfrm_output_sched to fix rtp generation issuesPau Espin Pedrol1-1/+131
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-13jibuf: Estimate src clock skewPau Espin Pedrol1-3/+28
Change-Id: Ifae633d53107417a8e2f9b0f200d2711db72d199
2018-04-13jibuf: re-sync clock out of sync timestampsPau Espin Pedrol1-5/+24
Change-Id: I33556b33d7549654442d9bdd7f31128792506652
2018-04-13jibuf: Take RTP marker into accountPau Espin Pedrol1-3/+15
Change-Id: Ie142acfb45650e0af775f58226fd191beaf8178e
2018-04-13jibuf: Add initial implementation of Jitter BufferPau Espin Pedrol2-0/+382
Change-Id: I9688ba9c4d5b733b9f29d0f15f73750f9271ef55
2018-04-12osmux: osmux_xfrm_output_pull: Improve checks and log of malformed packetsPau Espin Pedrol1-5/+11
Change-Id: I143805bb5ee9f5e3ada46114e380a03ede80df9f Related: SYS#4182
2018-04-05stream.c: osmo_stream_cli_open2: Remove wrong assumption in reconnect decisionPau Espin Pedrol1-1/+1
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-03-07osmux: Use correct log category DLMUXPau Espin Pedrol1-27/+27
Change-Id: I77f4593941207689f714d15304dcce40b21d4bd8
2018-02-22add support for flushing and destroying a server-side streamStefan Sperling1-1/+29
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
2017-11-20osmo_stream_{cli,srv}_destroy: fix mem leak: empty msgb queueNeels Hofmeyr1-0/+2
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-17stream: Avoid re-creating and leaking socket when unneededPau Espin Pedrol1-2/+6
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-13Add SPDX-License-Identifier + Copyright statementsHarald Welte11-1/+164
Change-Id: I43bb1c4a889421907a1a08eb29c96f2330ab00ec
2017-11-13src/rs232.c: Fix accidential reference to GPLv3+ instead of GPLv2+Harald Welte1-1/+1
Change-Id: I5fa2696c5090994c417ca882c5225cbd7c1be2c7
2017-10-28Don't link library against libosmogsm, we don't use any symbols of itHarald Welte2-4/+4
This fixes a related dpkg-shlibdeps warning Change-Id: I0325e7a6dea5195f1634230930570bf4dfe3810c
2017-10-27Tag/Release Version Welte1-1/+1
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-27some more Doxygen header text for datagram, osmux and stream moduleHarald Welte3-0/+19
Change-Id: Ied83e6b117a420d734a88e3aff925a874c3dd520
2017-10-24osmux_snprintf: Add doxygen docPau Espin Pedrol1-1/+10
Change-Id: Idb3fcf25be9558bfc2f822352c07ebc2cb7d5caa
2017-10-24osmux_snprintf: Support different types of Osmux framesPau Espin Pedrol1-18/+32
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-23osmux_snprintf: Split logic parsing osmux header and AMR payloadPau Espin Pedrol1-10/+13
The current code still expects to parse only AMR osmux frames, but that will be fixed in following patches. Change-Id: Ic2f4d1d3cc88af912bb43c8ecd90eacc6ff7190f
2017-10-13cosmetic: print textual error from recv()Max1-1/+1
Change-Id: Ic9557c6519b44b5985daf7d2d14ec063790441fb
2017-10-13cosmetic: relax UDP length checkMax1-2/+2
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-05rs232.c: Don't #include <osmocom/abis/e1_input.h>Harald Welte1-1/+1
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-09-12src: _snprintf() helper functions nul-terminate buffers, if possiblePablo Neira Ayuso2-0/+6
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-11osmux: fix buffer management mess in snprintf() callsPablo Neira Ayuso2-40/+39
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-05rtp: return offset in osmo_rtp_snprintf()Pablo Neira Ayuso1-1/+1
Instead of the result of the last snprintf() call. Change-Id: I10066d73387be96a4e1f3349d700405beb138076
2017-08-14osmux: Slightly improve output format of osmux_snprintfPau Espin Pedrol1-1/+4
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-14osmux: Fix buffer overflow in osmux_snprintfPau Espin Pedrol1-1/+1
When running osmux_test on my PC, the process was aborted with a "stack smashing detected" error. Change-Id: I8a7cc422c181c0c5712ac8976a5be5f0ad44a9c0
2017-07-13rtp.c: Fix print formatPau Espin Pedrol1-3/+4
Fixes compilation warning Change-Id: I0146a19bf852c9e27d265a098dc9d7a337424e10
2017-06-07src: use osmo_timer_setup()Pablo Neira Ayuso3-10/+6
Use new function available in libosmocore to set up timers. Compile tested only. Change-Id: Id3dd32102c7362f3b280d2c058c2decebccb357a
2017-05-14somo_stream_srv_fd_cb(): close socket if NODELAY failsHarald Welte1-8/+14
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-04-29misc: Call the variable ctx like in all other placesHolger Hans Peter Freyther1-8/+8
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-28osmux: Fix delay between RTP packetsPau Espin Pedrol1-2/+3
AMR frame contains 160 samples at 8000Hz -> 20 ms long Change-Id: I36dc69f9caf591dd1b578bc914a2ce426c7f2813
2017-04-27osmux: Use osmo_gettimeofday for testing puroposesPau Espin Pedrol1-2/+2
This way we can use fake time and osmux_test take 700ms instead of >2sec to run. Change-Id: Ic39cab74400aca8262a00c0d06884230b1a15ca3
2017-04-27osmux: Add RTP marker bit supportPau Espin Pedrol1-3/+13
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-27osmux: Check batch_factor overflow in osmux_batch_enqueuePau Espin Pedrol1-6/+7
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-27osmux: use uint8_t everywhere for batch_factorPau Espin Pedrol1-5/+5
Change-Id: I9fcc8e94b2fcd843b10cb3f8f009f2348eb3a4af
2017-04-17SCTP: Don't enable sender_dry_event for SCTP, as it breaks Linux SCTPHarald Welte1-2/+11
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-16stream.c: Fix SCTP_NODELAY settingHarald Welte1-1/+1
We were using the wrong variable when setting the SCTP_NODELAY, resulting in the setsoctkopt() fialing. Change-Id: Ic04cb8bb5ff41f177f7f5b7f7e2a2ecc686dd4c0
2017-04-14osmo_stream_srv_fd_cb(): don't leak socket FDs on errorsNeels Hofmeyr1-6/+23
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-12SCTP: Fix PPID byte widthHarald Welte1-3/+3
In a659590e29412588bca2243b8329e82286244b00 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-11Add osmo_stream_{cli,srv_link}_set_nodelay() functionHarald Welte1-0/+60
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-10stream.c: Fix endianness handling of PPID and STREAM_IDHarald Welte1-6/+6
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