platform/upstream/libnice.git
7 years agocandidate: Add equality check function
Olivier Crête [Tue, 4 Apr 2017 18:41:51 +0000 (14:41 -0400)]
candidate: Add equality check function

Add a function that can check if two candidates point to the same place.

https://phabricator.freedesktop.org/T104

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Differential Revision: https://phabricator.freedesktop.org/D1715

7 years agotest-credentials: Fix leak
Olivier Crête [Wed, 5 Apr 2017 21:01:35 +0000 (17:01 -0400)]
test-credentials: Fix leak

7 years agodebug: Use libnice-verbose, not libnice-nice-verbose
Olivier Crête [Wed, 5 Apr 2017 00:34:05 +0000 (20:34 -0400)]
debug: Use libnice-verbose, not libnice-nice-verbose

7 years agotests: Use automake test-driver for valgrind
Olivier Crête [Tue, 4 Apr 2017 22:42:57 +0000 (18:42 -0400)]
tests: Use automake test-driver for valgrind

This fixes the valgrind integration with the new test drivers.

7 years agoagent: Remove impossible case
Olivier Crête [Tue, 4 Apr 2017 20:16:46 +0000 (16:16 -0400)]
agent: Remove impossible case

7 years agoagent: Separate return from NiceSocket and internal enum
Olivier Crête [Tue, 4 Apr 2017 20:16:05 +0000 (16:16 -0400)]
agent: Separate return from NiceSocket and internal enum

The same variable was used for return values from NiceSocket and
for the internal enum, but 0 and -1 have different meanings in both.

7 years agoudp-turn: Add some const to internal APIs
Olivier Crête [Tue, 4 Apr 2017 19:24:43 +0000 (15:24 -0400)]
udp-turn: Add some const to internal APIs

7 years agoMake clang-analyzer happy
Olivier Crête [Tue, 4 Apr 2017 16:30:27 +0000 (12:30 -0400)]
Make clang-analyzer happy

Various little things, none of which should make a functional difference.

7 years agoagent: Don't set variable that won't be used
Olivier Crête [Tue, 4 Apr 2017 16:29:29 +0000 (12:29 -0400)]
agent: Don't set variable that won't be used

It exits the loop immediately, so no point to set the variable.
And it makes the clang static analyzer happy.

7 years agoconncheck: Use the right test for empty remote_frag
Olivier Crête [Tue, 4 Apr 2017 16:25:50 +0000 (12:25 -0400)]
conncheck: Use the right test for empty remote_frag

It's now an array, not a pointer, so needs to test to emptyness.

It's a bugfix on the previous commit, 59ce41df

7 years agoconncheck: consider answer received when remote credentials are set
Miguel París Díaz [Sat, 1 Apr 2017 00:20:38 +0000 (20:20 -0400)]
conncheck: consider answer received when remote credentials are set

Consider that the answer is received when remote credentials
are set instead of when a remote candidate is set,
which could not happen or could cause more delay for the
connection establishment.

Ported to git master by Olivier Crête

Differential Revision: https://phabricator.freedesktop.org/D1704

7 years agoVersion 0.1.14.1
Olivier Crête [Mon, 3 Apr 2017 18:30:10 +0000 (14:30 -0400)]
Version 0.1.14.1

7 years agoVersion 0.1.14 0.1.14
Olivier Crête [Mon, 3 Apr 2017 18:28:22 +0000 (14:28 -0400)]
Version 0.1.14

7 years agoREADME: Depends on GLib 2.44
Olivier Crête [Mon, 3 Apr 2017 18:20:51 +0000 (14:20 -0400)]
README: Depends on GLib 2.44

7 years agostun: Make hmac code NDEBUG safe
Olivier Crête [Mon, 3 Apr 2017 18:20:31 +0000 (14:20 -0400)]
stun: Make hmac code NDEBUG safe

7 years agostun: Remove double const on int
Olivier Crête [Mon, 3 Apr 2017 16:27:28 +0000 (12:27 -0400)]
stun: Remove double const on int

7 years agocandidate: Test against possible type
Olivier Crête [Mon, 3 Apr 2017 16:13:47 +0000 (12:13 -0400)]
candidate: Test against possible type

There was a confusion and it tested against a value not in the enum.

7 years agoconfigure: Remove missing-noreturn warning
Olivier Crête [Mon, 3 Apr 2017 16:12:54 +0000 (12:12 -0400)]
configure: Remove missing-noreturn warning

