platform/upstream/libnice.git
8 years agoagent: Only try to use the address of the same family to connect to TURN
Olivier Crête [Tue, 9 Feb 2016 17:52:45 +0000 (12:52 -0500)]
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.

8 years agostun turn usage: Only send the username if short term creds or nonce present
Olivier Crête [Mon, 8 Feb 2016 00:48:07 +0000 (19:48 -0500)]
stun turn usage: Only send the username if short term creds or nonce present

This is recommended by the STUN RFC 5389.

8 years agoturn: Cache the nonce & realm to remove useless round trips
Olivier Crête [Mon, 8 Feb 2016 00:41:52 +0000 (19:41 -0500)]
turn: Cache the nonce & realm to remove useless round trips

Instead of re-discovering the nonce and realm for every request, cache them
in th socket.

8 years agoconncheck: Stay READY if a new nominated pairs comes in
Olivier Crête [Tue, 9 Feb 2016 16:18:30 +0000 (11:18 -0500)]
conncheck: Stay READY if a new nominated pairs comes in

8 years agoconncheck: Deduplicate conncheck stopping code
Olivier Crête [Tue, 9 Feb 2016 02:04:24 +0000 (21:04 -0500)]
conncheck: Deduplicate conncheck stopping code

8 years agoReset to connecting if reconnected after failed
Olivier Crête [Tue, 9 Feb 2016 00:41:28 +0000 (19:41 -0500)]
Reset to connecting if reconnected after failed

8 years agoagent: Add warning on ignored result
Olivier Crête [Thu, 14 Jan 2016 22:59:16 +0000 (17:59 -0500)]
agent: Add warning on ignored result

8 years agoconncheck: display controlling mode of stun requests
Fabrice Bellet [Mon, 4 Apr 2016 22:02:52 +0000 (23:02 +0100)]
conncheck: display controlling mode of stun requests

This patch makes the debug log more explicit about the agent
controlling role for each stun request sent. It helps to debug
role conflict resolution.

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

8 years agoagent: remove newline from debug output
Fabrice Bellet [Mon, 4 Apr 2016 21:38:07 +0000 (22:38 +0100)]
agent: remove newline from debug output

Just a cosmetic fix.

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

8 years agosocket: refactor nice_socket_is_base_of()
Jakub Adam [Mon, 4 Apr 2016 20:52:29 +0000 (21:52 +0100)]
socket: refactor nice_socket_is_base_of()

• rename to nice_socket_is_based_on() and swap the order of arguments
   accordingly; the implementation doesn't have to use the confusing
   'return other->is_base_of()' pattern anymore
 • fix potential NULL dereferences

The argument order in agent_recv_message_unlocked() was already wrongly
swapped in 1732c7d6 and thus this commit isn't changing it back because
that order has become the correct one.

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

8 years agosocket: fix wrong function called in nice_socket_is_base_of()
Jakub Adam [Mon, 4 Apr 2016 20:46:05 +0000 (21:46 +0100)]
socket: fix wrong function called in nice_socket_is_base_of()

We have to call is_base_of "virtual function pointer" of 'other'
object, not 'sock', since 'other' is the structure whose base
NiceSocket we need to get from its private data.

For instance calling nice_socket_is_base_of() with 'sock' and 'other'
being respectively pseudo-SSL and UDP-TURN-over-TCP invoked is_base_of
variant for pseudo-SSL, casting other->priv into PseudoSSLPriv *, but
other->priv is actually TurnTcpPriv *. It must be called the other way
around.

https://phabricator.freedesktop.org/T7335
https://phabricator.freedesktop.org/T7336

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Reviewed-by: José Antonio Santos Cadenas <santoscadenas@gmail.com>
Reviewed-by: Philip Withnall <philip@tecnocode.co.uk>
Reviewed-by: José Antonio Santos Cadenas <santoscadenas@gmail.com>
Differential Revision: https://phabricator.freedesktop.org/D785

8 years agoconncheck: implement a "triggered queue" list
Fabrice Bellet [Mon, 4 Apr 2016 20:38:59 +0000 (21:38 +0100)]
conncheck: implement a "triggered queue" list

The checks should not be sent immediately in priv_conn_check_initiate(),
but be put into the "triggered queue", see  "7.2.1.4 Triggered Checks".
This patch implements this triggered checks list, and uses it to enforce a
pacing of STUN transactions, no more than one per Ta ms, according to
"B.1. Pacing of STUN Transactions".

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

8 years agoagent: Fix argument order
Olivier Crête [Sun, 6 Mar 2016 20:16:18 +0000 (15:16 -0500)]
agent: Fix argument order

Fixes crash reported on https://phabricator.freedesktop.org/D786

8 years agoice: fix the debug of the presence of the controlling/controlled attrib
Fabrice Bellet [Sat, 5 Mar 2016 18:46:48 +0000 (18:46 +0000)]
ice: fix the debug of the presence of the controlling/controlled attrib

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

