Documentation ¶
Index ¶
- Variables
- type CPluginChain
- type Ethertype
- type Frame
- func (f Frame) Destination() net.HardwareAddr
- func (f Frame) DestinationBytes() []byte
- func (f Frame) Ethertype() Ethertype
- func (f Frame) Payload() []byte
- func (f *Frame) Prepare(dst net.HardwareAddr, src net.HardwareAddr, tagging Tagging, ...)
- func (f Frame) ReplacePart(start int, end int, nval []byte)
- func (f *Frame) Resize(payloadSize int)
- func (f Frame) SetDestination(addr []byte)
- func (f Frame) SetSource(addr []byte)
- func (f Frame) Source() net.HardwareAddr
- func (f Frame) SourceBytes() []byte
- func (f Frame) Tagging() Tagging
- func (f Frame) Tags() []byte
- type GoPluginChain
- type InterfaceType
- type LuaPluginChain
- type PluginChain
- type PluginMode
- type Statistic
- type Tagging
- type TunnelMode
- type TunnelStatistic
- func (ts *TunnelStatistic) AddStatistic(statistic Statistic)
- func (ts TunnelStatistic) GetAverageByCount(start, end time.Time) (arx, atx int)
- func (ts TunnelStatistic) GetAverageByTime(start, end time.Time) (arx, atx int)
- func (ts TunnelStatistic) GetCurrentAverageByCount() (rx, tx int)
- func (ts TunnelStatistic) GetCurrentAverageByTime() (rx, tx int)
- func (ts TunnelStatistic) GetCurrentTotal() (rx, tx int)
- func (ts TunnelStatistic) GetTotal(start, end time.Time) (arx, atx, count int)
- type TunnelType
- type UdpAddress
- type UdpConnection
- func (u UdpConnection) Close() error
- func (u UdpConnection) IsClosed() bool
- func (u UdpConnection) LocalAddr() net.Addr
- func (u UdpConnection) Read(b []byte) (n int, err error)
- func (u UdpConnection) Reader()
- func (u UdpConnection) RemoteAddr() net.Addr
- func (u UdpConnection) SetDeadline(t time.Time) error
- func (u UdpConnection) SetReadDeadline(t time.Time) error
- func (u UdpConnection) SetWriteDeadline(t time.Time) error
- func (u UdpConnection) Write(b []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
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 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 (Frame) 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 ¶
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) Resize ¶
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 (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 (Frame) 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 ¶
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 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.
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 (*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)
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 ¶
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) 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.