We don't have or call noreturn functions in practice and it makes
the stun test build fail on clang.

7 years agostun: Use unions fix alignment issues
Olivier Crête [Mon, 3 Apr 2017 16:11:55 +0000 (12:11 -0400)]
stun: Use unions fix alignment issues

This makes clang happy.

7 years agoconfigure: Make sure flag test really fails on unknown flag
Olivier Crête [Mon, 3 Apr 2017 15:55:11 +0000 (11:55 -0400)]
configure: Make sure flag test really fails on unknown flag

clang on recent macOS seems to only emit a warning on unknown flags
which makes this test fail and then when using Werror, it makes the
compiler test fail too.

7 years agostun: Rename rand function to make its strengh clear
Olivier Crête [Mon, 3 Apr 2017 15:02:00 +0000 (11:02 -0400)]
stun: Rename rand function to make its strengh clear

It's only nonce level randomness, not long term key level.

Differential Revision: https://phabricator.freedesktop.org/D1711

7 years agostun: Switch from gcrypt to gnutls
Olivier Crête [Sat, 1 Apr 2017 01:23:12 +0000 (21:23 -0400)]
stun: Switch from gcrypt to gnutls

GLib already uses it, instead of adding another dep.

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Differential Revision: https://phabricator.freedesktop.org/D1705

7 years agoagent: Only try to use the address of the same family to connect to TURN
Jakub Adam [Sun, 2 Apr 2017 15:08:07 +0000 (17:08 +0200)]
agent: Only try to use the address of the same family to connect to TURN

Using a IPv6 local address to connect to a IPv4 relay just creates an
extra discovery attempt that will not provide something useful.

This commit fixes another place of TURN discovery creation which was
omitted in fc0d3744ebc03f8137866170594968ba61e6be30. In my case it cuts
down up to ~15 seconds from candidate gathering phase, making it almost
instantaneous.

Reviewed-by: Olivier Crête <olivier.crete@collabora.com>
Differential Revision: https://phabricator.freedesktop.org/D1709

7 years agoudp-bsd: Log g_socket_send_message() errors
Jakub Adam [Sun, 2 Apr 2017 14:38:21 +0000 (16:38 +0200)]
udp-bsd: Log g_socket_send_message() errors

Those may have previously been silently ignored.

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Differential Revision: https://phabricator.freedesktop.org/D1708

7 years agoagent: Eliminate duplicate debug in agent_recv_message_unlocked()
Jakub Adam [Sat, 1 Apr 2017 14:55:48 +0000 (16:55 +0200)]
agent: Eliminate duplicate debug in agent_recv_message_unlocked()

There were two almost consecutive verbose debugs containing basically
identical information. Merge them into one message that is printed only
when something was actually received.

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Differential Revision: https://phabricator.freedesktop.org/D1707

7 years agoagent: Improve debug in component_io_cb()
Jakub Adam [Sat, 1 Apr 2017 14:21:36 +0000 (16:21 +0200)]
agent: Improve debug in component_io_cb()

agent_recv_message_unlocked() always receives a single message and
returns a RecvStatus code.

Avoid weird debugs like "received -1 valid messages" (when retval is
RECV_WOULD_BLOCK) and print the message only when something was actually
received.

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Differential Revision: https://phabricator.freedesktop.org/D1706

7 years agoconfigure: gcry_mac_* were added in 1.6
Olivier Crête [Sat, 1 Apr 2017 00:43:27 +0000 (20:43 -0400)]
configure: gcry_mac_* were added in 1.6

They're not present int he 1.5.0 release, so require
the newer one.

7 years agoMakefile: Build tests before docs
Olivier Crête [Sat, 1 Apr 2017 00:03:30 +0000 (20:03 -0400)]
Makefile: Build tests before docs

7 years agodoc: Improve gtkdoc-check environment
Olivier Crête [Fri, 31 Mar 2017 23:20:17 +0000 (19:20 -0400)]
doc: Improve gtkdoc-check environment

7 years agodoc: Add missing symbol
Olivier Crête [Fri, 31 Mar 2017 23:09:36 +0000 (19:09 -0400)]
doc: Add missing symbol

7 years agoconfigure: Actually require gtk-doc 1.10 for no-tmpl
Olivier Crête [Fri, 31 Mar 2017 23:06:36 +0000 (19:06 -0400)]
configure: Actually require gtk-doc 1.10 for no-tmpl

