Documentation
¶
Index ¶
- Constants
- Variables
- func BytesToIcmp6Code(b []byte) string
- func BytesToIcmp6Type(b []byte) string
- func BytesToIcmpCode(b []byte) string
- func BytesToIcmpType(b []byte) string
- func BytesToProtoString(b []byte) string
- func BytesToTcpFlags(b []byte) string
- type HeaderOffset
- type Icmp6Code
- type Icmp6Type
- type IcmpCode
- type IcmpType
- type ProtoDesc
- type ProtoDescPtr
- type ProtoHdrDesc
- type ProtoHdrHolder
- type ProtoLayerHolder
- type ProtoType
- type ProtoTypeHolder
- type TcpFlagType
Constants ¶
View Source
const ( BitsPerByte byte = 8 BitsPerHalfByte byte = BitsPerByte / 2 )
View Source
const ( ICMPHDR_TYPE = HeaderOffset(byte(0) * BitsPerByte) ICMPHDR_CODE = HeaderOffset(byte(1) * BitsPerByte) ICMPHDR_CHECKSUM = HeaderOffset(byte(2) * BitsPerByte) ICMPHDR_ID = HeaderOffset(byte(4) * BitsPerByte) ICMPHDR_SEQ = HeaderOffset(byte(6) * BitsPerByte) ICMPHDR_GATEWAY = HeaderOffset(byte(8) * BitsPerByte) ICMPHDR_MTU = HeaderOffset(byte(14) * BitsPerByte) )
View Source
const ( ICMP6HDR_TYPE = HeaderOffset(byte(0) * BitsPerByte) ICMP6HDR_CODE = HeaderOffset(byte(1) * BitsPerByte) ICMP6HDR_CHECKSUM = HeaderOffset(byte(2) * BitsPerByte) ICMP6HDR_PPTR = HeaderOffset(byte(4) * BitsPerByte) ICMP6HDR_MTU = HeaderOffset(byte(8) * BitsPerByte) )
View Source
const ( UDPHDR_SPORT = HeaderOffset(byte(0) * BitsPerByte) UDPHDR_DPORT = HeaderOffset(byte(2) * BitsPerByte) UDPHDR_LENGTH = HeaderOffset(byte(4) * BitsPerByte) UDPHDR_CHECKSUM = HeaderOffset(byte(6) * BitsPerByte) )
View Source
const ( TCPHDR_SPORT = HeaderOffset(byte(0) * BitsPerByte) TCPHDR_DPORT = HeaderOffset(byte(2) * BitsPerByte) TCPHDR_SEQ = HeaderOffset(byte(4) * BitsPerByte) TCPHDR_ACKSEQ = HeaderOffset(byte(8) * BitsPerByte) TCPHDR_RESERVED = HeaderOffset(byte(12) * BitsPerByte) TCPHDR_DOFF = HeaderOffset(byte(TCPHDR_RESERVED) + BitsPerHalfByte) TCPHDR_FLAGS = HeaderOffset(byte(13) * BitsPerByte) TCPHDR_WINDOW = HeaderOffset(byte(14) * BitsPerByte) TCPHDR_CHECKSUM = HeaderOffset(byte(16) * BitsPerByte) TCPHDR_URGPTR = HeaderOffset(byte(18) * BitsPerByte) )
View Source
const ( IPHDR_HDRLENGTH = HeaderOffset(byte(0) * BitsPerHalfByte) IPHDR_VERSION = HeaderOffset(byte(IPHDR_HDRLENGTH) + BitsPerHalfByte) IPHDR_ECN = HeaderOffset(byte(IPHDR_VERSION) + BitsPerHalfByte) IPHDR_DSCP = HeaderOffset(byte(IPHDR_ECN) + BitsPerHalfByte) IPHDR_LENGTH = HeaderOffset(byte(IPHDR_DSCP) + BitsPerHalfByte) IPHDR_ID = HeaderOffset(byte(IPHDR_LENGTH) + 2*BitsPerByte) IPHDR_FRAG_OFF = HeaderOffset(byte(IPHDR_ID) + 2*BitsPerByte) IPHDR_TTL = HeaderOffset(byte(8) * BitsPerByte) IPHDR_PROTOCOL = HeaderOffset(byte(9) * BitsPerByte) IPHDR_CHECKSUM = HeaderOffset(byte(10) * BitsPerByte) IPHDR_SADDR = HeaderOffset(byte(12) * BitsPerByte) IPHDR_DADDR = HeaderOffset(byte(16) * BitsPerByte) )
View Source
const ( IP6HDR_VERSION = HeaderOffset(byte(0) * BitsPerByte) IP6HDR_FLOWLABEL = HeaderOffset(byte(1) * BitsPerByte) IP6HDR_LENGTH = HeaderOffset(byte(4) * BitsPerByte) IP6HDR_NEXTHDR = HeaderOffset(byte(6) * BitsPerByte) IP6HDR_HOPLIMIT = HeaderOffset(byte(7) * BitsPerByte) IP6HDR_SADDR = HeaderOffset(byte(8) * BitsPerByte) IP6HDR_DADDR = HeaderOffset(byte(24) * BitsPerByte) )
Variables ¶
View Source
var Protocols = ProtoLayerHolder{ expr.PayloadBaseTransportHeader: { unix.IPPROTO_ICMP: ProtoDesc{ Name: "icmp", Id: unix.IPPROTO_ICMP, Base: expr.PayloadBaseTransportHeader, CurrentOffset: ICMPHDR_TYPE, Offsets: ProtoHdrHolder{ ICMPHDR_TYPE: ProtoHdrDesc{Name: "type", Desc: BytesToIcmpType}, ICMPHDR_CODE: ProtoHdrDesc{Name: "code", Desc: BytesToIcmpCode}, ICMPHDR_CHECKSUM: ProtoHdrDesc{Name: "checksum", Desc: bytes.BytesToDecimalString}, ICMPHDR_ID: ProtoHdrDesc{Name: "id", Desc: bytes.BytesToDecimalString}, ICMPHDR_SEQ: ProtoHdrDesc{Name: "sequence", Desc: bytes.BytesToDecimalString}, ICMPHDR_GATEWAY: ProtoHdrDesc{Name: "gateway", Desc: bytes.BytesToDecimalString}, ICMPHDR_MTU: ProtoHdrDesc{Name: "mtu", Desc: bytes.BytesToDecimalString}, }, }, unix.IPPROTO_ICMPV6: ProtoDesc{ Name: "icmpv6", Id: unix.IPPROTO_ICMPV6, Base: expr.PayloadBaseTransportHeader, CurrentOffset: ICMP6HDR_TYPE, Offsets: ProtoHdrHolder{ ICMP6HDR_TYPE: ProtoHdrDesc{Name: "type", Desc: BytesToIcmp6Type}, ICMP6HDR_CODE: ProtoHdrDesc{Name: "code", Desc: BytesToIcmp6Code}, ICMP6HDR_CHECKSUM: ProtoHdrDesc{Name: "checksum", Desc: bytes.BytesToDecimalString}, ICMP6HDR_PPTR: ProtoHdrDesc{Name: "parameter-problem", Desc: bytes.BytesToDecimalString}, ICMP6HDR_MTU: ProtoHdrDesc{Name: "mtu", Desc: bytes.BytesToDecimalString}, }, }, unix.IPPROTO_UDP: ProtoDesc{ Name: "udp", Id: unix.IPPROTO_UDP, Base: expr.PayloadBaseTransportHeader, CurrentOffset: UDPHDR_SPORT, Offsets: ProtoHdrHolder{ UDPHDR_SPORT: ProtoHdrDesc{Name: "sport", Desc: bytes.BytesToDecimalString}, UDPHDR_DPORT: ProtoHdrDesc{Name: "dport", Desc: bytes.BytesToDecimalString}, UDPHDR_LENGTH: ProtoHdrDesc{Name: "length", Desc: bytes.BytesToDecimalString}, UDPHDR_CHECKSUM: ProtoHdrDesc{Name: "checksum", Desc: bytes.BytesToDecimalString}, }, }, unix.IPPROTO_TCP: ProtoDesc{ Name: "tcp", Id: unix.IPPROTO_TCP, Base: expr.PayloadBaseTransportHeader, CurrentOffset: TCPHDR_SPORT, Offsets: ProtoHdrHolder{ TCPHDR_SPORT: ProtoHdrDesc{Name: "sport", Desc: bytes.BytesToDecimalString}, TCPHDR_DPORT: ProtoHdrDesc{Name: "dport", Desc: bytes.BytesToDecimalString}, TCPHDR_SEQ: ProtoHdrDesc{Name: "sequence", Desc: bytes.BytesToDecimalString}, TCPHDR_ACKSEQ: ProtoHdrDesc{Name: "ackseq", Desc: bytes.BytesToDecimalString}, TCPHDR_RESERVED: ProtoHdrDesc{Name: "rederved", Desc: bytes.BytesToDecimalString}, TCPHDR_DOFF: ProtoHdrDesc{Name: "doff", Desc: bytes.BytesToDecimalString}, TCPHDR_FLAGS: ProtoHdrDesc{Name: "flags", Desc: BytesToTcpFlags}, TCPHDR_WINDOW: ProtoHdrDesc{Name: "window", Desc: bytes.BytesToDecimalString}, TCPHDR_CHECKSUM: ProtoHdrDesc{Name: "checksum", Desc: bytes.BytesToDecimalString}, TCPHDR_URGPTR: ProtoHdrDesc{Name: "urgptr", Desc: bytes.BytesToDecimalString}, }, }, unix.IPPROTO_NONE: ProtoDesc{ Name: "th", Id: unix.IPPROTO_NONE, Base: expr.PayloadBaseTransportHeader, CurrentOffset: THDR_SPORT, Offsets: ProtoHdrHolder{ THDR_SPORT: ProtoHdrDesc{Name: "sport", Desc: bytes.BytesToDecimalString}, THDR_DPORT: ProtoHdrDesc{Name: "dport", Desc: bytes.BytesToDecimalString}, }, }, }, expr.PayloadBaseNetworkHeader: { unix.IPPROTO_IP: ProtoDesc{ Name: "ip", Id: unix.IPPROTO_IP, Base: expr.PayloadBaseNetworkHeader, CurrentOffset: IPHDR_HDRLENGTH, Offsets: ProtoHdrHolder{ IPHDR_HDRLENGTH: ProtoHdrDesc{Name: "hdrlength", Desc: bytes.BytesToDecimalString}, IPHDR_VERSION: ProtoHdrDesc{Name: "version", Desc: bytes.BytesToIPVer}, IPHDR_ECN: ProtoHdrDesc{Name: "ecn", Desc: bytes.BytesToEcn}, IPHDR_DSCP: ProtoHdrDesc{Name: "dscp", Desc: bytes.BytesToDscp}, IPHDR_LENGTH: ProtoHdrDesc{Name: "length", Desc: bytes.BytesToDecimalString}, IPHDR_ID: ProtoHdrDesc{Name: "id", Desc: bytes.BytesToDecimalString}, IPHDR_FRAG_OFF: ProtoHdrDesc{Name: "frag-off", Desc: bytes.BytesToHexString}, IPHDR_TTL: ProtoHdrDesc{Name: "ttl", Desc: bytes.BytesToDecimalString}, IPHDR_PROTOCOL: ProtoHdrDesc{Name: "protocol", Desc: BytesToProtoString}, IPHDR_CHECKSUM: ProtoHdrDesc{Name: "checksum", Desc: bytes.BytesToDecimalString}, IPHDR_SADDR: ProtoHdrDesc{Name: "saddr", Desc: bytes.BytesToAddrString}, IPHDR_DADDR: ProtoHdrDesc{Name: "daddr", Desc: bytes.BytesToAddrString}, }, }, unix.IPPROTO_IPV6: ProtoDesc{ Name: "ip6", Id: unix.IPPROTO_IPV6, Base: expr.PayloadBaseNetworkHeader, CurrentOffset: IP6HDR_VERSION, Offsets: ProtoHdrHolder{ IP6HDR_VERSION: ProtoHdrDesc{Name: "version", Desc: bytes.BytesToDecimalString}, IP6HDR_FLOWLABEL: ProtoHdrDesc{Name: "flowlabel", Desc: bytes.BytesToDecimalString}, IP6HDR_LENGTH: ProtoHdrDesc{Name: "length", Desc: bytes.BytesToDecimalString}, IP6HDR_NEXTHDR: ProtoHdrDesc{Name: "nexthdr", Desc: bytes.BytesToDecimalString}, IP6HDR_HOPLIMIT: ProtoHdrDesc{Name: "hoplimit", Desc: bytes.BytesToDecimalString}, IP6HDR_SADDR: ProtoHdrDesc{Name: "saddr", Desc: bytes.BytesToAddrString}, IP6HDR_DADDR: ProtoHdrDesc{Name: "daddr", Desc: bytes.BytesToAddrString}, }, }, }, }
Functions ¶
func BytesToIcmp6Code ¶
func BytesToIcmp6Type ¶
func BytesToIcmpCode ¶
func BytesToIcmpType ¶
func BytesToProtoString ¶
func BytesToTcpFlags ¶
Types ¶
type HeaderOffset ¶
type HeaderOffset uint32
const ( THDR_SPORT HeaderOffset = HeaderOffset(byte(0) * BitsPerByte) THDR_DPORT HeaderOffset = HeaderOffset(byte(2) * BitsPerByte) )
func (HeaderOffset) BytesToBits ¶
func (nbytes HeaderOffset) BytesToBits() HeaderOffset
func (HeaderOffset) WithBitMask ¶
func (offset HeaderOffset) WithBitMask(mask uint32) HeaderOffset
type Icmp6Code ¶
type Icmp6Code int
type Icmp6Type ¶
type Icmp6Type int
const ( ICMP6_DST_UNREACH Icmp6Type = 1 ICMP6_PACKET_TOO_BIG Icmp6Type = 2 ICMP6_TIME_EXCEEDED Icmp6Type = 3 ICMP6_PARAM_PROB Icmp6Type = 4 ICMP6_ECHO_REQUEST Icmp6Type = 128 ICMP6_ECHO_REPLY Icmp6Type = 129 MLD_LISTENER_QUERY Icmp6Type = 130 MLD_LISTENER_REPORT Icmp6Type = 131 MLD_LISTENER_REDUCTION Icmp6Type = 132 ND_NEIGHBOR_SOLICIT Icmp6Type = 133 ND_NEIGHBOR_ADVERT Icmp6Type = 134 ND_REDIRECT Icmp6Type = 137 ICMP6_ROUTER_RENUMBERING Icmp6Type = 138 IND_NEIGHBOR_SOLICIT Icmp6Type = 141 IND_NEIGHBOR_ADVERT Icmp6Type = 142 ICMPV6_MLD2_REPORT Icmp6Type = 143 )
ICMP6_TYPE
type IcmpCode ¶
type IcmpCode int
type IcmpType ¶
type IcmpType int
const ( ICMP_ECHOREPLY IcmpType = 0 ICMP_DEST_UNREACH IcmpType = 3 ICMP_SOURCE_QUENCH IcmpType = 4 ICMP_REDIRECT IcmpType = 5 ICMP_ECHO IcmpType = 8 ICMP_ROUTERADVERT IcmpType = 9 ICMP_ROUTERSOLICIT IcmpType = 10 ICMP_TIME_EXCEEDED IcmpType = 11 ICMP_PARAMETERPROB IcmpType = 12 ICMP_TIMESTAMP IcmpType = 13 ICMP_TIMESTAMPREPLY IcmpType = 14 ICMP_INFO_REQUEST IcmpType = 15 ICMP_INFO_REPLY IcmpType = 16 ICMP_ADDRESS IcmpType = 17 ICMP_ADDRESSREPLY IcmpType = 18 )
ICMP_TYPE
type ProtoDesc ¶
type ProtoDesc struct {
Name string
Id ProtoType
Base expr.PayloadBase
CurrentOffset HeaderOffset
Offsets ProtoHdrHolder
}
type ProtoDescPtr ¶
type ProtoDescPtr *ProtoDesc
type ProtoHdrDesc ¶
type ProtoHdrHolder ¶
type ProtoHdrHolder map[HeaderOffset]ProtoHdrDesc
type ProtoLayerHolder ¶
type ProtoLayerHolder map[expr.PayloadBase]ProtoTypeHolder
type ProtoTypeHolder ¶
type TcpFlagType ¶
type TcpFlagType int
const ( TCP_FLAG_FIN TcpFlagType = 1 << iota TCP_FLAG_SYN TCP_FLAG_RST TCP_FLAG_PSH TCP_FLAG_ACK TCP_FLAG_URG TCP_FLAG_ECN TCP_FLAG_CWR )
TCP_FLAG_TYPE
func (TcpFlagType) String ¶
func (t TcpFlagType) String() string
Click to show internal directories.
Click to hide internal directories.