Documentation ¶
Index ¶
- func InitPacket(pkg Packet, ipPayloadLen int, src, dst net.IP)
- func L4Checksum(ipHdr Header, checksumPosition, l4Proto int)
- func NextID() int
- type Header
- type Packet
- type V4Header
- func (h V4Header) Checksum() int
- func (h V4Header) ConcatFragments(data *buffer.Data, fragsMap map[uint16][]*buffer.Data) *buffer.Data
- func (h V4Header) DSCP() int
- func (h V4Header) Destination() net.IP
- func (h V4Header) ECN() int
- func (h V4Header) Flags() ipv4.HeaderFlags
- func (h V4Header) FragmentOffset() int
- func (h V4Header) HeaderLen() int
- func (h V4Header) ID() uint16
- func (h V4Header) Initialize()
- func (h V4Header) L4Protocol() int
- func (h V4Header) Options() ([]V4Option, error)
- func (h V4Header) Packet() []byte
- func (h V4Header) Payload() []byte
- func (h V4Header) PayloadLen() int
- func (h V4Header) PseudoHeader(l4Proto int) []byte
- func (h V4Header) SetChecksum()
- func (h V4Header) SetDestination(ip net.IP)
- func (h V4Header) SetFlags(flags ipv4.HeaderFlags)
- func (h V4Header) SetFragmentOffset(fragOff int)
- func (h V4Header) SetHeaderLen(hl int)
- func (h V4Header) SetID(id int)
- func (h V4Header) SetL4Protocol(proto int)
- func (h V4Header) SetPayloadLen(len int)
- func (h V4Header) SetSource(ip net.IP)
- func (h V4Header) SetTTL(hops int)
- func (h V4Header) Source() net.IP
- func (h V4Header) TTL() int
- func (h V4Header) Version() int
- type V4Option
- type V6Header
- func (h V6Header) Destination() net.IP
- func (h V6Header) FlowLabel() int
- func (h V6Header) HeaderLen() int
- func (h V6Header) HopLimit() int
- func (h V6Header) Initialize()
- func (h V6Header) L4Protocol() int
- func (h V6Header) NextHeader() int
- func (h V6Header) Packet() []byte
- func (h V6Header) Payload() []byte
- func (h V6Header) PayloadLen() int
- func (h V6Header) ProcessFragments(data *buffer.Data, fragsMap map[uint16][]*buffer.Data) *buffer.Data
- func (h V6Header) PseudoHeader(l4Proto int) []byte
- func (h V6Header) SetChecksum()
- func (h V6Header) SetDestination(ip net.IP)
- func (h V6Header) SetL4Protocol(proto int)
- func (h V6Header) SetPayloadLen(tl int)
- func (h V6Header) SetSource(ip net.IP)
- func (h V6Header) SetTTL(hops int)
- func (h V6Header) Source() net.IP
- func (h V6Header) TrafficClass() int
- func (h V6Header) Version() int
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func L4Checksum ¶
L4Checksum computes a checksum for a layer 4 TCP or UDP header using a pseudo header created from the given IP header and assigns that checksum to the two bytes starting at checksumPosition.
The checksumPosition is the offset into the IP payload for the checksum for the given level-4 protocol which should be ipproto.TCP or ipproto.UDP.
It is assumed that the ipHdr represents an un-fragmented packet with a complete L4 payload.
Types ¶
type Header ¶
type Header interface { // Initialize ensures that the header has the correct version and that all other bytes are zero Initialize() // Version returns ipv4.Version or ipv6.Version Version() int // Destination returns the destination IP Destination() net.IP // Source returns the source IP Source() net.IP // HeaderLength() is the length of this header HeaderLen() int // PayloadLen is the length of the payload PayloadLen() int // L4Protocol is the protocol of the layer-4 header. L4Protocol() int // Packet returns the full packet that this header is backed by. Packet() []byte // Payload returns the payload of the packet that this header is backed by. Payload() []byte // PseudoHeader returns the pseudo header used when computing the checksum for a layer-4 header. // All fields must be filled in before requesting this header. PseudoHeader(l4Proto int) []byte // SetTTL sets the hop limit SetTTL(id int) // SetSource sets the packet source IP address SetSource(ip net.IP) // SetDestination sets the packet destination IP address SetDestination(ip net.IP) // SetL4Protocol sets the layer 4 protocol (a.k.a. the next-layer protocol) SetL4Protocol(int) // SetPayloadLen sets the length of the payload SetPayloadLen(int) // SetChecksum computes the checksum for this header. No further modifications must be made once this is called. // This method is a no-op for ipv6. SetChecksum() }
A Header provides a common interface for the V4Header and the V6Header
func ParseHeader ¶
ParseHeader returns a v4 or v6 header backed by the given argument. The type of header is determined by looking at the top 4 bits of the first byte which must match ipv4.Version or ipv6.Version
type V4Header ¶
type V4Header []byte
func (V4Header) ConcatFragments ¶
func (V4Header) Destination ¶
func (V4Header) Flags ¶
func (h V4Header) Flags() ipv4.HeaderFlags
func (V4Header) FragmentOffset ¶
func (V4Header) Initialize ¶
func (h V4Header) Initialize()
func (V4Header) L4Protocol ¶
func (V4Header) PayloadLen ¶
func (V4Header) PseudoHeader ¶
func (V4Header) SetChecksum ¶
func (h V4Header) SetChecksum()
func (V4Header) SetDestination ¶
func (V4Header) SetFlags ¶
func (h V4Header) SetFlags(flags ipv4.HeaderFlags)
func (V4Header) SetFragmentOffset ¶
func (V4Header) SetHeaderLen ¶
func (V4Header) SetL4Protocol ¶
func (V4Header) SetPayloadLen ¶
type V6Header ¶
type V6Header []byte
func (V6Header) Destination ¶
func (V6Header) Initialize ¶
func (h V6Header) Initialize()
func (V6Header) L4Protocol ¶
func (V6Header) NextHeader ¶
func (V6Header) PayloadLen ¶
func (V6Header) ProcessFragments ¶
func (V6Header) PseudoHeader ¶
func (V6Header) SetChecksum ¶
func (h V6Header) SetChecksum()