raw

package module
v0.0.0-...-4aaed68 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: Apache-2.0 Imports: 6 Imported by: 1

README

raw Build Status GoDoc Go Report Card Coverage Status

uml class diagram

@startuml

title raw

class raw.Addr {
    +HardwareAddr
    +Network()
    +String()
}

interface raw.ListenPacket {
    +listenPacket(Interface, Protocol) packetConn
}

class raw.Conn {
    -p packetConn
    +ReadFrom(buffer) Addr
    +WriteTo(buffer, Addr)
    +Close()
    +LocalAddr() Addr
    +SetDeadline()
    +SetReadDeadline()
    +SetWriteDeadline()
}

raw.ListenPacket <-- raw.Conn

interface linux.socket {
    +Bind(Sockaddr)
    +Close()
    +Recvfrom(buffer) Sockaddr
    +Sendto(buffer, SockAddr)
    +SetNonblock()
}

interface linux.Sleeper {
    +Sleep(time.duration)
}

class linux.packetConn {
    -ifi Interface
    -s socket
    -sleeper Sleeper
    -timeoutMu Mutex
    -nonblocking bool
    -rtimeout time.time
    +ReadFrom(buffer) Addr
    +WriteTo(buffer, Addr)
    +Close()
    +LocalAddr() Addr
    +SetDeadline()
    +SetReadDeadline()
    +SetWriteDeadline()
}



linux.packetConn *-- linux.Sleeper
linux.packetConn *-- linux.socket

class linux.listenPacket {
    -listenPacket(Interface, Protocol) packetConn
}

raw.ListenPacket <|-- linux.listenPacket
linux.listenPacket <-- linux.packetConn

interface net.Addr {}
interface net.Conn {}
interface net.Interface {}

net.Addr <|-- raw.Addr
net.Conn <|-- raw.Conn
net.Conn <|-- linux.packetConn

linux.packetConn -- net.Interface

@enduml

Documentation

Overview

Package raw enables reading and writing data at the device driver level for a network interface.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotImplemented is returned when certain functionality is not yet
	// implemented for the host operating system.
	ErrNotImplemented = errors.New("not implemented")
)

Functions

This section is empty.

Types

type Addr

type Addr struct {
	HardwareAddr net.HardwareAddr
}

Addr is a network address which can be used to contact other machines, using their hardware addresses.

func (*Addr) Network

func (a *Addr) Network() string

Network returns the address's network name, "raw".

func (*Addr) String

func (a *Addr) String() string

String returns the address's hardware address.

type Conn

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

Conn is an implementation of the net.PacketConn interface which ca send and receive data at the network interface device driver lvel

func ListenPacket

func ListenPacket(ifi *net.Interface, proto Protocol) (*Conn, error)

ListenPacket creates a net.PacketConn which can be used to send and receive data at the network interface device driver level.

ifi specifies the network interface which will be used to send and receive data. socket specifies the socket type to be used, such as syscall.SOCK_RAW or syscall.SOCK_DGRAM. proto specifies the protocol which should be captured and transimitted. proto is automattically converted to network byte order (big endian), akin to the htons() function in C.

func (*Conn) Close

func (c *Conn) Close() error

Close method

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr method

func (*Conn) ReadFrom

func (c *Conn) ReadFrom(b []byte) (int, net.Addr, error)

ReadFrom implements the net.PacketConn ReadFrom method

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

SetDeadline method

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline method

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline method

func (*Conn) WriteTo

func (c *Conn) WriteTo(b []byte, addr net.Addr) (int, error)

WriteTo method

type Protocol

type Protocol uint16

Protocol is A protocol is a network protocol constant which id the type of traffic a raw socket should send and receive

const (
	// ProtocolARP specifies the Address Resolution Protocol
	ProtocolARP Protocol = syscall.ETH_P_ARP
	// ProtocolAoE specifies the
	ProtocolAoE Protocol = syscall.ETH_P_AOE
	// ProtocolWoL specifies the
	ProtocolWoL Protocol = 0x0842
)

Directories

Path Synopsis
examples
receiver command
sender command

Jump to

Keyboard shortcuts

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