ethernet-go: github.com/xitongsys/ethernet-go/header Index | Files

package header

import "github.com/xitongsys/ethernet-go/header"

Index

Package Files

build.go ethernet.go ipv4.go ipv4Pseudo.go parser.go tcp.go udp.go util.go

Constants

const (
    VLANNone = 0x000
    VLANMax  = 0xfff
)
const (
    FIN = 0x01
    SYN = 0x02
    RST = 0x04
    PSH = 0x08
    ACK = 0x10
    URG = 0x20
    ECE = 0x40
    CWR = 0x80
)
const (
    TCPID = 6
    UDPID = 17
)

Variables

var (
    Broadcast = net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
)

func BuildTcpHeader Uses

func BuildTcpHeader(src, dst string) (*IPv4, *TCP)

func BuildTcpPacket Uses

func BuildTcpPacket(ipHeader *IPv4, tcpHeader *TCP, data []byte) []byte

func BuildUdpHeader Uses

func BuildUdpHeader(src, dst string) (*IPv4, *UDP)

func BuildUdpPacket Uses

func BuildUdpPacket(ipHeader *IPv4, udpHeader *UDP, data []byte) []byte

func Get Uses

func Get(data []byte) (proto string, iph *IPv4, udph *UDP, tcph *TCP, packetData []byte, err error)

func GetBase Uses

func GetBase(data []byte) (proto string, src string, dst string, err error)

func GetIp Uses

func GetIp(data []byte) (src uint32, dst uint32, err error)

func GetSubSlice Uses

func GetSubSlice(b []byte, bgn, end int) []byte

func GetTcpAddr Uses

func GetTcpAddr(iph *IPv4, tcph *TCP) (src string, dst string)

func GetUdpAddr Uses

func GetUdpAddr(iph *IPv4, udph *UDP) (src string, dst string)

func IP2Str Uses

func IP2Str(ip uint32) string

func IpStr2Bytes Uses

func IpStr2Bytes(ip string) [4]byte

a.b.c.d -> []byte{a,b,c,d}

func MaskNumber2Mask Uses

func MaskNumber2Mask(mask int) uint32

func ParseAddr Uses

func ParseAddr(src string) (string, int)

src: IP:PORT

func ParseNet Uses

func ParseNet(src string) (string, int)

src: ip/mask

func ReCalTcpCheckSum Uses

func ReCalTcpCheckSum(bs []byte) error

func ReCalUdpCheckSum Uses

func ReCalUdpCheckSum(bs []byte) error

func Str2IP Uses

func Str2IP(s string) uint32

type EtherType Uses

type EtherType uint16
const (
    EtherTypeIPv4        EtherType = 0x0800
    EtherTypeARP         EtherType = 0x0806
    EtherTypeIPv6        EtherType = 0x86DD
    EtherTypeVLAN        EtherType = 0x8100
    EtherTypeServiceVLAN EtherType = 0x88a8
)

type Frame Uses

type Frame struct {
    Destination net.HardwareAddr
    Source      net.HardwareAddr
    ServiceVLAN *VLAN
    VLAN        *VLAN
    EtherType   EtherType
    Payload     []byte
}

func (*Frame) MarshalBinary Uses

func (f *Frame) MarshalBinary() ([]byte, error)

func (*Frame) MarshalFCS Uses

func (f *Frame) MarshalFCS() ([]byte, error)

func (*Frame) UnmarshalBinary Uses

func (f *Frame) UnmarshalBinary(b []byte) error

func (*Frame) UnmarshalFCS Uses

func (f *Frame) UnmarshalFCS(b []byte) error

type IPv4 Uses

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 Uses

func (h *IPv4) CalChecksum() uint16

func (*IPv4) HeaderLen Uses

func (h *IPv4) HeaderLen() uint16

func (*IPv4) LenBytes Uses

func (h *IPv4) LenBytes() uint16

func (*IPv4) Marshal Uses

func (h *IPv4) Marshal() []byte

func (*IPv4) MarshalRaw Uses

func (h *IPv4) MarshalRaw() []byte

func (*IPv4) ResetChecksum Uses

func (h *IPv4) ResetChecksum()

func (IPv4) String Uses

func (h IPv4) String() string

func (*IPv4) Unmarshal Uses

func (h *IPv4) Unmarshal(bs []byte) error

type IPv4Pseudo Uses

type IPv4Pseudo struct {
    Src      uint32
    Dst      uint32
    Reserved uint8
    Protocol uint8
    Len      uint16
}

func (*IPv4Pseudo) HeaderLen Uses

func (h *IPv4Pseudo) HeaderLen() uint16

func (*IPv4Pseudo) LenBytes Uses

func (h *IPv4Pseudo) LenBytes() uint16

func (*IPv4Pseudo) Marshal Uses

func (h *IPv4Pseudo) Marshal() []byte

func (IPv4Pseudo) String Uses

func (h IPv4Pseudo) String() string

func (*IPv4Pseudo) Unmarshal Uses

func (h *IPv4Pseudo) Unmarshal(bs []byte) error

type Priority Uses

type Priority uint8
const (
    PriorityBackground           Priority = 1
    PriorityBestEffort           Priority = 0
    PriorityExcellentEffort      Priority = 2
    PriorityCriticalApplications Priority = 3
    PriorityVideo                Priority = 4
    PriorityVoice                Priority = 5
    PriorityInternetworkControl  Priority = 6
    PriorityNetworkControl       Priority = 7
)

type TCP Uses

type TCP struct {
    SrcPort    uint16
    DstPort    uint16
    Seq        uint32
    Ack        uint32
    Offset     uint8
    Flags      uint8
    Win        uint16
    Checksum   uint16
    UrgPointer uint16
    Opt        uint32
}

func (*TCP) HeaderLen Uses

func (h *TCP) HeaderLen() uint16

func (*TCP) Marshal Uses

func (h *TCP) Marshal() []byte

func (TCP) String Uses

func (h TCP) String() string

func (*TCP) Unmarshal Uses

func (h *TCP) Unmarshal(bs []byte) error

type UDP Uses

type UDP struct {
    SrcPort  uint16
    DstPort  uint16
    Len      uint16
    Checksum uint16
}

func (*UDP) HeaderLen Uses

func (h *UDP) HeaderLen() uint16

func (*UDP) LenBytes Uses

func (h *UDP) LenBytes() uint16

func (*UDP) Marshal Uses

func (h *UDP) Marshal() []byte

func (UDP) String Uses

func (h UDP) String() string

func (*UDP) Unmarshal Uses

func (h *UDP) Unmarshal(bs []byte) error

type VLAN Uses

type VLAN struct {
    Priority     Priority
    DropEligible bool
    ID           uint16
}

func (*VLAN) MarshalBinary Uses

func (v *VLAN) MarshalBinary() ([]byte, error)

func (*VLAN) UnmarshalBinary Uses

func (v *VLAN) UnmarshalBinary(b []byte) error

Package header imports 7 packages (graph) and is imported by 4 packages. Updated 2019-09-21. Refresh now. Tools for package owners.