Documentation
¶
Overview ¶
Package icmp provides the logic for parsing ICMP packets
Package icmp has icmp tracerouting logic
Index ¶
Constants ¶
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 RunICMPTraceroute ¶
RunICMPTraceroute fully executes a ICMP traceroute using the given parameters
Types ¶
type Params ¶
type Params struct {
// Target is the IP:port to traceroute
Target netip.Addr
// ParallelParams are the standard params for parallel traceroutes
ParallelParams common.TracerouteParallelParams
// UseWindowsDriver controls whether to use driver-based packet capture (Windows)
UseWindowsDriver bool
}
Params is the ICMP traceroute parameters
type Parser ¶
type Parser interface {
Match(header *ipv4.Header, packet []byte, localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, innerIdentifier uint32, packetID uint16) (net.IP, error)
Parse(header *ipv4.Header, packet []byte) (*Response, error)
}
Parser defines the interface for parsing ICMP packets
func NewICMPTCPParser ¶
func NewICMPTCPParser() Parser
NewICMPTCPParser creates a new ICMPParser that can parse ICMP packets with embedded TCP packets
func NewICMPUDPParser ¶
func NewICMPUDPParser() Parser
NewICMPUDPParser creates a new ICMPParser that can parse ICMP packets with embedded UDP packets
type Response ¶
type Response struct {
SrcIP net.IP
DstIP net.IP
TypeCode layers.ICMPv4TypeCode
InnerIPID uint16
InnerSrcIP net.IP
InnerDstIP net.IP
InnerSrcPort uint16
InnerDstPort uint16
// InnerIdentifier will be populated with
// an additional identifcation field for matching
// received packets. For TCP packets, this is the
// sequence number. For UDP packets, this is the
// checksum, a uint16 cast to a uint32.
InnerIdentifier uint32
}
Response encapsulates the data from an ICMP response packet needed for matching
func (*Response) Matches ¶
func (i *Response) Matches(localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, innerIdentifier uint32, packetID uint16) bool
Matches checks if an ICMPResponse matches the expected response based on the local and remote IP, port, and identifier. In this context, identifier will either be the TCP sequence number OR the UDP checksum
type TCPParser ¶
type TCPParser struct {
// contains filtered or unexported fields
}
TCPParser encapsulates the data and logic for parsing ICMP packets with embedded TCP data
type UDPParser ¶
type UDPParser struct {
// contains filtered or unexported fields
}
UDPParser encapsulates the data and logic for parsing ICMP packets with embedded UDP data