aboutsummaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
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
2017-04-10stream/datagram: Ensure reliable close/destroyHarald Welte2-4/+16
* 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-10stream/datagram: Consistently use osmo_talloc_replace_string()Harald Welte2-14/+8
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-10stream+datagram: Allow local bind + connect for client socketsHarald Welte2-7/+44
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-08doc: Add Doxygen group for OSMUX related functionsHarald Welte1-0/+11
Change-Id: I87e08bd84236ae5d5c057bca96d122e568a6b52a
2017-04-08Add minimal doxygen documentation for stream + datagram modulesHarald Welte2-4/+259
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-03-29stream.c: Handle SCTP in osmo_stream_srv_recv()Daniel Willmann1-1/+57
Change-Id: If0875cfa3eba9ef36acc0c4bfd0d168a45c380b9
2017-03-20stream client: Ensure client is notified on reconnectionHarald Welte1-0/+1
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-17stream: Export osmo_stream_cli_reconnect()Harald Welte1-1/+1
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-17stream: When destroying, make sure to kill reconnect timerHarald Welte1-0/+1
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-17stream: don't crash in _close() when fd is not initializedHarald Welte1-0/+6
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-17stream_client: Actually use/honor the reconect parameterHarald Welte1-1/+4
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-02-07Fix potential NULL dereferenceMax1-1/+2
Change-Id: I5baf369dbf3948565614476980a32be59abaf42a
2016-12-22rs232.c: Fix license to GPLv2-or-later. libosmo-netif is GPLv2-or-laterHarald Welte1-3/+3
Change-Id: I7c73d1a0b15cfb2a729687cde6f9a8e62a230fd7
2016-12-01osmo_stream_cli_open2(): Fix bogus EINPROGRESS handlingHarald Welte1-10/+3
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-01rs232: Don't pass negative number to strerror()Harald Welte1-1/+1
Change-Id: Ia777221cd0472cd1e7aa79e5146b07048a545dd8 Fixes: Coverity CID 57860
2016-11-26sctp_sock_activate_events(): Print error message on errorHarald Welte1-0/+3
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-02Set SO_NOSIGPIPE on SCTP connections, for patforms which support it (macOS, ↵Arran Cudbard-Bell1-1/+17
FreeBSD etc...) Change-Id: If4f2a99b2baf143551a7122f40ed1f9088c5936c Signed-off-by: Arran Cudbard-Bell <a.cudbardb@freeradius.org>
2016-05-26osmux: Add function to delete all msgs pending for a circuitDaniel Willmann1-0/+11
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-25osmux: Pass circuit to _batch_del_circuit() and use it from _xfrm_input_fini()Daniel Willmann1-12/+10
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-02-19stream: Use macros to access data and lengthDaniel Willmann1-1/+1
2015-12-25stream.c: ensure to zero-initialize sctp_sndrcvinfoHarald Welte1-0/+2
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-22fix/complete stream client re-connect logicHarald Welte1-4/+16
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-22stream.c: Fix another 'link' variable / symbol mismatchHarald Welte1-1/+1
2015-12-22osmo_stream_cli_destroy: call talloc_free on right objectHarald Welte1-1/+1
'link' turns out to be a really bad variable name, as the symbol resolves to the global link(2)...
2015-12-21SCTP support for osmo_stream_{cli,srv} codeHarald Welte2-7/+86
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-11-03libosmovty: Drop dependency as no VTY code is written hereHolger Hans Peter Freyther1-2/+2
Do not link to libosmovty as we don't need it.
2015-08-19osmux: rename batch->dummy field to batch->ndummyPablo Neira Ayuso1-5/+5
This is basically a counter that tells us how many circuits need the padding, so better rename this to ndummy. Suggested by Holger.
2015-07-21build: bump library release numberPablo Neira Ayuso1-1/+1
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-21osmux: kill osmux_get_hdr()Pablo Neira Ayuso1-12/+0
Never used, so let's get rid of this function. We can recover it later on in case we need it.
2015-07-21osmux: introduce osmux_xfrm_input_open_circuit()Pablo Neira Ayuso1-33/+100
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-21osmux: introduce osmux_xfrm_input_close_circuit()Pablo Neira Ayuso1-5/+22
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-21osmux: count pending messages to be transformed in the batchPablo Neira Ayuso1-17/+15
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-21osmux: pass up struct osmux_batchPablo Neira Ayuso1-9/+8
Instead of struct osmux_in_handle. This object contains the internal batching state information.
2015-07-21osmux: rename circuit->list to circuit->rtp_listPablo Neira Ayuso1-7/+7
A circuit object contains a list of pending RTP messages to be converted to the osmux format.
2015-07-21osmux: rename struct batch_list_node to osmux_circuitPablo Neira Ayuso1-33/+33
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-21osmux: add circuit helper functionsPablo Neira Ayuso1-19/+46
Add osmux_batch_add_circuit() and osmux_batch_find_circuit() helper functions.
2015-07-17osmux: add osmux_input_state structurePablo Neira Ayuso1-37/+40
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-17osmux: discard non voice osmux messagePablo Neira Ayuso1-0/+5
We only support voice osmux messages by now. Discard unsupported types.