Documentation
¶
Overview ¶
Package packet contains *Packet and the related definitions.
Index ¶
Constants ¶
View Source
const ( // IPProtocolTCP is the TCP protocol number. IPProtocolTCP = 6 // IPProtocolUDP is the UDP protocol number. IPProtocolUDP = 17 )
View Source
const ( // TCPFlagFIN is the FIN flag. TCPFlagFIN = 1 // TCPFlagSYN is the SYN flag. TCPFlagSYN = 2 // TCPFlagRST is the RST flag. TCPFlagRST = 4 // TCPFlagPSH is the PSH flag. TCPFlagPSH = 8 // TCPFlagACK is the ACK flag. TCPFlagACK = 16 )
View Source
const DefaultBufferChannel = 128
DefaultBufferChannel is the required buffering for NetworkDevice channels.
Variables ¶
This section is empty.
Functions ¶
func NewNetworkDeviceIOChannels ¶
NewNetworkDeviceIOChannels constructs two channels with size == DefaultBufferChannel.
Types ¶
type Filter ¶
Filter processes *Packet and determines its fate.
The Filter method returns the Target and optionally a list of new packets to inject.
type FilterFunc ¶
FilterFunc allows using a function as a Filter.
type IPProtocol ¶
type IPProtocol uint8
IPProtocol is the protocol number of an IP packet.
func (IPProtocol) String ¶
func (p IPProtocol) String() string
String returns the string representation of the IP protocol.
type NetworkDevice ¶
type NetworkDevice interface { // Addresses returns the device addresses. Addresses() []netip.Addr // EOF returns a channel that is closed when the device is closed. EOF() <-chan struct{} // Input returns a channel to send [*Packet] to the device. // // The channel must have size >= [DefaultBufferChannel]. Input() chan<- *Packet // Output returns a channel to receive [*Packet] from the device. // // The channel must have size >= [DefaultBufferChannel]. Output() <-chan *Packet }
NetworkDevice is a network device to read/write *Packet.
type Packet ¶
type Packet struct { // TTL is the packet time to live. TTL uint8 // SrcAddr is the source address. SrcAddr netip.Addr // DstAddr is the destination address. DstAddr netip.Addr // IPProtocol is the protocol number. IPProtocol IPProtocol // SrcPort is the source port. SrcPort uint16 // DstPort is the destination port. DstPort uint16 // TCPFlags is the TCP flags. Flags TCPFlags // Payload is the packet payload. Payload []byte }
Packet is a network packet.
Click to show internal directories.
Click to hide internal directories.