7 years agostun: Use libgcrypt for SHA1 support
Philip Withnall [Mon, 7 Mar 2016 10:05:27 +0000 (10:05 +0000)]
stun: Use libgcrypt for SHA1 support

Now that libstun depends on libgcrypt, we might as well use its SHA1 hash
support, rather than carrying around our own.

Differential Revision: https://phabricator.freedesktop.org/D1612

7 years agostun: Use libgcrypt for MD5 support
Philip Withnall [Mon, 7 Mar 2016 10:04:52 +0000 (10:04 +0000)]
stun: Use libgcrypt for MD5 support

Now that libstun depends on libgcrypt, we might as well use its MD5 hash
support, rather than carrying around our own.

Differential Revision: https://phabricator.freedesktop.org/D1611

7 years agostun: Use libgcrypt to provide secure random number generation
Philip Withnall [Mon, 7 Mar 2016 09:27:38 +0000 (09:27 +0000)]
stun: Use libgcrypt to provide secure random number generation

Previously, a custom Mersenne Twister PRNG was used, which is not
securely random. In addition, its seeding fell back to wall-clock time,
which is typically predictable.

This uses libgcrypt on Linux but retains the Windows code which uses the
Windows crypt API.

Differential Revision: https://phabricator.freedesktop.org/D1610

7 years agostun: Add libgcrypt dependency
Philip Withnall [Mon, 7 Mar 2016 09:27:00 +0000 (09:27 +0000)]
stun: Add libgcrypt dependency

This will shortly be used to implement secure random number generation.

Differential Revision: https://phabricator.freedesktop.org/D1609

7 years agostun: Remove outdated tests from test-hmac
Philip Withnall [Mon, 7 Mar 2016 10:53:47 +0000 (10:53 +0000)]
stun: Remove outdated tests from test-hmac

The SHA-1 and MD5 implementations in libnice are about to be removed, so
stop testing them explicitly. In addition, rework the remaining test to
use the stun_sha1() API which will remain.

Differential Revision: https://phabricator.freedesktop.org/D1608

7 years agostun: Fix cast-align compiler warning when casting sockaddr
Philip Withnall [Fri, 3 Mar 2017 10:19:20 +0000 (10:19 +0000)]
stun: Fix cast-align compiler warning when casting sockaddr

There should never be a problem with alignment at runtime, since we’re
casting the sockaddr to sockaddr_in or sockaddr_in6 based on its
declared sa_family — anything declared as AF_INET6 should have been
allocated as a sockaddr_in6, and hence have appropriate alignment (same
for AF_INET).

This fixes a compiler warning on ARM and other alignment-sensitive
architectures.

https://phabricator.freedesktop.org/T7718

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: Olivier Crête <olivier.crete@collabora.com>
Differential Revision: https://phabricator.freedesktop.org/D1686

7 years agobuild: Add default-reviewers key to .arcconfig
Philip Withnall [Tue, 17 Jan 2017 00:03:45 +0000 (00:03 +0000)]
build: Add default-reviewers key to .arcconfig

This should cause all patches submitted using git-phab to be assigned to
the #libnice project for review, by default.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
7 years agoms-ice: limit legacy connchecks as per [MS-ICE2] 3.1.4.8.2
Jakub Adam [Wed, 29 Jun 2016 06:40:27 +0000 (06:40 +0000)]
ms-ice: limit legacy connchecks as per [MS-ICE2] 3.1.4.8.2

Client should stop sending connectivity checks with legacy FINGERPRINT
when it receives a conncheck message containing IMPLEMENTATION-VERSION
attribute.

Differential Revision: https://phabricator.freedesktop.org/D1139

7 years agoms-ice: legacy FINGERPRINT mode
Jakub Adam [Wed, 29 Jun 2016 06:40:12 +0000 (06:40 +0000)]
ms-ice: legacy FINGERPRINT mode

In order to preserve compatibility with clients which use custom CRC
lookup table from [MS-ICE2], whenever a connectivity check request or
reply is sent, an additional message is sent along. These two messages
differ only in FINGERPRINT attribute - one uses regular CRC lookup table
for calculation, the other uses the modified table.

When a message is received and FINGERPRINT doesn't pass validation using
regular CRC table, the receiver also tries to verify using the modified
table.

[MS-ICE2] 3.1.4.8.2 describes this procedure.

The commit fixes compatibility with older MSOC and Lync clients.

Differential Revision: https://phabricator.freedesktop.org/D1138

