sniffer

package
v0.0.0-...-c37fa34 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GO_ETH_P_ALL = (sys.ETH_P_ALL<<8)&0xff00 | sys.ETH_P_ALL>>8
	IFA_MAX      = 20
)

Variables

Functions

func IPBytesToString

func IPBytesToString(ip [4]byte) string

func MacBytesToString

func MacBytesToString(mac [6]byte) string

Types

type ARPHeader

type ARPHeader struct {
	HardwareType          uint16
	ProtocolType          uint16
	HardwareAddressLength uint8
	ProtocolAddressLength uint8
	Operation             uint16
	SenderHardwareAddress [6]byte
	SenderIP              [4]byte
	TargetHardwareAddress [6]byte
	TargetIP              [4]byte
}

type ARPLayer

type ARPLayer struct {
	ARPHdr ARPHeader
}

func (*ARPLayer) FromBytes

func (e *ARPLayer) FromBytes(buf []byte) (uintptr, uintptr)

func (*ARPLayer) NextLayer

func (il *ARPLayer) NextLayer() PacketLayer

func (*ARPLayer) Payload

func (il *ARPLayer) Payload() []byte

func (*ARPLayer) Print

func (al *ARPLayer) Print(fd *os.File)

func (*ARPLayer) Type

func (il *ARPLayer) Type() string

type Capture

type Capture struct {
	Fd int
}

func (*Capture) Cap

func (c *Capture) Cap(cb func(EthLayer, uintptr, uintptr))

func (*Capture) Capn

func (c *Capture) Capn(loop int, cb func(EthLayer, uintptr, uintptr))

func (*Capture) CreateCap

func (c *Capture) CreateCap(ifa string)

func (*Capture) Destroy

func (c *Capture) Destroy()

func (Capture) GetIfaces

func (c Capture) GetIfaces() []string

type EthHeader

type EthHeader struct {
	Dhost [6]byte
	Shost [6]byte
	Proto uint16
}

type EthLayer

type EthLayer struct {
	EthHdr EthHeader
	// contains filtered or unexported fields
}

func (*EthLayer) FromBytes

func (e *EthLayer) FromBytes(buf []byte) (uintptr, uintptr)

func (*EthLayer) NextLayer

func (el *EthLayer) NextLayer() PacketLayer

func (*EthLayer) Payload

func (el *EthLayer) Payload() []byte

func (*EthLayer) Print

func (el *EthLayer) Print(fd *os.File)

func (*EthLayer) Type

func (el *EthLayer) Type() string

type IPHeader

type IPHeader struct {
	VersionAndIHL uint8
	TypeOfService uint8
	TotalLength   uint16
	ID            uint16
	Flags         uint16
	TTL           uint8
	Protocol      uint8
	Checksum      uint16
	SrcIP         [4]byte
	DstIP         [4]byte
}

type IPLayer

type IPLayer struct {
	IPHdr IPHeader
	// contains filtered or unexported fields
}

func (*IPLayer) FromBytes

func (e *IPLayer) FromBytes(buf []byte) (uintptr, uintptr)

func (*IPLayer) NextLayer

func (il *IPLayer) NextLayer() PacketLayer

func (*IPLayer) Payload

func (il *IPLayer) Payload() []byte

func (*IPLayer) Print

func (il *IPLayer) Print(fd *os.File)

func (*IPLayer) Type

func (il *IPLayer) Type() string

type PacketLayer

type PacketLayer interface {
	Type() string
	Payload() []byte
	NextLayer() PacketLayer
	FromBytes(buf []byte) (uintptr, uintptr)
	Print(fd *os.File)
}

Jump to

Keyboard shortcuts

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