Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Unified Diff: webrtc/p2p/base/port.cc

Issue 2989303002: Make Port (and subclasses) fully "Network"-based, instead of IP-based. (Closed)
Patch Set: Add back Port constructor that takes IP for backwards compatibility. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/port.cc
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc
index a1016332dee478aa26920dd5e9c25fcec6b4fe35..40b2502f65a0e8b652fa0883effebf25e580768d 100644
--- a/webrtc/p2p/base/port.cc
+++ b/webrtc/p2p/base/port.cc
@@ -145,7 +145,6 @@ Port::Port(rtc::Thread* thread,
const std::string& type,
rtc::PacketSocketFactory* factory,
rtc::Network* network,
- const rtc::IPAddress& ip,
const std::string& username_fragment,
const std::string& password)
: thread_(thread),
@@ -153,7 +152,6 @@ Port::Port(rtc::Thread* thread,
type_(type),
send_retransmit_count_attribute_(false),
network_(network),
- ip_(ip),
min_port_(0),
max_port_(0),
component_(ICE_CANDIDATE_COMPONENT_DEFAULT),
@@ -172,7 +170,6 @@ Port::Port(rtc::Thread* thread,
const std::string& type,
rtc::PacketSocketFactory* factory,
rtc::Network* network,
- const rtc::IPAddress& ip,
uint16_t min_port,
uint16_t max_port,
const std::string& username_fragment,
@@ -182,7 +179,6 @@ Port::Port(rtc::Thread* thread,
type_(type),
send_retransmit_count_attribute_(false),
network_(network),
- ip_(ip),
min_port_(min_port),
max_port_(max_port),
component_(ICE_CANDIDATE_COMPONENT_DEFAULT),
@@ -471,14 +467,15 @@ bool Port::GetStunMessage(const char* data,
}
bool Port::IsCompatibleAddress(const rtc::SocketAddress& addr) {
- int family = ip().family();
+ // Get a representative IP for the Network this port is configured to use.
+ rtc::IPAddress ip = network_->GetBestIP();
// We use single-stack sockets, so families must match.
- if (addr.family() != family) {
+ if (addr.family() != ip.family()) {
return false;
}
// Link-local IPv6 ports can only connect to other link-local IPv6 ports.
- if (family == AF_INET6 &&
- (IPIsLinkLocal(ip()) != IPIsLinkLocal(addr.ipaddr()))) {
+ if (ip.family() == AF_INET6 &&
+ (IPIsLinkLocal(ip) != IPIsLinkLocal(addr.ipaddr()))) {
return false;
}
return true;
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698