From e491ebbacf548a2a2f818f1093b09d6f1c13e7e0 Mon Sep 17 00:00:00 2001 From: Chris Kuiper Date: Sun, 16 Dec 2018 23:04:56 -0800 Subject: Allow sending of multicast and IPv6 link-local packets w/o route. Same as with broadcast packets, sending of a multicast packet shouldn't require accessing the route table. The same applies to IPv6 link-local addresses, which aren't routable at all (they don't belong to any subnet by definition). PiperOrigin-RevId: 225775870 Change-Id: Ic53e6560c125a83be2be9c3d112e66b36e8dfe7b --- pkg/tcpip/header/ipv6.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'pkg/tcpip/header') diff --git a/pkg/tcpip/header/ipv6.go b/pkg/tcpip/header/ipv6.go index d985b745d..3d24736c7 100644 --- a/pkg/tcpip/header/ipv6.go +++ b/pkg/tcpip/header/ipv6.go @@ -77,6 +77,9 @@ const ( // IPv6MinimumMTU is the minimum MTU required by IPv6, per RFC 2460, // section 5. IPv6MinimumMTU = 1280 + + // IPv6Any is the non-routable IPv6 "any" meta address. + IPv6Any tcpip.Address = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" ) // PayloadLength returns the value of the "payload length" field of the ipv6 @@ -234,3 +237,12 @@ func LinkLocalAddr(linkAddr tcpip.LinkAddress) tcpip.Address { } return tcpip.Address(lladdrb[:]) } + +// IsV6LinkLocalAddress determines if the provided address is an IPv6 +// link-local address (fe80::/10). +func IsV6LinkLocalAddress(addr tcpip.Address) bool { + if len(addr) != IPv6AddressSize { + return false + } + return addr[0] == 0xfe && (addr[1]&0xc0) == 0x80 +} -- cgit v1.2.3