tcpip

package
v0.0.0-...-7757972 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2016 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Author: FTwOoO <booobooob@gmail.com>

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Author: FTwOoO <booobooob@gmail.com>

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Author: FTwOoO <booobooob@gmail.com>

Index

Constants

View Source
const (
	HOPOPT            = 0x00
	ICMP              = 0x01
	IGMP              = 0x02
	GGP               = 0x03
	IPv4Encapsulation = 0x04
	ST                = 0x05
	TCP               = 0x06
	CBT               = 0x07
	EGP               = 0x08
	IGP               = 0x09
	BBN_RCC_MON       = 0x0A
	NVP_II            = 0x0B
	PUP               = 0x0C
	ARGUS             = 0x0D
	EMCON             = 0x0E
	XNET              = 0x0F
	CHAOS             = 0x10
	UDP               = 0x11
	MUX               = 0x12
	DCN_MEAS          = 0x13
	HMP               = 0x14
	PRM               = 0x15
	XNS_IDP           = 0x16
	TRUNK_1           = 0x17
	TRUNK_2           = 0x18
	LEAF_1            = 0x19
	LEAF_2            = 0x1A
	RDP               = 0x1B
	IRTP              = 0x1C
	ISO_TP4           = 0x1D
	NETBLT            = 0x1E
	MFE_NSP           = 0x1F
	MERIT_INP         = 0x20
	DCCP              = 0x21
	ThirdPC           = 0x22
	IDPR              = 0x23
	XTP               = 0x24
	DDP               = 0x25
	IDPR_CMTP         = 0x26
	TPxx              = 0x27
	IL                = 0x28
	IPv6Encapsulation = 0x29
	SDRP              = 0x2A
	IPv6_Route        = 0x2B
	IPv6_Frag         = 0x2C
	IDRP              = 0x2D
	RSVP              = 0x2E
	GRE               = 0x2F
	MHRP              = 0x30
	BNA               = 0x31
	ESP               = 0x32
	AH                = 0x33
	I_NLSP            = 0x34
	SWIPE             = 0x35
	NARP              = 0x36
	MOBILE            = 0x37
	TLSP              = 0x38
	SKIP              = 0x39
	IPv6_ICMP         = 0x3A
	IPv6_NoNxt        = 0x3B
	IPv6_Opts         = 0x3C
	CFTP              = 0x3E
	SAT_EXPAK         = 0x40
	KRYPTOLAN         = 0x41
	RVD               = 0x42
	IPPC              = 0x43
	SAT_MON           = 0x45
	VISA              = 0x46
	IPCV              = 0x47
	CPNX              = 0x48
	CPHB              = 0x49
	WSN               = 0x4A
	PVP               = 0x4B
	BR_SAT_MON        = 0x4C
	SUN_ND            = 0x4D
	WB_MON            = 0x4E
	WB_EXPAK          = 0x4F
	ISO_IP            = 0x50
	VMTP              = 0x51
	SECURE_VMTP       = 0x52
	VINES             = 0x53
	TTP               = 0x54
	IPTM              = 0x54
	NSFNET_IGP        = 0x55
	DGP               = 0x56
	TCF               = 0x57
	EIGRP             = 0x58
	OSPF              = 0x59
	Sprite_RPC        = 0x5A
	LARP              = 0x5B
	MTP               = 0x5C
	AX_25             = 0x5D
	IPIP              = 0x5E
	MICP              = 0x5F
	SCC_SP            = 0x60
	ETHERIP           = 0x61
	ENCAP             = 0x62
	GMTP              = 0x64
	IFMP              = 0x65
	PNNI              = 0x66
	PIM               = 0x67
	ARIS              = 0x68
	SCPS              = 0x69
	QNX               = 0x6A
	A_N               = 0x6B
	IPComp            = 0x6C
	SNP               = 0x6D
	Compaq_Peer       = 0x6E
	IPX_in_IP         = 0x6F
	VRRP              = 0x70
	PGM               = 0x71
	L2TP              = 0x73
	DDX               = 0x74
	IATP              = 0x75
	STP               = 0x76
	SRP               = 0x77
	UTI               = 0x78
	SMP               = 0x79
	SM                = 0x7A
	PTP               = 0x7B
	FIRE              = 0x7D
	CRTP              = 0x7E
	CRUDP             = 0x7F
	SSCOPMCE          = 0x80
	IPLT              = 0x81
	SPS               = 0x82
	PIPE              = 0x83
	SCTP              = 0x84
	FC                = 0x85

	HIP   = 0x8B
	Shim6 = 0x8C
)

IP Protocols. From: http://en.wikipedia.org/wiki/List_of_IP_protocol_numbers

Variables

