mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-11 10:44:41 +00:00
55b1221db2
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>
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
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
|
|
|
|
// IPProto is an IP subprotocol as defined by the IANA protocol
|
|
// numbers list
|
|
// (https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml),
|
|
// or the special values Unknown or Fragment.
|
|
type IPProto uint8
|
|
|
|
const (
|
|
// Unknown represents an unknown or unsupported protocol; it's
|
|
// deliberately the zero value. Strictly speaking the zero
|
|
// value is IPv6 hop-by-hop extensions, but we don't support
|
|
// those, so this is still technically correct.
|
|
Unknown IPProto = 0x00
|
|
|
|
// Values from the IANA registry.
|
|
ICMPv4 IPProto = 0x01
|
|
IGMP IPProto = 0x02
|
|
ICMPv6 IPProto = 0x3a
|
|
TCP IPProto = 0x06
|
|
UDP IPProto = 0x11
|
|
|
|
// Fragment represents any non-first IP fragment, for which we
|
|
// don't have the sub-protocol header (and therefore can't
|
|
// figure out what the sub-protocol is).
|
|
//
|
|
// 0xFF is reserved in the IANA registry, so we steal it for
|
|
// internal use.
|
|
Fragment IPProto = 0xFF
|
|
)
|
|
|
|
func (p IPProto) String() string {
|
|
switch p {
|
|
case Fragment:
|
|
return "Frag"
|
|
case ICMPv4:
|
|
return "ICMPv4"
|
|
case IGMP:
|
|
return "IGMP"
|
|
case ICMPv6:
|
|
return "ICMPv6"
|
|
case UDP:
|
|
return "UDP"
|
|
case TCP:
|
|
return "TCP"
|
|
default:
|
|
return "Unknown"
|
|
}
|
|
}
|