Skip to content

Commit

Permalink
Merge branch 'master' into dev-refax-remove-cpacket-refs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Małecki committed Sep 14, 2023
2 parents d126e64 + 09f35c0 commit 084c9c5
Show file tree
Hide file tree
Showing 48 changed files with 1,136 additions and 420 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ matrix:
- BUILD_TYPE=Release
- BUILD_OPTS='-DENABLE_MONOTONIC_CLOCK=ON'
script:
- TESTS_IPv6="TestMuxer.IPv4_and_IPv6:TestIPv6.v6_calls_v6*:ReuseAddr.ProtocolVersion:ReuseAddr.*6" ; # Tests to skip due to lack of IPv6 support
- if [ "$TRAVIS_COMPILER" == "x86_64-w64-mingw32-g++" ]; then
export CC="x86_64-w64-mingw32-gcc";
export CXX="x86_64-w64-mingw32-g++";
Expand All @@ -95,7 +94,7 @@ script:
fi
- if [ "$TRAVIS_COMPILER" != "x86_64-w64-mingw32-g++" ]; then
ulimit -c unlimited;
./test-srt --gtest_filter="-$TESTS_IPv6";
./test-srt -disable-ipv6;
SUCCESS=$?;
if [ -f core ]; then gdb -batch ./test-srt -c core -ex bt -ex "info thread" -ex quit; else echo "NO CORE - NO CRY!"; fi;
test $SUCCESS == 0;
Expand Down
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#

cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
set (SRT_VERSION 1.5.2)
set (SRT_VERSION 1.5.3)

set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/scripts")
include(haiUtil) # needed for set_version_variables
Expand Down Expand Up @@ -153,6 +153,7 @@ option(ENABLE_GETNAMEINFO "In-logs sockaddr-to-string should do rev-dns" OFF)
option(ENABLE_UNITTESTS "Enable unit tests" OFF)
option(ENABLE_ENCRYPTION "Enable encryption in SRT" ON)
option(ENABLE_AEAD_API_PREVIEW "Enable AEAD API preview in SRT" Off)
option(ENABLE_MAXREXMITBW "Enable SRTO_MAXREXMITBW (v1.6.0 API preview)" Off)
option(ENABLE_CXX_DEPS "Extra library dependencies in srt.pc for the CXX libraries useful with C language" ON)
option(USE_STATIC_LIBSTDCXX "Should use static rather than shared libstdc++" OFF)
option(ENABLE_INET_PTON "Set to OFF to prevent usage of inet_pton when building against modern SDKs while still requiring compatibility with older Windows versions, such as Windows XP, Windows Server 2003 etc." ON)
Expand Down Expand Up @@ -299,7 +300,13 @@ if(WIN32)
if(ENABLE_INET_PTON)
set(CMAKE_REQUIRED_LIBRARIES ws2_32)
check_function_exists(inet_pton HAVE_INET_PTON)
add_definitions(-D_WIN32_WINNT=0x0600)
try_compile(AT_LEAST_VISTA
${CMAKE_BINARY_DIR}
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/test_vista.c")
if(NOT AT_LEAST_VISTA)
# force targeting Vista
add_definitions(-D_WIN32_WINNT=0x0600)
endif()
else()
add_definitions(-D_WIN32_WINNT=0x0501)
endif()
Expand Down Expand Up @@ -460,6 +467,13 @@ if (USE_GNUSTL)
set (SRT_LIBS_PRIVATE ${SRT_LIBS_PRIVATE} ${GNUSTL_LIBRARIES} ${GNUSTL_LDFLAGS})
endif()

if (ENABLE_MAXREXMITBW)
add_definitions(-DENABLE_MAXREXMITBW)
message(STATUS "MAXREXMITBW API: ENABLED")
else()
message(STATUS "MAXREXMITBW API: DISABLED")
endif()

if (USING_DEFAULT_COMPILER_PREFIX)
# Detect if the compiler is GNU compatible for flags
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Intel|Clang|AppleClang")
Expand Down
3 changes: 3 additions & 0 deletions apps/socketoptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ const SocketOption srt_options [] {
#ifdef ENABLE_AEAD_API_PREVIEW
,{ "cryptomode", 0, SRTO_CRYPTOMODE, SocketOption::PRE, SocketOption::INT, nullptr }
#endif
#ifdef ENABLE_MAXREXMITBW
,{ "maxrexmitbw", 0, SRTO_MAXREXMITBW, SocketOption::POST, SocketOption::INT64, nullptr }
#endif
};
}

