platform/upstream/libnice.git
9 years agonicesink: Add support for render buffer_list
Jose Antonio Santos Cadenas [Tue, 17 Mar 2015 10:00:26 +0000 (11:00 +0100)]
nicesink: Add support for render buffer_list

Also memory copies are reduced if buffers are fragmented

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

9 years agonicesrc: Clear the output buffer queue when shutting down and disposing
Sebastian Dröge [Thu, 19 Mar 2015 08:21:23 +0000 (09:21 +0100)]
nicesrc: Clear the output buffer queue when shutting down and disposing

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

9 years agoagent: Add missing preconditions to public API
Philip Withnall [Tue, 10 Mar 2015 12:42:02 +0000 (12:42 +0000)]
agent: Add missing preconditions to public API

Makes things a little bit safer to abuse.

9 years agoagent: Fix documentation to use ‘nul-terminated’ for strings
Philip Withnall [Tue, 10 Mar 2015 12:25:25 +0000 (12:25 +0000)]
agent: Fix documentation to use ‘nul-terminated’ for strings

NULL is ((gpointer) 0). nul is '\0'. Arrays can be NULL terminated.
Strings can be nul terminated.

9 years agostun: Fix documentation to use ‘nul-terminated’ for strings
Philip Withnall [Tue, 10 Mar 2015 12:24:37 +0000 (12:24 +0000)]
stun: Fix documentation to use ‘nul-terminated’ for strings

NULL is ((gpointer) 0). nul is '\0'. Arrays can be NULL terminated.
Strings can be nul terminated.

9 years agowin32: Update README
David Feurle [Sat, 7 Feb 2015 11:10:09 +0000 (12:10 +0100)]
win32: Update README

9 years agostun: Use dynamic array instead of stack allocated array
David Feurle [Sat, 7 Feb 2015 09:49:07 +0000 (10:49 +0100)]
stun: Use dynamic array instead of stack allocated array

Dynamic on-stack arrays are not supported in Visual Studio.

This has the downside of introducing an extra memory allocation into
libstun, but it’s on a debug path so should be harmless.

9 years agowin32: Update file list in Visual Studio project
David Feurle [Sat, 7 Feb 2015 09:46:39 +0000 (10:46 +0100)]
win32: Update file list in Visual Studio project

9 years agowin32: Remove outdated DLL files
David Feurle [Sat, 7 Feb 2015 09:35:51 +0000 (10:35 +0100)]
win32: Remove outdated DLL files

9 years agostun: Use sprintf() instead of snprintf() to support VS 2010
Philip Withnall [Thu, 30 Oct 2014 09:35:16 +0000 (09:35 +0000)]
stun: Use sprintf() instead of snprintf() to support VS 2010

Visual Studio 2010 still doesn’t support C99, and snprintf() is a C99
function, so compilation fails with:
    error: C3861: 'snprintf': identifier not found

Use sprintf() instead, which is C89 and thus supported. This does not
make the code unsafe, as the format specifier is constrained to two
characters (+ trailing nul), which are guaranteed to fit in the array
bounds.

Reported on the mailing list:
http://lists.freedesktop.org/archives/nice/2014-October/000978.html

9 years agoRemove duplicate ips from nice_interfaces
Youness Alaoui [Sat, 15 Nov 2014 21:17:58 +0000 (16:17 -0500)]
Remove duplicate ips from nice_interfaces
OpenVPN creates a tun interface having the same IP assigned twice like:

9: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc ...100
    link/none
    inet 10.222.111.10 peer 10.222.111.9/32 brd 10.222.111.10 scope global tun0
       valid_lft forever preferred_lft forever
    inet 10.222.111.10/32 brd 10.222.111.10 scope global tun0
       valid_lft forever preferred_lft forever

This interface would generate two identical host candidates with the same value
of foundation.

9 years agoVersion 0.1.10.1
Olivier Crête [Thu, 29 Jan 2015 03:37:51 +0000 (22:37 -0500)]
Version 0.1.10.1

9 years agoVersion 0.1.10 0.1.10
Olivier Crête [Thu, 29 Jan 2015 03:35:09 +0000 (22:35 -0500)]
Version 0.1.10

