common

package
v0.0.0-...-66c0c6b Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 10 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}
	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}
)

http://en.wikipedia.org/wiki/Ethertype

Functions

func IsBroadcastAddr

func IsBroadcastAddr(addr net.HardwareAddr) bool

func IsIPv4MulticastAddr

func IsIPv4MulticastAddr(addr net.HardwareAddr) bool

func PingIface

func PingIface(dstIP net.IP) error

func SetupIface

func SetupIface(ip net.IPNet, devName string) error

func TearDownIface

func TearDownIface(devName string) error

Types

type EtherType

type EtherType [2]byte

type FrameTag

type FrameTag int
const (
	FrameNotTagged FrameTag = iota << 2
	FrameTagged
	FrameDoubleTagged
)

type IPProtocol

type IPProtocol byte
const (
	HOPOPT IPProtocol = 0x00 + iota
	ICMP
	IGMP
	GGP
	IPv4Encapsulation
	ST
	TCP
	CBT
	EGP
	IGP
	BBN_RCC_MON
	NVP_II
	PUP
	ARGUS
	EMCON
	XNET
	CHAOS
	UDP
	MUX
	DCN_MEAS
	HMP
	PRM
	XNS_IDP
	TRUNK_1
	TRUNK_2
	LEAF_1
	LEAF_2
	RDP
	IRTP
	ISO_TP4
	NETBLT
	MFE_NSP
	MERIT_INP
	DCCP
	ThirdPC
	IDPR
	XTP
	DDP
	IDPR_CMTP
	TPxx
	IL
	IPv6Encapsulation
	SDRP
	IPv6_Route
	IPv6_Frag
	IDRP
	RSVP
	GRE
	MHRP
	BNA
	ESP
	AH
	I_NLSP
	SWIPE
	NARP
	MOBILE
	TLSP
	SKIP
	IPv6_ICMP
	IPv6_NoNxt
	IPv6_Opts

	CFTP

	SAT_EXPAK
	KRYPTOLAN
	RVD
	IPPC

	SAT_MON
	VISA
	IPCV
	CPNX
	CPHB
	WSN
	PVP
	BR_SAT_MON
	SUN_ND
	WB_MON
	WB_EXPAK
	ISO_IP
	VMTP
	SECURE_VMTP
	VINES
	TTP
	IPTM
	NSFNET_IGP
	DGP
	TCF
	EIGRP
	OSPF
	Sprite_RPC
	LARP
	MTP
	AX_25
	IPIP
	MICP
	SCC_SP
	ETHERIP
	ENCAP
	GMTP
	IFMP
	PNNI
	PIM
	ARIS
	SCPS
	QNX
	A_N
	IPComp
	SNP
	Compaq_Peer
	IPX_in_IP
	VRRP
	PGM
	L2TP
	DDX
	IATP
	STP
	SRP
	UTI
	SMP
	SM
	PTP

	FIRE
	CRTP
	CRUDP
	SSCOPMCE
	IPLT
	SPS
	PIPE
	SCTP
	FC

	HIP   IPProtocol = 0x8B
	Shim6 IPProtocol = 0x8C
)

http://en.wikipedia.org/wiki/List_of_IP_protocol_numbers

type TapIface

type TapIface struct {
	Name               string
	io.ReadWriteCloser // 实现从文件中读取信息
}

func NewTAP

func NewTAP(tapIfaceName string) (*TapIface, error)

func (*TapIface) CloseIface

func (i *TapIface) CloseIface() error

func (*TapIface) CreateDataChannels

func (i *TapIface) CreateDataChannels() (<-chan []byte, <-chan error, func())

func (*TapIface) GetFrameTag

func (i *TapIface) GetFrameTag(frame []byte) FrameTag

func (*TapIface) ParseDstMACFromFrame

func (i *TapIface) ParseDstMACFromFrame(frame []byte) net.HardwareAddr

func (*TapIface) ParseMACEtherType

func (i *TapIface) ParseMACEtherType(frame []byte) EtherType

func (*TapIface) ParseMACPayload

func (i *TapIface) ParseMACPayload(frame []byte) []byte

func (*TapIface) ParseSrcMACFromFrame

func (i *TapIface) ParseSrcMACFromFrame(frame []byte) net.HardwareAddr

func (*TapIface) WaitOrReadData

func (i *TapIface) WaitOrReadData(
	dataROCh <-chan []byte,
	errROCh <-chan error,
)

type TunIface

type TunIface struct {
	Name               string
	io.ReadWriteCloser // 实现从文件中读取信息
}

func NewTUN

func NewTUN(tunIfaceName string) (*TunIface, error)

func (*TunIface) CloseIface

func (i *TunIface) CloseIface() error

func (*TunIface) CreateDataChannels

func (i *TunIface) CreateDataChannels() (<-chan []byte, <-chan error, func())

func (*TunIface) WaitOrReadData

func (i *TunIface) WaitOrReadData(
	dataROCh <-chan []byte,
	errROCh <-chan error,
)

Jump to

Keyboard shortcuts

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