Documentation
¶
Index ¶
- Variables
- func ParseIpAddr(ipAddrStr string) ([]byte, error)
- func ParseMacAddr(macAddrStr string) ([]byte, error)
- type Config
- type Engine
- type InNatEntry
- type NetIf
- func (i *NetIf) GetArpCache(ipAddr []byte) (macAddr []byte)
- func (i *NetIf) HandleArp(ethPayload []byte, ethSrcMac []byte)
- func (i *NetIf) MacAddrToU(macAddr []byte) (macAddrU uint64)
- func (i *NetIf) PacketHandle()
- func (i *NetIf) RxEthernet(ethFrm []byte)
- func (i *NetIf) RxIcmp(ipv4Payload []byte, ipv4SrcAddr []byte)
- func (i *NetIf) RxIpv4(ethPayload []byte)
- func (i *NetIf) RxTcp()
- func (i *NetIf) RxUdp(ipv4Payload []byte, ipv4SrcAddr []byte)
- func (i *NetIf) SetArpCache(ipAddr []byte, macAddr []byte)
- func (i *NetIf) TxEthernet(ethPayload []byte, ethDstMac []byte, ethProto uint16) []byte
- func (i *NetIf) TxIcmp(icmpPayload []byte, seq uint16, ipv4DstAddr []byte) []byte
- func (i *NetIf) TxIpv4(ipv4Payload []byte, ipv4HeadProto uint8, ipv4DstAddr []byte) []byte
- func (i *NetIf) TxTcpAck(tcpSrcPort uint16, tcpDstPort uint16, ipv4DstAddr []byte) []byte
- func (i *NetIf) TxTcpSyn(tcpSrcPort uint16, tcpDstPort uint16, ipv4DstAddr []byte) []byte
- func (i *NetIf) TxTcpSynAck(tcpSrcPort uint16, tcpDstPort uint16, ipv4DstAddr []byte) []byte
- func (i *NetIf) TxUdp(udpPayload []byte, udpSrcPort uint16, udpDstPort uint16, ipv4DstAddr []byte) []byte
- func (i *NetIf) UToMacAddr(macAddrU uint64) (macAddr []byte)
- type NetIfConfig
- type OutNatEntry
- type RoutingEntry
- type RoutingEntryConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var (
BROADCAST_MAC_ADDR = []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
)
Functions ¶
func ParseIpAddr ¶
func ParseMacAddr ¶
Types ¶
type Config ¶
type Config struct { DebugLog bool // 调试日志 NetIfList []*NetIfConfig // 网卡列表 RoutingTable []*RoutingEntryConfig // 路由表 }
type Engine ¶
type Engine struct { DebugLog bool Stop bool NetIfMap map[string]*NetIf RoutingTable []*RoutingEntry Ipv4PktFwdHook func(ipv4Pkt []byte) []byte }
func InitEngine ¶
func (*Engine) StopEngine ¶
func (e *Engine) StopEngine()
type InNatEntry ¶ added in v1.0.1
type NetIf ¶
type NetIf struct { Name string MacAddr []byte IpAddr []byte NetworkMask []byte EthRxChan chan []byte EthTxChan chan []byte LoChan chan []byte Engine *Engine // arp缓存表 key:ip value:mac ArpCacheTable map[uint32]uint64 ArpCacheTableLock sync.RWMutex HandleUdp func(udpPayload []byte, udpSrcPort uint16, udpDstPort uint16, ipv4SrcAddr []byte) NatEnable bool NatTable map[OutNatEntry]*InNatEntry NatTableLock sync.RWMutex }
func (*NetIf) GetArpCache ¶
func (*NetIf) MacAddrToU ¶ added in v1.0.1
func (*NetIf) PacketHandle ¶
func (i *NetIf) PacketHandle()
func (*NetIf) RxEthernet ¶ added in v1.0.1
func (*NetIf) SetArpCache ¶
func (*NetIf) TxEthernet ¶ added in v1.0.1
func (*NetIf) TxTcpSynAck ¶
func (*NetIf) UToMacAddr ¶ added in v1.0.1
type NetIfConfig ¶
type OutNatEntry ¶ added in v1.0.1
type RoutingEntry ¶ added in v1.0.1
Click to show internal directories.
Click to hide internal directories.