9 years agonicesink: unblock pending write on component change
Jakub Adam [Thu, 25 Sep 2014 13:50:30 +0000 (15:50 +0200)]
nicesink: unblock pending write on component change

When a nicesink switches to a different component, we should unblock any
pending write waiting in gst_nice_sink_render() for writable_cond being
signalled because if the new transport already is writable, we'll never
get notified about the condition and thus nicesink will wait forever.

That way, either the pending data are immediately sent or the nicesink
blocks again until the transport becomes writable.

9 years agoconfigure: Add "subdir-objects" automake option
Olivier Crête [Thu, 29 Jan 2015 02:56:49 +0000 (21:56 -0500)]
configure: Add "subdir-objects" automake option

Automake now warns that it will be the only behavior
in the future. So quell the warning by adding it.

9 years agoVersion 0.1.9.1
Olivier Crête [Thu, 29 Jan 2015 02:46:33 +0000 (21:46 -0500)]
Version 0.1.9.1

9 years agoVersion 0.1.9 0.1.9
Olivier Crête [Thu, 29 Jan 2015 02:44:04 +0000 (21:44 -0500)]
Version 0.1.9

9 years agoOnly change the receiving nicesock for udp-turn for ice-tcp
Youness Alaoui [Tue, 20 Jan 2015 17:31:11 +0000 (12:31 -0500)]
Only change the receiving nicesock for udp-turn for ice-tcp

The code was in the wrong spot, for OC2007, we need to fix the
nicesock used only in the case of udp-turn-over-tcp for OC2007
compatibility mode. With the current code, it was thinking that
the data came from TURN for every udp packet.
This should hopefully fix : https://github.com/EricssonResearch/openwebrtc/issues/85

9 years agodocs: Enable documentation checks during `make check` by default
Philip Withnall [Fri, 2 Jan 2015 19:25:32 +0000 (19:25 +0000)]
docs: Enable documentation checks during `make check` by default

Now that they pass, we should endeavour to ensure they continue to pass.

9 years agodocs: Add 0.1.8 API to the documentation index
Philip Withnall [Fri, 2 Jan 2015 19:25:07 +0000 (19:25 +0000)]
docs: Add 0.1.8 API to the documentation index

This should have been included before. This fixes `make check` in docs/.

9 years agodocs: Add various missing documentation comments and update sections.txt
Philip Withnall [Fri, 2 Jan 2015 19:24:31 +0000 (19:24 +0000)]
docs: Add various missing documentation comments and update sections.txt

This straightens out the last few bits of the documentation and almost
allows `make check` to pass in docs/.

9 years agodocs: Inform gtk-doc of the libnice namespace
Philip Withnall [Fri, 2 Jan 2015 19:23:39 +0000 (19:23 +0000)]
docs: Inform gtk-doc of the libnice namespace

This allows it to order the index a little better.

9 years agodocs: Use gtk-doc no-tmpl mode
Philip Withnall [Fri, 2 Jan 2015 19:22:23 +0000 (19:22 +0000)]
docs: Use gtk-doc no-tmpl mode

Templated mode has been deprecated for a long time and will be removed
in future versions of gtk-doc. Switch to no-tmpl mode for faster
documentation builds and future-proofness.

This does not bump our gtk-doc dependency, since gtk-doc 1.9 supported
no-tmpl mode.

9 years agodocs: Switch from gtk-doc SGML mode to XML mode
Philip Withnall [Fri, 2 Jan 2015 19:21:48 +0000 (19:21 +0000)]
docs: Switch from gtk-doc SGML mode to XML mode

We already used XML everywhere; just formally switch to XML mode and
eliminate the last few traces of SGML.

9 years agoagent: Document G_MESSAGES_DEBUG and NICE_DEBUG
Philip Withnall [Sat, 27 Dec 2014 09:49:37 +0000 (09:49 +0000)]
agent: Document G_MESSAGES_DEBUG and NICE_DEBUG

As requested on the mailing list, expand the documentation for
nice_debug_enable() to mention them.

