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

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

Issue 3331024: Treat IPv6 link local addresses as loopback addresses. (Closed)
Patch Set: Created 10 years, 3 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
« no previous file with comments | « no previous file | 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/regex.h> 9 #include <unicode/regex.h>
10 #include <unicode/ucnv.h> 10 #include <unicode/ucnv.h>
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 for (struct ifaddrs* interface = interface_addr; 1824 for (struct ifaddrs* interface = interface_addr;
1825 interface != NULL; 1825 interface != NULL;
1826 interface = interface->ifa_next) { 1826 interface = interface->ifa_next) {
1827 if (!(IFF_UP & interface->ifa_flags)) 1827 if (!(IFF_UP & interface->ifa_flags))
1828 continue; 1828 continue;
1829 if (IFF_LOOPBACK & interface->ifa_flags) 1829 if (IFF_LOOPBACK & interface->ifa_flags)
1830 continue; 1830 continue;
1831 const struct sockaddr* addr = interface->ifa_addr; 1831 const struct sockaddr* addr = interface->ifa_addr;
1832 if (!addr) 1832 if (!addr)
1833 continue; 1833 continue;
1834 if (addr->sa_family == AF_INET6) {
1835 // Safe cast since this is AF_INET6.
1836 const struct sockaddr_in6* addr_in6 =
1837 reinterpret_cast<const struct sockaddr_in6*>(addr);
1838 const struct in6_addr* sin6_addr = &addr_in6->sin6_addr;
1839 if (IN6_IS_ADDR_LOOPBACK(sin6_addr) || IN6_IS_ADDR_LINKLOCAL(sin6_addr))
1840 continue;
1841 }
1834 if (addr->sa_family != AF_INET6 && addr->sa_family != AF_INET) 1842 if (addr->sa_family != AF_INET6 && addr->sa_family != AF_INET)
1835 continue; 1843 continue;
1836 1844
1837 result = false; 1845 result = false;
1838 break; 1846 break;
1839 } 1847 }
1840 freeifaddrs(interface_addr); 1848 freeifaddrs(interface_addr);
1841 return result; 1849 return result;
1842 #else 1850 #else
1843 NOTIMPLEMENTED(); 1851 NOTIMPLEMENTED();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 } 1986 }
1979 1987
1980 int GetPortFromAddrinfo(const struct addrinfo* info) { 1988 int GetPortFromAddrinfo(const struct addrinfo* info) {
1981 uint16* port_field = GetPortFieldFromAddrinfo(info); 1989 uint16* port_field = GetPortFieldFromAddrinfo(info);
1982 if (!port_field) 1990 if (!port_field)
1983 return -1; 1991 return -1;
1984 return ntohs(*port_field); 1992 return ntohs(*port_field);
1985 } 1993 }
1986 1994
1987 } // namespace net 1995 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698