Documentation ¶
Index ¶
- Constants
- Variables
- func ARPHandle(l2l *L2Layer, skb *SkBuff)
- func ICMPRcv(_ *L3Layer, packet IPv4)
- func ICMPSend(packet ICMPv4)
- func IpSelectIdent(ip IPv4) uint32
- func JHash3Words(a, b, c, initval uint32) uint32
- func Register(device Device)
- func RegisterBus(bus Bus)
- func SendUDP(skb *SkBuff)
- type ARP
- func (a ARP) HardwareAddressSize() int
- func (a ARP) HardwareType() uint16
- func (a ARP) InitIPv4OverEthernetARPPacket(op uint16)
- func (a ARP) Op() uint16
- func (a ARP) ProtocolAddressSize() int
- func (a ARP) ProtocolType() uint16
- func (a ARP) SenderHardwareAddress() []byte
- func (a ARP) SenderProtocolAddress() []byte
- func (a ARP) TargetHardwareAddress() []byte
- func (a ARP) TargetProtocolAddress() []byte
- type Bus
- type Device
- type Driver
- type Echo
- type Frame
- type ICMPv4
- type IPv4
- func (b IPv4) Checksum() uint16
- func (b IPv4) DestinationAddress() []byte
- func (b IPv4) Flags() uint8
- func (b IPv4) FlagsOffset() uint16
- func (b IPv4) FragmentOffset() uint16
- func (b IPv4) HeaderLength() uint8
- func (b IPv4) Identification() uint16
- func (b IPv4) Message() []byte
- func (b IPv4) Protocol() uint8
- func (b IPv4) SetChecksum(cks uint16)
- func (b IPv4) SetHeaderLength(l uint8)
- func (b IPv4) SetIdentification(id uint16)
- func (b IPv4) SetProtocol(p uint8)
- func (b IPv4) SetTTL(ttl uint8)
- func (b IPv4) SetToS(tos uint8)
- func (b IPv4) SetTotalLength(totl uint16)
- func (b IPv4) SetVersion(v uint8)
- func (b IPv4) SourceAddress() []byte
- func (b IPv4) TTL() uint8
- func (b IPv4) ToS() uint8
- func (b IPv4) TotalLength() uint16
- func (b IPv4) Version() uint8
- type L2Layer
- type L3Layer
- type MemResource
- type PCIAddress
- type PCIBus
- type PCIDevice
- type SkBuff
- type TapDevice
- type UDP
Constants ¶
const ( // ARPProtocolNumber is the ARP network protocol number. // TODO: make a protocol interface. ARPProtocolNumber = 0x0806 // ARPSize is the size of an IPv4-over-Ethernet ARP packet. ARPSize = 2 + 2 + 1 + 1 + 2 + 2*6 + 2*4 // Typical ARP opcodes defined in RFC 826. ARPRequest uint16 = 1 ARPReply uint16 = 2 )
const ( ICMPv4EchoReply uint8 = 0 ICMPv4DstUnreachable uint8 = 3 ICMPv4SrcQuench uint8 = 4 ICMPv4Redirect uint8 = 5 ICMPv4Echo uint8 = 8 ICMPv4TimeExceeded uint8 = 11 ICMPv4ParamProblem uint8 = 12 ICMPv4Timestamp uint8 = 13 ICMPv4TimestampReply uint8 = 14 ICMPv4InfoRequest uint8 = 15 ICMPv4InfoReply uint8 = 16 )
Typical values of ICMPv4Type defined in RFC 792.
const ( IPv4ProtocolNumber = 0x0800 IPv6ProtocolNumber = 0x86DD )
const ( MaxFrameSize = 1526 // max frame size EthMACAddressSize = 6 EthEtherTypeSize = 2 EthHeaderSize = EthEtherTypeSize + 2*EthMACAddressSize )
const ( PATH_SYSFS_PCI_DEVICES = "/sys/bus/pci/devices" PCI_MAX_RESOURCE = 6 // At most there 6 BARs from 0 to 5, but most devices just use 2 or 3 BARs. // IO resource type IORESOURCE_IO = 0x00000100 IORESOURCE_MEM = 0x00000200 )
const ( IFF_TUN = 0x0001 IFF_TAP = 0x0002 IFF_NO_PI = 0x1000 )
const ( UDPHeaderLength uint8 = 8 // udp header length IPHeaderLength uint8 = 20 // normallly ip header length is 20 )
Variables ¶
var ICMPv4ProtocolNumber uint8 = 1
Functions ¶
func IpSelectIdent ¶
func JHash3Words ¶
JHash3Words is a Jenkins hash support, adapted from Linux kernel include/linux/jhash.h, origin is http://burtleburtle.net/bob/hash/. These are the credits from Bob's sources: lookup3.c, by Bob Jenkins, May 2006, Public Domain.
func RegisterBus ¶
func RegisterBus(bus Bus)
Types ¶
type ARP ¶
type ARP []byte
ARP represents the arp packet.
func (ARP) HardwareAddressSize ¶
HardwareAddressSize specifies the size of l2 hardware address.
func (ARP) HardwareType ¶
HardwareType is the l2 hardware type, often ethernet (1).
func (ARP) InitIPv4OverEthernetARPPacket ¶
func (ARP) ProtocolAddressSize ¶
ProtocolAddressSize specifies the size of l3 network address.
func (ARP) ProtocolType ¶
ProtocolType is the type for l3 network type, often IPv4 (0x0800).
func (ARP) SenderHardwareAddress ¶
SenderHardwareAddress is the link address of the sender. It is a view on to the ARP packet so it can be used to set the value.
func (ARP) SenderProtocolAddress ¶
SenderProtocolAddress is the protocol address of the sender. It is a view on to the ARP packet so it can be used to set the value.
func (ARP) TargetHardwareAddress ¶
TargetHardwareAddress is the link address of the target. It is a view on to the ARP packet so it can be used to set the value.
func (ARP) TargetProtocolAddress ¶
TargetProtocolAddress is the protocol address of the target. It is a view on to the ARP packet so it can be used to set the value.
type Frame ¶
type Frame []byte
Link layer frame
func (Frame) Destination ¶
Destination is the mac destination address.
type IPv4 ¶
type IPv4 []byte
IPv4
func (IPv4) DestinationAddress ¶
DestinationAddress returns IP destination address.
func (IPv4) FlagsOffset ¶
flagsOffset returns flags and offset filed of the header.
func (IPv4) FragmentOffset ¶
FragmentOffset returns offset of the IP fragment.
func (IPv4) HeaderLength ¶
HeaderLength returns IPv4 headerlength, it's unit is 4.
func (IPv4) Identification ¶
Identification returns identification of the IPv4 header.
func (IPv4) SetChecksum ¶
func (IPv4) SetHeaderLength ¶
func (IPv4) SetIdentification ¶
SetIdentification sets packet ID for this IPv4 packet.
func (IPv4) SetProtocol ¶
func (IPv4) SetTotalLength ¶
func (IPv4) SetVersion ¶
func (IPv4) SourceAddress ¶
SourceAddress returns IP source address.
func (IPv4) TotalLength ¶
TotalLength returns the total length of the IPv4 header and payload.
type L3Layer ¶
type L3Layer struct {
*L2Layer
}
L3Layer is a IP layer.
type MemResource ¶
type PCIDevice ¶
type SkBuff ¶
type SkBuff struct {
// contains filtered or unexported fields
}
SkBuff is a buffer used for socket, it can be prepended from the head.