common

package
v0.0.0-...-d0f1447 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IPv4                = Ethertype{0x08, 0x00}
	ARP                 = Ethertype{0x08, 0x06}
	WakeOnLAN           = Ethertype{0x08, 0x42}
	TRILL               = Ethertype{0x22, 0xF3}
	DECnetPhase4        = Ethertype{0x60, 0x03}
	RARP                = Ethertype{0x80, 0x35}
	AppleTalk           = Ethertype{0x80, 0x9B}
	AARP                = Ethertype{0x80, 0xF3}
	IPX1                = Ethertype{0x81, 0x37}
	IPX2                = Ethertype{0x81, 0x38}
	QNXQnet             = Ethertype{0x82, 0x04}
	IPv6                = Ethertype{0x86, 0xDD}
	EthernetFlowControl = Ethertype{0x88, 0x08}
	IEEE802_3           = Ethertype{0x88, 0x09}
	CobraNet            = Ethertype{0x88, 0x19}
	MPLSUnicast         = Ethertype{0x88, 0x47}
	MPLSMulticast       = Ethertype{0x88, 0x48}
	PPPoEDiscovery      = Ethertype{0x88, 0x63}
	PPPoESession        = Ethertype{0x88, 0x64}
	JumboFrames         = Ethertype{0x88, 0x70}
	HomePlug1_0MME      = Ethertype{0x88, 0x7B}
	IEEE802_1X          = Ethertype{0x88, 0x8E}
	PROFINET            = Ethertype{0x88, 0x92}
	HyperSCSI           = Ethertype{0x88, 0x9A}
	AoE                 = Ethertype{0x88, 0xA2}
	EtherCAT            = Ethertype{0x88, 0xA4}
	EthernetPowerlink   = Ethertype{0x88, 0xAB}
	LLDP                = Ethertype{0x88, 0xCC}
	SERCOS3             = Ethertype{0x88, 0xCD}
	WSMP                = Ethertype{0x88, 0xDC}
	HomePlugAVMME       = Ethertype{0x88, 0xE1}
	MRP                 = Ethertype{0x88, 0xE3}
	IEEE802_1AE         = Ethertype{0x88, 0xE5}
	IEEE1588            = Ethertype{0x88, 0xF7}
	IEEE802_1ag         = Ethertype{0x89, 0x02}
	FCoE                = Ethertype{0x89, 0x06}
	FCoEInit            = Ethertype{0x89, 0x14}
	RoCE                = Ethertype{0x89, 0x15}
	CTP                 = Ethertype{0x90, 0x00}
	VeritasLLT          = Ethertype{0xCA, 0xFE}
)

Common ethertype values

Functions

This section is empty.

Types

type CPluginChain

type CPluginChain struct {
	PluginChain
	// contains filtered or unexported fields
}

func GetCPluginChain

func GetCPluginChain(name string, mode PluginMode) (p CPluginChain)

func (CPluginChain) AddNextChainLoop

func (p CPluginChain) AddNextChainLoop(n PluginChain)

func (CPluginChain) Call

func (p CPluginChain) Call(ibuff []byte) (obuff []byte)

func (CPluginChain) Close

func (p CPluginChain) Close()

func (CPluginChain) GetNext

func (p CPluginChain) GetNext() PluginChain

func (CPluginChain) HasNext

func (p CPluginChain) HasNext() bool

type Ethertype

type Ethertype [2]byte

type Frame

type Frame []byte

Frame represents an ethernet frame. The length of the underlying slice of a Frame should always reflect the ethernet frame length.

func (Frame) Destination

func (f Frame) Destination() net.HardwareAddr

Destination returns the destination address field of the frame. The address references a slice on the frame.

It is not safe to use this method if f is nil or an invalid ethernet frame.

func (Frame) DestinationBytes

func (f Frame) DestinationBytes() []byte

func (Frame) Ethertype

func (f Frame) Ethertype() Ethertype

Ethertype returns the ethertype field of the frame.

It is not safe to use this method if f is nil or an invalid ethernet frame.

func (Frame) Payload

func (f Frame) Payload() []byte

