supersocket

package
v0.0.0-...-1848e1e Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Recv

func Recv(iface string) gopacket.Packet

Recv this function receives the array of bytes. It doesn't need to be called on a supersocket structure. This functions creates the supersocket automatically, allowing to have a more abstract usage.

func Send

func Send(packetBytes []byte, iface string)

Send this function sends the array of bytes. It doesn't need to be called on a supersocket structure. This functions creates the supersocket automatically, allowing to have a more abstract usage.

func SendMultiplePackets

func SendMultiplePackets(packets [][]byte, iface string, maxConcurrentSends int)

SendMultiplePackets sends multiple packets concurrently. It doesn't need to be called on a supersocket structure. This functions creates the supersocket automatically, allowing to have a more abstract usage.

func SendRecv

func SendRecv(packetBytes []byte, iface string) gopacket.Packet

SendRecv this function Sends the array of bytes and receives its answer. It doesn't need to be called on a supersocket structure. This functions creates the supersocket automatically, allowing to have a more abstract usage.

Types

type SuperSocket

type SuperSocket struct {
	// contains filtered or unexported fields
}

SuperSocket structure contains the pointer to pcap.Handle and the interface to be used

func NewSuperSocket

func NewSuperSocket(device string, bpfFilter string) (*SuperSocket, error)

NewSuperSocket Given the interface and the filter opens the socket connection

func (*SuperSocket) Close

func (ss *SuperSocket) Close()

Close closes the socket connection

func (*SuperSocket) GetHandle

func (ss *SuperSocket) GetHandle() *pcap.Handle

GetHandle returns the pointer to the pcap.Handle

func (*SuperSocket) Recv

func (ss *SuperSocket) Recv() (gopacket.Packet, error)

Recv receives the bytes and transforms it into a gopacket.packet using the function NewPacket

func (*SuperSocket) Send

func (ss *SuperSocket) Send(packetBytes []byte) error

Send sends the array of bytes through the supersocket

func (*SuperSocket) SendMultiplePackets

func (ss *SuperSocket) SendMultiplePackets(packets [][]byte, maxConcurrentSends int) error

SendMultiplePackets Given an array of bytes, sends them using goroutines. The maxConcurrentSends defines the maximum number of threads to be created

Jump to

Keyboard shortcuts

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