Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1783)

Side by Side Diff: net/base/net_util.cc

Issue 3067012: Merge 53487 - [Linux] Enable connecting to localhost when offline.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/net_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ucnv.h> 9 #include <unicode/ucnv.h>
10 #include <unicode/uidna.h> 10 #include <unicode/uidna.h>
(...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 } 1776 }
1777 1777
1778 IPv6SupportResults(IPV6_GLOBAL_ADDRESS_MISSING); 1778 IPv6SupportResults(IPV6_GLOBAL_ADDRESS_MISSING);
1779 return false; 1779 return false;
1780 #else 1780 #else
1781 NOTIMPLEMENTED(); 1781 NOTIMPLEMENTED();
1782 return true; 1782 return true;
1783 #endif // defined(various platforms) 1783 #endif // defined(various platforms)
1784 } 1784 }
1785 1785
1786 bool HaveOnlyLoopbackAddresses() {
1787 #if defined(OS_POSIX)
1788 struct ifaddrs* interface_addr = NULL;
1789 int rv = getifaddrs(&interface_addr);
1790 if (rv != 0) {
1791 DLOG(INFO) << "getifaddrs() failed with errno = " << errno;
1792 return false;
1793 }
1794
1795 bool result = true;
1796 for (struct ifaddrs* interface = interface_addr;
1797 interface != NULL;
1798 interface = interface->ifa_next) {
1799 if (!(IFF_UP & interface->ifa_flags))
1800 continue;
1801 if (IFF_LOOPBACK & interface->ifa_flags)
1802 continue;
1803 const struct sockaddr* addr = interface->ifa_addr;
1804 if (!addr)
1805 continue;
1806 if (addr->sa_family != AF_INET6 && addr->sa_family != AF_INET)
1807 continue;
1808
1809 result = false;
1810 break;
1811 }
1812 freeifaddrs(interface_addr);
1813 return result;
1814 #else
1815 NOTIMPLEMENTED();
1816 return false;
1817 #endif // defined(various platforms)
1818 }
1819
1786 bool ParseIPLiteralToNumber(const std::string& ip_literal, 1820 bool ParseIPLiteralToNumber(const std::string& ip_literal,
1787 IPAddressNumber* ip_number) { 1821 IPAddressNumber* ip_number) {
1788 // |ip_literal| could be either a IPv4 or an IPv6 literal. If it contains 1822 // |ip_literal| could be either a IPv4 or an IPv6 literal. If it contains
1789 // a colon however, it must be an IPv6 address. 1823 // a colon however, it must be an IPv6 address.
1790 if (ip_literal.find(':') != std::string::npos) { 1824 if (ip_literal.find(':') != std::string::npos) {
1791 // GURL expects IPv6 hostnames to be surrounded with brackets. 1825 // GURL expects IPv6 hostnames to be surrounded with brackets.
1792 std::string host_brackets = "[" + ip_literal + "]"; 1826 std::string host_brackets = "[" + ip_literal + "]";
1793 url_parse::Component host_comp(0, host_brackets.size()); 1827 url_parse::Component host_comp(0, host_brackets.size());
1794 1828
1795 // Try parsing the hostname as an IPv6 literal. 1829 // Try parsing the hostname as an IPv6 literal.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 } 1950 }
1917 1951
1918 int GetPortFromAddrinfo(const struct addrinfo* info) { 1952 int GetPortFromAddrinfo(const struct addrinfo* info) {
1919 uint16* port_field = GetPortFieldFromAddrinfo(info); 1953 uint16* port_field = GetPortFieldFromAddrinfo(info);
1920 if (!port_field) 1954 if (!port_field)
1921 return -1; 1955 return -1;
1922 return ntohs(*port_field); 1956 return ntohs(*port_field);
1923 } 1957 }
1924 1958
1925 } // namespace net 1959 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698