protocol

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ARP_REQUEST uint16 = 0x0001
	ARP_REPLY   uint16 = 0x0002
	ARP_UNKNOWN uint16 = 0xffff
)
View Source
const (
	ETH_PROTO_IP      uint16 = 0x0800
	ETH_PROTO_ARP     uint16 = 0x0806
	ETH_PROTO_UNKNOWN uint16 = 0xffff
)
View Source
const (
	ICMP_REQUEST uint8 = 0x08
	ICMP_REPLY   uint8 = 0x00
	ICMP_UNKNOWN uint8 = 0xff
)
View Source
const (
	IPH_PROTO_ICMP    uint8 = 0x01
	IPH_PROTO_TCP     uint8 = 0x06
	IPH_PROTO_UDP     uint8 = 0x11
	IPH_PROTO_UNKNOWN uint8 = 0xff
)

Variables

View Source
var ICMP_DEFAULT_PAYLOAD = []byte{
	0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
	0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
}

Functions

func BuildArpPkt

func BuildArpPkt(option uint16, srcMac []byte, srcAddr []byte, dstMac []byte, dstAddr []byte) (pkt []byte, err error)

func BuildEthFrm

func BuildEthFrm(payload []byte, dstMac []byte, srcMac []byte, ethProto uint16) (frm []byte, err error)

func BuildIcmpPkt

func BuildIcmpPkt(payload []byte, icmpType uint8, icmpId []byte, icmpSeq []byte) (pkt []byte, err error)

func BuildIpv4Pkt

func BuildIpv4Pkt(payload []byte, ipHeadProto uint8, srcAddr []byte, dstAddr []byte) (pkt []byte, err error)

func BuildTcpAckPkt

func BuildTcpAckPkt(srcPort uint16, dstPort uint16, srcAddr []byte, dstAddr []byte, seqNum uint32, ackNum uint32) (pkt []byte, err error)

func BuildTcpSynAckPkt

func BuildTcpSynAckPkt(srcPort uint16, dstPort uint16, srcAddr []byte, dstAddr []byte, seqNum uint32, ackNum uint32) (pkt []byte, err error)

func BuildTcpSynPkt

func BuildTcpSynPkt(srcPort uint16, dstPort uint16, srcAddr []byte, dstAddr []byte, seqNum uint32) (pkt []byte, err error)

func BuildUdpPkt

func BuildUdpPkt(payload []byte, srcPort uint16, dstPort uint16, srcAddr []byte, dstAddr []byte) (pkt []byte, err error)

func ConvIpAddrToUint32

func ConvIpAddrToUint32(ipAddr []byte) (ipAddrUint32 uint32)

func GetCheckSum

func GetCheckSum(data []byte) []byte

func ParseArpPkt

func ParseArpPkt(pkt []byte) (option uint16, srcMac []byte, srcAddr []byte, dstMac []byte, dstAddr []byte, err error)

func ParseEthFrm

func ParseEthFrm(frm []byte) (payload []byte, dstMac []byte, srcMac []byte, ethProto uint16, err error)

func ParseIcmpPkt

func ParseIcmpPkt(pkt []byte) (payload []byte, icmpType uint8, icmpId []byte, icmpSeq []byte, err error)

func ParseIpv4Pkt

func ParseIpv4Pkt(pkt []byte) (payload []byte, ipHeadProto uint8, srcAddr []byte, dstAddr []byte, err error)

func ParseUdpPkt

func ParseUdpPkt(pkt []byte, srcAddr []byte, dstAddr []byte) (payload []byte, srcPort uint16, dstPort uint16, err error)

func SetRandIpHeaderId

func SetRandIpHeaderId()

Types

This section is empty.

Directories

Path Synopsis
Package kcp-go is a Reliable-UDP library for golang.
Package kcp-go is a Reliable-UDP library for golang.

Jump to

Keyboard shortcuts

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