9 years agoagent: Handle EWOULDBLOCK when transmitting pseudo-TCP segments
Philip Withnall [Mon, 15 Dec 2014 23:35:13 +0000 (23:35 +0000)]
agent: Handle EWOULDBLOCK when transmitting pseudo-TCP segments

The pseudo-TCP code previously didn’t handle EAGAIN or EWOULDBLOCK
errors from the low-level NiceSocket code. This caused pseudo-TCP
connections to be dropped if the transmitting socket ever filled up,
which could cause problems on high bandwidth connections.

Fix the issue by effectively dropping the packet on EWOULDBLOCK. This
will eventually get picked up by the pseudo-TCP recovery mechanism,
retransmitting the packet and throttling the sender. This should
hopefully reduce the system resource usage which caused EWOULDBLOCK in
the first place.

Spotted and debugged by Radosław Kołodziejczyk
<radek.kolodziejczyk@gmail.com>.

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

9 years agopseudotcp: Do roll-over safe assertion
Olivier Crête [Mon, 8 Dec 2014 15:22:21 +0000 (10:22 -0500)]
pseudotcp: Do roll-over safe assertion

In case of a roll-over, only the difference matters.

10 years agoagent: Add debug output for lifetime of Components and Streams
Philip Withnall [Fri, 14 Nov 2014 10:06:21 +0000 (10:06 +0000)]
agent: Add debug output for lifetime of Components and Streams

10 years agotests: Use G_SOURCE_[CONTINUE|REMOVE] instead of booleans
Philip Withnall [Thu, 6 Nov 2014 10:41:57 +0000 (10:41 +0000)]
tests: Use G_SOURCE_[CONTINUE|REMOVE] instead of booleans

Makes the test code a little clearer. Introduces no functional changes.

10 years agotests: Fix a memory leak in test-send-recv
Philip Withnall [Thu, 6 Nov 2014 10:40:53 +0000 (10:40 +0000)]
tests: Fix a memory leak in test-send-recv

If n_messages ≠ n_valid_messages.

10 years agoAdd ability to build static GST plugins
Nicolas Dufresne [Thu, 30 Oct 2014 21:09:41 +0000 (17:09 -0400)]
Add ability to build static GST plugins

Note that this only works for 1.0 plugin.

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

10 years agoagent: Expand simple example in documentation to mention GMainContext
Philip Withnall [Thu, 30 Oct 2014 17:20:43 +0000 (17:20 +0000)]
agent: Expand simple example in documentation to mention GMainContext

wrt the ML thread:
http://lists.freedesktop.org/archives/nice/2014-October/000981.html

10 years agoagent: Close pseudo-TCP socket earlier in component_close()
Philip Withnall [Thu, 30 Oct 2014 09:10:51 +0000 (09:10 +0000)]
agent: Close pseudo-TCP socket earlier in component_close()

This tries to mitigate the race condition between finishing the TCP FIN
handshake and closing the underlying sockets, but it’s impossible to
mitigate properly without API changes. See the comment.

10 years agostun: Rename a symbol to avoid a naming clash with OpenSSL
Curieux Tres [Mon, 27 Oct 2014 11:32:17 +0000 (11:32 +0000)]
stun: Rename a symbol to avoid a naming clash with OpenSSL

The symbol is not exported, but nevertheless leaks in the static version
of libnice, due to limitations on symbol visibilities with static
libraries. OpenSSL has a symbol named RAND_bytes(), which ours clashes
with if the two are linked together statically.

Avoid this by prefixing ours with ‘nice_’.

10 years agoFix documentation relating to how remote crendentials should be set for new ICE format
Youness Alaoui [Thu, 18 Sep 2014 23:42:53 +0000 (19:42 -0400)]
Fix documentation relating to how remote crendentials should be set for new ICE format

10 years agoagent: ignore externally set peer-reflexive candidates
Youness Alaoui [Thu, 18 Sep 2014 23:30:08 +0000 (19:30 -0400)]
agent: ignore externally set peer-reflexive candidates

All discovered peer-reflexive candidates should be added internally in
conncheck.c and should have the sockptr set. We ignore any prflx
candidates added by an external application because their NULL sockptr
could cause a crash in conn_check_send().

