Documentation ¶
Index ¶
- Constants
- Variables
- func BuildTcpHeader(src, dst string) (*IPv4, *TCP)
- func BuildTcpPacket(ipHeader *IPv4, tcpHeader *TCP, data []byte) []byte
- func BuildUdpHeader(src, dst string) (*IPv4, *UDP)
- func BuildUdpPacket(ipHeader *IPv4, udpHeader *UDP, data []byte) []byte
- func Get(data []byte) (proto string, iph *IPv4, udph *UDP, tcph *TCP, packetData []byte, err error)
- func GetBase(data []byte) (proto string, src string, dst string, err error)
- func GetIp(data []byte) (src uint32, dst uint32, err error)
- func GetSubSlice(b []byte, bgn, end int) []byte
- func GetTcpAddr(iph *IPv4, tcph *TCP) (src string, dst string)
- func GetUdpAddr(iph *IPv4, udph *UDP) (src string, dst string)
- func IP2Str(ip uint32) string
- func MaskNumber2Mask(mask int) uint32
- func ParseAddr(src string) (string, int)
- func ParseNet(src string) (string, int)
- func ReCalTcpCheckSum(bs []byte) error
- func ReCalUdpCheckSum(bs []byte) error
- func Str2IP(s string) uint32
- type EtherType
- type Frame
- type IPv4
- type IPv4Pseudo
- type Priority
- type TCP
- type UDP
- type VLAN
Constants ¶
View Source
const ( VLANNone = 0x000 VLANMax = 0xfff )
View Source
const ( FIN = 0x01 SYN = 0x02 RST = 0x04 PSH = 0x08 ACK = 0x10 URG = 0x20 ECE = 0x40 CWR = 0x80 )
View Source
const ( TCPID = 6 UDPID = 17 )
Variables ¶
View Source
var (
Broadcast = net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
)
Functions ¶
func BuildTcpHeader ¶
func BuildUdpHeader ¶
func GetSubSlice ¶
func MaskNumber2Mask ¶
func ReCalTcpCheckSum ¶
func ReCalUdpCheckSum ¶
Types ¶
type Frame ¶
type Frame struct { Destination net.HardwareAddr Source net.HardwareAddr ServiceVLAN *VLAN VLAN *VLAN EtherType EtherType Payload []byte }
func (*Frame) MarshalBinary ¶
func (*Frame) MarshalFCS ¶
func (*Frame) UnmarshalBinary ¶
func (*Frame) UnmarshalFCS ¶
type IPv4 ¶
type IPv4 struct { VerIHL uint8 Tos uint8 Len uint16 Id uint16 Offset uint16 TTL uint8 Protocol uint8 Checksum uint16 Src uint32 Dst uint32 Opt []byte }
func (*IPv4) CalChecksum ¶
func (*IPv4) MarshalRaw ¶
func (*IPv4) ResetChecksum ¶
func (h *IPv4) ResetChecksum()
type IPv4Pseudo ¶
func (*IPv4Pseudo) HeaderLen ¶
func (h *IPv4Pseudo) HeaderLen() uint16
func (*IPv4Pseudo) LenBytes ¶
func (h *IPv4Pseudo) LenBytes() uint16
func (*IPv4Pseudo) Marshal ¶
func (h *IPv4Pseudo) Marshal() []byte
func (IPv4Pseudo) String ¶
func (h IPv4Pseudo) String() string
func (*IPv4Pseudo) Unmarshal ¶
func (h *IPv4Pseudo) Unmarshal(bs []byte) error
type TCP ¶
Click to show internal directories.
Click to hide internal directories.