7 years agostun: add STUN_COMPATIBILITY_MSICE2
Jakub Adam [Wed, 29 Jun 2016 06:39:50 +0000 (06:39 +0000)]
stun: add STUN_COMPATIBILITY_MSICE2

Windows Live Messenger is a discontinued service. We can repurpose
STUN_COMPATIBILITY_WLM2009 as [MS-ICE2] compatibility.

The orignial WLM enumerator is kept for the sake of API compatibility.

Differential Revision: https://phabricator.freedesktop.org/D1137

7 years agoms-ice: calculate FINGERPRINT according to [MS-ICE2]
Jakub Adam [Wed, 29 Jun 2016 06:39:22 +0000 (06:39 +0000)]
ms-ice: calculate FINGERPRINT according to [MS-ICE2]

Connectivity checks that are fully conforming to [MS-ICE2] should
contain IMPLEMENTATION-VERSION attribute ([MS-ICE2] 2.2.2.2) equal to 2
and their FINGERPRINT should be calculated as described in RFC5389
section 15.5 (i.e. using standard CRC lookup table).

We need this because some Skype for Business clients no longer accept
messages whose FINGERPRINT contains a value calculated using Microsoft's
old custom CRC table (specified verbatim in [MS-ICE2] 3.1.4.8.2).

The change creates a compatibility breakage with legacy Lync clients
which will be fixed in following commits.

Differential Revision: https://phabricator.freedesktop.org/D1136

7 years agostun: add STUN_USAGE_ICE_COMPATIBILITY_MSICE2
Jakub Adam [Wed, 29 Jun 2016 06:39:02 +0000 (06:39 +0000)]
stun: add STUN_USAGE_ICE_COMPATIBILITY_MSICE2

Windows Live Messenger is a discontinued service. The only users of WLM
mode seem to be Lync clients, so STUN_USAGE_ICE_COMPATIBILITY_WLM2009
can be repurposed as [MS-ICE2] compatibility.

We keep the WLM enumerator for the sake of API compatibility.

Differential Revision: https://phabricator.freedesktop.org/D1135

8 years agoconncheck: invoke the debug dump in more places
Fabrice Bellet [Tue, 12 Apr 2016 11:20:38 +0000 (13:20 +0200)]
conncheck: invoke the debug dump in more places

Differential Revision: https://phabricator.freedesktop.org/D1123

8 years agoconncheck: fix pair socket assignment
Fabrice Bellet [Tue, 14 Jun 2016 18:44:55 +0000 (20:44 +0200)]
conncheck: fix pair socket assignment

This patch fixes a problem when a new pair having a peer-reflexive new
remote candidate is added while the transport type is udp. In this case
the new pair socket really should be the socket of the local candidate,
and not the remote (for example, the local candidate may be of relayed
type).

Differential Revision: https://phabricator.freedesktop.org/D1122

8 years agoconncheck: fix tick counter used for debug stats
Fabrice Bellet [Tue, 21 Jun 2016 19:32:11 +0000 (21:32 +0200)]
conncheck: fix tick counter used for debug stats

The tick counter variable used to display pairs statistics should be
per stream defined, to avoid side effects of a global variable, for
example always having an odd or even tick counter value when the agent
contains just two streams.

Differential Revision: https://phabricator.freedesktop.org/D1113

8 years agoagent: remove unused agent property
Fabrice Bellet [Tue, 21 Jun 2016 19:36:28 +0000 (21:36 +0200)]
agent: remove unused agent property

Differential Revision: https://phabricator.freedesktop.org/D1112

8 years agotest-turn: wait for gathering done sequentially
Fabrice Bellet [Tue, 21 Jun 2016 21:58:20 +0000 (23:58 +0200)]
test-turn: wait for gathering done sequentially

Fixes a bug in the logic of the wait loop, where only a single
gathering done was required to exit the loop, the other was caught
by the following assert.

Differential Revision: https://phabricator.freedesktop.org/D1110

8 years agoagent: Don't ask upnp to remove not yet allocated candidates
Olivier Crête [Tue, 21 Jun 2016 20:41:50 +0000 (16:41 -0400)]
agent: Don't ask upnp to remove not yet allocated candidates

This caused a warning in Farstream tests.

8 years agoagent: read from the correct TCP-TURN socket
Jakub Adam [Tue, 21 Jun 2016 08:43:49 +0000 (08:43 +0000)]
agent: read from the correct TCP-TURN socket

