slayers

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Overview

Package slayers contains gopacket style layers for the SCION Header, HopByHop and EndToEnd Extension headers, SCMP, and SCION/UDP.

Basic Decoding

There are multiple ways to decode a SCION packet. If performance is of no concern a new gopacket.Packet can be instantiated:

// Eagerly decode an entire SCION packet
packet := gopacket.NewPacket(raw, LayerTypeSCION, gopacket.Default)
// Access the SCION header
if scnL := packet.Layer(LayerTypeSCION); scnL != nil {
	fmt.Println("This is a SCION packet.")
	// Access the actual SCION data from this layer
	s := scnL.(*slayers.SCION) // Guaranteed to work
	fmt.Printf("From %s to %s\n", s.SrcIA, s.DstIA)
}
// Similarly, a SCION/UDP payload can be accessed
if udpL := packet.Layer(LayerTypeSCIONUDP); udpL != nil {
	u := udpL.(*slayers.UDP) // Guaranteed to work
	fmt.Printf("From %d to %d\n", u.SrcPort, u.DstPort)
}

Decoding using gopacket.DecodingLayerParser

Decoding using gopacket.DecodingLayerParser can yield speed ups for more than 10x compared to eager decoding. The following can be used to decode any SCION packet (including HBH and E2E extension) that have either a SCION/UDP or SCMP payload:

var scn slayers.SCION
var hbh slayers.HopByHopExtnSkipper
var e2e slayers.EndToEndExtnSkipper
var udp slayers.UDP
var scmp slayers.SCMP
var pld gopacket.Payload
parser := gopacket.NewDecodingLayerParser(LayerTypeSCION, &scn, &hbh, &e2e, &udp, &scmp, &pld)
decoded := []gopacket.LayerType{}
if err := parser.DecodeLayers(packetData, &decoded); err != nil {
	// Handle error
}
for _, layerType := range decoded {
	// Handle layers
}

The important thing to note here is that the parser is modifying the passed in layers (scn, hbh, e2e, udp, scmp) instead of allocating new ones, thus greatly speeding up the decoding process. It's even branching based on layer type... it'll handle an (scn, e2e, udp) or (scn, hbh, scmp) stack.

Note: Great care has been taken to only lazily parse the SCION header, however, HBH and E2E extensions are currently eagerly parsed (if they exist). Thus, handling packets containing these extensions will be much slower (see the package benchmarks for reference). When using the DecodingLayerParser, the extensions can be explicitly skipped by using the HopByHop/EndToEndExtnSkipper layer. The content of this Skipper-layer can be decoded into the full representation when necessary.

Creating Packet Data

Packet data can be created by instantiating the various slayers.* types. To generate an empty (and useless) SCION(HBH(UDP(Payload))) packet, for example, you can run:

s := &slayers.SCION{}
hbh := &slayers.HopByHopExtn{}
udp := &slayers.UDP{}
pld := gopacket.Payload([]byte{1, 2, 3, 4}))
buf := gopacket.NewSerializeBuffer()
opts := gopacket.SerializeOptions{}
if err := gopacket.SerializeLayers(buf, opts, s, hbh, udp, pld); err != nil {
	// Handle error
}
packedData := buf.Bytes()

BFD and gopacket/layers

slayers does intentionally not import gopacket/layers, as this contains a considerable amount of bloat in the form of layer types that are never used by most users of the slayers package. At the same time, the slayers.SCION layer supports parsing SCION/BFD packets using the gopacket/layers.BFD layer type. Applications that want to parse SCION/BFD packets need to ensure that gopacket/layers is imported somewhere in the application so that the corresponding layer decoder is registered. Note that this is naturally ensured when using the DecodingLayer style.

Index

Constants

View Source
const (
	PacketAuthASHost uint8 = iota
	PacketAuthHostHost
)
View Source
const (
	PacketAuthSenderSide uint8 = iota
	PacketAuthReceiverSide
)
View Source
const (
	// LineLen is the length of a SCION header line in bytes.
	LineLen = 4
	// CmnHdrLen is the length of the SCION common header in bytes.
	CmnHdrLen = 12
	// MaxHdrLen is the maximum allowed length of a SCION header in bytes.
	MaxHdrLen = 1020
	// SCIONVersion is the currently supported version of the SCION header format. Different
	// versions are not guaranteed to be compatible to each other.
	SCIONVersion = 0
)
View Source
const (
	T4Ip  AddrType = 0b0000 // T=0, L=0
	T4Svc          = 0b0100 // T=1, L=0
	T16Ip          = 0b0011 // T=0, L=3
)

AddrType constants

View Source
const MaxSCMPPacketLen = 1232

MaxSCMPPacketLen the maximum length a SCION packet including SCMP quote can have. This length includes the SCION, and SCMP header of the packet.

+-------------------------+
|        Underlay         |
+-------------------------+
|          SCION          |  \
|          SCMP           |   \
+-------------------------+    \_ MaxSCMPPacketLen
|          Quote:         |    /
|        SCION Orig       |   /
|         L4 Orig         |  /
+-------------------------+
View Source
const (
	// PacketAuthOptionMetadataLen is the size of the SPAO Metadata and
	// corresponds the minimum size of the SPAO OptData.
	// The SPAO header contains the following fixed-length fields:
	// SPI (4 Bytes), Algorithm (1 Byte), RSV (1 Byte) and
	// Timestamp / Sequence Number (6 Bytes).
	PacketAuthOptionMetadataLen = 12
)

Variables

View Source
var (
	LayerTypeSCION = gopacket.RegisterLayerType(
		1000,
		gopacket.LayerTypeMetadata{
			Name:    "SCION",
			Decoder: gopacket.DecodeFunc(decodeSCION),
		},
	)
	LayerClassSCION gopacket.LayerClass = LayerTypeSCION

	LayerTypeSCIONUDP = gopacket.RegisterLayerType(
		1001,
		gopacket.LayerTypeMetadata{
			Name:    "SCION/UDP",
			Decoder: gopacket.DecodeFunc(decodeSCIONUDP),
		},
	)
	LayerClassSCIONUDP gopacket.LayerClass = LayerTypeSCIONUDP

	LayerTypeSCMP = gopacket.RegisterLayerType(
		1002,
		gopacket.LayerTypeMetadata{
			Name:    "SCMP",
			Decoder: gopacket.DecodeFunc(decodeSCMP),
		},
	)
	LayerClassSCMP gopacket.LayerClass = LayerTypeSCMP

	LayerTypeHopByHopExtn = gopacket.RegisterLayerType(
		1003,
		gopacket.LayerTypeMetadata{
			Name:    "HopByHopExtn",
			Decoder: gopacket.DecodeFunc(decodeHopByHopExtn),
		},
	)
	LayerClassHopByHopExtn gopacket.LayerClass = LayerTypeHopByHopExtn

	LayerTypeEndToEndExtn = gopacket.RegisterLayerType(
		1004,
		gopacket.LayerTypeMetadata{
			Name:    "EndToEndExtn",
			Decoder: gopacket.DecodeFunc(decodeEndToEndExtn),
		},
	)
	LayerClassEndToEndExtn gopacket.LayerClass = LayerTypeEndToEndExtn

	LayerTypeSCMPExternalInterfaceDown = gopacket.RegisterLayerType(
		1005,
		gopacket.LayerTypeMetadata{
			Name:    "SCMPExternalInterfaceDown",
			Decoder: gopacket.DecodeFunc(decodeSCMPExternalInterfaceDown),
		},
	)
	LayerTypeSCMPInternalConnectivityDown = gopacket.RegisterLayerType(
		1006,
		gopacket.LayerTypeMetadata{
			Name:    "SCMPInternalConnectivityDown",
			Decoder: gopacket.DecodeFunc(decodeSCMPInternalConnectivityDown),
		},
	)
	LayerTypeSCMPParameterProblem = gopacket.RegisterLayerType(
		1007,
		gopacket.LayerTypeMetadata{
			Name:    "SCMPParameterProblem",
			Decoder: gopacket.DecodeFunc(decodeSCMPParameterProblem),
		},
	)
	LayerTypeSCMPDestinationUnreachable = gopacket.RegisterLayerType(
		1008,
		gopacket.LayerTypeMetadata{
			Name:    "SCMPDestinationUnreachable",
			Decoder: gopacket.DecodeFunc(decodeSCMPDestinationUnreachable),
		},
	)
	LayerTypeSCMPPacketTooBig = gopacket.RegisterLayerType(
		1009,
		gopacket.LayerTypeMetadata{
			Name:    "SCMPPacketTooBig",
			Decoder: gopacket.DecodeFunc(decodeSCMPPacketTooBig),
		},
	)
	LayerTypeSCMPEcho = gopacket.RegisterLayerType(
		1128,
		gopacket.LayerTypeMetadata{
			Name:    "SCMPEcho",
			Decoder: gopacket.DecodeFunc(decodeSCMPEcho),
		},
	)
	LayerTypeSCMPTraceroute = gopacket.RegisterLayerType(
		1130,
		gopacket.LayerTypeMetadata{
			Name:    "SCMPTraceroute",
			Decoder: gopacket.DecodeFunc(decodeSCMPTraceroute),
		},
	)

	EndpointUDPPort = gopacket.RegisterEndpointType(
		1005,
		gopacket.EndpointTypeMetadata{
			Name: "UDP",
			Formatter: func(b []byte) string {
				return strconv.Itoa(int(binary.BigEndian.Uint16(b)))
			},
		},
	)
)
View Source
var (
	ErrOptionNotFound = serrors.New("Option not found")
)

Functions

func ParseAddr added in v0.9.0

func ParseAddr(addrType AddrType, raw []byte) (addr.Host, error)

Types

type AddrType

type AddrType uint8

AddrType indicates the type of a host address in the SCION header. The AddrType consists of a sub-type and length part, both two bits wide. The four possible lengths are 4B (0), 8B (1), 12B (2), or 16B (3) bytes. There are four possible sub-types per address length.

func PackAddr added in v0.9.0

func PackAddr(host addr.Host) (AddrType, []byte, error)

func (AddrType) Length added in v0.9.0

func (tl AddrType) Length() int

Length returns the length of this AddrType value.

type BaseLayer

type BaseLayer struct {
	// Contents is the set of bytes that make up this layer.  IE: for an
	// Ethernet packet, this would be the set of bytes making up the
	// Ethernet frame.
	Contents []byte
	// Payload is the set of bytes contained by (but not part of) this
	// Layer.  Again, to take Ethernet as an example, this would be the
	// set of bytes encapsulated by the Ethernet protocol.
	Payload []byte
}

BaseLayer is a convenience struct which implements the LayerData and LayerPayload functions of the Layer interface. Copy-pasted from gopacket/layers (we avoid importing this due its massive size)

func (*BaseLayer) LayerContents

func (b *BaseLayer) LayerContents() []byte

LayerContents returns the bytes of the packet layer.

func (*BaseLayer) LayerPayload

func (b *BaseLayer) LayerPayload() []byte

LayerPayload returns the bytes contained within the packet layer.

type EndToEndExtn

type EndToEndExtn struct {
	Options []*EndToEndOption
	// contains filtered or unexported fields
}

EndToEndExtn is the SCION end-to-end options extension.

func (*EndToEndExtn) CanDecode

func (e *EndToEndExtn) CanDecode() gopacket.LayerClass

func (*EndToEndExtn) DecodeFromBytes

func (e *EndToEndExtn) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error

DecodeFromBytes implementation according to gopacket.DecodingLayer.

func (*EndToEndExtn) FindOption

func (e *EndToEndExtn) FindOption(typ OptionType) (*EndToEndOption, error)

FindOption returns the first option entry of the given type if any exists, or ErrOptionNotFound otherwise.

func (*EndToEndExtn) LayerPayload

func (e *EndToEndExtn) LayerPayload() []byte

func (*EndToEndExtn) LayerType

func (e *EndToEndExtn) LayerType() gopacket.LayerType

func (*EndToEndExtn) NextLayerType

func (e *EndToEndExtn) NextLayerType() gopacket.LayerType

func (*EndToEndExtn) SerializeTo

SerializeTo implementation according to gopacket.SerializableLayer

type EndToEndExtnSkipper

type EndToEndExtnSkipper struct {
	// contains filtered or unexported fields
}

EndToEndExtnSkipper is a DecodingLayer which decodes an EndToEnd extension without parsing its content. This can be used with a DecodingLayerParser to handle SCION packets which may or may not have an EndToEnd extension.

func (*EndToEndExtnSkipper) CanDecode

func (s *EndToEndExtnSkipper) CanDecode() gopacket.LayerClass

func (*EndToEndExtnSkipper) DecodeFromBytes

func (s *EndToEndExtnSkipper) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error

DecodeFromBytes implementation according to gopacket.DecodingLayer

func (*EndToEndExtnSkipper) LayerType

func (e *EndToEndExtnSkipper) LayerType() gopacket.LayerType

func (*EndToEndExtnSkipper) NextLayerType

func (e *EndToEndExtnSkipper) NextLayerType() gopacket.LayerType

type EndToEndOption

type EndToEndOption tlvOption

EndToEndOption is a TLV option present in a SCION end-to-end extension.

type HopByHopExtn

type HopByHopExtn struct {
	Options []*HopByHopOption
	// contains filtered or unexported fields
}

HopByHopExtn is the SCION hop-by-hop options extension.

func (*HopByHopExtn) CanDecode

func (h *HopByHopExtn) CanDecode() gopacket.LayerClass

func (*HopByHopExtn) DecodeFromBytes

func (h *HopByHopExtn) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error

DecodeFromBytes implementation according to gopacket.DecodingLayer.

func (*HopByHopExtn) LayerPayload

func (h *HopByHopExtn) LayerPayload() []byte

func (*HopByHopExtn) LayerType

func (h *HopByHopExtn) LayerType() gopacket.LayerType

func (*HopByHopExtn) NextLayerType

func (h *HopByHopExtn) NextLayerType() gopacket.LayerType

func (*HopByHopExtn) SerializeTo

SerializeTo implementation according to gopacket.SerializableLayer.

type HopByHopExtnSkipper

type HopByHopExtnSkipper struct {
	// contains filtered or unexported fields
}

HopByHopExtnSkipper is a DecodingLayer which decodes a HopByHop extension without parsing its content. This can be used with a DecodingLayerParser to handle SCION packets which may or may not have a HopByHop extension.

func (*HopByHopExtnSkipper) CanDecode

func (s *HopByHopExtnSkipper) CanDecode() gopacket.LayerClass

func (*HopByHopExtnSkipper) DecodeFromBytes

func (s *HopByHopExtnSkipper) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error

DecodeFromBytes implementation according to gopacket.DecodingLayer

func (*HopByHopExtnSkipper) LayerType

func (e *HopByHopExtnSkipper) LayerType() gopacket.LayerType

func (*HopByHopExtnSkipper) NextLayerType

func (h *HopByHopExtnSkipper) NextLayerType() gopacket.LayerType

type HopByHopOption

type HopByHopOption tlvOption

HopByHopOption is a TLV option present in a SCION hop-by-hop extension.

type L4ProtocolType

type L4ProtocolType uint8
const (
	L4None L4ProtocolType = 0
	L4TCP  L4ProtocolType = 6
	L4UDP  L4ProtocolType = 17
	L4SCMP L4ProtocolType = 202
	L4BFD  L4ProtocolType = 203

	HopByHopClass L4ProtocolType = 200
	End2EndClass  L4ProtocolType = 201
)

func (L4ProtocolType) String

func (p L4ProtocolType) String() string

type OptionType

type OptionType uint8

OptionType indicates the type of a TLV Option that is part of an extension header.

const (
	OptTypePad1 OptionType = iota
	OptTypePadN
	OptTypeAuthenticator
)

Definition of option type constants.

type PacketAuthAlg

type PacketAuthAlg uint8

PacketAuthAlg is the enumerator for authenticator algorithm types in the packet authenticator option.

const (
	PacketAuthCMAC PacketAuthAlg = iota
	PacketAuthSHA1_AES_CBC
)

type PacketAuthOption added in v0.9.0

type PacketAuthOption struct {
	*EndToEndOption
}

PacketAuthOption wraps an EndToEndOption of OptTypeAuthenticator. This can be used to serialize and parse the internal structure of the packet authenticator option.

func NewPacketAuthOption added in v0.9.0

func NewPacketAuthOption(
	p PacketAuthOptionParams,
) (PacketAuthOption, error)

NewPacketAuthOption creates a new EndToEndOption of OptTypeAuthenticator, initialized with the given SPAO data.

func ParsePacketAuthOption added in v0.9.0

func ParsePacketAuthOption(o *EndToEndOption) (PacketAuthOption, error)

ParsePacketAuthOption parses o as a packet authenticator option. Performs minimal checks to ensure that SPI, algorithm, timestamp, RSV, and sequence number are set. Checking the size and content of the Authenticator data must be done by the caller.

func (PacketAuthOption) Algorithm added in v0.9.0

func (o PacketAuthOption) Algorithm() PacketAuthAlg

Algorithm returns the algorithm type stored in the data buffer.

func (PacketAuthOption) Authenticator added in v0.9.0

func (o PacketAuthOption) Authenticator() []byte

Authenticator returns slice of the underlying auth buffer. Changes to this slice will be reflected on the wire when the extension is serialized.

func (PacketAuthOption) Reset added in v0.9.0

Reset reinitializes the underlying EndToEndOption with the SPAO data. Reuses the OptData buffer if it is of sufficient capacity.

func (PacketAuthOption) SPI added in v0.9.0

SPI returns the value set in the Security Parameter Index in the extension.

func (PacketAuthOption) TimestampSN added in v0.9.0

func (o PacketAuthOption) TimestampSN() uint64

Timestamp returns the value set in the homonym field in the extension.

type PacketAuthOptionParams added in v0.9.0

type PacketAuthOptionParams struct {
	SPI         PacketAuthSPI
	Algorithm   PacketAuthAlg
	TimestampSN uint64
	Auth        []byte
}

type PacketAuthSPI added in v0.9.0

type PacketAuthSPI uint32

PacketAuthSPI (Security Parameter Index) is the identifier for the key used for the packet authentication option. DRKey values are in the range [1, 2^21-1].

func MakePacketAuthSPIDRKey added in v0.9.0

