OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 // This class handles the interaction with the ChromeOS network library APIs. | 1215 // This class handles the interaction with the ChromeOS network library APIs. |
1216 // Classes can add themselves as observers. Users can get an instance of the | 1216 // Classes can add themselves as observers. Users can get an instance of the |
1217 // library like this: chromeos::CrosLibrary::Get()->GetNetworkLibrary() | 1217 // library like this: chromeos::CrosLibrary::Get()->GetNetworkLibrary() |
1218 class NetworkLibrary { | 1218 class NetworkLibrary { |
1219 public: | 1219 public: |
1220 enum HardwareAddressFormat { | 1220 enum HardwareAddressFormat { |
1221 FORMAT_RAW_HEX, | 1221 FORMAT_RAW_HEX, |
1222 FORMAT_COLON_SEPARATED_HEX | 1222 FORMAT_COLON_SEPARATED_HEX |
1223 }; | 1223 }; |
1224 | 1224 |
| 1225 // Used to configure which IP parameters will be specified by DHCP and which |
| 1226 // will be set by the user. |
| 1227 enum UseDHCP { |
| 1228 USE_DHCP_ADDRESS = 0x1, |
| 1229 USE_DHCP_NETMASK = 0x1 << 1, |
| 1230 USE_DHCP_GATEWAY = 0x1 << 2, |
| 1231 USE_DHCP_NAME_SERVERS = 0x1 << 3, |
| 1232 USE_DHCP_ALL_ROUTING_INFO = |
| 1233 (USE_DHCP_ADDRESS | |
| 1234 USE_DHCP_NETMASK | |
| 1235 USE_DHCP_GATEWAY), |
| 1236 }; |
| 1237 |
1225 class NetworkManagerObserver { | 1238 class NetworkManagerObserver { |
1226 public: | 1239 public: |
1227 // Called when the state of the network manager has changed, | 1240 // Called when the state of the network manager has changed, |
1228 // for example, networks have appeared or disappeared. | 1241 // for example, networks have appeared or disappeared. |
1229 virtual void OnNetworkManagerChanged(NetworkLibrary* obj) = 0; | 1242 virtual void OnNetworkManagerChanged(NetworkLibrary* obj) = 0; |
1230 protected: | 1243 protected: |
1231 virtual ~NetworkManagerObserver() { } | 1244 virtual ~NetworkManagerObserver() { } |
1232 }; | 1245 }; |
1233 | 1246 |
1234 class NetworkObserver { | 1247 class NetworkObserver { |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1649 | 1662 |
1650 // Fetches IP configs and hardware address for a given device_path. | 1663 // Fetches IP configs and hardware address for a given device_path. |
1651 // The hardware address is usually a MAC address like "0011AA22BB33". | 1664 // The hardware address is usually a MAC address like "0011AA22BB33". |
1652 // |hardware_address| will be an empty string, if no hardware address is | 1665 // |hardware_address| will be an empty string, if no hardware address is |
1653 // found. | 1666 // found. |
1654 virtual NetworkIPConfigVector GetIPConfigs( | 1667 virtual NetworkIPConfigVector GetIPConfigs( |
1655 const std::string& device_path, | 1668 const std::string& device_path, |
1656 std::string* hardware_address, | 1669 std::string* hardware_address, |
1657 HardwareAddressFormat) = 0; | 1670 HardwareAddressFormat) = 0; |
1658 | 1671 |
1659 // Sets an IP config. This is called when user changes from dhcp to static | 1672 // Sets the configuration of the IP parameters. This is called when user |
1660 // or vice versa or when user changes the ip config info. | 1673 // changes IP settings from dhcp to static or vice versa or when user changes |
1661 // If nothing is changed, this method does nothing. | 1674 // the ip config info. If nothing is changed, this method does nothing. |
1662 virtual void SetIPConfig(const NetworkIPConfig& ipconfig) = 0; | 1675 // |dhcp_usage_mask| is a bitmask composed of items from the UseDHCP enum, and |
| 1676 // indicates which of the supplied values are overridden by values given by |
| 1677 // the default IP acquisition technique for the service (DHCP, usually). |
| 1678 virtual void SetIPParameters(const std::string& service_path, |
| 1679 const std::string& address, |
| 1680 const std::string& netmask, |
| 1681 const std::string& gateway, |
| 1682 const std::string& name_servers, |
| 1683 int dhcp_usage_mask) = 0; |
1663 | 1684 |
1664 // This will connect to a preferred network if the currently connected | 1685 // This will connect to a preferred network if the currently connected |
1665 // network is not preferred. This should be called when the active profile | 1686 // network is not preferred. This should be called when the active profile |
1666 // changes. | 1687 // changes. |
1667 virtual void SwitchToPreferredNetwork() = 0; | 1688 virtual void SwitchToPreferredNetwork() = 0; |
1668 | 1689 |
1669 // Load networks from an Open Network Configuration blob. | 1690 // Load networks from an Open Network Configuration blob. |
1670 // If there was an error, this will return false and |error| will be set to | 1691 // If there was an error, this will return false and |error| will be set to |
1671 // the error message. | 1692 // the error message. |
1672 virtual bool LoadOncNetworks(const std::string& onc_blob, | 1693 virtual bool LoadOncNetworks(const std::string& onc_blob, |
(...skipping 10 matching lines...) Expand all Loading... |
1683 const std::string& service_path) = 0; | 1704 const std::string& service_path) = 0; |
1684 | 1705 |
1685 // Factory function, creates a new instance and returns ownership. | 1706 // Factory function, creates a new instance and returns ownership. |
1686 // For normal usage, access the singleton via CrosLibrary::Get(). | 1707 // For normal usage, access the singleton via CrosLibrary::Get(). |
1687 static NetworkLibrary* GetImpl(bool stub); | 1708 static NetworkLibrary* GetImpl(bool stub); |
1688 }; | 1709 }; |
1689 | 1710 |
1690 } // namespace chromeos | 1711 } // namespace chromeos |
1691 | 1712 |
1692 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 1713 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
OLD | NEW |