Expand Down
2 changes: 1 addition & 1 deletion apps/transmitmedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,6 @@ class UdpCommon

if (is_multicast)
{
ip_mreq_source mreq_ssm;
ip_mreq mreq;
sockaddr_any maddr (AF_INET);
int opt_name;
Expand All @@ -872,6 +871,7 @@ class UdpCommon
if (attr.count("source"))
{
#ifdef IP_ADD_SOURCE_MEMBERSHIP
ip_mreq_source mreq_ssm;
/* this is an ssm. we need to use the right struct and opt */
opt_name = IP_ADD_SOURCE_MEMBERSHIP;
mreq_ssm.imr_multiaddr.s_addr = sadr.sin.sin_addr.s_addr;
Expand Down
14 changes: 9 additions & 5 deletions docs/API/API-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Since SRT v1.5.0.
| [SRT_REJ_FILTER](#SRT_REJ_FILTER) | 1.3.4 | The [`SRTO_PACKETFILTER`](API-socket-options.md#SRTO_PACKETFILTER) option has been set differently on both connection parties |
| [SRT_REJ_GROUP](#SRT_REJ_GROUP) | 1.4.2 | The group type or some group settings are incompatible for both connection parties |
| [SRT_REJ_TIMEOUT](#SRT_REJ_TIMEOUT) | 1.4.2 | The connection wasn't rejected, but it timed out |
| [SRT_REJ_CRYPTO](#SRT_REJ_CRYPTO) | 1.6.0-dev | The connection was rejected due to an unsupported or mismatching encryption mode |
| [SRT_REJ_CRYPTO](#SRT_REJ_CRYPTO) | 1.5.2 | The connection was rejected due to an unsupported or mismatching encryption mode |
| <img width=290px height=1px/> | | |

<h4 id="error-codes">Error Codes</h4>
Expand Down Expand Up @@ -359,8 +359,12 @@ int srt_bind(SRTSOCKET u, const struct sockaddr* name, int namelen);
Binds a socket to a local address and port. Binding specifies the local network
interface and the UDP port number to be used for the socket. When the local
address is a wildcard (`INADDR_ANY` for IPv4 or `in6addr_any` for IPv6), then
it's bound to all interfaces (although see `SRTO_IPV6ONLY` and additional
information below for details about the wildcard address in IPv6).
it's bound to all interfaces.

**IMPORTANT**: When you bind an IPv6 wildcard address, note that the
`SRTO_IPV6ONLY` option must be set on the socket explicitly to 1 or 0 prior to
calling this function. See
[`SRTO_IPV6ONLY`](API-socket-options.md#SRTO_IPV6ONLY) for more details.

Binding is necessary for every socket to be used for communication. If the socket
is to be used to initiate a connection to a listener socket, which can be done,
Expand Down Expand Up @@ -662,7 +666,7 @@ internal use only.
| Returns | |
|:----------------------------- |:----------------------------------------------------------------------- |
| socket/group ID | On success, a valid SRT socket or group ID to be used for transmission. |
| `SRT_ERROR` | (-1) on failure |
| `SRT_INVALID_SOCK` | (-1) on failure |
| <img width=240px height=1px/> | <img width=710px height=1px/> |

| Errors | |
Expand Down Expand Up @@ -718,7 +722,7 @@ calling this function.
| Returns | |
|:----------------------------- |:---------------------------------------------------------------------- |
| SRT socket<br/>group ID | On success, a valid SRT socket or group ID to be used for transmission |
| `SRT_ERROR` | (-1) on failure |
| `SRT_INVALID_SOCK` | (-1) on failure |
| <img width=240px height=1px/> | <img width=710px height=1px/> |

| Errors | |
Expand Down
41 changes: 35 additions & 6 deletions docs/API/API-socket-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ The following table lists SRT API socket options in alphabetical order. Option d
| [`SRTO_BINDTODEVICE`](#SRTO_BINDTODEVICE) | 1.4.2 | pre-bind | `string` | | | | RW | GSD+ |
| [`SRTO_CONGESTION`](#SRTO_CONGESTION) | 1.3.0 | pre | `string` | | "live" | \* | W | S |
| [`SRTO_CONNTIMEO`](#SRTO_CONNTIMEO) | 1.1.2 | pre | `int32_t` | ms | 3000 | 0.. | W | GSD+ |
| [`SRTO_CRYPTOMODE`](#SRTO_CRYPTOMODE) | 1.6.0-dev | pre | `int32_t` | | 0 (Auto) | [0, 2] | W | GSD |
| [`SRTO_CRYPTOMODE`](#SRTO_CRYPTOMODE) | 1.5.2 | pre | `int32_t` | | 0 (Auto) | [0, 2] | W | GSD |
| [`SRTO_DRIFTTRACER`](#SRTO_DRIFTTRACER) | 1.4.2 | post | `bool` | | true | | RW | GSD |
| [`SRTO_ENFORCEDENCRYPTION`](#SRTO_ENFORCEDENCRYPTION) | 1.3.2 | pre | `bool` | | true | | W | GSD |
| [`SRTO_EVENT`](#SRTO_EVENT) | | | `int32_t` | flags | | | R | S |
Expand All @@ -224,6 +224,7 @@ The following table lists SRT API socket options in alphabetical order. Option d
| [`SRTO_LINGER`](#SRTO_LINGER) | | post | `linger` | s | off \* | 0.. | RW | GSD |
| [`SRTO_LOSSMAXTTL`](#SRTO_LOSSMAXTTL) | 1.2.0 | post | `int32_t` | packets | 0 | 0.. | RW | GSD+ |
| [`SRTO_MAXBW`](#SRTO_MAXBW) | | post | `int64_t` | B/s | -1 | -1.. | RW | GSD |
| [`SRTO_MAXREXMITBW`](#SRTO_MAXREXMITBW) | 1.5.3 | post | `int64_t` | B/s | -1 | -1.. | RW | GSD |
| [`SRTO_MESSAGEAPI`](#SRTO_MESSAGEAPI) | 1.3.0 | pre | `bool` | | true | | W | GSD |
| [`SRTO_MININPUTBW`](#SRTO_MININPUTBW) | 1.4.3 | post | `int64_t` | B/s | 0 | 0.. | RW | GSD |
| [`SRTO_MINVERSION`](#SRTO_MINVERSION) | 1.3.0 | pre | `int32_t` | version | 0x010000 | \* | RW | GSD |
Expand Down Expand Up @@ -327,7 +328,7 @@ will be 10 times the value set with `SRTO_CONNTIMEO`.

| OptName | Since | Restrict | Type | Units | Default | Range | Dir | Entity |
| ------------------ | --------- | -------- | --------- | ------ | -------- | ------ | --- | ------ |
| `SRTO_CRYPTOMODE` | 1.6.0-dev | pre | `int32_t` | | 0 (Auto) | [0, 2] | RW | GSD |
| `SRTO_CRYPTOMODE` | 1.5.2 | pre | `int32_t` | | 0 (Auto) | [0, 2] | RW | GSD |

The encryption mode to be used if the [`SRTO_PASSPHRASE`](#SRTO_PASSPHRASE) is set.

Expand Down Expand Up @@ -647,10 +648,22 @@ and the actual value for connected sockets.

Set system socket option level `IPPROTO_IPV6` named `IPV6_V6ONLY`. This is meaningful
only when the socket is going to be bound to the IPv6 wildcard address `in6addr_any`
(known also as `::`). In this case this option must be also set explicitly to 0 or 1
before binding, otherwise binding will fail (this is because it is not possible to
determine the default value of this above-mentioned system option in any portable or
reliable way). Possible values are:
(known also as `::`). If you bind to a wildcard address, you have the following
possibilities:

* IPv4 only: bind to an IPv4 wildcard address
* IPv6 only: bind to an IPv6 wildcard address and set this option to 1
* IPv4 and IPv6: bind to an IPv6 wildcard address and set this option to 0

This option's default value is -1 because it is not possible to determine the default
value on the current platform, and if you bind to an IPv6 wildcard address, this value
is required prior to binding. When you bind implicitly by calling `srt_connect` on the
socket, this isn't a problem -- binding will be done using the system-default value and then
extracted afterwards. But if you want to bind explicitly using `srt_bind`, this
option must be set explicitly to 0 or 1 because this information is vital for
determining any potential bind conflicts with other sockets.

Possible values are:

* -1: (default) use system-default value (can be used when not binding to IPv6 wildcard `::`)
* 0: The binding to `in6addr_any` will bind to both IPv6 and IPv4 wildcard address
Expand Down Expand Up @@ -834,6 +847,22 @@ therefore the default -1 remains even in live mode.

---

#### SRTO_MAXREXMITBW

| OptName | Since | Restrict | Type | Units | Default | Range | Dir | Entity |
| -------------------- | ----- | -------- | ---------- | ------- | -------- | ------ | --- | ------ |
| `SRTO_MAXREXMITBW` | 1.5.3 | post | `int64_t` | B/s | -1 | -1.. | RW | GSD |

Maximum BW limit for retransmissions:

- `-1`: unlimited;
- `0`: do not allow retransmissions.
- `>0`: BW usage limit in Bytes/sec for packet retransmissions (including 16 bytes of SRT header).

[Return to list](#list-of-options)

---

#### SRTO_MESSAGEAPI

| OptName | Since | Restrict | Type | Units | Default | Range | Dir | Entity |
Expand Down
17 changes: 9 additions & 8 deletions docs/apps/srt-live-transmit.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,13 @@ specify the host as `::`.
NOTE: Don't use square brackets syntax in the **adapter** parameter
specification, as in this case only the host is expected.

3. If you want to listen for connections from both IPv4 and IPv6, mind the
`ipv6only` option. The default value for this option is system default (see
system manual for `IPV6_V6ONLY` socket option); if unsure, you might want to
enforce `ipv6only=0` in order to be able to accept both IPv4 and IPv6
connections by the same listener, or set `ipv6only=1` to accept exclusively IPv6.
3. If you bind to an IPv6 wildcard address (with listener mode, or when using the `bind`
option), setting the `ipv6only` option to 0 or 1 is obligatory, as it is a part
of the binding definition. If you set it to 1, the binding will apply only to
IPv6 local addresses, and if you set it to 0, it will apply to both IPv4 and
IPv6 local addresses. See the
[`SRTO_IPV6ONLY`](../API/API-socket-options.md#SRTO_IPV6ONLY) option
description for details.

4. In rendezvous mode you may only interconnect both parties using IPv4,
or both using IPv6. Unlike listener mode, if you want to leave the socket
Expand All @@ -303,9 +305,8 @@ Examples:

* `srt://[::]:5000` defines caller mode (!) with IPv6.

* `srt://[::]:5000?mode=listener` defines listener mode with IPv6. If the
default value for `IPV6_V6ONLY` system socket option is 0, it will accept
also IPv4 connections.
* `srt://[::]:5000?mode=listener&ipv6only=1` defines listener mode with IPv6.
Only connections from IPv6 callers will be accepted.

* `srt://192.168.0.5:5000?mode=rendezvous` will make a rendezvous connection
with local address `INADDR_ANY` (IPv4) and port 5000 to a destination with
Expand Down
9 changes: 8 additions & 1 deletion docs/build/build-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Option details are given further below.
| [`ENABLE_DEBUG`](#enable_debug) | 1.2.0 | `INT` | ON | Allows release/debug control through the `CMAKE_BUILD_TYPE` variable. |
| [`ENABLE_ENCRYPTION`](#enable_encryption) | 1.3.3 | `BOOL` | ON | Enables encryption feature, with dependency on an external encryption library. |
| [`ENABLE_AEAD_API_PREVIEW`](#enable_aead_api_preview) | 1.5.2 | `BOOL` | OFF | Enables AEAD preview API (encryption with integrity check). |
| [`ENABLE_MAXREXMITBW`](#enable_maxrexmitbw) | 1.5.3 | `BOOL` | OFF | Enables SRTO_MAXREXMITBW (v1.6.0 API). |
| [`ENABLE_GETNAMEINFO`](#enable_getnameinfo) | 1.3.0 | `BOOL` | OFF | Enables the use of `getnameinfo` to allow using reverse DNS to resolve an internal IP address into a readable internet domain name. |
| [`ENABLE_HAICRYPT_LOGGING`](#enable_haicrypt_logging) | 1.3.1 | `BOOL` | OFF | Enables logging in the *haicrypt* module, which serves as a connector to an encryption library. |
| [`ENABLE_HEAVY_LOGGING`](#enable_heavy_logging) | 1.3.0 | `BOOL` | OFF | Enables heavy logging instructions in the code that occur often and cover many detailed aspects of library behavior. Default: OFF in release mode. |
Expand Down Expand Up @@ -275,9 +276,15 @@ use encryption for the connection.

When ON, the AEAD API is enabled. The `ENABLE_ENCRYPTION` must be enabled as well.
The AEAD functionality is only available if OpenSSL EVP is selected as the crypto provider:
build option `-DUSE_ENCLIB=openssl-evp`.
build option should be set to `USE_ENCLIB=openssl-evp`.

The AEAD API is to be official in SRT v1.6.0.

#### ENABLE_MAXREXMITBW
**`--enable-maxrexmitbw`** (default: OFF)

When ON, the `SRTO_MAXREXMITBW` is enabled (to become official in SRT v1.6.0).


#### ENABLE_GETNAMEINFO
**`--enable-getnameinfo`** (default: OFF)
Expand Down
3 changes: 2 additions & 1 deletion haicrypt/hcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ int HaiCrypt_Clone(HaiCrypt_Handle hhcSrc, HaiCrypt_CryptoDir tx, HaiCrypt_Handl

if (tx) {
HaiCrypt_Cfg crypto_config;
HaiCrypt_ExtractConfig(hhcSrc, &crypto_config);
if (-1 == HaiCrypt_ExtractConfig(hhcSrc, &crypto_config))
return -1;

/*
* Just invert the direction written in flags and use the
Expand Down
10 changes: 10 additions & 0 deletions scripts/test_vista.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* Copyright © 2023 Steve Lhomme */
/* SPDX-License-Identifier: ISC */
#include <windows.h>
#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 /* _WIN32_WINNT_VISTA */
#error NOPE
#endif
int main(void)
{
return 0;
}
2 changes: 2 additions & 0 deletions scripts/win-installer/libsrt.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ Section "Install"
; Header files.
CreateDirectory "$INSTDIR\include\srt"
SetOutPath "$INSTDIR\include\srt"
File "${RepoDir}\srtcore\access_control.h"
File "${RepoDir}\srtcore\logging_api.h"
File "${RepoDir}\srtcore\platform_sys.h"
File "${RepoDir}\srtcore\srt.h"
File "${RepoDir}\srtcore\udt.h"
File "${Build64Dir}\version.h"

CreateDirectory "$INSTDIR\include\win"
Expand Down
Loading

0 comments on commit 084c9c5

Please sign in to comment.