8 years agoagent: fix relay candidate discovery on hosts having several IPs
Jakub Adam [Wed, 2 Mar 2016 00:01:19 +0000 (00:01 +0000)]
agent: fix relay candidate discovery on hosts having several IPs

When a message is received from a TURN server and we manage to find a
local relay candidate with matching stream and component IDs, we should
also check whether the message came from the candidate's respective
socket.

We should do this because there might still be some pending TURN
candidate discovery with the same server from a different local host IP
and the message may be a response to our allocate request. If
nice_udp_turn_socket_parse_recv_message() is passed such request, it can
make some wrong assumptions and modify it like in the case of reliable
UDP-TURN-OVER-TCP by removing (supposed) RFC4571 framing, which in turn
causes the reply to be unrecognized and discarded.

Because of this, any subsequent replies following the first successful
allocate response from that server couldn't create any additional relay
candidates.

Maniphest Tasks: https://phabricator.freedesktop.org/T7336

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

8 years agobuild: Update autogen.sh from GNOME template
Philip Withnall [Tue, 1 Mar 2016 23:50:11 +0000 (23:50 +0000)]
build: Update autogen.sh from GNOME template

https://wiki.gnome.org/Projects/GnomeCommon/Migration#autogen.sh

8 years agocomponent.c: Fix memory leak
Olivier Crête [Tue, 1 Mar 2016 23:29:10 +0000 (23:29 +0000)]
component.c: Fix memory leak

If nicesocket is not added to a component it will be leaked.

This is the case of active tcp sockets

Change-Id: I57fefffef71d35ce9871139ee1064181f6fe125b
Reviewed-by: José Antonio Santos Cadenas <santoscadenas@gmail.com>
Differential Revision: https://phabricator.freedesktop.org/D822

8 years agoagent: Use provided CandidatePair rather than re-finding a pair
Philip Withnall [Tue, 1 Mar 2016 23:23:14 +0000 (23:23 +0000)]
agent: Use provided CandidatePair rather than re-finding a pair

In priv_update_selected_pair(), commit 57393333 changed the code to
re-find a CandidatePair matching the given lfoundation and rfoundation.
However, the foundation does not uniquely identify candidate pairs,
and if we’re aiming to set a specific candidate pair as the selected
pair, this could result in the wrong pair being selected.

This can happen when handling multiple similar candidate pairs, such as
when generating peer reflexive candidates from multiple sources.

See https://tools.ietf.org/html/rfc5245#section-2.4.

Originally spotted by Fabrice Bellet in
https://phabricator.freedesktop.org/T3557.

Reviewed-by: José Antonio Santos Cadenas <santoscadenas@gmail.com>
Differential Revision: https://phabricator.freedesktop.org/D742

8 years agosimple-example: transmission can begin earlier than in ready state
Philip Withnall [Tue, 1 Mar 2016 23:05:20 +0000 (23:05 +0000)]
simple-example: transmission can begin earlier than in ready state

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

8 years agotest-new-dribble: wait until ragent reaches state completed
Philip Withnall [Tue, 1 Mar 2016 23:04:14 +0000 (23:04 +0000)]
test-new-dribble: wait until ragent reaches state completed

The test didn't let enough time for ragent to reach the completed state
after obtaining its remote candidates and switching to connecting state.

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

8 years agoconncheck: reorder the connection list when priorities are updated
Philip Withnall [Tue, 1 Mar 2016 23:02:52 +0000 (23:02 +0000)]
conncheck: reorder the connection list when priorities are updated

The update of pairs priorities due to agent role change requires the
conncheck list to be reordered to reflect this modification.

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

8 years agoconncheck: fix keepalive stun agent initialisation
Philip Withnall [Tue, 1 Mar 2016 23:01:14 +0000 (23:01 +0000)]
conncheck: fix keepalive stun agent initialisation

With this patch, we send keepalive binding requests using agent
compatibility flags, instead of RFC 3489 classic stun. The peer stun
agent will known how to handle it, and won't be confused by the
uncompatible RFC 3489 message, causing "no cookie" errors in the debug
log.

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

8 years agoconncheck: foundations are shared across streams
Philip Withnall [Tue, 1 Mar 2016 22:58:15 +0000 (22:58 +0000)]
conncheck: foundations are shared across streams

This patch fixes a bug where the foundation definition shouldn't take
into account the stream the pair belongs to. This is important, because
the ordinary checks algorithm will change pair state from Frozen to
Waiting, by selecting pairs from other streams sharing the same
foundation than already succeeded pairs.

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

8 years agotest-priority: ignore the local preference
Philip Withnall [Tue, 1 Mar 2016 22:37:33 +0000 (22:37 +0000)]
test-priority: ignore the local preference

The local preference depends on the rank of the IP address in the list
of all IP addresses available of the box running the test. As this value
is not fixed we ignore it in the test.

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

8 years agoconncheck: nominate only one matching pair
Philip Withnall [Tue, 1 Mar 2016 22:33:51 +0000 (22:33 +0000)]
conncheck: nominate only one matching pair