fileno of UDP-TURN NiceSocket is NULL since 0a6c779f and so we need
different means to identify the topmost socket.

Differential Revision: https://phabricator.freedesktop.org/D1100

8 years agoconncheck: dump timer status in the stream check list
Fabrice Bellet [Tue, 14 Jun 2016 18:34:52 +0000 (20:34 +0200)]
conncheck: dump timer status in the stream check list

Instead of printing the static pair priority values, it provides more
information to dump each pair timer state, next timeout, and
retranmission count, when debugging the whole connchecks list
content.

8 years agoconncheck: use strncmp instead of strcmp
Fabrice Bellet [Tue, 19 Apr 2016 18:46:34 +0000 (20:46 +0200)]
conncheck: use strncmp instead of strcmp

Differential Revision: https://phabricator.freedesktop.org/D931

8 years agotests: fix io-stream when built with optimizations
Fabrice Bellet [Thu, 16 Jun 2016 18:51:19 +0000 (20:51 +0200)]
tests: fix io-stream when built with optimizations

In construct like "while (foo);" when foo is modified outside of the
current thread, the variable should be declared volatile to suggest the
compiler to read its value without making code optimization.

8 years agostun: avoid expensive call to sprintf in debug-related code
Fabrice Bellet [Mon, 8 Feb 2016 19:20:06 +0000 (20:20 +0100)]
stun: avoid expensive call to sprintf in debug-related code

8 years agoagent: rework gathering failures on auto-generated IPs
Fabrice Bellet [Tue, 7 Jun 2016 08:52:02 +0000 (10:52 +0200)]
agent: rework gathering failures on auto-generated IPs

This patch reworks commit fc4d3aa "ignore gathering failures on
auto-generated IPs", that introduces a regression in the test-fullmode
check, when turn is on and use_loopback is off. The part of the test
that fails is when nice_agent_gather_candidates (ragent...) should
return false when the port range for the second component is already
busy, line 385.

In this case, agent->local_address is null, so the code path added by
commit fc4d3aa is taken, and the function will return true, even when
not local address has been gathered.

The proper fix is to swap the inner and outer loops (on components, and
on local addresses), and to go to error when all local addresses of a
given component have failed, and to return false only in this case.

8 years agoconncheck: state is connected when a pair is nominated
Fabrice Bellet [Mon, 6 Jun 2016 20:35:36 +0000 (22:35 +0200)]
conncheck: state is connected when a pair is nominated

This patch fixes is bug introduced in commit 1ab9d7c "conncheck:
Separate valid and succeded states", with the introduction of the valid
flag. The agent really should go to connected state when we have a
nominated pair, and not just a valid one.

8 years agotest-send-recv: reduce deadlock timeout
Fabrice Bellet [Thu, 16 Jun 2016 18:58:41 +0000 (20:58 +0200)]
test-send-recv: reduce deadlock timeout

8 years agopseudotcp-fuzzy: fix this test
Fabrice Bellet [Thu, 16 Jun 2016 22:31:48 +0000 (00:31 +0200)]
pseudotcp-fuzzy: fix this test

The header size should be 24 bytes only, if we don't want to fuzz the
payload too.  Moreover, the default lambda parameter is decreased to
one, to not fuzz the header too heavily, and consequently increase too
much the time for the test to complete, due to exponential
retransmission timeout when packets are corrupted.

8 years agopseudotcp: accept several FIN segments
Fabrice Bellet [Thu, 16 Jun 2016 22:28:16 +0000 (00:28 +0200)]
pseudotcp: accept several FIN segments

This modification allows to gracefully recover from a first
corrupted FIN segment.

8 years agobuild: fix build in alternate builddir
Fabrice Bellet [Tue, 19 Apr 2016 18:41:27 +0000 (20:41 +0200)]
build: fix build in alternate builddir

Differential Revision: https://phabricator.freedesktop.org/D930

8 years agoconncheck: Remove pairs before freeing candidate
Olivier Crête [Mon, 6 Jun 2016 22:31:22 +0000 (18:31 -0400)]
conncheck: Remove pairs before freeing candidate

Remove the whole pair before the candidate is
to be freed.

https://phabricator.freedesktop.org/T7460

8 years agostun timer: Do 7 retransmissions as recommended
Olivier Crête [Fri, 19 Feb 2016 20:01:03 +0000 (15:01 -0500)]
stun timer: Do 7 retransmissions as recommended

Also reduce the normal timeout to make the test bearable.

This is what RFC 5389 section 7.2.1

