summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/libjingle/source/talk/base/network.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/libjingle/source/talk/base/network.h')
-rw-r--r--chromium/third_party/libjingle/source/talk/base/network.h39
1 files changed, 30 insertions, 9 deletions
diff --git a/chromium/third_party/libjingle/source/talk/base/network.h b/chromium/third_party/libjingle/source/talk/base/network.h
index 63f3e732fd9..2be81bb1c8d 100644
--- a/chromium/third_party/libjingle/source/talk/base/network.h
+++ b/chromium/third_party/libjingle/source/talk/base/network.h
@@ -45,9 +45,23 @@ struct ifaddrs;
namespace talk_base {
class Network;
-class NetworkSession;
class Thread;
+enum AdapterType {
+ // This enum resembles the one in Chromium net::ConnectionType.
+ ADAPTER_TYPE_UNKNOWN = 0,
+ ADAPTER_TYPE_ETHERNET = 1,
+ ADAPTER_TYPE_WIFI = 2,
+ ADAPTER_TYPE_CELLULAR = 3,
+ ADAPTER_TYPE_VPN = 4
+};
+
+// Makes a string key for this network. Used in the network manager's maps.
+// Network objects are keyed on interface name, network prefix and the
+// length of that prefix.
+std::string MakeNetworkKey(const std::string& name, const IPAddress& prefix,
+ int prefix_length);
+
// Generic network manager interface. It provides list of local
// networks.
class NetworkManager {
@@ -168,10 +182,12 @@ class BasicNetworkManager : public NetworkManagerBase,
// Represents a Unix-type network interface, with a name and single address.
class Network {
public:
- Network() : prefix_(INADDR_ANY), scope_id_(0) {}
Network(const std::string& name, const std::string& description,
const IPAddress& prefix, int prefix_length);
+ Network(const std::string& name, const std::string& description,
+ const IPAddress& prefix, int prefix_length, AdapterType type);
+
// Returns the name of the interface this network is associated wtih.
const std::string& name() const { return name_; }
@@ -184,6 +200,10 @@ class Network {
// Returns the length, in bits, of this network's prefix.
int prefix_length() const { return prefix_length_; }
+ // |key_| has unique value per network interface. Used in sorting network
+ // interfaces. Key is derived from interface name and it's prefix.
+ std::string key() const { return key_; }
+
// Returns the Network's current idea of the 'best' IP it has.
// 'Best' currently means the first one added.
// TODO: We should be preferring temporary addresses.
@@ -215,27 +235,28 @@ class Network {
bool ignored() const { return ignored_; }
void set_ignored(bool ignored) { ignored_ = ignored; }
+ AdapterType type() const { return type_; }
+ int preference() const { return preference_; }
+ void set_preference(int preference) { preference_ = preference; }
+
// Debugging description of this network
std::string ToString() const;
private:
- typedef std::vector<NetworkSession*> SessionList;
-
std::string name_;
std::string description_;
IPAddress prefix_;
int prefix_length_;
+ std::string key_;
std::vector<IPAddress> ips_;
int scope_id_;
bool ignored_;
- SessionList sessions_;
- double uniform_numerator_;
- double uniform_denominator_;
- double exponential_numerator_;
- double exponential_denominator_;
+ AdapterType type_;
+ int preference_;
friend class NetworkManager;
};
+
} // namespace talk_base
#endif // TALK_BASE_NETWORK_H_