platform/upstream/libnice.git
2 years agomeson_option: Enable dlog 52/274852/2 accepted/tizen/unified/20220525.134545 submit/tizen/20220524.055649
Sangchul Lee [Wed, 11 May 2022 02:37:55 +0000 (11:37 +0900)]
meson_option: Enable dlog

[Version] 0.1.18-2
[Issue Type] Log

Change-Id: I666e75c78ef1309b523ec2bb79781b2313f1bfad
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
2 years agoUpdate spec file and meson files 53/271253/1 accepted/tizen/unified/20220221.080256 submit/tizen/20220218.104050
Sangchul Lee [Thu, 17 Feb 2022 07:18:16 +0000 (16:18 +0900)]
Update spec file and meson files

Change-Id: I155c032e191ebbc0bcfaf62e6904c1ad28f5dfee
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
2 years agomeson: Fix openssl setting 45/271245/1
Olivier Crête [Wed, 26 Jan 2022 18:57:13 +0000 (13:57 -0500)]
meson: Fix openssl setting

This should fix builds on platforms openssl

Change-Id: If13f747fe358f1e7e0043356043a5085781d09c6

2 years agomeson: Simplify finding OpenSSL 44/271244/1
Olivier Crête [Tue, 2 Nov 2021 17:14:55 +0000 (13:14 -0400)]
meson: Simplify finding OpenSSL

Remove duplicated calls to dependency() so we can have fallback in all
cases.

Change-Id: Ic278734a9824e1646aec50a1d807b0451f8bf834

2 years agomeson: Fix name of variable 43/271243/1
Olivier Crête [Tue, 2 Nov 2021 16:33:13 +0000 (12:33 -0400)]
meson: Fix name of variable

This is a fix over the recent fix in commit 574f44b4

Change-Id: I922f0895ae13d5802aea4775860f642d18c8d86c

2 years agoFix error when crypto/ssl libs are found without pkg-config 42/271242/1
Xavier Claessens [Thu, 28 Oct 2021 14:24:39 +0000 (10:24 -0400)]
Fix error when crypto/ssl libs are found without pkg-config

In that case crypto_dep is a list and we can't call .found() method.

Change-Id: Ie63d78530d9a935312263bf9843f76667b17c4f6

2 years agoMerge branch 'upstream' into tizen 35/271235/1
Sangchul Lee [Thu, 17 Feb 2022 05:08:15 +0000 (14:08 +0900)]
Merge branch 'upstream' into tizen

It is updated to 0.1.18.

Change-Id: Ife96288be82519f7cec61c48d5f6f53edd98de79

2 years agoMerge tag '0.1.18' into upstream upstream/0.1.18
Sangchul Lee [Thu, 17 Feb 2022 04:08:01 +0000 (13:08 +0900)]
Merge tag '0.1.18' into upstream

Libnice release 0.1.18

Change-Id: I3af1a67390b647bd36d23002f396bc2406659c7b

2 years agoInitialize git
Sangchul Lee [Thu, 17 Feb 2022 04:05:23 +0000 (13:05 +0900)]
Initialize git

Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
2 years agoExclude gst plugins from build 03/271103/1 accepted/tizen/unified/20220217.153448 submit/tizen/20220216.051033
Sangchul Lee [Thu, 10 Feb 2022 05:52:49 +0000 (14:52 +0900)]
Exclude gst plugins from build

Gstreamer plugins move on to the gstreamer mono git since 1.20.0.
 : gstreamer/subprojects/gst-plugins-bad/ext/nice

Change-Id: Ib006250b5261ded170f6ba17725d79a24ed000b2
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
(cherry picked from commit 4e38bd1424281f45de01779ec1b1f2b301107f5a)

2 years agoChange nice_debug_verbose as dlog message 18/263418/2 accepted/tizen_6.5_unified tizen_6.5 accepted/tizen/6.5/unified/20211029.013819 accepted/tizen/unified/20210907.121855 submit/tizen/20210902.060944 submit/tizen/20210906.055733 submit/tizen/20210907.040339 submit/tizen_6.5/20211028.163501 tizen_6.5.m2_release
YoungHun Kim [Thu, 2 Sep 2021 03:05:23 +0000 (12:05 +0900)]
Change nice_debug_verbose as dlog message

Change-Id: I6d759bf95019e6fcd02bede420bd88d6f980f18e

2 years agoUse dlog to debug agent 28/262428/20 accepted/tizen/unified/20210824.123845 submit/tizen/20210818.024548
YoungHun Kim [Tue, 10 Aug 2021 09:29:45 +0000 (18:29 +0900)]
Use dlog to debug agent

 - Log tag is LIBNICE_AGENT

Change-Id: I19252689850078b8452e4cd7ae51dc04f275bf4f

3 years agoversion 0.1.18 0.1.18
Olivier Crête [Wed, 21 Oct 2020 00:45:24 +0000 (20:45 -0400)]
version 0.1.18

3 years agoconncheck: Only valid stun messages used for Keepalive
Johan Sternerup [Thu, 9 Jul 2020 11:37:27 +0000 (13:37 +0200)]
conncheck: Only valid stun messages used for Keepalive

