Documentation ¶
Overview ¶
Package icmp provides the logic for parsing ICMP packets
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 ¶
This section is empty.
Types ¶
type Parser ¶
type Parser interface { Match(header *ipv4.Header, packet []byte, localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, innerIdentifier uint32) (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 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) 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