mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-03 02:21:58 +00:00
net/packet: add IPv6 source and destination IPs to Parsed.
Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
committed by
Dave Anderson
parent
d192bd0f86
commit
89894c6930
24
net/packet/ip6.go
Normal file
24
net/packet/ip6.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user