Payload returns a slice holding the payload part of the frame. Upper layer should use the returned slice for both reading and writing purposes.

It is not safe to use this method if f is nil or an invalid ethernet frame.

func (*Frame) Prepare

func (f *Frame) Prepare(dst net.HardwareAddr, src net.HardwareAddr, tagging Tagging, ethertype Ethertype, payloadSize int)

Prepare prepares *f to be used, by filling in dst/src address, setting up proper tagging and ethertype, and resizing it to proper length.

It is safe to call Prepare on a pointer to a nil Frame or invalid Frame.

func (Frame) ReplacePart

func (f Frame) ReplacePart(start int, end int, nval []byte)

func (*Frame) Resize

func (f *Frame) Resize(payloadSize int)

Resize re-slices (*f) so that len(*f) holds exactly payloadSize bytes of payload. If cap(*f) is not large enough, a new slice is made and content from old slice is copied to the new one.

If len(*f) is less than 14 bytes, it is assumed to be not tagged.

It is safe to call Resize on a pointer to a nil Frame.

func (Frame) SetDestination

func (f Frame) SetDestination(addr []byte)

func (Frame) SetSource

func (f Frame) SetSource(addr []byte)

func (Frame) Source

func (f Frame) Source() net.HardwareAddr

Source returns the source address field of the frame. The address references a slice on the frame.

It is not safe to use this method if f is nil or an invalid ethernet frame.

func (Frame) SourceBytes

func (f Frame) SourceBytes() []byte

func (Frame) Tagging

func (f Frame) Tagging() Tagging

Tagging returns whether/how the frame has 802.1Q tag(s).

It is not safe to use this method if f is nil or an invalid ethernet frame.

func (Frame) Tags

func (f Frame) Tags() []byte

Tag returns a slice holding the tag part of the frame, if any. Note that this includes the Tag Protocol Identifier (TPID), e.g. 0x8100 or 0x88a8. Upper layer should use the returned slice for both reading and writing.

It is not safe to use this method if f is nil or an invalid ethernet frame.

type GoPluginChain

type GoPluginChain struct {
	PluginChain
	// contains filtered or unexported fields
}

func GetGoPluginChain

func GetGoPluginChain(name string, mode PluginMode) (p GoPluginChain)

func (GoPluginChain) AddNextChainLoop

func (p GoPluginChain) AddNextChainLoop(n PluginChain)

func (GoPluginChain) Call

func (p GoPluginChain) Call(ibuff []byte) (obuff []byte)

func (GoPluginChain) Close

func (p GoPluginChain) Close()

func (GoPluginChain) GetNext

func (p GoPluginChain) GetNext() PluginChain

func (GoPluginChain) HasNext

func (p GoPluginChain) HasNext() bool

type InterfaceType

type InterfaceType string
const (
	SOCKS_IFACE  InterfaceType = "socks"
	TCP_IFACE    InterfaceType = "tcp"
	UDP_IFACE    InterfaceType = "udp"
	TUN_IFACE    InterfaceType = "tun"
	SERIAL_IFACE InterfaceType = "serial"
)

type LuaPluginChain

type LuaPluginChain struct {
	PluginChain
	// contains filtered or unexported fields
}

func GetLuaPluginChain

func GetLuaPluginChain(name string, mode PluginMode) (p LuaPluginChain)

func (LuaPluginChain) AddNextChainLoop

func (p LuaPluginChain) AddNextChainLoop(n PluginChain)

func (LuaPluginChain) Call

func (p LuaPluginChain) Call(ibuff []byte) (obuff []byte)

func (LuaPluginChain) Close

func (p LuaPluginChain) Close()

func (LuaPluginChain) GetNext

func (p LuaPluginChain) GetNext() PluginChain

func (LuaPluginChain) HasNext

func (p LuaPluginChain) HasNext() bool

type PluginChain

type PluginChain interface {
	Call(ibuff []byte) (obuff []byte)
	AddNextChainLoop(n PluginChain)
	HasNext() bool
	GetNext() PluginChain
	Close()
}

func PluginFactory

func PluginFactory(plugins string) (input, output PluginChain)

type PluginMode