Differential Revision: https://phabricator.freedesktop.org/D1056
Maniphest Task: https://phabricator.freedesktop.org/T3339

8 years agotimer: Maximum retransmission should include the original one
Olivier Crête [Mon, 6 Jun 2016 20:21:54 +0000 (16:21 -0400)]
timer: Maximum retransmission should include the original one

We really care about the maximum transmissions, the first one counts.

8 years agopseudotcp: it's still a GObject
Olivier Crête [Fri, 3 Jun 2016 22:42:59 +0000 (18:42 -0400)]
pseudotcp: it's still a GObject

8 years agopseudotcp: Make sure duplicate ack representing losses have no data
Olivier Crête [Thu, 14 Apr 2016 11:32:51 +0000 (13:32 +0200)]
pseudotcp: Make sure duplicate ack representing losses have no data

If they have data in them, they won't be recognized as duplicate acks by
the sender.

8 years agopseudotcp: Implement NewReno timestamp heuristic
Olivier Crête [Thu, 14 Apr 2016 07:50:09 +0000 (09:50 +0200)]
pseudotcp: Implement NewReno timestamp heuristic

This allows the sender to enter fast retransmit after a timeout because
it can now detect that three duplicate acks are caused by a packet loss.

As specific in RFC 6582 section 4.2.

8 years agopseudotcp: Set min RTO to 1 second
Olivier Crête [Wed, 6 Apr 2016 07:46:46 +0000 (10:46 +0300)]
pseudotcp: Set min RTO to 1 second

This is recommended by RFC 6298

8 years agopseudotcp: Implement full NewReno
Olivier Crête [Tue, 5 Apr 2016 22:59:36 +0000 (01:59 +0300)]
pseudotcp: Implement full NewReno

8 years agopseudotcp: Make debug more useful
Olivier Crête [Tue, 2 Feb 2016 21:59:18 +0000 (16:59 -0500)]
pseudotcp: Make debug more useful

8 years agopseudotcp: Separate default and maximum MTU
Olivier Crête [Wed, 13 Jan 2016 01:14:48 +0000 (20:14 -0500)]
pseudotcp: Separate default and maximum MTU

Accept packets much beyond the default MTU, but
set a reasonable default MTU for sending of 1400

8 years agopseudotcp: close local socket on initial transmission error
Olivier Crête [Thu, 24 Dec 2015 06:15:59 +0000 (01:15 -0500)]
pseudotcp: close local socket on initial transmission error

This is required as no retransmissions will happen

8 years agopseudotcp: Export more symbols for PseudoTCP
Olivier Crête [Fri, 18 Sep 2015 01:26:36 +0000 (21:26 -0400)]
pseudotcp: Export more symbols for PseudoTCP

8 years agopseudotcp: Make structs definitions private
Olivier Crête [Thu, 17 Sep 2015 19:00:27 +0000 (15:00 -0400)]
pseudotcp: Make structs definitions private

8 years agopseudotcp: Correct behaviour of buffer size methods when part-closed
Philip Withnall [Tue, 23 Jun 2015 14:42:33 +0000 (15:42 +0100)]
pseudotcp: Correct behaviour of buffer size methods when part-closed

Correct the behaviour of pseudo_tcp_socket_get_available_bytes() and
pseudo_tcp_get_available_send_space() when the socket is not in
TCP_ESTABLISHED state. It’s still permissible to send and receive up
until the local side calls pseudo_tcp_socket_close(), which means we
may be in state TCP_ESTABLISHED *or TCP_CLOSE_WAIT*.

8 years agopseudotcp: Fix EOS checks in high packet loss situations
Philip Withnall [Fri, 31 Jul 2015 13:28:51 +0000 (14:28 +0100)]
pseudotcp: Fix EOS checks in high packet loss situations

The state tracking previously assumed that if a FIN packet was sent, the
other side received it and the preceding packets, and hence it was
correct to sent an RST if an unexpected packet (such as a delayed
SYN-ACK) was received.

In cases where there is high packet loss, this won’t work. For example,
peer A sends a SYN, it is received and peer B replies with a SYN-ACK
which is also received; then peer A sends its data and a FIN, which are
both dropped. Since it hasn’t received anything since the original SYN,
peer B resends its SYN-ACK. If that is received, peer A was incorrectly
treating it as an erroneous packet, and would then send a RST. In actual
fact, it should take this as a signal that the data and FIN packets were
dropped, and should resend them.

