platform/upstream/libnice.git
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.

4 years agoconncheck: enable retransmit flag after nominated pair reordering
Fabrice Bellet [Sun, 5 Apr 2020 19:15:02 +0000 (21:15 +0200)]
conncheck: enable retransmit flag after nominated pair reordering

When an existing peer-reflexive remote candidate is updated to a server
reflexive one, due to the late reception of remove candidates, this
update has several consequences on the conncheck list:

 - pair foundations and priorities must be recomputed
 - the highest nominated pair may have changed too
 - this is not strictly required, but some pairs that had *a lower*
   priority than the previously peer-reflexive nominated pair, had
   their retransmit flag set to false, for this reason. These pairs may
   now have *a higher* priority than the newly promoted nominated pair,
   and it is fair in that case to turn their retransmit flag back to
   true.

4 years agoUse g_assert_cmp.int() to get better debug logs on crash
Olivier Crête [Wed, 6 May 2020 00:03:03 +0000 (20:03 -0400)]
Use g_assert_cmp.int() to get better debug logs on crash

4 years agotests: Replace g_assert (memcmp) with g_assert_cmpmem()
Olivier Crête [Tue, 5 May 2020 22:53:02 +0000 (18:53 -0400)]
tests: Replace g_assert (memcmp) with g_assert_cmpmem()

This makes for clearer reports in the CI

4 years agocandidate: fix compiler warnings on raspbian
Tim-Philipp Müller [Sun, 3 May 2020 09:49:58 +0000 (09:49 +0000)]
candidate: fix compiler warnings on raspbian

candidate.c:351:12: warning: format ‘%lx’ expects argument of
type ‘long unsigned int’, but argument 4/5 has type ‘guint64’
{aka ‘long long unsigned int’} [-Wformat=]

4 years agotest-thread: Use GCond to make sure there is no race
Olivier Crête [Tue, 5 May 2020 20:50:54 +0000 (16:50 -0400)]
test-thread: Use GCond to make sure  there is no race

4 years agotest-gstreamer: Use g_debug instead of gst debug
Olivier Crête [Tue, 5 May 2020 03:54:51 +0000 (23:54 -0400)]
test-gstreamer: Use g_debug instead of gst debug

This matches the rest of the tests.

4 years agotest-gstreamer: Use GCond to avoid race condition
Olivier Crête [Tue, 5 May 2020 03:54:12 +0000 (23:54 -0400)]
test-gstreamer: Use GCond to avoid race condition

This race condition is hit all the time when running the test under
valgrind.

4 years agomeson: Disable check forking, let meson handle the timeout
Olivier Crête [Mon, 4 May 2020 23:19:22 +0000 (19:19 -0400)]
meson: Disable check forking, let meson handle the timeout

4 years agoconncheck: more debug
Fabrice Bellet [Sun, 23 Feb 2020 18:38:08 +0000 (19:38 +0100)]
conncheck: more debug

4 years agoconncheck: add debug about agent mode
Fabrice Bellet [Sun, 5 Apr 2020 20:27:38 +0000 (22:27 +0200)]
conncheck: add debug about agent mode

4 years agodiscovery: add the agent pointer to turn debug messages
Fabrice Bellet [Wed, 8 Apr 2020 14:59:40 +0000 (16:59 +0200)]
discovery: add the agent pointer to turn debug messages

4 years agoconncheck: drop some excessively verbose comment
Fabrice Bellet [Fri, 21 Feb 2020 14:40:56 +0000 (15:40 +0100)]
conncheck: drop some excessively verbose comment

4 years agoconncheck: wait for a pair until all stun requests are completed
Fabrice Bellet [Sun, 5 Apr 2020 19:11:19 +0000 (21:11 +0200)]
conncheck: wait for a pair until all stun requests are completed

Only the newest stun request may need to be retransmitted, according to
the pair retransmit flag. This is the first element of the
stun_transactions list. Older stun requests are just kept around until
their timeout expires, without retransmission.

The newest stun request is usually the last one that will timeout.
Current code was based on that assumption, causing the pair to fail when
the newest stun request timeout expires. This is not always true, and some
older stun requests may have a greater timeout delay.

So, we should wait until *all* stun requests of a given pair have
reached their timeout.

We also refactor this part of the code, to handle the first stun and the
other stun requests in the same loop.

4 years agodiscovery: use different port numbers for every local host candidates
Fabrice Bellet [Sun, 5 Apr 2020 19:18:55 +0000 (21:18 +0200)]
discovery: use different port numbers for every local host candidates

This constraint is added to handle the situation where the agent runs on
a box doing SNAT on one of its outgoing network interface. The NAT does
usually its best to ensure that source port number is preserved on the
external NAT address and port. This is called "port preservation" in RFC
4787.

When two local host candidates are allowed to have the same source port
number, we increase the risk that a first local host candidate *is* the
NAT mapping address and port of a second local host candidate, because
of the "port preservation" effect. When it happens, a server reflexive
candidate and a host candidate will have the same address and port.

For that situation to happen, a stun request must be emitted from the
internal address first, the NAT mapping doing the port preservation will
be created for the internal address, and when a stun request is sent
from the external address thereafter, a new NAT mapping will be created,
but without port preservation, because the previous mapping already took
that reservation.

The problem will occur on the remote agent, when receiving a stun request
from this address and port, that has no way to know wheather it comes from
the host or the server reflexive candidate, if both have been advertised
remotely, resulting in pair type mislabelling.