This patch fixes a bug in priv_mark_pair_nominated(), where the local
candidate was not passed to the function, so removing the possibility to
find which local candidate the check was sent to.

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

8 years agoconncheck: add more debug information
Philip Withnall [Tue, 1 Mar 2016 22:28:35 +0000 (22:28 +0000)]
conncheck: add more debug information

Add a more debug details, specifically in some places, it is interesting
to have the src and dst IP addresses of the pairs being checked, and
also to make the difference between log related to different stream ids.

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

8 years agoagent: Fix not setting UPnP timeout on second gather_candidates()
Mike Ruprecht [Mon, 18 Jan 2016 12:42:46 +0000 (12:42 +0000)]
agent: Fix not setting UPnP timeout on second gather_candidates()

If the first call to nice_agent_gather_candidates() partially succeeds
(setting a UPnP agent and timeout), then fails before starting
gathering, a second call to nice_agent_gather_candidates() would fail to
set a new UPnP timeout because the UPnP initialisation block would be
skipped. That means gathering would never succeed due to timing out on
UPnP.

Fix that by setting the UPnP timeout whenever a new pending UPnP mapping
is added.

https://phabricator.freedesktop.org/T3534

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
8 years agoconfigure.ac: Update glib version
Jose Antonio Santos Cadenas [Thu, 3 Dec 2015 14:01:35 +0000 (15:01 +0100)]
configure.ac: Update glib version

As udp-bsd.ccode is using G_IO_ERROR_CONNECTION_CLOSED glib 2.44
is required.

Change-Id: I1bb63f2484c513c58eeec312ba0835164604c40c
Reviewed-by: Philip Withnall <philip@tecnocode.co.uk>
https://phabricator.freedesktop.org/T3492

8 years agopseudotcp: Use labs() rather than abs() for handling long integers
Philip Withnall [Wed, 7 Oct 2015 18:03:58 +0000 (19:03 +0100)]
pseudotcp: Use labs() rather than abs() for handling long integers

This fixes a compiler warning and prevents a possible truncation.

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

8 years agotests: Enable G_MESSAGES_DEBUG for all unit tests
Philip Withnall [Mon, 22 Jun 2015 10:30:31 +0000 (11:30 +0100)]
tests: Enable G_MESSAGES_DEBUG for all unit tests

Now that we’re using automake’s parallel test harness, it automatically
redirects all the debug log spew away from the console, so we should
always have it enabled.

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

8 years agobuild: Set repository callsign in .arcconfig
Philip Withnall [Thu, 1 Oct 2015 16:52:08 +0000 (17:52 +0100)]
build: Set repository callsign in .arcconfig

This fixes `arc diff` to select the right repository when submitting
patches.

8 years agoagent: Correctly namespace Component and its methods
Philip Withnall [Wed, 30 Sep 2015 13:57:10 +0000 (14:57 +0100)]
agent: Correctly namespace Component and its methods

Remove all references to the old, unnamespaced versions. This should
cause no functional changes.

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

8 years agoagent: Correctly namespace Stream and its methods
Philip Withnall [Wed, 30 Sep 2015 13:34:34 +0000 (14:34 +0100)]
agent: Correctly namespace Stream and its methods

Remove all references to the old, unnamespaced versions. This should
cause no functional changes.

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

8 years agoagent: Turn Component into a GObject
Philip Withnall [Wed, 30 Sep 2015 13:11:14 +0000 (14:11 +0100)]
agent: Turn Component into a GObject

This makes it reference-counted. This will be useful for allowing
GDatagramBased and GIOStream objects to hold references to the stream
and component they are interested in, allowing removal of the global
NiceAgent lock previously needed to look up the component for every I/O
operation.

Deprecate all the old methods until it’s properly namespaced.

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

8 years agoagent: Turn Stream into a GObject
Philip Withnall [Wed, 30 Sep 2015 13:10:32 +0000 (14:10 +0100)]
agent: Turn Stream into a GObject

This makes it reference-counted. This will be useful for allowing
GDatagramBased and GIOStream objects to hold references to the stream
and component they are interested in, allowing removal of the global
NiceAgent lock previously needed to look up the component for every I/O
operation.

It also means that nice_stream_close() could eventually become
asynchronous, which would fix a few race conditions.

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

8 years agotests: Update expected priority values in test-priority
Philip Withnall [Wed, 30 Sep 2015 16:59:04 +0000 (17:59 +0100)]
tests: Update expected priority values in test-priority

This is a follow up to T3324, to update the test case to match the new
values generated.

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

8 years agotests: Use g_assert_cmpuint() to make test failures easier to diagnose
Philip Withnall [Wed, 30 Sep 2015 16:54:21 +0000 (17:54 +0100)]
tests: Use g_assert_cmpuint() to make test failures easier to diagnose

Now we can actually see the priority numbers which are unequal.

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

8 years agotests: Set candidate addresses in test-priority
Philip Withnall [Wed, 30 Sep 2015 16:53:14 +0000 (17:53 +0100)]
tests: Set candidate addresses in test-priority

