platform/upstream/libnice.git
4 years agointerfaces: fix network to host conversion for private addresses
Fabrice Bellet [Thu, 13 Feb 2020 15:09:31 +0000 (16:09 +0100)]
interfaces: fix network to host conversion for private addresses

4 years agotests: fix local preference based on interface rank in list
Fabrice Bellet [Wed, 12 Feb 2020 15:29:24 +0000 (16:29 +0100)]
tests: fix local preference based on interface rank in list

The local preference of UDP candidates is (now) determined by the
position of the IP address in the list returned by
nice_interfaces_get_local_ips().

4 years agocandidate: fix local preferences of udp candidates
Fabrice Bellet [Wed, 12 Feb 2020 14:40:52 +0000 (15:40 +0100)]
candidate: fix local preferences of udp candidates

udp candidates failed to call nice_candidate_ip_local_preferences()
and were all given the same local preference priority.

4 years agoagent: enforce turn deallocate stun pacing
Fabrice Bellet [Wed, 19 Feb 2020 20:11:59 +0000 (21:11 +0100)]
agent: enforce turn deallocate stun pacing

In a way similar to other stun packets, we add a delay of Timer TA
(default is 20 ms) between each refresh candidate processing.

4 years agoconncheck: enforce keepalives stun requests pacing
Fabrice Bellet [Tue, 18 Feb 2020 13:01:37 +0000 (14:01 +0100)]
conncheck: enforce keepalives stun requests pacing

Keepalives STUN requests should not be sent for each local host
candidate or each selected candidate in the single loop, but with a pacing
of at least Timer TA (default is 20 ms) between each request. It remains
compatible with a pause of Timer TR (default is 20 seconds) between each
keepalives batch.

4 years agodiscovery: enforce stun requests pacing
Fabrice Bellet [Tue, 18 Feb 2020 12:58:09 +0000 (13:58 +0100)]
discovery: enforce stun requests pacing

Only a single STUN request should be sent per discovery tick to enforce
an overall pacing of 20ms per default between two STUN requests.

4 years agointerfaces: ignore only interfaces we really want to (II)
Stefan Becker [Fri, 28 Feb 2020 18:49:21 +0000 (20:49 +0200)]
interfaces: ignore only interfaces we really want to (II)

This improves commit bd4b47813844aa0e68e9074b3ac516c383ca8bab

There is a second place where this fix is needed.

4 years agogitlab-ci: Disable trigger for now
Olivier Crête [Thu, 13 Feb 2020 21:19:03 +0000 (16:19 -0500)]
gitlab-ci: Disable trigger for now

4 years agogitlab-ci: Make the documentation acceptable for the website
Olivier Crête [Fri, 10 May 2019 05:23:39 +0000 (01:23 -0400)]
gitlab-ci: Make the documentation acceptable for the website

4 years agoconncheck: Connection check reply must have a remote candidate
Jakub Adam [Thu, 13 Feb 2020 19:33:18 +0000 (20:33 +0100)]
conncheck: Connection check reply must have a remote candidate

Ensure that a conncheck reply is coming from an address and port of a
known remote candidate and that the type of incoming socket matches that
candidate's transport.

Attemps to fix a Coverity issue in which no matching remote_candidate
gets found for a connectivity reply in conn_check_handle_inbound_stun()
(apparently due to transport mismatch), yet
priv_map_reply_to_conn_check_request() still successfully matches it
with a previous request.

4 years agoconncheck: Typo fix
Jakub Adam [Thu, 13 Feb 2020 18:59:39 +0000 (19:59 +0100)]
conncheck: Typo fix

4 years agoconncheck: display priorities in debug by spliting their values
Fabrice Bellet [Sat, 8 Feb 2020 21:00:57 +0000 (22:00 +0100)]
conncheck: display priorities in debug by spliting their values

We display 32-bit candidate priorities in hexadecimal to identify each
8-bit-aligned field more easily: type preference, local preference, and
component id. We display 64-bit pair priority by splitting their local
and remote part. See RFC-8445, section 5.1.2.1.  "Recommended Formula",
and section 6.1.2.3. "Computing Pair Priority and Ordering Pairs".

