15976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org/* 25976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * libjingle 35976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * Copyright 2004--2005, Google Inc. 45976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * 55976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * Redistribution and use in source and binary forms, with or without 65976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * modification, are permitted provided that the following conditions are met: 75976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * 85976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * 1. Redistributions of source code must retain the above copyright notice, 95976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * this list of conditions and the following disclaimer. 105976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * 2. Redistributions in binary form must reproduce the above copyright notice, 115976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * this list of conditions and the following disclaimer in the documentation 125976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * and/or other materials provided with the distribution. 135976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * 3. The name of the author may not be used to endorse or promote products 145976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * derived from this software without specific prior written permission. 155976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * 165976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 175976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 185976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 195976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 205976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 215976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 225976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 235976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 245976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 255976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 265976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org */ 275976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 285976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#ifndef TALK_BASE_NETWORK_H_ 295976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#define TALK_BASE_NETWORK_H_ 305976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 315976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include <deque> 325976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include <map> 335976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include <string> 345976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include <vector> 355976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 365976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include "talk/base/basictypes.h" 375976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include "talk/base/ipaddress.h" 385976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include "talk/base/messagehandler.h" 395976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include "talk/base/sigslot.h" 405976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 415976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#if defined(POSIX) 425976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgstruct ifaddrs; 435976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#endif // defined(POSIX) 445976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 455976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgnamespace talk_base { 465976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 475976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgclass Network; 485976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgclass NetworkSession; 495976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgclass Thread; 505976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 515976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// Generic network manager interface. It provides list of local 525976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// networks. 535976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgclass NetworkManager { 545976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org public: 555976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org typedef std::vector<Network*> NetworkList; 565976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 575976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org NetworkManager(); 585976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual ~NetworkManager(); 595976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 605976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Called when network list is updated. 615976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org sigslot::signal0<> SignalNetworksChanged; 625976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 635976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Indicates a failure when getting list of network interfaces. 645976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org sigslot::signal0<> SignalError; 655976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 665976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Start/Stop monitoring of network interfaces 675976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // list. SignalNetworksChanged or SignalError is emitted immidiately 685976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // after StartUpdating() is called. After that SignalNetworksChanged 695976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // is emitted wheneven list of networks changes. 705976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual void StartUpdating() = 0; 715976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual void StopUpdating() = 0; 725976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 735976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Returns the current list of networks available on this machine. 745976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // UpdateNetworks() must be called before this method is called. 755976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // It makes sure that repeated calls return the same object for a 765976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // given network, so that quality is tracked appropriately. Does not 775976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // include ignored networks. 785976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual void GetNetworks(NetworkList* networks) const = 0; 795976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 805976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Dumps a list of networks available to LS_INFO. 815976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual void DumpNetworks(bool include_ignored) {} 825976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org}; 835976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 845976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// Base class for NetworkManager implementations. 855976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgclass NetworkManagerBase : public NetworkManager { 865976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org public: 875976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org NetworkManagerBase(); 885976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual ~NetworkManagerBase(); 895976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 905976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual void GetNetworks(std::vector<Network*>* networks) const; 915976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org bool ipv6_enabled() const { return ipv6_enabled_; } 925976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org void set_ipv6_enabled(bool enabled) { ipv6_enabled_ = enabled; } 935976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 945976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org protected: 955976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org typedef std::map<std::string, Network*> NetworkMap; 965976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Updates |networks_| with the networks listed in |list|. If 975976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // |network_map_| already has a Network object for a network listed 985976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // in the |list| then it is reused. Accept ownership of the Network 995976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // objects in the |list|. |changed| will be set to true if there is 1005976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // any change in the network list. 1015976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org void MergeNetworkList(const NetworkList& list, bool* changed); 1025976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1035976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org private: 1045976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org friend class NetworkTest; 1055976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org void DoUpdateNetworks(); 1065976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1075976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org NetworkList networks_; 1085976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org NetworkMap networks_map_; 1095976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org bool ipv6_enabled_; 1105976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org}; 1115976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1125976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// Basic implementation of the NetworkManager interface that gets list 1135976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// of networks using OS APIs. 1145976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgclass BasicNetworkManager : public NetworkManagerBase, 1155976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org public MessageHandler { 1165976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org public: 1175976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org BasicNetworkManager(); 1185976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual ~BasicNetworkManager(); 1195976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1205976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual void StartUpdating(); 1215976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual void StopUpdating(); 1225976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1235976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Logs the available networks. 1245976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual void DumpNetworks(bool include_ignored); 1255976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1265976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // MessageHandler interface. 1275976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual void OnMessage(Message* msg); 1285976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org bool started() { return start_count_ > 0; } 1295976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 130e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org // Sets the network ignore list, which is empty by default. Any network on 131e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org // the ignore list will be filtered from network enumeration results. 132e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org void set_network_ignore_list(const std::vector<std::string>& list) { 133e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org network_ignore_list_ = list; 134e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org } 135e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org#if defined(ANDROID) || defined(LINUX) 136e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org // Sets the flag for ignoring non-default routes. 137e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org void set_ignore_non_default_routes(bool value) { 138e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org ignore_non_default_routes_ = true; 139e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org } 140e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org#endif 141e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org 1425976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org protected: 1435976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#if defined(POSIX) 1445976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Separated from CreateNetworks for tests. 1455976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org void ConvertIfAddrs(ifaddrs* interfaces, 1465976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org bool include_ignored, 1475976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org NetworkList* networks) const; 1485976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#endif // defined(POSIX) 1495976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1505976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Creates a network object for each network available on the machine. 1515976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org bool CreateNetworks(bool include_ignored, NetworkList* networks) const; 1525976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1535976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Determines if a network should be ignored. 154e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org bool IsIgnoredNetwork(const Network& network) const; 1555976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1565976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org private: 1575976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org friend class NetworkTest; 1585976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1595976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org void DoUpdateNetworks(); 1605976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1615976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org Thread* thread_; 1625976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org bool sent_first_update_; 1635976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org int start_count_; 164e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org std::vector<std::string> network_ignore_list_; 165e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org bool ignore_non_default_routes_; 1665976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org}; 1675976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1685976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// Represents a Unix-type network interface, with a name and single address. 1695976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgclass Network { 1705976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org public: 1715976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org Network() : prefix_(INADDR_ANY), scope_id_(0) {} 1725976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org Network(const std::string& name, const std::string& description, 1735976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org const IPAddress& prefix, int prefix_length); 1745976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1755976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Returns the name of the interface this network is associated wtih. 1765976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org const std::string& name() const { return name_; } 1775976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1785976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Returns the OS-assigned name for this network. This is useful for 1795976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // debugging but should not be sent over the wire (for privacy reasons). 1805976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org const std::string& description() const { return description_; } 1815976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1825976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Returns the prefix for this network. 1835976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org const IPAddress& prefix() const { return prefix_; } 1845976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Returns the length, in bits, of this network's prefix. 1855976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org int prefix_length() const { return prefix_length_; } 1865976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 1875976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Returns the Network's current idea of the 'best' IP it has. 1885976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // 'Best' currently means the first one added. 1895976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // TODO: We should be preferring temporary addresses. 1905976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Returns an unset IP if this network has no active addresses. 1915976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org IPAddress ip() const { 1925976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org if (ips_.size() == 0) { 1935976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org return IPAddress(); 1945976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org } 1955976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org return ips_.at(0); 1965976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org } 1975976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Adds an active IP address to this network. Does not check for duplicates. 1985976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org void AddIP(const IPAddress& ip) { ips_.push_back(ip); } 1995976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 2005976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Sets the network's IP address list. Returns true if new IP addresses were 2015976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // detected. Passing true to already_changed skips this check. 2025976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org bool SetIPs(const std::vector<IPAddress>& ips, bool already_changed); 2035976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Get the list of IP Addresses associated with this network. 2045976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org const std::vector<IPAddress>& GetIPs() { return ips_;} 2055976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Clear the network's list of addresses. 2065976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org void ClearIPs() { ips_.clear(); } 2075976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 2085976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Returns the scope-id of the network's address. 2095976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Should only be relevant for link-local IPv6 addresses. 2105976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org int scope_id() const { return scope_id_; } 2115976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org void set_scope_id(int id) { scope_id_ = id; } 2125976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 2135976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Indicates whether this network should be ignored, perhaps because 2145976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // the IP is 0, or the interface is one we know is invalid. 2155976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org bool ignored() const { return ignored_; } 2165976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org void set_ignored(bool ignored) { ignored_ = ignored; } 2175976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 2185976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org // Debugging description of this network 2195976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org std::string ToString() const; 2205976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 2215976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org private: 2225976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org typedef std::vector<NetworkSession*> SessionList; 2235976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 2245976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org std::string name_; 2255976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org std::string description_; 2265976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org IPAddress prefix_; 2275976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org int prefix_length_; 2285976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org std::vector<IPAddress> ips_; 2295976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org int scope_id_; 2305976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org bool ignored_; 2315976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org SessionList sessions_; 2325976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org double uniform_numerator_; 2335976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org double uniform_denominator_; 2345976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org double exponential_numerator_; 2355976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org double exponential_denominator_; 2365976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 2375976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org friend class NetworkManager; 2385976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org}; 2395976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org} // namespace talk_base 2405976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 2415976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#endif // TALK_BASE_NETWORK_H_ 242