| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <unicode/regex.h> | 9 #include <unicode/regex.h> |
| 10 #include <unicode/ucnv.h> | 10 #include <unicode/ucnv.h> |
| (...skipping 1886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1897 } | 1897 } |
| 1898 | 1898 |
| 1899 bool ParseCIDRBlock(const std::string& cidr_literal, | 1899 bool ParseCIDRBlock(const std::string& cidr_literal, |
| 1900 IPAddressNumber* ip_number, | 1900 IPAddressNumber* ip_number, |
| 1901 size_t* prefix_length_in_bits) { | 1901 size_t* prefix_length_in_bits) { |
| 1902 // We expect CIDR notation to match one of these two templates: | 1902 // We expect CIDR notation to match one of these two templates: |
| 1903 // <IPv4-literal> "/" <number of bits> | 1903 // <IPv4-literal> "/" <number of bits> |
| 1904 // <IPv6-literal> "/" <number of bits> | 1904 // <IPv6-literal> "/" <number of bits> |
| 1905 | 1905 |
| 1906 std::vector<std::string> parts; | 1906 std::vector<std::string> parts; |
| 1907 SplitString(cidr_literal, '/', &parts); | 1907 base::SplitString(cidr_literal, '/', &parts); |
| 1908 if (parts.size() != 2) | 1908 if (parts.size() != 2) |
| 1909 return false; | 1909 return false; |
| 1910 | 1910 |
| 1911 // Parse the IP address. | 1911 // Parse the IP address. |
| 1912 if (!ParseIPLiteralToNumber(parts[0], ip_number)) | 1912 if (!ParseIPLiteralToNumber(parts[0], ip_number)) |
| 1913 return false; | 1913 return false; |
| 1914 | 1914 |
| 1915 // Parse the prefix length. | 1915 // Parse the prefix length. |
| 1916 int number_of_bits = -1; | 1916 int number_of_bits = -1; |
| 1917 if (!base::StringToInt(parts[1], &number_of_bits)) | 1917 if (!base::StringToInt(parts[1], &number_of_bits)) |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1989 } | 1989 } |
| 1990 | 1990 |
| 1991 int GetPortFromAddrinfo(const struct addrinfo* info) { | 1991 int GetPortFromAddrinfo(const struct addrinfo* info) { |
| 1992 uint16* port_field = GetPortFieldFromAddrinfo(info); | 1992 uint16* port_field = GetPortFieldFromAddrinfo(info); |
| 1993 if (!port_field) | 1993 if (!port_field) |
| 1994 return -1; | 1994 return -1; |
| 1995 return ntohs(*port_field); | 1995 return ntohs(*port_field); |
| 1996 } | 1996 } |
| 1997 | 1997 |
| 1998 } // namespace net | 1998 } // namespace net |
| OLD | NEW |