Previously, a STUN response for which there was no associated request
would be considered valid media input and as such could keep a dead
connection alive. If peer A was communicating with peer B and peer B got
disconnected, the keepalive mechanism in peer A should detect this.
However, a misbehaving STUN server could keep sending STUN responses to
peer A which would then be considered a valid communication between A
and B and thereby prevent the keepalive mechanism from shutting down the
connection.

Situation above refers to a stun message validated as
STUN_VALIDATION_UNMATCHED_RESPONSE. With this change only messages
validated as STUN_VALIDATION_SUCCESS may keep the connection alive.

3 years agoagent: Enable both UDP and TCP to the same TURN server
Johan Sternerup [Thu, 17 Sep 2020 14:20:05 +0000 (16:20 +0200)]
agent: Enable both UDP and TCP to the same TURN server

Previously if we enabled both UDP and TCP to the same TURN server, the
TCP connection would not work. What happened was that when traffic was
targeted at the TCP connection we would fail to route the traffic to
the right socket due to a too early jump out of the loop searching for
the socket. The search would stop when finding a TURN server matching
the address of the incoming message source. Thus, a UDP TURN server
with the same address as the TCP TURN server would effectively mean
that traffic got routed to a different stun agent that would complain
about receiving responses without matching requests.

3 years agocandidate: Hide the internal implementation from API
Olivier Crête [Fri, 22 May 2020 02:13:14 +0000 (22:13 -0400)]
candidate: Hide the internal implementation from API

This is slightly an API break, but it should never have been public.

3 years agoVersion 0.1.17 with tizen patch 53/241453/2 accepted/tizen_6.0_unified_hotfix tizen_6.0_hotfix accepted/tizen/6.0/unified/20201030.110054 accepted/tizen/6.0/unified/hotfix/20201102.234034 accepted/tizen/6.0/unified/hotfix/20201103.050554 accepted/tizen/unified/20200820.213428 submit/tizen/20200820.092250 submit/tizen_6.0/20201029.205502 submit/tizen_6.0_hotfix/20201102.192902 submit/tizen_6.0_hotfix/20201103.115102 tizen_6.0.m2_release
Hyunil [Thu, 20 Aug 2020 08:39:07 +0000 (17:39 +0900)]
Version 0.1.17 with tizen patch

remove doc from Makefile.am and configue.ac

Change-Id: If82a404c5c29e0481afa05396d71f1e8cdccfeec

3 years agoMerge branch 'upstream' into tizen 52/241452/1
Hyunil [Thu, 20 Aug 2020 08:35:41 +0000 (17:35 +0900)]
Merge branch 'upstream' into tizen

Change-Id: I64747e2043743986156f15d883a136c4fcbc0375

3 years agoImported Upstream version 0.1.17 50/241450/1 upstream/0.1.17
Hyunil [Thu, 20 Aug 2020 08:32:40 +0000 (17:32 +0900)]
Imported Upstream version 0.1.17

Change-Id: I4574844e0f8310d9f89f80a4315861ad87ef070d

3 years agoagent: Actually fail gathering on UDP port unavailability
Olivier Crête [Wed, 22 Jul 2020 20:23:09 +0000 (16:23 -0400)]
agent: Actually fail gathering on UDP port unavailability

This will make it fail if either our test of UDP port clash fails
or if the kernel rejects the new socket because there is a port clash.

Also include a unit test for this.

3 years agomeson: Remove duplicated entry
Olivier Crête [Tue, 18 Aug 2020 19:55:22 +0000 (15:55 -0400)]
meson: Remove duplicated entry

3 years agoIgnore interfaces in windows
Ami Perlmutter [Thu, 13 Aug 2020 11:34:50 +0000 (14:34 +0300)]
Ignore interfaces in windows

3 years agogitlab-ci: Use curl --data to make coverity happy
Olivier Crête [Mon, 10 Aug 2020 23:00:16 +0000 (19:00 -0400)]
gitlab-ci: Use curl --data to make coverity happy

3 years agoaddress: Use union
Olivier Crête [Mon, 10 Aug 2020 22:33:49 +0000 (18:33 -0400)]
address: Use union

This makes coverity happier.

3 years agoUse g_alloca instead of g_malloc_n in socket_send_messages
Lorenzo Miniero [Tue, 4 Aug 2020 13:53:42 +0000 (15:53 +0200)]
Use g_alloca instead of g_malloc_n in socket_send_messages

3 years agoChanged type of variable to signed
Lorenzo Miniero [Thu, 23 Jul 2020 16:33:57 +0000 (18:33 +0200)]
Changed type of variable to signed

3 years agoFixed wrong return value in socket_send_messages for n_messages=1
Lorenzo Miniero [Tue, 21 Jul 2020 13:30:32 +0000 (15:30 +0200)]
Fixed wrong return value in socket_send_messages for n_messages=1

3 years agoRefactored UDP socket_send_messages to use g_socket_send_messages
Lorenzo Miniero [Tue, 21 Jul 2020 10:31:06 +0000 (12:31 +0200)]
Refactored UDP socket_send_messages to use g_socket_send_messages

