Documentation
¶
Index ¶
- Constants
- func Addr(sa *SockAddr) []byte
- func AddrLen(sa *SockAddr) uint8
- func AddrType(sa *SockAddr) uint16
- func Family(sa *SockAddr) uint16
- func Htons(value uint16) uint16
- func Ifindex(sa *SockAddr) uint32
- func PacketType(sa *SockAddr) uint8
- func SockProtocol(sa *SockAddr) uint16
- type Option
- func BerkleyPacketFilter(bpf string) Option
- func Domain(domain int) Option
- func MaxFrameSize(frameSize uint16) Option
- func MaxTotalFrames(maxFrames uint) Option
- func PacketRxFilter(filter func(nettypes.Frame, uint32, uint32) nettypes.Frame) Option
- func Protocol(proto uint16) Option
- func RxChannel(channel chan nettypes.Frame) Option
- func RxEnable(enable bool) Option
- func TxEnable(enable bool) Option
- func Version(version TPacketVersion) Option
- func VlanRxAdjustEnable(enable bool) Option
- type RawSocket
- func (sock *RawSocket) Close()
- func (sock *RawSocket) Flush() (uint, error, []error)
- func (sock *RawSocket) MaxPacketSize() uint16
- func (sock *RawSocket) MaxPackets() int32
- func (sock *RawSocket) MaxTxPacketSize() uint16
- func (sock *RawSocket) Open() error
- func (sock *RawSocket) String() string
- func (sock *RawSocket) TPacketVersion() TPacketVersion
- func (sock *RawSocket) TxFrame(buf []byte, l uint16) (int32, error)
- func (sock *RawSocket) WrittenPackets() int32
- type SockAddr
- type TPacket2Hdr
- type TPacketReq
- type TPacketVersion
Constants ¶
View Source
const ( TPacketAlignment = 16 MinimumFrameSize = TPacketAlignment << 7 MaximumFrameSize = TPacketAlignment << 11 DefaultMaxPackets = 128 )
View Source
const ( // Packet socket options PacketRxRing = 5 PacketVersion = 10 PacketReserve = 12 PacketTxRing = 13 // TODO: Support for any of the following useful? PacketStatistics = 6 /// Counts packets and drops PacketLoss = 14 PacketVnetHdr = 15 PacketTxTimestamp = 16 PacketTimestamp = 17 )
View Source
const ( HostByteSize = 1 HostShortSize = 2 HostIntSize = 4 HostLongSize = 8 )
View Source
const ( PacketHost = 0 // To us PacketBroadcast = 1 // To all PacketMulticast = 2 // To group PacketOtherHost = 3 // To someone else PacketOutgoing = 4 // Outgoing of any type PacketLoopback = 5 // MC/BRD frame looped back PacketUser = 6 // To user space PacketFastRoute = 6 // Fastrouted frame PacketKernel = 7 // To kernel space )
Packet types
View Source
const DefaultFrameSize uint16 = MinimumFrameSize
View Source
const DefaultProtocol uint16 = syscall.ETH_P_ALL
Variables ¶
This section is empty.
Functions ¶
func PacketType ¶
func SockProtocol ¶
Types ¶
type Option ¶
type Option func(*RawSocket)
func BerkleyPacketFilter ¶
func MaxFrameSize ¶
func MaxTotalFrames ¶
func PacketRxFilter ¶
func Version ¶
func Version(version TPacketVersion) Option
func VlanRxAdjustEnable ¶
type RawSocket ¶
type RawSocket struct {
// contains filtered or unexported fields
}
func NewRawSocket ¶
NewRawSocket initializes a new raw socket but does not open it
func (*RawSocket) MaxPacketSize ¶
MaxPacketSize returns the frame size in bytes
func (*RawSocket) MaxPackets ¶
MaxPackets returns the maximum amount of frame packets that can be written
func (*RawSocket) MaxTxPacketSize ¶
MaxTxPacketSize returns the frame size in bytes
func (*RawSocket) TPacketVersion ¶
func (sock *RawSocket) TPacketVersion() TPacketVersion
func (*RawSocket) TxFrame ¶
TxFrame writes a raw frame in bytes to the TX ring buffer. The length of the frame must be specified or 0 can be provided and the size of the byte buffer will be used.
func (*RawSocket) WrittenPackets ¶
WrittenPackets returns the amount of packets, written to the tx ring, that haven't been flushed.
type SockAddr ¶
type SockAddr struct {
// contains filtered or unexported fields
}
func NewSockAddr ¶
type TPacket2Hdr ¶
type TPacket2Hdr struct {
TpStatus uint32
TpLen uint32
TpSnapLen uint32
TpMac uint16
TpNet uint16
TpSec uint32
TpNsec uint32
TpVlanTci uint16
TpVlanTpid uint16
// contains filtered or unexported fields
}
func NewTPacket2Hdr ¶
func NewTPacket2Hdr(rawData []byte) *TPacket2Hdr
type TPacketReq ¶
type TPacketReq struct {
// contains filtered or unexported fields
}
type TPacketVersion ¶
type TPacketVersion int
const DefaultTPacketVersion TPacketVersion = TpacketV2
TODO: This will soon change to TpacketV3
const TpacketV2 TPacketVersion = 1
const TpacketV3 TPacketVersion = 2
Click to show internal directories.
Click to hide internal directories.