Use backticks not vertical bars to denote variables in comments for /p2p
Bug: webrtc:12338 Change-Id: Ie047b750cdf7ea2efe7a4632d18d5ed719c5ea83 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226952 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34570}
This commit is contained in:
parent
ea24027e83
commit
2dbb4c9775
@ -37,9 +37,9 @@ inline bool IsStunMessage(uint16_t msg_type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AsyncStunTCPSocket
|
// AsyncStunTCPSocket
|
||||||
// Binds and connects |socket| and creates AsyncTCPSocket for
|
// Binds and connects `socket` and creates AsyncTCPSocket for
|
||||||
// it. Takes ownership of |socket|. Returns NULL if bind() or
|
// it. Takes ownership of `socket`. Returns NULL if bind() or
|
||||||
// connect() fail (|socket| is destroyed in that case).
|
// connect() fail (`socket` is destroyed in that case).
|
||||||
AsyncStunTCPSocket* AsyncStunTCPSocket::Create(
|
AsyncStunTCPSocket* AsyncStunTCPSocket::Create(
|
||||||
rtc::AsyncSocket* socket,
|
rtc::AsyncSocket* socket,
|
||||||
const rtc::SocketAddress& bind_address,
|
const rtc::SocketAddress& bind_address,
|
||||||
|
|||||||
@ -23,9 +23,9 @@ namespace cricket {
|
|||||||
|
|
||||||
class AsyncStunTCPSocket : public rtc::AsyncTCPSocketBase {
|
class AsyncStunTCPSocket : public rtc::AsyncTCPSocketBase {
|
||||||
public:
|
public:
|
||||||
// Binds and connects |socket| and creates AsyncTCPSocket for
|
// Binds and connects `socket` and creates AsyncTCPSocket for
|
||||||
// it. Takes ownership of |socket|. Returns NULL if bind() or
|
// it. Takes ownership of `socket`. Returns NULL if bind() or
|
||||||
// connect() fail (|socket| is destroyed in that case).
|
// connect() fail (`socket` is destroyed in that case).
|
||||||
static AsyncStunTCPSocket* Create(rtc::AsyncSocket* socket,
|
static AsyncStunTCPSocket* Create(rtc::AsyncSocket* socket,
|
||||||
const rtc::SocketAddress& bind_address,
|
const rtc::SocketAddress& bind_address,
|
||||||
const rtc::SocketAddress& remote_address);
|
const rtc::SocketAddress& remote_address);
|
||||||
@ -41,7 +41,7 @@ class AsyncStunTCPSocket : public rtc::AsyncTCPSocketBase {
|
|||||||
private:
|
private:
|
||||||
// This method returns the message hdr + length written in the header.
|
// This method returns the message hdr + length written in the header.
|
||||||
// This method also returns the number of padding bytes needed/added to the
|
// This method also returns the number of padding bytes needed/added to the
|
||||||
// turn message. |pad_bytes| should be used only when |is_turn| is true.
|
// turn message. `pad_bytes` should be used only when `is_turn` is true.
|
||||||
size_t GetExpectedLength(const void* data, size_t len, int* pad_bytes);
|
size_t GetExpectedLength(const void* data, size_t len, int* pad_bytes);
|
||||||
|
|
||||||
RTC_DISALLOW_COPY_AND_ASSIGN(AsyncStunTCPSocket);
|
RTC_DISALLOW_COPY_AND_ASSIGN(AsyncStunTCPSocket);
|
||||||
|
|||||||
@ -339,7 +339,7 @@ const Connection* BasicIceController::MorePingable(const Connection* conn1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// During the initial state when nothing has been pinged yet, return the first
|
// During the initial state when nothing has been pinged yet, return the first
|
||||||
// one in the ordered |connections_|.
|
// one in the ordered `connections_`.
|
||||||
auto connections = connections_;
|
auto connections = connections_;
|
||||||
return *(std::find_if(connections.begin(), connections.end(),
|
return *(std::find_if(connections.begin(), connections.end(),
|
||||||
[conn1, conn2](const Connection* conn) {
|
[conn1, conn2](const Connection* conn) {
|
||||||
@ -382,7 +382,7 @@ const Connection* BasicIceController::LeastRecentlyPinged(
|
|||||||
|
|
||||||
std::map<const rtc::Network*, const Connection*>
|
std::map<const rtc::Network*, const Connection*>
|
||||||
BasicIceController::GetBestConnectionByNetwork() const {
|
BasicIceController::GetBestConnectionByNetwork() const {
|
||||||
// |connections_| has been sorted, so the first one in the list on a given
|
// `connections_` has been sorted, so the first one in the list on a given
|
||||||
// network is the best connection on the network, except that the selected
|
// network is the best connection on the network, except that the selected
|
||||||
// connection is always the best connection on the network.
|
// connection is always the best connection on the network.
|
||||||
std::map<const rtc::Network*, const Connection*> best_connection_by_network;
|
std::map<const rtc::Network*, const Connection*> best_connection_by_network;
|
||||||
@ -390,7 +390,7 @@ BasicIceController::GetBestConnectionByNetwork() const {
|
|||||||
best_connection_by_network[selected_connection_->network()] =
|
best_connection_by_network[selected_connection_->network()] =
|
||||||
selected_connection_;
|
selected_connection_;
|
||||||
}
|
}
|
||||||
// TODO(honghaiz): Need to update this if |connections_| are not sorted.
|
// TODO(honghaiz): Need to update this if `connections_` are not sorted.
|
||||||
for (const Connection* conn : connections_) {
|
for (const Connection* conn : connections_) {
|
||||||
const rtc::Network* network = conn->network();
|
const rtc::Network* network = conn->network();
|
||||||
// This only inserts when the network does not exist in the map.
|
// This only inserts when the network does not exist in the map.
|
||||||
@ -645,7 +645,7 @@ int BasicIceController::CompareConnectionStates(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compares two connections based only on the candidate and network information.
|
// Compares two connections based only on the candidate and network information.
|
||||||
// Returns positive if |a| is better than |b|.
|
// Returns positive if `a` is better than `b`.
|
||||||
int BasicIceController::CompareConnectionCandidates(const Connection* a,
|
int BasicIceController::CompareConnectionCandidates(const Connection* a,
|
||||||
const Connection* b) const {
|
const Connection* b) const {
|
||||||
int compare_a_b_by_networks =
|
int compare_a_b_by_networks =
|
||||||
@ -758,7 +758,7 @@ std::vector<const Connection*> BasicIceController::PruneConnections() {
|
|||||||
// which point, we would prune out the current selected connection). We leave
|
// which point, we would prune out the current selected connection). We leave
|
||||||
// connections on other networks because they may not be using the same
|
// connections on other networks because they may not be using the same
|
||||||
// resources and they may represent very distinct paths over which we can
|
// resources and they may represent very distinct paths over which we can
|
||||||
// switch. If |best_conn_on_network| is not connected, we may be reconnecting
|
// switch. If `best_conn_on_network` is not connected, we may be reconnecting
|
||||||
// a TCP connection and should not prune connections in this network.
|
// a TCP connection and should not prune connections in this network.
|
||||||
// See the big comment in CompareConnectionStates.
|
// See the big comment in CompareConnectionStates.
|
||||||
//
|
//
|
||||||
@ -804,13 +804,13 @@ bool BasicIceController::GetUseCandidateAttr(const Connection* conn,
|
|||||||
case NominationMode::SEMI_AGGRESSIVE: {
|
case NominationMode::SEMI_AGGRESSIVE: {
|
||||||
// Nominate if
|
// Nominate if
|
||||||
// a) Remote is in FULL ICE AND
|
// a) Remote is in FULL ICE AND
|
||||||
// a.1) |conn| is the selected connection OR
|
// a.1) `conn` is the selected connection OR
|
||||||
// a.2) there is no selected connection OR
|
// a.2) there is no selected connection OR
|
||||||
// a.3) the selected connection is unwritable OR
|
// a.3) the selected connection is unwritable OR
|
||||||
// a.4) |conn| has higher priority than selected_connection.
|
// a.4) `conn` has higher priority than selected_connection.
|
||||||
// b) Remote is in LITE ICE AND
|
// b) Remote is in LITE ICE AND
|
||||||
// b.1) |conn| is the selected_connection AND
|
// b.1) `conn` is the selected_connection AND
|
||||||
// b.2) |conn| is writable.
|
// b.2) `conn` is writable.
|
||||||
bool selected = conn == selected_connection_;
|
bool selected = conn == selected_connection_;
|
||||||
if (remote_ice_mode == ICEMODE_LITE) {
|
if (remote_ice_mode == ICEMODE_LITE) {
|
||||||
return selected && conn->writable();
|
return selected && conn->writable();
|
||||||
|
|||||||
@ -79,7 +79,7 @@ class BasicIceController : public IceControllerInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now);
|
const Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now);
|
||||||
// Between |conn1| and |conn2|, this function returns the one which should
|
// Between `conn1` and `conn2`, this function returns the one which should
|
||||||
// be pinged first.
|
// be pinged first.
|
||||||
const Connection* MorePingable(const Connection* conn1,
|
const Connection* MorePingable(const Connection* conn1,
|
||||||
const Connection* conn2);
|
const Connection* conn2);
|
||||||
@ -112,13 +112,13 @@ class BasicIceController : public IceControllerInterface {
|
|||||||
const Connection* b,
|
const Connection* b,
|
||||||
absl::optional<rtc::AdapterType> network_preference) const;
|
absl::optional<rtc::AdapterType> network_preference) const;
|
||||||
|
|
||||||
// The methods below return a positive value if |a| is preferable to |b|,
|
// The methods below return a positive value if `a` is preferable to `b`,
|
||||||
// a negative value if |b| is preferable, and 0 if they're equally preferable.
|
// a negative value if `b` is preferable, and 0 if they're equally preferable.
|
||||||
// If |receiving_unchanged_threshold| is set, then when |b| is receiving and
|
// If `receiving_unchanged_threshold` is set, then when `b` is receiving and
|
||||||
// |a| is not, returns a negative value only if |b| has been in receiving
|
// `a` is not, returns a negative value only if `b` has been in receiving
|
||||||
// state and |a| has been in not receiving state since
|
// state and `a` has been in not receiving state since
|
||||||
// |receiving_unchanged_threshold| and sets
|
// `receiving_unchanged_threshold` and sets
|
||||||
// |missed_receiving_unchanged_threshold| to true otherwise.
|
// `missed_receiving_unchanged_threshold` to true otherwise.
|
||||||
int CompareConnectionStates(
|
int CompareConnectionStates(
|
||||||
const Connection* a,
|
const Connection* a,
|
||||||
const Connection* b,
|
const Connection* b,
|
||||||
@ -130,7 +130,7 @@ class BasicIceController : public IceControllerInterface {
|
|||||||
// (writable/receiving/connected), nomination states, last data received time,
|
// (writable/receiving/connected), nomination states, last data received time,
|
||||||
// and static preferences. Does not include latency. Used by both sorting
|
// and static preferences. Does not include latency. Used by both sorting
|
||||||
// and ShouldSwitchSelectedConnection().
|
// and ShouldSwitchSelectedConnection().
|
||||||
// Returns a positive value if |a| is better than |b|.
|
// Returns a positive value if `a` is better than `b`.
|
||||||
int CompareConnections(const Connection* a,
|
int CompareConnections(const Connection* a,
|
||||||
const Connection* b,
|
const Connection* b,
|
||||||
absl::optional<int64_t> receiving_unchanged_threshold,
|
absl::optional<int64_t> receiving_unchanged_threshold,
|
||||||
@ -146,10 +146,10 @@ class BasicIceController : public IceControllerInterface {
|
|||||||
IceConfig config_;
|
IceConfig config_;
|
||||||
const IceFieldTrials* field_trials_;
|
const IceFieldTrials* field_trials_;
|
||||||
|
|
||||||
// |connections_| is a sorted list with the first one always be the
|
// `connections_` is a sorted list with the first one always be the
|
||||||
// |selected_connection_| when it's not nullptr. The combination of
|
// `selected_connection_` when it's not nullptr. The combination of
|
||||||
// |pinged_connections_| and |unpinged_connections_| has the same
|
// `pinged_connections_` and `unpinged_connections_` has the same
|
||||||
// connections as |connections_|. These 2 sets maintain whether a
|
// connections as `connections_`. These 2 sets maintain whether a
|
||||||
// connection should be pinged next or not.
|
// connection should be pinged next or not.
|
||||||
const Connection* selected_connection_ = nullptr;
|
const Connection* selected_connection_ = nullptr;
|
||||||
std::vector<const Connection*> connections_;
|
std::vector<const Connection*> connections_;
|
||||||
|
|||||||
@ -513,7 +513,7 @@ void Connection::OnReadPacket(const char* data,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// Remote end point sent an STUN indication instead of regular binding
|
// Remote end point sent an STUN indication instead of regular binding
|
||||||
// request. In this case |last_ping_received_| will be updated but no
|
// request. In this case `last_ping_received_` will be updated but no
|
||||||
// response will be sent.
|
// response will be sent.
|
||||||
case STUN_BINDING_INDICATION:
|
case STUN_BINDING_INDICATION:
|
||||||
ReceivedPing(msg->transaction_id());
|
ReceivedPing(msg->transaction_id());
|
||||||
@ -928,7 +928,7 @@ bool Connection::dead(int64_t now) const {
|
|||||||
// working. This also allows a remote peer to continue pinging over a
|
// working. This also allows a remote peer to continue pinging over a
|
||||||
// locally inactive (pruned) connection. This also allows the local agent to
|
// locally inactive (pruned) connection. This also allows the local agent to
|
||||||
// ping with longer interval than 30s as long as it shorter than
|
// ping with longer interval than 30s as long as it shorter than
|
||||||
// |dead_connection_timeout_ms|.
|
// `dead_connection_timeout_ms`.
|
||||||
if (now <= (last_received() + DEAD_CONNECTION_RECEIVE_TIMEOUT)) {
|
if (now <= (last_received() + DEAD_CONNECTION_RECEIVE_TIMEOUT)) {
|
||||||
// Not dead since we have received the last 30s.
|
// Not dead since we have received the last 30s.
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -138,7 +138,7 @@ class Connection : public CandidatePairInterface,
|
|||||||
inactive_timeout_ = value;
|
inactive_timeout_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the |ConnectionInfo| stats, where |best_connection| has not been
|
// Gets the `ConnectionInfo` stats, where `best_connection` has not been
|
||||||
// populated (default value false).
|
// populated (default value false).
|
||||||
ConnectionInfo stats();
|
ConnectionInfo stats();
|
||||||
|
|
||||||
@ -183,10 +183,10 @@ class Connection : public CandidatePairInterface,
|
|||||||
uint32_t remote_nomination() const { return remote_nomination_; }
|
uint32_t remote_nomination() const { return remote_nomination_; }
|
||||||
// One or several pairs may be nominated based on if Regular or Aggressive
|
// One or several pairs may be nominated based on if Regular or Aggressive
|
||||||
// Nomination is used. https://tools.ietf.org/html/rfc5245#section-8
|
// Nomination is used. https://tools.ietf.org/html/rfc5245#section-8
|
||||||
// |nominated| is defined both for the controlling or controlled agent based
|
// `nominated` is defined both for the controlling or controlled agent based
|
||||||
// on if a nomination has been pinged or acknowledged. The controlled agent
|
// on if a nomination has been pinged or acknowledged. The controlled agent
|
||||||
// gets its |remote_nomination_| set when pinged by the controlling agent with
|
// gets its `remote_nomination_` set when pinged by the controlling agent with
|
||||||
// a nomination value. The controlling agent gets its |acked_nomination_| set
|
// a nomination value. The controlling agent gets its `acked_nomination_` set
|
||||||
// when receiving a response to a nominating ping.
|
// when receiving a response to a nominating ping.
|
||||||
bool nominated() const { return acked_nomination_ || remote_nomination_; }
|
bool nominated() const { return acked_nomination_ || remote_nomination_; }
|
||||||
void set_remote_ice_mode(IceMode mode) { remote_ice_mode_ = mode; }
|
void set_remote_ice_mode(IceMode mode) { remote_ice_mode_ = mode; }
|
||||||
@ -277,14 +277,14 @@ class Connection : public CandidatePairInterface,
|
|||||||
uint32_t ComputeNetworkCost() const;
|
uint32_t ComputeNetworkCost() const;
|
||||||
|
|
||||||
// Update the ICE password and/or generation of the remote candidate if the
|
// Update the ICE password and/or generation of the remote candidate if the
|
||||||
// ufrag in |params| matches the candidate's ufrag, and the
|
// ufrag in `params` matches the candidate's ufrag, and the
|
||||||
// candidate's password and/or ufrag has not been set.
|
// candidate's password and/or ufrag has not been set.
|
||||||
void MaybeSetRemoteIceParametersAndGeneration(const IceParameters& params,
|
void MaybeSetRemoteIceParametersAndGeneration(const IceParameters& params,
|
||||||
int generation);
|
int generation);
|
||||||
|
|
||||||
// If |remote_candidate_| is peer reflexive and is equivalent to
|
// If `remote_candidate_` is peer reflexive and is equivalent to
|
||||||
// |new_candidate| except the type, update |remote_candidate_| to
|
// `new_candidate` except the type, update `remote_candidate_` to
|
||||||
// |new_candidate|.
|
// `new_candidate`.
|
||||||
void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate);
|
void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate);
|
||||||
|
|
||||||
// Returns the last received time of any data, stun request, or stun
|
// Returns the last received time of any data, stun request, or stun
|
||||||
@ -297,7 +297,7 @@ class Connection : public CandidatePairInterface,
|
|||||||
|
|
||||||
bool stable(int64_t now) const;
|
bool stable(int64_t now) const;
|
||||||
|
|
||||||
// Check if we sent |val| pings without receving a response.
|
// Check if we sent `val` pings without receving a response.
|
||||||
bool TooManyOutstandingPings(const absl::optional<int>& val) const;
|
bool TooManyOutstandingPings(const absl::optional<int>& val) const;
|
||||||
|
|
||||||
void SetIceFieldTrials(const IceFieldTrials* field_trials);
|
void SetIceFieldTrials(const IceFieldTrials* field_trials);
|
||||||
@ -401,7 +401,7 @@ class Connection : public CandidatePairInterface,
|
|||||||
bool connected_;
|
bool connected_;
|
||||||
bool pruned_;
|
bool pruned_;
|
||||||
bool selected_ = false;
|
bool selected_ = false;
|
||||||
// By default |use_candidate_attr_| flag will be true,
|
// By default `use_candidate_attr_` flag will be true,
|
||||||
// as we will be using aggressive nomination.
|
// as we will be using aggressive nomination.
|
||||||
// But when peer is ice-lite, this flag "must" be initialized to false and
|
// But when peer is ice-lite, this flag "must" be initialized to false and
|
||||||
// turn on when connection becomes "best connection".
|
// turn on when connection becomes "best connection".
|
||||||
|
|||||||
@ -241,7 +241,7 @@ bool DtlsTransport::SetRemoteFingerprint(const std::string& digest_alg,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the other side doesn't support DTLS, turn off |dtls_active_|.
|
// If the other side doesn't support DTLS, turn off `dtls_active_`.
|
||||||
// TODO(deadbeef): Remove this. It's dangerous, because it relies on higher
|
// TODO(deadbeef): Remove this. It's dangerous, because it relies on higher
|
||||||
// level code to ensure DTLS is actually used, but there are tests that
|
// level code to ensure DTLS is actually used, but there are tests that
|
||||||
// depend on it, for the case where an m= section is rejected. In that case
|
// depend on it, for the case where an m= section is rejected. In that case
|
||||||
|
|||||||
@ -94,13 +94,13 @@ class StreamInterfaceChannel : public rtc::StreamInterface {
|
|||||||
// as the constructor.
|
// as the constructor.
|
||||||
class DtlsTransport : public DtlsTransportInternal {
|
class DtlsTransport : public DtlsTransportInternal {
|
||||||
public:
|
public:
|
||||||
// |ice_transport| is the ICE transport this DTLS transport is wrapping. It
|
// `ice_transport` is the ICE transport this DTLS transport is wrapping. It
|
||||||
// must outlive this DTLS transport.
|
// must outlive this DTLS transport.
|
||||||
//
|
//
|
||||||
// |crypto_options| are the options used for the DTLS handshake. This affects
|
// `crypto_options` are the options used for the DTLS handshake. This affects
|
||||||
// whether GCM crypto suites are negotiated.
|
// whether GCM crypto suites are negotiated.
|
||||||
//
|
//
|
||||||
// |event_log| is an optional RtcEventLog for logging state changes. It should
|
// `event_log` is an optional RtcEventLog for logging state changes. It should
|
||||||
// outlive the DtlsTransport.
|
// outlive the DtlsTransport.
|
||||||
DtlsTransport(
|
DtlsTransport(
|
||||||
IceTransportInternal* ice_transport,
|
IceTransportInternal* ice_transport,
|
||||||
|
|||||||
@ -44,7 +44,7 @@ static bool IsRtpLeadByte(uint8_t b) {
|
|||||||
return ((b & 0xC0) == 0x80);
|
return ((b & 0xC0) == 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
// |modify_digest| is used to set modified fingerprints that are meant to fail
|
// `modify_digest` is used to set modified fingerprints that are meant to fail
|
||||||
// validation.
|
// validation.
|
||||||
void SetRemoteFingerprintFromCert(
|
void SetRemoteFingerprintFromCert(
|
||||||
DtlsTransport* transport,
|
DtlsTransport* transport,
|
||||||
@ -298,7 +298,7 @@ class DtlsTestClient : public sigslot::has_slots<> {
|
|||||||
// Base class for DtlsTransportTest and DtlsEventOrderingTest, which
|
// Base class for DtlsTransportTest and DtlsEventOrderingTest, which
|
||||||
// inherit from different variants of ::testing::Test.
|
// inherit from different variants of ::testing::Test.
|
||||||
//
|
//
|
||||||
// Note that this test always uses a FakeClock, due to the |fake_clock_| member
|
// Note that this test always uses a FakeClock, due to the `fake_clock_` member
|
||||||
// variable.
|
// variable.
|
||||||
class DtlsTransportTestBase {
|
class DtlsTransportTestBase {
|
||||||
public:
|
public:
|
||||||
@ -618,7 +618,7 @@ class DtlsEventOrderingTest
|
|||||||
public ::testing::TestWithParam<
|
public ::testing::TestWithParam<
|
||||||
::testing::tuple<std::vector<DtlsTransportEvent>, bool>> {
|
::testing::tuple<std::vector<DtlsTransportEvent>, bool>> {
|
||||||
protected:
|
protected:
|
||||||
// If |valid_fingerprint| is false, the caller will receive a fingerprint
|
// If `valid_fingerprint` is false, the caller will receive a fingerprint
|
||||||
// that doesn't match the callee's certificate, so the handshake should fail.
|
// that doesn't match the callee's certificate, so the handshake should fail.
|
||||||
void TestEventOrdering(const std::vector<DtlsTransportEvent>& events,
|
void TestEventOrdering(const std::vector<DtlsTransportEvent>& events,
|
||||||
bool valid_fingerprint) {
|
bool valid_fingerprint) {
|
||||||
|
|||||||
@ -96,8 +96,8 @@ class FakeDtlsTransport : public DtlsTransportInternal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Simulates the two DTLS transports connecting to each other.
|
// Simulates the two DTLS transports connecting to each other.
|
||||||
// If |asymmetric| is true this method only affects this FakeDtlsTransport.
|
// If `asymmetric` is true this method only affects this FakeDtlsTransport.
|
||||||
// If false, it affects |dest| as well.
|
// If false, it affects `dest` as well.
|
||||||
void SetDestination(FakeDtlsTransport* dest, bool asymmetric = false) {
|
void SetDestination(FakeDtlsTransport* dest, bool asymmetric = false) {
|
||||||
if (dest == dest_) {
|
if (dest == dest_) {
|
||||||
return;
|
return;
|
||||||
@ -118,7 +118,7 @@ class FakeDtlsTransport : public DtlsTransportInternal {
|
|||||||
if (!asymmetric) {
|
if (!asymmetric) {
|
||||||
dest->SetDestination(this, true);
|
dest->SetDestination(this, true);
|
||||||
}
|
}
|
||||||
// If the |dtls_role_| is unset, set it to SSL_CLIENT by default.
|
// If the `dtls_role_` is unset, set it to SSL_CLIENT by default.
|
||||||
if (!dtls_role_) {
|
if (!dtls_role_) {
|
||||||
dtls_role_ = std::move(rtc::SSL_CLIENT);
|
dtls_role_ = std::move(rtc::SSL_CLIENT);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,8 +69,8 @@ class FakeIceTransport : public IceTransportInternal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Simulates the two transports connecting to each other.
|
// Simulates the two transports connecting to each other.
|
||||||
// If |asymmetric| is true this method only affects this FakeIceTransport.
|
// If `asymmetric` is true this method only affects this FakeIceTransport.
|
||||||
// If false, it affects |dest| as well.
|
// If false, it affects `dest` as well.
|
||||||
void SetDestination(FakeIceTransport* dest, bool asymmetric = false) {
|
void SetDestination(FakeIceTransport* dest, bool asymmetric = false) {
|
||||||
RTC_DCHECK_RUN_ON(network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
if (dest == dest_) {
|
if (dest == dest_) {
|
||||||
@ -107,7 +107,7 @@ class FakeIceTransport : public IceTransportInternal {
|
|||||||
if (connection_count) {
|
if (connection_count) {
|
||||||
had_connection_ = true;
|
had_connection_ = true;
|
||||||
}
|
}
|
||||||
// In this fake transport channel, |connection_count_| determines the
|
// In this fake transport channel, `connection_count_` determines the
|
||||||
// transport state.
|
// transport state.
|
||||||
if (connection_count_ < old_connection_count) {
|
if (connection_count_ < old_connection_count) {
|
||||||
SignalStateChanged(this);
|
SignalStateChanged(this);
|
||||||
|
|||||||
@ -36,8 +36,8 @@ class FakePacketTransport : public PacketTransportInternal {
|
|||||||
void SetReceiving(bool receiving) { set_receiving(receiving); }
|
void SetReceiving(bool receiving) { set_receiving(receiving); }
|
||||||
|
|
||||||
// Simulates the two transports connecting to each other.
|
// Simulates the two transports connecting to each other.
|
||||||
// If |asymmetric| is true this method only affects this FakePacketTransport.
|
// If `asymmetric` is true this method only affects this FakePacketTransport.
|
||||||
// If false, it affects |dest| as well.
|
// If false, it affects `dest` as well.
|
||||||
void SetDestination(FakePacketTransport* dest, bool asymmetric) {
|
void SetDestination(FakePacketTransport* dest, bool asymmetric) {
|
||||||
if (dest) {
|
if (dest) {
|
||||||
dest_ = dest;
|
dest_ = dest;
|
||||||
|
|||||||
@ -55,7 +55,7 @@ struct IceControllerEvent {
|
|||||||
//
|
//
|
||||||
// The P2PTransportChannel owns (creates and destroys) Connections,
|
// The P2PTransportChannel owns (creates and destroys) Connections,
|
||||||
// but P2PTransportChannel gives const pointers to the the IceController using
|
// but P2PTransportChannel gives const pointers to the the IceController using
|
||||||
// |AddConnection|, i.e the IceController should not call any non-const methods
|
// `AddConnection`, i.e the IceController should not call any non-const methods
|
||||||
// on a Connection but signal back in the interface if any mutable function
|
// on a Connection but signal back in the interface if any mutable function
|
||||||
// shall be called.
|
// shall be called.
|
||||||
//
|
//
|
||||||
@ -123,7 +123,7 @@ class IceControllerInterface {
|
|||||||
// Select a connection to Ping, or nullptr if none.
|
// Select a connection to Ping, or nullptr if none.
|
||||||
virtual PingResult SelectConnectionToPing(int64_t last_ping_sent_ms) = 0;
|
virtual PingResult SelectConnectionToPing(int64_t last_ping_sent_ms) = 0;
|
||||||
|
|
||||||
// Compute the "STUN_ATTR_USE_CANDIDATE" for |conn|.
|
// Compute the "STUN_ATTR_USE_CANDIDATE" for `conn`.
|
||||||
virtual bool GetUseCandidateAttr(const Connection* conn,
|
virtual bool GetUseCandidateAttr(const Connection* conn,
|
||||||
NominationMode mode,
|
NominationMode mode,
|
||||||
IceMode remote_ice_mode) const = 0;
|
IceMode remote_ice_mode) const = 0;
|
||||||
@ -133,7 +133,7 @@ class IceControllerInterface {
|
|||||||
virtual const Connection* FindNextPingableConnection() = 0;
|
virtual const Connection* FindNextPingableConnection() = 0;
|
||||||
virtual void MarkConnectionPinged(const Connection* con) = 0;
|
virtual void MarkConnectionPinged(const Connection* con) = 0;
|
||||||
|
|
||||||
// Check if we should switch to |connection|.
|
// Check if we should switch to `connection`.
|
||||||
// This method is called for IceControllerEvent's that can switch directly
|
// This method is called for IceControllerEvent's that can switch directly
|
||||||
// i.e without resorting.
|
// i.e without resorting.
|
||||||
virtual SwitchResult ShouldSwitchConnection(IceControllerEvent reason,
|
virtual SwitchResult ShouldSwitchConnection(IceControllerEvent reason,
|
||||||
|
|||||||
@ -136,12 +136,12 @@ struct IceConfig {
|
|||||||
// The interval in milliseconds at which ICE checks (STUN pings) will be sent
|
// The interval in milliseconds at which ICE checks (STUN pings) will be sent
|
||||||
// for a candidate pair when it is both writable and receiving (strong
|
// for a candidate pair when it is both writable and receiving (strong
|
||||||
// connectivity). This parameter overrides the default value given by
|
// connectivity). This parameter overrides the default value given by
|
||||||
// |STRONG_PING_INTERVAL| in p2ptransport.h if set.
|
// `STRONG_PING_INTERVAL` in p2ptransport.h if set.
|
||||||
absl::optional<int> ice_check_interval_strong_connectivity;
|
absl::optional<int> ice_check_interval_strong_connectivity;
|
||||||
// The interval in milliseconds at which ICE checks (STUN pings) will be sent
|
// The interval in milliseconds at which ICE checks (STUN pings) will be sent
|
||||||
// for a candidate pair when it is either not writable or not receiving (weak
|
// for a candidate pair when it is either not writable or not receiving (weak
|
||||||
// connectivity). This parameter overrides the default value given by
|
// connectivity). This parameter overrides the default value given by
|
||||||
// |WEAK_PING_INTERVAL| in p2ptransport.h if set.
|
// `WEAK_PING_INTERVAL` in p2ptransport.h if set.
|
||||||
absl::optional<int> ice_check_interval_weak_connectivity;
|
absl::optional<int> ice_check_interval_weak_connectivity;
|
||||||
// ICE checks (STUN pings) will not be sent at higher rate (lower interval)
|
// ICE checks (STUN pings) will not be sent at higher rate (lower interval)
|
||||||
// than this, no matter what other settings there are.
|
// than this, no matter what other settings there are.
|
||||||
@ -153,19 +153,19 @@ struct IceConfig {
|
|||||||
absl::optional<int> ice_check_min_interval;
|
absl::optional<int> ice_check_min_interval;
|
||||||
// The min time period for which a candidate pair must wait for response to
|
// The min time period for which a candidate pair must wait for response to
|
||||||
// connectivity checks before it becomes unwritable. This parameter
|
// connectivity checks before it becomes unwritable. This parameter
|
||||||
// overrides the default value given by |CONNECTION_WRITE_CONNECT_TIMEOUT|
|
// overrides the default value given by `CONNECTION_WRITE_CONNECT_TIMEOUT`
|
||||||
// in port.h if set, when determining the writability of a candidate pair.
|
// in port.h if set, when determining the writability of a candidate pair.
|
||||||
absl::optional<int> ice_unwritable_timeout;
|
absl::optional<int> ice_unwritable_timeout;
|
||||||
|
|
||||||
// The min number of connectivity checks that a candidate pair must sent
|
// The min number of connectivity checks that a candidate pair must sent
|
||||||
// without receiving response before it becomes unwritable. This parameter
|
// without receiving response before it becomes unwritable. This parameter
|
||||||
// overrides the default value given by |CONNECTION_WRITE_CONNECT_FAILURES| in
|
// overrides the default value given by `CONNECTION_WRITE_CONNECT_FAILURES` in
|
||||||
// port.h if set, when determining the writability of a candidate pair.
|
// port.h if set, when determining the writability of a candidate pair.
|
||||||
absl::optional<int> ice_unwritable_min_checks;
|
absl::optional<int> ice_unwritable_min_checks;
|
||||||
|
|
||||||
// The min time period for which a candidate pair must wait for response to
|
// The min time period for which a candidate pair must wait for response to
|
||||||
// connectivity checks it becomes inactive. This parameter overrides the
|
// connectivity checks it becomes inactive. This parameter overrides the
|
||||||
// default value given by |CONNECTION_WRITE_TIMEOUT| in port.h if set, when
|
// default value given by `CONNECTION_WRITE_TIMEOUT` in port.h if set, when
|
||||||
// determining the writability of a candidate pair.
|
// determining the writability of a candidate pair.
|
||||||
absl::optional<int> ice_inactive_timeout;
|
absl::optional<int> ice_inactive_timeout;
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ class RTC_EXPORT IceTransportInternal : public rtc::PacketTransportInternal {
|
|||||||
virtual void SetRemoteIceCredentials(const std::string& ice_ufrag,
|
virtual void SetRemoteIceCredentials(const std::string& ice_ufrag,
|
||||||
const std::string& ice_pwd);
|
const std::string& ice_pwd);
|
||||||
|
|
||||||
// The ufrag and pwd in |ice_params| must be set
|
// The ufrag and pwd in `ice_params` must be set
|
||||||
// before candidate gathering can start.
|
// before candidate gathering can start.
|
||||||
virtual void SetIceParameters(const IceParameters& ice_params) = 0;
|
virtual void SetIceParameters(const IceParameters& ice_params) = 0;
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ class MockIceTransport : public IceTransportInternal {
|
|||||||
int component() const override { return 0; }
|
int component() const override { return 0; }
|
||||||
void SetIceRole(IceRole role) override {}
|
void SetIceRole(IceRole role) override {}
|
||||||
void SetIceTiebreaker(uint64_t tiebreaker) override {}
|
void SetIceTiebreaker(uint64_t tiebreaker) override {}
|
||||||
// The ufrag and pwd in |ice_params| must be set
|
// The ufrag and pwd in `ice_params` must be set
|
||||||
// before candidate gathering can start.
|
// before candidate gathering can start.
|
||||||
void SetIceParameters(const IceParameters& ice_params) override {}
|
void SetIceParameters(const IceParameters& ice_params) override {}
|
||||||
void SetRemoteIceParameters(const IceParameters& ice_params) override {}
|
void SetRemoteIceParameters(const IceParameters& ice_params) override {}
|
||||||
|
|||||||
@ -1739,7 +1739,7 @@ void P2PTransportChannel::SortConnectionsAndUpdateState(
|
|||||||
// Any changes after this point will require a re-sort.
|
// Any changes after this point will require a re-sort.
|
||||||
sort_dirty_ = false;
|
sort_dirty_ = false;
|
||||||
|
|
||||||
// If necessary, switch to the new choice. Note that |top_connection| doesn't
|
// If necessary, switch to the new choice. Note that `top_connection` doesn't
|
||||||
// have to be writable to become the selected connection although it will
|
// have to be writable to become the selected connection although it will
|
||||||
// have higher priority if it is writable.
|
// have higher priority if it is writable.
|
||||||
MaybeSwitchSelectedConnection(
|
MaybeSwitchSelectedConnection(
|
||||||
@ -1795,7 +1795,7 @@ void P2PTransportChannel::PruneConnections() {
|
|||||||
void P2PTransportChannel::SwitchSelectedConnection(Connection* conn,
|
void P2PTransportChannel::SwitchSelectedConnection(Connection* conn,
|
||||||
IceControllerEvent reason) {
|
IceControllerEvent reason) {
|
||||||
RTC_DCHECK_RUN_ON(network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
// Note: if conn is NULL, the previous |selected_connection_| has been
|
// Note: if conn is NULL, the previous `selected_connection_` has been
|
||||||
// destroyed, so don't use it.
|
// destroyed, so don't use it.
|
||||||
Connection* old_selected_connection = selected_connection_;
|
Connection* old_selected_connection = selected_connection_;
|
||||||
selected_connection_ = conn;
|
selected_connection_ = conn;
|
||||||
@ -2040,9 +2040,9 @@ void P2PTransportChannel::MarkConnectionPinged(Connection* conn) {
|
|||||||
ice_controller_->MarkConnectionPinged(conn);
|
ice_controller_->MarkConnectionPinged(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apart from sending ping from |conn| this method also updates
|
// Apart from sending ping from `conn` this method also updates
|
||||||
// |use_candidate_attr| and |nomination| flags. One of the flags is set to
|
// `use_candidate_attr` and `nomination` flags. One of the flags is set to
|
||||||
// nominate |conn| if this channel is in CONTROLLING.
|
// nominate `conn` if this channel is in CONTROLLING.
|
||||||
void P2PTransportChannel::PingConnection(Connection* conn) {
|
void P2PTransportChannel::PingConnection(Connection* conn) {
|
||||||
RTC_DCHECK_RUN_ON(network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
bool use_candidate_attr = false;
|
bool use_candidate_attr = false;
|
||||||
|
|||||||
@ -148,9 +148,9 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal {
|
|||||||
void RemoveRemoteCandidate(const Candidate& candidate) override;
|
void RemoveRemoteCandidate(const Candidate& candidate) override;
|
||||||
void RemoveAllRemoteCandidates() override;
|
void RemoveAllRemoteCandidates() override;
|
||||||
// Sets the parameters in IceConfig. We do not set them blindly. Instead, we
|
// Sets the parameters in IceConfig. We do not set them blindly. Instead, we
|
||||||
// only update the parameter if it is considered set in |config|. For example,
|
// only update the parameter if it is considered set in `config`. For example,
|
||||||
// a negative value of receiving_timeout will be considered "not set" and we
|
// a negative value of receiving_timeout will be considered "not set" and we
|
||||||
// will not use it to update the respective parameter in |config_|.
|
// will not use it to update the respective parameter in `config_`.
|
||||||
// TODO(deadbeef): Use absl::optional instead of negative values.
|
// TODO(deadbeef): Use absl::optional instead of negative values.
|
||||||
void SetIceConfig(const IceConfig& config) override;
|
void SetIceConfig(const IceConfig& config) override;
|
||||||
const IceConfig& config() const;
|
const IceConfig& config() const;
|
||||||
@ -182,7 +182,7 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note: These are only for testing purpose.
|
// Note: These are only for testing purpose.
|
||||||
// |ports_| and |pruned_ports| should not be changed from outside.
|
// `ports_` and `pruned_ports` should not be changed from outside.
|
||||||
const std::vector<PortInterface*>& ports() {
|
const std::vector<PortInterface*>& ports() {
|
||||||
RTC_DCHECK_RUN_ON(network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
return ports_;
|
return ports_;
|
||||||
@ -254,7 +254,7 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal {
|
|||||||
return allocator_session()->IsGettingPorts();
|
return allocator_session()->IsGettingPorts();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if it's possible to send packets on |connection|.
|
// Returns true if it's possible to send packets on `connection`.
|
||||||
bool ReadyToSend(Connection* connection) const;
|
bool ReadyToSend(Connection* connection) const;
|
||||||
bool PresumedWritable(const Connection* conn) const;
|
bool PresumedWritable(const Connection* conn) const;
|
||||||
void UpdateConnectionStates();
|
void UpdateConnectionStates();
|
||||||
@ -311,11 +311,11 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal {
|
|||||||
bool port_muxed);
|
bool port_muxed);
|
||||||
void OnCandidateFilterChanged(uint32_t prev_filter, uint32_t cur_filter);
|
void OnCandidateFilterChanged(uint32_t prev_filter, uint32_t cur_filter);
|
||||||
|
|
||||||
// When a port is destroyed, remove it from both lists |ports_|
|
// When a port is destroyed, remove it from both lists `ports_`
|
||||||
// and |pruned_ports_|.
|
// and `pruned_ports_`.
|
||||||
void OnPortDestroyed(PortInterface* port);
|
void OnPortDestroyed(PortInterface* port);
|
||||||
// When pruning a port, move it from |ports_| to |pruned_ports_|.
|
// When pruning a port, move it from `ports_` to `pruned_ports_`.
|
||||||
// Returns true if the port is found and removed from |ports_|.
|
// Returns true if the port is found and removed from `ports_`.
|
||||||
bool PrunePort(PortInterface* port);
|
bool PrunePort(PortInterface* port);
|
||||||
void OnRoleConflict(PortInterface* port);
|
void OnRoleConflict(PortInterface* port);
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal {
|
|||||||
return remote_ice_parameters_.empty() ? nullptr
|
return remote_ice_parameters_.empty() ? nullptr
|
||||||
: &remote_ice_parameters_.back();
|
: &remote_ice_parameters_.back();
|
||||||
}
|
}
|
||||||
// Returns the remote IceParameters and generation that match |ufrag|
|
// Returns the remote IceParameters and generation that match `ufrag`
|
||||||
// if found, and returns nullptr otherwise.
|
// if found, and returns nullptr otherwise.
|
||||||
const IceParameters* FindRemoteIceFromUfrag(const std::string& ufrag,
|
const IceParameters* FindRemoteIceFromUfrag(const std::string& ufrag,
|
||||||
uint32_t* generation);
|
uint32_t* generation);
|
||||||
@ -412,10 +412,10 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal {
|
|||||||
int error_ RTC_GUARDED_BY(network_thread_);
|
int error_ RTC_GUARDED_BY(network_thread_);
|
||||||
std::vector<std::unique_ptr<PortAllocatorSession>> allocator_sessions_
|
std::vector<std::unique_ptr<PortAllocatorSession>> allocator_sessions_
|
||||||
RTC_GUARDED_BY(network_thread_);
|
RTC_GUARDED_BY(network_thread_);
|
||||||
// |ports_| contains ports that are used to form new connections when
|
// `ports_` contains ports that are used to form new connections when
|
||||||
// new remote candidates are added.
|
// new remote candidates are added.
|
||||||
std::vector<PortInterface*> ports_ RTC_GUARDED_BY(network_thread_);
|
std::vector<PortInterface*> ports_ RTC_GUARDED_BY(network_thread_);
|
||||||
// |pruned_ports_| contains ports that have been removed from |ports_| and
|
// `pruned_ports_` contains ports that have been removed from `ports_` and
|
||||||
// are not being used to form new connections, but that aren't yet destroyed.
|
// are not being used to form new connections, but that aren't yet destroyed.
|
||||||
// They may have existing connections, and they still fire signals such as
|
// They may have existing connections, and they still fire signals such as
|
||||||
// SignalUnknownAddress.
|
// SignalUnknownAddress.
|
||||||
|
|||||||
@ -45,7 +45,7 @@ struct IceFieldTrials {
|
|||||||
|
|
||||||
// Sending a PING directly after a switch on ICE_CONTROLLING-side.
|
// Sending a PING directly after a switch on ICE_CONTROLLING-side.
|
||||||
// TODO(jonaso) : Deprecate this in favor of
|
// TODO(jonaso) : Deprecate this in favor of
|
||||||
// |send_ping_on_selected_ice_controlling|.
|
// `send_ping_on_selected_ice_controlling`.
|
||||||
bool send_ping_on_switch_ice_controlling = false;
|
bool send_ping_on_switch_ice_controlling = false;
|
||||||
|
|
||||||
// Sending a PING directly after selecting a connection
|
// Sending a PING directly after selecting a connection
|
||||||
|
|||||||
@ -816,7 +816,7 @@ class P2PTransportChannelTestBase : public ::testing::Test,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OnNetworkRouteChanged(absl::optional<rtc::NetworkRoute> network_route) {
|
void OnNetworkRouteChanged(absl::optional<rtc::NetworkRoute> network_route) {
|
||||||
// If the |network_route| is unset, don't count. This is used in the case
|
// If the `network_route` is unset, don't count. This is used in the case
|
||||||
// when the network on remote side is down, the signal will be fired with an
|
// when the network on remote side is down, the signal will be fired with an
|
||||||
// unset network route and it shouldn't trigger a connection switch.
|
// unset network route and it shouldn't trigger a connection switch.
|
||||||
if (network_route) {
|
if (network_route) {
|
||||||
@ -2276,7 +2276,7 @@ TEST_F(P2PTransportChannelTest, SignalReadyToSendWithPresumedWritable) {
|
|||||||
int len = static_cast<int>(strlen(data));
|
int len = static_cast<int>(strlen(data));
|
||||||
EXPECT_EQ(-1, SendData(ep1_ch1(), data, len));
|
EXPECT_EQ(-1, SendData(ep1_ch1(), data, len));
|
||||||
|
|
||||||
// Reset |ready_to_send_| flag, which is set to true if the event fires as it
|
// Reset `ready_to_send_` flag, which is set to true if the event fires as it
|
||||||
// should.
|
// should.
|
||||||
GetEndpoint(0)->ready_to_send_ = false;
|
GetEndpoint(0)->ready_to_send_ = false;
|
||||||
virtual_socket_server()->SetSendingBlocked(false);
|
virtual_socket_server()->SetSendingBlocked(false);
|
||||||
@ -2671,7 +2671,7 @@ TEST_F(P2PTransportChannelMultihomedTest, TestIceRenomination) {
|
|||||||
Connection* selected_connection2 =
|
Connection* selected_connection2 =
|
||||||
const_cast<Connection*>(ep2_ch1()->selected_connection());
|
const_cast<Connection*>(ep2_ch1()->selected_connection());
|
||||||
uint32_t remote_nomination2 = selected_connection2->remote_nomination();
|
uint32_t remote_nomination2 = selected_connection2->remote_nomination();
|
||||||
// |selected_connection2| should not be nominated any more since the previous
|
// `selected_connection2` should not be nominated any more since the previous
|
||||||
// nomination has been acknowledged.
|
// nomination has been acknowledged.
|
||||||
ConnectSignalNominated(selected_connection2);
|
ConnectSignalNominated(selected_connection2);
|
||||||
SIMULATED_WAIT(nominated(), kMediumTimeout, clock);
|
SIMULATED_WAIT(nominated(), kMediumTimeout, clock);
|
||||||
@ -2804,7 +2804,7 @@ TEST_F(P2PTransportChannelMultihomedTest,
|
|||||||
// side to switch connections and networks.
|
// side to switch connections and networks.
|
||||||
TEST_F(P2PTransportChannelMultihomedTest, TestRemoteFailover) {
|
TEST_F(P2PTransportChannelMultihomedTest, TestRemoteFailover) {
|
||||||
rtc::ScopedFakeClock clock;
|
rtc::ScopedFakeClock clock;
|
||||||
// The interface names are chosen so that |cellular| would have higher
|
// The interface names are chosen so that `cellular` would have higher
|
||||||
// candidate priority and higher cost.
|
// candidate priority and higher cost.
|
||||||
auto& wifi = kPublicAddrs;
|
auto& wifi = kPublicAddrs;
|
||||||
auto& cellular = kAlternateAddrs;
|
auto& cellular = kAlternateAddrs;
|
||||||
@ -2850,7 +2850,7 @@ TEST_F(P2PTransportChannelMultihomedTest, TestRemoteFailover) {
|
|||||||
|
|
||||||
// Tests that a Wifi-Wifi connection has the highest precedence.
|
// Tests that a Wifi-Wifi connection has the highest precedence.
|
||||||
TEST_F(P2PTransportChannelMultihomedTest, TestPreferWifiToWifiConnection) {
|
TEST_F(P2PTransportChannelMultihomedTest, TestPreferWifiToWifiConnection) {
|
||||||
// The interface names are chosen so that |cellular| would have higher
|
// The interface names are chosen so that `cellular` would have higher
|
||||||
// candidate priority if it is not for the network type.
|
// candidate priority if it is not for the network type.
|
||||||
auto& wifi = kAlternateAddrs;
|
auto& wifi = kAlternateAddrs;
|
||||||
auto& cellular = kPublicAddrs;
|
auto& cellular = kPublicAddrs;
|
||||||
@ -2877,7 +2877,7 @@ TEST_F(P2PTransportChannelMultihomedTest, TestPreferWifiToWifiConnection) {
|
|||||||
// Tests that a Wifi-Cellular connection has higher precedence than
|
// Tests that a Wifi-Cellular connection has higher precedence than
|
||||||
// a Cellular-Cellular connection.
|
// a Cellular-Cellular connection.
|
||||||
TEST_F(P2PTransportChannelMultihomedTest, TestPreferWifiOverCellularNetwork) {
|
TEST_F(P2PTransportChannelMultihomedTest, TestPreferWifiOverCellularNetwork) {
|
||||||
// The interface names are chosen so that |cellular| would have higher
|
// The interface names are chosen so that `cellular` would have higher
|
||||||
// candidate priority if it is not for the network type.
|
// candidate priority if it is not for the network type.
|
||||||
auto& wifi = kAlternateAddrs;
|
auto& wifi = kAlternateAddrs;
|
||||||
auto& cellular = kPublicAddrs;
|
auto& cellular = kPublicAddrs;
|
||||||
@ -2902,7 +2902,7 @@ TEST_F(P2PTransportChannelMultihomedTest, TestPreferWifiOverCellularNetwork) {
|
|||||||
// what was configured.
|
// what was configured.
|
||||||
TEST_F(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) {
|
TEST_F(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) {
|
||||||
AddAddress(0, kPublicAddrs[0]);
|
AddAddress(0, kPublicAddrs[0]);
|
||||||
// Adding alternate address will make sure |kPublicAddrs| has the higher
|
// Adding alternate address will make sure `kPublicAddrs` has the higher
|
||||||
// priority than others. This is due to FakeNetwork::AddInterface method.
|
// priority than others. This is due to FakeNetwork::AddInterface method.
|
||||||
AddAddress(1, kAlternateAddrs[1]);
|
AddAddress(1, kAlternateAddrs[1]);
|
||||||
AddAddress(1, kPublicAddrs[1]);
|
AddAddress(1, kPublicAddrs[1]);
|
||||||
@ -2918,7 +2918,7 @@ TEST_F(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) {
|
|||||||
ep2_ch1()->SetIceConfig(
|
ep2_ch1()->SetIceConfig(
|
||||||
CreateIceConfig(2000, GATHER_ONCE, backup_ping_interval));
|
CreateIceConfig(2000, GATHER_ONCE, backup_ping_interval));
|
||||||
// After the state becomes COMPLETED, the backup connection will be pinged
|
// After the state becomes COMPLETED, the backup connection will be pinged
|
||||||
// once every |backup_ping_interval| milliseconds.
|
// once every `backup_ping_interval` milliseconds.
|
||||||
ASSERT_TRUE_WAIT(ep2_ch1()->GetState() == IceTransportState::STATE_COMPLETED,
|
ASSERT_TRUE_WAIT(ep2_ch1()->GetState() == IceTransportState::STATE_COMPLETED,
|
||||||
1000);
|
1000);
|
||||||
auto connections = ep2_ch1()->connections();
|
auto connections = ep2_ch1()->connections();
|
||||||
@ -2941,7 +2941,7 @@ TEST_F(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) {
|
|||||||
// what was configured when stable and writable.
|
// what was configured when stable and writable.
|
||||||
TEST_F(P2PTransportChannelMultihomedTest, TestStableWritableRate) {
|
TEST_F(P2PTransportChannelMultihomedTest, TestStableWritableRate) {
|
||||||
AddAddress(0, kPublicAddrs[0]);
|
AddAddress(0, kPublicAddrs[0]);
|
||||||
// Adding alternate address will make sure |kPublicAddrs| has the higher
|
// Adding alternate address will make sure `kPublicAddrs` has the higher
|
||||||
// priority than others. This is due to FakeNetwork::AddInterface method.
|
// priority than others. This is due to FakeNetwork::AddInterface method.
|
||||||
AddAddress(1, kAlternateAddrs[1]);
|
AddAddress(1, kAlternateAddrs[1]);
|
||||||
AddAddress(1, kPublicAddrs[1]);
|
AddAddress(1, kPublicAddrs[1]);
|
||||||
@ -2959,7 +2959,7 @@ TEST_F(P2PTransportChannelMultihomedTest, TestStableWritableRate) {
|
|||||||
config.stable_writable_connection_ping_interval = ping_interval_ms;
|
config.stable_writable_connection_ping_interval = ping_interval_ms;
|
||||||
ep2_ch1()->SetIceConfig(config);
|
ep2_ch1()->SetIceConfig(config);
|
||||||
// After the state becomes COMPLETED and is stable and writable, the
|
// After the state becomes COMPLETED and is stable and writable, the
|
||||||
// connection will be pinged once every |ping_interval_ms| milliseconds.
|
// connection will be pinged once every `ping_interval_ms` milliseconds.
|
||||||
ASSERT_TRUE_WAIT(ep2_ch1()->GetState() == IceTransportState::STATE_COMPLETED,
|
ASSERT_TRUE_WAIT(ep2_ch1()->GetState() == IceTransportState::STATE_COMPLETED,
|
||||||
1000);
|
1000);
|
||||||
auto connections = ep2_ch1()->connections();
|
auto connections = ep2_ch1()->connections();
|
||||||
@ -3337,7 +3337,7 @@ class P2PTransportChannelPingTest : public ::testing::Test,
|
|||||||
return switches;
|
return switches;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if the |pair| matches the last network route.
|
// Return true if the `pair` matches the last network route.
|
||||||
bool CandidatePairMatchesNetworkRoute(CandidatePairInterface* pair) {
|
bool CandidatePairMatchesNetworkRoute(CandidatePairInterface* pair) {
|
||||||
if (!pair) {
|
if (!pair) {
|
||||||
return !last_network_route_.has_value();
|
return !last_network_route_.has_value();
|
||||||
@ -3643,7 +3643,7 @@ TEST_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithVariousUfrags) {
|
|||||||
EXPECT_TRUE(FindNextPingableConnectionAndPingIt(&ch) == nullptr);
|
EXPECT_TRUE(FindNextPingableConnectionAndPingIt(&ch) == nullptr);
|
||||||
|
|
||||||
// Set the remote ICE parameters with the "future" ufrag.
|
// Set the remote ICE parameters with the "future" ufrag.
|
||||||
// This should set the ICE pwd in the remote candidate of |conn1|, making
|
// This should set the ICE pwd in the remote candidate of `conn1`, making
|
||||||
// it pingable.
|
// it pingable.
|
||||||
ch.SetRemoteIceParameters(kIceParams[2]);
|
ch.SetRemoteIceParameters(kIceParams[2]);
|
||||||
EXPECT_EQ(kIceUfrag[2], candidate.username());
|
EXPECT_EQ(kIceUfrag[2], candidate.username());
|
||||||
@ -4465,7 +4465,7 @@ TEST_F(P2PTransportChannelPingTest, TestGetState) {
|
|||||||
// No connections are writable yet, so we should still be in the kChecking
|
// No connections are writable yet, so we should still be in the kChecking
|
||||||
// state.
|
// state.
|
||||||
EXPECT_EQ(webrtc::IceTransportState::kChecking, ch.GetIceTransportState());
|
EXPECT_EQ(webrtc::IceTransportState::kChecking, ch.GetIceTransportState());
|
||||||
// |conn1| becomes writable and receiving; it then should prune |conn2|.
|
// `conn1` becomes writable and receiving; it then should prune `conn2`.
|
||||||
conn1->ReceivedPingResponse(LOW_RTT, "id");
|
conn1->ReceivedPingResponse(LOW_RTT, "id");
|
||||||
EXPECT_TRUE_SIMULATED_WAIT(conn2->pruned(), kShortTimeout, clock);
|
EXPECT_TRUE_SIMULATED_WAIT(conn2->pruned(), kShortTimeout, clock);
|
||||||
EXPECT_EQ(IceTransportState::STATE_COMPLETED, ch.GetState());
|
EXPECT_EQ(IceTransportState::STATE_COMPLETED, ch.GetState());
|
||||||
@ -4498,18 +4498,18 @@ TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) {
|
|||||||
EXPECT_EQ_SIMULATED_WAIT(conn1, ch.selected_connection(), kDefaultTimeout,
|
EXPECT_EQ_SIMULATED_WAIT(conn1, ch.selected_connection(), kDefaultTimeout,
|
||||||
clock);
|
clock);
|
||||||
|
|
||||||
// Add a low-priority connection |conn2|, which will be pruned, but it will
|
// Add a low-priority connection `conn2`, which will be pruned, but it will
|
||||||
// not be deleted right away. Once the current selected connection becomes not
|
// not be deleted right away. Once the current selected connection becomes not
|
||||||
// receiving, |conn2| will start to ping and upon receiving the ping response,
|
// receiving, `conn2` will start to ping and upon receiving the ping response,
|
||||||
// it will become the selected connection.
|
// it will become the selected connection.
|
||||||
ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1));
|
ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1));
|
||||||
Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2, &clock);
|
Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2, &clock);
|
||||||
ASSERT_TRUE(conn2 != nullptr);
|
ASSERT_TRUE(conn2 != nullptr);
|
||||||
EXPECT_TRUE_SIMULATED_WAIT(!conn2->active(), kDefaultTimeout, clock);
|
EXPECT_TRUE_SIMULATED_WAIT(!conn2->active(), kDefaultTimeout, clock);
|
||||||
// |conn2| should not send a ping yet.
|
// `conn2` should not send a ping yet.
|
||||||
EXPECT_EQ(IceCandidatePairState::WAITING, conn2->state());
|
EXPECT_EQ(IceCandidatePairState::WAITING, conn2->state());
|
||||||
EXPECT_EQ(IceTransportState::STATE_COMPLETED, ch.GetState());
|
EXPECT_EQ(IceTransportState::STATE_COMPLETED, ch.GetState());
|
||||||
// Wait for |conn1| becoming not receiving.
|
// Wait for `conn1` becoming not receiving.
|
||||||
EXPECT_TRUE_SIMULATED_WAIT(!conn1->receiving(), kMediumTimeout, clock);
|
EXPECT_TRUE_SIMULATED_WAIT(!conn1->receiving(), kMediumTimeout, clock);
|
||||||
// Make sure conn2 is not deleted.
|
// Make sure conn2 is not deleted.
|
||||||
conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2, &clock);
|
conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2, &clock);
|
||||||
@ -4521,7 +4521,7 @@ TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) {
|
|||||||
clock);
|
clock);
|
||||||
EXPECT_EQ(IceTransportState::STATE_CONNECTING, ch.GetState());
|
EXPECT_EQ(IceTransportState::STATE_CONNECTING, ch.GetState());
|
||||||
|
|
||||||
// When |conn1| comes back again, |conn2| will be pruned again.
|
// When `conn1` comes back again, `conn2` will be pruned again.
|
||||||
conn1->ReceivedPingResponse(LOW_RTT, "id");
|
conn1->ReceivedPingResponse(LOW_RTT, "id");
|
||||||
EXPECT_EQ_SIMULATED_WAIT(conn1, ch.selected_connection(), kDefaultTimeout,
|
EXPECT_EQ_SIMULATED_WAIT(conn1, ch.selected_connection(), kDefaultTimeout,
|
||||||
clock);
|
clock);
|
||||||
@ -4796,11 +4796,11 @@ TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest,
|
|||||||
the flakiness. The following test becomes flaky because we now ping the
|
the flakiness. The following test becomes flaky because we now ping the
|
||||||
connections with fast rates until every connection is pinged at least three
|
connections with fast rates until every connection is pinged at least three
|
||||||
times. The selected connection may have been pinged before
|
times. The selected connection may have been pinged before
|
||||||
|max_strong_interval|, so it may not be the next connection to be pinged as
|
`max_strong_interval`, so it may not be the next connection to be pinged as
|
||||||
expected in the test.
|
expected in the test.
|
||||||
|
|
||||||
// Verify that conn3 will be the "selected connection" since it is readable
|
// Verify that conn3 will be the "selected connection" since it is readable
|
||||||
// and writable. After |MAX_CURRENT_STRONG_INTERVAL|, it should be the next
|
// and writable. After `MAX_CURRENT_STRONG_INTERVAL`, it should be the next
|
||||||
// pingable connection.
|
// pingable connection.
|
||||||
EXPECT_TRUE_WAIT(conn3 == ch.selected_connection(), kDefaultTimeout);
|
EXPECT_TRUE_WAIT(conn3 == ch.selected_connection(), kDefaultTimeout);
|
||||||
WAIT(false, max_strong_interval + 100);
|
WAIT(false, max_strong_interval + 100);
|
||||||
@ -5585,7 +5585,7 @@ TEST_F(P2PTransportChannelTest,
|
|||||||
// This is the complement to
|
// This is the complement to
|
||||||
// SurfaceHostCandidateOnCandidateFilterChangeFromRelayToAll, and instead of
|
// SurfaceHostCandidateOnCandidateFilterChangeFromRelayToAll, and instead of
|
||||||
// gathering continually we only gather once, which makes the config
|
// gathering continually we only gather once, which makes the config
|
||||||
// |surface_ice_candidates_on_ice_transport_type_changed| ineffective after the
|
// `surface_ice_candidates_on_ice_transport_type_changed` ineffective after the
|
||||||
// gathering stopped.
|
// gathering stopped.
|
||||||
TEST_F(P2PTransportChannelTest,
|
TEST_F(P2PTransportChannelTest,
|
||||||
CannotSurfaceTheNewlyAllowedOnFilterChangeIfNotGatheringContinually) {
|
CannotSurfaceTheNewlyAllowedOnFilterChangeIfNotGatheringContinually) {
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class RTC_EXPORT PacketTransportInternal : public sigslot::has_slots<> {
|
|||||||
// TODO(zhihuang): Make it pure virtual once the Chrome/remoting is updated.
|
// TODO(zhihuang): Make it pure virtual once the Chrome/remoting is updated.
|
||||||
virtual absl::optional<NetworkRoute> network_route() const;
|
virtual absl::optional<NetworkRoute> network_route() const;
|
||||||
|
|
||||||
// Emitted when the writable state, represented by |writable()|, changes.
|
// Emitted when the writable state, represented by `writable()`, changes.
|
||||||
sigslot::signal1<PacketTransportInternal*> SignalWritableState;
|
sigslot::signal1<PacketTransportInternal*> SignalWritableState;
|
||||||
|
|
||||||
// Emitted when the PacketTransportInternal is ready to send packets. "Ready
|
// Emitted when the PacketTransportInternal is ready to send packets. "Ready
|
||||||
|
|||||||
@ -655,7 +655,7 @@ bool Port::MaybeIceRoleConflict(const rtc::SocketAddress& addr,
|
|||||||
remote_tiebreaker = stun_attr->value();
|
remote_tiebreaker = stun_attr->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If |remote_ufrag| is same as port local username fragment and
|
// If `remote_ufrag` is same as port local username fragment and
|
||||||
// tie breaker value received in the ping message matches port
|
// tie breaker value received in the ping message matches port
|
||||||
// tiebreaker value this must be a loopback call.
|
// tiebreaker value this must be a loopback call.
|
||||||
// We will treat this as valid scenario.
|
// We will treat this as valid scenario.
|
||||||
|
|||||||
@ -292,7 +292,7 @@ class Port : public PortInterface,
|
|||||||
sigslot::signal2<Port*, Connection*> SignalConnectionCreated;
|
sigslot::signal2<Port*, Connection*> SignalConnectionCreated;
|
||||||
|
|
||||||
// In a shared socket mode each port which shares the socket will decide
|
// In a shared socket mode each port which shares the socket will decide
|
||||||
// to accept the packet based on the |remote_addr|. Currently only UDP
|
// to accept the packet based on the `remote_addr`. Currently only UDP
|
||||||
// port implemented this method.
|
// port implemented this method.
|
||||||
// TODO(mallinath) - Make it pure virtual.
|
// TODO(mallinath) - Make it pure virtual.
|
||||||
virtual bool HandleIncomingPacket(rtc::AsyncPacketSocket* socket,
|
virtual bool HandleIncomingPacket(rtc::AsyncPacketSocket* socket,
|
||||||
@ -301,7 +301,7 @@ class Port : public PortInterface,
|
|||||||
const rtc::SocketAddress& remote_addr,
|
const rtc::SocketAddress& remote_addr,
|
||||||
int64_t packet_time_us);
|
int64_t packet_time_us);
|
||||||
|
|
||||||
// Shall the port handle packet from this |remote_addr|.
|
// Shall the port handle packet from this `remote_addr`.
|
||||||
// This method is overridden by TurnPort.
|
// This method is overridden by TurnPort.
|
||||||
virtual bool CanHandleIncomingPacketsFrom(
|
virtual bool CanHandleIncomingPacketsFrom(
|
||||||
const rtc::SocketAddress& remote_addr) const;
|
const rtc::SocketAddress& remote_addr) const;
|
||||||
@ -467,7 +467,7 @@ class Port : public PortInterface,
|
|||||||
// PortAllocatorSession will provide these username_fragment and password.
|
// PortAllocatorSession will provide these username_fragment and password.
|
||||||
//
|
//
|
||||||
// Note: we should always use username_fragment() instead of using
|
// Note: we should always use username_fragment() instead of using
|
||||||
// |ice_username_fragment_| directly. For the details see the comment on
|
// `ice_username_fragment_` directly. For the details see the comment on
|
||||||
// username_fragment().
|
// username_fragment().
|
||||||
std::string ice_username_fragment_;
|
std::string ice_username_fragment_;
|
||||||
std::string password_;
|
std::string password_;
|
||||||
|
|||||||
@ -173,14 +173,14 @@ bool PortAllocator::SetConfiguration(
|
|||||||
|
|
||||||
turn_customizer_ = turn_customizer;
|
turn_customizer_ = turn_customizer;
|
||||||
|
|
||||||
// If |candidate_pool_size_| is less than the number of pooled sessions, get
|
// If `candidate_pool_size_` is less than the number of pooled sessions, get
|
||||||
// rid of the extras.
|
// rid of the extras.
|
||||||
while (candidate_pool_size_ < static_cast<int>(pooled_sessions_.size())) {
|
while (candidate_pool_size_ < static_cast<int>(pooled_sessions_.size())) {
|
||||||
pooled_sessions_.back().reset(nullptr);
|
pooled_sessions_.back().reset(nullptr);
|
||||||
pooled_sessions_.pop_back();
|
pooled_sessions_.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
// |stun_candidate_keepalive_interval_| will be used in STUN port allocation
|
// `stun_candidate_keepalive_interval_` will be used in STUN port allocation
|
||||||
// in future sessions. We also update the ready ports in the pooled sessions.
|
// in future sessions. We also update the ready ports in the pooled sessions.
|
||||||
// Ports in sessions that are taken and owned by P2PTransportChannel will be
|
// Ports in sessions that are taken and owned by P2PTransportChannel will be
|
||||||
// updated there via IceConfig.
|
// updated there via IceConfig.
|
||||||
@ -190,7 +190,7 @@ bool PortAllocator::SetConfiguration(
|
|||||||
stun_candidate_keepalive_interval_);
|
stun_candidate_keepalive_interval_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If |candidate_pool_size_| is greater than the number of pooled sessions,
|
// If `candidate_pool_size_` is greater than the number of pooled sessions,
|
||||||
// create new sessions.
|
// create new sessions.
|
||||||
while (static_cast<int>(pooled_sessions_.size()) < candidate_pool_size_) {
|
while (static_cast<int>(pooled_sessions_.size()) < candidate_pool_size_) {
|
||||||
IceParameters iceCredentials =
|
IceParameters iceCredentials =
|
||||||
|
|||||||
@ -549,7 +549,7 @@ class RTC_EXPORT PortAllocator : public sigslot::has_slots<> {
|
|||||||
// taken via TakePooledSession.
|
// taken via TakePooledSession.
|
||||||
//
|
//
|
||||||
// A change in the candidate filter also fires a signal
|
// A change in the candidate filter also fires a signal
|
||||||
// |SignalCandidateFilterChanged|, so that objects subscribed to this signal
|
// `SignalCandidateFilterChanged`, so that objects subscribed to this signal
|
||||||
// can, for example, update the candidate filter for sessions created by this
|
// can, for example, update the candidate filter for sessions created by this
|
||||||
// allocator and already taken by the object.
|
// allocator and already taken by the object.
|
||||||
//
|
//
|
||||||
@ -599,7 +599,7 @@ class RTC_EXPORT PortAllocator : public sigslot::has_slots<> {
|
|||||||
// Return IceParameters of the pooled sessions.
|
// Return IceParameters of the pooled sessions.
|
||||||
std::vector<IceParameters> GetPooledIceCredentials();
|
std::vector<IceParameters> GetPooledIceCredentials();
|
||||||
|
|
||||||
// Fired when |candidate_filter_| changes.
|
// Fired when `candidate_filter_` changes.
|
||||||
sigslot::signal2<uint32_t /* prev_filter */, uint32_t /* cur_filter */>
|
sigslot::signal2<uint32_t /* prev_filter */, uint32_t /* cur_filter */>
|
||||||
SignalCandidateFilterChanged;
|
SignalCandidateFilterChanged;
|
||||||
|
|
||||||
|
|||||||
@ -266,7 +266,7 @@ static void SendPingAndReceiveResponse(Connection* lconn,
|
|||||||
|
|
||||||
class TestChannel : public sigslot::has_slots<> {
|
class TestChannel : public sigslot::has_slots<> {
|
||||||
public:
|
public:
|
||||||
// Takes ownership of |p1| (but not |p2|).
|
// Takes ownership of `p1` (but not `p2`).
|
||||||
explicit TestChannel(std::unique_ptr<Port> p1) : port_(std::move(p1)) {
|
explicit TestChannel(std::unique_ptr<Port> p1) : port_(std::move(p1)) {
|
||||||
port_->SignalPortComplete.connect(this, &TestChannel::OnPortComplete);
|
port_->SignalPortComplete.connect(this, &TestChannel::OnPortComplete);
|
||||||
port_->SignalUnknownAddress.connect(this, &TestChannel::OnUnknownAddress);
|
port_->SignalUnknownAddress.connect(this, &TestChannel::OnUnknownAddress);
|
||||||
@ -588,7 +588,7 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||||||
|
|
||||||
void ExpectPortsCanConnect(bool can_connect, Port* p1, Port* p2);
|
void ExpectPortsCanConnect(bool can_connect, Port* p1, Port* p2);
|
||||||
|
|
||||||
// This does all the work and then deletes |port1| and |port2|.
|
// This does all the work and then deletes `port1` and `port2`.
|
||||||
void TestConnectivity(const char* name1,
|
void TestConnectivity(const char* name1,
|
||||||
std::unique_ptr<Port> port1,
|
std::unique_ptr<Port> port1,
|
||||||
const char* name2,
|
const char* name2,
|
||||||
@ -598,7 +598,7 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||||||
bool same_addr2,
|
bool same_addr2,
|
||||||
bool possible);
|
bool possible);
|
||||||
|
|
||||||
// This connects the provided channels which have already started. |ch1|
|
// This connects the provided channels which have already started. `ch1`
|
||||||
// should have its Connection created (either through CreateConnection() or
|
// should have its Connection created (either through CreateConnection() or
|
||||||
// TCP reconnecting mechanism before entering this function.
|
// TCP reconnecting mechanism before entering this function.
|
||||||
void ConnectStartedChannels(TestChannel* ch1, TestChannel* ch2) {
|
void ConnectStartedChannels(TestChannel* ch1, TestChannel* ch2) {
|
||||||
@ -616,7 +616,7 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This connects and disconnects the provided channels in the same sequence as
|
// This connects and disconnects the provided channels in the same sequence as
|
||||||
// TestConnectivity with all options set to |true|. It does not delete either
|
// TestConnectivity with all options set to `true`. It does not delete either
|
||||||
// channel.
|
// channel.
|
||||||
void StartConnectAndStopChannels(TestChannel* ch1, TestChannel* ch2) {
|
void StartConnectAndStopChannels(TestChannel* ch1, TestChannel* ch2) {
|
||||||
// Acquire addresses.
|
// Acquire addresses.
|
||||||
@ -1414,7 +1414,7 @@ TEST_F(PortTest, TestLoopbackCall) {
|
|||||||
// response.
|
// response.
|
||||||
lport->Reset();
|
lport->Reset();
|
||||||
lport->AddCandidateAddress(kLocalAddr2);
|
lport->AddCandidateAddress(kLocalAddr2);
|
||||||
// Creating a different connection as |conn| is receiving.
|
// Creating a different connection as `conn` is receiving.
|
||||||
Connection* conn1 =
|
Connection* conn1 =
|
||||||
lport->CreateConnection(lport->Candidates()[1], Port::ORIGIN_MESSAGE);
|
lport->CreateConnection(lport->Candidates()[1], Port::ORIGIN_MESSAGE);
|
||||||
conn1->Ping(0);
|
conn1->Ping(0);
|
||||||
@ -1446,8 +1446,8 @@ TEST_F(PortTest, TestLoopbackCall) {
|
|||||||
|
|
||||||
// This test verifies role conflict signal is received when there is
|
// This test verifies role conflict signal is received when there is
|
||||||
// conflict in the role. In this case both ports are in controlling and
|
// conflict in the role. In this case both ports are in controlling and
|
||||||
// |rport| has higher tiebreaker value than |lport|. Since |lport| has lower
|
// `rport` has higher tiebreaker value than `lport`. Since `lport` has lower
|
||||||
// value of tiebreaker, when it receives ping request from |rport| it will
|
// value of tiebreaker, when it receives ping request from `rport` it will
|
||||||
// send role conflict signal.
|
// send role conflict signal.
|
||||||
TEST_F(PortTest, TestIceRoleConflict) {
|
TEST_F(PortTest, TestIceRoleConflict) {
|
||||||
auto lport = CreateTestPort(kLocalAddr1, "lfrag", "lpass");
|
auto lport = CreateTestPort(kLocalAddr1, "lfrag", "lpass");
|
||||||
@ -1871,7 +1871,7 @@ TEST_F(PortTest, TestNomination) {
|
|||||||
Connection* rconn =
|
Connection* rconn =
|
||||||
rport->CreateConnection(lport->Candidates()[0], Port::ORIGIN_MESSAGE);
|
rport->CreateConnection(lport->Candidates()[0], Port::ORIGIN_MESSAGE);
|
||||||
|
|
||||||
// |lconn| is controlling, |rconn| is controlled.
|
// `lconn` is controlling, `rconn` is controlled.
|
||||||
uint32_t nomination = 1234;
|
uint32_t nomination = 1234;
|
||||||
lconn->set_nomination(nomination);
|
lconn->set_nomination(nomination);
|
||||||
|
|
||||||
@ -1880,8 +1880,8 @@ TEST_F(PortTest, TestNomination) {
|
|||||||
EXPECT_EQ(lconn->nominated(), lconn->stats().nominated);
|
EXPECT_EQ(lconn->nominated(), lconn->stats().nominated);
|
||||||
EXPECT_EQ(rconn->nominated(), rconn->stats().nominated);
|
EXPECT_EQ(rconn->nominated(), rconn->stats().nominated);
|
||||||
|
|
||||||
// Send ping (including the nomination value) from |lconn| to |rconn|. This
|
// Send ping (including the nomination value) from `lconn` to `rconn`. This
|
||||||
// should set the remote nomination of |rconn|.
|
// should set the remote nomination of `rconn`.
|
||||||
lconn->Ping(0);
|
lconn->Ping(0);
|
||||||
ASSERT_TRUE_WAIT(lport->last_stun_msg(), kDefaultTimeout);
|
ASSERT_TRUE_WAIT(lport->last_stun_msg(), kDefaultTimeout);
|
||||||
ASSERT_TRUE(lport->last_stun_buf());
|
ASSERT_TRUE(lport->last_stun_buf());
|
||||||
@ -1893,8 +1893,8 @@ TEST_F(PortTest, TestNomination) {
|
|||||||
EXPECT_EQ(lconn->nominated(), lconn->stats().nominated);
|
EXPECT_EQ(lconn->nominated(), lconn->stats().nominated);
|
||||||
EXPECT_EQ(rconn->nominated(), rconn->stats().nominated);
|
EXPECT_EQ(rconn->nominated(), rconn->stats().nominated);
|
||||||
|
|
||||||
// This should result in an acknowledgment sent back from |rconn| to |lconn|,
|
// This should result in an acknowledgment sent back from `rconn` to `lconn`,
|
||||||
// updating the acknowledged nomination of |lconn|.
|
// updating the acknowledged nomination of `lconn`.
|
||||||
ASSERT_TRUE_WAIT(rport->last_stun_msg(), kDefaultTimeout);
|
ASSERT_TRUE_WAIT(rport->last_stun_msg(), kDefaultTimeout);
|
||||||
ASSERT_TRUE(rport->last_stun_buf());
|
ASSERT_TRUE(rport->last_stun_buf());
|
||||||
lconn->OnReadPacket(rport->last_stun_buf()->data<char>(),
|
lconn->OnReadPacket(rport->last_stun_buf()->data<char>(),
|
||||||
@ -2648,11 +2648,11 @@ TEST_F(PortTest, TestConnectionPriority) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note that UpdateState takes into account the estimated RTT, and the
|
// Note that UpdateState takes into account the estimated RTT, and the
|
||||||
// correctness of using |kMaxExpectedSimulatedRtt| as an upper bound of RTT in
|
// correctness of using `kMaxExpectedSimulatedRtt` as an upper bound of RTT in
|
||||||
// the following tests depends on the link rate and the delay distriubtion
|
// the following tests depends on the link rate and the delay distriubtion
|
||||||
// configured in VirtualSocketServer::AddPacketToNetwork. The tests below use
|
// configured in VirtualSocketServer::AddPacketToNetwork. The tests below use
|
||||||
// the default setup where the RTT is deterministically one, which generates an
|
// the default setup where the RTT is deterministically one, which generates an
|
||||||
// estimate given by |MINIMUM_RTT| = 100.
|
// estimate given by `MINIMUM_RTT` = 100.
|
||||||
TEST_F(PortTest, TestWritableState) {
|
TEST_F(PortTest, TestWritableState) {
|
||||||
rtc::ScopedFakeClock clock;
|
rtc::ScopedFakeClock clock;
|
||||||
auto port1 = CreateUdpPort(kLocalAddr1);
|
auto port1 = CreateUdpPort(kLocalAddr1);
|
||||||
@ -2728,8 +2728,8 @@ TEST_F(PortTest, TestWritableState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test writability states using the configured threshold value to replace
|
// Test writability states using the configured threshold value to replace
|
||||||
// the default value given by |CONNECTION_WRITE_CONNECT_TIMEOUT| and
|
// the default value given by `CONNECTION_WRITE_CONNECT_TIMEOUT` and
|
||||||
// |CONNECTION_WRITE_CONNECT_FAILURES|.
|
// `CONNECTION_WRITE_CONNECT_FAILURES`.
|
||||||
TEST_F(PortTest, TestWritableStateWithConfiguredThreshold) {
|
TEST_F(PortTest, TestWritableStateWithConfiguredThreshold) {
|
||||||
rtc::ScopedFakeClock clock;
|
rtc::ScopedFakeClock clock;
|
||||||
auto port1 = CreateUdpPort(kLocalAddr1);
|
auto port1 = CreateUdpPort(kLocalAddr1);
|
||||||
@ -2813,7 +2813,7 @@ TEST_F(PortTest, TestTimeoutForNeverWritable) {
|
|||||||
|
|
||||||
// This test verifies the connection setup between ICEMODE_FULL
|
// This test verifies the connection setup between ICEMODE_FULL
|
||||||
// and ICEMODE_LITE.
|
// and ICEMODE_LITE.
|
||||||
// In this test |ch1| behaves like FULL mode client and we have created
|
// In this test `ch1` behaves like FULL mode client and we have created
|
||||||
// port which responds to the ping message just like LITE client.
|
// port which responds to the ping message just like LITE client.
|
||||||
TEST_F(PortTest, TestIceLiteConnectivity) {
|
TEST_F(PortTest, TestIceLiteConnectivity) {
|
||||||
auto ice_full_port =
|
auto ice_full_port =
|
||||||
|
|||||||
@ -147,10 +147,10 @@ class RTC_EXPORT PseudoTcp {
|
|||||||
// Creates a packet and submits it to the network. This method can either
|
// Creates a packet and submits it to the network. This method can either
|
||||||
// send payload or just an ACK packet.
|
// send payload or just an ACK packet.
|
||||||
//
|
//
|
||||||
// |seq| is the sequence number of this packet.
|
// `seq` is the sequence number of this packet.
|
||||||
// |flags| is the flags for sending this packet.
|
// `flags` is the flags for sending this packet.
|
||||||
// |offset| is the offset to read from |m_sbuf|.
|
// `offset` is the offset to read from `m_sbuf`.
|
||||||
// |len| is the number of bytes to read from |m_sbuf| as payload. If this
|
// `len` is the number of bytes to read from `m_sbuf` as payload. If this
|
||||||
// value is 0 then this is an ACK packet, otherwise this packet has payload.
|
// value is 0 then this is an ACK packet, otherwise this packet has payload.
|
||||||
IPseudoTcpNotify::WriteResult packet(uint32_t seq,
|
IPseudoTcpNotify::WriteResult packet(uint32_t seq,
|
||||||
uint8_t flags,
|
uint8_t flags,
|
||||||
@ -190,11 +190,11 @@ class RTC_EXPORT PseudoTcp {
|
|||||||
// Apply window scale option.
|
// Apply window scale option.
|
||||||
void applyWindowScaleOption(uint8_t scale_factor);
|
void applyWindowScaleOption(uint8_t scale_factor);
|
||||||
|
|
||||||
// Resize the send buffer with |new_size| in bytes.
|
// Resize the send buffer with `new_size` in bytes.
|
||||||
void resizeSendBuffer(uint32_t new_size);
|
void resizeSendBuffer(uint32_t new_size);
|
||||||
|
|
||||||
// Resize the receive buffer with |new_size| in bytes. This call adjusts
|
// Resize the receive buffer with `new_size` in bytes. This call adjusts
|
||||||
// window scale factor |m_swnd_scale| accordingly.
|
// window scale factor `m_swnd_scale` accordingly.
|
||||||
void resizeReceiveBuffer(uint32_t new_size);
|
void resizeReceiveBuffer(uint32_t new_size);
|
||||||
|
|
||||||
class LockedFifoBuffer final {
|
class LockedFifoBuffer final {
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class PseudoTcpTestBase : public ::testing::Test,
|
|||||||
rtc::SetRandomTestMode(false);
|
rtc::SetRandomTestMode(false);
|
||||||
}
|
}
|
||||||
// If true, both endpoints will send the "connect" segment simultaneously,
|
// If true, both endpoints will send the "connect" segment simultaneously,
|
||||||
// rather than |local_| sending it followed by a response from |remote_|.
|
// rather than `local_` sending it followed by a response from `remote_`.
|
||||||
// Note that this is what chromoting ends up doing.
|
// Note that this is what chromoting ends up doing.
|
||||||
void SetSimultaneousOpen(bool enabled) { simultaneous_open_ = enabled; }
|
void SetSimultaneousOpen(bool enabled) { simultaneous_open_ = enabled; }
|
||||||
void SetLocalMtu(int mtu) {
|
void SetLocalMtu(int mtu) {
|
||||||
@ -461,7 +461,7 @@ class PseudoTcpTestPingPong : public PseudoTcpTestBase {
|
|||||||
// contracts and enlarges correctly.
|
// contracts and enlarges correctly.
|
||||||
class PseudoTcpTestReceiveWindow : public PseudoTcpTestBase {
|
class PseudoTcpTestReceiveWindow : public PseudoTcpTestBase {
|
||||||
public:
|
public:
|
||||||
// Not all the data are transfered, |size| just need to be big enough
|
// Not all the data are transfered, `size` just need to be big enough
|
||||||
// to fill up the receiver window twice.
|
// to fill up the receiver window twice.
|
||||||
void TestTransfer(int size) {
|
void TestTransfer(int size) {
|
||||||
// Create some dummy data to send.
|
// Create some dummy data to send.
|
||||||
|
|||||||
@ -30,7 +30,7 @@ namespace cricket {
|
|||||||
const int RETRY_TIMEOUT = 50 * 1000; // 50 seconds
|
const int RETRY_TIMEOUT = 50 * 1000; // 50 seconds
|
||||||
|
|
||||||
// Stop logging errors in UDPPort::SendTo after we have logged
|
// Stop logging errors in UDPPort::SendTo after we have logged
|
||||||
// |kSendErrorLogLimit| messages. Start again after a successful send.
|
// `kSendErrorLogLimit` messages. Start again after a successful send.
|
||||||
const int kSendErrorLogLimit = 5;
|
const int kSendErrorLogLimit = 5;
|
||||||
|
|
||||||
// Handles a binding request sent to the STUN server.
|
// Handles a binding request sent to the STUN server.
|
||||||
@ -102,7 +102,7 @@ class StunBindingRequest : public StunRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Returns true if |now| is within the lifetime of the request (a negative
|
// Returns true if `now` is within the lifetime of the request (a negative
|
||||||
// lifetime means infinite).
|
// lifetime means infinite).
|
||||||
bool WithinLifetime(int64_t now) const {
|
bool WithinLifetime(int64_t now) const {
|
||||||
int lifetime = port_->stun_keepalive_lifetime();
|
int lifetime = port_->stun_keepalive_lifetime();
|
||||||
@ -373,7 +373,7 @@ void UDPPort::OnLocalAddressReady(rtc::AsyncPacketSocket* socket,
|
|||||||
const rtc::SocketAddress& address) {
|
const rtc::SocketAddress& address) {
|
||||||
// When adapter enumeration is disabled and binding to the any address, the
|
// When adapter enumeration is disabled and binding to the any address, the
|
||||||
// default local address will be issued as a candidate instead if
|
// default local address will be issued as a candidate instead if
|
||||||
// |emit_local_for_anyaddress| is true. This is to allow connectivity for
|
// `emit_local_for_anyaddress` is true. This is to allow connectivity for
|
||||||
// applications which absolutely requires a HOST candidate.
|
// applications which absolutely requires a HOST candidate.
|
||||||
rtc::SocketAddress addr = address;
|
rtc::SocketAddress addr = address;
|
||||||
|
|
||||||
@ -474,7 +474,7 @@ void UDPPort::SendStunBindingRequest(const rtc::SocketAddress& stun_addr) {
|
|||||||
ResolveStunAddress(stun_addr);
|
ResolveStunAddress(stun_addr);
|
||||||
|
|
||||||
} else if (socket_->GetState() == rtc::AsyncPacketSocket::STATE_BOUND) {
|
} else if (socket_->GetState() == rtc::AsyncPacketSocket::STATE_BOUND) {
|
||||||
// Check if |server_addr_| is compatible with the port's ip.
|
// Check if `server_addr_` is compatible with the port's ip.
|
||||||
if (IsCompatibleAddress(stun_addr)) {
|
if (IsCompatibleAddress(stun_addr)) {
|
||||||
requests_.Send(
|
requests_.Send(
|
||||||
new StunBindingRequest(this, stun_addr, rtc::TimeMillis()));
|
new StunBindingRequest(this, stun_addr, rtc::TimeMillis()));
|
||||||
@ -520,7 +520,7 @@ void UDPPort::OnStunBindingRequestSucceeded(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bind_request_succeeded_servers_.insert(stun_server_addr);
|
bind_request_succeeded_servers_.insert(stun_server_addr);
|
||||||
// If socket is shared and |stun_reflected_addr| is equal to local socket
|
// If socket is shared and `stun_reflected_addr` is equal to local socket
|
||||||
// address, or if the same address has been added by another STUN server,
|
// address, or if the same address has been added by another STUN server,
|
||||||
// then discarding the stun address.
|
// then discarding the stun address.
|
||||||
// For STUN, related address is the local socket address.
|
// For STUN, related address is the local socket address.
|
||||||
|
|||||||
@ -112,7 +112,7 @@ class UDPPort : public Port {
|
|||||||
void set_stun_keepalive_lifetime(int lifetime) {
|
void set_stun_keepalive_lifetime(int lifetime) {
|
||||||
stun_keepalive_lifetime_ = lifetime;
|
stun_keepalive_lifetime_ = lifetime;
|
||||||
}
|
}
|
||||||
// Returns true if there is a pending request with type |msg_type|.
|
// Returns true if there is a pending request with type `msg_type`.
|
||||||
bool HasPendingRequest(int msg_type) {
|
bool HasPendingRequest(int msg_type) {
|
||||||
return requests_.HasRequest(msg_type);
|
return requests_.HasRequest(msg_type);
|
||||||
}
|
}
|
||||||
@ -170,8 +170,8 @@ class UDPPort : public Port {
|
|||||||
|
|
||||||
void SendStunBindingRequests();
|
void SendStunBindingRequests();
|
||||||
|
|
||||||
// Helper function which will set |addr|'s IP to the default local address if
|
// Helper function which will set `addr`'s IP to the default local address if
|
||||||
// |addr| is the "any" address and |emit_local_for_anyaddress_| is true. When
|
// `addr` is the "any" address and `emit_local_for_anyaddress_` is true. When
|
||||||
// returning false, it indicates that the operation has failed and the
|
// returning false, it indicates that the operation has failed and the
|
||||||
// address shouldn't be used by any candidate.
|
// address shouldn't be used by any candidate.
|
||||||
bool MaybeSetDefaultLocalAddress(rtc::SocketAddress* addr) const;
|
bool MaybeSetDefaultLocalAddress(rtc::SocketAddress* addr) const;
|
||||||
|
|||||||
@ -79,7 +79,7 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> {
|
|||||||
rtc::CreateRandomString(16), rtc::CreateRandomString(22), stun_servers,
|
rtc::CreateRandomString(16), rtc::CreateRandomString(22), stun_servers,
|
||||||
std::string(), absl::nullopt);
|
std::string(), absl::nullopt);
|
||||||
stun_port_->set_stun_keepalive_delay(stun_keepalive_delay_);
|
stun_port_->set_stun_keepalive_delay(stun_keepalive_delay_);
|
||||||
// If |stun_keepalive_lifetime_| is negative, let the stun port
|
// If `stun_keepalive_lifetime_` is negative, let the stun port
|
||||||
// choose its lifetime from the network type.
|
// choose its lifetime from the network type.
|
||||||
if (stun_keepalive_lifetime_ >= 0) {
|
if (stun_keepalive_lifetime_ >= 0) {
|
||||||
stun_port_->set_stun_keepalive_lifetime(stun_keepalive_lifetime_);
|
stun_port_->set_stun_keepalive_lifetime(stun_keepalive_lifetime_);
|
||||||
@ -350,15 +350,15 @@ TEST_F(StunPortTest, TestTwoCandidatesWithTwoStunServersAcrossNat) {
|
|||||||
// type on a STUN port. Also test that it will be updated if the network type
|
// type on a STUN port. Also test that it will be updated if the network type
|
||||||
// changes.
|
// changes.
|
||||||
TEST_F(StunPortTest, TestStunPortGetStunKeepaliveLifetime) {
|
TEST_F(StunPortTest, TestStunPortGetStunKeepaliveLifetime) {
|
||||||
// Lifetime for the default (unknown) network type is |kInfiniteLifetime|.
|
// Lifetime for the default (unknown) network type is `kInfiniteLifetime`.
|
||||||
CreateStunPort(kStunAddr1);
|
CreateStunPort(kStunAddr1);
|
||||||
EXPECT_EQ(kInfiniteLifetime, port()->stun_keepalive_lifetime());
|
EXPECT_EQ(kInfiniteLifetime, port()->stun_keepalive_lifetime());
|
||||||
// Lifetime for the cellular network is |kHighCostPortKeepaliveLifetimeMs|
|
// Lifetime for the cellular network is `kHighCostPortKeepaliveLifetimeMs`
|
||||||
SetNetworkType(rtc::ADAPTER_TYPE_CELLULAR);
|
SetNetworkType(rtc::ADAPTER_TYPE_CELLULAR);
|
||||||
EXPECT_EQ(kHighCostPortKeepaliveLifetimeMs,
|
EXPECT_EQ(kHighCostPortKeepaliveLifetimeMs,
|
||||||
port()->stun_keepalive_lifetime());
|
port()->stun_keepalive_lifetime());
|
||||||
|
|
||||||
// Lifetime for the wifi network is |kInfiniteLifetime|.
|
// Lifetime for the wifi network is `kInfiniteLifetime`.
|
||||||
SetNetworkType(rtc::ADAPTER_TYPE_WIFI);
|
SetNetworkType(rtc::ADAPTER_TYPE_WIFI);
|
||||||
CreateStunPort(kStunAddr2);
|
CreateStunPort(kStunAddr2);
|
||||||
EXPECT_EQ(kInfiniteLifetime, port()->stun_keepalive_lifetime());
|
EXPECT_EQ(kInfiniteLifetime, port()->stun_keepalive_lifetime());
|
||||||
@ -368,15 +368,15 @@ TEST_F(StunPortTest, TestStunPortGetStunKeepaliveLifetime) {
|
|||||||
// type on a shared STUN port (UDPPort). Also test that it will be updated
|
// type on a shared STUN port (UDPPort). Also test that it will be updated
|
||||||
// if the network type changes.
|
// if the network type changes.
|
||||||
TEST_F(StunPortTest, TestUdpPortGetStunKeepaliveLifetime) {
|
TEST_F(StunPortTest, TestUdpPortGetStunKeepaliveLifetime) {
|
||||||
// Lifetime for the default (unknown) network type is |kInfiniteLifetime|.
|
// Lifetime for the default (unknown) network type is `kInfiniteLifetime`.
|
||||||
CreateSharedUdpPort(kStunAddr1, nullptr);
|
CreateSharedUdpPort(kStunAddr1, nullptr);
|
||||||
EXPECT_EQ(kInfiniteLifetime, port()->stun_keepalive_lifetime());
|
EXPECT_EQ(kInfiniteLifetime, port()->stun_keepalive_lifetime());
|
||||||
// Lifetime for the cellular network is |kHighCostPortKeepaliveLifetimeMs|.
|
// Lifetime for the cellular network is `kHighCostPortKeepaliveLifetimeMs`.
|
||||||
SetNetworkType(rtc::ADAPTER_TYPE_CELLULAR);
|
SetNetworkType(rtc::ADAPTER_TYPE_CELLULAR);
|
||||||
EXPECT_EQ(kHighCostPortKeepaliveLifetimeMs,
|
EXPECT_EQ(kHighCostPortKeepaliveLifetimeMs,
|
||||||
port()->stun_keepalive_lifetime());
|
port()->stun_keepalive_lifetime());
|
||||||
|
|
||||||
// Lifetime for the wifi network type is |kInfiniteLifetime|.
|
// Lifetime for the wifi network type is `kInfiniteLifetime`.
|
||||||
SetNetworkType(rtc::ADAPTER_TYPE_WIFI);
|
SetNetworkType(rtc::ADAPTER_TYPE_WIFI);
|
||||||
CreateSharedUdpPort(kStunAddr2, nullptr);
|
CreateSharedUdpPort(kStunAddr2, nullptr);
|
||||||
EXPECT_EQ(kInfiniteLifetime, port()->stun_keepalive_lifetime());
|
EXPECT_EQ(kInfiniteLifetime, port()->stun_keepalive_lifetime());
|
||||||
|
|||||||
@ -106,7 +106,7 @@ void StunRequestManager::Clear() {
|
|||||||
|
|
||||||
for (uint32_t i = 0; i < requests.size(); ++i) {
|
for (uint32_t i = 0; i < requests.size(); ++i) {
|
||||||
// StunRequest destructor calls Remove() which deletes requests
|
// StunRequest destructor calls Remove() which deletes requests
|
||||||
// from |requests_|.
|
// from `requests_`.
|
||||||
delete requests[i];
|
delete requests[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,12 +44,12 @@ class StunRequestManager {
|
|||||||
void Send(StunRequest* request);
|
void Send(StunRequest* request);
|
||||||
void SendDelayed(StunRequest* request, int delay);
|
void SendDelayed(StunRequest* request, int delay);
|
||||||
|
|
||||||
// If |msg_type| is kAllRequests, sends all pending requests right away.
|
// If `msg_type` is kAllRequests, sends all pending requests right away.
|
||||||
// Otherwise, sends those that have a matching type right away.
|
// Otherwise, sends those that have a matching type right away.
|
||||||
// Only for testing.
|
// Only for testing.
|
||||||
void Flush(int msg_type);
|
void Flush(int msg_type);
|
||||||
|
|
||||||
// Returns true if at least one request with |msg_type| is scheduled for
|
// Returns true if at least one request with `msg_type` is scheduled for
|
||||||
// transmission. For testing only.
|
// transmission. For testing only.
|
||||||
bool HasRequest(int msg_type);
|
bool HasRequest(int msg_type);
|
||||||
|
|
||||||
@ -112,10 +112,10 @@ class StunRequest : public rtc::MessageHandler {
|
|||||||
// Returns the STUN type of the request message.
|
// Returns the STUN type of the request message.
|
||||||
int type();
|
int type();
|
||||||
|
|
||||||
// Returns a const pointer to |msg_|.
|
// Returns a const pointer to `msg_`.
|
||||||
const StunMessage* msg() const;
|
const StunMessage* msg() const;
|
||||||
|
|
||||||
// Returns a mutable pointer to |msg_|.
|
// Returns a mutable pointer to `msg_`.
|
||||||
StunMessage* mutable_msg();
|
StunMessage* mutable_msg();
|
||||||
|
|
||||||
// Time elapsed since last send (in ms)
|
// Time elapsed since last send (in ms)
|
||||||
|
|||||||
@ -18,10 +18,10 @@
|
|||||||
* before stun binding completed will trigger IPC socket layer to shutdown
|
* before stun binding completed will trigger IPC socket layer to shutdown
|
||||||
* the connection.
|
* the connection.
|
||||||
*
|
*
|
||||||
* - PendingTCP: |connection_pending_| indicates whether there is an
|
* - PendingTCP: `connection_pending_` indicates whether there is an
|
||||||
* outstanding TCP connection in progress.
|
* outstanding TCP connection in progress.
|
||||||
*
|
*
|
||||||
* - PretendWri: Tracked by |pretending_to_be_writable_|. Marking connection as
|
* - PretendWri: Tracked by `pretending_to_be_writable_`. Marking connection as
|
||||||
* WRITE_TIMEOUT will cause the connection be deleted. Instead, we're
|
* WRITE_TIMEOUT will cause the connection be deleted. Instead, we're
|
||||||
* "pretending" we're still writable for a period of time such that reconnect
|
* "pretending" we're still writable for a period of time such that reconnect
|
||||||
* could work.
|
* could work.
|
||||||
@ -342,8 +342,8 @@ void TCPPort::OnAddressReady(rtc::AsyncPacketSocket* socket,
|
|||||||
0, "", true);
|
0, "", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(qingsi): |CONNECTION_WRITE_CONNECT_TIMEOUT| is overriden by
|
// TODO(qingsi): `CONNECTION_WRITE_CONNECT_TIMEOUT` is overriden by
|
||||||
// |ice_unwritable_timeout| in IceConfig when determining the writability state.
|
// `ice_unwritable_timeout` in IceConfig when determining the writability state.
|
||||||
// Replace this constant with the config parameter assuming the default value if
|
// Replace this constant with the config parameter assuming the default value if
|
||||||
// we decide it is also applicable here.
|
// we decide it is also applicable here.
|
||||||
TCPConnection::TCPConnection(TCPPort* port,
|
TCPConnection::TCPConnection(TCPPort* port,
|
||||||
@ -506,7 +506,7 @@ void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) {
|
|||||||
MSG_TCPCONNECTION_DELAYED_ONCLOSE);
|
MSG_TCPCONNECTION_DELAYED_ONCLOSE);
|
||||||
} else if (!pretending_to_be_writable_) {
|
} else if (!pretending_to_be_writable_) {
|
||||||
// OnClose could be called when the underneath socket times out during the
|
// OnClose could be called when the underneath socket times out during the
|
||||||
// initial connect() (i.e. |pretending_to_be_writable_| is false) . We have
|
// initial connect() (i.e. `pretending_to_be_writable_` is false) . We have
|
||||||
// to manually destroy here as this connection, as never connected, will not
|
// to manually destroy here as this connection, as never connected, will not
|
||||||
// be scheduled for ping to trigger destroy.
|
// be scheduled for ping to trigger destroy.
|
||||||
Destroy();
|
Destroy();
|
||||||
|
|||||||
@ -61,8 +61,8 @@ class TransportDescriptionFactory {
|
|||||||
IceCredentialsIterator* ice_credentials) const;
|
IceCredentialsIterator* ice_credentials) const;
|
||||||
// Create a transport description that is a response to an offer.
|
// Create a transport description that is a response to an offer.
|
||||||
//
|
//
|
||||||
// If |require_transport_attributes| is true, then TRANSPORT category
|
// If `require_transport_attributes` is true, then TRANSPORT category
|
||||||
// attributes are expected to be present in |offer|, as defined by
|
// attributes are expected to be present in `offer`, as defined by
|
||||||
// sdp-mux-attributes, and null will be returned otherwise. It's expected
|
// sdp-mux-attributes, and null will be returned otherwise. It's expected
|
||||||
// that this will be set to false for an m= section that's in a BUNDLE group
|
// that this will be set to false for an m= section that's in a BUNDLE group
|
||||||
// but isn't the first m= section in the group.
|
// but isn't the first m= section in the group.
|
||||||
|
|||||||
@ -69,7 +69,7 @@ class TransportDescriptionFactoryTest : public ::testing::Test {
|
|||||||
// This test ice restart by doing two offer answer exchanges. On the second
|
// This test ice restart by doing two offer answer exchanges. On the second
|
||||||
// exchange ice is restarted. The test verifies that the ufrag and password
|
// exchange ice is restarted. The test verifies that the ufrag and password
|
||||||
// in the offer and answer is changed.
|
// in the offer and answer is changed.
|
||||||
// If |dtls| is true, the test verifies that the finger print is not changed.
|
// If `dtls` is true, the test verifies that the finger print is not changed.
|
||||||
void TestIceRestart(bool dtls) {
|
void TestIceRestart(bool dtls) {
|
||||||
SetDtls(dtls);
|
SetDtls(dtls);
|
||||||
cricket::TransportOptions options;
|
cricket::TransportOptions options;
|
||||||
|
|||||||
@ -817,7 +817,7 @@ void TurnPort::OnResolveResult(rtc::AsyncResolverInterface* resolver) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the original server address in |resolved_address|. For TLS based
|
// Copy the original server address in `resolved_address`. For TLS based
|
||||||
// sockets we need hostname along with resolved address.
|
// sockets we need hostname along with resolved address.
|
||||||
rtc::SocketAddress resolved_address = server_address_.address;
|
rtc::SocketAddress resolved_address = server_address_.address;
|
||||||
if (resolver_->GetError() != 0 ||
|
if (resolver_->GetError() != 0 ||
|
||||||
@ -831,7 +831,7 @@ void TurnPort::OnResolveResult(rtc::AsyncResolverInterface* resolver) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Signal needs both resolved and unresolved address. After signal is sent
|
// Signal needs both resolved and unresolved address. After signal is sent
|
||||||
// we can copy resolved address back into |server_address_|.
|
// we can copy resolved address back into `server_address_`.
|
||||||
SignalResolvedServerAddress(this, server_address_.address, resolved_address);
|
SignalResolvedServerAddress(this, server_address_.address, resolved_address);
|
||||||
server_address_.address = resolved_address;
|
server_address_.address = resolved_address;
|
||||||
PrepareAddress();
|
PrepareAddress();
|
||||||
@ -1070,7 +1070,7 @@ void TurnPort::HandleChannelData(int channel_id,
|
|||||||
<< len;
|
<< len;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Allowing messages larger than |len|, as ChannelData can be padded.
|
// Allowing messages larger than `len`, as ChannelData can be padded.
|
||||||
|
|
||||||
TurnEntry* entry = FindEntry(channel_id);
|
TurnEntry* entry = FindEntry(channel_id);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
@ -1786,7 +1786,7 @@ TurnEntry::TurnEntry(TurnPort* port,
|
|||||||
ext_addr_(ext_addr),
|
ext_addr_(ext_addr),
|
||||||
state_(STATE_UNBOUND),
|
state_(STATE_UNBOUND),
|
||||||
remote_ufrag_(remote_ufrag) {
|
remote_ufrag_(remote_ufrag) {
|
||||||
// Creating permission for |ext_addr_|.
|
// Creating permission for `ext_addr_`.
|
||||||
SendCreatePermissionRequest(0);
|
SendCreatePermissionRequest(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1846,7 +1846,7 @@ void TurnEntry::OnCreatePermissionSuccess() {
|
|||||||
port_->SignalCreatePermissionResult(port_, ext_addr_,
|
port_->SignalCreatePermissionResult(port_, ext_addr_,
|
||||||
TURN_SUCCESS_RESULT_CODE);
|
TURN_SUCCESS_RESULT_CODE);
|
||||||
|
|
||||||
// If |state_| is STATE_BOUND, the permission will be refreshed
|
// If `state_` is STATE_BOUND, the permission will be refreshed
|
||||||
// by ChannelBindRequest.
|
// by ChannelBindRequest.
|
||||||
if (state_ != STATE_BOUND) {
|
if (state_ != STATE_BOUND) {
|
||||||
// Refresh the permission request about 1 minute before the permission
|
// Refresh the permission request about 1 minute before the permission
|
||||||
|
|||||||
@ -51,7 +51,7 @@ class TurnPort : public Port {
|
|||||||
STATE_DISCONNECTED, // TCP connection died, cannot send/receive any
|
STATE_DISCONNECTED, // TCP connection died, cannot send/receive any
|
||||||
// packets.
|
// packets.
|
||||||
};
|
};
|
||||||
// Create a TURN port using the shared UDP socket, |socket|.
|
// Create a TURN port using the shared UDP socket, `socket`.
|
||||||
static std::unique_ptr<TurnPort> Create(
|
static std::unique_ptr<TurnPort> Create(
|
||||||
rtc::Thread* thread,
|
rtc::Thread* thread,
|
||||||
rtc::PacketSocketFactory* factory,
|
rtc::PacketSocketFactory* factory,
|
||||||
@ -81,7 +81,7 @@ class TurnPort : public Port {
|
|||||||
thread, factory, network, socket, username, password, server_address,
|
thread, factory, network, socket, username, password, server_address,
|
||||||
credentials, server_priority, origin, customizer));
|
credentials, server_priority, origin, customizer));
|
||||||
}
|
}
|
||||||
// TODO(steveanton): Remove once downstream clients have moved to |Create|.
|
// TODO(steveanton): Remove once downstream clients have moved to `Create`.
|
||||||
static std::unique_ptr<TurnPort> CreateUnique(
|
static std::unique_ptr<TurnPort> CreateUnique(
|
||||||
rtc::Thread* thread,
|
rtc::Thread* thread,
|
||||||
rtc::PacketSocketFactory* factory,
|
rtc::PacketSocketFactory* factory,
|
||||||
@ -99,8 +99,8 @@ class TurnPort : public Port {
|
|||||||
customizer);
|
customizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a TURN port that will use a new socket, bound to |network| and
|
// Create a TURN port that will use a new socket, bound to `network` and
|
||||||
// using a port in the range between |min_port| and |max_port|.
|
// using a port in the range between `min_port` and `max_port`.
|
||||||
static std::unique_ptr<TurnPort> Create(
|
static std::unique_ptr<TurnPort> Create(
|
||||||
rtc::Thread* thread,
|
rtc::Thread* thread,
|
||||||
rtc::PacketSocketFactory* factory,
|
rtc::PacketSocketFactory* factory,
|
||||||
@ -136,7 +136,7 @@ class TurnPort : public Port {
|
|||||||
origin, tls_alpn_protocols, tls_elliptic_curves,
|
origin, tls_alpn_protocols, tls_elliptic_curves,
|
||||||
customizer, tls_cert_verifier));
|
customizer, tls_cert_verifier));
|
||||||
}
|
}
|
||||||
// TODO(steveanton): Remove once downstream clients have moved to |Create|.
|
// TODO(steveanton): Remove once downstream clients have moved to `Create`.
|
||||||
static std::unique_ptr<TurnPort> CreateUnique(
|
static std::unique_ptr<TurnPort> CreateUnique(
|
||||||
rtc::Thread* thread,
|
rtc::Thread* thread,
|
||||||
rtc::PacketSocketFactory* factory,
|
rtc::PacketSocketFactory* factory,
|
||||||
@ -248,7 +248,7 @@ class TurnPort : public Port {
|
|||||||
void set_credentials(const RelayCredentials& credentials) {
|
void set_credentials(const RelayCredentials& credentials) {
|
||||||
credentials_ = credentials;
|
credentials_ = credentials;
|
||||||
}
|
}
|
||||||
// Finds the turn entry with |address| and sets its channel id.
|
// Finds the turn entry with `address` and sets its channel id.
|
||||||
// Returns true if the entry is found.
|
// Returns true if the entry is found.
|
||||||
bool SetEntryChannelId(const rtc::SocketAddress& address, int channel_id);
|
bool SetEntryChannelId(const rtc::SocketAddress& address, int channel_id);
|
||||||
// Visible for testing.
|
// Visible for testing.
|
||||||
@ -363,12 +363,12 @@ class TurnPort : public Port {
|
|||||||
TurnEntry* FindEntry(int channel_id) const;
|
TurnEntry* FindEntry(int channel_id) const;
|
||||||
bool EntryExists(TurnEntry* e);
|
bool EntryExists(TurnEntry* e);
|
||||||
void DestroyEntry(TurnEntry* entry);
|
void DestroyEntry(TurnEntry* entry);
|
||||||
// Destroys the entry only if |timestamp| matches the destruction timestamp
|
// Destroys the entry only if `timestamp` matches the destruction timestamp
|
||||||
// in |entry|.
|
// in `entry`.
|
||||||
void DestroyEntryIfNotCancelled(TurnEntry* entry, int64_t timestamp);
|
void DestroyEntryIfNotCancelled(TurnEntry* entry, int64_t timestamp);
|
||||||
void ScheduleEntryDestruction(TurnEntry* entry);
|
void ScheduleEntryDestruction(TurnEntry* entry);
|
||||||
|
|
||||||
// Marks the connection with remote address |address| failed and
|
// Marks the connection with remote address `address` failed and
|
||||||
// pruned (a.k.a. write-timed-out). Returns true if a connection is found.
|
// pruned (a.k.a. write-timed-out). Returns true if a connection is found.
|
||||||
bool FailAndPruneConnection(const rtc::SocketAddress& address);
|
bool FailAndPruneConnection(const rtc::SocketAddress& address);
|
||||||
|
|
||||||
|
|||||||
@ -425,7 +425,7 @@ class TurnPortTest : public ::testing::Test,
|
|||||||
conn->state() == IceCandidatePairState::FAILED;
|
conn->state() == IceCandidatePairState::FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks that |turn_port_| has a nonempty set of connections and they are all
|
// Checks that `turn_port_` has a nonempty set of connections and they are all
|
||||||
// failed and pruned.
|
// failed and pruned.
|
||||||
bool CheckAllConnectionsFailedAndPruned() {
|
bool CheckAllConnectionsFailedAndPruned() {
|
||||||
auto& connections = turn_port_->connections();
|
auto& connections = turn_port_->connections();
|
||||||
@ -1090,8 +1090,8 @@ TEST_F(TurnPortTest, TestTurnAllocateNonceResetAfterAllocateMismatch) {
|
|||||||
CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr);
|
CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr);
|
||||||
|
|
||||||
// It is expected that the turn port will first get a nonce from the server
|
// It is expected that the turn port will first get a nonce from the server
|
||||||
// using timestamp |ts_before| but then get an allocate mismatch error and
|
// using timestamp `ts_before` but then get an allocate mismatch error and
|
||||||
// receive an even newer nonce based on the system clock. |ts_before| is
|
// receive an even newer nonce based on the system clock. `ts_before` is
|
||||||
// chosen so that the two NONCEs generated by the server will be different.
|
// chosen so that the two NONCEs generated by the server will be different.
|
||||||
int64_t ts_before = rtc::TimeMillis() - 1;
|
int64_t ts_before = rtc::TimeMillis() - 1;
|
||||||
std::string first_nonce =
|
std::string first_nonce =
|
||||||
@ -1722,7 +1722,7 @@ TEST_F(TurnPortTest, TestTurnCustomizerCount) {
|
|||||||
TestTurnSendData(PROTO_TLS);
|
TestTurnSendData(PROTO_TLS);
|
||||||
EXPECT_EQ(TLS_PROTOCOL_NAME, turn_port_->Candidates()[0].relay_protocol());
|
EXPECT_EQ(TLS_PROTOCOL_NAME, turn_port_->Candidates()[0].relay_protocol());
|
||||||
|
|
||||||
// There should have been at least turn_packets_.size() calls to |customizer|.
|
// There should have been at least turn_packets_.size() calls to `customizer`.
|
||||||
EXPECT_GE(customizer->modify_cnt_ + customizer->allow_channel_data_cnt_,
|
EXPECT_GE(customizer->modify_cnt_ + customizer->allow_channel_data_cnt_,
|
||||||
turn_packets_.size());
|
turn_packets_.size());
|
||||||
|
|
||||||
@ -1752,7 +1752,7 @@ TEST_F(TurnPortTest, TestTurnCustomizerDisallowChannelData) {
|
|||||||
TestTurnSendData(PROTO_TLS);
|
TestTurnSendData(PROTO_TLS);
|
||||||
EXPECT_EQ(TLS_PROTOCOL_NAME, turn_port_->Candidates()[0].relay_protocol());
|
EXPECT_EQ(TLS_PROTOCOL_NAME, turn_port_->Candidates()[0].relay_protocol());
|
||||||
|
|
||||||
// There should have been at least turn_packets_.size() calls to |customizer|.
|
// There should have been at least turn_packets_.size() calls to `customizer`.
|
||||||
EXPECT_GE(customizer->modify_cnt_, turn_packets_.size());
|
EXPECT_GE(customizer->modify_cnt_, turn_packets_.size());
|
||||||
|
|
||||||
// No channel data should be received.
|
// No channel data should be received.
|
||||||
@ -1782,7 +1782,7 @@ TEST_F(TurnPortTest, TestTurnCustomizerAddAttribute) {
|
|||||||
TestTurnSendData(PROTO_TLS);
|
TestTurnSendData(PROTO_TLS);
|
||||||
EXPECT_EQ(TLS_PROTOCOL_NAME, turn_port_->Candidates()[0].relay_protocol());
|
EXPECT_EQ(TLS_PROTOCOL_NAME, turn_port_->Candidates()[0].relay_protocol());
|
||||||
|
|
||||||
// There should have been at least turn_packets_.size() calls to |customizer|.
|
// There should have been at least turn_packets_.size() calls to `customizer`.
|
||||||
EXPECT_GE(customizer->modify_cnt_, turn_packets_.size());
|
EXPECT_GE(customizer->modify_cnt_, turn_packets_.size());
|
||||||
|
|
||||||
// Everything will be sent as messages since channel data is disallowed.
|
// Everything will be sent as messages since channel data is disallowed.
|
||||||
|
|||||||
@ -41,7 +41,7 @@ class TurnServerConnectionTest : public ::testing::Test {
|
|||||||
protected:
|
protected:
|
||||||
rtc::VirtualSocketServer vss_;
|
rtc::VirtualSocketServer vss_;
|
||||||
rtc::AutoSocketServerThread thread_;
|
rtc::AutoSocketServerThread thread_;
|
||||||
// Since this is constructed after |thread_|, it will pick up |threads_|'s
|
// Since this is constructed after `thread_`, it will pick up `threads_`'s
|
||||||
// socket server.
|
// socket server.
|
||||||
rtc::BasicPacketSocketFactory socket_factory_;
|
rtc::BasicPacketSocketFactory socket_factory_;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -830,7 +830,7 @@ void BasicPortAllocatorSession::OnNetworksChanged() {
|
|||||||
std::vector<rtc::Network*> failed_networks;
|
std::vector<rtc::Network*> failed_networks;
|
||||||
for (AllocationSequence* sequence : sequences_) {
|
for (AllocationSequence* sequence : sequences_) {
|
||||||
// Mark the sequence as "network failed" if its network is not in
|
// Mark the sequence as "network failed" if its network is not in
|
||||||
// |networks|.
|
// `networks`.
|
||||||
if (!sequence->network_failed() &&
|
if (!sequence->network_failed() &&
|
||||||
!absl::c_linear_search(networks, sequence->network())) {
|
!absl::c_linear_search(networks, sequence->network())) {
|
||||||
sequence->OnNetworkFailed();
|
sequence->OnNetworkFailed();
|
||||||
@ -1026,7 +1026,7 @@ bool BasicPortAllocatorSession::PruneTurnPorts(Port* newly_pairable_turn_port) {
|
|||||||
// are considered the same network here.
|
// are considered the same network here.
|
||||||
const std::string& network_name = newly_pairable_turn_port->Network()->name();
|
const std::string& network_name = newly_pairable_turn_port->Network()->name();
|
||||||
Port* best_turn_port = GetBestTurnPortForNetwork(network_name);
|
Port* best_turn_port = GetBestTurnPortForNetwork(network_name);
|
||||||
// |port| is already in the list of ports, so the best port cannot be nullptr.
|
// `port` is already in the list of ports, so the best port cannot be nullptr.
|
||||||
RTC_CHECK(best_turn_port != nullptr);
|
RTC_CHECK(best_turn_port != nullptr);
|
||||||
|
|
||||||
bool pruned = false;
|
bool pruned = false;
|
||||||
@ -1241,7 +1241,7 @@ void AllocationSequence::Init() {
|
|||||||
udp_socket_->SignalReadPacket.connect(this,
|
udp_socket_->SignalReadPacket.connect(this,
|
||||||
&AllocationSequence::OnReadPacket);
|
&AllocationSequence::OnReadPacket);
|
||||||
}
|
}
|
||||||
// Continuing if |udp_socket_| is NULL, as local TCP and RelayPort using TCP
|
// Continuing if `udp_socket_` is NULL, as local TCP and RelayPort using TCP
|
||||||
// are next available options to setup a communication channel.
|
// are next available options to setup a communication channel.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1457,7 +1457,7 @@ void AllocationSequence::CreateTCPPorts() {
|
|||||||
session_->allocator()->allow_tcp_listen());
|
session_->allocator()->allow_tcp_listen());
|
||||||
if (port) {
|
if (port) {
|
||||||
session_->AddAllocatedPort(port.release(), this, true);
|
session_->AddAllocatedPort(port.release(), this, true);
|
||||||
// Since TCPPort is not created using shared socket, |port| will not be
|
// Since TCPPort is not created using shared socket, `port` will not be
|
||||||
// added to the dequeue.
|
// added to the dequeue.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1486,7 +1486,7 @@ void AllocationSequence::CreateStunPorts() {
|
|||||||
session_->allocator()->stun_candidate_keepalive_interval());
|
session_->allocator()->stun_candidate_keepalive_interval());
|
||||||
if (port) {
|
if (port) {
|
||||||
session_->AddAllocatedPort(port.release(), this, true);
|
session_->AddAllocatedPort(port.release(), this, true);
|
||||||
// Since StunPort is not created using shared socket, |port| will not be
|
// Since StunPort is not created using shared socket, `port` will not be
|
||||||
// added to the dequeue.
|
// added to the dequeue.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -255,7 +255,7 @@ class RTC_EXPORT BasicPortAllocatorSession : public PortAllocatorSession {
|
|||||||
void PrunePortsAndRemoveCandidates(
|
void PrunePortsAndRemoveCandidates(
|
||||||
const std::vector<PortData*>& port_data_list);
|
const std::vector<PortData*>& port_data_list);
|
||||||
// Gets filtered and sanitized candidates generated from a port and
|
// Gets filtered and sanitized candidates generated from a port and
|
||||||
// append to |candidates|.
|
// append to `candidates`.
|
||||||
void GetCandidatesFromPort(const PortData& data,
|
void GetCandidatesFromPort(const PortData& data,
|
||||||
std::vector<Candidate>* candidates) const;
|
std::vector<Candidate>* candidates) const;
|
||||||
Port* GetBestTurnPortForNetwork(const std::string& network_name) const;
|
Port* GetBestTurnPortForNetwork(const std::string& network_name) const;
|
||||||
@ -287,7 +287,7 @@ class RTC_EXPORT BasicPortAllocatorSession : public PortAllocatorSession {
|
|||||||
// Records configuration information useful in creating ports.
|
// Records configuration information useful in creating ports.
|
||||||
// TODO(deadbeef): Rename "relay" to "turn_server" in this struct.
|
// TODO(deadbeef): Rename "relay" to "turn_server" in this struct.
|
||||||
struct RTC_EXPORT PortConfiguration {
|
struct RTC_EXPORT PortConfiguration {
|
||||||
// TODO(jiayl): remove |stun_address| when Chrome is updated.
|
// TODO(jiayl): remove `stun_address` when Chrome is updated.
|
||||||
rtc::SocketAddress stun_address;
|
rtc::SocketAddress stun_address;
|
||||||
ServerAddresses stun_servers;
|
ServerAddresses stun_servers;
|
||||||
std::string username;
|
std::string username;
|
||||||
@ -338,7 +338,7 @@ class AllocationSequence : public sigslot::has_slots<> {
|
|||||||
|
|
||||||
// kInit --> kRunning --> {kCompleted|kStopped}
|
// kInit --> kRunning --> {kCompleted|kStopped}
|
||||||
};
|
};
|
||||||
// |port_allocation_complete_callback| is called when AllocationSequence is
|
// `port_allocation_complete_callback` is called when AllocationSequence is
|
||||||
// done with allocating ports. This signal is useful when port allocation
|
// done with allocating ports. This signal is useful when port allocation
|
||||||
// fails which doesn't result in any candidates. Using this signal
|
// fails which doesn't result in any candidates. Using this signal
|
||||||
// BasicPortAllocatorSession can send its candidate discovery conclusion
|
// BasicPortAllocatorSession can send its candidate discovery conclusion
|
||||||
@ -409,7 +409,7 @@ class AllocationSequence : public sigslot::has_slots<> {
|
|||||||
int phase_;
|
int phase_;
|
||||||
std::function<void()> port_allocation_complete_callback_;
|
std::function<void()> port_allocation_complete_callback_;
|
||||||
// This counter is sampled and passed together with tasks when tasks are
|
// This counter is sampled and passed together with tasks when tasks are
|
||||||
// posted. If the sampled counter doesn't match |epoch_| on reception, the
|
// posted. If the sampled counter doesn't match `epoch_` on reception, the
|
||||||
// posted task is ignored.
|
// posted task is ignored.
|
||||||
int epoch_ = 0;
|
int epoch_ = 0;
|
||||||
webrtc::ScopedTaskSafety safety_;
|
webrtc::ScopedTaskSafety safety_;
|
||||||
|
|||||||
@ -184,7 +184,7 @@ class BasicPortAllocatorTestBase : public ::testing::Test,
|
|||||||
// different from the route to the STUN server (the default route).
|
// different from the route to the STUN server (the default route).
|
||||||
void AddInterfaceAsDefaultRoute(const SocketAddress& addr) {
|
void AddInterfaceAsDefaultRoute(const SocketAddress& addr) {
|
||||||
AddInterface(addr);
|
AddInterface(addr);
|
||||||
// When a binding comes from the any address, the |addr| will be used as the
|
// When a binding comes from the any address, the `addr` will be used as the
|
||||||
// srflx address.
|
// srflx address.
|
||||||
vss_->SetDefaultRoute(addr.ipaddr());
|
vss_->SetDefaultRoute(addr.ipaddr());
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ class BasicPortAllocatorTestBase : public ::testing::Test,
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if the addresses are the same, or the port is 0 in |pattern|
|
// Return true if the addresses are the same, or the port is 0 in `pattern`
|
||||||
// (acting as a wildcard) and the IPs are the same.
|
// (acting as a wildcard) and the IPs are the same.
|
||||||
// Even with a wildcard port, the port of the address should be nonzero if
|
// Even with a wildcard port, the port of the address should be nonzero if
|
||||||
// the IP is nonzero.
|
// the IP is nonzero.
|
||||||
@ -377,8 +377,8 @@ class BasicPortAllocatorTestBase : public ::testing::Test,
|
|||||||
EXPECT_TRUE(session->CandidatesAllocationDone());
|
EXPECT_TRUE(session->CandidatesAllocationDone());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if all ports allocated have send-buffer size |expected|. If
|
// Check if all ports allocated have send-buffer size `expected`. If
|
||||||
// |expected| == -1, check if GetOptions returns SOCKET_ERROR.
|
// `expected` == -1, check if GetOptions returns SOCKET_ERROR.
|
||||||
void CheckSendBufferSizesOfAllPorts(int expected) {
|
void CheckSendBufferSizesOfAllPorts(int expected) {
|
||||||
std::vector<PortInterface*>::iterator it;
|
std::vector<PortInterface*>::iterator it;
|
||||||
for (it = ports_.begin(); it < ports_.end(); ++it) {
|
for (it = ports_.begin(); it < ports_.end(); ++it) {
|
||||||
@ -511,8 +511,8 @@ class BasicPortAllocatorTest : public FakeClockBase,
|
|||||||
public BasicPortAllocatorTestBase {
|
public BasicPortAllocatorTestBase {
|
||||||
public:
|
public:
|
||||||
// This function starts the port/address gathering and check the existence of
|
// This function starts the port/address gathering and check the existence of
|
||||||
// candidates as specified. When |expect_stun_candidate| is true,
|
// candidates as specified. When `expect_stun_candidate` is true,
|
||||||
// |stun_candidate_addr| carries the expected reflective address, which is
|
// `stun_candidate_addr` carries the expected reflective address, which is
|
||||||
// also the related address for TURN candidate if it is expected. Otherwise,
|
// also the related address for TURN candidate if it is expected. Otherwise,
|
||||||
// it should be ignore.
|
// it should be ignore.
|
||||||
void CheckDisableAdapterEnumeration(
|
void CheckDisableAdapterEnumeration(
|
||||||
@ -600,7 +600,7 @@ class BasicPortAllocatorTest : public FakeClockBase,
|
|||||||
EXPECT_EQ(0, CountPorts(ports_, "relay", PROTO_UDP, kClientAddr));
|
EXPECT_EQ(0, CountPorts(ports_, "relay", PROTO_UDP, kClientAddr));
|
||||||
|
|
||||||
// Now that we remove candidates when a TURN port is pruned, there will be
|
// Now that we remove candidates when a TURN port is pruned, there will be
|
||||||
// exactly 3 candidates in both |candidates_| and |ready_candidates|.
|
// exactly 3 candidates in both `candidates_` and `ready_candidates`.
|
||||||
EXPECT_EQ(3U, candidates_.size());
|
EXPECT_EQ(3U, candidates_.size());
|
||||||
const std::vector<Candidate>& ready_candidates =
|
const std::vector<Candidate>& ready_candidates =
|
||||||
session_->ReadyCandidates();
|
session_->ReadyCandidates();
|
||||||
@ -631,9 +631,9 @@ class BasicPortAllocatorTest : public FakeClockBase,
|
|||||||
kDefaultAllocationTimeout, fake_clock);
|
kDefaultAllocationTimeout, fake_clock);
|
||||||
// Only 2 ports (one STUN and one TURN) are actually being used.
|
// Only 2 ports (one STUN and one TURN) are actually being used.
|
||||||
EXPECT_EQ(2U, session_->ReadyPorts().size());
|
EXPECT_EQ(2U, session_->ReadyPorts().size());
|
||||||
// We have verified that each port, when it is added to |ports_|, it is
|
// We have verified that each port, when it is added to `ports_`, it is
|
||||||
// found in |ready_ports|, and when it is pruned, it is not found in
|
// found in `ready_ports`, and when it is pruned, it is not found in
|
||||||
// |ready_ports|, so we only need to verify the content in one of them.
|
// `ready_ports`, so we only need to verify the content in one of them.
|
||||||
EXPECT_EQ(2U, ports_.size());
|
EXPECT_EQ(2U, ports_.size());
|
||||||
EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr));
|
EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr));
|
||||||
int num_udp_ports = tcp_pruned ? 1 : 0;
|
int num_udp_ports = tcp_pruned ? 1 : 0;
|
||||||
@ -642,11 +642,11 @@ class BasicPortAllocatorTest : public FakeClockBase,
|
|||||||
EXPECT_EQ(1 - num_udp_ports,
|
EXPECT_EQ(1 - num_udp_ports,
|
||||||
CountPorts(ports_, "relay", PROTO_TCP, kClientAddr));
|
CountPorts(ports_, "relay", PROTO_TCP, kClientAddr));
|
||||||
|
|
||||||
// Now that we remove candidates when a TURN port is pruned, |candidates_|
|
// Now that we remove candidates when a TURN port is pruned, `candidates_`
|
||||||
// should only contains two candidates regardless whether the TCP TURN port
|
// should only contains two candidates regardless whether the TCP TURN port
|
||||||
// is created before or after the UDP turn port.
|
// is created before or after the UDP turn port.
|
||||||
EXPECT_EQ(2U, candidates_.size());
|
EXPECT_EQ(2U, candidates_.size());
|
||||||
// There will only be 2 candidates in |ready_candidates| because it only
|
// There will only be 2 candidates in `ready_candidates` because it only
|
||||||
// includes the candidates in the ready ports.
|
// includes the candidates in the ready ports.
|
||||||
const std::vector<Candidate>& ready_candidates =
|
const std::vector<Candidate>& ready_candidates =
|
||||||
session_->ReadyCandidates();
|
session_->ReadyCandidates();
|
||||||
@ -700,7 +700,7 @@ class BasicPortAllocatorTest : public FakeClockBase,
|
|||||||
EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientIPv6Addr2));
|
EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientIPv6Addr2));
|
||||||
|
|
||||||
// Now that we remove candidates when TURN ports are pruned, there will be
|
// Now that we remove candidates when TURN ports are pruned, there will be
|
||||||
// exactly 10 candidates in |candidates_|.
|
// exactly 10 candidates in `candidates_`.
|
||||||
EXPECT_EQ(10U, candidates_.size());
|
EXPECT_EQ(10U, candidates_.size());
|
||||||
const std::vector<Candidate>& ready_candidates =
|
const std::vector<Candidate>& ready_candidates =
|
||||||
session_->ReadyCandidates();
|
session_->ReadyCandidates();
|
||||||
|
|||||||
@ -61,7 +61,7 @@ class StunProber::Requester : public sigslot::has_slots<> {
|
|||||||
void ProcessResponse(const char* buf, size_t buf_len);
|
void ProcessResponse(const char* buf, size_t buf_len);
|
||||||
};
|
};
|
||||||
|
|
||||||
// StunProber provides |server_ips| for Requester to probe. For shared
|
// StunProber provides `server_ips` for Requester to probe. For shared
|
||||||
// socket mode, it'll be all the resolved IP addresses. For non-shared mode,
|
// socket mode, it'll be all the resolved IP addresses. For non-shared mode,
|
||||||
// it'll just be a single address.
|
// it'll just be a single address.
|
||||||
Requester(StunProber* prober,
|
Requester(StunProber* prober,
|
||||||
|
|||||||
@ -70,9 +70,9 @@ class RTC_EXPORT StunProber : public sigslot::has_slots<> {
|
|||||||
Stats();
|
Stats();
|
||||||
~Stats();
|
~Stats();
|
||||||
|
|
||||||
// |raw_num_request_sent| is the total number of requests
|
// `raw_num_request_sent` is the total number of requests
|
||||||
// sent. |num_request_sent| is the count of requests against a server where
|
// sent. `num_request_sent` is the count of requests against a server where
|
||||||
// we see at least one response. |num_request_sent| is designed to protect
|
// we see at least one response. `num_request_sent` is designed to protect
|
||||||
// against DNS resolution failure or the STUN server is not responsive
|
// against DNS resolution failure or the STUN server is not responsive
|
||||||
// which could skew the result.
|
// which could skew the result.
|
||||||
int raw_num_request_sent = 0;
|
int raw_num_request_sent = 0;
|
||||||
@ -101,16 +101,16 @@ class RTC_EXPORT StunProber : public sigslot::has_slots<> {
|
|||||||
const rtc::NetworkManager::NetworkList& networks);
|
const rtc::NetworkManager::NetworkList& networks);
|
||||||
~StunProber() override;
|
~StunProber() override;
|
||||||
|
|
||||||
// Begin performing the probe test against the |servers|. If
|
// Begin performing the probe test against the `servers`. If
|
||||||
// |shared_socket_mode| is false, each request will be done with a new socket.
|
// `shared_socket_mode` is false, each request will be done with a new socket.
|
||||||
// Otherwise, a unique socket will be used for a single round of requests
|
// Otherwise, a unique socket will be used for a single round of requests
|
||||||
// against all resolved IPs. No single socket will be used against a given IP
|
// against all resolved IPs. No single socket will be used against a given IP
|
||||||
// more than once. The interval of requests will be as close to the requested
|
// more than once. The interval of requests will be as close to the requested
|
||||||
// inter-probe interval |stun_ta_interval_ms| as possible. After sending out
|
// inter-probe interval `stun_ta_interval_ms` as possible. After sending out
|
||||||
// the last scheduled request, the probe will wait |timeout_ms| for request
|
// the last scheduled request, the probe will wait `timeout_ms` for request
|
||||||
// responses and then call |finish_callback|. |requests_per_ip| indicates how
|
// responses and then call `finish_callback`. `requests_per_ip` indicates how
|
||||||
// many requests should be tried for each resolved IP address. In shared mode,
|
// many requests should be tried for each resolved IP address. In shared mode,
|
||||||
// (the number of sockets to be created) equals to |requests_per_ip|. In
|
// (the number of sockets to be created) equals to `requests_per_ip`. In
|
||||||
// non-shared mode, (the number of sockets) equals to requests_per_ip * (the
|
// non-shared mode, (the number of sockets) equals to requests_per_ip * (the
|
||||||
// number of resolved IP addresses). TODO(guoweis): Remove this once
|
// number of resolved IP addresses). TODO(guoweis): Remove this once
|
||||||
// everything moved to Prepare() and Run().
|
// everything moved to Prepare() and Run().
|
||||||
@ -133,7 +133,7 @@ class RTC_EXPORT StunProber : public sigslot::has_slots<> {
|
|||||||
// Start to send out the STUN probes.
|
// Start to send out the STUN probes.
|
||||||
bool Start(StunProber::Observer* observer);
|
bool Start(StunProber::Observer* observer);
|
||||||
|
|
||||||
// Method to retrieve the Stats once |finish_callback| is invoked. Returning
|
// Method to retrieve the Stats once `finish_callback` is invoked. Returning
|
||||||
// false when the result is inconclusive, for example, whether it's behind a
|
// false when the result is inconclusive, for example, whether it's behind a
|
||||||
// NAT or not.
|
// NAT or not.
|
||||||
bool GetStats(Stats* stats) const;
|
bool GetStats(Stats* stats) const;
|
||||||
@ -186,7 +186,7 @@ class RTC_EXPORT StunProber : public sigslot::has_slots<> {
|
|||||||
bool SendNextRequest();
|
bool SendNextRequest();
|
||||||
|
|
||||||
// Will be invoked in 1ms intervals and schedule the next request from the
|
// Will be invoked in 1ms intervals and schedule the next request from the
|
||||||
// |current_requester_| if the time has passed for another request.
|
// `current_requester_` if the time has passed for another request.
|
||||||
void MaybeScheduleStunRequests();
|
void MaybeScheduleStunRequests();
|
||||||
|
|
||||||
void ReportOnPrepared(StunProber::Status status);
|
void ReportOnPrepared(StunProber::Status status);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user