| 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 CHROMEOS_NETWORK_NETWORK_UTIL_H_ | 5 #ifndef CHROMEOS_NETWORK_NETWORK_UTIL_H_ |
| 6 #define CHROMEOS_NETWORK_NETWORK_UTIL_H_ | 6 #define CHROMEOS_NETWORK_NETWORK_UTIL_H_ |
| 7 | 7 |
| 8 // This header is introduced to make it easy to switch from chromeos_network.cc | 8 // This header is introduced to make it easy to switch from chromeos_network.cc |
| 9 // to Chrome's own DBus code. crosbug.com/16557 | 9 // to Chrome's own DBus code. crosbug.com/16557 |
| 10 // All calls to functions in chromeos_network.h should be made through | 10 // All calls to functions in chromeos_network.h should be made through |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 // Converts a |prefix_length| to a netmask. (for IPv4 only) | 75 // Converts a |prefix_length| to a netmask. (for IPv4 only) |
| 76 // e.g. a |prefix_length| of 24 is converted to a netmask of "255.255.255.0". | 76 // e.g. a |prefix_length| of 24 is converted to a netmask of "255.255.255.0". |
| 77 // Invalid prefix lengths will return the empty string. | 77 // Invalid prefix lengths will return the empty string. |
| 78 CHROMEOS_EXPORT std::string PrefixLengthToNetmask(int32 prefix_length); | 78 CHROMEOS_EXPORT std::string PrefixLengthToNetmask(int32 prefix_length); |
| 79 | 79 |
| 80 // Converts a |netmask| to a prefixlen. (for IPv4 only) | 80 // Converts a |netmask| to a prefixlen. (for IPv4 only) |
| 81 // e.g. a |netmask| of 255.255.255.0 is converted to a prefixlen of 24 | 81 // e.g. a |netmask| of 255.255.255.0 is converted to a prefixlen of 24 |
| 82 CHROMEOS_EXPORT int32 NetmaskToPrefixLength(const std::string& netmask); | 82 CHROMEOS_EXPORT int32 NetmaskToPrefixLength(const std::string& netmask); |
| 83 | 83 |
| 84 // Returns |shill_mac_address| in aa:bb format. |
| 85 CHROMEOS_EXPORT std::string FormattedMacAddress( |
| 86 const std::string& shill_mac_address); |
| 87 |
| 84 // Parses |list|, which contains DictionaryValues and returns a vector of | 88 // Parses |list|, which contains DictionaryValues and returns a vector of |
| 85 // CellularScanResult in |scan_results|. Returns false if parsing fails, | 89 // CellularScanResult in |scan_results|. Returns false if parsing fails, |
| 86 // in which case the contents of |scan_results| will be undefined. | 90 // in which case the contents of |scan_results| will be undefined. |
| 87 CHROMEOS_EXPORT bool ParseCellularScanResults( | 91 CHROMEOS_EXPORT bool ParseCellularScanResults( |
| 88 const base::ListValue& list, std::vector<CellularScanResult>* scan_results); | 92 const base::ListValue& list, std::vector<CellularScanResult>* scan_results); |
| 89 | 93 |
| 90 // Retrieves the ONC state dictionary for |favorite| using GetStateProperties. | 94 // Retrieves the ONC state dictionary for |favorite| using GetStateProperties. |
| 91 // This includes properties from the corresponding NetworkState if it exists. | 95 // This includes properties from the corresponding NetworkState if it exists. |
| 92 CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> TranslateFavoriteStateToONC( | 96 CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> TranslateFavoriteStateToONC( |
| 93 const FavoriteState* favorite); | 97 const FavoriteState* favorite); |
| 94 | 98 |
| 95 // Retrieves the list of network services by passing |pattern|, | 99 // Retrieves the list of network services by passing |pattern|, |
| 96 // |configured_only|, and |visible_only| to NetworkStateHandler:: | 100 // |configured_only|, and |visible_only| to NetworkStateHandler:: |
| 97 // GetNetworkListByType(). Translates the result into a list of ONC | 101 // GetNetworkListByType(). Translates the result into a list of ONC |
| 98 // dictionaries using TranslateShillServiceToONCPart. |limit| is used to limit | 102 // dictionaries using TranslateShillServiceToONCPart. |limit| is used to limit |
| 99 // the number of results. | 103 // the number of results. |
| 100 CHROMEOS_EXPORT scoped_ptr<base::ListValue> TranslateNetworkListToONC( | 104 CHROMEOS_EXPORT scoped_ptr<base::ListValue> TranslateNetworkListToONC( |
| 101 NetworkTypePattern pattern, | 105 NetworkTypePattern pattern, |
| 102 bool configured_only, | 106 bool configured_only, |
| 103 bool visible_only, | 107 bool visible_only, |
| 104 int limit); | 108 int limit); |
| 105 | 109 |
| 106 } // namespace network_util | 110 } // namespace network_util |
| 107 } // namespace chromeos | 111 } // namespace chromeos |
| 108 | 112 |
| 109 #endif // CHROMEOS_NETWORK_NETWORK_UTIL_H_ | 113 #endif // CHROMEOS_NETWORK_NETWORK_UTIL_H_ |
| OLD | NEW |