| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  *  Copyright 2004 The WebRTC Project Authors. All rights reserved. |    2  *  Copyright 2004 The WebRTC Project Authors. All rights reserved. | 
|    3  * |    3  * | 
|    4  *  Use of this source code is governed by a BSD-style license |    4  *  Use of this source code is governed by a BSD-style license | 
|    5  *  that can be found in the LICENSE file in the root of the source |    5  *  that can be found in the LICENSE file in the root of the source | 
|    6  *  tree. An additional intellectual property rights grant can be found |    6  *  tree. An additional intellectual property rights grant can be found | 
|    7  *  in the file PATENTS.  All contributing project authors may |    7  *  in the file PATENTS.  All contributing project authors may | 
|    8  *  be found in the AUTHORS file in the root of the source tree. |    8  *  be found in the AUTHORS file in the root of the source tree. | 
|    9  */ |    9  */ | 
|   10  |   10  | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   48   PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE = 0x200, |   48   PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE = 0x200, | 
|   49   PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION = 0x400, |   49   PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION = 0x400, | 
|   50   // When specified, a loopback candidate will be generated if |   50   // When specified, a loopback candidate will be generated if | 
|   51   // PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified. |   51   // PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified. | 
|   52   PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE = 0x800, |   52   PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE = 0x800, | 
|   53   // Disallow use of UDP when connecting to a relay server. Since proxy servers |   53   // Disallow use of UDP when connecting to a relay server. Since proxy servers | 
|   54   // usually don't handle UDP, using UDP will leak the IP address. |   54   // usually don't handle UDP, using UDP will leak the IP address. | 
|   55   PORTALLOCATOR_DISABLE_UDP_RELAY = 0x1000, |   55   PORTALLOCATOR_DISABLE_UDP_RELAY = 0x1000, | 
|   56 }; |   56 }; | 
|   57  |   57  | 
|   58 const uint32 kDefaultPortAllocatorFlags = 0; |   58 const uint32_t kDefaultPortAllocatorFlags = 0; | 
|   59  |   59  | 
|   60 const uint32 kDefaultStepDelay = 1000;  // 1 sec step delay. |   60 const uint32_t kDefaultStepDelay = 1000;  // 1 sec step delay. | 
|   61 // As per RFC 5245 Appendix B.1, STUN transactions need to be paced at certain |   61 // As per RFC 5245 Appendix B.1, STUN transactions need to be paced at certain | 
|   62 // internal. Less than 20ms is not acceptable. We choose 50ms as our default. |   62 // internal. Less than 20ms is not acceptable. We choose 50ms as our default. | 
|   63 const uint32 kMinimumStepDelay = 50; |   63 const uint32_t kMinimumStepDelay = 50; | 
|   64  |   64  | 
|   65 // CF = CANDIDATE FILTER |   65 // CF = CANDIDATE FILTER | 
|   66 enum { |   66 enum { | 
|   67   CF_NONE = 0x0, |   67   CF_NONE = 0x0, | 
|   68   CF_HOST = 0x1, |   68   CF_HOST = 0x1, | 
|   69   CF_REFLEXIVE = 0x2, |   69   CF_REFLEXIVE = 0x2, | 
|   70   CF_RELAY = 0x4, |   70   CF_RELAY = 0x4, | 
|   71   CF_ALL = 0x7, |   71   CF_ALL = 0x7, | 
|   72 }; |   72 }; | 
|   73  |   73  | 
|   74 class PortAllocatorSession : public sigslot::has_slots<> { |   74 class PortAllocatorSession : public sigslot::has_slots<> { | 
|   75  public: |   75  public: | 
|   76   // Content name passed in mostly for logging and debugging. |   76   // Content name passed in mostly for logging and debugging. | 
|   77   // TODO(mallinath) - Change username and password to ice_ufrag and ice_pwd. |   77   // TODO(mallinath) - Change username and password to ice_ufrag and ice_pwd. | 
|   78   PortAllocatorSession(const std::string& content_name, |   78   PortAllocatorSession(const std::string& content_name, | 
|   79                        int component, |   79                        int component, | 
|   80                        const std::string& username, |   80                        const std::string& username, | 
|   81                        const std::string& password, |   81                        const std::string& password, | 
|   82                        uint32 flags); |   82                        uint32_t flags); | 
|   83  |   83  | 
|   84   // Subclasses should clean up any ports created. |   84   // Subclasses should clean up any ports created. | 
|   85   virtual ~PortAllocatorSession() {} |   85   virtual ~PortAllocatorSession() {} | 
|   86  |   86  | 
|   87   uint32 flags() const { return flags_; } |   87   uint32_t flags() const { return flags_; } | 
|   88   void set_flags(uint32 flags) { flags_ = flags; } |   88   void set_flags(uint32_t flags) { flags_ = flags; } | 
|   89   std::string content_name() const { return content_name_; } |   89   std::string content_name() const { return content_name_; } | 
|   90   int component() const { return component_; } |   90   int component() const { return component_; } | 
|   91  |   91  | 
|   92   // Starts gathering STUN and Relay configurations. |   92   // Starts gathering STUN and Relay configurations. | 
|   93   virtual void StartGettingPorts() = 0; |   93   virtual void StartGettingPorts() = 0; | 
|   94   virtual void StopGettingPorts() = 0; |   94   virtual void StopGettingPorts() = 0; | 
|   95   virtual bool IsGettingPorts() = 0; |   95   virtual bool IsGettingPorts() = 0; | 
|   96  |   96  | 
|   97   sigslot::signal2<PortAllocatorSession*, PortInterface*> SignalPortReady; |   97   sigslot::signal2<PortAllocatorSession*, PortInterface*> SignalPortReady; | 
|   98   sigslot::signal2<PortAllocatorSession*, |   98   sigslot::signal2<PortAllocatorSession*, | 
|   99                    const std::vector<Candidate>&> SignalCandidatesReady; |   99                    const std::vector<Candidate>&> SignalCandidatesReady; | 
|  100   sigslot::signal1<PortAllocatorSession*> SignalCandidatesAllocationDone; |  100   sigslot::signal1<PortAllocatorSession*> SignalCandidatesAllocationDone; | 
|  101  |  101  | 
|  102   virtual uint32 generation() { return generation_; } |  102   virtual uint32_t generation() { return generation_; } | 
|  103   virtual void set_generation(uint32 generation) { generation_ = generation; } |  103   virtual void set_generation(uint32_t generation) { generation_ = generation; } | 
|  104   sigslot::signal1<PortAllocatorSession*> SignalDestroyed; |  104   sigslot::signal1<PortAllocatorSession*> SignalDestroyed; | 
|  105  |  105  | 
|  106  protected: |  106  protected: | 
|  107   const std::string& username() const { return username_; } |  107   const std::string& username() const { return username_; } | 
|  108   const std::string& password() const { return password_; } |  108   const std::string& password() const { return password_; } | 
|  109  |  109  | 
|  110   std::string content_name_; |  110   std::string content_name_; | 
|  111   int component_; |  111   int component_; | 
|  112  |  112  | 
|  113  private: |  113  private: | 
|  114   uint32 flags_; |  114   uint32_t flags_; | 
|  115   uint32 generation_; |  115   uint32_t generation_; | 
|  116   std::string username_; |  116   std::string username_; | 
|  117   std::string password_; |  117   std::string password_; | 
|  118 }; |  118 }; | 
|  119  |  119  | 
|  120 class PortAllocator : public sigslot::has_slots<> { |  120 class PortAllocator : public sigslot::has_slots<> { | 
|  121  public: |  121  public: | 
|  122   PortAllocator() : |  122   PortAllocator() : | 
|  123       flags_(kDefaultPortAllocatorFlags), |  123       flags_(kDefaultPortAllocatorFlags), | 
|  124       min_port_(0), |  124       min_port_(0), | 
|  125       max_port_(0), |  125       max_port_(0), | 
|  126       step_delay_(kDefaultStepDelay), |  126       step_delay_(kDefaultStepDelay), | 
|  127       allow_tcp_listen_(true), |  127       allow_tcp_listen_(true), | 
|  128       candidate_filter_(CF_ALL) { |  128       candidate_filter_(CF_ALL) { | 
|  129     // This will allow us to have old behavior on non webrtc clients. |  129     // This will allow us to have old behavior on non webrtc clients. | 
|  130   } |  130   } | 
|  131   virtual ~PortAllocator() {} |  131   virtual ~PortAllocator() {} | 
|  132  |  132  | 
|  133   PortAllocatorSession* CreateSession( |  133   PortAllocatorSession* CreateSession( | 
|  134       const std::string& sid, |  134       const std::string& sid, | 
|  135       const std::string& content_name, |  135       const std::string& content_name, | 
|  136       int component, |  136       int component, | 
|  137       const std::string& ice_ufrag, |  137       const std::string& ice_ufrag, | 
|  138       const std::string& ice_pwd); |  138       const std::string& ice_pwd); | 
|  139  |  139  | 
|  140   uint32 flags() const { return flags_; } |  140   uint32_t flags() const { return flags_; } | 
|  141   void set_flags(uint32 flags) { flags_ = flags; } |  141   void set_flags(uint32_t flags) { flags_ = flags; } | 
|  142  |  142  | 
|  143   const std::string& user_agent() const { return agent_; } |  143   const std::string& user_agent() const { return agent_; } | 
|  144   const rtc::ProxyInfo& proxy() const { return proxy_; } |  144   const rtc::ProxyInfo& proxy() const { return proxy_; } | 
|  145   void set_proxy(const std::string& agent, const rtc::ProxyInfo& proxy) { |  145   void set_proxy(const std::string& agent, const rtc::ProxyInfo& proxy) { | 
|  146     agent_ = agent; |  146     agent_ = agent; | 
|  147     proxy_ = proxy; |  147     proxy_ = proxy; | 
|  148   } |  148   } | 
|  149  |  149  | 
|  150   // Gets/Sets the port range to use when choosing client ports. |  150   // Gets/Sets the port range to use when choosing client ports. | 
|  151   int min_port() const { return min_port_; } |  151   int min_port() const { return min_port_; } | 
|  152   int max_port() const { return max_port_; } |  152   int max_port() const { return max_port_; } | 
|  153   bool SetPortRange(int min_port, int max_port) { |  153   bool SetPortRange(int min_port, int max_port) { | 
|  154     if (min_port > max_port) { |  154     if (min_port > max_port) { | 
|  155       return false; |  155       return false; | 
|  156     } |  156     } | 
|  157  |  157  | 
|  158     min_port_ = min_port; |  158     min_port_ = min_port; | 
|  159     max_port_ = max_port; |  159     max_port_ = max_port; | 
|  160     return true; |  160     return true; | 
|  161   } |  161   } | 
|  162  |  162  | 
|  163   uint32 step_delay() const { return step_delay_; } |  163   uint32_t step_delay() const { return step_delay_; } | 
|  164   void set_step_delay(uint32 delay) { |  164   void set_step_delay(uint32_t delay) { step_delay_ = delay; } | 
|  165     step_delay_ = delay; |  | 
|  166   } |  | 
|  167  |  165  | 
|  168   bool allow_tcp_listen() const { return allow_tcp_listen_; } |  166   bool allow_tcp_listen() const { return allow_tcp_listen_; } | 
|  169   void set_allow_tcp_listen(bool allow_tcp_listen) { |  167   void set_allow_tcp_listen(bool allow_tcp_listen) { | 
|  170     allow_tcp_listen_ = allow_tcp_listen; |  168     allow_tcp_listen_ = allow_tcp_listen; | 
|  171   } |  169   } | 
|  172  |  170  | 
|  173   uint32 candidate_filter() { return candidate_filter_; } |  171   uint32_t candidate_filter() { return candidate_filter_; } | 
|  174   bool set_candidate_filter(uint32 filter) { |  172   bool set_candidate_filter(uint32_t filter) { | 
|  175     // TODO(mallinath) - Do transition check? |  173     // TODO(mallinath) - Do transition check? | 
|  176     candidate_filter_ = filter; |  174     candidate_filter_ = filter; | 
|  177     return true; |  175     return true; | 
|  178   } |  176   } | 
|  179  |  177  | 
|  180   // Gets/Sets the Origin value used for WebRTC STUN requests. |  178   // Gets/Sets the Origin value used for WebRTC STUN requests. | 
|  181   const std::string& origin() const { return origin_; } |  179   const std::string& origin() const { return origin_; } | 
|  182   void set_origin(const std::string& origin) { origin_ = origin; } |  180   void set_origin(const std::string& origin) { origin_ = origin; } | 
|  183  |  181  | 
|  184  protected: |  182  protected: | 
|  185   virtual PortAllocatorSession* CreateSessionInternal( |  183   virtual PortAllocatorSession* CreateSessionInternal( | 
|  186       const std::string& content_name, |  184       const std::string& content_name, | 
|  187       int component, |  185       int component, | 
|  188       const std::string& ice_ufrag, |  186       const std::string& ice_ufrag, | 
|  189       const std::string& ice_pwd) = 0; |  187       const std::string& ice_pwd) = 0; | 
|  190  |  188  | 
|  191   uint32 flags_; |  189   uint32_t flags_; | 
|  192   std::string agent_; |  190   std::string agent_; | 
|  193   rtc::ProxyInfo proxy_; |  191   rtc::ProxyInfo proxy_; | 
|  194   int min_port_; |  192   int min_port_; | 
|  195   int max_port_; |  193   int max_port_; | 
|  196   uint32 step_delay_; |  194   uint32_t step_delay_; | 
|  197   bool allow_tcp_listen_; |  195   bool allow_tcp_listen_; | 
|  198   uint32 candidate_filter_; |  196   uint32_t candidate_filter_; | 
|  199   std::string origin_; |  197   std::string origin_; | 
|  200 }; |  198 }; | 
|  201  |  199  | 
|  202 }  // namespace cricket |  200 }  // namespace cricket | 
|  203  |  201  | 
|  204 #endif  // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ |  202 #endif  // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ | 
| OLD | NEW |