3 years agotests: Fix warning when building with newer GLib version
Olivier Crête [Wed, 22 Jul 2020 19:29:24 +0000 (15:29 -0400)]
tests: Fix warning when building with newer GLib version

3 years agoagent: Accept duplicated ports if no other option
Olivier Crête [Tue, 23 Jun 2020 21:32:39 +0000 (17:32 -0400)]
agent: Accept duplicated ports if no other option

Commit a04fa4d492 introduced a new feature to try to have a different port for every
local candidate, even if they are on different interfaces. This breaks setups where the
application really wants a specific port and sets a range of exactly 1 port or a very small range.
In that case, if we can't find non-duplicated ports, then we just go around again and skip that check,
but only if both ports are in the same stream and component. Otherwise, we fail the whole component!

3 years agocandidate: Make debug string functions public
Olivier Crête [Tue, 21 Jul 2020 23:35:42 +0000 (19:35 -0400)]
candidate: Make debug string functions public

Adds new public APIs, nice_candidate_type_to_string() and
nice_candidate_transport_to_string().

3 years agointerfaces: Fix code style for function declarations
Nirbheek Chauhan [Thu, 9 Jul 2020 17:27:34 +0000 (22:57 +0530)]
interfaces: Fix code style for function declarations

3 years agointerfaces: Fix fetching of interfaces on Win32
Nirbheek Chauhan [Thu, 9 Jul 2020 12:25:53 +0000 (17:55 +0530)]
interfaces: Fix fetching of interfaces on Win32

nice_interfaces_get_local_interfaces() was returning the hardware
device names of interfaces that have been seen in the past or could be
connected. It had no relation to the actual interfaces present on the
device. Perhaps this worked back in the XP days, but it is returning
garbage today.

Use GetAdapterAddresses(), and return the adapter friendly names as
the interface names. At the same time, update
nice_interfaces_get_ip_for_interface() to match.

Coincidentally, this also fixes UWP compatibility since GetIfTable and
GetIpAddrTable are not available when targeting UWP. They are only
available for desktop apps:

https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getiftable
https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getipaddrtable

3 years agointerfaces: Remove unused win32 code
Nirbheek Chauhan [Thu, 9 Jul 2020 12:25:08 +0000 (17:55 +0530)]
interfaces: Remove unused win32 code

3 years agointerfaces: Port to GetBestInterfaceEx for UWP compat
Nirbheek Chauhan [Thu, 9 Jul 2020 11:13:45 +0000 (16:43 +0530)]
interfaces: Port to GetBestInterfaceEx for UWP compat

Still prefer ipv4 addresses for backwards-compat. GetBestInterface is
not allowed when targeting UWP, so use GetBestInterfaceEx.

Also add some debug logging to ensure that the function is actually
running correctly.

3 years agointerfaces: Add debug logging to sockaddr_to_string
Nirbheek Chauhan [Thu, 9 Jul 2020 11:13:19 +0000 (16:43 +0530)]
interfaces: Add debug logging to sockaddr_to_string

Helps when you forgot to call WSAStartup, for instance.

3 years agoagent: Don't go haywire if only a partial message is available
Olivier Crête [Tue, 23 Jun 2020 22:26:31 +0000 (18:26 -0400)]
agent: Don't go haywire if only a partial message is available

Instead, collect all the pieces until it's complete.

3 years agostund: Use lowercase winsock2.h
Nirbheek Chauhan [Mon, 15 Jun 2020 14:24:21 +0000 (19:54 +0530)]
stund: Use lowercase winsock2.h

Windows ships with `WinSock2.h` but mingw ships with `winsock2.h`.
This is fine on Windows because files are case-insensitive, but on
Linux it causes the compiler to not find the header.

All other #includes are lowercase, so just use that.

3 years agomeson: Fix typos in crypto-library detection
Nirbheek Chauhan [Mon, 15 Jun 2020 22:24:28 +0000 (03:54 +0530)]
meson: Fix typos in crypto-library detection

3 years agorand: Use crypto libs instead of CryptGenRandom()
Nirbheek Chauhan [Mon, 15 Jun 2020 22:19:14 +0000 (03:49 +0530)]
rand: Use crypto libs instead of CryptGenRandom()

We will always have either openssl or gnutls, which are better sources
for random nonces. Also, CryptGenRandom is deprecated API that's not
available on WinRT/UWP.

3 years agoApply ASLR to stund and stunbdc of stun/tools 12/236112/3 accepted/tizen/unified/20200616.040956 submit/tizen/20200615.034320
Hyunil [Mon, 15 Jun 2020 03:18:23 +0000 (12:18 +0900)]
Apply ASLR to stund and stunbdc of stun/tools

Change-Id: Ieb4ad8f0098329ff6145828fc0f1ec617e85f6f6
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
4 years agoconncheck: add a check to move into the ready state after a pair failed
Fabrice Bellet [Wed, 20 May 2020 12:25:17 +0000 (14:25 +0200)]
conncheck: add a check to move into the ready state after a pair failed