10 years agoVersion 0.1.8.1
Olivier Crête [Thu, 9 Oct 2014 21:37:49 +0000 (17:37 -0400)]
Version 0.1.8.1

10 years agoVersion 0.1.8 0.1.8
Olivier Crête [Thu, 9 Oct 2014 20:43:16 +0000 (16:43 -0400)]
Version 0.1.8

10 years agoagent: Remove extra post condition
Olivier Crête [Thu, 9 Oct 2014 21:05:32 +0000 (17:05 -0400)]
agent: Remove extra post condition

It prevent the GError from happening

10 years agoudp-turn: Don't dereference priv before check that it's valid
Olivier Crête [Thu, 9 Oct 2014 21:02:56 +0000 (17:02 -0400)]
udp-turn: Don't dereference priv before check that it's valid

10 years agoagent: Pass all packets that are not acceptable STUN packets to the application
Olivier Crête [Thu, 9 Oct 2014 20:21:18 +0000 (16:21 -0400)]
agent: Pass all packets that are not acceptable STUN packets to the application

We attempted to not pass through some packets that looked like
valid STUN but were ot acceptable to us, but that dropped some application
packets.

10 years agoagent: Re-emit gathering done after a new relay has been set
Olivier Crête [Wed, 8 Oct 2014 23:36:01 +0000 (19:36 -0400)]
agent: Re-emit gathering done after a new relay has been set

If the stream was ever gathering and a new relay has been set,
then re-emit the candidate=gathering-done signal

10 years agopseudotcp: Print unsigned int with %u not %d
Olivier Crête [Sun, 5 Oct 2014 18:06:58 +0000 (14:06 -0400)]
pseudotcp: Print unsigned int with %u not %d

10 years agoagent: Add function to retrieve the current component state
Olivier Crête [Sun, 5 Oct 2014 17:34:22 +0000 (13:34 -0400)]
agent: Add function to retrieve the current component state

10 years agoagent: Make the stun-pacing-timer app configurable
Olivier Crête [Sun, 5 Oct 2014 17:35:12 +0000 (13:35 -0400)]
agent: Make the stun-pacing-timer app configurable

There is no reason to only allow modifying it in the new().

10 years agopseudotcp: Set default RTO to 1 second
Olivier Crête [Sun, 5 Oct 2014 17:33:00 +0000 (13:33 -0400)]
pseudotcp: Set default RTO to 1 second

The newer RFC 6298 recommends 1 second instead of 3.

10 years agoconncheck: Computer STUN retransmission timeout (RTO) dynamically
Olivier Crête [Sun, 5 Oct 2014 17:32:24 +0000 (13:32 -0400)]
conncheck: Computer STUN retransmission timeout (RTO) dynamically

This is how it is specified in RFC 5245 section 16

10 years agodiscovery: Remove extra \n in g_debug()
Olivier Crête [Fri, 3 Oct 2014 21:44:59 +0000 (17:44 -0400)]
discovery: Remove extra \n in g_debug()

10 years agoagent: Only add pairs once on gathering done
Olivier Crête [Fri, 3 Oct 2014 21:10:45 +0000 (17:10 -0400)]
agent: Only add pairs once on gathering done

Also don't try to re-add pairs that already have been added

10 years agoconncheck: Insert the candidates sorted after setting the priority
Olivier Crête [Fri, 3 Oct 2014 20:30:16 +0000 (16:30 -0400)]
conncheck: Insert the candidates sorted after setting the priority

10 years agoconncheck: Insert peer reflexive pair sorted
Olivier Crête [Thu, 2 Oct 2014 22:41:14 +0000 (18:41 -0400)]
conncheck: Insert peer reflexive pair sorted

The rest of the list is sorted, but this was just appended, making it likely
to be dropped if the list grows too long.

10 years agoconncheck: Don't remove elements in the conncheck list while iterating it
Olivier Crête [Thu, 2 Oct 2014 22:37:34 +0000 (18:37 -0400)]
conncheck: Don't remove elements in the conncheck list while iterating it

