ice: support RFC 6544 ICE over TCP

This patch is the first one used to perform ICE over TCP. Leads to
major changes:

+ IceTransport has now a tcpEnable parameters to use TCP instead
of UDP. Also, this patch makes ICE aggressive nomination available.
+ File transfer is now usable without TURN in a local network. For
now, UPnP is not supported, this will come in a near future. Now,
it can use a direct connection between two pairs.

If the negotiation between peer fails, the TURN is used as a
fallback. Moreover, to avoid breaking compability when a peer wants
to connect, it will send the SDP message followed by TURN ips (like
the current version).

Change-Id: I0425c7da34ff2bc272c376261847195be768d522
parent 65716237
......@@ -28,13 +28,14 @@ if "%NO_AUTO%"=="" (
set UNIXPATH=%SRC:\=/%
set UNIXPATH=%ROOTPATH%%UNIXPATH:C:/=%
bash -c "%PATCH_CMD% %UNIXPATH%pjproject/ipv6.patch"
bash -c "%PATCH_CMD% %UNIXPATH%pjproject/ice_config.patch"
bash -c "%PATCH_CMD% %UNIXPATH%pjproject/multiple_listeners.patch"
bash -c "%PATCH_CMD% %UNIXPATH%pjproject/pj_ice_sess.patch"
bash -c "%PATCH_CMD% %UNIXPATH%pjproject/fix_turn_fallback.patch"
bash -c "%PATCH_CMD% %UNIXPATH%pjproject/fix_ioqueue_ipv6_sendto.patch"
bash -c "%PATCH_CMD% %UNIXPATH%pjproject/add_dtls_transport.patch"
bash -c "%PATCH_CMD% %UNIXPATH%pjproject/rfc6062.patch"
bash -c "%PATCH_CMD% %UNIXPATH%pjproject/rfc6544.patch"
bash -c "%PATCH_CMD% %UNIXPATH%pjproject/ice_config.patch"
%APPLY_CMD% %SRC%\pjproject\win32_vs_gnutls.patch
%APPLY_CMD% %SRC%\pjproject\win_config.patch
......
......@@ -34,11 +34,11 @@ index 5c2f04bd..d8b546c8 100644
@@ -253,7 +253,7 @@
* Default: 2
* Default: 4 (one active and one passive for IPv4 and IPv6)
*/
#ifndef PJ_ICE_MAX_STUN
-# define PJ_ICE_MAX_STUN 2
+# define PJ_ICE_MAX_STUN 3
-# define PJ_ICE_MAX_STUN 4
+# define PJ_ICE_MAX_STUN 6
#endif
......
This diff is collapsed.
......@@ -59,13 +59,14 @@ ifdef HAVE_ANDROID
endif
$(APPLY) $(SRC)/pjproject/rfc2466.patch
$(APPLY) $(SRC)/pjproject/ipv6.patch
$(APPLY) $(SRC)/pjproject/ice_config.patch
$(APPLY) $(SRC)/pjproject/multiple_listeners.patch
$(APPLY) $(SRC)/pjproject/pj_ice_sess.patch
$(APPLY) $(SRC)/pjproject/fix_turn_fallback.patch
$(APPLY) $(SRC)/pjproject/fix_ioqueue_ipv6_sendto.patch
$(APPLY) $(SRC)/pjproject/add_dtls_transport.patch
$(APPLY) $(SRC)/pjproject/rfc6062.patch
$(APPLY) $(SRC)/pjproject/rfc6544.patch
$(APPLY) $(SRC)/pjproject/ice_config.patch
$(UPDATE_AUTOCONFIG)
$(MOVE)
......
This diff is collapsed.
......@@ -40,7 +40,8 @@ class Controller;
class IceTransport;
using IceTransportCompleteCb = std::function<void(bool)>;
using IceRecvCb = std::function<ssize_t(unsigned char* buf, size_t len)>;
using IceRecvInfo = std::function<void(void)>;
using IceRecvCb = std::function<ssize_t(unsigned char *buf, size_t len)>;
using IceCandidate = pj_ice_sess_cand;
struct StunServerInfo {
......@@ -64,9 +65,12 @@ struct TurnServerInfo {
struct IceTransportOptions {
bool upnpEnable {false};
IceTransportCompleteCb onInitDone {};
IceTransportCompleteCb onNegoDone {};
IceTransportCompleteCb onNegoDone{};
IceRecvInfo onRecvReady{}; // Detect that we have data to read but without destroying the buffer
std::vector<StunServerInfo> stunServers;
std::vector<TurnServerInfo> turnServers;
bool tcpEnable {false}; // If we want to use TCP
bool aggressive {false}; // If we use the aggressive nomination strategy
};
class IceTransport {
......@@ -161,6 +165,7 @@ public:
void setOnRecv(unsigned comp_id, IceRecvCb cb);
ssize_t recv(int comp_id, unsigned char* buf, size_t len);
ssize_t recvfrom(int comp_id, char *buf, size_t len);
ssize_t send(int comp_id, const unsigned char* buf, size_t len);
......@@ -170,9 +175,20 @@ public:
ssize_t waitForData(int comp_id, unsigned int timeout, std::error_code& ec);
/**
* Return without waiting how many bytes are ready to read
* @param comp_id Ice component
* @return the number of bytes ready to read
*/
ssize_t isDataAvailable(int comp_id);
unsigned getComponentCount() const;
private:
// Set session state
bool setSlaveSession();
bool setInitiatorSession();
private:
class Impl;
std::unique_ptr<Impl> pimpl_;
};
......
This diff is collapsed.
......@@ -2,6 +2,7 @@
* Copyright (C) 2017-2019 Savoir-faire Linux Inc.
*
* Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
* Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment