common

package
v0.0.0-...-46749fd Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package common contains common functionality for both TCP and UDP traceroute implementations

Index

Constants

View Source
const (
	// IPProtoICMP is the IP protocol number for ICMP
	// we create our own constant here because there are
	// different imports for the constant in different
	// operating systems
	IPProtoICMP = 1
)

Variables

This section is empty.

Functions

func ICMPMatch

func ICMPMatch(localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, seqNum uint32, response *ICMPResponse) bool

ICMPMatch checks if an ICMP response matches the expected response based on the local and remote IP, port, and sequence number

func LocalAddrForHost

func LocalAddrForHost(destIP net.IP, destPort uint16) (*net.UDPAddr, error)

LocalAddrForHost takes in a destionation IP and port and returns the local address that should be used to connect to the destination

Types

type CanceledError

type CanceledError string

CanceledError is sent when a listener is canceled

func (CanceledError) Error

func (c CanceledError) Error() string

type Hop

type Hop struct {
	IP       net.IP
	Port     uint16
	ICMPType layers.ICMPv4TypeCode
	RTT      time.Duration
	IsDest   bool
}

Hop encapsulates information about a single hop in a traceroute

type ICMPResponse

type ICMPResponse struct {
	SrcIP        net.IP
	DstIP        net.IP
	TypeCode     layers.ICMPv4TypeCode
	InnerSrcIP   net.IP
	InnerDstIP   net.IP
	InnerSrcPort uint16
	InnerDstPort uint16
	InnerSeqNum  uint32
}

ICMPResponse encapsulates the data from an ICMP response packet needed for matching

func ParseICMP

func ParseICMP(header *ipv4.Header, payload []byte) (*ICMPResponse, error)

ParseICMP takes in an IPv4 header and payload and tries to convert to an ICMP message, it returns all the fields from the packet we need to validate it's the response we're looking for

type Results

type Results struct {
	Source     net.IP
	SourcePort uint16
	Target     net.IP
	DstPort    uint16
	Hops       []*Hop
}

Results encapsulates a response from the traceroute

Jump to

Keyboard shortcuts

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