netutil

package
v0.0.0-...-6659799 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TCPFlagFIN = 1  // 0000 0001
	TCPFlagSYN = 2  // 0000 0010
	TCPFlagRST = 4  // 0000 0100
	TCPFlagPSH = 8  // 0000 1000
	TCPFlagACK = 16 // 0001 0000
	TCPFlagURG = 32 // 0010 0000
)

TCP flags

Variables

View Source
var (
	ErrInvalidIdentifier = errors.New("invalid tcp packet identifier")
	ErrCreateSocket      = errors.New("failed to create socket")
	ErrApplyFilter       = errors.New("failed to apply bpf filter")
	ErrMessageTooShort   = errors.New("input message is too short")
)

Possible return errors

Functions

This section is empty.

Types

type TCPPacket

type TCPPacket struct {
	// Header fields
	Source      uint16
	Destination uint16
	SeqNum      uint32
	AckNum      uint32
	DataOffset  uint8 // 4 bits
	Reserved    uint8 // 3 bits
	ECN         uint8 // 3 bits
	Ctrl        uint8 // 6 bits
	Window      uint16
	Checksum    uint16 // Kernel will set this if it's 0
	Urgent      uint16
}

TCPPacket describes a tcp packet

type TCPPacketIdentifier

type TCPPacketIdentifier struct {
	TargetPort uint16
	SeqNum     uint32
	AckNum     uint32
	TCPFlag    uint8
}

TCPPacketIdentifier provides instructions for filtering the packets

type TCPPacketSniffer

type TCPPacketSniffer interface {
	Capture(identifier *TCPPacketIdentifier) (<-chan *TCPPacket, error)
	Stop()
}

TCPPacketSniffer supports capturing tcp packets following designated pattern

func NewTCPPacketSniffer

func NewTCPPacketSniffer() TCPPacketSniffer

NewTCPPacketSniffer returns a new TCP packet sniffer

Directories

Path Synopsis
internal
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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