4 years agocandidate: strip link-local ipv6 scope in local preference
Fabrice Bellet [Thu, 13 Feb 2020 15:11:00 +0000 (16:11 +0100)]
candidate: strip link-local ipv6 scope in local preference

This patch makes IPv6 link-local addresses obtain a unique ice
local preference when computing their priority, by stripping the
"%<interfacename>" added to them by getnameinfo(). Previously, all
these addresses obtained the same preference value, since the whole
local ips list was checked without finding a match.

4 years agogitlab: Also push to coverity on manual builds
Olivier Crête [Thu, 13 Feb 2020 00:54:49 +0000 (19:54 -0500)]
gitlab: Also push to coverity on manual builds

4 years agostun usage turn: Check return value as is done elsewhere
Olivier Crête [Thu, 13 Feb 2020 00:47:16 +0000 (19:47 -0500)]
stun usage turn: Check return value as is done elsewhere

4 years agoudp-bsd: Check all return value
Olivier Crête [Thu, 13 Feb 2020 00:45:32 +0000 (19:45 -0500)]
udp-bsd: Check all return value

Errors found by coverity

4 years agostun test: Check return value as is done elsewhere
Olivier Crête [Thu, 13 Feb 2020 00:41:45 +0000 (19:41 -0500)]
stun test: Check return value as is done elsewhere

4 years agoconncheck: Pass arguments in the right order
Olivier Crête [Thu, 13 Feb 2020 00:19:45 +0000 (19:19 -0500)]
conncheck: Pass arguments in the right order

The order of the passed arguments doesn't match the prototype of the
function. We exchange the local and remote candidates.

4 years agoudp-udp: Make coverity happy by giving it the whole union
Olivier Crête [Thu, 13 Feb 2020 00:16:00 +0000 (19:16 -0500)]
udp-udp: Make coverity happy by giving it the whole union

4 years agogitlab-ci: Build coverity using meson
Olivier Crête [Wed, 12 Feb 2020 23:41:27 +0000 (18:41 -0500)]
gitlab-ci: Build coverity using meson

4 years agoagent: refactor conncheck update_selected_pair
Fabrice Bellet [Tue, 11 Feb 2020 12:20:10 +0000 (13:20 +0100)]
agent: refactor conncheck update_selected_pair

4 years agoagent: update the selected pair priority when foundation changes
Fabrice Bellet [Sat, 8 Feb 2020 18:33:30 +0000 (19:33 +0100)]
agent: update the selected pair priority when foundation changes

The component selected pair priority may have its priority modified
if the foundation of its remote candidate changes. This update needs
to be recorded, even if its not signalled, since this value is used
in the conncheck in priv_update_selected_pair().

4 years agoagent: make code indentation a bit more homogeneous
Fabrice Bellet [Fri, 7 Feb 2020 09:50:04 +0000 (10:50 +0100)]
agent: make code indentation a bit more homogeneous

4 years agoagent: verify the best nominated pair after priorities recalculation
Fabrice Bellet [Fri, 7 Feb 2020 08:17:46 +0000 (09:17 +0100)]
agent: verify the best nominated pair after priorities recalculation

When we get a set_remote_candidate late after the start of the
conncheck, some remote candidates type may change from peer-reflexive
to server-reflexive. This required a recalculation of the foundations
and of the priorities of the related pairs.

