Chromium Code Reviews| 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 #include "net/base/net_util.h" | 5 #include "net/base/net_util.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1030 interface_index(interface_index), | 1030 interface_index(interface_index), |
| 1031 type(type), | 1031 type(type), |
| 1032 address(address), | 1032 address(address), |
| 1033 prefix_length(prefix_length), | 1033 prefix_length(prefix_length), |
| 1034 ip_address_attributes(ip_address_attributes) { | 1034 ip_address_attributes(ip_address_attributes) { |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 NetworkInterface::~NetworkInterface() { | 1037 NetworkInterface::~NetworkInterface() { |
| 1038 } | 1038 } |
| 1039 | 1039 |
| 1040 NetworkChangeNotifier::ConnectionType ConnectionTypeFromInterfaceList( | |
|
pauljensen
2015/01/15 15:05:10
Please move to network_change_notifier.cc
derekjchow1
2015/01/15 20:32:51
Done.
| |
| 1041 const NetworkInterfaceList& interfaces) { | |
| 1042 if (interfaces.empty()) | |
| 1043 return NetworkChangeNotifier::CONNECTION_NONE; | |
| 1044 | |
|
pauljensen
2015/01/15 15:05:10
Please rework this to ignore the terredo interface
derekjchow1
2015/01/15 20:32:51
Done.
| |
| 1045 for (size_t i = 1; i < interfaces.size(); ++i) { | |
| 1046 if (interfaces[i].type != interfaces[0].type) | |
| 1047 return NetworkChangeNotifier::CONNECTION_UNKNOWN; | |
| 1048 } | |
| 1049 return interfaces[0].type; | |
| 1050 } | |
| 1051 | |
| 1040 unsigned CommonPrefixLength(const IPAddressNumber& a1, | 1052 unsigned CommonPrefixLength(const IPAddressNumber& a1, |
| 1041 const IPAddressNumber& a2) { | 1053 const IPAddressNumber& a2) { |
| 1042 DCHECK_EQ(a1.size(), a2.size()); | 1054 DCHECK_EQ(a1.size(), a2.size()); |
| 1043 for (size_t i = 0; i < a1.size(); ++i) { | 1055 for (size_t i = 0; i < a1.size(); ++i) { |
| 1044 unsigned diff = a1[i] ^ a2[i]; | 1056 unsigned diff = a1[i] ^ a2[i]; |
| 1045 if (!diff) | 1057 if (!diff) |
| 1046 continue; | 1058 continue; |
| 1047 for (unsigned j = 0; j < CHAR_BIT; ++j) { | 1059 for (unsigned j = 0; j < CHAR_BIT; ++j) { |
| 1048 if (diff & (1 << (CHAR_BIT - 1))) | 1060 if (diff & (1 << (CHAR_BIT - 1))) |
| 1049 return i * CHAR_BIT + j; | 1061 return i * CHAR_BIT + j; |
| 1050 diff <<= 1; | 1062 diff <<= 1; |
| 1051 } | 1063 } |
| 1052 NOTREACHED(); | 1064 NOTREACHED(); |
| 1053 } | 1065 } |
| 1054 return a1.size() * CHAR_BIT; | 1066 return a1.size() * CHAR_BIT; |
| 1055 } | 1067 } |
| 1056 | 1068 |
| 1057 unsigned MaskPrefixLength(const IPAddressNumber& mask) { | 1069 unsigned MaskPrefixLength(const IPAddressNumber& mask) { |
| 1058 IPAddressNumber all_ones(mask.size(), 0xFF); | 1070 IPAddressNumber all_ones(mask.size(), 0xFF); |
| 1059 return CommonPrefixLength(mask, all_ones); | 1071 return CommonPrefixLength(mask, all_ones); |
| 1060 } | 1072 } |
| 1061 | 1073 |
| 1062 ScopedWifiOptions::~ScopedWifiOptions() { | 1074 ScopedWifiOptions::~ScopedWifiOptions() { |
| 1063 } | 1075 } |
| 1064 | 1076 |
| 1065 } // namespace net | 1077 } // namespace net |
| OLD | NEW |