1. Have IPIsPrivate calling IPIsLinkLocal
2. Also check the Mac based IPv6
3. move the ip filtering into createnetwork. It shouldn't be done in IsIgnoredNetwork as the IP inside that could change later.
BUG=
R=juberti@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/48509004
Cr-Original-Commit-Position: refs/heads/master@{#8758}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: b91d0f513049b398e662c0ed98ddafe6d2e6ded2
diff --git a/base/ipaddress.cc b/base/ipaddress.cc
index be709c8..ae3b38d 100644
--- a/base/ipaddress.cc
+++ b/base/ipaddress.cc
@@ -300,9 +300,7 @@
return IsPrivateV4(ip.v4AddressAsHostOrderInteger());
}
case AF_INET6: {
- in6_addr v6 = ip.ipv6_address();
- return (v6.s6_addr[0] == 0xFE && v6.s6_addr[1] == 0x80) ||
- IPIsLoopback(ip);
+ return IPIsLinkLocal(ip) || IPIsLoopback(ip);
}
}
return false;
@@ -435,7 +433,16 @@
bool IPIsLinkLocal(const IPAddress& ip) {
// Can't use the helper because the prefix is 10 bits.
in6_addr addr = ip.ipv6_address();
- return addr.s6_addr[0] == 0xFE && (addr.s6_addr[1] & 0x80) == 0x80;
+ return addr.s6_addr[0] == 0xFE && addr.s6_addr[1] == 0x80;
+}
+
+// According to http://www.ietf.org/rfc/rfc2373.txt, Appendix A, page 19. An
+// address which contains MAC will have its 11th and 12th bytes as FF:FE as well
+// as the U/L bit as 1.
+bool IPIsMacBased(const IPAddress& ip) {
+ in6_addr addr = ip.ipv6_address();
+ return ((addr.s6_addr[8] & 0x02) && addr.s6_addr[11] == 0xFF &&
+ addr.s6_addr[12] == 0xFE);
}
bool IPIsSiteLocal(const IPAddress& ip) {