layers

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ETHERTYPE = map[uint16]string{
	0x0800: "IPv4",
	0x0806: "ARP",
	0x86dd: "IPv6",
}

Ethernet Types

View Source
var HARDWARE_TYPES = map[uint16]string{
	1:  "Ethernet (10Mb)",
	2:  "Ethernet (3Mb)",
	3:  "AX.25",
	4:  "Proteon ProNET Token Ring",
	5:  "Chaos",
	6:  "IEEE 802 Networks",
	7:  "ARCNET",
	8:  "Hyperchannel",
	9:  "Lanstar",
	10: "Autonet Short Address",
	11: "LocalTalk",
	12: "LocalNet",
	13: "Ultra link",
	14: "SMDS",
	15: "Frame relay",
	16: "ATM",
	17: "HDLC",
	18: "Fibre Channel",
	19: "ATM",
	20: "Serial Line",
	21: "ATM",
}
View Source
var IHLLENGTH = map[uint8]string{
	5:  "20 bytes",
	6:  "24 bytes",
	7:  "28 bytes",
	8:  "32 bytes",
	9:  "36 bytes",
	10: "40 bytes",
	11: "44 bytes",
	12: "48 bytes",
	13: "52 bytes",
	14: "56 bytes",
	15: "60 bytes",
}

IHL Lengths

View Source
var IPOPTIONS = map[uint8]string{
	0:  "end_of_list",
	1:  "nop",
	2:  "security",
	3:  "loose_source_route",
	4:  "timestamp",
	5:  "extended_security",
	6:  "commercial_security",
	7:  "record_route",
	8:  "stream_id",
	9:  "strict_source_route",
	10: "experimental_measurement",
	11: "mtu_probe",
	12: "mtu_reply",
	13: "flow_control",
	14: "access_control",
	15: "encode",
	16: "imi_traffic_descriptor",
	17: "extended_IP",
	18: "traceroute",
	19: "address_extension",
	20: "router_alert",
	21: "selective_directed_broadcast_mode",
	23: "dynamic_packet_state",
	24: "upstream_multicast_packet",
	25: "quick_start",
	30: "rfc4727_experiment",
}

IP Options

View Source
var OPCODE = map[uint16]string{
	1: "who-has",
	2: "is-at",
	3: "RARP-req",
	4: "RARP-rep",
	5: "Dyn-RARP-req",
	6: "Dyn-RAR-rep",
	7: "Dyn-RARP-err",
	8: "InARP-req",
	9: "InARP-rep",
}

Functions

This section is empty.

Types

type ARP

type ARP struct {
	Hwtype uint16
	Ptype  uint16
	Hwlen  uint8
	Plen   uint8
	Opcode uint16
	Hwsrc  net.HardwareAddr
	Psrc   net.IP
	Hwdst  net.HardwareAddr
	Pdst   net.IP
}

func ARPLayer added in v0.3.0

func ARPLayer() ARP

Create and return an ARP layer with default value set

func (*ARP) BindLayer

func (a *ARP) BindLayer() Layer

func (*ARP) Build

func (a *ARP) Build() *buffer.ProtoBuff

TODO: Take into account the addition of paddind depending on frame size

func (*ARP) Dissect

func (a *ARP) Dissect(buffer *buffer.ProtoBuff) *buffer.ProtoBuff

func (*ARP) GetName

func (a *ARP) GetName() string

func (*ARP) SetDefault added in v0.3.0

func (a *ARP) SetDefault()

Set a default value for each layer field

type Ether

type Ether struct {
	Dst  net.HardwareAddr
	Src  net.HardwareAddr
	Type uint16
}

func EtherLayer added in v0.3.0

func EtherLayer() Ether

Create and return an Ether layer with default value set

func (Ether) BindLayer

func (e Ether) BindLayer() Layer

BindLayer return the top

func (*Ether) Build

func (e *Ether) Build() *buffer.ProtoBuff

Serialize will convert a layer into bytes

func (*Ether) Dissect

func (e *Ether) Dissect(buffer *buffer.ProtoBuff) *buffer.ProtoBuff

Deserialize will convert bytes into a layer

func (Ether) GetName

func (e Ether) GetName() string

GetName returns the protocol name.

func (*Ether) SetDefault added in v0.3.0

func (e *Ether) SetDefault()

Set a default value for each layer field

type IP

type IP struct {
	Version    uint8
	IHL        uint8
	TOS        uint8
	Length     uint16
	ID         uint16
	Flags      uint8
	FragOffset uint8
	TTL        uint8
	Protocol   uint8
	Checksum   uint16
	Src        net.IP
	Dst        net.IP
}

func IPLayer added in v0.4.5

func IPLayer() IP

Create and return an IP layer with default value set

func IPv4Layer added in v0.4.5

func IPv4Layer() IP

func (*IP) BindLayer added in v0.4.5

func (i *IP) BindLayer() Layer

func (*IP) Build added in v0.4.5

func (i *IP) Build() *buffer.ProtoBuff

func (*IP) Dissect added in v0.4.5

func (i *IP) Dissect(buffer *buffer.ProtoBuff) *buffer.ProtoBuff

func (*IP) GetName

func (i *IP) GetName() string

func (*IP) SetDefault added in v0.4.5

func (i *IP) SetDefault()

type IP_Options added in v0.4.5

type IP_Options struct {
	Type   uint8
	Length uint8
	Data   uint8
}

type Layer

type Layer interface {
	GetName() string
	SetDefault()
	Build() *buffer.ProtoBuff
	Dissect(*buffer.ProtoBuff) *buffer.ProtoBuff
	BindLayer() Layer
}

Layer is an interface representing a layer of the package.

type Raw

type Raw struct {
	Load []byte
}

func RawLayer added in v0.3.0

func RawLayer() Raw

func (*Raw) BindLayer

func (r *Raw) BindLayer() Layer

func (*Raw) Build

func (r *Raw) Build() *buffer.ProtoBuff

func (*Raw) Dissect

func (r *Raw) Dissect(buf *buffer.ProtoBuff) *buffer.ProtoBuff

func (*Raw) GetName

func (r *Raw) GetName() string

func (*Raw) SetDefault added in v0.3.0

func (r *Raw) SetDefault()

type TCP

type TCP struct {
	SrcPort       uint16
	DstPort       uint16
	Seq           uint32
	Ack           uint32
	DataOffset    uint8
	Reserved      uint8
	Flags         uint16
	WindowSize    uint16
	Checksum      uint16
	UrgentPointer uint16
	Options       []byte
	Padding       []byte
}

Jump to

Keyboard shortcuts

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