This patch tries to move the component state from connected to ready in
places where a pair may fail. Consequently, the final check done after
the expiration of the idle timeout can be removed, assuming that
transitions are done as soon as they occur.

The only place where such a situation has been observed in a real world
stress test is a 401 unauthorized stun error received in
priv_map_reply_to_conn_check_request(), when the conncheck contains a
local and a remote candidate, both of type host, with an identical IP
address and port number (two boxes with a private network using the same
subnet). In such a case, a stun request to the remote candidate will
reach the local candidate instead, and will logically fail.

4 years agogitignore: Remove in-tree built files
Olivier Crête [Fri, 22 May 2020 22:18:15 +0000 (18:18 -0400)]
gitignore: Remove in-tree built files

Meson always does out of tree builds

4 years agoagent: Remove test that is not required
Olivier Crête [Fri, 22 May 2020 22:07:30 +0000 (18:07 -0400)]
agent: Remove test that is not required

The stream and component pointers are always valid there.

4 years agogitlab-ci: Put image at the top
Olivier Crête [Fri, 22 May 2020 21:35:14 +0000 (17:35 -0400)]
gitlab-ci: Put image at the top

4 years agogitlab-ci: Rename tasks to not say meson
Olivier Crête [Fri, 31 Jan 2020 16:31:48 +0000 (16:31 +0000)]
gitlab-ci: Rename tasks to not say meson

They're always meson now.

4 years agoRemove autotools build
Tim-Philipp Müller [Fri, 31 Jan 2020 16:31:48 +0000 (16:31 +0000)]
Remove autotools build

Remove dist check on the CI, since it doesn't really
add anything in the Meson case (tarball is based
on files checked into git and srcdir != builddir).

4 years agoversion 0.1.17.1
Olivier Crête [Fri, 22 May 2020 19:58:01 +0000 (15:58 -0400)]
version 0.1.17.1

4 years agoversion 0.1.17 0.1.17
Olivier Crête [Fri, 22 May 2020 19:41:19 +0000 (15:41 -0400)]
version 0.1.17

4 years agomeson: Remove Wextra from options
Olivier Crête [Fri, 22 May 2020 19:32:22 +0000 (15:32 -0400)]
meson: Remove Wextra from options

meson already sets it on warning_level >= 2

4 years agomeson: Actually make meson generate the compat Makefile
Olivier Crête [Fri, 22 May 2020 03:09:19 +0000 (23:09 -0400)]
meson: Actually make meson generate the compat Makefile

The previous patch didn't get triggered

4 years agoMakefile.am: Add dist meson friendly test
Olivier Crête [Fri, 22 May 2020 19:51:42 +0000 (15:51 -0400)]
Makefile.am: Add dist meson friendly test

4 years agomeson: Make gtkdoc-check work with older gtk-doc
Olivier Crête [Fri, 22 May 2020 14:36:52 +0000 (10:36 -0400)]
meson: Make gtkdoc-check work with older gtk-doc

Older gtkdoc versions expect to find a Makefile, so generate
a fake one with the information it wants.

4 years agomeson: Run gtkdoc-check
Olivier Crête [Fri, 22 May 2020 03:09:19 +0000 (23:09 -0400)]
meson: Run gtkdoc-check

4 years agogitlab-ci: Disable gtkdoc when doing valgrind
Olivier Crête [Fri, 22 May 2020 18:35:59 +0000 (14:35 -0400)]
gitlab-ci: Disable gtkdoc when doing valgrind

4 years agogitignore: Don't ignore libnice-docs.txt
Olivier Crête [Fri, 22 May 2020 03:09:01 +0000 (23:09 -0400)]
gitignore: Don't ignore libnice-docs.txt

4 years agotest-new-trickle: No need to be connected to receive data
Olivier Crête [Fri, 22 May 2020 15:17:28 +0000 (11:17 -0400)]
test-new-trickle: No need to be connected to receive data

4 years agoconncheck: do not always remove pair in triggered check list
Fabrice Bellet [Tue, 19 May 2020 11:58:55 +0000 (13:58 +0200)]
conncheck: do not always remove pair in triggered check list

This patch reenables an interesting side effect that existed before
commit 263c0903, when the state of a pair state in the triggered check
list was changed to in-progress. Such "triggered" pairs with this state
were selectively pruned from the conncheck list according to their
priority in priv_prune_pending_checks(), meaning that pairs with a high
priority were conserved, and quickly rechecked.

Retrospectively, I suspect that this side effect was the initial
motivation for changing the state of a "triggered" pair.

Commit 263c0903 disabled that behaviour, for the sake of clarity, but it
seems important to restore it, because these "triggered" pairs are often
retriggered for a good reason, and frequently lead to a nominated pair.
And loosing the opportunity to nominate a pair may be critical in
controlled role when the peer agent is in aggressive nomination mode.

4 years agoagent: Don't hold hard ref while removing stream
Olivier Crête [Fri, 8 May 2020 23:08:20 +0000 (19:08 -0400)]
agent: Don't hold hard ref while removing stream