func MakePacketAuthSPIDRKey(
	proto uint16,
	drkeyType uint8,
	dir uint8,
) (PacketAuthSPI, error)

func (PacketAuthSPI) DRKeyProto added in v0.9.0

func (p PacketAuthSPI) DRKeyProto() uint16

func (PacketAuthSPI) Direction added in v0.9.0

func (p PacketAuthSPI) Direction() uint8

func (PacketAuthSPI) IsDRKey added in v0.9.0

func (p PacketAuthSPI) IsDRKey() bool

func (PacketAuthSPI) Type added in v0.9.0

func (p PacketAuthSPI) Type() uint8

type SCION

type SCION struct {
	BaseLayer

	// Version is version of the SCION Header. Currently, only 0 is supported.
	Version uint8
	// TrafficClass denotes the traffic class. Its value in a received packet or fragment might be
	// different from the value sent by the packet’s source. The current use of the Traffic Class
	// field for Differentiated Services and Explicit Congestion Notification is specified in
	// RFC2474 and RFC3168
	TrafficClass uint8
	// FlowID is a 20-bit field used by a source to label sequences of packets to be treated in the
	// network as a single flow. It is mandatory to be set.
	FlowID uint32
	// NextHdr  encodes the type of the first header after the SCION header. This can be either a
	// SCION extension or a layer-4 protocol such as TCP or UDP. Values of this field respect and
	// extend IANA’s assigned internet protocol numbers.
	NextHdr L4ProtocolType
	// HdrLen is the length of the SCION header in multiples of 4 bytes. The SCION header length is
	// computed as HdrLen * 4 bytes. The 8 bits of the HdrLen field limit the SCION header to a
	// maximum of 255 * 4 == 1020 bytes.
	HdrLen uint8
	// PayloadLen is the length of the payload in bytes. The payload includes extension headers and
	// the L4 payload. This field is 16 bits long, supporting a maximum payload size of 64KB.
	PayloadLen uint16
	// PathType specifies the type of path in this SCION header.
	PathType path.Type
	// DstAddrType (4 bit) is the type/length of the destination address.
	DstAddrType AddrType
	// SrcAddrType (4 bit) is the type/length of the source address.
	SrcAddrType AddrType

	// DstIA is the destination ISD-AS.
	DstIA addr.IA
	// SrcIA is the source ISD-AS.
	SrcIA addr.IA
	// RawDstAddr is the destination address.
	RawDstAddr []byte
	// RawSrcAddr is the source address.
	RawSrcAddr []byte

	// Path is the path contained in the SCION header. It depends on the PathType field.
	Path path.Path
	// contains filtered or unexported fields
}

SCION is the header of a SCION packet.

func (*SCION) AddrHdrLen

func (s *SCION) AddrHdrLen() int

AddrHdrLen returns the length of the address header (destination and source ISD-AS-Host triples) in bytes.

func (*SCION) CanDecode

func (s *SCION) CanDecode() gopacket.LayerClass

func (*SCION) DecodeAddrHdr

func (s *SCION) DecodeAddrHdr(data []byte) error

DecodeAddrHdr decodes the destination and source ISD-AS-Host address triples from the provided buffer. The caller must ensure that the correct address types and lengths are set in the SCION layer, otherwise the results of this method are undefined.

func (*SCION) DecodeFromBytes

func (s *SCION) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error

DecodeFromBytes decodes the SCION layer. DecodeFromBytes resets the internal state of this layer to the state defined by the passed-in bytes. Slices in the SCION layer reference the passed-in data, so care should be taken to copy it first should later modification of data be required before the SCION layer is discarded.

func (*SCION) DstAddr

func (s *SCION) DstAddr() (addr.Host, error)

DstAddr parses the destination address into a addr.Host.

func (*SCION) LayerPayload

func (s *SCION) LayerPayload() []byte

func (*SCION) LayerType

func (s *SCION) LayerType() gopacket.LayerType

func (*SCION) NetworkFlow

func (s *SCION) NetworkFlow() gopacket.Flow

func (*SCION) NextLayerType

func (s *SCION) NextLayerType() gopacket.LayerType

func (*SCION) RecyclePaths

func (s *SCION) RecyclePaths()

RecyclePaths enables recycling of paths used for DecodeFromBytes. This is only useful if the layer itself is reused. When this is enabled, the Path instance may be overwritten in DecodeFromBytes. No references to Path should be kept in use between invocations of DecodeFromBytes.

func (*SCION) SerializeAddrHdr

func (s *SCION) SerializeAddrHdr(buf []byte) error

SerializeAddrHdr serializes destination and source ISD-AS-Host address triples into the provided buffer. The caller must ensure that the correct address types and lengths are set in the SCION layer, otherwise the results of this method are undefined.

