aboutsummaryrefslogtreecommitdiffstats
path: root/include
AgeCommit message (Collapse)AuthorFilesLines
2020-05-16amr: Fix OA<->BWE conversion.Alexander Chemeris1-12/+26
Size of a single AMR frame doesn't always shrink by a byte when converted from octet-aligned to bandwidth-efficient mode. It does shrink for AMR modes 2, 3, 4, 6, and 7 but doesn't shrink for AMR modes 0, 1, 5, and SID frames because we only remove 6 bits. So old code generated truncated AMR packets for those AMR modes. This patch fixes the length calculation by properly counting bits. Proper bit counting is also bringing us one small step closer to properly handlig multi-frame AMR packets. Change-Id: I0462e054a0adc9080456f3eeea9cab7c229cdb70
2020-05-14Revert "amr: Fix OA<->BWE conversion."neels1-26/+12
This reverts commit 002a51e2180cf19bf5e11e16d78271998d0b3f5c. Reason for revert: amr_test fails with sanitizer build: Sample No.: 6 bw-efficient: a7bfc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03f 1010011110111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111 ../../../src/libosmo-netif/src/amr.c:63:24: runtime error: index 15 out of bounds for type 'size_t [9]' ../../../src/libosmo-netif/src/amr.c:63:24: runtime error: load of address 0x7f69498e56b8 with insufficient space for an object of type 'size_t' 0x7f69498e56b8: note: pointer points here 00 00 00 00 00 00 00 00 00 00 00 00 5f 00 00 00 00 00 00 00 67 00 00 00 00 00 00 00 76 00 00 00 ^ ================================================================= ==489935==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7f69498e56b8 at pc 0x7f69498abec7 bp 0x7ffeafb35330 sp 0x7ffeafb35328 READ of size 8 at 0x7f69498e56b8 thread T0 #0 0x7f69498abec6 in osmo_amr_bytes ../../../src/libosmo-netif/src/amr.c:63 #1 0x7f69498ac661 in osmo_amr_bwe_to_oa ../../../src/libosmo-netif/src/amr.c:193 #2 0x5648b11afb96 in osmo_amr_bwe_to_oa_test ../../../src/libosmo-netif/tests/amr/amr_test.c:134 #3 0x5648b11af31d in main ../../../src/libosmo-netif/tests/amr/amr_test.c:235 #4 0x7f6948d5de0a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26e0a) #5 0x5648b11af3d9 in _start (/n/s/dev/make/libosmo-netif/tests/amr/amr_test+0x43d9) 0x7f69498e56b8 is located 8 bytes to the left of global variable 'amr_ft_to_bits' defined in '../../../src/libosmo-netif/src/amr.c:32:15' (0x7f69498e56c0) of size 72 0x7f69498e56b8 is located 48 bytes to the right of global variable 'amr_ft_to_bytes' defined in '../../../src/libosmo-netif/src/amr.c:44:15' (0x7f69498e5640) of size 72 SUMMARY: AddressSanitizer: global-buffer-overflow ../../../src/libosmo-netif/src/amr.c:63 in osmo_amr_bytes Change-Id: I8232521c513722435e71dc90bdbfee10f8f83496
2020-05-14amr: Fix OA<->BWE conversion.Alexander Chemeris1-12/+26
Size of a single AMR frame doesn't always shrink by a byte when converted from octet-aligned to bandwidth-efficient mode. It does shrink for AMR modes 2, 3, 4, 6, and 7 but doesn't shrink for AMR modes 0, 1, 5, and SID frames because we only remove 6 bits. So old code generated truncated AMR packets for those AMR modes. This patch fixes the length calculation by properly counting bits. Proper bit counting is also bringing us one small step closer to properly handlig multi-frame AMR packets. Change-Id: I9fc5fb92e9bada22a47a82fcfb0925e892e50ced
2020-01-12add/clean big-endian packed structs (struct_endianess.py)Neels Hofmeyr3-27/+16
Change-Id: If408153af472a41dcea8d6f6aedd22adb16963d5
2020-01-07struct amr_header: copy comments to little endian partNeels Hofmeyr1-4/+4
I will soon apply struct_endianess.py to this code, and then the comments that are now only in the big endian part would be lost. Copy them to preserve them. Change-Id: Ie4279928bd77a5d425d0e7a3c4d58bac3cf0230a
2019-10-15stream: osmo_stream_cli: Support setting multiple addrPau Espin Pedrol1-0/+2
This API will be later used to set multiple addresses for SCTP sockets. Depends: libosmocore.git Ic8681d9e093216c99c6bca4be81c31ef83688ed1 Related: OS#3608 Change-Id: I09f0d989f2309abdeb304fe570355abed2cd107b
2019-10-15stream: osmo_stream_srv_link: Support setting multiple addrPau Espin Pedrol1-0/+1
This API will be later used to set multiple addresses for SCTP sockets. Depends: libosmocore.git Ic8681d9e093216c99c6bca4be81c31ef83688ed1 Related: OS#3608 Change-Id: I0fe62f518e195db4e34f3b0ad1762bb57ba9d92a
2019-09-04stream: Introduce API osmo_stream_cli_is_connectedPau Espin Pedrol1-0/+1
Can be used by users to fetch current status of the stream. Change-Id: I5402430e5f39eef22dfa18f33807ab6b1e771f1b
2019-05-17osmux: Extend osmux_out_handle and add new API to set rtp payload_typePau Espin Pedrol1-1/+3
Previously payload_type was always hardcoded to 98 for generated rtp packets from incoming osmux frame. Change-Id: I5cbeb494a8932953d9fd2dc24dacf8cd97fd84e4
2019-03-19Deprecate osmo_stream_cli_open2()Max1-1/+2
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-07AMR: add functions to convert between bw-efficient and octet-alignedpmaier/amrmanglePhilipp Maier1-0/+8
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-01AMR: add define constants for AMR payload lengthPhilipp Maier1-0/+12
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-02-27AMR: add spec reference for AMR frame typesPhilipp Maier1-0/+3
Change-Id: I39a602ae96570c9609680ff67e0946a696091cbe
2019-02-20Stream client: add disconnect callbackMax1-0/+1
It's similar to connect_cb() but called once client has been disconnected. Change-Id: I905adb2d6191216551a3bcdcd1aec1f96f01612a
2019-02-05Add socket name functions to stream client/serverMax1-0/+2
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-01-31Cosmetic: use #pragma once as include guardMax1-4/+1
Change-Id: I2c1a13252730294597a7a9fb5726aae928f41bfd
2019-01-31Add missing includeMax1-0/+2
stream.h uses msgb from libosmocore without corresponding #include It's odd that we haven't hit this issue earlier. Change-Id: Ib8b4f4965af0fefa7dac3f2a56a5a4b76a03fd57
2018-08-01Migrate from osmo_ipa_idtag_parse() to ipa_ccm_id_resp_parse()Harald Welte1-1/+0
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-06-29remove "channel" layerHarald Welte5-87/+0
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-04-19osmux: Set Marker bit on osmux frame loss detectedPau Espin Pedrol1-0/+1
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-2/+10
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-0/+5
Change-Id: Ifae633d53107417a8e2f9b0f200d2711db72d199
2018-04-13jibuf: Add initial implementation of Jitter BufferPau Espin Pedrol2-0/+64
Change-Id: I9688ba9c4d5b733b9f29d0f15f73750f9271ef55
2018-02-22add support for flushing and destroying a server-side streamStefan Sperling1-0/+1
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-05-02stream.h: Add missing stdint.h includePau Espin Pedrol1-0/+1
This header uses uint16_t, which is provided by stdint.h. Change-Id: I399e2986c9d8cb5b3dd31673a6b4bf63070a4770
2017-04-29misc: Call the variable ctx like in all other placesHolger Hans Peter Freyther1-3/+3
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-27osmux: Add RTP marker bit supportPau Espin Pedrol1-3/+6
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-15netif/ipa.h: Don't redefine 'struct ipaccess_unit' from libosmocoreHarald Welte1-13/+1
'struct ipaccess_unit' is defined in libosmocore/gsm/ipa.h, we shouldn't re-define it here. This entire IPA code duplication accross multiple libraries and programs is a big mess. Change-Id: If378a088c741df540befb928a5557fc62dea954a
2017-04-14ipa.h: Don't redefine what libosmocore already definesHarald Welte1-33/+5
Change-Id: Ibd81efc1dc61b8c2019d55a8fa6e3bb99b5acb20
2017-04-12stream.h: Add missing stdbool.h includeHarald Welte1-0/+2
Functions introduced in 9ec26583cd807e0aeaa3b9de927f3d8a768c3a71 are using the bool type without referencing stdbool.h as include file. Change-Id: I736cb04629d516c10c7d5f42f792ed3d5ae6658f
2017-04-11Add osmo_stream_{cli,srv_link}_set_nodelay() functionHarald Welte1-0/+2
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+datagram: Allow local bind + connect for client socketsHarald Welte2-0/+4
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/+10
Change-Id: I87e08bd84236ae5d5c057bca96d122e568a6b52a
2017-04-08Add minimal doxygen documentation for stream + datagram modulesHarald Welte1-0/+12
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-17stream: Export osmo_stream_cli_reconnect()Harald Welte1-0/+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
2015-12-22fix/complete stream client re-connect logicHarald Welte1-0/+1
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-21SCTP support for osmo_stream_{cli,srv} codeHarald Welte1-0/+5
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-07-21osmux: kill osmux_get_hdr()Pablo Neira Ayuso1-2/+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-1/+3
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-0/+2
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-03-22rtp: Declare struct msgb to fix compiler warningHolger Hans Peter Freyther1-0/+3
Fixes: /usr/include/osmocom/netif/rtp.h:63:41: warning: ‘struct msgb’ declared inside parameter list struct rtp_hdr *osmo_rtp_get_hdr(struct msgb *msg);
2015-03-22rtp: Add "data" to access the data behind the headerHolger Hans Peter Freyther1-0/+1
This is needed for mgcp_transcode.c of OpenBSC to access the data after the header. Use a zero sized array for it.
2015-03-22endian: Use the new endian macros for portabilityHolger Hans Peter Freyther3-8/+14
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.
2014-08-29osmux: export OSMUX_BATCH_DEFAULT_MAXPablo Neira Ayuso1-0/+3
This allows you to set the default batch size when initializing the osmux input handle.
2014-08-28osmux: add statistics to osmux_in_handle structPablo Neira Ayuso1-0/+8
Add statistics to the osmux input handle, which translates the RTP messages to osmux batch.
2014-08-28osmux: allow to specify the osmux frame sizePablo Neira Ayuso1-0/+1
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-28osmux: add osmux_xfrm_input_fini()Pablo Neira Ayuso1-0/+1
To clean up the osmux input handle.
2014-08-26include: define OSMUX_ID_MAXPablo Neira Ayuso1-0/+1
This tells us the maximum osmux circuit ID.
2014-04-25amr: make sure the header is packedPablo Neira Ayuso1-1/+1
2013-05-24osmux: fix wrong OSMUX header description in header filePablo Neira Ayuso1-8/+8
It was not matching with the current code.