type PluginMode string
const (
	ENC PluginMode = "encoder"
	DEC PluginMode = "decoder"
)

type Statistic

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

type Tagging

type Tagging byte

Tagging is a type used to indicate whether/how a frame is tagged. The value is number of bytes taken by tagging.

const (
	NotTagged    Tagging = 0
	Tagged       Tagging = 4
	DoubleTagged Tagging = 8
)

Const values for different taggings

type TunnelMode

type TunnelMode string
const (
	SERVER TunnelMode = "server"
	CLIENT TunnelMode = "client"
)

type TunnelStatistic

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

func GetTunnelStatistic

func GetTunnelStatistic(name string, duration time.Duration, historyDuration time.Duration) *TunnelStatistic

func (*TunnelStatistic) AddStatistic

func (ts *TunnelStatistic) AddStatistic(statistic Statistic)

func (TunnelStatistic) GetAverageByCount

func (ts TunnelStatistic) GetAverageByCount(start, end time.Time) (arx, atx int)

func (TunnelStatistic) GetAverageByTime

func (ts TunnelStatistic) GetAverageByTime(start, end time.Time) (arx, atx int)

func (TunnelStatistic) GetCurrentAverageByCount

func (ts TunnelStatistic) GetCurrentAverageByCount() (rx, tx int)

func (TunnelStatistic) GetCurrentAverageByTime

func (ts TunnelStatistic) GetCurrentAverageByTime() (rx, tx int)

func (TunnelStatistic) GetCurrentTotal

func (ts TunnelStatistic) GetCurrentTotal() (rx, tx int)

func (TunnelStatistic) GetTotal

func (ts TunnelStatistic) GetTotal(start, end time.Time) (arx, atx, count int)

type TunnelType

type TunnelType string
const (
	HTTP_TUN  TunnelType = "http"
	HTTPS_TUN TunnelType = "https"
	TCP_TUN   TunnelType = "tcp"
	UDP_TUN   TunnelType = "udp"
	TLS_TUN   TunnelType = "tls"
)

type UdpAddress

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

func GetUdpAddress

func GetUdpAddress(addr *net.UDPAddr) *UdpAddress

func (*UdpAddress) Equals

func (ua *UdpAddress) Equals(uan *UdpAddress) bool

func (*UdpAddress) GetAddress

func (ua *UdpAddress) GetAddress() *net.UDPAddr

func (*UdpAddress) IsTimedOut

func (ua *UdpAddress) IsTimedOut() bool

func (*UdpAddress) SetTimeout

func (ua *UdpAddress) SetTimeout(t time.Duration)

func (*UdpAddress) UpdateLastUsed

func (ua *UdpAddress) UpdateLastUsed()

type UdpConnection

type UdpConnection struct {
	net.Conn
	// contains filtered or unexported fields
}

func GetUdpConnection

func GetUdpConnection(raddress string, laddr [8]byte, ch chan []byte) (UdpConnection, error)

func (UdpConnection) Close

func (u UdpConnection) Close() error

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.

func (UdpConnection) IsClosed

func (u UdpConnection) IsClosed() bool

func (UdpConnection) LocalAddr

func (u UdpConnection) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (UdpConnection) Read

func (u UdpConnection) Read(b []byte) (n int, err error)

func (UdpConnection) Reader

func (u UdpConnection) Reader()

func (UdpConnection) RemoteAddr

func (u UdpConnection) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (UdpConnection) SetDeadline

func (u UdpConnection) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.

A deadline is an absolute time after which I/O operations fail with a timeout (see type Error) instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.

An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.

A zero value for t means I/O operations will not time out.

func (UdpConnection) SetReadDeadline

func (u UdpConnection) SetReadDeadline(t time.Time) error

SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.

func (UdpConnection) SetWriteDeadline

func (u UdpConnection) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.

func (UdpConnection) Write

func (u UdpConnection) Write(b []byte) (n int, err error)

Write writes data to the connection. Write can be made to time out and return an Error with Timeout() == true after a fixed time limit; see SetDeadline and SetWriteDeadline.

Jump to

Keyboard shortcuts

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