This avoids an assertion failure in nice_address_to_string() when the
addresses are compared for priority.

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

8 years agoagent: Remove redundant GLIB_CHECK_VERSION macros
Philip Withnall [Wed, 30 Sep 2015 16:46:47 +0000 (17:46 +0100)]
agent: Remove redundant GLIB_CHECK_VERSION macros

We depend on GLib 2.36.0, which is a higher version than any of these
version checks cared about, so they were all trivially true or false.

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

8 years agotests: Remove g_thread_init() calls
Philip Withnall [Wed, 30 Sep 2015 16:44:44 +0000 (17:44 +0100)]
tests: Remove g_thread_init() calls

We depend on GLib 2.36.0; g_thread_init() has been deprecated since
2.32.0, when thread initialisation was changed to happen automatically.

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

8 years agotests: Remove g_type_init() calls
Philip Withnall [Wed, 30 Sep 2015 16:41:36 +0000 (17:41 +0100)]
tests: Remove g_type_init() calls

We depend on GLib 2.36.0, which deprecated g_type_init() since GType
initialisation is now done automatically.

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

8 years agoconncheck: rename priv_process_response_check_for_peer_reflexive()
Jakub Adam [Fri, 11 Sep 2015 10:57:54 +0000 (11:57 +0100)]
conncheck: rename priv_process_response_check_for_peer_reflexive()

Renamed the function to priv_process_response_check_for_reflexive()
because it now checks also for server reflexive candidates.

Updated the documentation to indicate that the function never returns
NULL.

Maniphest Tasks: https://phabricator.freedesktop.org/T115
Differential Revision: https://phabricator.freedesktop.org/D243
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
8 years agoconncheck: generate candidate pair for valid srflx candidate
Jakub Adam [Fri, 11 Sep 2015 10:56:02 +0000 (11:56 +0100)]
conncheck: generate candidate pair for valid srflx candidate

In priv_process_response_check_for_peer_reflexive(), mere presence of a candidate in local_candidates doesn't mean there's also some candidate
pair in conncheck_list using it - for instance that candidate may be server reflexive, for which no check pairs are initially created (see
conn_check_add_for_candidate_pair()).

If we fail to find corresponding pair upon receiving such candidate's IP in a conncheck response's XOR-MAPPED-ADDRESS attribute, we shall add a
new one in a similar way we would add a new pair for a just discovered peer reflexive candidate.

Previous priv_process_response_check_for_peer_reflexive() implementation would return NULL, causing a CandidateCheckPair with local candidate of
type HOST to be wrongly selected even though the local host IP might not be directly accessible by the remote counterpart (e.g. it's an address
on a private network segment). In practice this was coming through as a duplex connection that libnice was reporting as properly established,
but only one direction of the communication was actually working.

Maniphest Tasks: https://phabricator.freedesktop.org/T115
Differential Revision: https://phabricator.freedesktop.org/D242
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
8 years agoagent: check for base socket in _tcp_sock_is_writable()
Jakub Adam [Fri, 11 Sep 2015 10:33:51 +0000 (11:33 +0100)]
agent: check for base socket in _tcp_sock_is_writable()

The argument passed into the callback is always a base (TCP/UDP) socket,
which can't be directly compared with local candidate's sockptr (may be
TURN, http, or other socket wrapping another one). We're in fact
interested whether sock is a base socket of sockptr.

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

8 years agosocket: add nice_socket_is_base_of()
Jakub Adam [Fri, 11 Sep 2015 10:29:39 +0000 (11:29 +0100)]
socket: add nice_socket_is_base_of()

This will be used in the next commit.

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

9 years agobuild: Bump GLib dependency to 2.36
Philip Withnall [Thu, 10 Jul 2014 07:32:04 +0000 (08:32 +0100)]
build: Bump GLib dependency to 2.36

This is needed for G_IO_ERROR_BROKEN_PIPE, which is used in the I/O
stream code.

Reported by Emanuele Bizzarri <emabiz76@gmail.com> on the mailing list.

9 years agostun: Disable debug by default
Philip Withnall [Fri, 4 Sep 2015 07:14:08 +0000 (08:14 +0100)]
stun: Disable debug by default

To match debug_enable in agent/debug.c. Debug can still be enabled by
calling stun_debug_enable() or nice_debug_enable().

Spotted on the mailing list by Tom Chen.

9 years agoagent: Add assertions to check component state transitions are valid
Philip Withnall [Mon, 29 Jun 2015 15:30:12 +0000 (16:30 +0100)]
agent: Add assertions to check component state transitions are valid

There is no point in the NiceComponents having a state machine if the
state transition graph is not documented or enforced. Document and
enforce it.

http://phabricator.freedesktop.org/T120

9 years agoms-ice: ensure distinct candidate priority for multihomed hosts
Philip Withnall [Wed, 2 Sep 2015 15:44:45 +0000 (16:44 +0100)]
ms-ice: ensure distinct candidate priority for multihomed hosts

