Documentation ¶
Overview ¶
Package header provides the implementation of the encoding and decoding of network protocol headers.
Index ¶
- Constants
- Variables
- func Acceptable(segSeq seqnum.Value, segLen seqnum.Size, rcvNxt, rcvAcc seqnum.Value) bool
- func AddTCPOptionPadding(options []byte, offset int) int
- func AppendOpaqueInterfaceIdentifier(buf []byte, prefix tcpip.Subnet, nicName string, dadCounter uint8, ...) []byte
- func Checksum(buf []byte, initial uint16) uint16
- func ChecksumCombine(a, b uint16) uint16
- func ChecksumOld(buf []byte, initial uint16) uint16
- func ChecksumVV(vv buffer.VectorisedView, initial uint16) uint16
- func DecisecondToDuration(ds uint8) time.Duration
- func EncodeMSSOption(mss uint32, b []byte) int
- func EncodeNOP(b []byte) int
- func EncodeSACKBlocks(sackBlocks []SACKBlock, b []byte) int
- func EncodeSACKPermittedOption(b []byte) int
- func EncodeTSOption(tsVal, tsEcr uint32, b []byte) int
- func EncodeWSOption(ws int, b []byte) int
- func EthernetAdddressToModifiedEUI64IntoBuf(linkAddr tcpip.LinkAddress, buf []byte)
- func EthernetAddressFromMulticastIPv4Address(addr tcpip.Address) tcpip.LinkAddress
- func EthernetAddressFromMulticastIPv6Address(addr tcpip.Address) tcpip.LinkAddress
- func EthernetAddressToModifiedEUI64(linkAddr tcpip.LinkAddress) [IIDSize]byte
- func GenerateTempIPv6SLAACAddr(tempIIDHistory []byte, stableAddr tcpip.Address) tcpip.AddressWithPrefix
- func ICMPv4Checksum(h ICMPv4, payloadCsum uint16) uint16
- func ICMPv6Checksum(params ICMPv6ChecksumParams) uint16
- func IGMPCalculateChecksum(h IGMP) uint16
- func IPVersion(b []byte) int
- func InitialTempIID(initialTempIIDHistory []byte, seed []byte, nicID tcpip.NICID)
- func IsMulticastEthernetAddress(addr tcpip.LinkAddress) bool
- func IsSolicitedNodeAddr(addr tcpip.Address) bool
- func IsV4LinkLocalMulticastAddress(addr tcpip.Address) bool
- func IsV4LinkLocalUnicastAddress(addr tcpip.Address) bool
- func IsV4LoopbackAddress(addr tcpip.Address) bool
- func IsV4MappedAddress(addr tcpip.Address) bool
- func IsV4MulticastAddress(addr tcpip.Address) bool
- func IsV6LinkLocalMulticastAddress(addr tcpip.Address) bool
- func IsV6LinkLocalUnicastAddress(addr tcpip.Address) bool
- func IsV6LoopbackAddress(addr tcpip.Address) bool
- func IsV6MulticastAddress(addr tcpip.Address) bool
- func IsV6UnicastAddress(addr tcpip.Address) bool
- func IsValidUnicastEthernetAddress(addr tcpip.LinkAddress) bool
- func LinkLocalAddr(linkAddr tcpip.LinkAddress) tcpip.Address
- func LinkLocalAddrWithOpaqueIID(nicName string, dadCounter uint8, secretKey []byte) tcpip.Address
- func PseudoHeaderChecksum(protocol tcpip.TransportProtocolNumber, srcAddr tcpip.Address, ...) uint16
- func PutChecksum(b []byte, xsum uint16)
- func SolicitedNodeAddr(addr tcpip.Address) tcpip.Address
- type ARP
- type ARPHardwareType
- type ARPOp
- type Checksumer
- type ChecksummableNetwork
- type ChecksummableTransport
- type Ethernet
- type EthernetFields
- type GUE
- type GUEFields
- type ICMPv4
- func (b ICMPv4) Checksum() uint16
- func (b ICMPv4) Code() ICMPv4Code
- func (ICMPv4) DestinationPort() uint16
- func (b ICMPv4) Ident() uint16
- func (b ICMPv4) MTU() uint16
- func (b ICMPv4) Payload() []byte
- func (b ICMPv4) Pointer() byte
- func (b ICMPv4) Sequence() uint16
- func (b ICMPv4) SetChecksum(checksum uint16)
- func (b ICMPv4) SetCode(c ICMPv4Code)
- func (ICMPv4) SetDestinationPort(uint16)
- func (b ICMPv4) SetIdent(ident uint16)
- func (b ICMPv4) SetIdentWithChecksumUpdate(new uint16)
- func (b ICMPv4) SetMTU(mtu uint16)
- func (b ICMPv4) SetPointer(c byte)
- func (b ICMPv4) SetSequence(sequence uint16)
- func (ICMPv4) SetSourcePort(uint16)
- func (b ICMPv4) SetType(t ICMPv4Type)
- func (ICMPv4) SourcePort() uint16
- func (b ICMPv4) Type() ICMPv4Type
- type ICMPv4Code
- type ICMPv4Type
- type ICMPv6
- func (b ICMPv6) Checksum() uint16
- func (b ICMPv6) Code() ICMPv6Code
- func (ICMPv6) DestinationPort() uint16
- func (b ICMPv6) Ident() uint16
- func (b ICMPv6) MTU() uint32
- func (b ICMPv6) MessageBody() []byte
- func (b ICMPv6) Payload() []byte
- func (b ICMPv6) Sequence() uint16
- func (b ICMPv6) SetChecksum(checksum uint16)
- func (b ICMPv6) SetCode(c ICMPv6Code)
- func (ICMPv6) SetDestinationPort(uint16)
- func (b ICMPv6) SetIdent(ident uint16)
- func (b ICMPv6) SetIdentWithChecksumUpdate(new uint16)
- func (b ICMPv6) SetMTU(mtu uint32)
- func (b ICMPv6) SetSequence(sequence uint16)
- func (ICMPv6) SetSourcePort(uint16)
- func (b ICMPv6) SetType(t ICMPv6Type)
- func (b ICMPv6) SetTypeSpecific(val uint32)
- func (ICMPv6) SourcePort() uint16
- func (b ICMPv6) Type() ICMPv6Type
- func (b ICMPv6) TypeSpecific() uint32
- func (b ICMPv6) UpdateChecksumPseudoHeaderAddress(old, new tcpip.Address)
- type ICMPv6ChecksumParams
- type ICMPv6Code
- type ICMPv6Type
- type IGMP
- func (b IGMP) Checksum() uint16
- func (IGMP) DestinationPort() uint16
- func (b IGMP) GroupAddress() tcpip.Address
- func (b IGMP) MaxRespTime() time.Duration
- func (IGMP) Payload() []byte
- func (b IGMP) SetChecksum(checksum uint16)
- func (IGMP) SetDestinationPort(uint16)
- func (b IGMP) SetGroupAddress(address tcpip.Address)
- func (b IGMP) SetMaxRespTime(m byte)
- func (IGMP) SetSourcePort(uint16)
- func (b IGMP) SetType(t IGMPType)
- func (IGMP) SourcePort() uint16
- func (b IGMP) Type() IGMPType
- type IGMPType
- type IPv4
- func (b IPv4) CalculateChecksum() uint16
- func (b IPv4) Checksum() uint16
- func (b IPv4) DestinationAddress() tcpip.Address
- func (b IPv4) Encode(i *IPv4Fields)
- func (b IPv4) EncodePartial(partialChecksum, totalLength uint16)
- func (b IPv4) Flags() uint8
- func (b IPv4) FragmentOffset() uint16
- func (b IPv4) HeaderLength() uint8
- func (b IPv4) ID() uint16
- func (b IPv4) IsChecksumValid() bool
- func (b IPv4) IsValid(pktSize int) bool
- func (b IPv4) More() bool
- func (b IPv4) Options() IPv4Options
- func (b IPv4) Payload() []byte
- func (b IPv4) PayloadLength() uint16
- func (b IPv4) Protocol() uint8
- func (b IPv4) SetChecksum(v uint16)
- func (b IPv4) SetDestinationAddress(addr tcpip.Address)
- func (b IPv4) SetDestinationAddressWithChecksumUpdate(new tcpip.Address)
- func (b IPv4) SetFlagsFragmentOffset(flags uint8, offset uint16)
- func (b IPv4) SetHeaderLength(hdrLen uint8)
- func (b IPv4) SetID(v uint16)
- func (b IPv4) SetSourceAddress(addr tcpip.Address)
- func (b IPv4) SetSourceAddressWithChecksumUpdate(new tcpip.Address)
- func (b IPv4) SetTOS(v uint8, _ uint32)
- func (b IPv4) SetTTL(v byte)
- func (b IPv4) SetTotalLength(totalLength uint16)
- func (b IPv4) SourceAddress() tcpip.Address
- func (b IPv4) TOS() (uint8, uint32)
- func (b IPv4) TTL() uint8
- func (b IPv4) TotalLength() uint16
- func (b IPv4) TransportProtocol() tcpip.TransportProtocolNumber
- type IPv4Fields
- type IPv4OptParameterProblem
- type IPv4OptTSFlags
- type IPv4Option
- type IPv4OptionGeneric
- type IPv4OptionIterator
- func (i *IPv4OptionIterator) ConsumeBuffer(size int)
- func (i *IPv4OptionIterator) Finalize() IPv4Options
- func (i *IPv4OptionIterator) InitReplacement(option IPv4Option) IPv4Options
- func (i *IPv4OptionIterator) Next() (IPv4Option, bool, *IPv4OptParameterProblem)
- func (i *IPv4OptionIterator) PushNOPOrEnd(val IPv4OptionType)
- func (i *IPv4OptionIterator) RemainingBuffer() IPv4Options
- type IPv4OptionRecordRoute
- type IPv4OptionRouterAlert
- type IPv4OptionTimestamp
- func (ts *IPv4OptionTimestamp) Contents() []byte
- func (ts *IPv4OptionTimestamp) Flags() IPv4OptTSFlags
- func (ts *IPv4OptionTimestamp) IncOverflow() uint8
- func (ts *IPv4OptionTimestamp) Overflow() uint8
- func (ts *IPv4OptionTimestamp) Pointer() uint8
- func (ts *IPv4OptionTimestamp) Size() uint8
- func (ts *IPv4OptionTimestamp) Type() IPv4OptionType
- func (ts *IPv4OptionTimestamp) UpdateTimestamp(addr tcpip.Address, clock tcpip.Clock)
- type IPv4OptionType
- type IPv4Options
- type IPv4OptionsSerializer
- type IPv4SerializableListEndOption
- type IPv4SerializableNOPOption
- type IPv4SerializableOption
- type IPv4SerializableOptionPayload
- type IPv4SerializableRouterAlertOption
- type IPv6
- func (IPv6) Checksum() uint16
- func (b IPv6) DestinationAddress() tcpip.Address
- func (b IPv6) Encode(i *IPv6Fields)
- func (b IPv6) HopLimit() uint8
- func (b IPv6) IsValid(pktSize int) bool
- func (b IPv6) NextHeader() uint8
- func (b IPv6) Payload() []byte
- func (b IPv6) PayloadLength() uint16
- func (IPv6) SetChecksum(uint16)
- func (b IPv6) SetDestinationAddress(addr tcpip.Address)
- func (b IPv6) SetHopLimit(v uint8)
- func (b IPv6) SetNextHeader(v uint8)
- func (b IPv6) SetPayloadLength(payloadLength uint16)
- func (b IPv6) SetSourceAddress(addr tcpip.Address)
- func (b IPv6) SetTOS(t uint8, l uint32)
- func (b IPv6) SourceAddress() tcpip.Address
- func (b IPv6) TOS() (uint8, uint32)
- func (b IPv6) TransportProtocol() tcpip.TransportProtocolNumber
- type IPv6AddressScope
- type IPv6DestinationOptionsExtHdr
- type IPv6ExtHdrOption
- type IPv6ExtHdrOptionIdentifier
- type IPv6ExtHdrSerializer
- type IPv6ExtensionHeaderIdentifier
- type IPv6Fields
- type IPv6Fragment
- func (b IPv6Fragment) Checksum() uint16
- func (b IPv6Fragment) DestinationAddress() tcpip.Address
- func (b IPv6Fragment) FragmentOffset() uint16
- func (b IPv6Fragment) ID() uint32
- func (b IPv6Fragment) IsValid() bool
- func (b IPv6Fragment) More() bool
- func (b IPv6Fragment) NextHeader() uint8
- func (b IPv6Fragment) Payload() []byte
- func (b IPv6Fragment) SetChecksum(uint16)
- func (b IPv6Fragment) SetDestinationAddress(tcpip.Address)
- func (b IPv6Fragment) SetSourceAddress(tcpip.Address)
- func (b IPv6Fragment) SetTOS(t uint8, l uint32)
- func (b IPv6Fragment) SourceAddress() tcpip.Address
- func (b IPv6Fragment) TOS() (uint8, uint32)
- func (b IPv6Fragment) TransportProtocol() tcpip.TransportProtocolNumber
- type IPv6FragmentExtHdr
- type IPv6HopByHopOptionsExtHdr
- type IPv6MulticastScope
- type IPv6OptionUnknownAction
- type IPv6OptionsExtHdrOptionsIterator
- type IPv6PayloadHeader
- type IPv6PayloadIterator
- type IPv6RawPayloadHeader
- type IPv6RouterAlertOption
- type IPv6RouterAlertValue
- type IPv6RoutingExtHdr
- type IPv6SerializableExtHdr
- type IPv6SerializableFragmentExtHdr
- type IPv6SerializableHopByHopExtHdr
- type IPv6SerializableHopByHopOption
- type IPv6UnknownExtHdrOption
- type MLD
- type NDPDNSSearchList
- type NDPNeighborAdvert
- func (b NDPNeighborAdvert) Options() NDPOptions
- func (b NDPNeighborAdvert) OverrideFlag() bool
- func (b NDPNeighborAdvert) RouterFlag() bool
- func (b NDPNeighborAdvert) SetOverrideFlag(f bool)
- func (b NDPNeighborAdvert) SetRouterFlag(f bool)
- func (b NDPNeighborAdvert) SetSolicitedFlag(f bool)
- func (b NDPNeighborAdvert) SetTargetAddress(addr tcpip.Address)
- func (b NDPNeighborAdvert) SolicitedFlag() bool
- func (b NDPNeighborAdvert) TargetAddress() tcpip.Address
- type NDPNeighborSolicit
- type NDPNonceOption
- type NDPOption
- type NDPOptionIterator
- type NDPOptions
- type NDPOptionsSerializer
- type NDPPrefixInformation
- func (o NDPPrefixInformation) AutonomousAddressConfigurationFlag() bool
- func (o NDPPrefixInformation) OnLinkFlag() bool
- func (o NDPPrefixInformation) PreferredLifetime() time.Duration
- func (o NDPPrefixInformation) Prefix() tcpip.Address
- func (o NDPPrefixInformation) PrefixLength() uint8
- func (o NDPPrefixInformation) String() string
- func (o NDPPrefixInformation) Subnet() tcpip.Subnet
- func (o NDPPrefixInformation) ValidLifetime() time.Duration
- type NDPRecursiveDNSServer
- type NDPRouteInformation
- type NDPRoutePreference
- type NDPRouterAdvert
- func (b NDPRouterAdvert) CurrHopLimit() uint8
- func (b NDPRouterAdvert) DefaultRouterPreference() NDPRoutePreference
- func (b NDPRouterAdvert) ManagedAddrConfFlag() bool
- func (b NDPRouterAdvert) Options() NDPOptions
- func (b NDPRouterAdvert) OtherConfFlag() bool
- func (b NDPRouterAdvert) ReachableTime() time.Duration
- func (b NDPRouterAdvert) RetransTimer() time.Duration
- func (b NDPRouterAdvert) RouterLifetime() time.Duration
- type NDPRouterSolicit
- type NDPSourceLinkLayerAddressOption
- type NDPTargetLinkLayerAddressOption
- type Network
- type SACKBlock
- type TCP
- func (b TCP) AckNumber() uint32
- func (b TCP) CalculateChecksum(partialChecksum uint16) uint16
- func (b TCP) Checksum() uint16
- func (b TCP) DataOffset() uint8
- func (b TCP) DestinationPort() uint16
- func (b TCP) Encode(t *TCPFields)
- func (b TCP) EncodePartial(partialChecksum, length uint16, seqnum, acknum uint32, flags TCPFlags, ...)
- func (b TCP) Flags() TCPFlags
- func (b TCP) IsChecksumValid(src, dst tcpip.Address, payloadChecksum, payloadLength uint16) bool
- func (b TCP) Options() []byte
- func (b TCP) ParsedOptions() TCPOptions
- func (b TCP) Payload() []byte
- func (b TCP) SequenceNumber() uint32
- func (b TCP) SetAckNumber(ackNum uint32)
- func (b TCP) SetChecksum(checksum uint16)
- func (b TCP) SetDataOffset(headerLen uint8)
- func (b TCP) SetDestinationPort(port uint16)
- func (b TCP) SetDestinationPortWithChecksumUpdate(new uint16)
- func (b TCP) SetFlags(flags uint8)
- func (b TCP) SetSequenceNumber(seqNum uint32)
- func (b TCP) SetSourcePort(port uint16)
- func (b TCP) SetSourcePortWithChecksumUpdate(new uint16)
- func (b TCP) SetUrgentPointer(urgentPointer uint16)
- func (b TCP) SetWindowSize(rcvwnd uint16)
- func (b TCP) SourcePort() uint16
- func (b TCP) UpdateChecksumPseudoHeaderAddress(old, new tcpip.Address, fullChecksum bool)
- func (b TCP) UrgentPointer() uint16
- func (b TCP) WindowSize() uint16
- type TCPFields
- type TCPFlags
- type TCPOptions
- type TCPSynOptions
- type Transport
- type UDP
- func (b UDP) CalculateChecksum(partialChecksum uint16) uint16
- func (b UDP) Checksum() uint16
- func (b UDP) DestinationPort() uint16
- func (b UDP) Encode(u *UDPFields)
- func (b UDP) IsChecksumValid(src, dst tcpip.Address, payloadChecksum uint16) bool
- func (b UDP) Length() uint16
- func (b UDP) Payload() []byte
- func (b UDP) SetChecksum(checksum uint16)
- func (b UDP) SetDestinationPort(port uint16)
- func (b UDP) SetDestinationPortWithChecksumUpdate(new uint16)
- func (b UDP) SetLength(length uint16)
- func (b UDP) SetSourcePort(port uint16)
- func (b UDP) SetSourcePortWithChecksumUpdate(new uint16)
- func (b UDP) SourcePort() uint16
- func (b UDP) UpdateChecksumPseudoHeaderAddress(old, new tcpip.Address, fullChecksum bool)
- type UDPFields
- type VirtioNetHeader
- func (v VirtioNetHeader) CSumOffset() uint16
- func (v VirtioNetHeader) CSumStart() uint16
- func (v VirtioNetHeader) Encode(f *VirtioNetHeaderFields)
- func (v VirtioNetHeader) Flags() uint8
- func (v VirtioNetHeader) GSOSize() uint16
- func (v VirtioNetHeader) GSOType() uint8
- func (v VirtioNetHeader) HdrLen() uint16
- type VirtioNetHeaderFields
Constants ¶
const ( // ARPProtocolNumber is the ARP network protocol number. ARPProtocolNumber tcpip.NetworkProtocolNumber = 0x0806 // ARPSize is the size of an IPv4-over-Ethernet ARP packet. ARPSize = 28 )
const ( // EthernetMinimumSize is the minimum size of a valid ethernet frame. EthernetMinimumSize = 14 // EthernetAddressSize is the size, in bytes, of an ethernet address. EthernetAddressSize = 6 // UnspecifiedEthernetAddress is the unspecified ethernet address // (all bits set to 0). UnspecifiedEthernetAddress = tcpip.LinkAddress("\x00\x00\x00\x00\x00\x00") // EthernetBroadcastAddress is an ethernet address that addresses every node // on a local link. EthernetBroadcastAddress = tcpip.LinkAddress("\xff\xff\xff\xff\xff\xff") )
const ( // EthernetProtocolAll is a catch-all for all protocols carried inside // an ethernet frame. It is mainly used to create packet sockets that // capture all traffic. EthernetProtocolAll tcpip.NetworkProtocolNumber = 0x0003 // EthernetProtocolPUP is the PARC Universial Packet protocol ethertype. EthernetProtocolPUP tcpip.NetworkProtocolNumber = 0x0200 )
const ( // ICMPv4PayloadOffset defines the start of ICMP payload. ICMPv4PayloadOffset = 8 // ICMPv4MinimumSize is the minimum size of a valid ICMP packet. ICMPv4MinimumSize = 8 // ICMPv4MinimumErrorPayloadSize Is the smallest number of bytes of an // errant packet's transport layer that an ICMP error type packet should // attempt to send as per RFC 792 (see each type) and RFC 1122 // section 3.2.2 which states: // Every ICMP error message includes the Internet header and at // least the first 8 data octets of the datagram that triggered // the error; more than 8 octets MAY be sent; this header and data // MUST be unchanged from the received datagram. // // RFC 792 shows: // 0 1 2 3 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // | Type | Code | Checksum | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // | unused | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // | Internet Header + 64 bits of Original Data Datagram | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ICMPv4MinimumErrorPayloadSize = 8 // ICMPv4ProtocolNumber is the ICMP transport protocol number. ICMPv4ProtocolNumber tcpip.TransportProtocolNumber = 1 )
const ( // ICMPv6HeaderSize is the size of the ICMPv6 header. That is, the // sum of the size of the ICMPv6 Type, Code and Checksum fields, as // per RFC 4443 section 2.1. After the ICMPv6 header, the ICMPv6 // message body begins. ICMPv6HeaderSize = 4 // ICMPv6MinimumSize is the minimum size of a valid ICMP packet. ICMPv6MinimumSize = 8 // ICMPv6PayloadOffset is the offset of the payload in an // ICMP packet. ICMPv6PayloadOffset = 8 // ICMPv6ProtocolNumber is the ICMP transport protocol number. ICMPv6ProtocolNumber tcpip.TransportProtocolNumber = 58 // ICMPv6NeighborSolicitMinimumSize is the minimum size of a // neighbor solicitation packet. ICMPv6NeighborSolicitMinimumSize = ICMPv6HeaderSize + NDPNSMinimumSize // ICMPv6NeighborAdvertMinimumSize is the minimum size of a // neighbor advertisement packet. ICMPv6NeighborAdvertMinimumSize = ICMPv6HeaderSize + NDPNAMinimumSize // ICMPv6EchoMinimumSize is the minimum size of a valid echo packet. ICMPv6EchoMinimumSize = 8 // ICMPv6ErrorHeaderSize is the size of an ICMP error packet header, // as per RFC 4443, Apendix A, item 4 and the errata. // ... all ICMP error messages shall have exactly // 32 bits of type-specific data, so that receivers can reliably find // the embedded invoking packet even when they don't recognize the // ICMP message Type. ICMPv6ErrorHeaderSize = 8 // ICMPv6DstUnreachableMinimumSize is the minimum size of a valid ICMP // destination unreachable packet. ICMPv6DstUnreachableMinimumSize = ICMPv6MinimumSize // ICMPv6PacketTooBigMinimumSize is the minimum size of a valid ICMP // packet-too-big packet. ICMPv6PacketTooBigMinimumSize = ICMPv6MinimumSize // NDPHopLimit is the expected IP hop limit value of 255 for received // NDP packets, as per RFC 4861 sections 4.1 - 4.5, 6.1.1, 6.1.2, 7.1.1, // 7.1.2 and 8.1. If the hop limit value is not 255, nodes MUST silently // drop the NDP packet. All outgoing NDP packets must use this value for // its IP hop limit field. NDPHopLimit = 255 )
const ( // IGMPMinimumSize is the minimum size of a valid IGMP packet in bytes, // as per RFC 2236, Section 2, Page 2. IGMPMinimumSize = 8 // IGMPQueryMinimumSize is the minimum size of a valid Membership Query // Message in bytes, as per RFC 2236, Section 2, Page 2. IGMPQueryMinimumSize = 8 // IGMPReportMinimumSize is the minimum size of a valid Report Message in // bytes, as per RFC 2236, Section 2, Page 2. IGMPReportMinimumSize = 8 // IGMPLeaveMessageMinimumSize is the minimum size of a valid Leave Message // in bytes, as per RFC 2236, Section 2, Page 2. IGMPLeaveMessageMinimumSize = 8 // IGMPTTL is the TTL for all IGMP messages, as per RFC 2236, Section 3, Page // 3. IGMPTTL = 1 // IGMPProtocolNumber is IGMP's transport protocol number. IGMPProtocolNumber tcpip.TransportProtocolNumber = 2 )
const ( // IPv4MinimumSize is the minimum size of a valid IPv4 packet; // i.e. a packet header with no options. IPv4MinimumSize = 20 // IPv4MaximumHeaderSize is the maximum size of an IPv4 header. Given // that there are only 4 bits (max 0xF (15)) to represent the header length // in 32-bit (4 byte) units, the header cannot exceed 15*4 = 60 bytes. IPv4MaximumHeaderSize = 60 // IPv4MaximumOptionsSize is the largest size the IPv4 options can be. IPv4MaximumOptionsSize = IPv4MaximumHeaderSize - IPv4MinimumSize // IPv4MaximumPayloadSize is the maximum size of a valid IPv4 payload. // // Linux limits this to 65,515 octets (the max IP datagram size - the IPv4 // header size). But RFC 791 section 3.2 discusses the design of the IPv4 // fragment "allows 2**13 = 8192 fragments of 8 octets each for a total of // 65,536 octets. Note that this is consistent with the datagram total // length field (of course, the header is counted in the total length and not // in the fragments)." IPv4MaximumPayloadSize = 65536 // MinIPFragmentPayloadSize is the minimum number of payload bytes that // the first fragment must carry when an IPv4 packet is fragmented. MinIPFragmentPayloadSize = 8 // IPv4AddressSize is the size, in bytes, of an IPv4 address. IPv4AddressSize = 4 // IPv4ProtocolNumber is IPv4's network protocol number. IPv4ProtocolNumber tcpip.NetworkProtocolNumber = 0x0800 // IPv4Version is the version of the IPv4 protocol. IPv4Version = 4 // IPv4AllSystems is the all systems IPv4 multicast address as per // IANA's IPv4 Multicast Address Space Registry. See // https://www.iana.org/assignments/multicast-addresses/multicast-addresses.xhtml. IPv4AllSystems tcpip.Address = "\xe0\x00\x00\x01" // IPv4Broadcast is the broadcast address of the IPv4 procotol. IPv4Broadcast tcpip.Address = "\xff\xff\xff\xff" // IPv4Any is the non-routable IPv4 "any" meta address. IPv4Any tcpip.Address = "\x00\x00\x00\x00" // IPv4AllRoutersGroup is a multicast address for all routers. IPv4AllRoutersGroup tcpip.Address = "\xe0\x00\x00\x02" // IPv4MinimumProcessableDatagramSize is the minimum size of an IP // packet that every IPv4 capable host must be able to // process/reassemble. IPv4MinimumProcessableDatagramSize = 576 // IPv4MinimumMTU is the minimum MTU required by IPv4, per RFC 791, // section 3.2: // Every internet module must be able to forward a datagram of 68 octets // without further fragmentation. This is because an internet header may be // up to 60 octets, and the minimum fragment is 8 octets. IPv4MinimumMTU = 68 )
const ( IPv4FlagMoreFragments = 1 << iota IPv4FlagDontFragment )
Flags that may be set in an IPv4 packet.
const ( // IPv4OptionTimestampHdrLength is the length of the timestamp option header. IPv4OptionTimestampHdrLength = 4 // IPv4OptionTimestampSize is the size of an IP timestamp. IPv4OptionTimestampSize = 4 // IPv4OptionTimestampWithAddrSize is the size of an IP timestamp + Address. IPv4OptionTimestampWithAddrSize = IPv4AddressSize + IPv4OptionTimestampSize // IPv4OptionTimestampMaxSize is limited by space for options IPv4OptionTimestampMaxSize = IPv4MaximumOptionsSize // IPv4OptionTimestampOnlyFlag is a flag indicating that only timestamp // is present. IPv4OptionTimestampOnlyFlag IPv4OptTSFlags = 0 // IPv4OptionTimestampWithIPFlag is a flag indicating that both timestamps and // IP are present. IPv4OptionTimestampWithIPFlag IPv4OptTSFlags = 1 // IPv4OptionTimestampWithPredefinedIPFlag is a flag indicating that // predefined IP is present. IPv4OptionTimestampWithPredefinedIPFlag IPv4OptTSFlags = 3 )
Timestamp option specific related constants.
const ( // IPv4OptTSPointerOffset is the offset of the Timestamp pointer field. IPv4OptTSPointerOffset = 2 // IPv4OptTSPointerOffset is the offset of the combined Flag and Overflow // fields, (each being 4 bits). IPv4OptTSOFLWAndFLGOffset = 3 )
IP Timestamp option fields.
const ( // IPv4OptionRecordRouteHdrLength is the length of the Record Route option // header. IPv4OptionRecordRouteHdrLength = 3 // IPv4OptRRPointerOffset is the offset to the pointer field in an RR // option, which points to the next free slot in the list of addresses. IPv4OptRRPointerOffset = 2 )
RecordRoute option specific related constants.
from RFC 791 page 20:
Record Route +--------+--------+--------+---------//--------+ |00000111| length | pointer| route data | +--------+--------+--------+---------//--------+ Type=7 The record route option provides a means to record the route of an internet datagram. The option begins with the option type code. The second octet is the option length which includes the option type code and the length octet, the pointer octet, and length-3 octets of route data. The third octet is the pointer into the route data indicating the octet which begins the next area to store a route address. The pointer is relative to this option, and the smallest legal value for the pointer is 4.
const ( // IPv4OptionRouterAlertLength is the length of a Router Alert option. IPv4OptionRouterAlertLength = 4 // IPv4OptionRouterAlertValue is the only permissible value of the 16 bit // payload of the router alert option. IPv4OptionRouterAlertValue = 0 // IPv4OptionRouterAlertValueOffset is the offset for the value of a // RouterAlert option. IPv4OptionRouterAlertValueOffset = 2 )
Router Alert option specific related constants.
from RFC 2113 section 2.1:
+--------+--------+--------+--------+ |10010100|00000100| 2 octet value | +--------+--------+--------+--------+ Type: Copied flag: 1 (all fragments must carry the option) Option class: 0 (control) Option number: 20 (decimal) Length: 4 Value: A two octet code with the following values: 0 - Router shall examine packet 1-65535 - Reserved
const ( // IPv6PayloadLenOffset is the offset of the PayloadLength field in // IPv6 header. IPv6PayloadLenOffset = 4 // IPv6NextHeaderOffset is the offset of the NextHeader field in // IPv6 header. IPv6NextHeaderOffset = 6 // IPv6FixedHeaderSize is the size of the fixed header. IPv6FixedHeaderSize = v6DstAddr + IPv6AddressSize )
const ( // IPv6MinimumSize is the minimum size of a valid IPv6 packet. IPv6MinimumSize = IPv6FixedHeaderSize // IPv6AddressSize is the size, in bytes, of an IPv6 address. IPv6AddressSize = 16 // IPv6MaximumPayloadSize is the maximum size of a valid IPv6 payload per // RFC 8200 Section 4.5. IPv6MaximumPayloadSize = 65535 // IPv6ProtocolNumber is IPv6's network protocol number. IPv6ProtocolNumber tcpip.NetworkProtocolNumber = 0x86dd // IPv6Version is the version of the ipv6 protocol. IPv6Version = 6 // IPv6AllNodesMulticastAddress is a link-local multicast group that // all IPv6 nodes MUST join, as per RFC 4291, section 2.8. Packets // destined to this address will reach all nodes on a link. // // The address is ff02::1. IPv6AllNodesMulticastAddress tcpip.Address = "\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01" // IPv6AllRoutersInterfaceLocalMulticastAddress is an interface-local // multicast group that all IPv6 routers MUST join, as per RFC 4291, section // 2.8. Packets destined to this address will reach the router on an // interface. // // The address is ff01::2. IPv6AllRoutersInterfaceLocalMulticastAddress tcpip.Address = "\xff\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02" // IPv6AllRoutersLinkLocalMulticastAddress is a link-local multicast group // that all IPv6 routers MUST join, as per RFC 4291, section 2.8. Packets // destined to this address will reach all routers on a link. // // The address is ff02::2. IPv6AllRoutersLinkLocalMulticastAddress tcpip.Address = "\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02" // IPv6AllRoutersSiteLocalMulticastAddress is a site-local multicast group // that all IPv6 routers MUST join, as per RFC 4291, section 2.8. Packets // destined to this address will reach all routers in a site. // // The address is ff05::2. IPv6AllRoutersSiteLocalMulticastAddress tcpip.Address = "\xff\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02" // IPv6MinimumMTU is the minimum MTU required by IPv6, per RFC 8200, // section 5: // IPv6 requires that every link in the Internet have an MTU of 1280 octets // or greater. This is known as the IPv6 minimum link MTU. IPv6MinimumMTU = 1280 // IPv6Loopback is the IPv6 Loopback address. IPv6Loopback tcpip.Address = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01" // IPv6Any is the non-routable IPv6 "any" meta address. It is also // known as the unspecified address. IPv6Any tcpip.Address = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // IIDSize is the size of an interface identifier (IID), in bytes, as // defined by RFC 4291 section 2.5.1. IIDSize = 8 // IIDOffsetInIPv6Address is the offset, in bytes, from the start // of an IPv6 address to the beginning of the interface identifier // (IID) for auto-generated addresses. That is, all bytes before // the IIDOffsetInIPv6Address-th byte are the prefix bytes, and all // bytes including and after the IIDOffsetInIPv6Address-th byte are // for the IID. IIDOffsetInIPv6Address = 8 // OpaqueIIDSecretKeyMinBytes is the recommended minimum number of bytes // for the secret key used to generate an opaque interface identifier as // outlined by RFC 7217. OpaqueIIDSecretKeyMinBytes = 16 )
const ( IPv6Reserved0MulticastScope = IPv6MulticastScope(0x0) IPv6InterfaceLocalMulticastScope = IPv6MulticastScope(0x1) IPv6LinkLocalMulticastScope = IPv6MulticastScope(0x2) IPv6RealmLocalMulticastScope = IPv6MulticastScope(0x3) IPv6AdminLocalMulticastScope = IPv6MulticastScope(0x4) IPv6SiteLocalMulticastScope = IPv6MulticastScope(0x5) IPv6OrganizationLocalMulticastScope = IPv6MulticastScope(0x8) IPv6GlobalMulticastScope = IPv6MulticastScope(0xE) IPv6ReservedFMulticastScope = IPv6MulticastScope(0xF) )
The various values for IPv6 multicast scopes, as per RFC 7346 section 2:
+------+--------------------------+-------------------------+ | scop | NAME | REFERENCE | +------+--------------------------+-------------------------+ | 0 | Reserved | [RFC4291], RFC 7346 | | 1 | Interface-Local scope | [RFC4291], RFC 7346 | | 2 | Link-Local scope | [RFC4291], RFC 7346 | | 3 | Realm-Local scope | [RFC4291], RFC 7346 | | 4 | Admin-Local scope | [RFC4291], RFC 7346 | | 5 | Site-Local scope | [RFC4291], RFC 7346 | | 6 | Unassigned | | | 7 | Unassigned | | | 8 | Organization-Local scope | [RFC4291], RFC 7346 | | 9 | Unassigned | | | A | Unassigned | | | B | Unassigned | | | C | Unassigned | | | D | Unassigned | | | E | Global scope | [RFC4291], RFC 7346 | | F | Reserved | [RFC4291], RFC 7346 | +------+--------------------------+-------------------------+
const ( // IPv6FragmentExtHdrLength is the length of an IPv6 extension header, in // bytes. IPv6FragmentExtHdrLength = 8 // IPv6FragmentExtHdrFragmentOffsetBytesPerUnit is the unit size of a Fragment // extension header's Fragment Offset field. That is, given a Fragment Offset // of 2, the extension header is indiciating that the fragment's payload // starts at the 16th byte in the reassembled packet. IPv6FragmentExtHdrFragmentOffsetBytesPerUnit = 8 )
const ( // IPv6FragmentHeader header is the number used to specify that the next // header is a fragment header, per RFC 2460. IPv6FragmentHeader = 44 // IPv6FragmentHeaderSize is the size of the fragment header. IPv6FragmentHeaderSize = 8 )
const ( // MLDMinimumSize is the minimum size for an MLD message. MLDMinimumSize = 20 // MLDHopLimit is the Hop Limit for all IPv6 packets with an MLD message, as // per RFC 2710 section 3. MLDHopLimit = 1 )
const ( // NDPLinkLayerAddressSize is the size of a Source or Target Link Layer // Address option for an Ethernet address. NDPLinkLayerAddressSize = 8 // NDPInfiniteLifetime is a value that represents infinity for the // 4-byte lifetime fields found in various NDP options. Its value is // (2^32 - 1)s = 4294967295s. NDPInfiniteLifetime = time.Second * math.MaxUint32 )
const ( // HighRoutePreference indicates a high preference, as per // RFC 4191 section 2.1. HighRoutePreference NDPRoutePreference = 0b01 // MediumRoutePreference indicates a medium preference, as per // RFC 4191 section 2.1. // // This is the default preference value. MediumRoutePreference = 0b00 // LowRoutePreference indicates a low preference, as per // RFC 4191 section 2.1. LowRoutePreference = 0b11 // ReservedRoutePreference is a reserved preference value, as per // RFC 4191 section 2.1. // // It MUST NOT be sent. ReservedRoutePreference = 0b10 )
const ( TCPSrcPortOffset = 0 TCPDstPortOffset = 2 TCPSeqNumOffset = 4 TCPAckNumOffset = 8 TCPDataOffset = 12 TCPFlagsOffset = 13 TCPWinSizeOffset = 14 TCPChecksumOffset = 16 TCPUrgentPtrOffset = 18 )
These constants are the offsets of the respective fields in the TCP header.
const ( // MaxWndScale is maximum allowed window scaling, as described in // RFC 1323, section 2.3, page 11. MaxWndScale = 14 // TCPMaxSACKBlocks is the maximum number of SACK blocks that can // be encoded in a TCP option field. TCPMaxSACKBlocks = 4 )
const ( TCPOptionEOL = 0 TCPOptionNOP = 1 TCPOptionMSS = 2 TCPOptionWS = 3 TCPOptionTS = 8 TCPOptionSACKPermitted = 4 TCPOptionSACK = 5 )
Options that may be present in a TCP segment.
const ( TCPOptionMSSLength = 4 TCPOptionTSLength = 10 TCPOptionWSLength = 3 TCPOptionSackPermittedLength = 2 )
Option Lengths.
const ( // TCPMinimumSize is the minimum size of a valid TCP packet. TCPMinimumSize = 20 // TCPOptionsMaximumSize is the maximum size of TCP options. TCPOptionsMaximumSize = 40 // TCPHeaderMaximumSize is the maximum header size of a TCP packet. TCPHeaderMaximumSize = TCPMinimumSize + TCPOptionsMaximumSize // TCPProtocolNumber is TCP's transport protocol number. TCPProtocolNumber tcpip.TransportProtocolNumber = 6 // TCPMinimumMSS is the minimum acceptable value for MSS. This is the // same as the value TCP_MIN_MSS defined net/tcp.h. TCPMinimumMSS = IPv4MaximumHeaderSize + TCPHeaderMaximumSize + MinIPFragmentPayloadSize - IPv4MinimumSize - TCPMinimumSize // TCPMaximumMSS is the maximum acceptable value for MSS. TCPMaximumMSS = 0xffff // TCPDefaultMSS is the MSS value that should be used if an MSS option // is not received from the peer. It's also the value returned by // TCP_MAXSEG option for a socket in an unconnected state. // // Per RFC 1122, page 85: "If an MSS option is not received at // connection setup, TCP MUST assume a default send MSS of 536." TCPDefaultMSS = 536 )
const ( // UDPMinimumSize is the minimum size of a valid UDP packet. UDPMinimumSize = 8 // UDPMaximumSize is the maximum size of a valid UDP packet. The length field // in the UDP header is 16 bits as per RFC 768. UDPMaximumSize = math.MaxUint16 // UDPProtocolNumber is UDP's transport protocol number. UDPProtocolNumber tcpip.TransportProtocolNumber = 17 )
const (
// GUEMinimumSize is the minimum size of a valid GUE packet.
GUEMinimumSize = 4
)
const (
IPv4IHLStride = 4
)
RFC 791 page 11 shows the header length (IHL) is in the lower 4 bits of the first byte, and is counted in multiples of 4 bytes.
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Version| IHL |Type of Service| Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ (...) Version: 4 bits The Version field indicates the format of the internet header. This document describes version 4. IHL: 4 bits Internet Header Length is the length of the internet header in 32 bit words, and thus points to the beginning of the data. Note that the minimum value for a correct header is 5.
const ( // IPv4TotalLenOffset is the offset of the total length field in the // IPv4 header. IPv4TotalLenOffset = 2 )
RFC 971 defines the fields of the IPv4 header on page 11 using the following diagram: ("Figure 4")
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Version| IHL |Type of Service| Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Identification |Flags| Fragment Offset | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Time to Live | Protocol | Header Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Destination Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Options | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
const ( // MaxIPPacketSize is the maximum supported IP packet size, excluding // jumbograms. The maximum IPv4 packet size is 64k-1 (total size must fit // in 16 bits). For IPv6, the payload max size (excluding jumbograms) is // 64k-1 (also needs to fit in 16 bits). So we use 64k - 1 + 2 * m, where // m is the minimum IPv6 header size; we leave room for some potential // IP options. MaxIPPacketSize = 0xffff + 2*IPv6MinimumSize )
const ( // NDPNAMinimumSize is the minimum size of a valid NDP Neighbor // Advertisement message (body of an ICMPv6 packet). NDPNAMinimumSize = 20 )
const ( // NDPNSMinimumSize is the minimum size of a valid NDP Neighbor // Solicitation message (body of an ICMPv6 packet). NDPNSMinimumSize = 20 )
const ( // NDPRAMinimumSize is the minimum size of a valid NDP Router // Advertisement message (body of an ICMPv6 packet). NDPRAMinimumSize = 12 )
As per RFC 4191 section 2.2,
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Code | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Cur Hop Limit |M|O|H|Prf|Resvd| Router Lifetime | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reachable Time | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Retrans Timer | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Options ... +-+-+-+-+-+-+-+-+-+-+-+-
const ( // NDPRSMinimumSize is the minimum size of a valid NDP Router // Solicitation message (body of an ICMPv6 packet). NDPRSMinimumSize = 4 )
const (
// UDPMaximumPacketSize is the largest possible UDP packet.
UDPMaximumPacketSize = 0xffff
)
const (
// VirtioNetHeaderSize is the size of VirtioNetHeader in bytes.
VirtioNetHeaderSize = 10
)
Variables ¶
var ( ErrNDPOptMalformedBody = errors.New("NDP option has a malformed body") ErrNDPOptMalformedHeader = errors.New("NDP option has a malformed header") )
Potential errors when iterating over an NDPOptions.
var ErrMalformedIPv6ExtHdrOption = errors.New("malformed IPv6 extension header option")
ErrMalformedIPv6ExtHdrOption indicates that an IPv6 extension header option is malformed.
var Ethertypes = []tcpip.NetworkProtocolNumber{ EthernetProtocolAll, EthernetProtocolPUP, }
Ethertypes holds the protocol numbers describing the payload of an ethernet frame. These types aren't necessarily supported by netstack, but can be used to catch all traffic of a type via packet endpoints.
var IPv4EmptySubnet = func() tcpip.Subnet { subnet, err := tcpip.NewSubnet(IPv4Any, tcpip.AddressMask(IPv4Any)) if err != nil { panic(err) } return subnet }()
IPv4EmptySubnet is the empty IPv4 subnet.
var IPv4LoopbackSubnet = func() tcpip.Subnet { subnet, err := tcpip.NewSubnet(tcpip.Address("\x7f\x00\x00\x00"), tcpip.AddressMask("\xff\x00\x00\x00")) if err != nil { panic(err) } return subnet }()
IPv4LoopbackSubnet is the loopback subnet for IPv4.
var IPv4MappedIPv6Subnet = tcpip.AddressWithPrefix{
Address: "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00",
PrefixLen: 96,
}.Subnet()
IPv4MappedIPv6Subnet is the prefix for an IPv4 mapped IPv6 address as defined by RFC 4291 section 2.5.5.
var IPv6EmptySubnet = tcpip.AddressWithPrefix{ Address: IPv6Any, PrefixLen: 0, }.Subnet()
IPv6EmptySubnet is the empty IPv6 subnet. It may also be known as the catch-all or wildcard subnet. That is, all IPv6 addresses are considered to be contained within this subnet.
var IPv6LinkLocalPrefix = tcpip.AddressWithPrefix{
Address: "\xfe\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
PrefixLen: 64,
}
IPv6LinkLocalPrefix is the prefix for IPv6 link-local addresses, as defined by RFC 4291 section 2.5.6.
The prefix is fe80::/64
Functions ¶
func Acceptable ¶
Acceptable checks if a segment that starts at segSeq and has length segLen is "acceptable" for arriving in a receive window that starts at rcvNxt and ends before rcvAcc, according to the table on page 26 and 69 of RFC 793.
func AddTCPOptionPadding ¶
AddTCPOptionPadding adds the required number of TCPOptionNOP to quad align the option buffer. It adds padding bytes after the offset specified and returns the number of padding bytes added. The passed in options slice must have space for the padding bytes.
func AppendOpaqueInterfaceIdentifier ¶
func AppendOpaqueInterfaceIdentifier(buf []byte, prefix tcpip.Subnet, nicName string, dadCounter uint8, secretKey []byte) []byte
AppendOpaqueInterfaceIdentifier appends a 64 bit opaque interface identifier (IID) to buf as outlined by RFC 7217 and returns the extended buffer.
The opaque IID is generated from the cryptographic hash of the concatenation of the prefix, NIC's name, DAD counter (DAD retry counter) and the secret key. The secret key SHOULD be at least OpaqueIIDSecretKeyMinBytes bytes and MUST be generated to a pseudo-random number. See RFC 4086 for randomness requirements for security.
If buf has enough capacity for the IID (IIDSize bytes), a new underlying array for the buffer will not be allocated.
func Checksum ¶
Checksum calculates the checksum (as defined in RFC 1071) of the bytes in the given byte array. This function uses an optimized unrolled version of the checksum algorithm.
The initial checksum must have been computed on an even number of bytes.
func ChecksumCombine ¶
ChecksumCombine combines the two uint16 to form their checksum. This is done by adding them and the carry.
Note that checksum a must have been computed on an even number of bytes.
func ChecksumOld ¶
ChecksumOld calculates the checksum (as defined in RFC 1071) of the bytes in the given byte array. This function uses a non-optimized implementation. Its only retained for reference and to use as a benchmark/test. Most code should use the header.Checksum function.
The initial checksum must have been computed on an even number of bytes.
func ChecksumVV ¶
func ChecksumVV(vv buffer.VectorisedView, initial uint16) uint16
ChecksumVV calculates the checksum (as defined in RFC 1071) of the bytes in the given VectorizedView.
The initial checksum must have been computed on an even number of bytes.
func DecisecondToDuration ¶
DecisecondToDuration converts a value representing deci-seconds to a time.Duration.
func EncodeMSSOption ¶
EncodeMSSOption encodes the MSS TCP option with the provided MSS values in the supplied buffer. If the provided buffer is not large enough then it just returns without encoding anything. It returns the number of bytes written to the provided buffer.
func EncodeSACKBlocks ¶
EncodeSACKBlocks encodes the provided SACK blocks as a TCP SACK option block in the provided slice. It tries to fit in as many blocks as possible based on number of bytes available in the provided buffer. It returns the number of bytes written to the provided buffer.
func EncodeSACKPermittedOption ¶
EncodeSACKPermittedOption encodes a SACKPermitted option into the provided buffer. If the buffer is smaller than required it just returns without encoding anything. It returns the number of bytes written to the provided buffer.
func EncodeTSOption ¶
EncodeTSOption encodes the provided tsVal and tsEcr values as a TCP timestamp option into the provided buffer. If the buffer is smaller than expected it just returns without encoding anything. It returns the number of bytes written to the provided buffer.
func EncodeWSOption ¶
EncodeWSOption encodes the WS TCP option with the WS value in the provided buffer. If the provided buffer is not large enough then it just returns without encoding anything. It returns the number of bytes written to the provided buffer.
func EthernetAdddressToModifiedEUI64IntoBuf ¶
func EthernetAdddressToModifiedEUI64IntoBuf(linkAddr tcpip.LinkAddress, buf []byte)
EthernetAdddressToModifiedEUI64IntoBuf populates buf with a modified EUI-64 from a 48-bit Ethernet/MAC address, as per RFC 4291 section 2.5.1.
buf MUST be at least 8 bytes.
func EthernetAddressFromMulticastIPv4Address ¶
func EthernetAddressFromMulticastIPv4Address(addr tcpip.Address) tcpip.LinkAddress
EthernetAddressFromMulticastIPv4Address returns a multicast Ethernet address for a multicast IPv4 address.
addr MUST be a multicast IPv4 address.
func EthernetAddressFromMulticastIPv6Address ¶
func EthernetAddressFromMulticastIPv6Address(addr tcpip.Address) tcpip.LinkAddress
EthernetAddressFromMulticastIPv6Address returns a multicast Ethernet address for a multicast IPv6 address.
addr MUST be a multicast IPv6 address.
func EthernetAddressToModifiedEUI64 ¶
func EthernetAddressToModifiedEUI64(linkAddr tcpip.LinkAddress) [IIDSize]byte
EthernetAddressToModifiedEUI64 computes a modified EUI-64 from a 48-bit Ethernet/MAC address, as per RFC 4291 section 2.5.1.
func GenerateTempIPv6SLAACAddr ¶
func GenerateTempIPv6SLAACAddr(tempIIDHistory []byte, stableAddr tcpip.Address) tcpip.AddressWithPrefix
GenerateTempIPv6SLAACAddr generates a temporary SLAAC IPv6 address for an associated stable/permanent SLAAC address.
GenerateTempIPv6SLAACAddr will update the temporary IID history value to be used when generating a new temporary IID.
Panics if tempIIDHistory is not at least IIDSize bytes.
func ICMPv4Checksum ¶
ICMPv4Checksum calculates the ICMP checksum over the provided ICMP header, and payload.
func ICMPv6Checksum ¶
func ICMPv6Checksum(params ICMPv6ChecksumParams) uint16
ICMPv6Checksum calculates the ICMP checksum over the provided ICMPv6 header, IPv6 src/dst addresses and the payload.
func IGMPCalculateChecksum ¶
IGMPCalculateChecksum calculates the IGMP checksum over the provided IGMP header.
func IPVersion ¶
IPVersion returns the version of IP used in the given packet. It returns -1 if the packet is not large enough to contain the version field.
func InitialTempIID ¶
InitialTempIID generates the initial temporary IID history value to generate temporary SLAAC addresses with.
Panics if initialTempIIDHistory is not at least IIDSize bytes.
func IsMulticastEthernetAddress ¶
func IsMulticastEthernetAddress(addr tcpip.LinkAddress) bool
IsMulticastEthernetAddress returns true if the address is a multicast ethernet address.
func IsSolicitedNodeAddr ¶
IsSolicitedNodeAddr determines whether the address is a solicited-node multicast address.
func IsV4LinkLocalMulticastAddress ¶
IsV4LinkLocalMulticastAddress determines if the provided address is an IPv4 link-local multicast address.
func IsV4LinkLocalUnicastAddress ¶
IsV4LinkLocalUnicastAddress determines if the provided address is an IPv4 link-local unicast address.
func IsV4LoopbackAddress ¶
IsV4LoopbackAddress determines if the provided address is an IPv4 loopback address (belongs to 127.0.0.0/8 subnet). See RFC 1122 section 3.2.1.3.
func IsV4MappedAddress ¶
IsV4MappedAddress determines if the provided address is an IPv4 mapped address by checking if its prefix is 0:0:0:0:0:ffff::/96.
func IsV4MulticastAddress ¶
IsV4MulticastAddress determines if the provided address is an IPv4 multicast address (range 224.0.0.0 to 239.255.255.255). The four most significant bits will be 1110 = 0xe0.
func IsV6LinkLocalMulticastAddress ¶
IsV6LinkLocalMulticastAddress returns true iff the provided address is an IPv6 link-local multicast address, as defined by RFC 4291 section 2.7.
func IsV6LinkLocalUnicastAddress ¶
IsV6LinkLocalUnicastAddress returns true iff the provided address is an IPv6 link-local unicast address, as defined by RFC 4291 section 2.5.6.
func IsV6LoopbackAddress ¶
IsV6LoopbackAddress returns true iff the provided address is an IPv6 loopback address, as defined by RFC 4291 section 2.5.3.
func IsV6MulticastAddress ¶
IsV6MulticastAddress determines if the provided address is an IPv6 multicast address (anything starting with FF).
func IsV6UnicastAddress ¶
IsV6UnicastAddress determines if the provided address is a valid IPv6 unicast (and specified) address. That is, IsV6UnicastAddress returns true if addr contains IPv6AddressSize bytes, is not the unspecified address and is not a multicast address.
func IsValidUnicastEthernetAddress ¶
func IsValidUnicastEthernetAddress(addr tcpip.LinkAddress) bool
IsValidUnicastEthernetAddress returns true if the address is a unicast ethernet address.
func LinkLocalAddr ¶
func LinkLocalAddr(linkAddr tcpip.LinkAddress) tcpip.Address
LinkLocalAddr computes the default IPv6 link-local address from a link-layer (MAC) address.
func LinkLocalAddrWithOpaqueIID ¶
LinkLocalAddrWithOpaqueIID computes the default IPv6 link-local address with an opaque IID.
func PseudoHeaderChecksum ¶
func PseudoHeaderChecksum(protocol tcpip.TransportProtocolNumber, srcAddr tcpip.Address, dstAddr tcpip.Address, totalLen uint16) uint16
PseudoHeaderChecksum calculates the pseudo-header checksum for the given destination protocol and network address. Pseudo-headers are needed by transport layers when calculating their own checksum.
func PutChecksum ¶
PutChecksum puts the checksum in the provided byte slice.
Types ¶
type ARP ¶
type ARP []byte
ARP is an ARP packet stored in a byte array as described in RFC 826.
func (ARP) HardwareAddressSender ¶
HardwareAddressSender is the link address of the sender. It is a view on to the ARP packet so it can be used to set the value.
func (ARP) HardwareAddressTarget ¶
HardwareAddressTarget is the link address of the target. It is a view on to the ARP packet so it can be used to set the value.
func (ARP) ProtocolAddressSender ¶
ProtocolAddressSender is the protocol address of the sender. It is a view on to the ARP packet so it can be used to set the value.
func (ARP) ProtocolAddressTarget ¶
ProtocolAddressTarget is the protocol address of the target. It is a view on to the ARP packet so it can be used to set the value.
func (ARP) SetIPv4OverEthernet ¶
func (a ARP) SetIPv4OverEthernet()
SetIPv4OverEthernet configures the ARP packet for IPv4-over-Ethernet.
type ARPHardwareType ¶
type ARPHardwareType uint16
ARPHardwareType is the hardware type for LinkEndpoint in an ARP header.
const ( ARPHardwareNone ARPHardwareType = 0 // ARPHardwareEther specifically is the HTYPE for Ethernet as specified // in the IANA list here: // // https://www.iana.org/assignments/arp-parameters/arp-parameters.xhtml#arp-parameters-2 ARPHardwareEther ARPHardwareType = 1 ARPHardwareLoopback ARPHardwareType = 2 )
Typical ARP HardwareType values. Some of the constants have to be specific values as they are egressed on the wire in the HTYPE field of an ARP header.
type Checksumer ¶
type Checksumer struct {
// contains filtered or unexported fields
}
Checksumer calculates checksum defined in RFC 1071.
func (*Checksumer) Checksum ¶
func (c *Checksumer) Checksum() uint16
Checksum returns the latest checksum value.
type ChecksummableNetwork ¶
type ChecksummableNetwork interface { Network // SetSourceAddressAndChecksum sets the source address and updates the // checksum to reflect the new address. SetSourceAddressWithChecksumUpdate(tcpip.Address) // SetDestinationAddressAndChecksum sets the destination address and // updates the checksum to reflect the new address. SetDestinationAddressWithChecksumUpdate(tcpip.Address) }
ChecksummableNetwork is a Network that supports checksumming.
type ChecksummableTransport ¶
type ChecksummableTransport interface { Transport // SetSourcePortWithChecksumUpdate sets the source port and updates // the checksum. // // The receiver's checksum must be a fully calculated checksum. SetSourcePortWithChecksumUpdate(port uint16) // SetDestinationPortWithChecksumUpdate sets the destination port and updates // the checksum. // // The receiver's checksum must be a fully calculated checksum. SetDestinationPortWithChecksumUpdate(port uint16) // UpdateChecksumPseudoHeaderAddress updates the checksum to reflect an // updated address in the pseudo header. // // If fullChecksum is true, the receiver's checksum field is assumed to hold a // fully calculated checksum. Otherwise, it is assumed to hold a partially // calculated checksum which only reflects the pseudo header. UpdateChecksumPseudoHeaderAddress(old, new tcpip.Address, fullChecksum bool) }
ChecksummableTransport is a Transport that supports checksumming.
type Ethernet ¶
type Ethernet []byte
Ethernet represents an ethernet frame header stored in a byte array.
func (Ethernet) DestinationAddress ¶
func (b Ethernet) DestinationAddress() tcpip.LinkAddress
DestinationAddress returns the "MAC destination" field of the ethernet frame header.
func (Ethernet) Encode ¶
func (b Ethernet) Encode(e *EthernetFields)
Encode encodes all the fields of the ethernet frame header.
func (Ethernet) SourceAddress ¶
func (b Ethernet) SourceAddress() tcpip.LinkAddress
SourceAddress returns the "MAC source" field of the ethernet frame header.
func (Ethernet) Type ¶
func (b Ethernet) Type() tcpip.NetworkProtocolNumber
Type returns the "ethertype" field of the ethernet frame header.
type EthernetFields ¶
type EthernetFields struct { // SrcAddr is the "MAC source" field of an ethernet frame header. SrcAddr tcpip.LinkAddress // DstAddr is the "MAC destination" field of an ethernet frame header. DstAddr tcpip.LinkAddress // Type is the "ethertype" field of an ethernet frame header. Type tcpip.NetworkProtocolNumber }
EthernetFields contains the fields of an ethernet frame header. It is used to describe the fields of a frame that needs to be encoded.
type GUE ¶
type GUE []byte
GUE represents a Generic UDP Encapsulation header stored in a byte array, the fields are described in https://tools.ietf.org/html/draft-ietf-nvo3-gue-01.
func (GUE) HeaderLength ¶
HeaderLength returns the total length of the GUE header.
func (GUE) TypeAndControl ¶
TypeAndControl returns the GUE packet type (top 3 bits of the first byte, which includes the control bit).
type GUEFields ¶
type GUEFields struct { // Type is the "type" field of the GUE header. Type uint8 // Control is the "control" field of the GUE header. Control bool // HeaderLength is the "header length" field of the GUE header. It must // be at least 4 octets, and a multiple of 4 as well. HeaderLength uint8 // Protocol is the "protocol" field of the GUE header. This is one of // the IPPROTO_* values. Protocol uint8 }
GUEFields contains the fields of a GUE packet. It is used to describe the fields of a packet that needs to be encoded.
type ICMPv4 ¶
type ICMPv4 []byte
ICMPv4 represents an ICMPv4 header stored in a byte array.
func (ICMPv4) Code ¶
func (b ICMPv4) Code() ICMPv4Code
Code is the ICMP code field. Its meaning depends on the value of Type.
func (ICMPv4) DestinationPort ¶
DestinationPort implements Transport.DestinationPort.
func (ICMPv4) SetChecksum ¶
SetChecksum sets the ICMP checksum field.
func (ICMPv4) SetDestinationPort ¶
SetDestinationPort implements Transport.SetDestinationPort.
func (ICMPv4) SetIdentWithChecksumUpdate ¶
SetIdentWithChecksumUpdate sets the Ident field and updates the checksum.
func (ICMPv4) SetPointer ¶
SetPointer sets the pointer field in a Parameter Problem packet.
func (ICMPv4) SetSequence ¶
SetSequence sets the Sequence field from an ICMPv4 message.
func (ICMPv4) SetSourcePort ¶
SetSourcePort implements Transport.SetSourcePort.
func (ICMPv4) SourcePort ¶
SourcePort implements Transport.SourcePort.
type ICMPv4Code ¶
type ICMPv4Code byte
ICMPv4Code is the ICMP code field described in RFC 792.
const ( ICMPv4TTLExceeded ICMPv4Code = 0 ICMPv4ReassemblyTimeout ICMPv4Code = 1 )
ICMP codes for ICMPv4 Time Exceeded messages as defined in RFC 792.
const ( ICMPv4NetUnreachable ICMPv4Code = 0 ICMPv4HostUnreachable ICMPv4Code = 1 ICMPv4ProtoUnreachable ICMPv4Code = 2 ICMPv4PortUnreachable ICMPv4Code = 3 ICMPv4FragmentationNeeded ICMPv4Code = 4 )
ICMP codes for ICMPv4 Destination Unreachable messages as defined in RFC 792.
const ICMPv4UnusedCode ICMPv4Code = 0
ICMPv4UnusedCode is a code to use in ICMP messages where no code is needed.
type ICMPv4Type ¶
type ICMPv4Type byte
ICMPv4Type is the ICMP type field described in RFC 792.
const ( ICMPv4EchoReply ICMPv4Type = 0 ICMPv4DstUnreachable ICMPv4Type = 3 ICMPv4SrcQuench ICMPv4Type = 4 ICMPv4Redirect ICMPv4Type = 5 ICMPv4Echo ICMPv4Type = 8 ICMPv4TimeExceeded ICMPv4Type = 11 ICMPv4ParamProblem ICMPv4Type = 12 ICMPv4Timestamp ICMPv4Type = 13 ICMPv4TimestampReply ICMPv4Type = 14 ICMPv4InfoRequest ICMPv4Type = 15 ICMPv4InfoReply ICMPv4Type = 16 )
Typical values of ICMPv4Type defined in RFC 792.
type ICMPv6 ¶
type ICMPv6 []byte
ICMPv6 represents an ICMPv6 header stored in a byte array.
func (ICMPv6) Code ¶
func (b ICMPv6) Code() ICMPv6Code
Code is the ICMP code field. Its meaning depends on the value of Type.
func (ICMPv6) DestinationPort ¶
DestinationPort implements Transport.DestinationPort.
func (ICMPv6) MessageBody ¶
MessageBody returns the message body as defined by RFC 4443 section 2.1; the portion of the ICMPv6 buffer after the first ICMPv6HeaderSize bytes.
func (ICMPv6) SetChecksum ¶
SetChecksum sets the ICMP checksum field.
func (ICMPv6) SetDestinationPort ¶
SetDestinationPort implements Transport.SetDestinationPort.
func (ICMPv6) SetIdentWithChecksumUpdate ¶
SetIdentWithChecksumUpdate sets the Ident field and updates the checksum.
func (ICMPv6) SetSequence ¶
SetSequence sets the Sequence field from an ICMPv6 message.
func (ICMPv6) SetSourcePort ¶
SetSourcePort implements Transport.SetSourcePort.
func (ICMPv6) SetTypeSpecific ¶
SetTypeSpecific sets the type specific data field.
func (ICMPv6) SourcePort ¶
SourcePort implements Transport.SourcePort.
func (ICMPv6) TypeSpecific ¶
TypeSpecific returns the type specific data field.
func (ICMPv6) UpdateChecksumPseudoHeaderAddress ¶
UpdateChecksumPseudoHeaderAddress updates the checksum to reflect an updated address in the pseudo header.
type ICMPv6ChecksumParams ¶
type ICMPv6ChecksumParams struct { Header ICMPv6 Src tcpip.Address Dst tcpip.Address PayloadCsum uint16 PayloadLen int }
ICMPv6ChecksumParams contains parameters to calculate ICMPv6 checksum.
type ICMPv6Code ¶
type ICMPv6Code byte
ICMPv6Code is the ICMP Code field described in RFC 4443.
const ( ICMPv6NetworkUnreachable ICMPv6Code = 0 ICMPv6Prohibited ICMPv6Code = 1 ICMPv6BeyondScope ICMPv6Code = 2 ICMPv6AddressUnreachable ICMPv6Code = 3 ICMPv6PortUnreachable ICMPv6Code = 4 ICMPv6Policy ICMPv6Code = 5 ICMPv6RejectRoute ICMPv6Code = 6 )
ICMP codes used with Destination Unreachable (Type 1). As per RFC 4443 section 3.1.
const ( ICMPv6HopLimitExceeded ICMPv6Code = 0 ICMPv6ReassemblyTimeout ICMPv6Code = 1 )
ICMP codes used with Time Exceeded (Type 3). As per RFC 4443 section 3.3.
const ( // ICMPv6ErroneousHeader indicates an erroneous header field was encountered. ICMPv6ErroneousHeader ICMPv6Code = 0 // ICMPv6UnknownHeader indicates an unrecognized Next Header type encountered. ICMPv6UnknownHeader ICMPv6Code = 1 // ICMPv6UnknownOption indicates an unrecognized IPv6 option was encountered. ICMPv6UnknownOption ICMPv6Code = 2 )
ICMP codes used with Parameter Problem (Type 4). As per RFC 4443 section 3.4.
const ICMPv6UnusedCode ICMPv6Code = 0
ICMPv6UnusedCode is the code value used with ICMPv6 messages which don't use the code field. (Types not mentioned above.)
type ICMPv6Type ¶
type ICMPv6Type byte
ICMPv6Type is the ICMP type field described in RFC 4443.
const ( ICMPv6DstUnreachable ICMPv6Type = 1 ICMPv6PacketTooBig ICMPv6Type = 2 ICMPv6TimeExceeded ICMPv6Type = 3 ICMPv6ParamProblem ICMPv6Type = 4 ICMPv6EchoRequest ICMPv6Type = 128 ICMPv6EchoReply ICMPv6Type = 129 ICMPv6RouterSolicit ICMPv6Type = 133 ICMPv6RouterAdvert ICMPv6Type = 134 ICMPv6NeighborSolicit ICMPv6Type = 135 ICMPv6NeighborAdvert ICMPv6Type = 136 ICMPv6RedirectMsg ICMPv6Type = 137 ICMPv6MulticastListenerQuery ICMPv6Type = 130 ICMPv6MulticastListenerReport ICMPv6Type = 131 ICMPv6MulticastListenerDone ICMPv6Type = 132 )
Values for use in the Type field of ICMPv6 packet from RFC 4433.
func (ICMPv6Type) IsErrorType ¶
func (typ ICMPv6Type) IsErrorType() bool
IsErrorType returns true if the receiver is an ICMP error type.
type IGMP ¶
type IGMP []byte
IGMP represents an IGMP header stored in a byte array.
func (IGMP) DestinationPort ¶
DestinationPort implements Transport.DestinationPort.
func (IGMP) GroupAddress ¶
GroupAddress gets the Group Address field.
func (IGMP) MaxRespTime ¶
MaxRespTime gets the MaxRespTimeField. This is meaningful only in Membership Query messages, in other cases it is set to 0 by the sender and ignored by the receiver.
func (IGMP) SetChecksum ¶
SetChecksum sets the IGMP checksum field.
func (IGMP) SetDestinationPort ¶
SetDestinationPort implements Transport.SetDestinationPort.
func (IGMP) SetGroupAddress ¶
SetGroupAddress sets the Group Address field.
func (IGMP) SetMaxRespTime ¶
SetMaxRespTime sets the MaxRespTimeField.
func (IGMP) SetSourcePort ¶
SetSourcePort implements Transport.SetSourcePort.
func (IGMP) SourcePort ¶
SourcePort implements Transport.SourcePort.
type IGMPType ¶
type IGMPType byte
IGMPType is the IGMP type field as per RFC 2236.
const ( // IGMPMembershipQuery indicates that the message type is Membership Query. // "There are two sub-types of Membership Query messages: // - General Query, used to learn which groups have members on an // attached network. // - Group-Specific Query, used to learn if a particular group // has any members on an attached network. // These two messages are differentiated by the Group Address, as // described in section 1.4 ." IGMPMembershipQuery IGMPType = 0x11 // IGMPv1MembershipReport indicates that the message is a Membership Report // generated by a host using the IGMPv1 protocol: "an additional type of // message, for backwards-compatibility with IGMPv1" IGMPv1MembershipReport IGMPType = 0x12 // IGMPv2MembershipReport indicates that the Message type is a Membership // Report generated by a host using the IGMPv2 protocol. IGMPv2MembershipReport IGMPType = 0x16 // IGMPLeaveGroup indicates that the message type is a Leave Group // notification message. IGMPLeaveGroup IGMPType = 0x17 )
Values for the IGMP Type described in RFC 2236 Section 2.1, Page 2. Descriptions below come from there.
type IPv4 ¶
type IPv4 []byte
IPv4 is an IPv4 header. Most of the methods of IPv4 access to the underlying slice without checking the boundaries and could panic because of 'index out of range'. Always call IsValid() to validate an instance of IPv4 before using other methods.
func (IPv4) CalculateChecksum ¶
CalculateChecksum calculates the checksum of the IPv4 header.
func (IPv4) DestinationAddress ¶
DestinationAddress returns the "destination address" field of the IPv4 header.
func (IPv4) Encode ¶
func (b IPv4) Encode(i *IPv4Fields)
Encode encodes all the fields of the IPv4 header.
func (IPv4) EncodePartial ¶
EncodePartial updates the total length and checksum fields of IPv4 header, taking in the partial checksum, which is the checksum of the header without the total length and checksum fields. It is useful in cases when similar packets are produced.
func (IPv4) FragmentOffset ¶
FragmentOffset returns the "fragment offset" field of the IPv4 header.
func (IPv4) HeaderLength ¶
HeaderLength returns the value of the "header length" field of the IPv4 header. The length returned is in bytes.
func (IPv4) IsChecksumValid ¶
IsChecksumValid returns true iff the IPv4 header's checksum is valid.
func (IPv4) Options ¶
func (b IPv4) Options() IPv4Options
Options returns a buffer holding the options.
func (IPv4) PayloadLength ¶
PayloadLength returns the length of the payload portion of the IPv4 packet.
func (IPv4) SetChecksum ¶
SetChecksum sets the checksum field of the IPv4 header.
func (IPv4) SetDestinationAddress ¶
SetDestinationAddress sets the "destination address" field of the IPv4 header.
func (IPv4) SetDestinationAddressWithChecksumUpdate ¶
SetDestinationAddressWithChecksumUpdate implements ChecksummableNetwork.
func (IPv4) SetFlagsFragmentOffset ¶
SetFlagsFragmentOffset sets the "flags" and "fragment offset" fields of the IPv4 header.
func (IPv4) SetHeaderLength ¶
SetHeaderLength sets the value of the "Internet Header Length" field.
func (IPv4) SetSourceAddress ¶
SetSourceAddress sets the "source address" field of the IPv4 header.
func (IPv4) SetSourceAddressWithChecksumUpdate ¶
SetSourceAddressWithChecksumUpdate implements ChecksummableNetwork.
func (IPv4) SetTotalLength ¶
SetTotalLength sets the "total length" field of the IPv4 header.
func (IPv4) SourceAddress ¶
SourceAddress returns the "source address" field of the IPv4 header.
func (IPv4) TotalLength ¶
TotalLength returns the "total length" field of the IPv4 header.
func (IPv4) TransportProtocol ¶
func (b IPv4) TransportProtocol() tcpip.TransportProtocolNumber
TransportProtocol implements Network.TransportProtocol.
type IPv4Fields ¶
type IPv4Fields struct { // TOS is the "type of service" field of an IPv4 packet. TOS uint8 // TotalLength is the "total length" field of an IPv4 packet. TotalLength uint16 // ID is the "identification" field of an IPv4 packet. ID uint16 // Flags is the "flags" field of an IPv4 packet. Flags uint8 // FragmentOffset is the "fragment offset" field of an IPv4 packet. FragmentOffset uint16 // TTL is the "time to live" field of an IPv4 packet. TTL uint8 // Protocol is the "protocol" field of an IPv4 packet. Protocol uint8 // Checksum is the "checksum" field of an IPv4 packet. Checksum uint16 // SrcAddr is the "source ip address" of an IPv4 packet. SrcAddr tcpip.Address // DstAddr is the "destination ip address" of an IPv4 packet. DstAddr tcpip.Address // Options must be 40 bytes or less as they must fit along with the // rest of the IPv4 header into the maximum size describable in the // IHL field. RFC 791 section 3.1 says: // IHL: 4 bits // // Internet Header Length is the length of the internet header in 32 // bit words, and thus points to the beginning of the data. Note that // the minimum value for a correct header is 5. // // That leaves ten 32 bit (4 byte) fields for options. An attempt to encode // more will fail. Options IPv4OptionsSerializer }
IPv4Fields contains the fields of an IPv4 packet. It is used to describe the fields of a packet that needs to be encoded. The IHL field is not here as it is totally defined by the size of the options.
type IPv4OptParameterProblem ¶
IPv4OptParameterProblem indicates that a Parameter Problem message should be generated, and gives the offset in the current entity that should be used in that packet.
type IPv4OptTSFlags ¶
type IPv4OptTSFlags uint8
IPv4OptTSFlags sefines the values expected in the Timestamp option Flags field.
type IPv4Option ¶
type IPv4Option interface { // Type returns the type identifier of the option. Type() IPv4OptionType // Size returns the size of the option in bytes. Size() uint8 // Contents returns a slice holding the contents of the option. Contents() []byte }
IPv4Option is an interface representing various option types.
type IPv4OptionGeneric ¶
type IPv4OptionGeneric []byte
IPv4OptionGeneric is an IPv4 Option of unknown type.
func (*IPv4OptionGeneric) Contents ¶
func (o *IPv4OptionGeneric) Contents() []byte
Contents implements IPv4Option.
func (*IPv4OptionGeneric) Size ¶
func (o *IPv4OptionGeneric) Size() uint8
Size implements IPv4Option.
func (*IPv4OptionGeneric) Type ¶
func (o *IPv4OptionGeneric) Type() IPv4OptionType
Type implements IPv4Option.
type IPv4OptionIterator ¶
type IPv4OptionIterator struct { // ErrCursor is where we are while parsing options. It is exported as any // resulting ICMP packet is supposed to have a pointer to the byte within // the IP packet where the error was detected. ErrCursor uint8 // contains filtered or unexported fields }
IPv4OptionIterator is an iterator pointing to a specific IP option at any point of time. It also holds information as to a new options buffer that we are building up to hand back to the caller. TODO(https://gvisor.dev/issues/5513): Add unit tests for IPv4OptionIterator.
func (*IPv4OptionIterator) ConsumeBuffer ¶
func (i *IPv4OptionIterator) ConsumeBuffer(size int)
ConsumeBuffer marks a portion of the new buffer as used.
func (*IPv4OptionIterator) Finalize ¶
func (i *IPv4OptionIterator) Finalize() IPv4Options
Finalize returns the completed replacement options buffer padded as needed.
func (*IPv4OptionIterator) InitReplacement ¶
func (i *IPv4OptionIterator) InitReplacement(option IPv4Option) IPv4Options
InitReplacement copies the option into the new option buffer.
func (*IPv4OptionIterator) Next ¶
func (i *IPv4OptionIterator) Next() (IPv4Option, bool, *IPv4OptParameterProblem)
Next returns the next IP option in the buffer/list of IP options. It returns
- A slice of bytes holding the next option or nil if there is error.
- A boolean which is true if parsing of all the options is complete. Undefined in the case of error.
- An error indication which is non-nil if an error condition was found.
func (*IPv4OptionIterator) PushNOPOrEnd ¶
func (i *IPv4OptionIterator) PushNOPOrEnd(val IPv4OptionType)
PushNOPOrEnd puts one of the single byte options onto the new options. Only values 0 or 1 (ListEnd or NOP) are valid input.
func (*IPv4OptionIterator) RemainingBuffer ¶
func (i *IPv4OptionIterator) RemainingBuffer() IPv4Options
RemainingBuffer returns the remaining (unused) part of the new option buffer, into which a new option may be written.
type IPv4OptionRecordRoute ¶
type IPv4OptionRecordRoute []byte
IPv4OptionRecordRoute is an IPv4 RecordRoute option defined by RFC 791.
func (*IPv4OptionRecordRoute) Contents ¶
func (rr *IPv4OptionRecordRoute) Contents() []byte
Contents implements IPv4Option.
func (*IPv4OptionRecordRoute) Pointer ¶
func (rr *IPv4OptionRecordRoute) Pointer() uint8
Pointer returns the pointer field in the IP RecordRoute option.
func (*IPv4OptionRecordRoute) Size ¶
func (rr *IPv4OptionRecordRoute) Size() uint8
Size implements IPv4Option.
func (*IPv4OptionRecordRoute) StoreAddress ¶
func (rr *IPv4OptionRecordRoute) StoreAddress(addr tcpip.Address)
StoreAddress stores the given IPv4 address into the next free slot.
func (*IPv4OptionRecordRoute) Type ¶
func (rr *IPv4OptionRecordRoute) Type() IPv4OptionType
Type implements IPv4Option.
type IPv4OptionRouterAlert ¶
type IPv4OptionRouterAlert []byte
IPv4OptionRouterAlert is an IPv4 RouterAlert option defined by RFC 2113.
func (*IPv4OptionRouterAlert) Contents ¶
func (ra *IPv4OptionRouterAlert) Contents() []byte
Contents implements IPv4Option.
func (*IPv4OptionRouterAlert) Size ¶
func (ra *IPv4OptionRouterAlert) Size() uint8
Size implements IPv4Option.
func (*IPv4OptionRouterAlert) Type ¶
func (*IPv4OptionRouterAlert) Type() IPv4OptionType
Type implements IPv4Option.
func (*IPv4OptionRouterAlert) Value ¶
func (ra *IPv4OptionRouterAlert) Value() uint16
Value returns the value of the IPv4OptionRouterAlert.
type IPv4OptionTimestamp ¶
type IPv4OptionTimestamp []byte
IPv4OptionTimestamp is a Timestamp option from RFC 791.
func (*IPv4OptionTimestamp) Contents ¶
func (ts *IPv4OptionTimestamp) Contents() []byte
Contents implements IPv4Option.
func (*IPv4OptionTimestamp) Flags ¶
func (ts *IPv4OptionTimestamp) Flags() IPv4OptTSFlags
Flags returns the flags field in the IP Timestamp option.
func (*IPv4OptionTimestamp) IncOverflow ¶
func (ts *IPv4OptionTimestamp) IncOverflow() uint8
IncOverflow increments the Overflow field in the IP Timestamp option. It returns the incremented value. If the return value is 0 then the field overflowed.
func (*IPv4OptionTimestamp) Overflow ¶
func (ts *IPv4OptionTimestamp) Overflow() uint8
Overflow returns the Overflow field in the IP Timestamp option.
func (*IPv4OptionTimestamp) Pointer ¶
func (ts *IPv4OptionTimestamp) Pointer() uint8
Pointer returns the pointer field in the IP Timestamp option.
func (*IPv4OptionTimestamp) Size ¶
func (ts *IPv4OptionTimestamp) Size() uint8
Size implements IPv4Option.
func (*IPv4OptionTimestamp) Type ¶
func (ts *IPv4OptionTimestamp) Type() IPv4OptionType
Type implements IPv4Option.Type().
func (*IPv4OptionTimestamp) UpdateTimestamp ¶
func (ts *IPv4OptionTimestamp) UpdateTimestamp(addr tcpip.Address, clock tcpip.Clock)
UpdateTimestamp updates the fields of the next free timestamp slot.
type IPv4OptionType ¶
type IPv4OptionType byte
An IPv4OptionType can hold the valuse for the Type in an IPv4 option.
const ( // IPv4OptionListEndType is the option type for the End Of Option List // option. Anything following is ignored. IPv4OptionListEndType IPv4OptionType = 0 // IPv4OptionNOPType is the No-Operation option. May appear between other // options and may appear multiple times. IPv4OptionNOPType IPv4OptionType = 1 // IPv4OptionRouterAlertType is the option type for the Router Alert option, // defined in RFC 2113 Section 2.1. IPv4OptionRouterAlertType IPv4OptionType = 20 | 0x80 // IPv4OptionRecordRouteType is used by each router on the path of the packet // to record its path. It is carried over to an Echo Reply. IPv4OptionRecordRouteType IPv4OptionType = 7 // IPv4OptionTimestampType is the option type for the Timestamp option. IPv4OptionTimestampType IPv4OptionType = 68 // IPv4OptionLengthOffset is the offset in an option of its length field. IPv4OptionLengthOffset = 1 )
type IPv4Options ¶
type IPv4Options []byte
IPv4Options is a buffer that holds all the raw IP options.
func (IPv4Options) MakeIterator ¶
func (o IPv4Options) MakeIterator() IPv4OptionIterator
MakeIterator sets up and returns an iterator of options. It also sets up the building of a new option set.
type IPv4OptionsSerializer ¶
type IPv4OptionsSerializer []IPv4SerializableOption
IPv4OptionsSerializer is a serializer for IPv4 options.
func (IPv4OptionsSerializer) Length ¶
func (s IPv4OptionsSerializer) Length() uint8
Length returns the total number of bytes required to serialize the options.
func (IPv4OptionsSerializer) Serialize ¶
func (s IPv4OptionsSerializer) Serialize(b []byte) uint8
Serialize serializes the provided list of IPV4 options into b.
Note, b must be of sufficient size to hold all the options in s. See IPv4OptionsSerializer.Length for details on the getting the total size of a serialized IPv4OptionsSerializer.
Serialize panics if b is not of sufficient size to hold all the options in s.
type IPv4SerializableListEndOption ¶
type IPv4SerializableListEndOption struct{}
IPv4SerializableListEndOption provides serialization for the IPv4 List End option.
type IPv4SerializableNOPOption ¶
type IPv4SerializableNOPOption struct{}
IPv4SerializableNOPOption provides serialization for the IPv4 no-op option.
type IPv4SerializableOption ¶
type IPv4SerializableOption interface {
// contains filtered or unexported methods
}
IPv4SerializableOption is an interface to represent serializable IPv4 option types.
type IPv4SerializableOptionPayload ¶
type IPv4SerializableOptionPayload interface {
// contains filtered or unexported methods
}
IPv4SerializableOptionPayload is an interface providing serialization of the payload of an IPv4 option.
type IPv4SerializableRouterAlertOption ¶
type IPv4SerializableRouterAlertOption struct{}
IPv4SerializableRouterAlertOption provides serialization of the Router Alert IPv4 option according to RFC 2113.
type IPv6 ¶
type IPv6 []byte
IPv6 represents an ipv6 header stored in a byte array. Most of the methods of IPv6 access to the underlying slice without checking the boundaries and could panic because of 'index out of range'. Always call IsValid() to validate an instance of IPv6 before using other methods.
func (IPv6) Checksum ¶
Checksum implements Network.Checksum. Given that IPv6 doesn't have a checksum, it just returns 0.
func (IPv6) DestinationAddress ¶
DestinationAddress returns the "destination address" field of the ipv6 header.
func (IPv6) Encode ¶
func (b IPv6) Encode(i *IPv6Fields)
Encode encodes all the fields of the ipv6 header.
func (IPv6) NextHeader ¶
NextHeader returns the value of the "next header" field of the ipv6 header.
func (IPv6) PayloadLength ¶
PayloadLength returns the value of the "payload length" field of the ipv6 header.
func (IPv6) SetChecksum ¶
SetChecksum implements Network.SetChecksum. Given that IPv6 doesn't have a checksum, it is empty.
func (IPv6) SetDestinationAddress ¶
SetDestinationAddress sets the "destination address" field of the ipv6 header.
func (IPv6) SetHopLimit ¶
SetHopLimit sets the value of the "Hop Limit" field.
func (IPv6) SetNextHeader ¶
SetNextHeader sets the value of the "next header" field of the ipv6 header.
func (IPv6) SetPayloadLength ¶
SetPayloadLength sets the "payload length" field of the ipv6 header.
func (IPv6) SetSourceAddress ¶
SetSourceAddress sets the "source address" field of the ipv6 header.
func (IPv6) SourceAddress ¶
SourceAddress returns the "source address" field of the ipv6 header.
func (IPv6) TransportProtocol ¶
func (b IPv6) TransportProtocol() tcpip.TransportProtocolNumber
TransportProtocol implements Network.TransportProtocol.
type IPv6AddressScope ¶
type IPv6AddressScope int
IPv6AddressScope is the scope of an IPv6 address.
const ( // LinkLocalScope indicates a link-local address. LinkLocalScope IPv6AddressScope = iota // GlobalScope indicates a global address. GlobalScope )
func ScopeForIPv6Address ¶
func ScopeForIPv6Address(addr tcpip.Address) (IPv6AddressScope, tcpip.Error)
ScopeForIPv6Address returns the scope for an IPv6 address.
type IPv6DestinationOptionsExtHdr ¶
type IPv6DestinationOptionsExtHdr struct {
// contains filtered or unexported fields
}
IPv6DestinationOptionsExtHdr is a buffer holding the Destination Options extension header.
func (IPv6DestinationOptionsExtHdr) Iter ¶
func (b IPv6DestinationOptionsExtHdr) Iter() IPv6OptionsExtHdrOptionsIterator
Iter returns an iterator over the IPv6 extension header options held in b.
type IPv6ExtHdrOption ¶
type IPv6ExtHdrOption interface { // UnknownAction returns the action to take in response to an unrecognized // option. UnknownAction() IPv6OptionUnknownAction // contains filtered or unexported methods }
IPv6ExtHdrOption is implemented by the various IPv6 extension header options.
type IPv6ExtHdrOptionIdentifier ¶
type IPv6ExtHdrOptionIdentifier uint8
IPv6ExtHdrOptionIdentifier is an IPv6 extension header option identifier.
type IPv6ExtHdrSerializer ¶
type IPv6ExtHdrSerializer []IPv6SerializableExtHdr
IPv6ExtHdrSerializer provides serialization of IPv6 extension headers.
func (IPv6ExtHdrSerializer) Length ¶
func (s IPv6ExtHdrSerializer) Length() int
Length returns the total number of bytes required to serialize the extension headers.
func (IPv6ExtHdrSerializer) Serialize ¶
func (s IPv6ExtHdrSerializer) Serialize(transportProtocol tcpip.TransportProtocolNumber, b []byte) (uint8, int)
Serialize serializes the provided list of IPv6 extension headers into b.
Note, b must be of sufficient size to hold all the headers in s. See IPv6ExtHdrSerializer.Length for details on the getting the total size of a serialized IPv6ExtHdrSerializer.
Serialize may panic if b is not of sufficient size to hold all the options in s.
Serialize takes the transportProtocol value to be used as the last extension header's Next Header value and returns the header identifier of the first serialized extension header and the total serialized length.
type IPv6ExtensionHeaderIdentifier ¶
type IPv6ExtensionHeaderIdentifier uint8
IPv6ExtensionHeaderIdentifier is an IPv6 extension header identifier.
const ( // IPv6HopByHopOptionsExtHdrIdentifier is the header identifier of a Hop by // Hop Options extension header, as per RFC 8200 section 4.3. IPv6HopByHopOptionsExtHdrIdentifier IPv6ExtensionHeaderIdentifier = 0 // IPv6RoutingExtHdrIdentifier is the header identifier of a Routing extension // header, as per RFC 8200 section 4.4. IPv6RoutingExtHdrIdentifier IPv6ExtensionHeaderIdentifier = 43 // IPv6FragmentExtHdrIdentifier is the header identifier of a Fragment // extension header, as per RFC 8200 section 4.5. IPv6FragmentExtHdrIdentifier IPv6ExtensionHeaderIdentifier = 44 // IPv6DestinationOptionsExtHdrIdentifier is the header identifier of a // Destination Options extension header, as per RFC 8200 section 4.6. IPv6DestinationOptionsExtHdrIdentifier IPv6ExtensionHeaderIdentifier = 60 // IPv6NoNextHeaderIdentifier is the header identifier used to signify the end // of an IPv6 payload, as per RFC 8200 section 4.7. IPv6NoNextHeaderIdentifier IPv6ExtensionHeaderIdentifier = 59 // IPv6UnknownExtHdrIdentifier is reserved by IANA. // https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#extension-header // "254 Use for experimentation and testing [RFC3692][RFC4727]" IPv6UnknownExtHdrIdentifier IPv6ExtensionHeaderIdentifier = 254 )
type IPv6Fields ¶
type IPv6Fields struct { // TrafficClass is the "traffic class" field of an IPv6 packet. TrafficClass uint8 // FlowLabel is the "flow label" field of an IPv6 packet. FlowLabel uint32 // PayloadLength is the "payload length" field of an IPv6 packet, including // the length of all extension headers. PayloadLength uint16 // TransportProtocol is the transport layer protocol number. Serialized in the // last "next header" field of the IPv6 header + extension headers. TransportProtocol tcpip.TransportProtocolNumber // HopLimit is the "Hop Limit" field of an IPv6 packet. HopLimit uint8 // SrcAddr is the "source ip address" of an IPv6 packet. SrcAddr tcpip.Address // DstAddr is the "destination ip address" of an IPv6 packet. DstAddr tcpip.Address // ExtensionHeaders are the extension headers following the IPv6 header. ExtensionHeaders IPv6ExtHdrSerializer }
IPv6Fields contains the fields of an IPv6 packet. It is used to describe the fields of a packet that needs to be encoded.
type IPv6Fragment ¶
type IPv6Fragment []byte
IPv6Fragment represents an ipv6 fragment header stored in a byte array. Most of the methods of IPv6Fragment access to the underlying slice without checking the boundaries and could panic because of 'index out of range'. Always call IsValid() to validate an instance of IPv6Fragment before using other methods.
func (IPv6Fragment) Checksum ¶
func (b IPv6Fragment) Checksum() uint16
Checksum is not supported by IPv6Fragment.
func (IPv6Fragment) DestinationAddress ¶
func (b IPv6Fragment) DestinationAddress() tcpip.Address
DestinationAddress is not supported by IPv6Fragment.
func (IPv6Fragment) FragmentOffset ¶
func (b IPv6Fragment) FragmentOffset() uint16
FragmentOffset returns the "fragment offset" field of the ipv6 fragment.
func (IPv6Fragment) ID ¶
func (b IPv6Fragment) ID() uint32
ID returns the value of the identifier field of the ipv6 fragment.
func (IPv6Fragment) IsValid ¶
func (b IPv6Fragment) IsValid() bool
IsValid performs basic validation on the fragment header.
func (IPv6Fragment) More ¶
func (b IPv6Fragment) More() bool
More returns the "more" field of the ipv6 fragment.
func (IPv6Fragment) NextHeader ¶
func (b IPv6Fragment) NextHeader() uint8
NextHeader returns the value of the "next header" field of the ipv6 fragment.
func (IPv6Fragment) Payload ¶
func (b IPv6Fragment) Payload() []byte
Payload implements Network.Payload.
func (IPv6Fragment) SetChecksum ¶
func (b IPv6Fragment) SetChecksum(uint16)
SetChecksum is not supported by IPv6Fragment.
func (IPv6Fragment) SetDestinationAddress ¶
func (b IPv6Fragment) SetDestinationAddress(tcpip.Address)
SetDestinationAddress is not supported by IPv6Fragment.
func (IPv6Fragment) SetSourceAddress ¶
func (b IPv6Fragment) SetSourceAddress(tcpip.Address)
SetSourceAddress is not supported by IPv6Fragment.
func (IPv6Fragment) SetTOS ¶
func (b IPv6Fragment) SetTOS(t uint8, l uint32)
SetTOS is not supported by IPv6Fragment.
func (IPv6Fragment) SourceAddress ¶
func (b IPv6Fragment) SourceAddress() tcpip.Address
SourceAddress is not supported by IPv6Fragment.
func (IPv6Fragment) TOS ¶
func (b IPv6Fragment) TOS() (uint8, uint32)
TOS is not supported by IPv6Fragment.
func (IPv6Fragment) TransportProtocol ¶
func (b IPv6Fragment) TransportProtocol() tcpip.TransportProtocolNumber
TransportProtocol implements Network.TransportProtocol.
type IPv6FragmentExtHdr ¶
type IPv6FragmentExtHdr [6]byte
IPv6FragmentExtHdr is a buffer holding the Fragment extension header specific data as outlined in RFC 8200 section 4.5.
Note, the buffer does not include the Next Header and Reserved fields.
func (IPv6FragmentExtHdr) FragmentOffset ¶
func (b IPv6FragmentExtHdr) FragmentOffset() uint16
FragmentOffset returns the Fragment Offset field.
This value indicates where the buffer following the Fragment extension header starts in the target (reassembled) packet.
func (IPv6FragmentExtHdr) ID ¶
func (b IPv6FragmentExtHdr) ID() uint32
ID returns the Identification field.
This value is used to uniquely identify the packet, between a souce and destination.
func (IPv6FragmentExtHdr) IsAtomic ¶
func (b IPv6FragmentExtHdr) IsAtomic() bool
IsAtomic returns whether the fragment header indicates an atomic fragment. An atomic fragment is a fragment that contains all the data required to reassemble a full packet.
func (IPv6FragmentExtHdr) More ¶
func (b IPv6FragmentExtHdr) More() bool
More returns the More (M) flag.
This indicates whether any fragments are expected to succeed b.
type IPv6HopByHopOptionsExtHdr ¶
type IPv6HopByHopOptionsExtHdr struct {
// contains filtered or unexported fields
}
IPv6HopByHopOptionsExtHdr is a buffer holding the Hop By Hop Options extension header.
func (IPv6HopByHopOptionsExtHdr) Iter ¶
func (b IPv6HopByHopOptionsExtHdr) Iter() IPv6OptionsExtHdrOptionsIterator
Iter returns an iterator over the IPv6 extension header options held in b.
type IPv6MulticastScope ¶
type IPv6MulticastScope uint8
IPv6MulticastScope is the scope of a multicast IPv6 address, as defined by RFC 7346 section 2.
func V6MulticastScope ¶
func V6MulticastScope(addr tcpip.Address) IPv6MulticastScope
V6MulticastScope returns the scope of a multicast address.
type IPv6OptionUnknownAction ¶
type IPv6OptionUnknownAction int
IPv6OptionUnknownAction is the action that must be taken if the processing IPv6 node does not recognize the option, as outlined in RFC 8200 section 4.2.
const ( // IPv6OptionUnknownActionSkip indicates that the unrecognized option must // be skipped and the node should continue processing the header. IPv6OptionUnknownActionSkip IPv6OptionUnknownAction = 0 // IPv6OptionUnknownActionDiscard indicates that the packet must be silently // discarded. IPv6OptionUnknownActionDiscard IPv6OptionUnknownAction = 1 // IPv6OptionUnknownActionDiscardSendICMP indicates that the packet must be // discarded and the node must send an ICMP Parameter Problem, Code 2, message // to the packet's source, regardless of whether or not the packet's // Destination was a multicast address. IPv6OptionUnknownActionDiscardSendICMP IPv6OptionUnknownAction = 2 // IPv6OptionUnknownActionDiscardSendICMPNoMulticastDest indicates that the // packet must be discarded and the node must send an ICMP Parameter Problem, // Code 2, message to the packet's source only if the packet's Destination was // not a multicast address. IPv6OptionUnknownActionDiscardSendICMPNoMulticastDest IPv6OptionUnknownAction = 3 )
type IPv6OptionsExtHdrOptionsIterator ¶
type IPv6OptionsExtHdrOptionsIterator struct {
// contains filtered or unexported fields
}
IPv6OptionsExtHdrOptionsIterator is an iterator over IPv6 extension header options.
Note, between when an IPv6OptionsExtHdrOptionsIterator is obtained and last used, no changes to the underlying buffer may happen. Doing so may cause undefined and unexpected behaviour. It is fine to obtain an IPv6OptionsExtHdrOptionsIterator, iterate over the first few options then modify the backing payload so long as the IPv6OptionsExtHdrOptionsIterator obtained before modification is no longer used.
func (*IPv6OptionsExtHdrOptionsIterator) Next ¶
func (i *IPv6OptionsExtHdrOptionsIterator) Next() (IPv6ExtHdrOption, bool, error)
Next returns the next option in the options data.
If the next item is not a known extension header option, IPv6UnknownExtHdrOption will be returned with the option identifier and data.
The return is of the format (option, done, error). done will be true when Next is unable to return anything because the iterator has reached the end of the options data, or an error occured.
func (*IPv6OptionsExtHdrOptionsIterator) OptionOffset ¶
func (i *IPv6OptionsExtHdrOptionsIterator) OptionOffset() uint32
OptionOffset returns the number of bytes parsed while processing the option field of the current Extension Header.
type IPv6PayloadHeader ¶
type IPv6PayloadHeader interface {
// contains filtered or unexported methods
}
IPv6PayloadHeader is implemented by the various headers that can be found in an IPv6 payload.
These headers include IPv6 extension headers or upper layer data.
type IPv6PayloadIterator ¶
type IPv6PayloadIterator struct {
// contains filtered or unexported fields
}
IPv6PayloadIterator is an iterator over the contents of an IPv6 payload.
The IPv6 payload may contain IPv6 extension headers before any upper layer data.
Note, between when an IPv6PayloadIterator is obtained and last used, no changes to the payload may happen. Doing so may cause undefined and unexpected behaviour. It is fine to obtain an IPv6PayloadIterator, iterate over the first few headers then modify the backing payload so long as the IPv6PayloadIterator obtained before modification is no longer used.
func MakeIPv6PayloadIterator ¶
func MakeIPv6PayloadIterator(nextHdrIdentifier IPv6ExtensionHeaderIdentifier, payload buffer.VectorisedView) IPv6PayloadIterator
MakeIPv6PayloadIterator returns an iterator over the IPv6 payload containing extension headers, or a raw payload if the payload cannot be parsed.
func (*IPv6PayloadIterator) AsRawHeader ¶
func (i *IPv6PayloadIterator) AsRawHeader(consume bool) IPv6RawPayloadHeader
AsRawHeader returns the remaining payload of i as a raw header and optionally consumes the iterator.
If consume is true, calls to Next after calling AsRawHeader on i will indicate that the iterator is done.
func (IPv6PayloadIterator) HeaderOffset ¶
func (i IPv6PayloadIterator) HeaderOffset() uint32
HeaderOffset returns the offset to the start of the extension header most recently processed.
func (*IPv6PayloadIterator) Next ¶
func (i *IPv6PayloadIterator) Next() (IPv6PayloadHeader, bool, error)
Next returns the next item in the payload.
If the next item is not a known IPv6 extension header, IPv6RawPayloadHeader will be returned with the remaining bytes and next header identifier.
The return is of the format (header, done, error). done will be true when Next is unable to return anything because the iterator has reached the end of the payload, or an error occured.
func (IPv6PayloadIterator) ParseOffset ¶
func (i IPv6PayloadIterator) ParseOffset() uint32
ParseOffset returns the number of bytes successfully parsed.
type IPv6RawPayloadHeader ¶
type IPv6RawPayloadHeader struct { Identifier IPv6ExtensionHeaderIdentifier Buf buffer.VectorisedView }
IPv6RawPayloadHeader the remainder of an IPv6 payload after an iterator encounters a Next Header field it does not recognize as an IPv6 extension header.
type IPv6RouterAlertOption ¶
type IPv6RouterAlertOption struct {
Value IPv6RouterAlertValue
}
IPv6RouterAlertOption is the IPv6 Router alert Hop by Hop option defined in RFC 2711 section 2.1.
func (*IPv6RouterAlertOption) UnknownAction ¶
func (*IPv6RouterAlertOption) UnknownAction() IPv6OptionUnknownAction
UnknownAction implements IPv6ExtHdrOption.
type IPv6RouterAlertValue ¶
type IPv6RouterAlertValue uint16
IPv6RouterAlertValue is the payload of an IPv6 Router Alert option.
const ( // IPv6RouterAlertMLD indicates a datagram containing a Multicast Listener // Discovery message as defined in RFC 2711 section 2.1. IPv6RouterAlertMLD IPv6RouterAlertValue = 0 // IPv6RouterAlertRSVP indicates a datagram containing an RSVP message as // defined in RFC 2711 section 2.1. IPv6RouterAlertRSVP IPv6RouterAlertValue = 1 // IPv6RouterAlertActiveNetworks indicates a datagram containing an Active // Networks message as defined in RFC 2711 section 2.1. IPv6RouterAlertActiveNetworks IPv6RouterAlertValue = 2 )
type IPv6RoutingExtHdr ¶
type IPv6RoutingExtHdr []byte
IPv6RoutingExtHdr is a buffer holding the Routing extension header specific data as outlined in RFC 8200 section 4.4.
func (IPv6RoutingExtHdr) SegmentsLeft ¶
func (b IPv6RoutingExtHdr) SegmentsLeft() uint8
SegmentsLeft returns the Segments Left field.
type IPv6SerializableExtHdr ¶
type IPv6SerializableExtHdr interface {
// contains filtered or unexported methods
}
IPv6SerializableExtHdr provides serialization for IPv6 extension headers.
type IPv6SerializableFragmentExtHdr ¶
type IPv6SerializableFragmentExtHdr struct { // FragmentOffset is the "fragment offset" field of an IPv6 fragment. FragmentOffset uint16 // M is the "more" field of an IPv6 fragment. M bool // Identification is the "identification" field of an IPv6 fragment. Identification uint32 }
IPv6SerializableFragmentExtHdr is used to serialize an IPv6 fragment extension header as defined in RFC 8200 section 4.5.
type IPv6SerializableHopByHopExtHdr ¶
type IPv6SerializableHopByHopExtHdr []IPv6SerializableHopByHopOption
IPv6SerializableHopByHopExtHdr implements serialization of the Hop by Hop options extension header.
type IPv6SerializableHopByHopOption ¶
type IPv6SerializableHopByHopOption interface {
// contains filtered or unexported methods
}
IPv6SerializableHopByHopOption provides serialization for hop by hop options.
type IPv6UnknownExtHdrOption ¶
type IPv6UnknownExtHdrOption struct { Identifier IPv6ExtHdrOptionIdentifier Data []byte }
IPv6UnknownExtHdrOption holds the identifier and data for an IPv6 extension header option that is unknown by the parsing utilities.
func (*IPv6UnknownExtHdrOption) UnknownAction ¶
func (o *IPv6UnknownExtHdrOption) UnknownAction() IPv6OptionUnknownAction
UnknownAction implements IPv6OptionUnknownAction.UnknownAction.
type MLD ¶
type MLD []byte
MLD is a Multicast Listener Discovery message in an ICMPv6 packet.
MLD will only contain the body of an ICMPv6 packet.
As per RFC 2710 section 3, MLD messages have the following format (MLD only holds the bytes after the first four bytes in the diagram below):
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Code | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Maximum Response Delay | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | + + | | + Multicast Address + | | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
func (MLD) MaximumResponseDelay ¶
MaximumResponseDelay returns the Maximum Response Delay.
func (MLD) MulticastAddress ¶
MulticastAddress returns the Multicast Address.
func (MLD) SetMaximumResponseDelay ¶
SetMaximumResponseDelay sets the Maximum Response Delay field.
maxRespDelayMS is the value in milliseconds.
func (MLD) SetMulticastAddress ¶
SetMulticastAddress sets the Multicast Address field.
type NDPDNSSearchList ¶
type NDPDNSSearchList []byte
NDPDNSSearchList is the NDP DNS Search List option, as defined by RFC 8106 section 5.2.
func (NDPDNSSearchList) DomainNames ¶
func (o NDPDNSSearchList) DomainNames() ([]string, error)
DomainNames returns a DNS search list of domain names.
DomainNames will parse the backing buffer as outlined by RFC 1035 section 3.1 and return a list of strings, with all domain names in lower case.
func (NDPDNSSearchList) Lifetime ¶
func (o NDPDNSSearchList) Lifetime() time.Duration
Lifetime returns the length of time that the DNS search list of domain names in this option may be used for name resolution.
Note, a value of 0 implies the domain names should no longer be used, and a value of infinity/forever is represented by NDPInfiniteLifetime.
func (NDPDNSSearchList) String ¶
func (o NDPDNSSearchList) String() string
String implements fmt.Stringer.
type NDPNeighborAdvert ¶
type NDPNeighborAdvert []byte
NDPNeighborAdvert is an NDP Neighbor Advertisement message. It will only contain the body of an ICMPv6 packet.
See RFC 4861 section 4.4 for more details.
func (NDPNeighborAdvert) Options ¶
func (b NDPNeighborAdvert) Options() NDPOptions
Options returns an NDPOptions of the the options body.
func (NDPNeighborAdvert) OverrideFlag ¶
func (b NDPNeighborAdvert) OverrideFlag() bool
OverrideFlag returns the value of the Override Flag field.
func (NDPNeighborAdvert) RouterFlag ¶
func (b NDPNeighborAdvert) RouterFlag() bool
RouterFlag returns the value of the Router Flag field.
func (NDPNeighborAdvert) SetOverrideFlag ¶
func (b NDPNeighborAdvert) SetOverrideFlag(f bool)
SetOverrideFlag sets the value in the Override Flag field.
func (NDPNeighborAdvert) SetRouterFlag ¶
func (b NDPNeighborAdvert) SetRouterFlag(f bool)
SetRouterFlag sets the value in the Router Flag field.
func (NDPNeighborAdvert) SetSolicitedFlag ¶
func (b NDPNeighborAdvert) SetSolicitedFlag(f bool)
SetSolicitedFlag sets the value in the Solicited Flag field.
func (NDPNeighborAdvert) SetTargetAddress ¶
func (b NDPNeighborAdvert) SetTargetAddress(addr tcpip.Address)
SetTargetAddress sets the value within the Target Address field.
func (NDPNeighborAdvert) SolicitedFlag ¶
func (b NDPNeighborAdvert) SolicitedFlag() bool
SolicitedFlag returns the value of the Solicited Flag field.
func (NDPNeighborAdvert) TargetAddress ¶
func (b NDPNeighborAdvert) TargetAddress() tcpip.Address
TargetAddress returns the value within the Target Address field.
type NDPNeighborSolicit ¶
type NDPNeighborSolicit []byte
NDPNeighborSolicit is an NDP Neighbor Solicitation message. It will only contain the body of an ICMPv6 packet.
See RFC 4861 section 4.3 for more details.
func (NDPNeighborSolicit) Options ¶
func (b NDPNeighborSolicit) Options() NDPOptions
Options returns an NDPOptions of the the options body.
func (NDPNeighborSolicit) SetTargetAddress ¶
func (b NDPNeighborSolicit) SetTargetAddress(addr tcpip.Address)
SetTargetAddress sets the value within the Target Address field.
func (NDPNeighborSolicit) TargetAddress ¶
func (b NDPNeighborSolicit) TargetAddress() tcpip.Address
TargetAddress returns the value within the Target Address field.
type NDPNonceOption ¶
type NDPNonceOption []byte
NDPNonceOption is the NDP Nonce Option as defined by RFC 3971 section 5.3.2.
It is the first X bytes following the NDP option's Type and Length field where X is the value in Length multiplied by lengthByteUnits - 2 bytes.
func (NDPNonceOption) Nonce ¶
func (o NDPNonceOption) Nonce() []byte
Nonce returns the nonce value this option holds.
func (NDPNonceOption) String ¶
func (o NDPNonceOption) String() string
String implements fmt.Stringer.
type NDPOptionIterator ¶
type NDPOptionIterator struct {
// contains filtered or unexported fields
}
NDPOptionIterator is an iterator of NDPOption.
Note, between when an NDPOptionIterator is obtained and last used, no changes to the NDPOptions may happen. Doing so may cause undefined and unexpected behaviour. It is fine to obtain an NDPOptionIterator, iterate over the first few NDPOption then modify the backing NDPOptions so long as the NDPOptionIterator obtained before modification is no longer used.
func (*NDPOptionIterator) Next ¶
func (i *NDPOptionIterator) Next() (NDPOption, bool, error)
Next returns the next element in the backing NDPOptions, or true if we are done, or false if an error occured.
The return can be read as option, done, error. Note, option should only be used if done is false and error is nil.
type NDPOptions ¶
type NDPOptions []byte
NDPOptions is a buffer of NDP options as defined by RFC 4861 section 4.6.
func (NDPOptions) Iter ¶
func (b NDPOptions) Iter(check bool) (NDPOptionIterator, error)
Iter returns an iterator of NDPOption.
If check is true, Iter will do an integrity check on the options by iterating over it and returning an error if detected.
See NDPOptionIterator for more information.
func (NDPOptions) Serialize ¶
func (b NDPOptions) Serialize(s NDPOptionsSerializer) int
Serialize serializes the provided list of NDP options into b.
Note, b must be of sufficient size to hold all the options in s. See NDPOptionsSerializer.Length for details on the getting the total size of a serialized NDPOptionsSerializer.
Serialize may panic if b is not of sufficient size to hold all the options in s.
type NDPOptionsSerializer ¶
type NDPOptionsSerializer []NDPOption
NDPOptionsSerializer is a serializer for NDP options.
func (NDPOptionsSerializer) Length ¶
func (b NDPOptionsSerializer) Length() int
Length returns the total number of bytes required to serialize.
type NDPPrefixInformation ¶
type NDPPrefixInformation []byte
NDPPrefixInformation is the NDP Prefix Information option as defined by RFC 4861 section 4.6.2.
The length, in bytes, of a valid NDP Prefix Information option body MUST be ndpPrefixInformationLength bytes.
func (NDPPrefixInformation) AutonomousAddressConfigurationFlag ¶
func (o NDPPrefixInformation) AutonomousAddressConfigurationFlag() bool
AutonomousAddressConfigurationFlag returns true if the prefix can be used for Stateless Address Auto-Configuration (as specified in RFC 4862).
func (NDPPrefixInformation) OnLinkFlag ¶
func (o NDPPrefixInformation) OnLinkFlag() bool
OnLinkFlag returns true of the prefix is considered on-link. On-link means that a forwarding node is not needed to send packets to other nodes on the same prefix.
Note, when this function returns false, no statement is made about the on-link property of a prefix. That is, if OnLinkFlag returns false, the caller MUST NOT conclude that the prefix is off-link and MUST NOT update any previously stored state for this prefix about its on-link status.
func (NDPPrefixInformation) PreferredLifetime ¶
func (o NDPPrefixInformation) PreferredLifetime() time.Duration
PreferredLifetime returns the length of time that an address generated from the prefix via Stateless Address Auto-Configuration remains preferred. This value is relative to the send time of the packet that the Prefix Information option was present in.
Note, a value of 0 implies that addresses generated from the prefix should no longer remain preferred, and a value of infinity is represented by NDPInfiniteLifetime.
Also note that the value of this field MUST NOT exceed the Valid Lifetime field to avoid preferring addresses that are no longer valid, for the purpose of Stateless Address Auto-Configuration.
func (NDPPrefixInformation) Prefix ¶
func (o NDPPrefixInformation) Prefix() tcpip.Address
Prefix returns an IPv6 address or a prefix of an IPv6 address. The Prefix Length field (see NDPPrefixInformation.PrefixLength) contains the number of valid leading bits in the prefix.
Hosts SHOULD ignore an NDP Prefix Information option where the Prefix field holds the link-local prefix (fe80::).
func (NDPPrefixInformation) PrefixLength ¶
func (o NDPPrefixInformation) PrefixLength() uint8
PrefixLength returns the value in the number of leading bits in the Prefix that are valid.
Valid values are in the range [0, 128], but o may not always contain valid values. It is up to the caller to valdiate the Prefix Information option.
func (NDPPrefixInformation) String ¶
func (o NDPPrefixInformation) String() string
String implements fmt.Stringer.
func (NDPPrefixInformation) Subnet ¶
func (o NDPPrefixInformation) Subnet() tcpip.Subnet
Subnet returns the Prefix field and Prefix Length field represented in a tcpip.Subnet.
func (NDPPrefixInformation) ValidLifetime ¶
func (o NDPPrefixInformation) ValidLifetime() time.Duration
ValidLifetime returns the length of time that the prefix is valid for the purpose of on-link determination. This value is relative to the send time of the packet that the Prefix Information option was present in.
Note, a value of 0 implies the prefix should not be considered as on-link, and a value of infinity/forever is represented by NDPInfiniteLifetime.
type NDPRecursiveDNSServer ¶
type NDPRecursiveDNSServer []byte
NDPRecursiveDNSServer is the NDP Recursive DNS Server option, as defined by RFC 8106 section 5.1.
To make sure that the option meets its minimum length and does not end in the middle of a DNS server's IPv6 address, the length of a valid NDPRecursiveDNSServer must meet the following constraint:
(Length - ndpRecursiveDNSServerAddressesOffset) % IPv6AddressSize == 0
func (NDPRecursiveDNSServer) Addresses ¶
func (o NDPRecursiveDNSServer) Addresses() ([]tcpip.Address, error)
Addresses returns the recursive DNS server IPv6 addresses that may be used for name resolution.
Note, the addresses MAY be link-local addresses.
func (NDPRecursiveDNSServer) Lifetime ¶
func (o NDPRecursiveDNSServer) Lifetime() time.Duration
Lifetime returns the length of time that the DNS server addresses in this option may be used for name resolution.
Note, a value of 0 implies the addresses should no longer be used, and a value of infinity/forever is represented by NDPInfiniteLifetime.
Lifetime may panic if o does not have enough bytes to hold the Lifetime field.
func (NDPRecursiveDNSServer) String ¶
func (o NDPRecursiveDNSServer) String() string
String implements fmt.Stringer.
type NDPRouteInformation ¶
type NDPRouteInformation []byte
NDPRouteInformation is the NDP Router Information option, as defined by RFC 4191 section 2.3.
func (NDPRouteInformation) Prefix ¶
func (o NDPRouteInformation) Prefix() (tcpip.Subnet, error)
Prefix returns the prefix of the destination subnet this route is for.
func (NDPRouteInformation) PrefixLength ¶
func (o NDPRouteInformation) PrefixLength() uint8
PrefixLength returns the length of the prefix.
func (NDPRouteInformation) RouteLifetime ¶
func (o NDPRouteInformation) RouteLifetime() time.Duration
RouteLifetime returns the lifetime of the route.
Note, a value of 0 implies the route is now invalid and a value of infinity/forever is represented by NDPInfiniteLifetime.
func (NDPRouteInformation) RoutePreference ¶
func (o NDPRouteInformation) RoutePreference() NDPRoutePreference
RoutePreference returns the preference of the route over other routes to the same destination but through a different router.
func (NDPRouteInformation) String ¶
func (o NDPRouteInformation) String() string
String implements fmt.Stringer.
type NDPRoutePreference ¶
type NDPRoutePreference uint8
NDPRoutePreference is the preference values for default routers or more-specific routes.
As per RFC 4191 section 2.1,
Default router preferences and preferences for more-specific routes are encoded the same way. Preference values are encoded as a two-bit signed integer, as follows: 01 High 00 Medium (default) 11 Low 10 Reserved - MUST NOT be sent Note that implementations can treat the value as a two-bit signed integer. Having just three values reinforces that they are not metrics and more values do not appear to be necessary for reasonable scenarios.
func (NDPRoutePreference) String ¶
func (p NDPRoutePreference) String() string
String implements fmt.Stringer.
type NDPRouterAdvert ¶
type NDPRouterAdvert []byte
NDPRouterAdvert is an NDP Router Advertisement message. It will only contain the body of an ICMPv6 packet.
See RFC 4861 section 4.2 and RFC 4191 section 2.2 for more details.
func (NDPRouterAdvert) CurrHopLimit ¶
func (b NDPRouterAdvert) CurrHopLimit() uint8
CurrHopLimit returns the value of the Curr Hop Limit field.
func (NDPRouterAdvert) DefaultRouterPreference ¶
func (b NDPRouterAdvert) DefaultRouterPreference() NDPRoutePreference
DefaultRouterPreference returns the Default Router Preference field.
func (NDPRouterAdvert) ManagedAddrConfFlag ¶
func (b NDPRouterAdvert) ManagedAddrConfFlag() bool
ManagedAddrConfFlag returns the value of the Managed Address Configuration flag.
func (NDPRouterAdvert) Options ¶
func (b NDPRouterAdvert) Options() NDPOptions
Options returns an NDPOptions of the the options body.
func (NDPRouterAdvert) OtherConfFlag ¶
func (b NDPRouterAdvert) OtherConfFlag() bool
OtherConfFlag returns the value of the Other Configuration flag.
func (NDPRouterAdvert) ReachableTime ¶
func (b NDPRouterAdvert) ReachableTime() time.Duration
ReachableTime returns the time that a node assumes a neighbor is reachable after having received a reachability confirmation. A value of 0 means that it is unspecified by the source of the Router Advertisement message.
func (NDPRouterAdvert) RetransTimer ¶
func (b NDPRouterAdvert) RetransTimer() time.Duration
RetransTimer returns the time between retransmitted Neighbor Solicitation messages. A value of 0 means that it is unspecified by the source of the Router Advertisement message.
func (NDPRouterAdvert) RouterLifetime ¶
func (b NDPRouterAdvert) RouterLifetime() time.Duration
RouterLifetime returns the lifetime associated with the default router. A value of 0 means the source of the Router Advertisement is not a default router and SHOULD NOT appear on the default router list. Note, a value of 0 only means that the router should not be used as a default router, it does not apply to other information contained in the Router Advertisement.
type NDPRouterSolicit ¶
type NDPRouterSolicit []byte
NDPRouterSolicit is an NDP Router Solicitation message. It will only contain the body of an ICMPv6 packet.
See RFC 4861 section 4.1 for more details.
func (NDPRouterSolicit) Options ¶
func (b NDPRouterSolicit) Options() NDPOptions
Options returns an NDPOptions of the the options body.
type NDPSourceLinkLayerAddressOption ¶
type NDPSourceLinkLayerAddressOption tcpip.LinkAddress
NDPSourceLinkLayerAddressOption is the NDP Source Link Layer Option as defined by RFC 4861 section 4.6.1.
It is the first X bytes following the NDP option's Type and Length field where X is the value in Length multiplied by lengthByteUnits - 2 bytes.
func (NDPSourceLinkLayerAddressOption) EthernetAddress ¶
func (o NDPSourceLinkLayerAddressOption) EthernetAddress() tcpip.LinkAddress
EthernetAddress will return an ethernet (MAC) address if the NDPSourceLinkLayerAddressOption's body has at minimum EthernetAddressSize bytes. If the body has more than EthernetAddressSize bytes, only the first EthernetAddressSize bytes are returned as that is all that is needed for an Ethernet address.
func (NDPSourceLinkLayerAddressOption) String ¶
func (o NDPSourceLinkLayerAddressOption) String() string
String implements fmt.Stringer.
type NDPTargetLinkLayerAddressOption ¶
type NDPTargetLinkLayerAddressOption tcpip.LinkAddress
NDPTargetLinkLayerAddressOption is the NDP Target Link Layer Option as defined by RFC 4861 section 4.6.1.
It is the first X bytes following the NDP option's Type and Length field where X is the value in Length multiplied by lengthByteUnits - 2 bytes.
func (NDPTargetLinkLayerAddressOption) EthernetAddress ¶
func (o NDPTargetLinkLayerAddressOption) EthernetAddress() tcpip.LinkAddress
EthernetAddress will return an ethernet (MAC) address if the NDPTargetLinkLayerAddressOption's body has at minimum EthernetAddressSize bytes. If the body has more than EthernetAddressSize bytes, only the first EthernetAddressSize bytes are returned as that is all that is needed for an Ethernet address.
func (NDPTargetLinkLayerAddressOption) String ¶
func (o NDPTargetLinkLayerAddressOption) String() string
String implements fmt.Stringer.
type Network ¶
type Network interface { // SourceAddress returns the value of the "source address" field. SourceAddress() tcpip.Address // DestinationAddress returns the value of the "destination address" // field. DestinationAddress() tcpip.Address // Checksum returns the value of the "checksum" field. Checksum() uint16 // SetSourceAddress sets the value of the "source address" field. SetSourceAddress(tcpip.Address) // SetDestinationAddress sets the value of the "destination address" // field. SetDestinationAddress(tcpip.Address) // SetChecksum sets the value of the "checksum" field. SetChecksum(uint16) // TransportProtocol returns the number of the transport protocol // stored in the payload. TransportProtocol() tcpip.TransportProtocolNumber // Payload returns a byte slice containing the payload of the network // packet. Payload() []byte // TOS returns the values of the "type of service" and "flow label" fields. TOS() (uint8, uint32) // SetTOS sets the values of the "type of service" and "flow label" fields. SetTOS(t uint8, l uint32) }
Network offers generic methods to query and/or update the fields of the header of a network protocol buffer.
type SACKBlock ¶
type SACKBlock struct { // Start indicates the lowest sequence number in the block. Start seqnum.Value // End indicates the sequence number immediately following the last // sequence number of this block. End seqnum.Value }
SACKBlock represents a single contiguous SACK block.
+stateify savable
type TCP ¶
type TCP []byte
TCP represents a TCP header stored in a byte array.
func (TCP) CalculateChecksum ¶
CalculateChecksum calculates the checksum of the TCP segment. partialChecksum is the checksum of the network-layer pseudo-header and the checksum of the segment data.
func (TCP) DataOffset ¶
DataOffset returns the "data offset" field of the TCP header. The return value is the length of the TCP header in bytes.
func (TCP) DestinationPort ¶
DestinationPort returns the "destination port" field of the TCP header.
func (TCP) EncodePartial ¶
func (b TCP) EncodePartial(partialChecksum, length uint16, seqnum, acknum uint32, flags TCPFlags, rcvwnd uint16)
EncodePartial updates a subset of the fields of the TCP header. It is useful in cases when similar segments are produced.
func (TCP) IsChecksumValid ¶
IsChecksumValid returns true iff the TCP header's checksum is valid.
func (TCP) ParsedOptions ¶
func (b TCP) ParsedOptions() TCPOptions
ParsedOptions returns a TCPOptions structure which parses and caches the TCP option values in the TCP segment. NOTE: Invoking this function repeatedly is expensive as it reparses the options on each invocation.
func (TCP) SequenceNumber ¶
SequenceNumber returns the "sequence number" field of the TCP header.
func (TCP) SetAckNumber ¶
SetAckNumber sets the ack number field of the TCP header.
func (TCP) SetChecksum ¶
SetChecksum sets the checksum field of the TCP header.
func (TCP) SetDataOffset ¶
SetDataOffset sets the data offset field of the TCP header. headerLen should be the length of the TCP header in bytes.
func (TCP) SetDestinationPort ¶
SetDestinationPort sets the "destination port" field of the TCP header.
func (TCP) SetDestinationPortWithChecksumUpdate ¶
SetDestinationPortWithChecksumUpdate implements ChecksummableTransport.
func (TCP) SetSequenceNumber ¶
SetSequenceNumber sets the sequence number field of the TCP header.
func (TCP) SetSourcePort ¶
SetSourcePort sets the "source port" field of the TCP header.
func (TCP) SetSourcePortWithChecksumUpdate ¶
SetSourcePortWithChecksumUpdate implements ChecksummableTransport.
func (TCP) SetUrgentPointer ¶
SetUrgentPointer sets the window size field of the TCP header.
func (TCP) SetWindowSize ¶
SetWindowSize sets the window size field of the TCP header.
func (TCP) SourcePort ¶
SourcePort returns the "source port" field of the TCP header.
func (TCP) UpdateChecksumPseudoHeaderAddress ¶
UpdateChecksumPseudoHeaderAddress implements ChecksummableTransport.
func (TCP) UrgentPointer ¶
UrgentPointer returns the "urgent pointer" field of the TCP header.
func (TCP) WindowSize ¶
WindowSize returns the "window size" field of the TCP header.
type TCPFields ¶
type TCPFields struct { // SrcPort is the "source port" field of a TCP packet. SrcPort uint16 // DstPort is the "destination port" field of a TCP packet. DstPort uint16 // SeqNum is the "sequence number" field of a TCP packet. SeqNum uint32 // AckNum is the "acknowledgement number" field of a TCP packet. AckNum uint32 // DataOffset is the "data offset" field of a TCP packet. It is the length of // the TCP header in bytes. DataOffset uint8 // Flags is the "flags" field of a TCP packet. Flags TCPFlags // WindowSize is the "window size" field of a TCP packet. WindowSize uint16 // Checksum is the "checksum" field of a TCP packet. Checksum uint16 // UrgentPointer is the "urgent pointer" field of a TCP packet. UrgentPointer uint16 }
TCPFields contains the fields of a TCP packet. It is used to describe the fields of a packet that needs to be encoded.
type TCPFlags ¶
type TCPFlags uint8
TCPFlags is the dedicated type for TCP flags.
Flags that may be set in a TCP segment.
func (TCPFlags) Intersects ¶
Intersects returns true iff there are flags common to both f and o.
type TCPOptions ¶
type TCPOptions struct { // TS is true if the TimeStamp option is enabled. TS bool // TSVal is the value in the TSVal field of the segment. TSVal uint32 // TSEcr is the value in the TSEcr field of the segment. TSEcr uint32 // SACKBlocks are the SACK blocks specified in the segment. SACKBlocks []SACKBlock }
TCPOptions are used to parse and cache the TCP segment options for a non syn/syn-ack segment.
+stateify savable
func ParseTCPOptions ¶
func ParseTCPOptions(b []byte) TCPOptions
ParseTCPOptions extracts and stores all known options in the provided byte slice in a TCPOptions structure.
type TCPSynOptions ¶
type TCPSynOptions struct { // MSS is the maximum segment size provided by the peer in the SYN. MSS uint16 // WS is the window scale option provided by the peer in the SYN. // // Set to -1 if no window scale option was provided. WS int // TS is true if the timestamp option was provided in the syn/syn-ack. TS bool // TSVal is the value of the TSVal field in the timestamp option. TSVal uint32 // TSEcr is the value of the TSEcr field in the timestamp option. TSEcr uint32 // SACKPermitted is true if the SACK option was provided in the SYN/SYN-ACK. SACKPermitted bool }
TCPSynOptions is used to return the parsed TCP Options in a syn segment.
func ParseSynOptions ¶
func ParseSynOptions(opts []byte, isAck bool) TCPSynOptions
ParseSynOptions parses the options received in a SYN segment and returns the relevant ones. opts should point to the option part of the TCP header.
type Transport ¶
type Transport interface { // SourcePort returns the value of the "source port" field. SourcePort() uint16 // Destination returns the value of the "destination port" field. DestinationPort() uint16 // Checksum returns the value of the "checksum" field. Checksum() uint16 // SetSourcePort sets the value of the "source port" field. SetSourcePort(uint16) // SetDestinationPort sets the value of the "destination port" field. SetDestinationPort(uint16) // SetChecksum sets the value of the "checksum" field. SetChecksum(uint16) // Payload returns the data carried in the transport buffer. Payload() []byte }
Transport offers generic methods to query and/or update the fields of the header of a transport protocol buffer.
type UDP ¶
type UDP []byte
UDP represents a UDP header stored in a byte array.
func (UDP) CalculateChecksum ¶
CalculateChecksum calculates the checksum of the UDP packet, given the checksum of the network-layer pseudo-header and the checksum of the payload.
func (UDP) DestinationPort ¶
DestinationPort returns the "destination port" field of the UDP header.
func (UDP) IsChecksumValid ¶
IsChecksumValid returns true iff the UDP header's checksum is valid.
func (UDP) SetChecksum ¶
SetChecksum sets the "checksum" field of the UDP header.
func (UDP) SetDestinationPort ¶
SetDestinationPort sets the "destination port" field of the UDP header.
func (UDP) SetDestinationPortWithChecksumUpdate ¶
SetDestinationPortWithChecksumUpdate implements ChecksummableTransport.
func (UDP) SetSourcePort ¶
SetSourcePort sets the "source port" field of the UDP header.
func (UDP) SetSourcePortWithChecksumUpdate ¶
SetSourcePortWithChecksumUpdate implements ChecksummableTransport.
func (UDP) SourcePort ¶
SourcePort returns the "source port" field of the UDP header.
type UDPFields ¶
type UDPFields struct { // SrcPort is the "source port" field of a UDP packet. SrcPort uint16 // DstPort is the "destination port" field of a UDP packet. DstPort uint16 // Length is the "length" field of a UDP packet. Length uint16 // Checksum is the "checksum" field of a UDP packet. Checksum uint16 }
UDPFields contains the fields of a UDP packet. It is used to describe the fields of a packet that needs to be encoded.
type VirtioNetHeader ¶
type VirtioNetHeader []byte
VirtioNetHeader represents a virtio net header stored in a byte array.
func (VirtioNetHeader) CSumOffset ¶
func (v VirtioNetHeader) CSumOffset() uint16
CSumOffset returns the "csumOffset" field of the virtio net header.
func (VirtioNetHeader) CSumStart ¶
func (v VirtioNetHeader) CSumStart() uint16
CSumStart returns the "csumStart" field of the virtio net header.
func (VirtioNetHeader) Encode ¶
func (v VirtioNetHeader) Encode(f *VirtioNetHeaderFields)
Encode encodes all the fields of the virtio net header.
func (VirtioNetHeader) Flags ¶
func (v VirtioNetHeader) Flags() uint8
Flags returns the "flags" field of the virtio net header.
func (VirtioNetHeader) GSOSize ¶
func (v VirtioNetHeader) GSOSize() uint16
GSOSize returns the "gsoSize" field of the virtio net header.
func (VirtioNetHeader) GSOType ¶
func (v VirtioNetHeader) GSOType() uint8
GSOType returns the "gsoType" field of the virtio net header.
func (VirtioNetHeader) HdrLen ¶
func (v VirtioNetHeader) HdrLen() uint16
HdrLen returns the "hdrLen" field of the virtio net header.
Source Files ¶
- arp.go
- checksum.go
- eth.go
- gue.go
- icmpv4.go
- icmpv6.go
- igmp.go
- interfaces.go
- ipv4.go
- ipv6.go
- ipv6_extension_headers.go
- ipv6_fragment.go
- mld.go
- ndp_neighbor_advert.go
- ndp_neighbor_solicit.go
- ndp_options.go
- ndp_router_advert.go
- ndp_router_solicit.go
- ndpoptionidentifier_string.go
- tcp.go
- udp.go
- virtionet.go