Revert 7093: "Implementing ICE Transports type handling in libjingle transport."

TBR=mallinath@webrtc.org
BUG=N/A

Review URL: https://webrtc-codereview.appspot.com/28419004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7112 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrike@webrtc.org
2014-09-08 22:46:28 +00:00
parent 519c9e207d
commit 8b0b21161a
8 changed files with 30 additions and 239 deletions

View File

@@ -47,15 +47,13 @@ using rtc::CreateRandomString;
namespace {
enum {
MSG_CONFIG_START,
MSG_CONFIG_READY,
MSG_ALLOCATE,
MSG_ALLOCATION_PHASE,
MSG_SHAKE,
MSG_SEQUENCEOBJECTS_CREATED,
MSG_CONFIG_STOP,
};
const uint32 MSG_CONFIG_START = 1;
const uint32 MSG_CONFIG_READY = 2;
const uint32 MSG_ALLOCATE = 3;
const uint32 MSG_ALLOCATION_PHASE = 4;
const uint32 MSG_SHAKE = 5;
const uint32 MSG_SEQUENCEOBJECTS_CREATED = 6;
const uint32 MSG_CONFIG_STOP = 7;
const int PHASE_UDP = 0;
const int PHASE_RELAY = 1;
@@ -230,11 +228,10 @@ BasicPortAllocator::~BasicPortAllocator() {
PortAllocatorSession *BasicPortAllocator::CreateSessionInternal(
const std::string& content_name, int component,
const std::string& ice_ufrag, const std::string& ice_pwd) {
return new BasicPortAllocatorSession(
this, content_name, component, ice_ufrag, ice_pwd);
return new BasicPortAllocatorSession(this, content_name, component,
ice_ufrag, ice_pwd);
}
// BasicPortAllocatorSession
BasicPortAllocatorSession::BasicPortAllocatorSession(
BasicPortAllocator *allocator,
@@ -533,10 +530,8 @@ void BasicPortAllocatorSession::OnCandidateReady(
// Send candidates whose protocol is enabled.
std::vector<Candidate> candidates;
ProtocolType pvalue;
bool candidate_allowed_to_send = CheckCandidateFilter(c);
if (StringToProto(c.protocol().c_str(), &pvalue) &&
data->sequence()->ProtocolEnabled(pvalue) &&
candidate_allowed_to_send) {
data->sequence()->ProtocolEnabled(pvalue)) {
candidates.push_back(c);
}
@@ -547,9 +542,7 @@ void BasicPortAllocatorSession::OnCandidateReady(
// Moving to READY state as we have atleast one candidate from the port.
// Since this port has atleast one candidate we should forward this port
// to listners, to allow connections from this port.
// Also we should make sure that candidate gathered from this port is allowed
// to send outside.
if (!data->ready() && candidate_allowed_to_send) {
if (!data->ready()) {
data->set_ready();
SignalPortReady(this, port);
}
@@ -595,8 +588,6 @@ void BasicPortAllocatorSession::OnProtocolEnabled(AllocationSequence* seq,
const std::vector<Candidate>& potentials = it->port()->Candidates();
for (size_t i = 0; i < potentials.size(); ++i) {
if (!CheckCandidateFilter(potentials[i]))
continue;
ProtocolType pvalue;
if (!StringToProto(potentials[i].protocol().c_str(), &pvalue))
continue;
@@ -611,31 +602,6 @@ void BasicPortAllocatorSession::OnProtocolEnabled(AllocationSequence* seq,
}
}
bool BasicPortAllocatorSession::CheckCandidateFilter(const Candidate& c) {
uint32 filter = allocator_->candidate_filter();
bool allowed = false;
if (filter & CF_RELAY) {
allowed |= (c.type() == RELAY_PORT_TYPE);
}
if (filter & CF_REFLEXIVE) {
// We allow host candidates if the filter allows server-reflexive candidates
// and the candidate is a public IP. Because we don't generate
// server-reflexive candidates if they have the same IP as the host
// candidate (i.e. when the host candidate is a public IP), filtering to
// only server-reflexive candidates won't work right when the host
// candidates have public IPs.
allowed |= (c.type() == STUN_PORT_TYPE) ||
(c.type() == LOCAL_PORT_TYPE && !c.address().IsPrivateIP());
}
if (filter & CF_HOST) {
allowed |= (c.type() == LOCAL_PORT_TYPE);
}
return allowed;
}
void BasicPortAllocatorSession::OnPortAllocationComplete(
AllocationSequence* seq) {
// Send candidate allocation complete signal if all ports are done.

View File

@@ -160,6 +160,7 @@ class BasicPortAllocatorSession : public PortAllocatorSession,
void set_ready() { ASSERT(state_ == STATE_INIT); state_ = STATE_READY; }
void set_complete() {
ASSERT(state_ == STATE_READY);
state_ = STATE_COMPLETE;
}
void set_error() {
@@ -200,8 +201,6 @@ class BasicPortAllocatorSession : public PortAllocatorSession,
void OnPortAllocationComplete(AllocationSequence* seq);
PortData* FindPort(Port* port);
bool CheckCandidateFilter(const Candidate& c);
BasicPortAllocator* allocator_;
rtc::Thread* network_thread_;
rtc::scoped_ptr<rtc::PacketSocketFactory> owned_socket_factory_;

View File

@@ -53,7 +53,6 @@ using rtc::SocketAddress;
using rtc::Thread;
static const SocketAddress kClientAddr("11.11.11.11", 0);
static const SocketAddress kPrivateAddr("192.168.1.11", 0);
static const SocketAddress kClientIPv6Addr(
"2401:fa00:4:1000:be30:5bff:fee5:c3", 0);
static const SocketAddress kClientAddr2("22.22.22.22", 0);
@@ -539,7 +538,7 @@ TEST_F(PortAllocatorTest, TestCandidatePriorityOfMultipleInterfaces) {
// Test to verify ICE restart process.
TEST_F(PortAllocatorTest, TestGetAllPortsRestarts) {
AddInterface(kClientAddr);
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
EXPECT_TRUE(CreateSession(1));
session_->StartGettingPorts();
EXPECT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout);
EXPECT_EQ(4U, ports_.size());
@@ -547,78 +546,6 @@ TEST_F(PortAllocatorTest, TestGetAllPortsRestarts) {
// TODO - Extend this to verify ICE restart.
}
// Test ICE candidate filter mechanism with options Relay/Host/Reflexive.
TEST_F(PortAllocatorTest, TestCandidateFilterWithRelayOnly) {
AddInterface(kClientAddr);
allocator().set_candidate_filter(cricket::CF_RELAY);
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
session_->StartGettingPorts();
EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
// Using GTURN, we will have 4 candidates.
EXPECT_EQ(4U, candidates_.size());
EXPECT_EQ(1U, ports_.size()); // Only Relay port will be in ready state.
for (size_t i = 0; i < candidates_.size(); ++i) {
EXPECT_EQ(cricket::RELAY_PORT_TYPE, candidates_[i].type());
}
}
TEST_F(PortAllocatorTest, TestCandidateFilterWithHostOnly) {
AddInterface(kClientAddr);
allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
allocator().set_candidate_filter(cricket::CF_HOST);
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
session_->StartGettingPorts();
EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
EXPECT_EQ(2U, candidates_.size()); // Host UDP/TCP candidates only.
EXPECT_EQ(2U, ports_.size()); // UDP/TCP ports only.
for (size_t i = 0; i < candidates_.size(); ++i) {
EXPECT_EQ(cricket::LOCAL_PORT_TYPE, candidates_[i].type());
}
}
// Host is behind the NAT.
TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnly) {
AddInterface(kPrivateAddr);
rtc::scoped_ptr<rtc::NATServer> nat_server(
CreateNatServer(kNatAddr, rtc::NAT_OPEN_CONE));
ServerAddresses stun_servers;
stun_servers.insert(kStunAddr);
allocator_.reset(new cricket::BasicPortAllocator(
&network_manager_, &nat_socket_factory_, stun_servers));
allocator().set_step_delay(cricket::kMinimumStepDelay);
allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
allocator().set_candidate_filter(cricket::CF_REFLEXIVE);
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
session_->StartGettingPorts();
EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
// Host is behind NAT, no private address will be exposed. Hence only UDP
// port with STUN candidate will be sent outside.
EXPECT_EQ(1U, candidates_.size()); // Only STUN candidate.
EXPECT_EQ(1U, ports_.size()); // Only UDP port will be in ready state.
for (size_t i = 0; i < candidates_.size(); ++i) {
EXPECT_EQ(cricket::STUN_PORT_TYPE, candidates_[i].type());
}
}
// Host is not behind the NAT.
TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnlyAndNoNAT) {
AddInterface(kClientAddr);
allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
allocator().set_candidate_filter(cricket::CF_REFLEXIVE);
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
session_->StartGettingPorts();
EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
// Host has a public address, both UDP and TCP candidates will be exposed.
EXPECT_EQ(2U, candidates_.size()); // Local UDP + TCP candidate.
EXPECT_EQ(2U, ports_.size()); // UDP and TCP ports will be in ready state.
for (size_t i = 0; i < candidates_.size(); ++i) {
EXPECT_EQ(cricket::LOCAL_PORT_TYPE, candidates_[i].type());
}
}
TEST_F(PortAllocatorTest, TestBasicMuxFeatures) {
AddInterface(kClientAddr);
allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_BUNDLE);