TODO: Add unit tests

8 years agopseudotcp: Propagate error codes from transmit() to callers
Philip Withnall [Fri, 31 Jul 2015 13:19:30 +0000 (14:19 +0100)]
pseudotcp: Propagate error codes from transmit() to callers

Otherwise we can’t easily differentiate between different transmission
failures; for example: underlying socket failures, versus retransmission
timeouts.

8 years agopseudotcp: Add more debug info on closing down a pseudo-TCP socket
Philip Withnall [Tue, 23 Jun 2015 14:40:13 +0000 (15:40 +0100)]
pseudotcp: Add more debug info on closing down a pseudo-TCP socket

8 years agopseudotcp: Fix pseudo_tcp_socket_recv() in state TCP_CLOSE_WAIT
Philip Withnall [Wed, 24 Jun 2015 13:06:05 +0000 (14:06 +0100)]
pseudotcp: Fix pseudo_tcp_socket_recv() in state TCP_CLOSE_WAIT

Previously, pseudo_tcp_socket_recv() would start returning 0 (EOS) as
soon as a FIN segment was received from the peer, even if there was
unread data already in the receive buffer.

Instead, the unread data should all be accessible before
pseudo_tcp_socket_recv() starts returning 0.

8 years agopseudotcp: Fix retransmission of segments before handling a FIN
Philip Withnall [Wed, 24 Jun 2015 12:52:16 +0000 (13:52 +0100)]
pseudotcp: Fix retransmission of segments before handling a FIN

Previously, if peer A transmitted one or more data segments (1),
followed by a FIN segment (2) to peer B, and segments 1 were
dropped, peer B would not request retransmission of them and would
instead continue with the FIN handshake. This effectively meant
segments 1 were lost without peer B realising.

Fix this by only handling the FIN segment once its sequence number is
acknowledged in the receive window.

8 years agosocket: Assert trying to use free'd socket
Olivier Crête [Thu, 2 Jun 2016 23:22:50 +0000 (19:22 -0400)]
socket: Assert trying to use free'd socket

Cleanly returnign makes no sense and may hide
worse problems.

8 years agocomponent: Fix set TCP selected remote candidate
Misha Uliutin [Mon, 25 Apr 2016 06:59:48 +0000 (09:59 +0300)]
component: Fix set TCP selected remote candidate

https://phabricator.freedesktop.org/T7407

8 years agoagent: Parse TURN packet on the right socket
Olivier Crête [Thu, 2 Jun 2016 23:00:17 +0000 (19:00 -0400)]
agent: Parse TURN packet on the right socket

https://phabricator.freedesktop.org/T99

8 years agotests: Add TURN test
Olivier Crête [Thu, 2 Jun 2016 21:34:27 +0000 (17:34 -0400)]
tests: Add TURN test

This test depends on rfc5766-turn-server which must
be installed for this test to run.

8 years agoconncheck: mark discovered pairs with TCP passive as valid
Jakub Adam [Tue, 31 May 2016 11:42:44 +0000 (11:42 +0000)]
conncheck: mark discovered pairs with TCP passive as valid

Doing so similarly to priv_process_response_check_for_reflexive(),
which also sets valid flag on discovered peer reflexive pairs.

Fixes a regression in previously working scenario.
Differential Revision: https://phabricator.freedesktop.org/D1035

8 years agotest-icetcp: don't be sensitive to the signal order
Jakub Adam [Wed, 1 Jun 2016 08:52:41 +0000 (08:52 +0000)]
test-icetcp: don't be sensitive to the signal order

"new-selected-pair" may be emitted after "component-state-changed"
to READY, by which time the main loop might have gotten quit in
cb_component_state_changed(). Consequently, cb_new_selected_pair() could
miss to register the selected pair, ultimately leading to an assertion
failure in main().

We should wait for both selected pair and state change events to occur
before stopping the main loop.

Differential Revision: https://phabricator.freedesktop.org/D1044

8 years agoRevert "WIP"
Olivier Crête [Tue, 31 May 2016 21:31:18 +0000 (17:31 -0400)]
Revert "WIP"

This reverts commit 01519677ba4d8df46e2c07bc20a5ef03ee2d9c3a.

8 years agoWIP
Olivier Crête [Tue, 31 May 2016 21:31:12 +0000 (17:31 -0400)]
WIP

8 years agoconncheck: fix pruning conn checks with TCP active sockets
Jakub Adam [Tue, 31 May 2016 09:27:03 +0000 (09:27 +0000)]
conncheck: fix pruning conn checks with TCP active sockets

