| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 return port >= 0 && port <= std::numeric_limits<uint16>::max(); | 299 return port >= 0 && port <= std::numeric_limits<uint16>::max(); |
| 300 } | 300 } |
| 301 | 301 |
| 302 bool IsPortAllowedByDefault(int port) { | 302 bool IsPortAllowedByDefault(int port) { |
| 303 int array_size = arraysize(kRestrictedPorts); | 303 int array_size = arraysize(kRestrictedPorts); |
| 304 for (int i = 0; i < array_size; i++) { | 304 for (int i = 0; i < array_size; i++) { |
| 305 if (kRestrictedPorts[i] == port) { | 305 if (kRestrictedPorts[i] == port) { |
| 306 return false; | 306 return false; |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 return true; | 309 return IsPortValid(port); |
| 310 } | 310 } |
| 311 | 311 |
| 312 bool IsPortAllowedByFtp(int port) { | 312 bool IsPortAllowedByFtp(int port) { |
| 313 int array_size = arraysize(kAllowedFtpPorts); | 313 int array_size = arraysize(kAllowedFtpPorts); |
| 314 for (int i = 0; i < array_size; i++) { | 314 for (int i = 0; i < array_size; i++) { |
| 315 if (kAllowedFtpPorts[i] == port) { | 315 if (kAllowedFtpPorts[i] == port) { |
| 316 return true; | 316 return true; |
| 317 } | 317 } |
| 318 } | 318 } |
| 319 // Port not explicitly allowed by FTP, so return the default restrictions. | 319 // Port not explicitly allowed by FTP, so return the default restrictions. |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 | 566 |
| 567 #if defined(OS_WIN) | 567 #if defined(OS_WIN) |
| 568 if (sock_addr->sa_family == AF_BTH) { | 568 if (sock_addr->sa_family == AF_BTH) { |
| 569 if (sock_addr_len < static_cast<socklen_t>(sizeof(SOCKADDR_BTH))) | 569 if (sock_addr_len < static_cast<socklen_t>(sizeof(SOCKADDR_BTH))) |
| 570 return false; | 570 return false; |
| 571 const SOCKADDR_BTH* addr = | 571 const SOCKADDR_BTH* addr = |
| 572 reinterpret_cast<const SOCKADDR_BTH*>(sock_addr); | 572 reinterpret_cast<const SOCKADDR_BTH*>(sock_addr); |
| 573 *address = reinterpret_cast<const uint8*>(&addr->btAddr); | 573 *address = reinterpret_cast<const uint8*>(&addr->btAddr); |
| 574 *address_len = kBluetoothAddressSize; | 574 *address_len = kBluetoothAddressSize; |
| 575 if (port) | 575 if (port) |
| 576 *port = addr->port; | 576 *port = static_cast<uint16>(addr->port); |
| 577 return true; | 577 return true; |
| 578 } | 578 } |
| 579 #endif | 579 #endif |
| 580 | 580 |
| 581 return false; // Unrecognized |sa_family|. | 581 return false; // Unrecognized |sa_family|. |
| 582 } | 582 } |
| 583 | 583 |
| 584 std::string IPAddressToString(const uint8* address, | 584 std::string IPAddressToString(const uint8* address, |
| 585 size_t address_len) { | 585 size_t address_len) { |
| 586 std::string str; | 586 std::string str; |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 | 1057 |
| 1058 unsigned MaskPrefixLength(const IPAddressNumber& mask) { | 1058 unsigned MaskPrefixLength(const IPAddressNumber& mask) { |
| 1059 IPAddressNumber all_ones(mask.size(), 0xFF); | 1059 IPAddressNumber all_ones(mask.size(), 0xFF); |
| 1060 return CommonPrefixLength(mask, all_ones); | 1060 return CommonPrefixLength(mask, all_ones); |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 ScopedWifiOptions::~ScopedWifiOptions() { | 1063 ScopedWifiOptions::~ScopedWifiOptions() { |
| 1064 } | 1064 } |
| 1065 | 1065 |
| 1066 } // namespace net | 1066 } // namespace net |
| OLD | NEW |