View Source
var (
	IPv4                = Ethertype{0x08, 0x00}
	ARP                 = Ethertype{0x08, 0x06}
	WakeOnLAN           = Ethertype{0x08, 0x42}
	TRILL               = Ethertype{0x22, 0xF3}
	DECnetPhase4        = Ethertype{0x60, 0x03}
	RARP                = Ethertype{0x80, 0x35}
	AppleTalk           = Ethertype{0x80, 0x9B}
	AARP                = Ethertype{0x80, 0xF3}
	IPX1                = Ethertype{0x81, 0x37}
	IPX2                = Ethertype{0x81, 0x38}
	QNXQnet             = Ethertype{0x82, 0x04}
	IPv6                = Ethertype{0x86, 0xDD}
	EthernetFlowControl = Ethertype{0x88, 0x08}
	IEEE802_3           = Ethertype{0x88, 0x09}
	CobraNet            = Ethertype{0x88, 0x19}
	MPLSUnicast         = Ethertype{0x88, 0x47}
	MPLSMulticast       = Ethertype{0x88, 0x48}
	PPPoEDiscovery      = Ethertype{0x88, 0x63}
	PPPoESession        = Ethertype{0x88, 0x64}
	JumboFrames         = Ethertype{0x88, 0x70}
	HomePlug1_0MME      = Ethertype{0x88, 0x7B}
	IEEE802_1X          = Ethertype{0x88, 0x8E}
	PROFINET            = Ethertype{0x88, 0x92}
	HyperSCSI           = Ethertype{0x88, 0x9A}
	AoE                 = Ethertype{0x88, 0xA2}
	EtherCAT            = Ethertype{0x88, 0xA4}
	EthernetPowerlink   = Ethertype{0x88, 0xAB}
	LLDP                = Ethertype{0x88, 0xCC}
	SERCOS3             = Ethertype{0x88, 0xCD}
	HomePlugAVMME       = Ethertype{0x88, 0xE1}
	MRP                 = Ethertype{0x88, 0xE3}
	IEEE802_1AE         = Ethertype{0x88, 0xE5}
	IEEE1588            = Ethertype{0x88, 0xF7}
	IEEE802_1ag         = Ethertype{0x89, 0x02}
	FCoE                = Ethertype{0x89, 0x06}
	FCoEInit            = Ethertype{0x89, 0x14}
	RoCE                = Ethertype{0x89, 0x15}
	CTP                 = Ethertype{0x90, 0x00}
	VeritasLLT          = Ethertype{0xCA, 0xFE}
)

Ethertype values. From: http://en.wikipedia.org/wiki/Ethertype

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 IsBroadcast

func IsBroadcast(addr net.HardwareAddr) bool

func IsIPv4

func IsIPv4(packet []byte) bool

func IsIPv4Multicast

func IsIPv4Multicast(addr net.HardwareAddr) bool

func IsIPv6

func IsIPv6(packet []byte) bool

func Sum

func Sum(b []byte) uint32

Types

type Ethertype

type Ethertype [2]byte

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 IP4Pool

type IP4Pool struct {
	Subnet *net.IPNet
	// contains filtered or unexported fields
}

func NewIP4Pool

func NewIP4Pool(subnet *net.IPNet) (*IP4Pool, error)

func (*IP4Pool) Next

func (p *IP4Pool) Next() (net.IP, error)

func (*IP4Pool) Release

func (p *IP4Pool) Release(ip net.IP)

type IPProtocol

type IPProtocol byte

type IPv4Packet

type IPv4Packet []byte

func (IPv4Packet) Checksum

func (p IPv4Packet) Checksum() uint16

func (IPv4Packet) DSCP

func (p IPv4Packet) DSCP() byte

func (IPv4Packet) DataLen

func (p IPv4Packet) DataLen() uint16

func (IPv4Packet) DestinationIP

func (p IPv4Packet) DestinationIP() net.IP

func (IPv4Packet) ECN

func (p IPv4Packet) ECN() byte

func (IPv4Packet) HeaderLen

func (p IPv4Packet) HeaderLen() uint16

func (IPv4Packet) Identification

func (p IPv4Packet) Identification() [2]byte

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) SetSourceIP

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

func (IPv4Packet) SourceIP

func (p IPv4Packet) SourceIP() net.IP

func (IPv4Packet) TTL

func (p IPv4Packet) TTL() byte

func (IPv4Packet) TotalLen

func (p IPv4Packet) TotalLen() uint16

type MACPacket

type MACPacket []byte

func (MACPacket) MACDestination

func (macFrame MACPacket) MACDestination() net.HardwareAddr

func (MACPacket) MACEthertype

func (macFrame MACPacket) MACEthertype() Ethertype

func (MACPacket) MACPayload

func (macFrame MACPacket) MACPayload() []byte

func (MACPacket) MACSource

func (macFrame MACPacket) MACSource() net.HardwareAddr

func (MACPacket) MACTagging

func (macFrame MACPacket) MACTagging() Tagging

type TCPPacket

type TCPPacket []byte

func (TCPPacket) Checksum

func (p TCPPacket) Checksum() uint16

func (TCPPacket) DestinationPort

func (p TCPPacket) DestinationPort() uint16

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 Tagging

type Tagging int
const (
	NotTagged    Tagging = 0
	Tagged       Tagging = 4
	DoubleTagged Tagging = 8
)

Indicating whether/how a MAC frame is tagged. The value is number of bytes taken by tagging.

type UDPPacket

type UDPPacket []byte

func (UDPPacket) Checksum

func (p UDPPacket) Checksum() uint16

func (UDPPacket) DestinationPort

func (p UDPPacket) DestinationPort() 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) 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