10e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org/* 20e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * libjingle 30e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * Copyright 2004--2005, Google Inc. 40e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 50e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * Redistribution and use in source and binary forms, with or without 60e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * modification, are permitted provided that the following conditions are met: 70e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 80e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 1. Redistributions of source code must retain the above copyright notice, 90e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * this list of conditions and the following disclaimer. 100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 2. Redistributions in binary form must reproduce the above copyright notice, 110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * this list of conditions and the following disclaimer in the documentation 120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * and/or other materials provided with the distribution. 130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 3. The name of the author may not be used to endorse or promote products 140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * derived from this software without specific prior written permission. 150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org */ 270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#ifndef TALK_P2P_CLIENT_BASICPORTALLOCATOR_H_ 290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#define TALK_P2P_CLIENT_BASICPORTALLOCATOR_H_ 300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include <string> 320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include <vector> 330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 34cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "talk/p2p/base/port.h" 35cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "talk/p2p/base/portallocator.h" 362a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/messagequeue.h" 372a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/network.h" 382a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/scoped_ptr.h" 392a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/thread.h" 400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgnamespace cricket { 420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgstruct RelayCredentials { 440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org RelayCredentials() {} 450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org RelayCredentials(const std::string& username, 460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const std::string& password) 470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org : username(username), 480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org password(password) { 490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org std::string username; 520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org std::string password; 530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}; 540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgtypedef std::vector<ProtocolAddress> PortList; 560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgstruct RelayServerConfig { 5788853c77c292bbaeb93f79bfe1dee6f95f70b384mallinath@webrtc.org RelayServerConfig(RelayType type) : type(type), priority(0) {} 580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org RelayType type; 600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org PortList ports; 610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org RelayCredentials credentials; 6288853c77c292bbaeb93f79bfe1dee6f95f70b384mallinath@webrtc.org int priority; 630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}; 640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass BasicPortAllocator : public PortAllocator { 660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public: 672a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org BasicPortAllocator(rtc::NetworkManager* network_manager, 682a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::PacketSocketFactory* socket_factory); 692a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org explicit BasicPortAllocator(rtc::NetworkManager* network_manager); 702a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org BasicPortAllocator(rtc::NetworkManager* network_manager, 712a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::PacketSocketFactory* socket_factory, 72459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org const ServerAddresses& stun_servers); 732a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org BasicPortAllocator(rtc::NetworkManager* network_manager, 74459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org const ServerAddresses& stun_servers, 752a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org const rtc::SocketAddress& relay_server_udp, 762a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org const rtc::SocketAddress& relay_server_tcp, 772a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org const rtc::SocketAddress& relay_server_ssl); 780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual ~BasicPortAllocator(); 790e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 802a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::NetworkManager* network_manager() { return network_manager_; } 810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // If socket_factory() is set to NULL each PortAllocatorSession 830e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // creates its own socket factory. 842a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } 850e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 86459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org const ServerAddresses& stun_servers() const { 87459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org return stun_servers_; 880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 890e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const std::vector<RelayServerConfig>& relays() const { 910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org return relays_; 920e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 930e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void AddRelay(const RelayServerConfig& relay) { 940e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org relays_.push_back(relay); 950e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 960e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual PortAllocatorSession* CreateSessionInternal( 980e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const std::string& content_name, 990e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int component, 1000e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const std::string& ice_ufrag, 1010e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const std::string& ice_pwd); 1020e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1030e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org private: 1040e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void Construct(); 1050e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1062a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::NetworkManager* network_manager_; 1072a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::PacketSocketFactory* socket_factory_; 108459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org const ServerAddresses stun_servers_; 1090e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org std::vector<RelayServerConfig> relays_; 1100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool allow_tcp_listen_; 1110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}; 1120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgstruct PortConfiguration; 1140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass AllocationSequence; 1150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass BasicPortAllocatorSession : public PortAllocatorSession, 1172a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org public rtc::MessageHandler { 1180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public: 1190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org BasicPortAllocatorSession(BasicPortAllocator* allocator, 1200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const std::string& content_name, 1210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int component, 1220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const std::string& ice_ufrag, 1230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const std::string& ice_pwd); 1240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org ~BasicPortAllocatorSession(); 1250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual BasicPortAllocator* allocator() { return allocator_; } 1272a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::Thread* network_thread() { return network_thread_; } 1282a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } 1290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void StartGettingPorts(); 1310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void StopGettingPorts(); 1320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual bool IsGettingPorts() { return running_; } 1330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org protected: 1350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Starts the process of getting the port configurations. 1360e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void GetPortConfigurations(); 1370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Adds a port configuration that is now ready. Once we have one for each 1390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // network (or a timeout occurs), we will start allocating ports. 1400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void ConfigReady(PortConfiguration* config); 1410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // MessageHandler. Can be overriden if message IDs do not conflict. 1432a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org virtual void OnMessage(rtc::Message *message); 1440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org private: 1460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org class PortData { 1470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public: 1480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org PortData() : port_(NULL), sequence_(NULL), state_(STATE_INIT) {} 1490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org PortData(Port* port, AllocationSequence* seq) 1500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org : port_(port), sequence_(seq), state_(STATE_INIT) { 1510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 1520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org Port* port() { return port_; } 1540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org AllocationSequence* sequence() { return sequence_; } 1550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool ready() const { return state_ == STATE_READY; } 1560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool complete() const { 1570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Returns true if candidate allocation has completed one way or another. 1580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org return ((state_ == STATE_COMPLETE) || (state_ == STATE_ERROR)); 1590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 1600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void set_ready() { ASSERT(state_ == STATE_INIT); state_ = STATE_READY; } 1620e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void set_complete() { 1630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org state_ = STATE_COMPLETE; 1640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 1650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void set_error() { 1660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org ASSERT(state_ == STATE_INIT || state_ == STATE_READY); 1670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org state_ = STATE_ERROR; 1680e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 1690e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1700e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org private: 1710e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org enum State { 1720e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org STATE_INIT, // No candidates allocated yet. 1730e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org STATE_READY, // At least one candidate is ready for process. 1740e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org STATE_COMPLETE, // All candidates allocated and ready for process. 1750e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org STATE_ERROR // Error in gathering candidates. 1760e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org }; 1770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org Port* port_; 1780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org AllocationSequence* sequence_; 1790e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org State state_; 1800e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org }; 1810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnConfigReady(PortConfiguration* config); 1830e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnConfigStop(); 1840e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void AllocatePorts(); 1850e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnAllocate(); 1860e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void DoAllocate(); 1870e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnNetworksChanged(); 1880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnAllocationSequenceObjectsCreated(); 1892a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org void DisableEquivalentPhases(rtc::Network* network, 1900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org PortConfiguration* config, uint32* flags); 1910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void AddAllocatedPort(Port* port, AllocationSequence* seq, 1920e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool prepare_address); 1930e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnCandidateReady(Port* port, const Candidate& c); 1940e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnPortComplete(Port* port); 1950e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnPortError(Port* port); 1960e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnProtocolEnabled(AllocationSequence* seq, ProtocolType proto); 1970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnPortDestroyed(PortInterface* port); 1980e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnShake(); 1990e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void MaybeSignalCandidatesAllocationDone(); 2000e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnPortAllocationComplete(AllocationSequence* seq); 2010e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org PortData* FindPort(Port* port); 2020e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2032ca56577c4c9aaedeb70024d2012a1f519dfb201mallinath@webrtc.org bool CheckCandidateFilter(const Candidate& c); 2042ca56577c4c9aaedeb70024d2012a1f519dfb201mallinath@webrtc.org 2050e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org BasicPortAllocator* allocator_; 2062a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::Thread* network_thread_; 2072a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_ptr<rtc::PacketSocketFactory> owned_socket_factory_; 2082a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::PacketSocketFactory* socket_factory_; 2090e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool allocation_started_; 2100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool network_manager_started_; 2110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool running_; // set when StartGetAllPorts is called 2120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool allocation_sequences_created_; 2130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org std::vector<PortConfiguration*> configs_; 2140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org std::vector<AllocationSequence*> sequences_; 2150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org std::vector<PortData> ports_; 2160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org friend class AllocationSequence; 2180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}; 2190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Records configuration information useful in creating ports. 2212a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.orgstruct PortConfiguration : public rtc::MessageData { 222459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org // TODO(jiayl): remove |stun_address| when Chrome is updated. 2232a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::SocketAddress stun_address; 224459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org ServerAddresses stun_servers; 2250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org std::string username; 2260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org std::string password; 2270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org typedef std::vector<RelayServerConfig> RelayList; 2290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org RelayList relays; 2300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 231459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org // TODO(jiayl): remove this ctor when Chrome is updated. 2322a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org PortConfiguration(const rtc::SocketAddress& stun_address, 2330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const std::string& username, 2340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const std::string& password); 2350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 236459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org PortConfiguration(const ServerAddresses& stun_servers, 237459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org const std::string& username, 238459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org const std::string& password); 239459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org 240459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org // TODO(jiayl): remove when |stun_address| is removed. 241459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org ServerAddresses StunServers(); 242459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org 2430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Adds another relay server, with the given ports and modifier, to the list. 2440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void AddRelay(const RelayServerConfig& config); 2450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Determines whether the given relay server supports the given protocol. 247afaf4d10603cf012a13d43a62fbc43c0757ec3b9buildbot@webrtc.org bool SupportsProtocol(const RelayServerConfig& relay, 248afaf4d10603cf012a13d43a62fbc43c0757ec3b9buildbot@webrtc.org ProtocolType type) const; 249ba4b69f4755d1bfb1a956f390cb3ce2713189cf2buildbot@webrtc.org bool SupportsProtocol(RelayType turn_type, ProtocolType type) const; 250459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org // Helper method returns the server addresses for the matching RelayType and 251459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org // Protocol type. 252459f356846e5dc1e9b2c5182568660f5eaacfe3ebuildbot@webrtc.org ServerAddresses GetRelayServerAddresses( 253ba4b69f4755d1bfb1a956f390cb3ce2713189cf2buildbot@webrtc.org RelayType turn_type, ProtocolType type) const; 2540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}; 2550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org} // namespace cricket 2570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#endif // TALK_P2P_CLIENT_BASICPORTALLOCATOR_H_ 259