icmp

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2026 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlowTimeout         = 30 * time.Second
	TraceIdentityLength = 16 + 8 + 1

	IPv4TTLExceededQuoteLen = 548
	IPv6TTLExceededQuoteLen = 1232
	MaxPayloadLen           = 1280
)

Variables

This section is empty.

Functions

func BuildTTLExceededPacket

func BuildTTLExceededPacket(packetInfo PacketInfo) ([]byte, error)

func EncodeDatagram

func EncodeDatagram(packet []byte, WireVersion WireVersion, traceContext TraceContext) ([]byte, error)

func EncodeV3Datagram

func EncodeV3Datagram(packet []byte) ([]byte, error)

func MaxEncodedPacketLen

func MaxEncodedPacketLen(WireVersion WireVersion, traceContext TraceContext) int

Types

type Bridge

type Bridge struct {
	WireVersion WireVersion
	// contains filtered or unexported fields
}

func NewBridge

func NewBridge(ctx context.Context, handler RouteHandler, sender protocol.DatagramSender, WireVersion WireVersion, logger logger.ContextLogger) *Bridge

func (*Bridge) HandleV2

func (b *Bridge) HandleV2(ctx context.Context, datagramType protocol.DatagramV2Type, payload []byte) error

func (*Bridge) HandleV3

func (b *Bridge) HandleV3(ctx context.Context, payload []byte) error

type FlowKey

type FlowKey struct {
	IPVersion   uint8
	SourceIP    netip.Addr
	Destination netip.Addr
}

type FlowState

type FlowState struct {
	// contains filtered or unexported fields
}

type PacketInfo

type PacketInfo struct {
	IPVersion     uint8
	Protocol      uint8
	SourceIP      netip.Addr
	Destination   netip.Addr
	ICMPType      uint8
	ICMPCode      uint8
	Identifier    uint16
	Sequence      uint16
	IPv4HeaderLen int
	IPv4TTL       uint8
	IPv6HopLimit  uint8
	RawPacket     []byte
}

func ParsePacket

func ParsePacket(packet []byte) (PacketInfo, error)

func (*PacketInfo) DecrementTTL

func (i *PacketInfo) DecrementTTL() error

func (PacketInfo) FlowKey

func (i PacketInfo) FlowKey() FlowKey

func (PacketInfo) IsEchoReply

func (i PacketInfo) IsEchoReply() bool

func (PacketInfo) IsEchoRequest

func (i PacketInfo) IsEchoRequest() bool

func (PacketInfo) ReplyRequestKey

func (i PacketInfo) ReplyRequestKey() RequestKey

func (PacketInfo) RequestKey

func (i PacketInfo) RequestKey() RequestKey

func (PacketInfo) TTL

func (i PacketInfo) TTL() uint8

func (PacketInfo) TTLExpired

func (i PacketInfo) TTLExpired() bool

type ReplyWriter

type ReplyWriter struct {
	WireVersion WireVersion
	// contains filtered or unexported fields
}

func NewReplyWriter

func NewReplyWriter(sender protocol.DatagramSender, WireVersion WireVersion) *ReplyWriter

func (*ReplyWriter) RegisterRequestTrace

func (w *ReplyWriter) RegisterRequestTrace(packetInfo PacketInfo, traceContext TraceContext)

func (*ReplyWriter) WritePacket

func (w *ReplyWriter) WritePacket(packet []byte) error

type RequestKey

type RequestKey struct {
	Flow       FlowKey
	Identifier uint16
	Sequence   uint16
}

type RouteHandler

type RouteHandler interface {
	RouteICMPConnection(
		ctx context.Context,
		session tun.DirectRouteSession,
		routeContext tun.DirectRouteContext,
		timeout time.Duration,
	) (tun.DirectRouteDestination, error)
}

type TraceContext

type TraceContext struct {
	Traced   bool
	Identity []byte
}

type TraceEntry

type TraceEntry struct {
	// contains filtered or unexported fields
}

type WireVersion

type WireVersion uint8
const (
	WireV2 WireVersion = iota + 1
	WireV3
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL