Documentation ¶
Index ¶
- Constants
- func ProtocolName(protocol uint8) string
- type ICMPv4Header
- func (h *ICMPv4Header) Body() uint32
- func (h *ICMPv4Header) Checksum() uint16
- func (h *ICMPv4Header) Code() uint8
- func (h *ICMPv4Header) DstPort() (uint16, error)
- func (h *ICMPv4Header) HeaderLen() int
- func (h *ICMPv4Header) NeedNewChecksum() bool
- func (h *ICMPv4Header) SetBody(body uint32)
- func (h *ICMPv4Header) SetCode(code uint8)
- func (h *ICMPv4Header) SetDstPort(port uint16) error
- func (h *ICMPv4Header) SetSrcPort(port uint16) error
- func (h *ICMPv4Header) SetType(hType uint8)
- func (h *ICMPv4Header) SrcPort() (uint16, error)
- func (h *ICMPv4Header) String() string
- func (h *ICMPv4Header) Type() uint8
- type ICMPv6Header
- func (h *ICMPv6Header) Body() uint32
- func (h *ICMPv6Header) Checksum() uint16
- func (h *ICMPv6Header) Code() uint8
- func (h *ICMPv6Header) DstPort() (uint16, error)
- func (h *ICMPv6Header) HeaderLen() int
- func (h *ICMPv6Header) NeedNewChecksum() bool
- func (h *ICMPv6Header) SetBody(body uint32)
- func (h *ICMPv6Header) SetCode(code uint8)
- func (h *ICMPv6Header) SetDstPort(port uint16) error
- func (h *ICMPv6Header) SetSrcPort(port uint16) error
- func (h *ICMPv6Header) SetType(hType uint8)
- func (h *ICMPv6Header) SrcPort() (uint16, error)
- func (h *ICMPv6Header) String() string
- func (h *ICMPv6Header) Type() uint8
- type IPHeader
- type IPv4Header
- func (h *IPv4Header) Checksum() (uint16, error)
- func (h *IPv4Header) DstIP() net.IP
- func (h *IPv4Header) Flags() uint8
- func (h *IPv4Header) FragOff() uint16
- func (h *IPv4Header) HeaderLen() uint8
- func (h *IPv4Header) ID() uint16
- func (h *IPv4Header) NeedNewChecksum() bool
- func (h *IPv4Header) NextHeader() uint8
- func (h *IPv4Header) Options() []byte
- func (h *IPv4Header) SetDstIP(ip net.IP)
- func (h *IPv4Header) SetSrcIP(ip net.IP)
- func (h *IPv4Header) SrcIP() net.IP
- func (h *IPv4Header) String() string
- func (h *IPv4Header) TOS() uint8
- func (h *IPv4Header) TTL() uint8
- func (h *IPv4Header) TotalLen() uint16
- func (h *IPv4Header) Version() int
- type IPv6Header
- func (h *IPv6Header) Checksum() (uint16, error)
- func (h *IPv6Header) DstIP() net.IP
- func (h *IPv6Header) FlowLabel() uint32
- func (h *IPv6Header) HeaderLen() uint8
- func (h *IPv6Header) HopLimit() uint8
- func (h *IPv6Header) NeedNewChecksum() bool
- func (h *IPv6Header) NextHeader() uint8
- func (h *IPv6Header) PayloadLen() uint16
- func (h *IPv6Header) SetDstIP(ip net.IP)
- func (h *IPv6Header) SetSrcIP(ip net.IP)
- func (h *IPv6Header) SrcIP() net.IP
- func (h *IPv6Header) String() string
- func (h *IPv6Header) TrafficClass() uint8
- func (h *IPv6Header) Version() int
- type ProtocolHeader
- type TCPHeader
- func (h *TCPHeader) ACK() bool
- func (h *TCPHeader) AckNum() uint32
- func (h *TCPHeader) CWR() bool
- func (h *TCPHeader) Checksum() uint16
- func (h *TCPHeader) DataOffset() uint8
- func (h *TCPHeader) DstPort() (uint16, error)
- func (h *TCPHeader) ECE() bool
- func (h *TCPHeader) FIN() bool
- func (h *TCPHeader) HeaderLen() int
- func (h *TCPHeader) NS() bool
- func (h *TCPHeader) NeedNewChecksum() bool
- func (h *TCPHeader) Options() []byte
- func (h *TCPHeader) PSH() bool
- func (h *TCPHeader) RST() bool
- func (h *TCPHeader) Reserved() uint8
- func (h *TCPHeader) SYN() bool
- func (h *TCPHeader) SeqNum() uint32
- func (h *TCPHeader) SetDstPort(port uint16) error
- func (h *TCPHeader) SetSrcPort(port uint16) error
- func (h *TCPHeader) SrcPort() (uint16, error)
- func (h *TCPHeader) String() string
- func (h *TCPHeader) URG() bool
- func (h *TCPHeader) UrgPtr() uint16
- func (h *TCPHeader) Window() uint16
- type UDPHeader
- func (h *UDPHeader) Checksum() uint16
- func (h *UDPHeader) DstPort() (uint16, error)
- func (h *UDPHeader) HeaderLen() int
- func (h *UDPHeader) Len() uint16
- func (h *UDPHeader) NeedNewChecksum() bool
- func (h *UDPHeader) SetDstPort(port uint16) error
- func (h *UDPHeader) SetSrcPort(port uint16) error
- func (h *UDPHeader) SrcPort() (uint16, error)
- func (h *UDPHeader) String() string
Constants ¶
const ( IPv4HeaderLen = 20 MaxIPv4HeaderLen = 60 IPv6HeaderLen = 40 TCPHeaderLen = 20 MaxTCPHeaderLen = 60 UDPHeaderLen = 8 ICMPv4HeaderLen = 8 ICMPv6HeaderLen = 8 ICMPv4 = 1 TCP = 6 UDP = 17 ICMPv6 = 58 IPv4 = 4 IPv6 = 6 )
Variables ¶
This section is empty.
Functions ¶
func ProtocolName ¶
Returns the name of the given protocol number See : https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers
Types ¶
type ICMPv4Header ¶
Represents a ICMP header https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#Header
func NewICMPv4Header ¶
func NewICMPv4Header(raw []byte) *ICMPv4Header
func (*ICMPv4Header) Body ¶
func (h *ICMPv4Header) Body() uint32
Reads the header's bytes and returns the body (Rest of the Header)
func (*ICMPv4Header) Checksum ¶
func (h *ICMPv4Header) Checksum() uint16
Reads the header's bytes and returns the Checksum
func (*ICMPv4Header) Code ¶
func (h *ICMPv4Header) Code() uint8
Reads the header's bytes and returns the code
func (*ICMPv4Header) HeaderLen ¶
func (h *ICMPv4Header) HeaderLen() int
Returns the length of the header in bytes (8 bytes)
func (*ICMPv4Header) NeedNewChecksum ¶
func (h *ICMPv4Header) NeedNewChecksum() bool
Returns true if the header has been modified
func (*ICMPv4Header) SetBody ¶
func (h *ICMPv4Header) SetBody(body uint32)
func (*ICMPv4Header) SetCode ¶
func (h *ICMPv4Header) SetCode(code uint8)
func (*ICMPv4Header) SetDstPort ¶
func (h *ICMPv4Header) SetDstPort(port uint16) error
Not used for ICMP
func (*ICMPv4Header) SetSrcPort ¶
func (h *ICMPv4Header) SetSrcPort(port uint16) error
Not used for ICMP
func (*ICMPv4Header) SetType ¶
func (h *ICMPv4Header) SetType(hType uint8)
func (*ICMPv4Header) String ¶
func (h *ICMPv4Header) String() string
func (*ICMPv4Header) Type ¶
func (h *ICMPv4Header) Type() uint8
Reads the header's bytes and returns the type
type ICMPv6Header ¶
Represents a ICMPv6 header https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol_for_IPv6#Message_types_and_formats
func NewICMPv6Header ¶
func NewICMPv6Header(raw []byte) *ICMPv6Header
func (*ICMPv6Header) Body ¶
func (h *ICMPv6Header) Body() uint32
Reads the header's bytes and returns the body (Rest of the Header)
func (*ICMPv6Header) Checksum ¶
func (h *ICMPv6Header) Checksum() uint16
Reads the header's bytes and returns the Checksum
func (*ICMPv6Header) Code ¶
func (h *ICMPv6Header) Code() uint8
Reads the header's bytes and returns the type
func (*ICMPv6Header) HeaderLen ¶
func (h *ICMPv6Header) HeaderLen() int
Returns the length of the header in bytes (8 bytes)
func (*ICMPv6Header) NeedNewChecksum ¶
func (h *ICMPv6Header) NeedNewChecksum() bool
Returns true if the header has been modified
func (*ICMPv6Header) SetBody ¶
func (h *ICMPv6Header) SetBody(body uint32)
func (*ICMPv6Header) SetCode ¶
func (h *ICMPv6Header) SetCode(code uint8)
func (*ICMPv6Header) SetDstPort ¶
func (h *ICMPv6Header) SetDstPort(port uint16) error
Not used for ICMPv6
func (*ICMPv6Header) SetSrcPort ¶
func (h *ICMPv6Header) SetSrcPort(port uint16) error
Not used for ICMPv6
func (*ICMPv6Header) SetType ¶
func (h *ICMPv6Header) SetType(hType uint8)
func (*ICMPv6Header) String ¶
func (h *ICMPv6Header) String() string
func (*ICMPv6Header) Type ¶
func (h *ICMPv6Header) Type() uint8
Reads the header's bytes and returns the type
type IPHeader ¶
type IPHeader interface { String() string Version() int HeaderLen() uint8 NextHeader() uint8 SrcIP() net.IP DstIP() net.IP SetSrcIP(net.IP) SetDstIP(net.IP) Checksum() (uint16, error) NeedNewChecksum() bool }
Represents a IPv4 or IPv6 Header
type IPv4Header ¶
Represents a IPv4 Header https://en.wikipedia.org/wiki/IPv4#Header
func NewIPv4Header ¶
func NewIPv4Header(raw []byte) *IPv4Header
func (*IPv4Header) Checksum ¶
func (h *IPv4Header) Checksum() (uint16, error)
Reads the header's bytes and returns the Checksum
func (*IPv4Header) DstIP ¶
func (h *IPv4Header) DstIP() net.IP
Reads the header's bytes and returns the destination IP
func (*IPv4Header) Flags ¶
func (h *IPv4Header) Flags() uint8
Reads the header's bytes and returns the flags
func (*IPv4Header) FragOff ¶
func (h *IPv4Header) FragOff() uint16
Reads the header's bytes and returns the Fragment Offset
func (*IPv4Header) HeaderLen ¶
func (h *IPv4Header) HeaderLen() uint8
Reads the header's bytes and returns its length
func (*IPv4Header) ID ¶
func (h *IPv4Header) ID() uint16
Reads the header's bytes and returns the ID
func (*IPv4Header) NeedNewChecksum ¶
func (h *IPv4Header) NeedNewChecksum() bool
Returns true if the header has been modified
func (*IPv4Header) NextHeader ¶
func (h *IPv4Header) NextHeader() uint8
Reads the header's bytes and returns the protocol number
func (*IPv4Header) Options ¶
func (h *IPv4Header) Options() []byte
Reads the header's bytes and returns the options as a byte slice if they exist or nil
func (*IPv4Header) SetDstIP ¶
func (h *IPv4Header) SetDstIP(ip net.IP)
Sets the destination IP of the packet
func (*IPv4Header) SetSrcIP ¶
func (h *IPv4Header) SetSrcIP(ip net.IP)
Sets the source IP of the packet
func (*IPv4Header) SrcIP ¶
func (h *IPv4Header) SrcIP() net.IP
Reads the header's bytes and returns the source IP
func (*IPv4Header) String ¶
func (h *IPv4Header) String() string
func (*IPv4Header) TOS ¶
func (h *IPv4Header) TOS() uint8
Reads the header's bytes and returns the Type Of Service
func (*IPv4Header) TTL ¶
func (h *IPv4Header) TTL() uint8
Reads the header's bytes and returns the Time To Live of the packet
func (*IPv4Header) TotalLen ¶
func (h *IPv4Header) TotalLen() uint16
Reads the header's bytes and returns the total length of the packet
type IPv6Header ¶
Represents a IPv6 header https://en.wikipedia.org/wiki/IPv6_packet#Fixed_header
func NewIPv6Header ¶
func NewIPv6Header(raw []byte) *IPv6Header
func (*IPv6Header) Checksum ¶
func (h *IPv6Header) Checksum() (uint16, error)
Always returns 0 and an error as IPv6 has no checksum
func (*IPv6Header) DstIP ¶
func (h *IPv6Header) DstIP() net.IP
Reads the header's bytes and returns the destination IP
func (*IPv6Header) FlowLabel ¶
func (h *IPv6Header) FlowLabel() uint32
Reads the header's bytes and returns the flow label
func (*IPv6Header) HeaderLen ¶
func (h *IPv6Header) HeaderLen() uint8
Returns the length of the header in bytes (40 bytes)
func (*IPv6Header) HopLimit ¶
func (h *IPv6Header) HopLimit() uint8
Reads the header's bytes and returns the hop limit
func (*IPv6Header) NeedNewChecksum ¶
func (h *IPv6Header) NeedNewChecksum() bool
Always returns false as IPv6 has no checksum
func (*IPv6Header) NextHeader ¶
func (h *IPv6Header) NextHeader() uint8
Reads the header's bytes and returns the protocol number
func (*IPv6Header) PayloadLen ¶
func (h *IPv6Header) PayloadLen() uint16
Reads the header's bytes and returns the length of the payload
func (*IPv6Header) SetDstIP ¶
func (h *IPv6Header) SetDstIP(ip net.IP)
Sets the destination IP of the packet
func (*IPv6Header) SetSrcIP ¶
func (h *IPv6Header) SetSrcIP(ip net.IP)
Sets the source IP of the packet
func (*IPv6Header) SrcIP ¶
func (h *IPv6Header) SrcIP() net.IP
Reads the header's bytes and returns the source IP
func (*IPv6Header) String ¶
func (h *IPv6Header) String() string
func (*IPv6Header) TrafficClass ¶
func (h *IPv6Header) TrafficClass() uint8
Reads the header's bytes and returns the traffic class
type ProtocolHeader ¶
type ProtocolHeader interface { String() string HeaderLen() int Checksum() uint16 SrcPort() (uint16, error) DstPort() (uint16, error) SetSrcPort(uint16) error SetDstPort(uint16) error NeedNewChecksum() bool }
Represents a protocol header Supported headers are TCP, UDP, ICMPv4, ICMPv6
type TCPHeader ¶
Represents a TCP header https://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure
func NewTCPHeader ¶
func (*TCPHeader) DataOffset ¶
Reads the header's bytes and returns the data offset
func (*TCPHeader) HeaderLen ¶
Reads the header's bytes and returns the length of the header in bytes
func (*TCPHeader) NeedNewChecksum ¶
Returns true if the header has been modified
func (*TCPHeader) Options ¶
Reads the header's bytes and returns the options as a byte slice if they exist or nil
func (*TCPHeader) SetDstPort ¶
Sets the destination port
func (*TCPHeader) SetSrcPort ¶
Sets the source port
type UDPHeader ¶
Represents a UDP header https://en.wikipedia.org/wiki/User_Datagram_Protocol#Packet_structure
func NewUDPHeader ¶
func (*UDPHeader) NeedNewChecksum ¶
Returns true if the header has been modified
func (*UDPHeader) SetDstPort ¶
Sets the destination port
func (*UDPHeader) SetSrcPort ¶
Sets the source port