Philip Withnall [Fri, 8 Aug 2014 08:44:46 +0000 (09:44 +0100)]
pseudotcp: Store segment flags in SSegment
Rather than reconstructing the flag state when sending a segment, just
store the flags explicitly. This does not introduce any behavioural
changes.
Philip Withnall [Wed, 6 Aug 2014 14:37:47 +0000 (15:37 +0100)]
pseudotcp: Allow the ‘current’ time to be set
This is needed for the upcoming new test suite for pseudo-TCP. It
shouldn’t be used in normal code — only in tests.
Ideally, the pseudo-TCP code should originally never have called
g_get_monotonic_time() itself, and should have always taken a time
parameter from the caller; then it would be more testable.
Unfortunately, API guarantees prevent this from being changed now.
Philip Withnall [Tue, 5 Aug 2014 16:39:01 +0000 (17:39 +0100)]
pseudotcp: Add socket state to debug messages
This should make debugging a little clearer.
Philip Withnall [Fri, 8 Aug 2014 08:05:19 +0000 (09:05 +0100)]
pseudotcp: Put TCP flags in an enum
The on-the-wire flags (FIN, RST, ACK, etc.) should be in an enum to
clarify the code a little. This introduces no functional changes.
Philip Withnall [Tue, 5 Aug 2014 09:42:20 +0000 (10:42 +0100)]
pseudotcp: Put TCP options in an enum
This tidies things up a little. No functional changes.
Philip Withnall [Fri, 8 Aug 2014 09:12:36 +0000 (10:12 +0100)]
tests: Improve debug output of pseudotcp tests slightly
Philip Withnall [Fri, 8 Aug 2014 09:10:39 +0000 (10:10 +0100)]
tests: Add setlocale() call to test-pseudotcp.c
This ensures UTF-8 output is printed correctly.
Philip Withnall [Fri, 8 Aug 2014 08:26:11 +0000 (09:26 +0100)]
tests: Add a logging domain for the unit tests
This clarifies the log output a little.
Philip Withnall [Fri, 8 Aug 2014 10:32:59 +0000 (11:32 +0100)]
socket: Gracefully return from send() if the socket is closed
Philip Withnall [Fri, 8 Aug 2014 10:31:06 +0000 (11:31 +0100)]
agent: Ensure Component.selected_pair is cleaned when freeing candidates
When freeing candidates (component_free_socket_sources()), the sockets
which back Component.selected_pair.[local|remote] are closed and their
addresses destroyed. Component.selected_pair should be cleared as well
to allow calling code to condition on (Component.selected_pair == NULL)
to see if it’s invalid.
Philip Withnall [Fri, 8 Aug 2014 10:30:43 +0000 (11:30 +0100)]
agent: Factor out common clean up code in Component
This introduces no functional changes.
Philip Withnall [Fri, 8 Aug 2014 10:29:41 +0000 (11:29 +0100)]
agent: Tidy up a few variable references
This simplifies the code a little. No functional changes.
Philip Withnall [Fri, 8 Aug 2014 07:48:08 +0000 (08:48 +0100)]
agent: Rearchitect message handling to use GErrors for EWOULDBLOCK
Previously, an EWOULDBLOCK return value from the low-level socket calls
(including PseudoTcpSocket) would be represented by a zero number of
bytes (or messages) read by the agent. This conflicts with the use of
zero to represent end of stream (EOS) for pseudo-TCP connections, where
the sender has indicated that they are not going to send any more bytes.
So, now use GError (G_IO_ERROR_WOULD_BLOCK) to represent EWOULDBLOCK,
just like the GSocket functions. Zero is reserved exclusively for if:
• the number of requested bytes/messages is zero; or
• reliable mode is enabled and EOS is reached.
This does change the documented behaviour of the NiceAgent send/recv
API, but only by allowing a new behaviour (returning zero) rather than
by changing an existing one, so it should be OK.
Philip Withnall [Tue, 12 Aug 2014 08:07:49 +0000 (09:07 +0100)]
pseudotcp: Fix the type of an argument to apply_option()
We’re dealing with unsigned bytes here, not chars. This will become
important when adding new TcpOptions numbered from 254 downwards.
Philip Withnall [Tue, 12 Aug 2014 07:29:39 +0000 (08:29 +0100)]
pseudotcp: Add pseudo_tcp_socket_is_closed_remotely()
New convenience API to check if the remote end of a pseudo-TCP socket
has been closed (but not necessarily the local end). This is currently a
stub implementation, but will be used fully once pseudo-TCP FIN–ACK
support lands.
Philip Withnall [Fri, 8 Aug 2014 09:16:00 +0000 (10:16 +0100)]
pseudotcp: Add pseudo_tcp_socket_is_closed()
New convenience API to check if the socket is in state TCP_CLOSED.
Philip Withnall [Tue, 5 Aug 2014 12:10:40 +0000 (13:10 +0100)]
pseudotcp: Factor out state changes and validate them
By validating state changes, we can verify that the implementation
conforms to the RFC 793 state machine at runtime. This will become more
important when FIN–ACK support is added, adding more states.
Olivier Crête [Thu, 21 Aug 2014 18:04:24 +0000 (14:04 -0400)]
agent: Factor out peer reflexive priority calculation
Olivier Crête [Thu, 14 Aug 2014 23:15:00 +0000 (19:15 -0400)]
agent: Add "keepalive-conncheck" property to make keepalives be conncheck
This is to use keepalives to check if the connection is still ongoing. If
they don't get a reply, then we can assume that the connection has died.
This needs to not happen in the case of ICE-TCP.
Olivier Crête [Mon, 18 Aug 2014 19:30:05 +0000 (15:30 -0400)]
nicesink: Check for signal present before removing it
The signal is only connected when setting an agent, if no agent
has been set, there will be no signal.
Philip Withnall [Sun, 10 Aug 2014 22:38:23 +0000 (23:38 +0100)]
stun: Fix definition of ssize_t on Windows
ssize_t should definitely be signed, not unsigned.
Philip Withnall [Sun, 10 Aug 2014 22:43:25 +0000 (23:43 +0100)]
build: Add README.win32 to EXTRA_DIST
As spotted by B Andrei on the mailing list.
Philip Withnall [Thu, 14 Aug 2014 17:06:43 +0000 (18:06 +0100)]
socket: Remove dead code
At that point, (len > 0), since there are conditions above handling the
(len == 0) and (len < 0) cases, both of which break from the loop.
Coverity issue: #29325
Youness Alaoui [Fri, 8 Aug 2014 19:32:13 +0000 (15:32 -0400)]
nicesink: Block until component is writable if in reliable mode
Youness Alaoui [Fri, 8 Aug 2014 19:31:33 +0000 (15:31 -0400)]
Fix bug in the ice-tcp unit test
Olivier Crête [Tue, 12 Aug 2014 22:40:47 +0000 (18:40 -0400)]
conncheck: Go to connected only if the component was connected or ready
Otherwise, it claimed it was connected when the component was in the FAILED
state, when it should really have gone to connecting.
Olivier Crête [Mon, 11 Aug 2014 18:27:40 +0000 (14:27 -0400)]
outputstream: Fix ref leak
Olivier Crête [Mon, 11 Aug 2014 18:12:53 +0000 (14:12 -0400)]
component: Fix ref leak
Philip Withnall [Fri, 18 Jul 2014 07:44:41 +0000 (08:44 +0100)]
agent: Expand documentation for nice_interfaces_get_ip_for_interface()
Youness Alaoui [Fri, 8 Aug 2014 03:33:43 +0000 (23:33 -0400)]
Set candidate pairs from discovered peer-reflx tcp-passive candidates into DISCOVERED state so it doesn't fail if the other side doesn't reply to our binding request
Youness Alaoui [Thu, 31 Jul 2014 23:58:43 +0000 (19:58 -0400)]
Fix retransmission timers for reliable sockets
The retransmissions would timeout after 600ms which caused the TCP connections
to timeout before it's able to connect. TCP sockets need to timeout
after 8 seconds instead.
Olivier Crête [Wed, 9 Jul 2014 21:57:33 +0000 (17:57 -0400)]
Revert "agent: Separate reliability from ice-tcp vs ice-udp"
This reverts commit
18e5dff4f25b12522e857c13d3ef3bdb40212246.
Youness Alaoui [Fri, 25 Jul 2014 11:02:25 +0000 (07:02 -0400)]
Change test-icetcp to be more robust against ready->connected->ready state changes
Youness Alaoui [Fri, 25 Jul 2014 10:59:10 +0000 (06:59 -0400)]
Cast the current time for pseudotcp timeout calculation into guint32
The pseudo_tcp_socket_get_next_clock returns the next clock in terms
of g_get_monotonic_clock / 1000, however, it gets cropped to guint32.
When we try to find the interval, by substracting the current time as
a guint64, it will return a negative value, which prevents an integer
overflow by setting the timeout to 0. This causes the notify_clock
timeout to be called all the time by the mainloop, taking 100% of CPU.
Olivier Crête [Wed, 23 Jul 2014 21:36:46 +0000 (22:36 +0100)]
agent: Print libnice debug messages when setting G_MESSAGES_DEBUG appropriately
This way all the debug can be controlled from one place.
Also disable -Wsuggest-attribute=format with -Werror because gcc 4.8.3
erroneously suggested it.
Olivier Crête [Wed, 23 Jul 2014 21:35:02 +0000 (22:35 +0100)]
pseudotcp: Use different g_log domain for pseudotcp
Also add one for pseudotcp-verbose
Olivier Crête [Wed, 23 Jul 2014 21:24:27 +0000 (22:24 +0100)]
debug: Make debug messages ready for g_log()
Send thing one line at a time, so no explicit \n
Also make it possible to set a log handler explicitly
Youness Alaoui [Wed, 23 Jul 2014 01:11:46 +0000 (21:11 -0400)]
Fix timer for TURN CreatePermission.
The TURN CreatePermission is a list of multiple permissions but the timer
is created and overwrites the old one, so some of them don't get triggered
at the right time.
This patch was suggested by Livio Madaro. We create a timer for the minimal
amount of time, and trigger the retransmissions on the permissions that
timed out, then reschedule for the next retransmissions.
Livio Madaro [Wed, 18 Jun 2014 01:18:57 +0000 (21:18 -0400)]
Check error code 438 for TURN Nonce expired
Youness Alaoui [Wed, 18 Jun 2014 01:02:45 +0000 (21:02 -0400)]
Do not access component if it was destroyed when calling the io callback
When calling component_emit_io_callback, the agent mutex will be unlocked before
the callback is called, this can cause another thread to remove the
stream and thus destroying the component. We must verify that the
source was not destroyed after calling component_emit_io_callback
and avoid accessing the component in that case.
Bug report by Stephan Thamm in the mailing list.
Youness Alaoui [Wed, 18 Jun 2014 00:38:00 +0000 (20:38 -0400)]
Use sockaddr for stun_usage_bind_process in unit test
Philip Withnall [Tue, 15 Jul 2014 13:57:46 +0000 (14:57 +0100)]
agent: Use AC_CHECK_HEADERS to check for netdb.h
Rather than assuming it is not available on Windows.
Olivier Crête [Sat, 12 Jul 2014 19:22:45 +0000 (15:22 -0400)]
interfaces: Add missing brackets
Youness Alaoui [Wed, 9 Jul 2014 22:55:44 +0000 (18:55 -0400)]
agent: Fix infinite loop when the peer closes a TCP connection remotely
Olivier Crête [Fri, 11 Jul 2014 21:59:27 +0000 (17:59 -0400)]
tcp-passive: Relay the tcp writable callback up
Otherwise, the caller gets a callback from an unexpected source.
Philip Withnall [Fri, 4 Jul 2014 13:39:29 +0000 (14:39 +0100)]
agent: Fix an old-style function definition in the Windows code
Philip Withnall [Fri, 4 Jul 2014 13:38:36 +0000 (14:38 +0100)]
agent: Add debugging when parsing addresses
Philip Withnall [Fri, 4 Jul 2014 11:31:32 +0000 (12:31 +0100)]
agent: Switch to GetAdapterAddresses() to find local IPs on Windows
The old GetIpAddrTable() function only returned IPv4 addresses. In order
to support IPv6 addresses, we need to use GetAdapterAddresses(), which
is available from Windows XP or Server 2003 onwards.
Philip Withnall [Fri, 4 Jul 2014 10:50:29 +0000 (11:50 +0100)]
agent: Use getaddrinfo() to parse addresses from strings
Rather than using inet_pton(), which doesn’t support IPv6 link-local
scope IDs, use getaddrinfo(). This is supported on all platforms
(POSIX.1-2001, and Windows winsock).
Philip Withnall [Fri, 4 Jul 2014 10:41:52 +0000 (11:41 +0100)]
agent: Use getnameinfo() instead of inet_ntop() to stringify addresses
inet_ntop() drops IPv6 link-local scope IDs on the floor, which means
libnice doesn’t generate any IPv6 candidates for link-local connections,
meaning that it will theoretically fail to negotiate a connection on an
IPv6-only network where the two peers are local.
Fix that by using getnameinfo() to convert sockaddrs to strings, which
preserves the scope ID.
There are no portability concerns — getnameinfo() is POSIX.1-2001, and
isn’t used on Windows (although it is supported, surprisingly).
Olivier Crête [Mon, 7 Jul 2014 23:38:13 +0000 (19:38 -0400)]
outputstream: Always try sending
Otherwise we're never woken up when it's again possible to send
Olivier Crête [Mon, 7 Jul 2014 23:34:38 +0000 (19:34 -0400)]
outputstream: Fix reference leak
Olivier Crête [Mon, 7 Jul 2014 20:01:49 +0000 (16:01 -0400)]
agent: Factor our writability signal
Olivier Crête [Wed, 2 Jul 2014 18:10:36 +0000 (14:10 -0400)]
introspection: Rename gir file to match library version
Philip Withnall [Wed, 2 Jul 2014 13:48:07 +0000 (14:48 +0100)]
socket: Avoid g_main_context_ref(NULL) calls using the default context
If (agent->main_context == NULL) the sockets are created with a NULL
main context, which they then try to ref. That does not end well.
Philip Withnall [Mon, 30 Jun 2014 19:09:30 +0000 (20:09 +0100)]
examples: Remove unnecessary dynamic type casts
We know the agent is a GObject — there is no need to check it at
runtime. This also improves Tartan’s static analysis of signal
connections.
Philip Withnall [Mon, 30 Jun 2014 19:04:16 +0000 (20:04 +0100)]
agent: Add a missing precondition assertion
Spotted by Tartan.
Philip Withnall [Mon, 30 Jun 2014 16:51:56 +0000 (17:51 +0100)]
docs: Remove some private symbols from the documentation sections file
Philip Withnall [Mon, 30 Jun 2014 16:51:45 +0000 (17:51 +0100)]
agent: Add a missing field documentation comment
Philip Withnall [Mon, 30 Jun 2014 16:51:33 +0000 (17:51 +0100)]
agent: Fix typos in documentation
Philip Withnall [Mon, 30 Jun 2014 16:38:35 +0000 (17:38 +0100)]
build: Add the lcov directory to .gitignore
Philip Withnall [Mon, 30 Jun 2014 16:37:17 +0000 (17:37 +0100)]
agent: Add missing #includes to candidate.h
Philip Withnall [Mon, 30 Jun 2014 16:35:39 +0000 (17:35 +0100)]
agent: Mark nice_agent_attach_recv() as (skip)
This removes it from the introspected bindings. It is unintrospectable
because it specifies a callback (@func) which persists after the
nice_agent_attach_recv() call returns. This is only supported by
gobject-introspection if a full closure with GDestroyNotify callback for
the user is passed in too.
Philip Withnall [Mon, 30 Jun 2014 16:35:19 +0000 (17:35 +0100)]
agent: Fix a typo in a documentation comment
Philip Withnall [Mon, 30 Jun 2014 16:34:53 +0000 (17:34 +0100)]
agent: Add missing (element-type) annotations to gtk-doc comments
These make the GSLists usable from introspection.
Philip Withnall [Mon, 30 Jun 2014 16:34:19 +0000 (17:34 +0100)]
agent: Fix badly formatted gtk-doc comments
Philip Withnall [Mon, 30 Jun 2014 16:30:21 +0000 (17:30 +0100)]
build: Add GObject introspection support
This bumps our autoconf requirement to 2.62 (from 2.59c) and disables
automake portability warnings.
It does not introduce a hard dependency on gobject-introspection; but if
available, it requires version 1.30.0. Support can be enabled with
--enable-introspection, and is required to make distcheck.
The generated introspection file has not been checked thoroughly, and
may expose internal symbols. A lot of new annotations are needed to make
many of the symbols usable.
Philip Withnall [Mon, 30 Jun 2014 16:28:09 +0000 (17:28 +0100)]
nice: Expose UPnP support in nice.pc.in
It might be useful for dependent packages to check whether libnice was
compiled with UPnP support, so expose that as a variable in the
pkg-config file, set to ‘true’ if supported, and the empty string
otherwise.
Philip Withnall [Mon, 30 Jun 2014 16:27:10 +0000 (17:27 +0100)]
nice: Auto-substitute pkg-config requirements in nice.pc.in
The requirements in the pkg-config file were outdated and incomplete. It
makes a lot more sense to automatically substitute them in from the
checks in configure.ac.
Olivier Crête [Mon, 7 Jul 2014 19:12:38 +0000 (15:12 -0400)]
interfaces: License was meant to be the same as the rest
Olivier Crête [Fri, 27 Jun 2014 14:14:05 +0000 (10:14 -0400)]
Require automake 1.12
We use macros from 1.12 anyway.
Olivier Crête [Sat, 17 May 2014 06:57:15 +0000 (15:57 +0900)]
agent: Separate reliability from ice-tcp vs ice-udp
We want ICE-TCP to not have reliable behavior unless the agent
is reliable otherwise it will confuse existing VoIP applications.
Olivier Crête [Sat, 17 May 2014 06:44:45 +0000 (15:44 +0900)]
agent: Only deal with pseudotcp if actually using PseudoTCP
PseudoTCP is only used if both the pseudotcp socket exists and the
underlying transport is unreliable.
Olivier Crête [Sat, 17 May 2014 05:49:46 +0000 (01:49 -0400)]
discovery: Make it less likely that a locally assigned remote foundation clashes with the remote one.
Olivier Crête [Sat, 17 May 2014 05:31:57 +0000 (01:31 -0400)]
discovery: Compare turn server when assigning foundations
The RFC says that "for reflexive and relayed candidates, the STUN or TURN servers
used to obtain them have the same IP address."
Olivier Crête [Sat, 17 May 2014 05:31:13 +0000 (01:31 -0400)]
discovery: Use nice_address_equal_no_port()
Olivier Crête [Sat, 17 May 2014 05:30:10 +0000 (01:30 -0400)]
discovery: Compare tranports (TCP vs UDP) while assigning remote foundations
Olivier Crête [Sat, 17 May 2014 05:29:14 +0000 (01:29 -0400)]
address: add nice_address_equal_no_port() to compare addresses ignoring ports
Olivier Crête [Sat, 17 May 2014 04:59:17 +0000 (00:59 -0400)]
agent: Add new-selected-pair-full
This signal include the whole candidate as the foundation is ambiguous.
Olivier Crête [Sat, 17 May 2014 04:50:44 +0000 (00:50 -0400)]
signal
Olivier Crête [Sat, 17 May 2014 03:10:07 +0000 (23:10 -0400)]
TODO: Update to match current state
Olivier Crête [Sat, 17 May 2014 04:23:14 +0000 (00:23 -0400)]
gitignore: Add test-driver from recent automake
Olivier Crête [Sat, 17 May 2014 04:03:04 +0000 (00:03 -0400)]
agent: Add new-candidate-full and new-remote-candidate-full signals
These signals include the actual candidate instead of just the foundation
which is not unique.
Olivier Crête [Sat, 17 May 2014 04:02:33 +0000 (00:02 -0400)]
candidate: Add Boxed type
Olivier Crête [Fri, 16 May 2014 16:04:30 +0000 (12:04 -0400)]
stunmessage: Accept NULL terminated buffers for fast speed validation
Olivier Crête [Thu, 15 May 2014 21:48:30 +0000 (17:48 -0400)]
discovery: Differentiate socket creation failure from other errors
If the socket can't be bound, then trying another port makes sense,
otherwise it doesn't.
Youness Alaoui [Fri, 25 Apr 2014 11:24:42 +0000 (07:24 -0400)]
Add TCP server reflexive candidates
For TCP server reflexive candidates, since STUN can't work on TCP
candidates, we will use STUN on UDP or TCP and once we get an
externally mapped address, we will create a server reflexive candidate
for all local TCP candidates that share the same base address, and use
the same mapped port as the base addresse's port.
Youness Alaoui [Fri, 25 Apr 2014 10:55:02 +0000 (06:55 -0400)]
Signal reliable-transport-writable when ice-tcp socket is writable
Youness Alaoui [Fri, 25 Apr 2014 10:40:40 +0000 (06:40 -0400)]
Add a nice_socket_can_send and nice_socket_set_writable_callback APIs
Youness Alaoui [Fri, 25 Apr 2014 10:13:33 +0000 (06:13 -0400)]
Call g_socket_check_connect_result before g_socket_is_connected
If we don't call check_connect_result on an outbound connection,
then is_connected will always return FALSE. That's why we check
both conditions to make sure g_socket_is_connected returns the
correct result, otherwise we end up closing valid connections
Youness Alaoui [Fri, 25 Apr 2014 08:32:32 +0000 (04:32 -0400)]
Bind to a local random port for tcp-bsd
Youness Alaoui [Fri, 25 Apr 2014 08:32:09 +0000 (04:32 -0400)]
Change argument names for tcp-bsd
Jakub Adam [Thu, 24 Apr 2014 11:12:26 +0000 (13:12 +0200)]
Set local address of TCP-BSD socket
Jakub Adam [Thu, 24 Apr 2014 10:38:56 +0000 (12:38 +0200)]
nice_tcp_bsd_socket_new: rename addr -> remote_addr
Youness Alaoui [Thu, 24 Apr 2014 02:32:53 +0000 (22:32 -0400)]
Add a bytestream-tcp property that is read-only for now
Youness Alaoui [Thu, 24 Apr 2014 02:29:32 +0000 (22:29 -0400)]
Only enable ice-tcp for RFC and OC2007 compatibility modes
Youness Alaoui [Thu, 24 Apr 2014 01:21:08 +0000 (21:21 -0400)]
Add documentation for ice-udp and ice-tcp properties
Youness Alaoui [Sat, 19 Apr 2014 06:34:12 +0000 (02:34 -0400)]
Only generate ms-turn candidates for ice-tcp base host addresses
The issue here was that there would be a new turn discovery for UDP
and for TCP-ACTIVE host candidates and we'd get 2 relayed addresses
with the same base_addr causing two relayed candidates to have the
same foundation. This causes farstream to duplicate candidates
since we only expose the foundation when we signal new-candidate.
This will also help later for adding turn-tcp support.
Youness Alaoui [Sat, 19 Apr 2014 04:52:18 +0000 (00:52 -0400)]
Move the rfc4571 handling for OC2007 into udp-turn
In the case of OC2007, we must consider that the turn control messages
are framed with rfc4571 and udp-turn-over-tcp only adds a single guint16
to represent turn-control or end-to-end indication. Otherwise, we will
have issues with double-framing when we do the allocate directly on
the udp-turn-over-tcp but we'd have no framing once we add the udp-turn
socket layer on top of udp-turn-over-tcp
Youness Alaoui [Sat, 19 Apr 2014 04:51:00 +0000 (00:51 -0400)]
Do not parse turn data more than once if we have multiple relays