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 <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
Index ¶
- Constants
- Variables
- func Checksum(sum uint32, b []byte) (answer [2]byte)
- func ConvertIPv4ToUint32(ip net.IP) uint32
- func ConvertUint32ToIPv4(v uint32) net.IP
- func IsBroadcast(addr net.HardwareAddr) bool
- func IsIPv4(packet []byte) bool
- func IsIPv4Multicast(addr net.HardwareAddr) bool
- func IsIPv6(packet []byte) bool
- func Sum(b []byte) uint32
- type Ethertype
- type ICMPPacket
- type ICMPType
- type IP4Pool
- type IPProtocol
- type IPv4Packet
- func (p IPv4Packet) Checksum() uint16
- func (p IPv4Packet) DSCP() byte
- func (p IPv4Packet) DataLen() uint16
- func (p IPv4Packet) DestinationIP() net.IP
- func (p IPv4Packet) ECN() byte
- func (p IPv4Packet) HeaderLen() uint16
- func (p IPv4Packet) Identification() [2]byte
- func (p IPv4Packet) Payload() []byte
- func (p IPv4Packet) Protocol() IPProtocol
- func (p IPv4Packet) PseudoSum() uint32
- func (p IPv4Packet) ResetChecksum()
- func (p IPv4Packet) SetChecksum(sum [2]byte)
- func (p IPv4Packet) SetDestinationIP(ip net.IP)
- func (p IPv4Packet) SetSourceIP(ip net.IP)
- func (p IPv4Packet) SourceIP() net.IP
- func (p IPv4Packet) TTL() byte
- func (p IPv4Packet) TotalLen() uint16
- type MACPacket
- type TCPPacket
- func (p TCPPacket) Checksum() uint16
- func (p TCPPacket) DestinationPort() uint16
- func (p TCPPacket) ResetChecksum(psum uint32)
- func (p TCPPacket) SetChecksum(sum [2]byte)
- func (p TCPPacket) SetDestinationPort(port uint16)
- func (p TCPPacket) SetSourcePort(port uint16)
- func (p TCPPacket) SourcePort() uint16
- type Tagging
- type UDPPacket
- func (p UDPPacket) Checksum() uint16
- func (p UDPPacket) DestinationPort() uint16
- func (p UDPPacket) ResetChecksum(psum uint32)
- func (p UDPPacket) SetChecksum(sum [2]byte)
- func (p UDPPacket) SetDestinationPort(port uint16)
- func (p UDPPacket) SetSourcePort(port uint16)
- func (p UDPPacket) SourcePort() uint16
Constants ¶
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 ¶
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 ConvertIPv4ToUint32 ¶
func ConvertUint32ToIPv4 ¶
func IsBroadcast ¶
func IsBroadcast(addr net.HardwareAddr) bool
func IsIPv4Multicast ¶
func IsIPv4Multicast(addr net.HardwareAddr) bool
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 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) 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 (MACPacket) MACPayload ¶
func (MACPacket) MACSource ¶
func (macFrame MACPacket) MACSource() net.HardwareAddr
func (MACPacket) MACTagging ¶
type TCPPacket ¶
type TCPPacket []byte
func (TCPPacket) DestinationPort ¶
func (TCPPacket) ResetChecksum ¶
func (TCPPacket) SetChecksum ¶
func (TCPPacket) SetDestinationPort ¶
func (TCPPacket) SetSourcePort ¶
func (TCPPacket) SourcePort ¶
type UDPPacket ¶
type UDPPacket []byte