mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-16 18:08:40 +00:00
![David Anderson](/assets/img/avatar_default.png)
The packet filter still rejects all IPv6, but decodes enough from v6 packets to do something smarter in a followup. name time/op Decode/tcp4-8 28.8ns ± 2% Decode/tcp6-8 20.6ns ± 1% Decode/udp4-8 28.2ns ± 1% Decode/udp6-8 20.0ns ± 6% Decode/icmp4-8 21.7ns ± 2% Decode/icmp6-8 14.1ns ± 2% Decode/unknown-8 9.43ns ± 2% Signed-off-by: David Anderson <danderson@tailscale.com>
31 lines
563 B
Go
31 lines
563 B
Go
// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package packet
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"inet.af/netaddr"
|
|
)
|
|
|
|
type IP6 [16]byte
|
|
|
|
func IP6FromNetaddr(ip netaddr.IP) IP6 {
|
|
if !ip.Is6() {
|
|
panic(fmt.Sprintf("IP6FromNetaddr called with non-v6 addr %q", ip))
|
|
}
|
|
return IP6(ip.As16())
|
|
}
|
|
|
|
func (ip IP6) Netaddr() netaddr.IP {
|
|
return netaddr.IPFrom16(ip)
|
|
}
|
|
|
|
func (ip IP6) String() string {
|
|
return ip.Netaddr().String()
|
|
}
|
|
|
|
const ip6HeaderLength = 40
|