Summary:
Offering multiple host candidates with equal priorities could lead to unpredictable candidate pair selection by our counterparty.

Fixes call disconnection by MS Lync client after 30 seconds while VPN (2nd IP) was active on libnice host.

Maniphest Tasks: T3324

Reviewers: pwithnall

Projects: #libnice

Reviewed By: pwithnall

Subscribers: pwithnall

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

9 years agocandidate: use distinct priority also for non-MS compatibilities
Jakub Adam [Wed, 2 Sep 2015 15:43:02 +0000 (16:43 +0100)]
candidate: use distinct priority also for non-MS compatibilities

Maniphest Tasks: T3324

Reviewers: pwithnall

Projects: #libnice

Reviewed By: pwithnall

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

9 years agoconncheck: give temporary candidate_priority a base_addr
Jakub Adam [Wed, 2 Sep 2015 15:41:49 +0000 (16:41 +0100)]
conncheck: give temporary candidate_priority a base_addr

Summary:
Fixes "(nice_address_to_string): should not be reached" errors when calling nice_candidate_ms_ice_priority() because of invalid NiceAddress.

Maniphest Tasks: T3324

Reviewers: pwithnall

Projects: #libnice

Reviewed By: pwithnall

Subscribers: pwithnall

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

9 years agoms-ice: ensure distinct candidate priority for multihomed hosts
Jakub Adam [Wed, 2 Sep 2015 15:41:49 +0000 (16:41 +0100)]
ms-ice: ensure distinct candidate priority for multihomed hosts

Summary:
Offering multiple host candidates with equal priorities could lead to unpredictable candidate pair selection by our counterparty.

Fixes call disconnection by MS Lync client after 30 seconds while VPN (2nd IP) was active on libnice host.

Maniphest Tasks: T3324

Reviewers: pwithnall

Projects: #libnice

Reviewed By: pwithnall

Subscribers: pwithnall

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

9 years agodiscovery: assign candidate priority after base_addr is set
Jakub Adam [Wed, 2 Sep 2015 15:41:48 +0000 (16:41 +0100)]
discovery: assign candidate priority after base_addr is set

Summary: So that we can take the base address into account in the calculation.

Maniphest Tasks: T3324

Reviewers: pwithnall

Projects: #libnice

Reviewed By: pwithnall

Subscribers: pwithnall

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

9 years agoms-turn: don't wait for a reply to STUN_SEND request
Philip Withnall [Wed, 2 Sep 2015 15:34:01 +0000 (16:34 +0100)]
ms-turn: don't wait for a reply to STUN_SEND request

Maniphest Tasks: T126

Reviewers: pwithnall

Projects: #libnice

Reviewed By: pwithnall

Subscribers: pwithnall

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

9 years agoms-turn: don't wait for a reply to STUN_SEND request
Jakub Adam [Wed, 2 Sep 2015 15:32:05 +0000 (16:32 +0100)]
ms-turn: don't wait for a reply to STUN_SEND request

As per [MS-TURN] Section 2.2.1, TURN message type 0x0104 "Send request
response" isn't supported and the TURN server MUST NOT send them. Thus,
libnice should not remember Send requests in agent->sent_ids because
without replies coming, the number of allowed pending transaction gets
quickly exhausted, causing our data packets to be dropped until a
request timeout frees some space in the queue.

This behavior resulted in choppy reception of our audio on a Lync client
when connected via Lync Edge (TURN) Server.

Maniphest Tasks: T126

Reviewers: pwithnall

Projects: #libnice

Reviewed By: pwithnall

Subscribers: pwithnall

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

9 years agoCreating TCP sockets with TCP_NODELAY option set to TRUE
Philip Withnall [Sat, 29 Aug 2015 22:26:00 +0000 (23:26 +0100)]
Creating TCP sockets with TCP_NODELAY option set to TRUE

Summary:
Disable Nagling for underlying TCP sockets used by libnice, because they
are typically used for streaming applications, or for pseudo-TCP; the
bandwidth in both cases is harmed by Nagling.

Based on a patch by Vadim Genkin.

Maniphest Tasks: T3317

Reviewers: vadimgenkin, pwithnall

Projects: #libnice

Reviewed By: pwithnall

Subscribers: pwithnall, vadimgenkin

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

9 years agoCreating TCP sockets with TCP_NODELAY option set to TRUE
Philip Withnall [Sat, 29 Aug 2015 21:39:56 +0000 (22:39 +0100)]
Creating TCP sockets with TCP_NODELAY option set to TRUE

Disable Nagling for underlying TCP sockets used by libnice, because they
are typically used for streaming applications, or for pseudo-TCP; the
bandwidth in both cases is harmed by Nagling.

Based on a patch by Vadim Genkin.

Maniphest Tasks: T3317

Reviewers: pwithnall

Projects: #libnice

Subscribers: pwithnall, vadimgenkin

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

9 years agoFix agent leak in case component socket is reset remotely
Philip Withnall [Sat, 29 Aug 2015 19:05:00 +0000 (20:05 +0100)]
Fix agent leak in case component socket is reset remotely