The timeout has a weak ref that should be enough.

4 years agovalgrind supp: Add updated gllibc suppressions
Olivier Crête [Wed, 13 May 2020 21:52:18 +0000 (17:52 -0400)]
valgrind supp: Add updated gllibc suppressions

4 years agoconncheck: clear the retransmit flag when the stun list is empty
Fabrice Bellet [Mon, 18 May 2020 12:16:12 +0000 (14:16 +0200)]
conncheck: clear the retransmit flag when the stun list is empty

This patch ensures that the retransmit flag is more tightly in sync with
the stun transaction list, by now clearing it when the list becomes
empty. It makes the code a bit more readable by dropping some cases. In
a couple of places, the retransmit flag was also used as a way to
compare the priority of a pair and the priority of the selected pair.

4 years agoconncheck: add a missing component state transition
Fabrice Bellet [Sun, 17 May 2020 21:08:12 +0000 (23:08 +0200)]
conncheck: add a missing component state transition

When reactivating a high priority pair, we have to change back the
component state from ready to connected, since there is a new pair to be
tested.

The case of the succeeded pair is also a bit simplified, the invocation
of the function conn_check_update_check_list_state_for_ready() to
complete the ready - connected - ready flip-flop transition is not
required for the trickle test any longer.

4 years agoconncheck: remove a redundant test
Fabrice Bellet [Sun, 17 May 2020 21:06:37 +0000 (23:06 +0200)]
conncheck: remove a redundant test

This test is redundant with the previous one.

4 years agoconncheck: do not change the pair state in triggered check queue
Fabrice Bellet [Sun, 17 May 2020 20:59:48 +0000 (22:59 +0200)]
conncheck: do not change the pair state in triggered check queue

We prefer to not change the state of the pair, when it is added to the
triggered check queue. Previously its state was changed to in-progress,
which was a bit misleading, as it somewhat anticipated a future state.

4 years agoconncheck: handle the consequence when a pair is not created
Fabrice Bellet [Sun, 17 May 2020 20:51:21 +0000 (22:51 +0200)]
conncheck: handle the consequence when a pair is not created

Since commit fcd6bc86 a pair is not always created, when its priority
is lower than the selected pair priority. We have to deal with this
possibility when calling the function priv_add_new_check_pair().

More precisely, the component state update really requires the addition
of a new pair.

4 years agoconncheck: rework the stun requests ordering per timer tick
Fabrice Bellet [Tue, 12 May 2020 18:13:18 +0000 (20:13 +0200)]
conncheck: rework the stun requests ordering per timer tick

With this patch, we merge the two variables stun_sent and
keep_timer_going. The three functions that are a possible source of a
new stun request returns a boolean value stating if a request has been
sent.  The semantic of keep_timer_going can now be deduced from
stun_sent and from the result of priv_conn_check_stream_nominate().

The trick that makes this merge possible is to repurpose the return
value of priv_conn_check_tick_stream(), because keep_timer_going set
when the conncheck list contains in-progress pairs in this function is
redundant with the same check later in function
priv_conn_check_tick_stream_nominate().

4 years agoconncheck: explicitely order the type of stun requests per timer tick
Fabrice Bellet [Mon, 11 May 2020 10:05:14 +0000 (12:05 +0200)]
conncheck: explicitely order the type of stun requests per timer tick

With this patch, we try to make more explicit the process order between
the different types of stun requets, according that only one request is
sent per callback timer tick, ie every 20ms, to respect the stun pacing
of the spec. We implement the follow priority:

 * triggered checks
 * stun retransmissions
 * ordinary checks

In a concrete case, while a stream has stun requests related to
triggered checks to be sent, all other stun transactions are delayed to
the next timer ticks.

The goal of this patch is to make this priority explicit, and more
easily swappable if needed. Triggered checks have more probability to
succeed than stun retransmissions, this is the reason why they are
handled before. Ordinary checks on the contrary can be performed on a
lower priority basis, after all other stun requests.

The problem that can be sometime observed with a large number of stun
transactions is that stun retransmissions may suffer from a delay after
they have reached their deadline. This delay should remain small thanks
to the design of the initial retransmission timer (RTO), that takes into
account the overall number of scheduled stun requests. It allows all
stun requests to be sent and resent at a predefined "pacing" frequency
without much extra delay.

This ordering not perfect, because stun requests of a given type are
examinated per-stream, by looking at the first stream before the others,
so it introduces a natural priority for the first stream.

4 years agogitlab-ci: Actually gnore mingw failure
Olivier Crête [Wed, 13 May 2020 23:47:11 +0000 (19:47 -0400)]
gitlab-ci: Actually gnore mingw failure

4 years agogitlab-ci: Ignore mingw failure for now
Olivier Crête [Wed, 13 May 2020 23:47:11 +0000 (19:47 -0400)]
gitlab-ci: Ignore mingw failure for now

4 years agogitlab-ci: Upload build logs as artifacts on Win
Olivier Crête [Tue, 12 May 2020 20:04:25 +0000 (16:04 -0400)]
gitlab-ci: Upload build logs as artifacts on Win