func (*SCION) SerializeTo

func (s *SCION) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error

func (*SCION) SetDstAddr

func (s *SCION) SetDstAddr(dst addr.Host) error

SetDstAddr sets the destination address and updates the DstAddrType field accordingly.

func (*SCION) SetSrcAddr

func (s *SCION) SetSrcAddr(src addr.Host) error

SetSrcAddr sets the source address and updates the DstAddrType field accordingly.

func (*SCION) SrcAddr

func (s *SCION) SrcAddr() (addr.Host, error)

SrcAddr parses the source address into a addr.Host.

type SCMP

type SCMP struct {
	BaseLayer
	TypeCode SCMPTypeCode
	Checksum uint16
	// contains filtered or unexported fields
}

SCMP is the SCMP header on top of SCION header.

 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            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            InfoBlock                          |
+                                                               +
|                         (variable length)                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            DataBlock                          |
+                                                               +
|                         (variable length)                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*SCMP) CanDecode

func (s *SCMP) CanDecode() gopacket.LayerClass

CanDecode returns the set of layer types that this DecodingLayer can decode.

func (*SCMP) DecodeFromBytes

func (s *SCMP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error

DecodeFromBytes decodes the given bytes into this layer.

func (*SCMP) LayerType

func (s *SCMP) LayerType() gopacket.LayerType

LayerType returns LayerTypeSCMP.

func (*SCMP) NextLayerType

func (s *SCMP) NextLayerType() gopacket.LayerType

NextLayerType use the typecode to select the right next decoder. If the SCMP type is unknown, the next layer is gopacket.LayerTypePayload.

func (*SCMP) SerializeTo

func (s *SCMP) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error

SerializeTo writes the serialized form of this layer into the SerializationBuffer, implementing gopacket.SerializableLayer.

func (*SCMP) SetNetworkLayerForChecksum

func (s *SCMP) SetNetworkLayerForChecksum(scn *SCION)

SetNetworkLayerForChecksum tells this layer which network layer is wrapping it. This is needed for computing the checksum when serializing,

func (*SCMP) String

func (s *SCMP) String() string

type SCMPCode

type SCMPCode uint8

SCMPCode is the code of the SCMP type code.

const (
	SCMPCodeNoRoute                   SCMPCode = 0
	SCMPCodeAdminDeny                 SCMPCode = 1
	SCMPCodeBeyondScopeOfSourceAddr   SCMPCode = 2
	SCMPCodeAddressUnreachable        SCMPCode = 3
	SCMPCodePortUnreachable           SCMPCode = 4
	SCMPCodeSourceAddressFailedPolicy SCMPCode = 5
	SCMPCodeRejectRouteToDest         SCMPCode = 6
)

Destination unreachable codes

const (
	SCMPCodeErroneousHeaderField SCMPCode = 0
	SCMPCodeUnknownNextHdrType   SCMPCode = 1

	SCMPCodeInvalidCommonHeader  SCMPCode = 16
	SCMPCodeUnknownSCIONVersion  SCMPCode = 17
	SCMPCodeFlowIDRequired       SCMPCode = 18
	SCMPCodeInvalidPacketSize    SCMPCode = 19
	SCMPCodeUnknownPathType      SCMPCode = 20
	SCMPCodeUnknownAddressFormat SCMPCode = 21

	SCMPCodeInvalidAddressHeader      SCMPCode = 32
	SCMPCodeInvalidSourceAddress      SCMPCode = 33
	SCMPCodeInvalidDestinationAddress SCMPCode = 34
	SCMPCodeNonLocalDelivery          SCMPCode = 35

	SCMPCodeInvalidPath            SCMPCode = 48
	SCMPCodeUnknownHopFieldIngress SCMPCode = 49
	SCMPCodeUnknownHopFieldEgress  SCMPCode = 50
	SCMPCodeInvalidHopFieldMAC     SCMPCode = 51
	SCMPCodePathExpired            SCMPCode = 52
	SCMPCodeInvalidSegmentChange   SCMPCode = 53

	SCMPCodeInvalidExtensionHeader SCMPCode = 64
	SCMPCodeUnknownHopByHopOption  SCMPCode = 65
	SCMPCodeUnknownEndToEndOption  SCMPCode = 66
)

ParameterProblem

type SCMPDestinationUnreachable

type SCMPDestinationUnreachable struct {
	BaseLayer
}

SCMPDestinationUnreachable represents the structure of a destination unreachable message.

 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             Unused                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*SCMPDestinationUnreachable) DecodeFromBytes

func (i *SCMPDestinationUnreachable) DecodeFromBytes(data []byte,
	df gopacket.DecodeFeedback) error

DecodeFromBytes decodes the given bytes into this layer.

