tcpip

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ICMP IPProtocol = 0x01
	TCP             = 0x06
	UDP             = 0x11
)

Variables

This section is empty.

Functions

func Checksum

func Checksum(sum uint32, b []byte) (answer [2]byte)

checksum for Internet Protocol family headers

func ConvertIPv4ToUint32

func ConvertIPv4ToUint32(ip net.IP) uint32

func ConvertUint32ToIPv4

func ConvertUint32ToIPv4(v uint32) net.IP

func IsIPPacket

func IsIPPacket(packet []byte) bool

func IsIPv4

func IsIPv4(packet []byte) bool

func IsIPv6

func IsIPv6(packet []byte) bool

func Sum

func Sum(b []byte) uint32

Types

type ICMPPacket

type ICMPPacket []byte

func (ICMPPacket) Checksum

func (p ICMPPacket) Checksum() uint16

func (ICMPPacket) Code

func (p ICMPPacket) Code() byte

func (ICMPPacket) ResetChecksum

func (p ICMPPacket) ResetChecksum()

func (ICMPPacket) SetChecksum

func (p ICMPPacket) SetChecksum(sum [2]byte)

func (ICMPPacket) SetType

func (p ICMPPacket) SetType(v ICMPType)

func (ICMPPacket) Type

func (p ICMPPacket) Type() ICMPType

type ICMPType

type ICMPType byte
const (
	ICMPEcho    ICMPType = 0x0
	ICMPRequest          = 0x8
)

type IPPacket

type IPPacket interface {
	TotalLen() uint16
	HeaderLen() uint16
	DataLen() uint16
	Payload() []byte
	Protocol() IPProtocol
	SourceIP() net.IP
	SetSourceIP(ip net.IP)
	DestinationIP() net.IP
	SetDestinationIP(ip net.IP)
	ResetChecksum()
	PseudoSum() uint32
	SetFields(src net.IP, dst net.IP, protocol IPProtocol, identification uint16)
}

func NewIPPacket

func NewIPPacket(packet []byte) IPPacket

type IPProtocol

type IPProtocol byte

type IPv4Packet

type IPv4Packet []byte

func (IPv4Packet) Checksum

func (p IPv4Packet) Checksum() uint16

func (IPv4Packet) DataLen

func (p IPv4Packet) DataLen() uint16

func (IPv4Packet) DestinationIP

func (p IPv4Packet) DestinationIP() net.IP

func (IPv4Packet) HeaderLen

func (p IPv4Packet) HeaderLen() uint16

func (IPv4Packet) Payload

func (p IPv4Packet) Payload() []byte

func (IPv4Packet) Protocol

func (p IPv4Packet) Protocol() IPProtocol

func (IPv4Packet) PseudoSum

func (p IPv4Packet) PseudoSum() uint32

for tcp checksum

func (IPv4Packet) ResetChecksum

func (p IPv4Packet) ResetChecksum()

func (IPv4Packet) SetChecksum

func (p IPv4Packet) SetChecksum(sum [2]byte)

func (IPv4Packet) SetDestinationIP

func (p IPv4Packet) SetDestinationIP(ip net.IP)

func (IPv4Packet) SetFields

func (p IPv4Packet) SetFields(src net.IP, dst net.IP, protocol IPProtocol, identification uint16)

func (IPv4Packet) SetSourceIP

func (p IPv4Packet) SetSourceIP(ip net.IP)

func (IPv4Packet) SourceIP

func (p IPv4Packet) SourceIP() net.IP

func (IPv4Packet) TotalLen

func (p IPv4Packet) TotalLen() uint16

type IPv6Packet

type IPv6Packet []byte

func (IPv6Packet) DataLen

func (p IPv6Packet) DataLen() uint16

func (IPv6Packet) DestinationIP

func (p IPv6Packet) DestinationIP() net.IP

func (IPv6Packet) HeaderLen

func (p IPv6Packet) HeaderLen() uint16

func (IPv6Packet) Payload

func (p IPv6Packet) Payload() []byte

func (IPv6Packet) Protocol

func (p IPv6Packet) Protocol() IPProtocol

func (IPv6Packet) PseudoSum

func (p IPv6Packet) PseudoSum() uint32

for tcp checksum

func (IPv6Packet) ResetChecksum

func (p IPv6Packet) ResetChecksum()

func (IPv6Packet) SetDestinationIP

func (p IPv6Packet) SetDestinationIP(ip net.IP)

func (IPv6Packet) SetFields

func (p IPv6Packet) SetFields(src net.IP, dst net.IP, protocol IPProtocol, identification uint16)

func (IPv6Packet) SetSourceIP

func (p IPv6Packet) SetSourceIP(ip net.IP)

func (IPv6Packet) SourceIP

func (p IPv6Packet) SourceIP() net.IP

func (IPv6Packet) TotalLen

func (p IPv6Packet) TotalLen() uint16

type TCPPacket

type TCPPacket []byte

func (TCPPacket) Checksum

func (p TCPPacket) Checksum() uint16

func (TCPPacket) DestinationPort

func (p TCPPacket) DestinationPort() uint16

func (TCPPacket) IsSYN

func (p TCPPacket) IsSYN() bool

func (TCPPacket) ResetChecksum

func (p TCPPacket) ResetChecksum(psum uint32)

func (TCPPacket) SetChecksum

func (p TCPPacket) SetChecksum(sum [2]byte)

func (TCPPacket) SetDestinationPort

func (p TCPPacket) SetDestinationPort(port uint16)

func (TCPPacket) SetSourcePort

func (p TCPPacket) SetSourcePort(port uint16)

func (TCPPacket) SourcePort

func (p TCPPacket) SourcePort() uint16

type UDPPacket

type UDPPacket []byte

func (UDPPacket) Checksum

func (p UDPPacket) Checksum() uint16

func (UDPPacket) DestinationPort

func (p UDPPacket) DestinationPort() uint16

func (UDPPacket) Length

func (p UDPPacket) Length() uint16

func (UDPPacket) ResetChecksum

func (p UDPPacket) ResetChecksum(psum uint32)

func (UDPPacket) SetChecksum

func (p UDPPacket) SetChecksum(sum [2]byte)

func (UDPPacket) SetDestinationPort

func (p UDPPacket) SetDestinationPort(port uint16)

func (UDPPacket) SetLength

func (p UDPPacket) SetLength(length uint16)

func (UDPPacket) SetSourcePort

func (p UDPPacket) SetSourcePort(port uint16)

func (UDPPacket) SourcePort

func (p UDPPacket) SourcePort() uint16

Jump to

Keyboard shortcuts

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