TCP active socket makes a NiceSocket for each peer in conn_check_send()
and this new socket is then stored as CandidateCheckPair's 'sockptr'.
We thus have to look also at the 'sockptr' value when eliminating
sockets which have received HUP from connection checks.
Differential Revision: https://phabricator.freedesktop.org/D1034

8 years agoagent: Remove socket on read error
Olivier Crête [Tue, 8 Mar 2016 20:37:05 +0000 (15:37 -0500)]
agent: Remove socket on read error

If a socket returned an error, remove it.

8 years agocomponent: Add API to cleanly remove a base socket
Olivier Crête [Sat, 16 Jan 2016 03:40:27 +0000 (22:40 -0500)]
component: Add API to cleanly remove a base socket

8 years agoagent: Fix udp-turn-over-tcp
Olivier Crête [Sat, 27 Feb 2016 08:35:27 +0000 (03:35 -0500)]
agent: Fix udp-turn-over-tcp

The TCP-based turns don't come pre-parsed unlike
the UDP variants!

8 years agoagent: Add force-relay property to force messages through the relay
Olivier Crête [Wed, 27 Jan 2016 23:56:13 +0000 (18:56 -0500)]
agent: Add force-relay property to force messages through the relay

This allows implementing WebRTC privacy mode.

8 years agoconncheck: Start conncheck on server reply if needed
Olivier Crête [Wed, 10 Feb 2016 21:29:57 +0000 (16:29 -0500)]
conncheck: Start conncheck on server reply if needed

This only really applies in the force relay mode where there are
no local candidates.

8 years agoReplace g_malloc/g_new with g_alloca where possible
Olivier Crête [Mon, 8 Feb 2016 21:44:47 +0000 (16:44 -0500)]
Replace g_malloc/g_new with g_alloca where possible

This should reduce the overhead a bit.

8 years agoconncheck: explain some corner cases
Fabrice Bellet [Wed, 20 Apr 2016 10:17:05 +0000 (10:17 +0000)]
conncheck: explain some corner cases

This patch give details why some exceptions to the ICE spec are needed.

Differential Revision: https://phabricator.freedesktop.org/D876

8 years agoconncheck: add a debug dump of the whole stream check list
Fabrice Bellet [Fri, 27 May 2016 23:15:39 +0000 (19:15 -0400)]
conncheck: add a debug dump of the whole stream check list

https://phabricator.freedesktop.org/D814

8 years agoconncheck: fix the replay of early incoming connchecks
Olivier Crête [Fri, 27 May 2016 22:50:59 +0000 (18:50 -0400)]
conncheck: fix the replay of early incoming connchecks

This patch fixes a bug in the way the list of incoming checks
is handled. The code purges this list too early, before all ichecks
for a given component are processed. It happens because the component
is computed from each pair of the check list, instead of being passed
as a fixed parameter of the function.

Differential Revision: https://phabricator.freedesktop.org/D882

8 years agostun: fix ice role conflict handling
Fabrice Bellet [Wed, 20 Apr 2016 09:23:14 +0000 (09:23 +0000)]
stun: fix ice role conflict handling

This patch fixes the role conflict handling in stun ICE usage,
according to RFC 5245, by adding including missing cases in the
test. The role switch not only depends of the comparison of the
stun ice-controlling/controlled attrib with the agent tie breaker
value, but it also depends on the current role of the agent.

This patch also changes the value returned by
stun_usage_ice_conncheck_create_reply() when a role conflict exists
but doesn't change the role of the agent, causing an error stun
response. Previously, this case could not be differenciated by the
caller from a case with no role conflict. Now by examinating the
return value, and whether the control param changed, the caller
can check the four possibles situations. The stun test suite is
updated to match this change.

Differential Revision: https://phabricator.freedesktop.org/D873

8 years agoconncheck: Make previous commit compile
Olivier Crête [Fri, 27 May 2016 21:26:06 +0000 (17:26 -0400)]
conncheck: Make previous commit compile

https://phabricator.freedesktop.org/T3324

8 years agodiscovery: Make sure each candidate has a unique priority
Olivier Crête [Mon, 8 Feb 2016 23:49:42 +0000 (18:49 -0500)]
discovery: Make sure each candidate has a unique priority

This should fix compliance with RFC 5245 Section 4.1.2

https://phabricator.freedesktop.org/T3324