Summary: The patch fixes the issue where agent reference count is not properly decremented causing instance leak in cases where component's socket is reset remotely.

Reviewers: #libnice, pwithnall

Projects: #libnice

Reviewed By: #libnice, pwithnall

Subscribers: pwithnall, maximgolunov

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

9 years agoFix agent leak in case component socket is reset remotely
Philip Withnall [Sat, 29 Aug 2015 19:04:03 +0000 (20:04 +0100)]
Fix agent leak in case component socket is reset remotely

Summary: The patch fixes the issue where agent reference count is not properly decremented causing instance leak in cases where component's socket is reset remotely.

Reviewers: #libnice, pwithnall

Projects: #libnice

Reviewed By: #libnice, pwithnall

Subscribers: pwithnall, maximgolunov

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

9 years agobuild: Update .gitignore
Philip Withnall [Wed, 19 Aug 2015 08:24:27 +0000 (09:24 +0100)]
build: Update .gitignore

Add stun/usages/.dirstamp.

9 years agobuild: Fix multiple definition of CLEANFILES
Philip Withnall [Wed, 19 Aug 2015 08:22:49 +0000 (09:22 +0100)]
build: Fix multiple definition of CLEANFILES

It’s already defined in common.mk.

9 years agobuild: Add .arcconfig file
Philip Withnall [Wed, 19 Aug 2015 08:20:01 +0000 (09:20 +0100)]
build: Add .arcconfig file

This completes the transition to Phabricator; everyone should be using
the same project settings now.

https://phabricator.freedesktop.org/tag/libnice/

9 years agosocket: Handle ECONNRESET as EWOULDBLOCK on Windows
Philip Withnall [Wed, 19 Aug 2015 08:19:18 +0000 (09:19 +0100)]
socket: Handle ECONNRESET as EWOULDBLOCK on Windows

Summary:
Some versions of Windows can return ECONNRESET for UDP recvmsg() calls
if they would otherwise block. Hence, handle the two equivalently; this
should not affect behaviour on Linux, which apparently does not return
ECONNRESET for UDP recvmsg() calls at all.

https://phabricator.freedesktop.org/T121

Maniphest Tasks: T121

Reviewers: ocrete

Projects: #libnice

Reviewed By: ocrete

Subscribers: stwiname, felixSchl

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

9 years agosocket: Close base socket for a TCP passive socket when closing parent
Philip Withnall [Wed, 19 Aug 2015 08:16:53 +0000 (09:16 +0100)]
socket: Close base socket for a TCP passive socket when closing parent

Summary:
Otherwise the base socket will leak. Spotted by Vadim Genkin.

https://phabricator.freedesktop.org/T125

Maniphest Tasks: T125

Reviewers: ocrete

Projects: #libnice

Reviewed By: ocrete

Subscribers: vadimgenkin

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

9 years agosocket: Close base socket for a TCP passive socket when closing parent
Philip Withnall [Tue, 18 Aug 2015 13:58:23 +0000 (14:58 +0100)]
socket: Close base socket for a TCP passive socket when closing parent

Otherwise the base socket will leak. Spotted by Vadim Genkin.

https://phabricator.freedesktop.org/T125

9 years agoagent: Remove unused inet_pton() function
Philip Withnall [Tue, 18 Aug 2015 13:03:41 +0000 (14:03 +0100)]
agent: Remove unused inet_pton() function

Summary:
As spotted by Felix <felixschlitter@gmail.com>. This is a static
function which is totally unused in this compilation unit and is causing
build failures with `-Werror=unused-function`.

Maniphest Tasks: T123

Reviewers: felixSchl, ocrete

Projects: #libnice

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

9 years agoagent: Remove unused inet_pton() function
Philip Withnall [Tue, 30 Jun 2015 13:39:51 +0000 (14:39 +0100)]
agent: Remove unused inet_pton() function

As spotted by Felix <felixschlitter@gmail.com>. This is a static
function which is totally unused in this compilation unit and is causing
build failures with -Werror=unused-function.

http://phabricator.freedesktop.org/T123

9 years agosocket: Handle ECONNRESET as EWOULDBLOCK on Windows
Philip Withnall [Tue, 18 Aug 2015 12:33:23 +0000 (13:33 +0100)]
socket: Handle ECONNRESET as EWOULDBLOCK on Windows

Some versions of Windows can return ECONNRESET for UDP recvmsg() calls
if they would otherwise block. Hence, handle the two equivalently; this
should not affect behaviour on Linux, which apparently does not return
ECONNRESET for UDP recvmsg() calls at all.

https://phabricator.freedesktop.org/T121

9 years agoconncheck: set writable callback to socket from TCP active connect
Jakub Adam [Thu, 18 Jun 2015 07:05:21 +0000 (09:05 +0200)]
conncheck: set writable callback to socket from TCP active connect

A new socket created in nice_tcp_active_socket_connect() should have its
writable callback set, because it's possible for it to become a base
socket of a peer reflexive candidate, if some is discovered by
connection checks on that TCP active candidate.