func (*SCMPDestinationUnreachable) LayerType

LayerType returns LayerTypeSCMPTraceroute.

func (*SCMPDestinationUnreachable) NextLayerType

NextLayerType returns the layer type contained by this DecodingLayer.

func (*SCMPDestinationUnreachable) SerializeTo

SerializeTo writes the serialized form of this layer into the SerializationBuffer, implementing gopacket.SerializableLayer.

type SCMPEcho

type SCMPEcho struct {
	BaseLayer
	Identifier uint16
	SeqNumber  uint16
}

SCMPEcho represents the structure of a ping.

 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Identifier          |        Sequence Number        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*SCMPEcho) DecodeFromBytes

func (i *SCMPEcho) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error

DecodeFromBytes decodes the given bytes into this layer.

func (*SCMPEcho) LayerType

func (*SCMPEcho) LayerType() gopacket.LayerType

LayerType returns LayerTypeSCMPEcho.

func (*SCMPEcho) NextLayerType

func (*SCMPEcho) NextLayerType() gopacket.LayerType

NextLayerType returns the layer type contained by this DecodingLayer.

func (*SCMPEcho) SerializeTo

SerializeTo writes the serialized form of this layer into the SerializationBuffer, implementing gopacket.SerializableLayer.

type SCMPExternalInterfaceDown

type SCMPExternalInterfaceDown struct {
	BaseLayer
	IA   addr.IA
	IfID uint64
}

SCMPExternalInterfaceDown message contains the data for that error.

 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              ISD              |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+         AS                    +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                        Interface ID                           +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*SCMPExternalInterfaceDown) DecodeFromBytes

func (i *SCMPExternalInterfaceDown) DecodeFromBytes(data []byte,
	df gopacket.DecodeFeedback) error

DecodeFromBytes decodes the given bytes into this layer.

func (*SCMPExternalInterfaceDown) LayerType

LayerType returns LayerTypeSCMPExternalInterfaceDown.

func (*SCMPExternalInterfaceDown) NextLayerType

func (i *SCMPExternalInterfaceDown) NextLayerType() gopacket.LayerType

NextLayerType returns the layer type contained by this DecodingLayer.

func (*SCMPExternalInterfaceDown) SerializeTo

SerializeTo writes the serialized form of this layer into the SerializationBuffer, implementing gopacket.SerializableLayer.

type SCMPInternalConnectivityDown

type SCMPInternalConnectivityDown struct {
	BaseLayer
	IA      addr.IA
	Ingress uint64
	Egress  uint64
}

SCMPInternalConnectivityDown indicates the AS internal connection between 2 routers is down. The format is as follows:

 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              ISD              |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+         AS                    +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                   Ingress Interface ID                        +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                   Egress Interface ID                         +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*SCMPInternalConnectivityDown) DecodeFromBytes

func (i *SCMPInternalConnectivityDown) DecodeFromBytes(data []byte,
	df gopacket.DecodeFeedback) error

DecodeFromBytes decodes the given bytes into this layer.

func (*SCMPInternalConnectivityDown) LayerType

LayerType returns LayerTypeSCMPInternalConnectivityDown.

func (*SCMPInternalConnectivityDown) NextLayerType

NextLayerType returns the layer type contained by this DecodingLayer.

func (*SCMPInternalConnectivityDown) SerializeTo

SerializeTo writes the serialized form of this layer into the SerializationBuffer, implementing gopacket.SerializableLayer.

type SCMPPacketTooBig

type SCMPPacketTooBig struct {
	BaseLayer
	MTU uint16
}

SCMPPacketTooBig represents the structure of a packet too big message.

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            reserved           |             MTU               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*SCMPPacketTooBig) DecodeFromBytes

func (i *SCMPPacketTooBig) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error

DecodeFromBytes decodes the given bytes into this layer.

func (*SCMPPacketTooBig) LayerType

func (*SCMPPacketTooBig) LayerType() gopacket.LayerType

LayerType returns LayerTypeSCMPParameterProblem.

func (*SCMPPacketTooBig) NextLayerType

func (*SCMPPacketTooBig) NextLayerType() gopacket.LayerType

NextLayerType returns the layer type contained by this DecodingLayer.

func (*SCMPPacketTooBig) SerializeTo

SerializeTo writes the serialized form of this layer into the SerializationBuffer, implementing gopacket.SerializableLayer.

type SCMPParameterProblem

type SCMPParameterProblem struct {
	BaseLayer
	Pointer uint16
}

SCMPParameterProblem represents the structure of a parameter problem message.

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            reserved           |           Pointer             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*SCMPParameterProblem) DecodeFromBytes

func (i *SCMPParameterProblem) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error

DecodeFromBytes decodes the given bytes into this layer.