priv_limit_conn_check_list_size() would remove elemtns from the conncheck_list
while the calling functions were iterating it. Now instead just mark them as
cancelled. Then later, at the outer function, free all cancelled elements to
prevent the list from growing out of bounds.

10 years agoagent: Avoid leaking UPnP mappings between streams
Olivier Crête [Wed, 1 Oct 2014 04:00:30 +0000 (00:00 -0400)]
agent: Avoid leaking UPnP mappings between streams

Clean up the UPnP mappings of each stream when closing it

10 years agoagent: Avoid restarting the GUPnP client on every gather
Olivier Crête [Wed, 1 Oct 2014 03:59:59 +0000 (23:59 -0400)]
agent: Avoid restarting the GUPnP client on every gather

This would cause mappings to be dropped on every new gather, which is bad!
Instead, keep the same one with the mappings, and just drop the timer to ignore
new discovered mappings afterwards.

10 years agoagent: Ignore UPnP mappings after the UPnP discovery has finished
Olivier Crête [Wed, 1 Oct 2014 02:49:16 +0000 (22:49 -0400)]
agent: Ignore UPnP mappings after the UPnP discovery has finished

10 years agocomponent: On ICE restart reset selected pair priority to 0
Olivier Crête [Tue, 30 Sep 2014 22:28:24 +0000 (18:28 -0400)]
component: On ICE restart reset selected pair priority to 0

This is to ensure that the result of the new negotiation will always
have priority.

10 years agoagent: Add some preconditions to public API
Philip Withnall [Tue, 23 Sep 2014 13:54:59 +0000 (14:54 +0100)]
agent: Add some preconditions to public API

To try and avoid NULL NiceCandidates entering our internal state.

10 years agobuild: Update .gitignore
Philip Withnall [Fri, 5 Sep 2014 09:54:11 +0000 (10:54 +0100)]
build: Update .gitignore

10 years agooutputstream: Fix double unref
Olivier Crête [Mon, 11 Aug 2014 18:27:40 +0000 (14:27 -0400)]
outputstream: Fix double unref

10 years agoagent: Remove socket source on HUP
Olivier Crête [Sat, 9 Aug 2014 20:18:33 +0000 (16:18 -0400)]
agent: Remove socket source on HUP

10 years agoagent: Declare the stream to be CONNECTED only if a pair is selected
Olivier Crête [Thu, 31 Jul 2014 19:16:38 +0000 (15:16 -0400)]
agent: Declare the stream to be CONNECTED only if a pair is selected

Don't change the state if no pair is selected. Otherwise we get
a component that claims to be CONNECTED but has no selected pair.
Also, set the selected pair before announcing the state change.

10 years agonice.pc: Include ${includedir} directly
Olivier Crête [Wed, 8 Oct 2014 23:03:12 +0000 (19:03 -0400)]
nice.pc: Include ${includedir} directly

It doesn't make sense to tell applications to include <agent.h>,
including <nice/agent.h> is much safer. So tell the applications
to use the includedir directly.

10 years agoagent: Document interaction between closing and removing streams
Philip Withnall [Fri, 26 Sep 2014 15:11:59 +0000 (16:11 +0100)]
agent: Document interaction between closing and removing streams

GIOStream and nice_agent_remove_stream() interact slightly subtly when
closing down the stream.

See: https://bugzilla.gnome.org/show_bug.cgi?id=735754

10 years agotests: Add more helgrind suppressions
Philip Withnall [Fri, 26 Sep 2014 11:57:18 +0000 (12:57 +0100)]
tests: Add more helgrind suppressions

10 years agoagent: Delay some assignments until the agent is locked
Philip Withnall [Fri, 26 Sep 2014 11:56:52 +0000 (12:56 +0100)]
agent: Delay some assignments until the agent is locked

This makes helgrind slightly happier.

10 years agoagent: Warn if a Component is freed without first being closed
Philip Withnall [Thu, 25 Sep 2014 12:55:42 +0000 (13:55 +0100)]
agent: Warn if a Component is freed without first being closed

10 years agoagent: Close Streams before freeing them
Philip Withnall [Thu, 25 Sep 2014 12:54:41 +0000 (13:54 +0100)]
agent: Close Streams before freeing them