4 years agoREADME: Update for meson
Olivier Crête [Fri, 8 May 2020 23:14:43 +0000 (19:14 -0400)]
README: Update for meson

Also, update the RFC numbers that are implemented.

4 years agoconncheck: fix try-alternate on tcp turn sockets
Fabrice Bellet [Sun, 3 May 2020 15:39:09 +0000 (17:39 +0200)]
conncheck: fix try-alternate on tcp turn sockets

In OC2007R2 compatibility mode, we observed the behaviour of a skype
turn server, when returning code 300 (try-alternate) stun error on its
tls connections. This value is returned apparently when the turn server
is overloaded already.

We noticed that the actual code in priv_handle_turn_alternate_server()
cannot handle a non-udp turn server, because a tcp one would require
to create a new socket.

But, even when creating such a new socket stack (tcp-bsd socket +
pseudossl socket), libnice still fails to establish a new connection to
the alternate server on port 443, in a very systematic way. I'm not sure
whether this problem is specific to this skype server infrastructure
(the skype client fails in a similar way). Anyway, this code path works
as expected with a non-microsoft turn server (tested with coturn).

4 years agoagent: fix tcp connection to turn servers
Fabrice Bellet [Wed, 6 May 2020 12:09:08 +0000 (14:09 +0200)]
agent: fix tcp connection to turn servers

A previous commit broke the logic used to start a discovery request for
tcp turn servers. The ambiguity came from the distinction between the
type of the turn server (turn->type), the compatibility of the
transport of the local base candidate (turn_tcp), and the reliability
of the underlying tcp socket (reliable_tcp).

reliable_tcp indicates whether the turn allocate request should be
"framed" in a tcp packet, according to RFC 4571. This is required in
OC2007R2 only.

This commit also puts the setup of the tcp turn socket in a separate
function, because such setup is also required when handling
try-alternate (code 300) stun errors on these tcp sockets, where we have
to setup a new connection to another tcp turn server.

4 years agoconncheck: ignore refreshes for tls turn server for OC2007R2
Fabrice Bellet [Thu, 7 May 2020 19:24:09 +0000 (21:24 +0200)]
conncheck: ignore refreshes for tls turn server for OC2007R2

Relay candidates obtained from TLS turn server don't have to be
refreshed in OC2007R2 compatibility mode.

4 years agoconncheck: send udp turn refreshes in oc2007r2 compatibility mode too
Fabrice Bellet [Sun, 3 May 2020 15:35:22 +0000 (17:35 +0200)]
conncheck: send udp turn refreshes in oc2007r2 compatibility mode too

4 years agomeson: Move glib wrap to download
Olivier Crête [Fri, 8 May 2020 18:31:59 +0000 (14:31 -0400)]
meson: Move glib wrap to download

4 years agoconncheck: make a single ordinary check per callback
Fabrice Bellet [Mon, 20 Apr 2020 21:21:17 +0000 (23:21 +0200)]
conncheck: make a single ordinary check per callback

This is more friendly with stun pacing.

4 years agoconncheck: improve places where the conncheck list is dumped
Fabrice Bellet [Thu, 16 Apr 2020 17:57:27 +0000 (19:57 +0200)]
conncheck: improve places where the conncheck list is dumped

4 years agoagent: stay in aggressive mode after stun requests have been sent
Fabrice Bellet [Thu, 23 Apr 2020 15:12:41 +0000 (17:12 +0200)]
agent: stay in aggressive mode after stun requests have been sent

This patch updates the previous commit "agent: stay in aggressive mode
after conncheck has started", by accepting to switch from aggressive to
regular mode, while no stun request has been sent. It gives the agent
some extra delay to still accept remote tcp candidates, after its state
already changed from gathering to connecting.

4 years agostun: update timer timeout and retransmissions
Fabrice Bellet [Tue, 14 Apr 2020 15:25:24 +0000 (17:25 +0200)]
stun: update timer timeout and retransmissions

This patch updates the stun timing constants and provides the rationale
with the choice of these new values, in the context of the ice
connection check algorithm.

One important value during the discovery state is the combination of the
initial timeout and the number of retransmissions, because this state
may complete after the last stun discovery binding request has timed
out. With the combination of 500ms and 3 retransmissions, the discovery
state is bound to 2000ms to discover server reflexive and relay
candidates.

The retransmission delay doubles at each retransmission except for the
last one. Generally, this state will complete sooner, when all
discovery requests get a reply before the timeout.

Another mechanism is used during the connection check, where an stun
request is sent with an initial timeout defined by :

   RTO = MAX(500ms, Ta * (number of in-progress + waiting pairs))
   with Ta = 20ms

The initial timeout is bounded by a minimum value, 500ms, and scales
linearly depending of the number of pairs on the way to be emited. The
same number of retransmissions than in the discovery state in used
during the connection check. The total time to wait for a pair to fail
is then RTO + 2*RTO + RTO = 4*RTO with 3 retransmissions.