This recalculation may change the pairs ordering in the conncheck list:
a srflx:prflx pair becoming a srflx:srflx pair will have a lower
priority (RFC 8445, section 5.1.2.1 "Recommended Formula", "the type
preference for peer-reflexive candidates MUST be higher than that of
server-reflexive candidates.")

This recalculation is required to maintain the same pairs ordering in
both agent.

But in some cases, in aggressive nomination mode, this may also change
the selected pair, if this recalculation changed the highest priority
pair with the nominated flag.

4 years agoconncheck: send keepalive for candidates until connected state
Fabrice Bellet [Sun, 9 Feb 2020 20:49:23 +0000 (21:49 +0100)]
conncheck: send keepalive for candidates until connected state

We can start sending keepalive stun request for the selected pair, and
stop sending keepalive for candidates as soon as the conncheck reaches
state connected and not ready.

4 years agoconncheck: fix peer-reflexive priority in discovered pair
Fabrice Bellet [Sun, 9 Feb 2020 20:45:55 +0000 (21:45 +0100)]
conncheck: fix peer-reflexive priority in discovered pair

The peer-reflexive priority used in the STUN request is copied from the
parent succeeded pair to the discovered pair. This value is not required
for discovered pair, that won't emit stun requests themselves, but may
be used when such pair becomes the selected pair, and when keepalive
stun are emitted, using the sockptr and prflx_priority values from the
succeeded pair.

4 years agoconncheck: update peer-reflexive priority of the selected pair
Fabrice Bellet [Sat, 8 Feb 2020 21:02:18 +0000 (22:02 +0100)]
conncheck: update peer-reflexive priority of the selected pair

4 years agoconncheck: do not create a pair from peer-reflexive local candidate
Fabrice Bellet [Fri, 7 Feb 2020 08:09:08 +0000 (09:09 +0100)]
conncheck: do not create a pair from peer-reflexive local candidate

The usual case when forming the initial conncheck list from local and
remote candidates is to discard server-reflexive local candidates, since
the agent can not send requests directly from these candidates. But it
also may happen, when the remote candidates are received late after the
beginning of the conncheck, that we also have discovered peer-reflexive
local candidates, that must be discarded as well. See RFC 8445, section
6.1.2.4 "Pruning the Pairs".

4 years agoconncheck: prune oversized conncheck list based on pair state
Fabrice Bellet [Mon, 10 Feb 2020 20:33:03 +0000 (20:33 +0000)]
conncheck: prune oversized conncheck list based on pair state

Removing lower-priority pairs to keep the conncheck list under a fixed
size (RFC 8445, sect 6.1.2.5) may accidently remove pairs that we want
to preserve, like succeeded and discovered pairs. We choose to only
remove pairs that are not engaged yet in the connection check
processing, those in frozen state.

Fixes #95

4 years agointerfaces: use fallback if getifaddrs failed
sergey radionov [Sun, 2 Feb 2020 09:06:31 +0000 (16:06 +0700)]
interfaces: use fallback if getifaddrs failed

fix #99

4 years agotest-thread: Increase timeout
Olivier Crête [Thu, 6 Feb 2020 21:43:12 +0000 (16:43 -0500)]
test-thread: Increase timeout

4 years agotest-io-stream-common: Remove io_stream pointer when removing stream
Olivier Crête [Thu, 6 Feb 2020 21:41:23 +0000 (16:41 -0500)]
test-io-stream-common: Remove io_stream pointer when removing stream

4 years agogitlab-ci: No longer allow meson test failures
Olivier Crête [Thu, 6 Feb 2020 21:37:50 +0000 (16:37 -0500)]
gitlab-ci: No longer allow meson test failures

4 years agotest-send-recv: Change timeout to 150s
Olivier Crête [Thu, 6 Feb 2020 21:30:34 +0000 (16:30 -0500)]
test-send-recv: Change timeout to 150s

4 years agotests: Make iostream test termination more reliable
Olivier Crête [Thu, 6 Feb 2020 20:21:50 +0000 (15:21 -0500)]
tests: Make iostream test termination more reliable

4 years agotest-io-common: Abort on error
Olivier Crête [Thu, 6 Feb 2020 02:12:11 +0000 (21:12 -0500)]
test-io-common: Abort on error

4 years agogitlab-ci: Run meson tests in debug setup
Olivier Crête [Thu, 6 Feb 2020 01:38:32 +0000 (20:38 -0500)]
gitlab-ci: Run meson tests in debug setup

This setup stores more debug info

4 years agotest-send-recv: Write in a loop until blocked
Olivier Crête [Thu, 6 Feb 2020 01:15:28 +0000 (20:15 -0500)]
test-send-recv: Write in a loop until blocked

We're not sure that our callback will be called again if
we haven't filled the pipe.

4 years agoconncheck: print a supplementary pair flag in the debug dump
Fabrice Bellet [Thu, 30 Jan 2020 19:32:44 +0000 (20:32 +0100)]
conncheck: print a supplementary pair flag in the debug dump

4 years agoconncheck: fix timer remainder return value
Fabrice Bellet [Wed, 5 Feb 2020 21:04:16 +0000 (21:04 +0000)]
conncheck: fix timer remainder return value

We show the timer remainder in milliseconds.

4 years agoFix building doc when libnice is a subproject
Xavier Claessens [Tue, 17 Dec 2019 15:54:37 +0000 (10:54 -0500)]
Fix building doc when libnice is a subproject

When passing strings to 'src_dir', they are assumed to be relative to
the root source dir of main project. That's possibly a Meson bug, it
should be relative to current source dir. In any case, it's better to
use include_directories() to avoid any confusion.

4 years agoRemove GTimeVal as it is deprecated in GLib
Olivier Crête [Wed, 11 Dec 2019 00:11:44 +0000 (19:11 -0500)]
Remove GTimeVal as it is deprecated in GLib

4 years agogitlab-ci: Replace dependencies with needs for parallel running
Olivier Crête [Fri, 6 Dec 2019 18:11:10 +0000 (13:11 -0500)]
gitlab-ci: Replace dependencies with needs for parallel running

4 years agogitlab-ci: Add workaround for missing msys in Docker image
Olivier Crête [Fri, 6 Dec 2019 19:37:09 +0000 (14:37 -0500)]
gitlab-ci: Add workaround for missing msys in Docker image

4 years agogitlab-ci: Move CI to Windows 1809 builder
Olivier Crête [Fri, 6 Dec 2019 19:20:11 +0000 (14:20 -0500)]
gitlab-ci: Move CI to Windows 1809 builder

Also upgrade to Windows image v8 as the image needs to match the host

4 years agoconncheck: fix long time to connect if conncheck list gets filled late
Jakub Adam [Tue, 26 Nov 2019 15:54:08 +0000 (16:54 +0100)]
conncheck: fix long time to connect if conncheck list gets filled late

When a stream's conncheck list is empty during
priv_conn_check_unfreeze_related() and the check pairs get added only
afterwards, the whole list may remain in frozen state for tens of
seconds until the lists of all other streams are completed.

If a connection check list missed the opportunity to be unfrozen
according to the process in RFC 5245 Section 7.1.3.2.3 because it was
empty at the time, unfreeze it immediately once some check pair gets
added.

4 years agomeson: fix build with Meson 0.49.2
Tim-Philipp Müller [Tue, 17 Sep 2019 10:58:16 +0000 (11:58 +0100)]
meson: fix build with Meson 0.49.2

The parser didn't seem to handle line continuations properly back then.

4 years agogitlab-ci: Add MSVC builds
Olivier Crête [Fri, 2 Aug 2019 00:10:45 +0000 (20:10 -0400)]
gitlab-ci: Add MSVC builds

Uses a wrap file to download a prebuilt OpenSSL from our git as a
subproject.
Builds for both amd64 & x86

4 years agotests: Don't use GSubprocessLauncher
Olivier Crete [Mon, 5 Aug 2019 19:07:36 +0000 (12:07 -0700)]
tests: Don't use GSubprocessLauncher

It crashes on Windows

4 years agotest-fullmode-with-stun: Use portable g_usleep() for MSVC
Olivier Crête [Fri, 2 Aug 2019 16:57:18 +0000 (12:57 -0400)]
test-fullmode-with-stun: Use portable g_usleep() for MSVC

4 years agomeson.build: Simplify shell based test checks
Olivier Crête [Thu, 1 Aug 2019 23:49:35 +0000 (19:49 -0400)]
meson.build: Simplify shell based test checks

4 years agomeson: Add non-pkgconfig test for OpenSSL
Olivier Crête [Thu, 1 Aug 2019 22:57:43 +0000 (18:57 -0400)]
meson: Add non-pkgconfig test for OpenSSL

This makes it work with Windows MSVC builds of OpenSSL which
don't include a pkg-config file.

4 years agoCI: add basic msys2 build
Jordan Petridis [Thu, 18 Jul 2019 09:28:00 +0000 (12:28 +0300)]
CI: add basic msys2 build

For now it uses the gstreamer docker image and shared runner, based
on windows server 1607. The runner will migrate to windows 1807
soonish hopefully.

This commit also adds a glib wrap file needed to build
libnice.

4 years agotests: Port test-fullmode-with-stun wrapper to C
Olivier Crête [Wed, 31 Jul 2019 23:20:27 +0000 (19:20 -0400)]
tests: Port test-fullmode-with-stun wrapper to C

Shell scripts don't work well on Windows and Python doesn't work with valgrind.

4 years agostund: Add win32 support
Olivier Crête [Thu, 1 Aug 2019 23:30:07 +0000 (16:30 -0700)]
stund: Add win32 support

4 years agoconncheck: fix a wrong transport value in debug
Fabrice Bellet [Fri, 2 Aug 2019 13:19:26 +0000 (13:19 +0000)]
conncheck: fix a wrong transport value in debug

4 years agodockerfiles: Add buildah format export to make gitlab happy
Olivier Crête [Thu, 1 Aug 2019 15:38:48 +0000 (11:38 -0400)]
dockerfiles: Add buildah format export to make gitlab happy

5 years agotests: Pass GST env with valgrind too
Olivier Crête [Wed, 31 Jul 2019 22:30:31 +0000 (18:30 -0400)]
tests: Pass GST env with valgrind too

5 years agolibnice.supp: Add RHEL 7 suppressions
Olivier Crête [Wed, 31 Jul 2019 20:09:25 +0000 (16:09 -0400)]
libnice.supp: Add RHEL 7 suppressions

5 years agogitlab-ci: Add valgrind autotools test too
Olivier Crête [Wed, 31 Jul 2019 20:00:27 +0000 (16:00 -0400)]
gitlab-ci: Add valgrind autotools test too

5 years agodockerfiles: Add valgrind to docker files
Olivier Crête [Wed, 31 Jul 2019 19:54:32 +0000 (15:54 -0400)]
dockerfiles: Add valgrind to docker files

5 years agogitlab-ci: Use extends to reduce size of script
Olivier Crête [Wed, 31 Jul 2019 19:45:16 +0000 (15:45 -0400)]
gitlab-ci: Use extends to reduce size of script

5 years agogitlab-ci: Add valgrind meson test
Olivier Crête [Wed, 31 Jul 2019 19:39:35 +0000 (15:39 -0400)]
gitlab-ci: Add valgrind meson test

5 years agomeson: Add valgrind setup
Olivier Crête [Wed, 31 Jul 2019 19:38:28 +0000 (15:38 -0400)]
meson: Add valgrind setup

5 years agolibnice.supp: Add GStreamer suppressions
Olivier Crête [Wed, 31 Jul 2019 19:33:51 +0000 (15:33 -0400)]
libnice.supp: Add GStreamer suppressions

5 years agotest-gstreamer: fix buffer leak
Olivier Crête [Wed, 31 Jul 2019 19:33:39 +0000 (15:33 -0400)]
test-gstreamer: fix buffer leak

5 years agoconncheck: Drop valid STUN for which we can't find a request
Olivier Crête [Wed, 31 Jul 2019 19:04:21 +0000 (15:04 -0400)]
conncheck: Drop valid STUN for which we can't find a request

It's most likely caused by a retransmission received after the initial
request already had a reply.

5 years agotest-tcp: Only free passive socket after child
Olivier Crête [Wed, 31 Jul 2019 18:51:16 +0000 (14:51 -0400)]
test-tcp: Only free passive socket after child

The child now calls into the parent..

5 years agotest-turn: Initialize variable earlier to avoid race
Olivier Crête [Wed, 31 Jul 2019 18:51:04 +0000 (14:51 -0400)]
test-turn: Initialize variable earlier to avoid race

5 years agotest-udp-turn-fragmentation: Avoid leaking test socket
Olivier Crête [Wed, 31 Jul 2019 18:39:51 +0000 (14:39 -0400)]
test-udp-turn-fragmentation: Avoid leaking test socket

5 years agotest-different-number-streams: Avoid leaking NiceAddress
Olivier Crête [Wed, 31 Jul 2019 18:39:35 +0000 (14:39 -0400)]
test-different-number-streams: Avoid leaking NiceAddress

5 years agoconncheck: ignore selected pairs for nomination that failed
Fabrice Bellet [Mon, 15 Jul 2019 12:47:11 +0000 (14:47 +0200)]
conncheck: ignore selected pairs for nomination that failed

When evaluating the stopping criterion, failed pairs from other streams
having the "use_candidate_on_next_check" flag set should be
ignored.

This should normally not happen, because a pair selected for nomination
has no reason to fail when being rechecked, since it previously
worked... but it may happen with Skype for Business, when libnice
selects a tcp pair for component 1, the peer seems to have no interest
in the second component and lets it fail in the middle of the conncheck.

5 years agoconncheck: make the stopping criterion a bit more clear
Fabrice Bellet [Fri, 12 Jul 2019 10:22:28 +0000 (12:22 +0200)]
conncheck: make the stopping criterion a bit more clear

This patch doesn't change the logic of the selection of the pair for
nomination, it makes the code a bit more simple to read.

5 years agoagent: fix a regression when updating foundations
Fabrice Bellet [Mon, 29 Jul 2019 21:35:04 +0000 (21:35 +0000)]
agent: fix a regression when updating foundations

A previous commit c1fb6f2 introduced a regression in the way the
foundation of a selected pair is updated and signaled, when the
foundation of its remote candidate changes. The previous comparison was
made on *always* identical strings, so the update of the selected pair
was *never* signaled.

5 years agoconncheck: update a misleading debug statement
Fabrice Bellet [Mon, 29 Jul 2019 21:11:55 +0000 (21:11 +0000)]
conncheck: update a misleading debug statement

We may not have received remote candidates yet, but we may have
discovered remote candidates from the early incoming checks. Only
having stream credentials is required to react to these checks.

5 years agoudp-bsd: Use sockaddr_storage union to ensure big enough socket
Olivier Crête [Sun, 28 Jul 2019 15:33:16 +0000 (11:33 -0400)]
udp-bsd: Use sockaddr_storage union to ensure big enough socket

The IPv6 struct sockaddr variant is bigger than the IPv4 one,
so use the storage struct to ensure that the size is big enough.

5 years agodiscovery: Don't start STUN/TURN disco on errorneous socket
Jakub Adam [Tue, 16 Jul 2019 09:55:32 +0000 (11:55 +0200)]
discovery: Don't start STUN/TURN disco on errorneous socket

If the initial attempt at sending discovery message returns a socket
error, don't start the retransmit timer and immediately mark such
discovery item as done. This is to quickly eliminate clearly
non-functioning items from the discovery process.

Particularly improves times to finish discovery on Windows, where
sending data from a link-local (169.254.0.0/16) IP to a destination not
on the same subnet leads to "A socket operation was attempted to an
unreachable network" error. Pointless retransmissions on those sockets
prolonged discovery in the order of seconds.

5 years agoudp-bsd: log source and destination addresses on GSocket send error
Jakub Adam [Tue, 16 Jul 2019 08:53:54 +0000 (10:53 +0200)]
udp-bsd: log source and destination addresses on GSocket send error

5 years agoagent: fix server-reflexive candidates with oc2007r2
Fabrice Bellet [Fri, 19 Jul 2019 07:58:34 +0000 (07:58 +0000)]
agent: fix server-reflexive candidates with oc2007r2

The nomination of a pair having such a local candidate breaks SfB when
the libnice agent is behind a nat that does not do port mapping
randomization. In that case a server reflexive local candidate usually
lead to a nominated pair.

The guess made here from observing this behavior is that, it is valid to
discover and signal these local server reflexive candidates to our peer,
but they should be removed from our local candidates list thereafter, so
they do not contribute to build a valid and *even worse* a nominated
pair with the type server-reflexive. They do not appear in the conncheck
list per design anyway.

Instead, the same candidate is discovered again later during the
conncheck, with a peer-reflexive type this time, and with that type, it
just works.

Closes #90

5 years agoconncheck: avoid transport association mismatch
Fabrice Bellet [Fri, 12 Jul 2019 14:06:13 +0000 (14:06 +0000)]
conncheck: avoid transport association mismatch

In some rare cases, the same address and port number may match two
remotes candidates, a tcp and an udp one, and lead to buggy pair
construction with incompatible transport. This supplementary check
prevents this problem. The matching test is not aimed to be exhaustive
but just a way to discard obviously broken associations, and fallback to
accept everything else (because socket type has a great diversity, with
socket types based on other sockets types).

It should fix #81, where such bogus transport association has been
reported (tcp-pass:udp).

5 years agointerfaces: ignore only interfaces we really want to
Jakub Adam [Fri, 12 Jul 2019 10:15:14 +0000 (12:15 +0200)]
interfaces: ignore only interfaces we really want to

Once an interface got ignored, ALL interfaces coming after it were
dropped too.

5 years agocandidate: replace uint8_t -> guint8
Jakub Adam [Fri, 12 Jul 2019 08:47:50 +0000 (10:47 +0200)]
candidate: replace uint8_t -> guint8

Fixes MSVC build.

5 years agodebug: fix verbose mode
Jakub Adam [Fri, 12 Jul 2019 08:30:39 +0000 (10:30 +0200)]
debug: fix verbose mode

Since g_parse_debug_string() was looking only at the first 4 items in
GDebugKey arrays, "libnice-verbose" couldn't get activated.

5 years agoexamples: fix compiler extra warnings
Fabrice Bellet [Tue, 9 Jul 2019 13:17:12 +0000 (15:17 +0200)]
examples: fix compiler extra warnings

5 years agoagent: fix condition for turn-tcp discovery creation
Fabrice Bellet [Wed, 3 Jul 2019 20:09:03 +0000 (22:09 +0200)]
agent: fix condition for turn-tcp discovery creation

We support turn-tcp in oc2007 compatibility only and when the
host candidate transport is compatible, ie when reliable_tcp is true.

5 years agoconncheck: test inbound stun address on the candidate base address
Fabrice Bellet [Wed, 12 Jun 2019 19:44:48 +0000 (21:44 +0200)]
conncheck: test inbound stun address on the candidate base address

When receiving an stun packet on a socket, and looking for the matching
local candidate, normally it doesn't make a difference to test the
address or the base address. Because a pair cannot have a local candidate
of type srv-rflx, where there would be a difference, the local candidate
obtained will be part of a pair of the conncheck list.

Except for the case of a pairs with tcp-act local candidate, where the
addr has a port number of zero (tcp-act socket before connect), and the
socket of the stun packet has a non-null port number (tcp-act socket
after connect), corresponding to the base address of another
peer-reflexive tcp-act local candidate, previously discoverd.

The selection of the local candidate concerned by an inbound stun
request happens when early incoming checks are processed, and when
inbound stun packets are normally received during the conncheck.

This commit complete commit e6a1941 (for early incoming checks)
in the normal inbound stun packets code path, where is similar
modification is needed.

5 years agoconncheck: improve comment on local peer-reflexive selection
Fabrice Bellet [Tue, 4 Jun 2019 17:34:22 +0000 (19:34 +0200)]
conncheck: improve comment on local peer-reflexive selection

This patch rewrites the comment surrounding this code snippet, to make it
clear, that this pair selection is not specific to the tcp transport.

5 years agoconncheck: nominate matching pairs across components and streams
Fabrice Bellet [Thu, 11 Jul 2019 19:02:53 +0000 (19:02 +0000)]
conncheck: nominate matching pairs across components and streams

The current valid pair nomination makes no effort to select pairs that
could have some similarities across different components and different
streams. This is normally not required by the RFC8445, but some well
known applications will misbehave when the libnice agent is in this
position to choose the nominated pairs (regular nomination mode, and
controlling mode) and if it makes an unexpected choice from the peer
point-of-view.

This patch improves the stopping criterion and the selection of the
preferred pair to nominate in that case.

When no other pair has been nominated yet (across all streams), the
previous stopping criterion still applies, and the best ranked pair of
the checklist is selected.

When a nominated pair exists from another component, we try to nominate
a pair of the same kind (same local and remote addresses and same
transport) if we have one, and possibly the best pair we have in the
checklist, and else we look for a nominated pair from another stream.

5 years agoagent: fix agent reference count
Fabrice Bellet [Sun, 30 Jun 2019 19:28:25 +0000 (21:28 +0200)]
agent: fix agent reference count

5 years agotests: fix a compiler warning
Fabrice Bellet [Fri, 28 Jun 2019 13:35:41 +0000 (15:35 +0200)]
tests: fix a compiler warning

5 years agotcp-bsd: fix a heap-use-after-free
Fabrice Bellet [Fri, 28 Jun 2019 11:54:57 +0000 (13:54 +0200)]
tcp-bsd: fix a heap-use-after-free

5 years agocomponent: don't detach the socket source twice
Fabrice Bellet [Fri, 28 Jun 2019 11:49:47 +0000 (13:49 +0200)]
component: don't detach the socket source twice

The source is also detached in socket_source_free()

5 years agoconncheck: define a property for a final idle timeout
Fabrice Bellet [Fri, 28 Jun 2019 11:45:11 +0000 (13:45 +0200)]
conncheck: define a property for a final idle timeout

This final idle timeout is renamed from the
NICE_AGENT_MAX_TIMER_GRACE_PERIOD macro, and keeps its semantic.

We also increase the default value of this timeout from 1 second to 5
seconds.  This is useful for the sipe pidgin plugin that has to deal
with SfB agents, that may take some time in controlling mode before
choosing and testing the nominated pair

5 years agoconncheck: fix pair priorities uniqueness
Fabrice Bellet [Tue, 25 Jun 2019 07:19:05 +0000 (09:19 +0200)]
conncheck: fix pair priorities uniqueness

This patch fixes the priority assigned to a peer reflexive discovered
local candidate, when the agent has the stun client role and receives an
stun reply. This priority must be the value put in the stun request, ie
the pair->rflx_priority from the parent pair. This ensures two similar
ordered pairs, will generate discovered pairs ordered in the same way
for the stun client, and also for the stun server on the other side.
Without this identical ordered on both sides of the connections, the two
agents may nominate a different pair with the aggresive nomination
scenario, since both are valid.

The other fix concerns the function that ensures local candidates
priority uniqueness, that breaks the assumption that "two local
candidates having the same priority should generate the same
prflx_priority in the pairs they contribute". Respecting this assumption
is important to stay coherent with the behavior of the other agent, that
considers that two stun requests coming from the same peer-reflexive
remote candidate will have the same remote priority (once a remote
candidate is added to the component remote_candidates list, its priority
is not supposed to change).

5 years agoconncheck: create the valid pair on early tcp stun requests
Fabrice Bellet [Sat, 22 Jun 2019 21:09:45 +0000 (23:09 +0200)]
conncheck: create the valid pair on early tcp stun requests

When replaying the incoming checks, we have to create the succeeded
valid pair matching this tcp connection the same way we do it
in conn_check_handle_inbound_stun().

5 years agoagent: discard sockptr on updated remote candidates
Fabrice Bellet [Fri, 21 Jun 2019 13:06:58 +0000 (15:06 +0200)]
agent: discard sockptr on updated remote candidates

These candidates type is updated from peer-reflexive, discovered during
early incoming checks, to the type of the matching regularly transmitted
candidate, so the previous sockptr value is no longer of interest here.
The same socket is already associated to the initial local candidate
anyway, source of the early discovery.

5 years agocomponent: remove socket also from remote candidates
Fabrice Bellet [Tue, 18 Jun 2019 18:54:16 +0000 (20:54 +0200)]
component: remove socket also from remote candidates

A socket to be removed may also come from a peer-reflexive remote
candidate, and some cleanup also needs to be done in this case. This
reference in a remote peer-reflexive tcp-active candidate caused a
heap-use-after-free asan error in some custom debugging dump of the list
of sockets of a component, after a read error in component_io_cb():

agent_recv_message_unlocked returned -1, errno (25) :
Inappropriate ioctl for device

5 years agodebug: fix verbose debug enable
Fabrice Bellet [Sun, 16 Jun 2019 20:05:49 +0000 (22:05 +0200)]
debug: fix verbose debug enable

5 years agoconncheck: fix incoming checks memory leak
Fabrice Bellet [Sun, 16 Jun 2019 19:04:41 +0000 (21:04 +0200)]
conncheck: fix incoming checks memory leak

5 years agoconncheck: test incoming checks on candidate base address
Fabrice Bellet [Wed, 12 Jun 2019 19:44:48 +0000 (21:44 +0200)]
conncheck: test incoming checks on candidate base address

The candidate may be a newly discovered peer reflexive one,
or a server reflexive initial candidate, where address and
base address differ. Early incoming checks are received on
the base address. These incoming checks may accumulate if remote
credentials arrive with a delay.