Sangchul Lee [Wed, 11 May 2022 02:37:55 +0000 (11:37 +0900)]
meson_option: Enable dlog
[Version] 0.1.18-2
[Issue Type] Log
Change-Id: I666e75c78ef1309b523ec2bb79781b2313f1bfad
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
Sangchul Lee [Thu, 17 Feb 2022 07:18:16 +0000 (16:18 +0900)]
Update spec file and meson files
Change-Id: I155c032e191ebbc0bcfaf62e6904c1ad28f5dfee
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
Olivier Crête [Wed, 26 Jan 2022 18:57:13 +0000 (13:57 -0500)]
meson: Fix openssl setting
This should fix builds on platforms openssl
Change-Id: If13f747fe358f1e7e0043356043a5085781d09c6
Olivier Crête [Tue, 2 Nov 2021 17:14:55 +0000 (13:14 -0400)]
meson: Simplify finding OpenSSL
Remove duplicated calls to dependency() so we can have fallback in all
cases.
Change-Id: Ic278734a9824e1646aec50a1d807b0451f8bf834
Olivier Crête [Tue, 2 Nov 2021 16:33:13 +0000 (12:33 -0400)]
meson: Fix name of variable
This is a fix over the recent fix in commit
574f44b4
Change-Id: I922f0895ae13d5802aea4775860f642d18c8d86c
Xavier Claessens [Thu, 28 Oct 2021 14:24:39 +0000 (10:24 -0400)]
Fix error when crypto/ssl libs are found without pkg-config
In that case crypto_dep is a list and we can't call .found() method.
Change-Id: Ie63d78530d9a935312263bf9843f76667b17c4f6
Sangchul Lee [Thu, 17 Feb 2022 05:08:15 +0000 (14:08 +0900)]
Merge branch 'upstream' into tizen
It is updated to 0.1.18.
Change-Id: Ife96288be82519f7cec61c48d5f6f53edd98de79
Sangchul Lee [Thu, 17 Feb 2022 04:08:01 +0000 (13:08 +0900)]
Merge tag '0.1.18' into upstream
Libnice release 0.1.18
Change-Id: I3af1a67390b647bd36d23002f396bc2406659c7b
Sangchul Lee [Thu, 17 Feb 2022 04:05:23 +0000 (13:05 +0900)]
Initialize git
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
Sangchul Lee [Thu, 10 Feb 2022 05:52:49 +0000 (14:52 +0900)]
Exclude gst plugins from build
Gstreamer plugins move on to the gstreamer mono git since 1.20.0.
: gstreamer/subprojects/gst-plugins-bad/ext/nice
Change-Id: Ib006250b5261ded170f6ba17725d79a24ed000b2
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
(cherry picked from commit
4e38bd1424281f45de01779ec1b1f2b301107f5a)
YoungHun Kim [Thu, 2 Sep 2021 03:05:23 +0000 (12:05 +0900)]
Change nice_debug_verbose as dlog message
Change-Id: I6d759bf95019e6fcd02bede420bd88d6f980f18e
YoungHun Kim [Tue, 10 Aug 2021 09:29:45 +0000 (18:29 +0900)]
Use dlog to debug agent
- Log tag is LIBNICE_AGENT
Change-Id: I19252689850078b8452e4cd7ae51dc04f275bf4f
Olivier Crête [Wed, 21 Oct 2020 00:45:24 +0000 (20:45 -0400)]
version 0.1.18
Johan Sternerup [Thu, 9 Jul 2020 11:37:27 +0000 (13:37 +0200)]
conncheck: Only valid stun messages used for Keepalive
Previously, a STUN response for which there was no associated request
would be considered valid media input and as such could keep a dead
connection alive. If peer A was communicating with peer B and peer B got
disconnected, the keepalive mechanism in peer A should detect this.
However, a misbehaving STUN server could keep sending STUN responses to
peer A which would then be considered a valid communication between A
and B and thereby prevent the keepalive mechanism from shutting down the
connection.
Situation above refers to a stun message validated as
STUN_VALIDATION_UNMATCHED_RESPONSE. With this change only messages
validated as STUN_VALIDATION_SUCCESS may keep the connection alive.
Johan Sternerup [Thu, 17 Sep 2020 14:20:05 +0000 (16:20 +0200)]
agent: Enable both UDP and TCP to the same TURN server
Previously if we enabled both UDP and TCP to the same TURN server, the
TCP connection would not work. What happened was that when traffic was
targeted at the TCP connection we would fail to route the traffic to
the right socket due to a too early jump out of the loop searching for
the socket. The search would stop when finding a TURN server matching
the address of the incoming message source. Thus, a UDP TURN server
with the same address as the TCP TURN server would effectively mean
that traffic got routed to a different stun agent that would complain
about receiving responses without matching requests.
Olivier Crête [Fri, 22 May 2020 02:13:14 +0000 (22:13 -0400)]
candidate: Hide the internal implementation from API
This is slightly an API break, but it should never have been public.
Hyunil [Thu, 20 Aug 2020 08:39:07 +0000 (17:39 +0900)]
Version 0.1.17 with tizen patch
remove doc from Makefile.am and configue.ac
Change-Id: If82a404c5c29e0481afa05396d71f1e8cdccfeec
Hyunil [Thu, 20 Aug 2020 08:35:41 +0000 (17:35 +0900)]
Merge branch 'upstream' into tizen
Change-Id: I64747e2043743986156f15d883a136c4fcbc0375
Hyunil [Thu, 20 Aug 2020 08:32:40 +0000 (17:32 +0900)]
Imported Upstream version 0.1.17
Change-Id: I4574844e0f8310d9f89f80a4315861ad87ef070d
Olivier Crête [Wed, 22 Jul 2020 20:23:09 +0000 (16:23 -0400)]
agent: Actually fail gathering on UDP port unavailability
This will make it fail if either our test of UDP port clash fails
or if the kernel rejects the new socket because there is a port clash.
Also include a unit test for this.
Olivier Crête [Tue, 18 Aug 2020 19:55:22 +0000 (15:55 -0400)]
meson: Remove duplicated entry
Ami Perlmutter [Thu, 13 Aug 2020 11:34:50 +0000 (14:34 +0300)]
Ignore interfaces in windows
Olivier Crête [Mon, 10 Aug 2020 23:00:16 +0000 (19:00 -0400)]
gitlab-ci: Use curl --data to make coverity happy
Olivier Crête [Mon, 10 Aug 2020 22:33:49 +0000 (18:33 -0400)]
address: Use union
This makes coverity happier.
Lorenzo Miniero [Tue, 4 Aug 2020 13:53:42 +0000 (15:53 +0200)]
Use g_alloca instead of g_malloc_n in socket_send_messages
Lorenzo Miniero [Thu, 23 Jul 2020 16:33:57 +0000 (18:33 +0200)]
Changed type of variable to signed
Lorenzo Miniero [Tue, 21 Jul 2020 13:30:32 +0000 (15:30 +0200)]
Fixed wrong return value in socket_send_messages for n_messages=1
Lorenzo Miniero [Tue, 21 Jul 2020 10:31:06 +0000 (12:31 +0200)]
Refactored UDP socket_send_messages to use g_socket_send_messages
Olivier Crête [Wed, 22 Jul 2020 19:29:24 +0000 (15:29 -0400)]
tests: Fix warning when building with newer GLib version
Olivier Crête [Tue, 23 Jun 2020 21:32:39 +0000 (17:32 -0400)]
agent: Accept duplicated ports if no other option
Commit
a04fa4d492 introduced a new feature to try to have a different port for every
local candidate, even if they are on different interfaces. This breaks setups where the
application really wants a specific port and sets a range of exactly 1 port or a very small range.
In that case, if we can't find non-duplicated ports, then we just go around again and skip that check,
but only if both ports are in the same stream and component. Otherwise, we fail the whole component!
Olivier Crête [Tue, 21 Jul 2020 23:35:42 +0000 (19:35 -0400)]
candidate: Make debug string functions public
Adds new public APIs, nice_candidate_type_to_string() and
nice_candidate_transport_to_string().
Nirbheek Chauhan [Thu, 9 Jul 2020 17:27:34 +0000 (22:57 +0530)]
interfaces: Fix code style for function declarations
Nirbheek Chauhan [Thu, 9 Jul 2020 12:25:53 +0000 (17:55 +0530)]
interfaces: Fix fetching of interfaces on Win32
nice_interfaces_get_local_interfaces() was returning the hardware
device names of interfaces that have been seen in the past or could be
connected. It had no relation to the actual interfaces present on the
device. Perhaps this worked back in the XP days, but it is returning
garbage today.
Use GetAdapterAddresses(), and return the adapter friendly names as
the interface names. At the same time, update
nice_interfaces_get_ip_for_interface() to match.
Coincidentally, this also fixes UWP compatibility since GetIfTable and
GetIpAddrTable are not available when targeting UWP. They are only
available for desktop apps:
https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getiftable
https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getipaddrtable
Nirbheek Chauhan [Thu, 9 Jul 2020 12:25:08 +0000 (17:55 +0530)]
interfaces: Remove unused win32 code
Nirbheek Chauhan [Thu, 9 Jul 2020 11:13:45 +0000 (16:43 +0530)]
interfaces: Port to GetBestInterfaceEx for UWP compat
Still prefer ipv4 addresses for backwards-compat. GetBestInterface is
not allowed when targeting UWP, so use GetBestInterfaceEx.
Also add some debug logging to ensure that the function is actually
running correctly.
Nirbheek Chauhan [Thu, 9 Jul 2020 11:13:19 +0000 (16:43 +0530)]
interfaces: Add debug logging to sockaddr_to_string
Helps when you forgot to call WSAStartup, for instance.
Olivier Crête [Tue, 23 Jun 2020 22:26:31 +0000 (18:26 -0400)]
agent: Don't go haywire if only a partial message is available
Instead, collect all the pieces until it's complete.
Nirbheek Chauhan [Mon, 15 Jun 2020 14:24:21 +0000 (19:54 +0530)]
stund: Use lowercase winsock2.h
Windows ships with `WinSock2.h` but mingw ships with `winsock2.h`.
This is fine on Windows because files are case-insensitive, but on
Linux it causes the compiler to not find the header.
All other #includes are lowercase, so just use that.
Nirbheek Chauhan [Mon, 15 Jun 2020 22:24:28 +0000 (03:54 +0530)]
meson: Fix typos in crypto-library detection
Nirbheek Chauhan [Mon, 15 Jun 2020 22:19:14 +0000 (03:49 +0530)]
rand: Use crypto libs instead of CryptGenRandom()
We will always have either openssl or gnutls, which are better sources
for random nonces. Also, CryptGenRandom is deprecated API that's not
available on WinRT/UWP.
Hyunil [Mon, 15 Jun 2020 03:18:23 +0000 (12:18 +0900)]
Apply ASLR to stund and stunbdc of stun/tools
Change-Id: Ieb4ad8f0098329ff6145828fc0f1ec617e85f6f6
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
Fabrice Bellet [Wed, 20 May 2020 12:25:17 +0000 (14:25 +0200)]
conncheck: add a check to move into the ready state after a pair failed
This patch tries to move the component state from connected to ready in
places where a pair may fail. Consequently, the final check done after
the expiration of the idle timeout can be removed, assuming that
transitions are done as soon as they occur.
The only place where such a situation has been observed in a real world
stress test is a 401 unauthorized stun error received in
priv_map_reply_to_conn_check_request(), when the conncheck contains a
local and a remote candidate, both of type host, with an identical IP
address and port number (two boxes with a private network using the same
subnet). In such a case, a stun request to the remote candidate will
reach the local candidate instead, and will logically fail.
Olivier Crête [Fri, 22 May 2020 22:18:15 +0000 (18:18 -0400)]
gitignore: Remove in-tree built files
Meson always does out of tree builds
Olivier Crête [Fri, 22 May 2020 22:07:30 +0000 (18:07 -0400)]
agent: Remove test that is not required
The stream and component pointers are always valid there.
Olivier Crête [Fri, 22 May 2020 21:35:14 +0000 (17:35 -0400)]
gitlab-ci: Put image at the top
Olivier Crête [Fri, 31 Jan 2020 16:31:48 +0000 (16:31 +0000)]
gitlab-ci: Rename tasks to not say meson
They're always meson now.
Tim-Philipp Müller [Fri, 31 Jan 2020 16:31:48 +0000 (16:31 +0000)]
Remove autotools build
Remove dist check on the CI, since it doesn't really
add anything in the Meson case (tarball is based
on files checked into git and srcdir != builddir).
Olivier Crête [Fri, 22 May 2020 19:58:01 +0000 (15:58 -0400)]
version 0.1.17.1
Olivier Crête [Fri, 22 May 2020 19:41:19 +0000 (15:41 -0400)]
version 0.1.17
Olivier Crête [Fri, 22 May 2020 19:32:22 +0000 (15:32 -0400)]
meson: Remove Wextra from options
meson already sets it on warning_level >= 2
Olivier Crête [Fri, 22 May 2020 03:09:19 +0000 (23:09 -0400)]
meson: Actually make meson generate the compat Makefile
The previous patch didn't get triggered
Olivier Crête [Fri, 22 May 2020 19:51:42 +0000 (15:51 -0400)]
Makefile.am: Add dist meson friendly test
Olivier Crête [Fri, 22 May 2020 14:36:52 +0000 (10:36 -0400)]
meson: Make gtkdoc-check work with older gtk-doc
Older gtkdoc versions expect to find a Makefile, so generate
a fake one with the information it wants.
Olivier Crête [Fri, 22 May 2020 03:09:19 +0000 (23:09 -0400)]
meson: Run gtkdoc-check
Olivier Crête [Fri, 22 May 2020 18:35:59 +0000 (14:35 -0400)]
gitlab-ci: Disable gtkdoc when doing valgrind
Olivier Crête [Fri, 22 May 2020 03:09:01 +0000 (23:09 -0400)]
gitignore: Don't ignore libnice-docs.txt
Olivier Crête [Fri, 22 May 2020 15:17:28 +0000 (11:17 -0400)]
test-new-trickle: No need to be connected to receive data
Fabrice Bellet [Tue, 19 May 2020 11:58:55 +0000 (13:58 +0200)]
conncheck: do not always remove pair in triggered check list
This patch reenables an interesting side effect that existed before
commit
263c0903, when the state of a pair state in the triggered check
list was changed to in-progress. Such "triggered" pairs with this state
were selectively pruned from the conncheck list according to their
priority in priv_prune_pending_checks(), meaning that pairs with a high
priority were conserved, and quickly rechecked.
Retrospectively, I suspect that this side effect was the initial
motivation for changing the state of a "triggered" pair.
Commit
263c0903 disabled that behaviour, for the sake of clarity, but it
seems important to restore it, because these "triggered" pairs are often
retriggered for a good reason, and frequently lead to a nominated pair.
And loosing the opportunity to nominate a pair may be critical in
controlled role when the peer agent is in aggressive nomination mode.
Olivier Crête [Fri, 8 May 2020 23:08:20 +0000 (19:08 -0400)]
agent: Don't hold hard ref while removing stream
The timeout has a weak ref that should be enough.
Olivier Crête [Wed, 13 May 2020 21:52:18 +0000 (17:52 -0400)]
valgrind supp: Add updated gllibc suppressions
Fabrice Bellet [Mon, 18 May 2020 12:16:12 +0000 (14:16 +0200)]
conncheck: clear the retransmit flag when the stun list is empty
This patch ensures that the retransmit flag is more tightly in sync with
the stun transaction list, by now clearing it when the list becomes
empty. It makes the code a bit more readable by dropping some cases. In
a couple of places, the retransmit flag was also used as a way to
compare the priority of a pair and the priority of the selected pair.
Fabrice Bellet [Sun, 17 May 2020 21:08:12 +0000 (23:08 +0200)]
conncheck: add a missing component state transition
When reactivating a high priority pair, we have to change back the
component state from ready to connected, since there is a new pair to be
tested.
The case of the succeeded pair is also a bit simplified, the invocation
of the function conn_check_update_check_list_state_for_ready() to
complete the ready - connected - ready flip-flop transition is not
required for the trickle test any longer.
Fabrice Bellet [Sun, 17 May 2020 21:06:37 +0000 (23:06 +0200)]
conncheck: remove a redundant test
This test is redundant with the previous one.
Fabrice Bellet [Sun, 17 May 2020 20:59:48 +0000 (22:59 +0200)]
conncheck: do not change the pair state in triggered check queue
We prefer to not change the state of the pair, when it is added to the
triggered check queue. Previously its state was changed to in-progress,
which was a bit misleading, as it somewhat anticipated a future state.
Fabrice Bellet [Sun, 17 May 2020 20:51:21 +0000 (22:51 +0200)]
conncheck: handle the consequence when a pair is not created
Since commit
fcd6bc86 a pair is not always created, when its priority
is lower than the selected pair priority. We have to deal with this
possibility when calling the function priv_add_new_check_pair().
More precisely, the component state update really requires the addition
of a new pair.
Fabrice Bellet [Tue, 12 May 2020 18:13:18 +0000 (20:13 +0200)]
conncheck: rework the stun requests ordering per timer tick
With this patch, we merge the two variables stun_sent and
keep_timer_going. The three functions that are a possible source of a
new stun request returns a boolean value stating if a request has been
sent. The semantic of keep_timer_going can now be deduced from
stun_sent and from the result of priv_conn_check_stream_nominate().
The trick that makes this merge possible is to repurpose the return
value of priv_conn_check_tick_stream(), because keep_timer_going set
when the conncheck list contains in-progress pairs in this function is
redundant with the same check later in function
priv_conn_check_tick_stream_nominate().
Fabrice Bellet [Mon, 11 May 2020 10:05:14 +0000 (12:05 +0200)]
conncheck: explicitely order the type of stun requests per timer tick
With this patch, we try to make more explicit the process order between
the different types of stun requets, according that only one request is
sent per callback timer tick, ie every 20ms, to respect the stun pacing
of the spec. We implement the follow priority:
* triggered checks
* stun retransmissions
* ordinary checks
In a concrete case, while a stream has stun requests related to
triggered checks to be sent, all other stun transactions are delayed to
the next timer ticks.
The goal of this patch is to make this priority explicit, and more
easily swappable if needed. Triggered checks have more probability to
succeed than stun retransmissions, this is the reason why they are
handled before. Ordinary checks on the contrary can be performed on a
lower priority basis, after all other stun requests.
The problem that can be sometime observed with a large number of stun
transactions is that stun retransmissions may suffer from a delay after
they have reached their deadline. This delay should remain small thanks
to the design of the initial retransmission timer (RTO), that takes into
account the overall number of scheduled stun requests. It allows all
stun requests to be sent and resent at a predefined "pacing" frequency
without much extra delay.
This ordering not perfect, because stun requests of a given type are
examinated per-stream, by looking at the first stream before the others,
so it introduces a natural priority for the first stream.
Olivier Crête [Wed, 13 May 2020 23:47:11 +0000 (19:47 -0400)]
gitlab-ci: Actually gnore mingw failure
Olivier Crête [Wed, 13 May 2020 23:47:11 +0000 (19:47 -0400)]
gitlab-ci: Ignore mingw failure for now
Olivier Crête [Tue, 12 May 2020 20:04:25 +0000 (16:04 -0400)]
gitlab-ci: Upload build logs as artifacts on Win
Olivier Crête [Fri, 8 May 2020 23:14:43 +0000 (19:14 -0400)]
README: Update for meson
Also, update the RFC numbers that are implemented.
Fabrice Bellet [Sun, 3 May 2020 15:39:09 +0000 (17:39 +0200)]
conncheck: fix try-alternate on tcp turn sockets
In OC2007R2 compatibility mode, we observed the behaviour of a skype
turn server, when returning code 300 (try-alternate) stun error on its
tls connections. This value is returned apparently when the turn server
is overloaded already.
We noticed that the actual code in priv_handle_turn_alternate_server()
cannot handle a non-udp turn server, because a tcp one would require
to create a new socket.
But, even when creating such a new socket stack (tcp-bsd socket +
pseudossl socket), libnice still fails to establish a new connection to
the alternate server on port 443, in a very systematic way. I'm not sure
whether this problem is specific to this skype server infrastructure
(the skype client fails in a similar way). Anyway, this code path works
as expected with a non-microsoft turn server (tested with coturn).
Fabrice Bellet [Wed, 6 May 2020 12:09:08 +0000 (14:09 +0200)]
agent: fix tcp connection to turn servers
A previous commit broke the logic used to start a discovery request for
tcp turn servers. The ambiguity came from the distinction between the
type of the turn server (turn->type), the compatibility of the
transport of the local base candidate (turn_tcp), and the reliability
of the underlying tcp socket (reliable_tcp).
reliable_tcp indicates whether the turn allocate request should be
"framed" in a tcp packet, according to RFC 4571. This is required in
OC2007R2 only.
This commit also puts the setup of the tcp turn socket in a separate
function, because such setup is also required when handling
try-alternate (code 300) stun errors on these tcp sockets, where we have
to setup a new connection to another tcp turn server.
Fabrice Bellet [Thu, 7 May 2020 19:24:09 +0000 (21:24 +0200)]
conncheck: ignore refreshes for tls turn server for OC2007R2
Relay candidates obtained from TLS turn server don't have to be
refreshed in OC2007R2 compatibility mode.
Fabrice Bellet [Sun, 3 May 2020 15:35:22 +0000 (17:35 +0200)]
conncheck: send udp turn refreshes in oc2007r2 compatibility mode too
Olivier Crête [Fri, 8 May 2020 18:31:59 +0000 (14:31 -0400)]
meson: Move glib wrap to download
Fabrice Bellet [Mon, 20 Apr 2020 21:21:17 +0000 (23:21 +0200)]
conncheck: make a single ordinary check per callback
This is more friendly with stun pacing.
Fabrice Bellet [Thu, 16 Apr 2020 17:57:27 +0000 (19:57 +0200)]
conncheck: improve places where the conncheck list is dumped
Fabrice Bellet [Thu, 23 Apr 2020 15:12:41 +0000 (17:12 +0200)]
agent: stay in aggressive mode after stun requests have been sent
This patch updates the previous commit "agent: stay in aggressive mode
after conncheck has started", by accepting to switch from aggressive to
regular mode, while no stun request has been sent. It gives the agent
some extra delay to still accept remote tcp candidates, after its state
already changed from gathering to connecting.
Fabrice Bellet [Tue, 14 Apr 2020 15:25:24 +0000 (17:25 +0200)]
stun: update timer timeout and retransmissions
This patch updates the stun timing constants and provides the rationale
with the choice of these new values, in the context of the ice
connection check algorithm.
One important value during the discovery state is the combination of the
initial timeout and the number of retransmissions, because this state
may complete after the last stun discovery binding request has timed
out. With the combination of 500ms and 3 retransmissions, the discovery
state is bound to 2000ms to discover server reflexive and relay
candidates.
The retransmission delay doubles at each retransmission except for the
last one. Generally, this state will complete sooner, when all
discovery requests get a reply before the timeout.
Another mechanism is used during the connection check, where an stun
request is sent with an initial timeout defined by :
RTO = MAX(500ms, Ta * (number of in-progress + waiting pairs))
with Ta = 20ms
The initial timeout is bounded by a minimum value, 500ms, and scales
linearly depending of the number of pairs on the way to be emited. The
same number of retransmissions than in the discovery state in used
during the connection check. The total time to wait for a pair to fail
is then RTO + 2*RTO + RTO = 4*RTO with 3 retransmissions.
On a typical laptop setup, with a wired and a wifi interface with
IPv4/IPv6 dual stack, a link-local and a link-global IPv6 address, a
couple a virtual addresses, a server-reflexive address, a turn relay
one, we end up with a total of 90 local candidates for 2 streams and 2
components each. The connection checks list includes up to 200 pairs
when tcp pairs are discarded, with :
<33 in-progress and waiting pairs in 50% cases (RTO = 660ms),
<55 in-progress and waiting pairs in 90% cases (RTO = 1100ms),
and up to 86 in-progres and waiting pairs (RTO = 1720ms)
The number of retransmission of 3 seems to be quite robust to handle
sporadic packets loss, if we consider for example a typical packet loss
frequency of 1% of the overall packets transmitted.
And a relatevely large initial timeout is interesting because it reduces
the overall network overhead caused by the stun requests and replies,
mesured around 3KB/s during a connection check with 4 components.
Finally, the total time to wait until all retransmissions have completed
and have timed out (2000ms with an initial timeout of 500ms and 3
retransmissions) gives a bound to the worst network latency we can
accept, when no packet is lost on the wire.
Fabrice Bellet [Mon, 13 Apr 2020 16:03:36 +0000 (18:03 +0200)]
conncheck: update the unfreeze method for RFC8445
The way pairs are unfrozen between RFC5245 and RFC8445 changed a bit,
and made the code much more simple. Previously pairs were unfrozen "per
stream", not they are unfrozen "per foundation". The principle of the
priv_conn_check_unfreeze_next function is now to unfreeze one and only
one frozen pair per foundation, all components and streams included.
The function is now idemporent: calling it when the connchecks still
contains waiting pairs does nothing.
Fabrice Bellet [Mon, 13 Apr 2020 15:54:33 +0000 (17:54 +0200)]
conncheck: update stun timer timeout for RFC8445
The new version of the RFC suppressed the difference between reliable
and not reliable maximum value for RTO. We choose to keep the value of
100ms that we used previously, which is lower that the recommended
value, but could be overriden most of the time, when a significant
number of pairs are handled.
We also compute exactly the number of in-progress and waiting
pairs for all streams of the agent, without relying on the value
per-stream, multiplied by the number of active streams.
Fabrice Bellet [Tue, 5 May 2020 15:09:47 +0000 (17:09 +0200)]
conncheck: another rare case of local tcp active candidate matching
An inbound stun request may come on a tcp pair, whose tcp-active socket
has just been created and connected (the local candidate port is zero),
but has not caused the creation of a discovered peer-reflexive local
candidate (with a non-zero port). This inbound request is stored in an
early icheck structure to be replayed later. When being processed after
remote creds have been received, we have to find which local candidate
it belongs to, by matching with the address only, without the port.
Fabrice Bellet [Sun, 3 May 2020 15:26:48 +0000 (17:26 +0200)]
conncheck: socket reliability should not change the conncheck behaviour
An inbound STUN request on a pair having another STUN request already
inflight already should generate to new triggered check, no matter the
type of the underlying socket.
Fabrice Bellet [Sun, 3 May 2020 15:22:42 +0000 (17:22 +0200)]
conncheck: inbound stun on tcp passive pairs should trigger a check
An inbound stun request on a newly discovered pair should trigger a
conncheck in the reverse direction, and not promote the pair directly in
state succeeded. This is particulary required if the agent is in
aggressive controlling mode.
Fabrice Bellet [Mon, 20 Apr 2020 21:29:49 +0000 (23:29 +0200)]
conncheck: simplify the test to find a matching local candidate
Since we keep a relation between a succeeded and its discovered pair, we
can just test for the socket associated to a given pair, and eventually
follow the link to the parent succeeded pair.
Fabrice Bellet [Mon, 20 Apr 2020 21:24:21 +0000 (23:24 +0200)]
conncheck: properly select tcp-active discovered candidate
Some tcp-active discovered peer-reflexive local candidates may only be
recognised by their local socket, if they have the same address and same
port. It may happen when a nat generates an identical mapping from two
different base local candidates.
Fabrice Bellet [Sun, 5 Apr 2020 19:02:47 +0000 (21:02 +0200)]
stun: set delay in retransmission instead of adding it
We may have situation when stun_timer_refresh is called with a
significant delay after the current deadline. In the actual situation,
this delay is just included to the computation of the new deadline of the
next stun retransmission. We think this may lead to unfair situations,
where the next deadline may be too short, just to compensate the first
deadline that was too long.
For example, if a stun request is scheduled with a delay of
200ms for the 2nd transmission, and 400ms for the 3rd transmission,
if stun_timer_remainder() is called 300ms after the start of the
timer, the second delay will last only 300ms, instead of 400ms.
Fabrice Bellet [Thu, 16 Apr 2020 18:01:25 +0000 (20:01 +0200)]
discovery: ensure port number uniqueness agent-wide
The port number must be different for all local host candidates, not
just in the same component, but across all components and all streams.
A candidate ambiguity between a host local host and an identical server
reflexive candidate have more unwanted consequences when it concerns two
different components, because an inbound stun request may be associated
to a wrong component.
Olivier Crête [Wed, 6 May 2020 04:01:37 +0000 (00:01 -0400)]
interfaces: Use the private address detector from NiceAddress
Olivier Crête [Wed, 6 May 2020 04:00:36 +0000 (00:00 -0400)]
address: Make the private IP address detector more complete
Also adds a unit test
Fixes #67
Fabrice Bellet [Sun, 3 May 2020 16:01:35 +0000 (18:01 +0200)]
conncheck: fix some missing loop exit cases
The refresh list may be modified while being iterated
Fabrice Bellet [Sun, 19 Apr 2020 15:16:05 +0000 (17:16 +0200)]
conncheck: add a couple of switch case fallthroughs
Fabrice Bellet [Sat, 29 Feb 2020 10:02:01 +0000 (11:02 +0100)]
conncheck: merge two cascaded conditions
Olivier Crête [Wed, 6 May 2020 01:59:38 +0000 (21:59 -0400)]
interfaces: Use union for sockaddr/sockaddr_in
This makes clang happy
Fixes #100
Fabrice Bellet [Mon, 13 Apr 2020 15:46:13 +0000 (17:46 +0200)]
conncheck: honor the retransmit flag in case of role conflict
This other rare situation happens when a role conflict is detected by an
stun reply message, on a component that already has a nominated pair
with a higher priority. In that case, the retransmit flag should be
honored, and the pair with "role conflict" should not be retransmitted.
Fabrice Bellet [Thu, 9 Apr 2020 14:47:17 +0000 (16:47 +0200)]
conncheck: add missing cases when pruning pending checks
When pruning pending checks (after at least one nominated pair has been
obtained), some supplementary cases need to be handled, to ensure that
the property "all pairs and only the pairs having a higher priority than
the nominated pair should have the stun retransmit flag set" remains
true during the whole conncheck:
- a pair "not to be retransmitted" must be removed from the triggered check
list (because a triggered check would create a new stun request, that
would defacto ignore the retransmit flag)
- an in-progress pair "not to be retransmitted", for which no stun
request has been sent (p->stun_transactions == NULL, a transient
state) must be removed from the conncheck list, just like a waiting
pair.
- a failed pair must have its flag "retransmit" updated too, just like
another pair, since a failed pair could match an inbound check, and
generate a triggered check, based on retransmit flag value : ie only
if this pair has a chance to become a better nominated pair. See
NICE_CHECK_FAILED case in priv_schedule_triggered_check().
Fabrice Bellet [Wed, 8 Apr 2020 15:24:05 +0000 (17:24 +0200)]
conncheck: toggle the retransmit flag when pruning pending checks
The function conn_check_update_retransmit_flag() that was introduced to
reenable the retransmit flag on pairs with higher priority than the
nominated one can be merged in priv_prune_pending_checks(), and its
invocation replaced by conn_check_update_check_list_state_for_ready().
The function priv_prune_pending_checks() can also be tweaked to use
the component selected pair priority, instead of getting it from
the checklist. This function is called when at least one nominated pair
exists, so selected_pair is this nominated pair.
Fabrice Bellet [Wed, 8 Apr 2020 15:16:30 +0000 (17:16 +0200)]
conncheck: discard new pair creation when priority is too low
It is possible to ignore the creation of a new pair whose priority is
lower than the priority of the selected pair, ie the nominated pair with
the highest priority. Such pair would be discarded by a call to
prune_pending_checks(), and if checked, there state would break the
assumption that all pairs with lower priority than the nominated pair
are not retransmitted.
Fabrice Bellet [Sun, 5 Apr 2020 20:13:27 +0000 (22:13 +0200)]
conncheck: optimize pending checks pruning
We use the property that the conncheck list is ordered by
pairs priorities, so we don't have to iterate twice.