ipv4

package
v0.0.0-...-c97f47a Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: BSD-2-Clause Imports: 4 Imported by: 1

Documentation

Overview

Provides encoding and decoding for IPv4 packets.

Index

Constants

View Source
const (
	Evil          Flags = 1 << 2 /* RFC3514 */
	DontFragment        = 1 << 1
	MoreFragments       = 1 << 0
)
View Source
const (
	None     Protocol = 0x00
	GRE               = 0x2F
	ICMPv4            = 0x01
	ICMPv6            = 0x3A
	IGMP              = 0x02
	IPSecAH           = 0x33
	IPSecESP          = 0x32
	IPv6              = 0x29
	ISIS              = 0x7C
	L2TP              = 0x73
	OSPF              = 0x59
	SCTP              = 0x84
	TCP               = 0x06
	UDP               = 0x11
	UDPLite           = 0x88
)

Variables

This section is empty.

Functions

func CalculateChecksum

func CalculateChecksum(raw_bytes []byte, csum uint32) uint16

func ProtocolToType

func ProtocolToType(proto Protocol) packet.Type

Create a new Type from the given IP protocol ID.

Types

type Flags

type Flags uint8

func (Flags) String

func (f Flags) String() string

type Packet

type Packet struct {
	Version  uint8
	IHL      uint8
	TOS      uint8  `cmp:"skip"`
	Length   uint16 `cmp:"skip"`
	Id       uint16
	Flags    Flags
	FragOff  uint16
	TTL      uint8    `cmp:"skip"`
	Protocol Protocol `string:"proto"`
	Checksum uint16   `cmp:"skip" string:"sum"`
	SrcAddr  net.IP   `string:"src"`
	DstAddr  net.IP   `string:"dst"`
	// contains filtered or unexported fields
}

func Make

func Make() *Packet

func (*Packet) Answers

func (p *Packet) Answers(other packet.Packet) bool

func (*Packet) Equals

func (p *Packet) Equals(other packet.Packet) bool

func (*Packet) GetLength

func (p *Packet) GetLength() uint16

func (*Packet) GetType

func (p *Packet) GetType() packet.Type

func (*Packet) GuessPayloadType

func (p *Packet) GuessPayloadType() packet.Type

func (*Packet) InitChecksum

func (p *Packet) InitChecksum(csum uint32)

func (*Packet) Pack

func (p *Packet) Pack(buf *packet.Buffer) error

func (*Packet) Payload

func (p *Packet) Payload() packet.Packet

func (*Packet) SetPayload

func (p *Packet) SetPayload(pl packet.Packet) error

func (*Packet) String

func (p *Packet) String() string

func (*Packet) Unpack

func (p *Packet) Unpack(buf *packet.Buffer) error

type Protocol

type Protocol uint8

func TypeToProtocol

func TypeToProtocol(pkttype packet.Type) Protocol

Convert the Type to the corresponding IP protocol ID.

func (Protocol) String

func (p Protocol) String() string

Jump to

Keyboard shortcuts

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