On a typical laptop setup, with a wired and a wifi interface with
IPv4/IPv6 dual stack, a link-local and a link-global IPv6 address, a
couple a virtual addresses, a server-reflexive address, a turn relay
one, we end up with a total of 90 local candidates for 2 streams and 2
components each.  The connection checks list includes up to 200 pairs
when tcp pairs are discarded, with :

  <33 in-progress and waiting pairs in 50% cases (RTO = 660ms),
  <55 in-progress and waiting pairs in 90% cases (RTO = 1100ms),
  and up to 86 in-progres and waiting pairs (RTO = 1720ms)

The number of retransmission of 3 seems to be quite robust to handle
sporadic packets loss, if we consider for example a typical packet loss
frequency of 1% of the overall packets transmitted.

And a relatevely large initial timeout is interesting because it reduces
the overall network overhead caused by the stun requests and replies,
mesured around 3KB/s during a connection check with 4 components.

Finally, the total time to wait until all retransmissions have completed
and have timed out (2000ms with an initial timeout of 500ms and 3
retransmissions) gives a bound to the worst network latency we can
accept, when no packet is lost on the wire.

4 years agoconncheck: update the unfreeze method for RFC8445
Fabrice Bellet [Mon, 13 Apr 2020 16:03:36 +0000 (18:03 +0200)]
conncheck: update the unfreeze method for RFC8445

The way pairs are unfrozen between RFC5245 and RFC8445 changed a bit,
and made the code much more simple. Previously pairs were unfrozen "per
stream", not they are unfrozen "per foundation". The principle of the
priv_conn_check_unfreeze_next function is now to unfreeze one and only
one frozen pair per foundation, all components and streams included.
The function is now idemporent: calling it when the connchecks still
contains waiting pairs does nothing.

4 years agoconncheck: update stun timer timeout for RFC8445
Fabrice Bellet [Mon, 13 Apr 2020 15:54:33 +0000 (17:54 +0200)]
conncheck: update stun timer timeout for RFC8445

The new version of the RFC suppressed the difference between reliable
and not reliable maximum value for RTO. We choose to keep the value of
100ms that we used previously, which is lower that the recommended
value, but could be overriden most of the time, when a significant
number of pairs are handled.

We also compute exactly the number of in-progress and waiting
pairs for all streams of the agent, without relying on the value
per-stream, multiplied by the number of active streams.

4 years agoconncheck: another rare case of local tcp active candidate matching
Fabrice Bellet [Tue, 5 May 2020 15:09:47 +0000 (17:09 +0200)]
conncheck: another rare case of local tcp active candidate matching

An inbound stun request may come on a tcp pair, whose tcp-active socket
has just been created and connected (the local candidate port is zero),
but has not caused the creation of a discovered peer-reflexive local
candidate (with a non-zero port). This inbound request is stored in an
early icheck structure to be replayed later. When being processed after
remote creds have been received, we have to find which local candidate
it belongs to, by matching with the address only, without the port.

4 years agoconncheck: socket reliability should not change the conncheck behaviour
Fabrice Bellet [Sun, 3 May 2020 15:26:48 +0000 (17:26 +0200)]
conncheck: socket reliability should not change the conncheck behaviour

An inbound STUN request on a pair having another STUN request already
inflight already should generate to new triggered check, no matter the
type of the underlying socket.

4 years agoconncheck: inbound stun on tcp passive pairs should trigger a check
Fabrice Bellet [Sun, 3 May 2020 15:22:42 +0000 (17:22 +0200)]
conncheck: inbound stun on tcp passive pairs should trigger a check

An inbound stun request on a newly discovered pair should trigger a
conncheck in the reverse direction, and not promote the pair directly in
state succeeded. This is particulary required if the agent is in
aggressive controlling mode.

4 years agoconncheck: simplify the test to find a matching local candidate
Fabrice Bellet [Mon, 20 Apr 2020 21:29:49 +0000 (23:29 +0200)]
conncheck: simplify the test to find a matching local candidate

Since we keep a relation between a succeeded and its discovered pair, we
can just test for the socket associated to a given pair, and eventually
follow the link to the parent succeeded pair.

4 years agoconncheck: properly select tcp-active discovered candidate
Fabrice Bellet [Mon, 20 Apr 2020 21:24:21 +0000 (23:24 +0200)]
conncheck: properly select tcp-active discovered candidate

Some tcp-active discovered peer-reflexive local candidates may only be
recognised by their local socket, if they have the same address and same
port. It may happen when a nat generates an identical mapping from two
different base local candidates.

4 years agostun: set delay in retransmission instead of adding it
Fabrice Bellet [Sun, 5 Apr 2020 19:02:47 +0000 (21:02 +0200)]
stun: set delay in retransmission instead of adding it

We may have situation when stun_timer_refresh is called with a
significant delay after the current deadline. In the actual situation,
this delay is just included to the computation of the new deadline of the
next stun retransmission. We think this may lead to unfair situations,
where the next deadline may be too short, just to compensate the first
deadline that was too long.