This could result in leaking the stream’s un-closed state otherwise, in
any case where a NiceAgent is finalised without
nice_agent_remove_stream() being called on all its streams.

10 years agotests: Add a Valgrind suppression file
Philip Withnall [Thu, 25 Sep 2014 09:33:12 +0000 (10:33 +0100)]
tests: Add a Valgrind suppression file

To be used with `make check-valgrind`.

10 years agotests: Fix various memory leaks in the unit tests
Philip Withnall [Thu, 25 Sep 2014 08:24:04 +0000 (09:24 +0100)]
tests: Fix various memory leaks in the unit tests

The theory being that if we can get check-valgrind to pass, we could
acutally use it to find more memory leaks and other errors in the agent.

10 years agoagent: Check STUN buffer is non-NULL before getting its message ID
Philip Withnall [Thu, 25 Sep 2014 08:22:26 +0000 (09:22 +0100)]
agent: Check STUN buffer is non-NULL before getting its message ID

This should fix a crash, as detected by Valgrind:
  ==28354== Invalid read of size 2
  ==28354==    at 0x4C2B5B0: memcpy@@GLIBC_2.14 (in
    /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==28354==    by 0x50C17E2: stun_message_id (stunmessage.c:658)
  ==28354==    by 0x509E4E7: candidate_check_pair_fail (conncheck.c:254)
  ==28354==    by 0x50A4EDB: conn_check_prune_socket (conncheck.c:3145)
  ==28354==    by 0x509B6F8: component_io_cb (agent.c:3951)

10 years agoagent: Fix a leak of a GCancellable and its GSource
Philip Withnall [Thu, 25 Sep 2014 08:21:44 +0000 (09:21 +0100)]
agent: Fix a leak of a GCancellable and its GSource

The GSource holds a reference to the GCancellable, so needs to be
explicitly removed from the GMainContext when it’s finised with.

10 years agoagent: Fix a minor leak in an error handling path
Philip Withnall [Thu, 25 Sep 2014 08:21:18 +0000 (09:21 +0100)]
agent: Fix a minor leak in an error handling path

10 years agotests: Move a closure from the heap to the stack
Philip Withnall [Wed, 24 Sep 2014 13:42:19 +0000 (14:42 +0100)]
tests: Move a closure from the heap to the stack

There is no need for this to be heap-allocated.

10 years agoconncheck: Don't use CandidateRefresh after freeing it
Olivier Crête [Wed, 24 Sep 2014 02:06:52 +0000 (22:06 -0400)]
conncheck: Don't use CandidateRefresh after freeing it

10 years agosocket: Fix a leak on the slow TURN packet handling path
Philip Withnall [Tue, 23 Sep 2014 14:20:31 +0000 (15:20 +0100)]
socket: Fix a leak on the slow TURN packet handling path

10 years agoagent: Eliminate a memset() for local variable initialisation
Philip Withnall [Tue, 23 Sep 2014 13:57:12 +0000 (14:57 +0100)]
agent: Eliminate a memset() for local variable initialisation

Stack variables can be initialised to zero by explicit assignment.

This introduces no functional changes.

10 years agoagent: Use g_slist_free_full() to reduce code
Philip Withnall [Tue, 23 Sep 2014 13:56:52 +0000 (14:56 +0100)]
agent: Use g_slist_free_full() to reduce code

This introduces no functional changes.

10 years agoagent: Add some preconditions to internal API
Philip Withnall [Tue, 23 Sep 2014 13:55:54 +0000 (14:55 +0100)]
agent: Add some preconditions to internal API

To try and avoid NULL NiceCandidates entering our internal state.

10 years agoagent: Add some preconditions to public API
Philip Withnall [Tue, 23 Sep 2014 13:54:59 +0000 (14:54 +0100)]
agent: Add some preconditions to public API

To try and avoid NULL NiceCandidates entering our internal state.

10 years agoagent: Clear GSource timeout also for GUPnP timeout
Olivier Crête [Mon, 22 Sep 2014 17:04:26 +0000 (13:04 -0400)]
agent: Clear GSource timeout also for GUPnP timeout

Fix regressions introduced by the following patch:
Clear existing GSource timeouts before adding new ones

10 years agoagent: Drop valid but unmatched STUN packets
Philip Withnall [Fri, 5 Sep 2014 09:50:23 +0000 (10:50 +0100)]
agent: Drop valid but unmatched STUN packets

Rather than passing them through to the application. Invalid STUN
packets are still passed through, but it causes unnecessary noise and
corruption for higher-level applications to receive STUN packets they
weren’t expecting.

This is permitted by RFC 5389, §7.3.0:
    If any errors are detected, the message is silently discarded.
    In the case when STUN is being multiplexed with another protocol,
    an error may indicate that this is not really a STUN message; in
    this case, the agent should try to parse the message as a different
    protocol.
where I interpret ‘error’ to mean ‘validation error’ rather than (e.g.)
‘unrecognised attribute’ or ‘unmatched response’ where the STUN packet
is otherwise perfectly formed.

10 years agoagent: Remove dangling pointers on NiceSocket destruction
Philip Withnall [Fri, 19 Sep 2014 12:22:09 +0000 (13:22 +0100)]
agent: Remove dangling pointers on NiceSocket destruction

If a NiceSocket is destroyed, various pointers are currently left
dangling to it in the conncheck state. These can cause crashes if (for
example) a CandidateCheckPair with such a dangling pointer is then used;
the GSocket methods will fail.

Fix this by explicitly removing the socket and all NiceCandidates which
wrap it from various areas of the state.

10 years agoagent: Factor out state transition to FAILED for CandidateCheckPairs
Philip Withnall [Fri, 19 Sep 2014 12:20:25 +0000 (13:20 +0100)]
agent: Factor out state transition to FAILED for CandidateCheckPairs

This introduces no functional changes.

10 years agoagent: Factor out free function for IncomingCheck
Philip Withnall [Fri, 19 Sep 2014 12:19:40 +0000 (13:19 +0100)]
agent: Factor out free function for IncomingCheck

10 years agoagent: Improve comments for container element types
Philip Withnall [Fri, 19 Sep 2014 10:03:27 +0000 (11:03 +0100)]
agent: Improve comments for container element types

To allow enhanced grepping for what structs point to other structs.

10 years agoagent: Clear existing GSource timeouts before adding new ones
Philip Withnall [Fri, 19 Sep 2014 08:56:21 +0000 (09:56 +0100)]
agent: Clear existing GSource timeouts before adding new ones

Modify agent_timeout_add_with_context() to force destroying and freeing
of an existing GSource before overwriting it with a new one (probably
with an updated timeout period).

This fixes a case in priv_map_reply_to_relay_refresh() where the TURN
candidate refresh timer was being overwritten with a new one, without
the old one being destroyed. This lead to two timeouts existing, only
one of which would be destroyed when the CandidateRefresh struct was
freed, leaking the other one (in the main context) and allowing it to be
later dispatched with a dangling CandidateRefresh pointer.

The modification to agent_timeout_add_with_context() should prevent this
happening in new code in future.

10 years agoagent: Add names to timer GSources
Philip Withnall [Fri, 19 Sep 2014 07:57:53 +0000 (08:57 +0100)]
agent: Add names to timer GSources

Modify the agent_timeout_add_with_context() utility function to
automatically add names to the timer GSources it creates. This makes
them a little easier to identify when debugging.

10 years agosocket: Return early from socket functions if the socket is closed
Philip Withnall [Tue, 2 Sep 2014 10:56:37 +0000 (11:56 +0100)]
socket: Return early from socket functions if the socket is closed

Explicitly check whether the socket is closed (universally represented
as sock->priv == NULL) before doing anything else in the socket methods.
This should safely return from unusual situations where the socket has
been closed and part-destroyed but still ends up having send() or recv()
called on it.

10 years agosocket: Fix return values of socket_send_messages in socks5.c
Philip Withnall [Tue, 2 Sep 2014 10:55:19 +0000 (11:55 +0100)]
socket: Fix return values of socket_send_messages in socks5.c

The return value is the number of messages sent, or -1 on error — not a
boolean.

10 years agostun: Make a warning message more prominent
Philip Withnall [Mon, 1 Sep 2014 14:56:34 +0000 (15:56 +0100)]
stun: Make a warning message more prominent

Since dropping a STUN message due to having insufficient buffer space in
libstun can cause ICE negotiation to fail. So we want it to be more
obvious in the logs.

10 years agoagent: Put one StunAgent per Component
Olivier Crête [Sat, 30 Aug 2014 21:13:29 +0000 (17:13 -0400)]
agent: Put one StunAgent per Component

Otherwise we risk running out of space in the space limited saved ids
list. So the easiest way to do that is to put one StunAgent in each
component. It may be advisable to just give up on not allocating
memory inside libstun and just use a regular hash table in there
instead.

10 years agoconncheck: Fetch stream once instead of twice
Olivier Crête [Mon, 1 Sep 2014 13:26:32 +0000 (09:26 -0400)]
conncheck: Fetch stream once instead of twice

10 years agoagent: Agent can reach EOS after having received something
Philip Withnall [Mon, 1 Sep 2014 15:01:02 +0000 (16:01 +0100)]
agent: Agent can reach EOS after having received something

The agent can reach EOS after performing one or more non-empty reads in
its read loop, and then hitting EOS on the underlying stream. That means
reached_eos is TRUE, but n_valid_messages is non-zero.

Weaken the postcondition to reflect this.

10 years agoagent: Fix locking when calling component_free()
Philip Withnall [Tue, 26 Aug 2014 08:31:37 +0000 (09:31 +0100)]
agent: Fix locking when calling component_free()

As mentioned in the previous commit message, component_free() requires
the agent lock to be released, but component_close() requires it to be
held. Fix the locking in nice_agent_remove_stream() to do that.

10 years agoagent: Split component_free() into component_[close|free]()
Philip Withnall [Tue, 26 Aug 2014 08:30:26 +0000 (09:30 +0100)]
agent: Split component_free() into component_[close|free]()

Closing a component and freeing it are slightly conceptually different.
As it happens, freeing it can result in the disposal of the component's
NiceIOStream, which requires the agent lock to be released — but closing
the rest of the Component requires the agent lock to be held. Splitting
the function up simplifies locking handling in other parts of the code
(see next commit).

10 years agoagent: Fix initialisation of the agent mutex for old GLib versions
Philip Withnall [Mon, 25 Aug 2014 10:31:52 +0000 (11:31 +0100)]
agent: Fix initialisation of the agent mutex for old GLib versions

The mutex is now non-recursive. This is left over from commit 1deee693.

10 years agotests: Fix test-build-io-stream for EOS changes
Philip Withnall [Mon, 25 Aug 2014 06:58:39 +0000 (07:58 +0100)]
tests: Fix test-build-io-stream for EOS changes

From commit 7b6935c66738d855c84fba291d47ece6ce1c43e2.

10 years agoagent: Add missing bracket
Philip Withnall [Mon, 25 Aug 2014 06:55:45 +0000 (07:55 +0100)]
agent: Add missing bracket

Bad merge in commit 67179ffd8fb1a39936c54ce611e8deeec8705ac3.

10 years agoagent: Add missing stream-closed checks for pseudo-TCP
Philip Withnall [Sat, 23 Aug 2014 07:45:30 +0000 (08:45 +0100)]
agent: Add missing stream-closed checks for pseudo-TCP

This got lost in rebasing the FIN–ACK work. component->tcp is now only
NULL before the pseudo-TCP stream is initially created — afterwards, it
is always non-NULL, but pseudo_tcp_stream_is_closed() returns TRUE if
the stream has closed (gracefully or on errors). This allows
differentiation between the states: TCP support was never initialised;
and TCP support was initialised but is now closed.

10 years agoagent: Return 0 on EOS from nice_input_stream_read()
Philip Withnall [Fri, 22 Aug 2014 07:24:57 +0000 (08:24 +0100)]
agent: Return 0 on EOS from nice_input_stream_read()

We should return 0 instead of G_IO_ERROR_CLOSED for consistency with
recv() and read().