This case may happen more easily when a source port range is reduced.

4 years agoagent: stay in aggressive mode after conncheck has started
Fabrice Bellet [Sun, 5 Apr 2020 18:56:38 +0000 (20:56 +0200)]
agent: stay in aggressive mode after conncheck has started

When remote tcp candidates are received late after the conncheck has
started, RFC 6554 suggests that we switch the nomination mode back from
aggressive to regular. The problem is that some stun requests may
already be inflight with the use-candidate stun flag set, and reverting
to regular mode in that case is too late, because these inflight
requests may nominate a pair on the remote agent, and not on the local
agent. We prefer to just ignore remote tcp candidates that are received
after the component state has reached state CONNECTING.

4 years agoagent: warn when reaching max number of turn and local addresses
Fabrice Bellet [Tue, 3 Mar 2020 10:17:04 +0000 (11:17 +0100)]
agent: warn when reaching max number of turn and local addresses

4 years agoagent: fix boundary test of max turn servers and local addresses
Fabrice Bellet [Tue, 3 Mar 2020 10:13:37 +0000 (11:13 +0100)]
agent: fix boundary test of max turn servers and local addresses

We can accept up to 8 turn servers, with turn preference value
starting at zero. Also fix the error message.

4 years agodiscovery: add a unique local preference value per turn server
Fabrice Bellet [Thu, 13 Feb 2020 17:50:07 +0000 (18:50 +0100)]
discovery: add a unique local preference value per turn server

This value is built from the position in the component turn servers
list, and from the base address network interface position in the list
of network interfaces. This value is used to ensure a unique candidate
priority for each one. Also ensure that the fields that compose the
local preference don't overlap, by checking their maximum value.  See
RFC-8445, section 5.1.2.2 "Guidelines for Choosing Type and Local
Preferences".

4 years agoconncheck: rename peer-reflexive priority to stun-priority
Fabrice Bellet [Wed, 12 Feb 2020 15:07:33 +0000 (16:07 +0100)]
conncheck: rename peer-reflexive priority to stun-priority

4 years agocandidate: ensuring stun priority uniqueness no more needed
Fabrice Bellet [Wed, 12 Feb 2020 14:48:12 +0000 (15:48 +0100)]
candidate: ensuring stun priority uniqueness no more needed

The uniqueness of candidate priorities is achieved by the iteration on
the ip local addresses for local host candidates, and also on their base
address for reflexive and relay candidates. Helper function checking
its uniqueness at allocation time is not required anyore.

The priority of the stun request (prflx_priority) is built from the
priority of the local candidate of the pair, according the RFC 5245,
section 7.1.2.1. This priority must be identical to a virtual "local
candidate of type peer-reflexive that would be learned as a consequence
of a check from this local candidate."

Outgoing stun requests will come from local candidates of type host or
type relayed. The priority uniqueness of local candidates of type host
implies the uniqueness of the computed peer-reflexive priority.  And
relay local candidates cannot produce a peer-reflexive local candidate
by design, so we can safely use their unique local priority too in
the stun request.

4 years agosubprojects: bump glib wrap to latest stable branch for msys build
Tim-Philipp Müller [Mon, 4 May 2020 12:01:02 +0000 (13:01 +0100)]
subprojects: bump glib wrap to latest stable branch for msys build

Should fix build failures with latest mingw compiler in msys.

4 years agoci: update windows image
Tim-Philipp Müller [Mon, 4 May 2020 11:52:35 +0000 (12:52 +0100)]
ci: update windows image

The old one (v8) was removed from the gstreamer registry it seems.

4 years agoconncheck: refactor local and remote candidates validation
Fabrice Bellet [Fri, 21 Feb 2020 14:40:56 +0000 (15:40 +0100)]
conncheck: refactor local and remote candidates validation

The same code to get and validate local and remote candidates from an
incoming stun is shared between regular inbound stun, early checks
replay, and partially in the local peer-reflexive discovery function.

The selection of the matching local and remote candidate from an
incoming stun sometimes requires more information than just the local
socket, and the sender address and port. It happens more frequently when
the port range is reduced, and when the conncheck handles both tcp and
udp candidates.

To help to disambiguate such situations, we add supplementary checks
when two candidates in the list have the same address and and port
number:

 * the type of the socket must compatible with the candidate transport.
   A socket for a tcp candidate may be active of passive, but also
   of type "tcp-bsd" when the parent active or passive socket is
   replaced after a bind() or accept(). It gives several cases.

 * the remote candidate transport and the local candidate transport must
   be compatible

4 years agoconncheck: match remote candidates on the socket reliability
Fabrice Bellet [Thu, 20 Feb 2020 16:05:51 +0000 (17:05 +0100)]
conncheck: match remote candidates on the socket reliability

When the couple (address, port) is identical between two remote
candidates, we may have to match a remote candidate based on its socket
reliability.

4 years agoconncheck: match transport of peer-reflexive local candidates
Fabrice Bellet [Mon, 17 Feb 2020 15:29:41 +0000 (16:29 +0100)]
conncheck: match transport of peer-reflexive local candidates

Another some rare case, but we may have two local candidates with
the same couple (address, port) and a different transport.

4 years agotests: add a unit test for private addresses ranges
Fabrice Bellet [Mon, 2 Mar 2020 12:23:35 +0000 (13:23 +0100)]
tests: add a unit test for private addresses ranges

This is a unix-only test

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