For example, if a stun request is scheduled with a delay of
200ms for the 2nd transmission, and 400ms for the 3rd transmission,
if stun_timer_remainder() is called 300ms after the start of the
timer, the second delay will last only 300ms, instead of 400ms.

4 years agodiscovery: ensure port number uniqueness agent-wide
Fabrice Bellet [Thu, 16 Apr 2020 18:01:25 +0000 (20:01 +0200)]
discovery: ensure port number uniqueness agent-wide

The port number must be different for all local host candidates, not
just in the same component, but across all components and all streams.
A candidate ambiguity between a host local host and an identical server
reflexive candidate have more unwanted consequences when it concerns two
different components, because an inbound stun request may be associated
to a wrong component.

4 years agointerfaces: Use the private address detector from NiceAddress
Olivier Crête [Wed, 6 May 2020 04:01:37 +0000 (00:01 -0400)]
interfaces: Use the private address detector from NiceAddress

4 years agoaddress: Make the private IP address detector more complete
Olivier Crête [Wed, 6 May 2020 04:00:36 +0000 (00:00 -0400)]
address: Make the private IP address detector more complete

Also adds a unit test

Fixes #67

4 years agoconncheck: fix some missing loop exit cases
Fabrice Bellet [Sun, 3 May 2020 16:01:35 +0000 (18:01 +0200)]
conncheck: fix some missing loop exit cases

The refresh list may be modified while being iterated

4 years agoconncheck: add a couple of switch case fallthroughs
Fabrice Bellet [Sun, 19 Apr 2020 15:16:05 +0000 (17:16 +0200)]
conncheck: add a couple of switch case fallthroughs

4 years agoconncheck: merge two cascaded conditions
Fabrice Bellet [Sat, 29 Feb 2020 10:02:01 +0000 (11:02 +0100)]
conncheck: merge two cascaded conditions

4 years agointerfaces: Use union for sockaddr/sockaddr_in
Olivier Crête [Wed, 6 May 2020 01:59:38 +0000 (21:59 -0400)]
interfaces: Use union for sockaddr/sockaddr_in

This makes clang happy
Fixes #100

4 years agoconncheck: honor the retransmit flag in case of role conflict
Fabrice Bellet [Mon, 13 Apr 2020 15:46:13 +0000 (17:46 +0200)]
conncheck: honor the retransmit flag in case of role conflict

This other rare situation happens when a role conflict is detected by an
stun reply message, on a component that already has a nominated pair
with a higher priority. In that case, the retransmit flag should be
honored, and the pair with "role conflict" should not be retransmitted.

4 years agoconncheck: add missing cases when pruning pending checks
Fabrice Bellet [Thu, 9 Apr 2020 14:47:17 +0000 (16:47 +0200)]
conncheck: add missing cases when pruning pending checks

When pruning pending checks (after at least one nominated pair has been
obtained), some supplementary cases need to be handled, to ensure that
the property "all pairs and only the pairs having a higher priority than
the nominated pair should have the stun retransmit flag set" remains
true during the whole conncheck:

- a pair "not to be retransmitted" must be removed from the triggered check
  list (because a triggered check would create a new stun request, that
  would defacto ignore the retransmit flag)

- an in-progress pair "not to be retransmitted", for which no stun
  request has been sent (p->stun_transactions == NULL, a transient
  state) must be removed from the conncheck list, just like a waiting
  pair.

- a failed pair must have its flag "retransmit" updated too, just like
  another pair, since a failed pair could match an inbound check, and
  generate a triggered check, based on retransmit flag value : ie only
  if this pair has a chance to become a better nominated pair. See
  NICE_CHECK_FAILED case in priv_schedule_triggered_check().

4 years agoconncheck: toggle the retransmit flag when pruning pending checks
Fabrice Bellet [Wed, 8 Apr 2020 15:24:05 +0000 (17:24 +0200)]
conncheck: toggle the retransmit flag when pruning pending checks

The function conn_check_update_retransmit_flag() that was introduced to
reenable the retransmit flag on pairs with higher priority than the
nominated one can be merged in priv_prune_pending_checks(), and its
invocation replaced by conn_check_update_check_list_state_for_ready().

The function priv_prune_pending_checks() can also be tweaked to use
the component selected pair priority, instead of getting it from
the checklist. This function is called when at least one nominated pair
exists, so selected_pair is this nominated pair.

4 years agoconncheck: discard new pair creation when priority is too low
Fabrice Bellet [Wed, 8 Apr 2020 15:16:30 +0000 (17:16 +0200)]
conncheck: discard new pair creation when priority is too low

It is possible to ignore the creation of a new pair whose priority is
lower than the priority of the selected pair, ie the nominated pair with
the highest priority. Such pair would be discarded by a call to
prune_pending_checks(), and if checked, there state would break the
assumption that all pairs with lower priority than the nominated pair
are not retransmitted.

4 years agoconncheck: optimize pending checks pruning
Fabrice Bellet [Sun, 5 Apr 2020 20:13:27 +0000 (22:13 +0200)]
conncheck: optimize pending checks pruning

We use the property that the conncheck list is ordered by
pairs priorities, so we don't have to iterate twice.