Previously, when such prflx candidate became selected, without write_cb
on the socket the agent was never notified about it becoming writable
again after the socket's buffer got filled up. This caused the data flow
to hang permanently.

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Reviewed-by: Olivier Crête <olivier.crete@collabora.com>
http://phabricator.freedesktop.org/T117

9 years agopseudotcp: Only define errnos on Windows if not already defined
Philip Withnall [Tue, 30 Jun 2015 13:29:43 +0000 (14:29 +0100)]
pseudotcp: Only define errnos on Windows if not already defined

Recent versions of MinGW define at least ECONNABORTED and EAFNOSUPPORT,
so only define the various socket errnos if they are not defined
already.

Based on a patch by Alexey Pawlow <alexey.pawlow@gmail.com> and Felix
<felixschlitter@gmail.com>.

Reviewed-by: Olivier Crete <olivier.crete@collabora.com>
Reviewed-by: Felix Schlitter <felixschlitter@gmail.com>
http://phabricator.freedesktop.org/T122

9 years agoUse G_GSIZE_FORMAT instead of %zu
Felix Schlitter [Mon, 29 Jun 2015 19:37:31 +0000 (07:37 +1200)]
Use G_GSIZE_FORMAT instead of %zu

The C runtime on windows does not implement a printf that understands
%zu and other C99 format specifiers. Use G_GSIZE_FORMAT instead. This
is further consistent with the rest of the code base that makes use of
G_GSIZE_FORMAT throughout.

https://github.com/libnice/libnice/pull/3

9 years agoSplit "verbose" on-every-packet messages to a verbose log
Olivier Crête [Thu, 18 Sep 2014 23:33:10 +0000 (19:33 -0400)]
Split "verbose" on-every-packet messages to a verbose log

This way, the regular log will only contain connection-time information.

9 years agostun: Remove annoying non-error on non-STUN packet
Olivier Crête [Thu, 18 Sep 2014 23:33:06 +0000 (19:33 -0400)]
stun: Remove annoying non-error on non-STUN packet

9 years agoconfigure: Fix configure failure when building without gstreamer support
Timo Gurr [Mon, 1 Jun 2015 14:10:16 +0000 (16:10 +0200)]
configure: Fix configure failure when building without gstreamer support

Error introduced in 20ea22e0a11a9bdfe4d8125b68083249b694338a, resulting in a
configure/build error when building without gstreamer:

configure: error: conditional "HAVE_GST_CHECK" was never defined.
Usually this means the macro was only invoked conditionally.

https://bugs.freedesktop.org/show_bug.cgi?id=90801

9 years agobuild: Auto-generate win32 .def file from libnice.sym
Philip Withnall [Fri, 8 May 2015 09:13:39 +0000 (10:13 +0100)]
build: Auto-generate win32 .def file from libnice.sym

We’ve neglected to manually update this file once too often — it’s been
out of date for important new symbols (for example,
nice_agent_get_io_stream()) since at least 0.1.11.

Since the format is a simple extension of libnice.sym, we might as well
automatically generate it at dist time.

9 years agoRemoving no-op assignment
Youness Alaoui [Tue, 5 May 2015 19:07:10 +0000 (15:07 -0400)]
Removing no-op assignment

9 years agoDo not compare scope for IPv6 address when scope is 0
Youness Alaoui [Tue, 5 May 2015 19:00:30 +0000 (15:00 -0400)]
Do not compare scope for IPv6 address when scope is 0

This caused issues with thinking local host candidates were peer-reflexive
candidates because the nice_address_equal would fail since the scope
would be 6 (or some other value) but locally created NiceAddress from
a stun response would have the scope set to 0.
We ignore the scope when comparing ipv6 candidates when scope is 0
to avoid these kinds of issues.
Thanks to ikonst_ for finding these issues

9 years agoDo not update a remote candidate's type
Youness Alaoui [Tue, 5 May 2015 18:24:15 +0000 (14:24 -0400)]
Do not update a remote candidate's type

When adding a remote candidate, if it's the same ip:port, we should
also check its type, otherwise it's a new candidate. We can't allow
a candidate type to be updated. This caused issues to ikonst_ on IRC
where for some reason a host candidate appeared as both host and prflx
and the update caused a remote host candidate to be updated to prflx
causing a crash when the sockptr was being accessed.

9 years agoagent: Remove unnecessary NULL check
Philip Withnall [Sun, 3 May 2015 15:05:30 +0000 (16:05 +0100)]
agent: Remove unnecessary NULL check

With the changes in commit 483bdcf8, @name is now guaranteed to be
non-NULL. Spotted by Coverity.

CID: #109878

9 years agoVersion 0.1.13.1
Olivier Crête [Tue, 28 Apr 2015 19:44:13 +0000 (15:44 -0400)]
Version 0.1.13.1

9 years agoVersion 0.1.13 0.1.13
Olivier Crête [Tue, 28 Apr 2015 19:37:57 +0000 (15:37 -0400)]
Version 0.1.13