func (*SCMPParameterProblem) LayerType

LayerType returns LayerTypeSCMPParameterProblem.

func (*SCMPParameterProblem) NextLayerType

func (*SCMPParameterProblem) NextLayerType() gopacket.LayerType

NextLayerType returns the layer type contained by this DecodingLayer.

func (*SCMPParameterProblem) SerializeTo

SerializeTo writes the serialized form of this layer into the SerializationBuffer, implementing gopacket.SerializableLayer.

type SCMPTraceroute

type SCMPTraceroute struct {
	BaseLayer
	Identifier uint16
	Sequence   uint16
	IA         addr.IA
	Interface  uint64
}

SCMPTraceroute represents the structure of a traceroute.

 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Identifier          |        Sequence Number        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              ISD              |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+         AS                    +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                        Interface ID                           +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*SCMPTraceroute) DecodeFromBytes

func (i *SCMPTraceroute) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error

DecodeFromBytes decodes the given bytes into this layer.

func (*SCMPTraceroute) LayerType

func (*SCMPTraceroute) LayerType() gopacket.LayerType

LayerType returns LayerTypeSCMPTraceroute.

func (*SCMPTraceroute) NextLayerType

func (*SCMPTraceroute) NextLayerType() gopacket.LayerType

NextLayerType returns the layer type contained by this DecodingLayer.

func (*SCMPTraceroute) SerializeTo

SerializeTo writes the serialized form of this layer into the SerializationBuffer, implementing gopacket.SerializableLayer.

type SCMPType

type SCMPType uint8

SCMPType is the type of the SCMP type code.

const (
	SCMPTypeDestinationUnreachable   SCMPType = 1
	SCMPTypePacketTooBig             SCMPType = 2
	SCMPTypeParameterProblem         SCMPType = 4
	SCMPTypeExternalInterfaceDown    SCMPType = 5
	SCMPTypeInternalConnectivityDown SCMPType = 6
)

SCMP error messages.

const (
	SCMPTypeEchoRequest       SCMPType = 128
	SCMPTypeEchoReply         SCMPType = 129
	SCMPTypeTracerouteRequest SCMPType = 130
	SCMPTypeTracerouteReply   SCMPType = 131
)

SCMP informational messages.

type SCMPTypeCode

type SCMPTypeCode uint16

SCMPTypeCode represents SCMP type/code case.

func CreateSCMPTypeCode

func CreateSCMPTypeCode(typ SCMPType, code SCMPCode) SCMPTypeCode

CreateSCMPTypeCode is a convenience function to create an SCMPTypeCode

func (SCMPTypeCode) Code

func (a SCMPTypeCode) Code() SCMPCode

Code returns the SCMP code field.

func (SCMPTypeCode) InfoMsg

func (a SCMPTypeCode) InfoMsg() bool

InfoMsg indicates if the SCMP message is an SCMP informational message.

func (SCMPTypeCode) SerializeTo

func (a SCMPTypeCode) SerializeTo(bytes []byte)

SerializeTo writes the SCMPTypeCode value to the buffer.

func (SCMPTypeCode) String

func (a SCMPTypeCode) String() string

func (SCMPTypeCode) Type

func (a SCMPTypeCode) Type() SCMPType

Type returns the SCMP type field.

type UDP

type UDP struct {
	BaseLayer
	SrcPort, DstPort uint16
	Length           uint16
	Checksum         uint16
	// contains filtered or unexported fields
}

UDP is the SCION/UDP header. Note; this _could_ mostly reuse gopacket/layers.UDP and only customize checksum calculation, but as this pulls in every layer available in gopacket, we avoid this and implement it manually (i.e. copy-paste).

func (*UDP) CanDecode

func (u *UDP) CanDecode() gopacket.LayerClass

func (*UDP) DecodeFromBytes

func (u *UDP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error

DecodeFromBytes implements the gopacket.DecodingLayer.DecodeFromBytes method. This implementation is copied from gopacket/layers/udp.go.

func (*UDP) LayerType

func (u *UDP) LayerType() gopacket.LayerType

func (*UDP) NextLayerType

func (u *UDP) NextLayerType() gopacket.LayerType

func (*UDP) SerializeTo

func (u *UDP) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error

func (*UDP) SetNetworkLayerForChecksum

func (u *UDP) SetNetworkLayerForChecksum(scn *SCION)

func (*UDP) String

func (u *UDP) String() string

func (*UDP) TransportFlow

func (u *UDP) TransportFlow() gopacket.Flow

Directories

Path Synopsis
internal
epic
Package epic implements the Path interface for the EPIC path type.
Package epic implements the Path interface for the EPIC path type.

Jump to

Keyboard shortcuts

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