9 years agoexamples: Use the correct g_io_channel_win32_new_fd() function
Olivier Crête [Tue, 28 Apr 2015 18:48:13 +0000 (14:48 -0400)]
examples: Use the correct g_io_channel_win32_new_fd() function

9 years agoagent: Fix a utility function being defined unnecessarily
Philip Withnall [Fri, 24 Apr 2015 09:27:41 +0000 (10:27 +0100)]
agent: Fix a utility function being defined unnecessarily

sockaddr_to_string() is not needed on UNIX when compiling without
HAVE_GETIFADDRS. This fixes a compiler warning in that case.

9 years agoagent: Add a missing cast when compiling without HAVE_GETIFADDRS
Philip Withnall [Fri, 24 Apr 2015 09:27:07 +0000 (10:27 +0100)]
agent: Add a missing cast when compiling without HAVE_GETIFADDRS

9 years agoagent: Move utility function outside #ifdef
Philip Withnall [Fri, 24 Apr 2015 09:18:32 +0000 (10:18 +0100)]
agent: Move utility function outside #ifdef

This fixes compilation when HAVE_GETIFADDRS is not define. Reported on
the mailing list by Curieux Tres <trescurieux@yahoo.fr>.

9 years agostun: Add missing casts to unit tests
Philip Withnall [Thu, 23 Apr 2015 08:42:24 +0000 (09:42 +0100)]
stun: Add missing casts to unit tests

This fixes some compiler warnings.

9 years agoexamples: Make them built on non-win32 with GLib < 2.36
Olivier Crête [Thu, 23 Apr 2015 01:26:09 +0000 (21:26 -0400)]
examples: Make them built on non-win32 with GLib < 2.36

9 years agoVersion 0.1.12.1
Olivier Crête [Thu, 23 Apr 2015 01:13:24 +0000 (21:13 -0400)]
Version 0.1.12.1

9 years agoVersion 0.1.12 0.1.12
Olivier Crête [Thu, 23 Apr 2015 01:11:17 +0000 (21:11 -0400)]
Version 0.1.12

9 years agoexamples: Make them build and work on Windows
Olivier Crête [Thu, 23 Apr 2015 00:56:09 +0000 (19:56 -0500)]
examples: Make them build and work on Windows

9 years agoagent: Print valid string even with no local candidates
Olivier Crête [Thu, 23 Apr 2015 00:54:50 +0000 (19:54 -0500)]
agent: Print valid string even with no local candidates

9 years agoagent: Fix SDP line counting
Olivier Crête [Wed, 22 Apr 2015 21:32:58 +0000 (17:32 -0400)]
agent: Fix SDP line counting

Fixes SDP parsing which I broke in commit 5972db04

9 years agonicesrc: Attach the receive callback in READY->PAUSED and detach in PAUSED->READY
Sebastian Dröge [Thu, 19 Mar 2015 08:19:23 +0000 (09:19 +0100)]
nicesrc: Attach the receive callback in READY->PAUSED and detach in PAUSED->READY

Receiving data before the element is ready to push them does not seem like the
best idea.

https://bugs.freedesktop.org/show_bug.cgi?id=89673

9 years agonicesrc: Keep the mutex locked whenever accessing the queue
Sebastian Dröge [Thu, 19 Mar 2015 08:17:38 +0000 (09:17 +0100)]
nicesrc: Keep the mutex locked whenever accessing the queue

https://bugs.freedesktop.org/show_bug.cgi?id=89673

9 years agoVersion 0.1.11.1
Olivier Crête [Mon, 20 Apr 2015 21:30:06 +0000 (17:30 -0400)]
Version 0.1.11.1

9 years agoVersion 0.1.11 0.1.11
Olivier Crête [Mon, 20 Apr 2015 21:24:08 +0000 (17:24 -0400)]
Version 0.1.11

9 years agostunagent: Initiliaze variable
Olivier Crête [Mon, 20 Apr 2015 21:23:00 +0000 (17:23 -0400)]
stunagent: Initiliaze variable

This remove a gcc warning

9 years agoagent: Count m= files to match streams
Olivier Crête [Mon, 20 Apr 2015 20:09:28 +0000 (16:09 -0400)]
agent: Count m= files to match streams

The only valid way to match streams is to count m= lines, see RFC 3264.

https://bugs.freedesktop.org/show_bug.cgi?id=90019

9 years agoagent: Warn on invalid media types for SDP
Olivier Crête [Mon, 20 Apr 2015 20:08:42 +0000 (16:08 -0400)]
agent: Warn on invalid media types for SDP

Only 6 strings are valid.

https://bugs.freedesktop.org/show_bug.cgi?id=90019

9 years agoPrefix include guards
Olivier Crête [Mon, 20 Apr 2015 19:44:16 +0000 (15:44 -0400)]
Prefix include guards

The include file names are very generic, at least make
the guards a bit less generic.

https://bugs.freedesktop.org/show_bug.cgi?id=90013