Documentation ¶
Overview ¶
This package is responsible for parsing a packet description, more specifically, an ordered list of layers definitions.
In its basic form, each layers is defined by a text line following the following sytnax:
TAG: prop1=val1 prop2=val2
where TAG serves two functions: 1. It specifies the type of layer. 2. It uniquely names a layer.
As an example:
IP4: Src=192.168.12.3 Dst=192.168.12.2 NextHdr=UDP UDP_1: Src=40000 Dst=50000 Checksum=0
The above example defines a packet with two layers, IP4 and UDP, with tags IP4 and UDP_1 respectively. Tags are useful to refer to specific layers in a packet.
The parse is indentation aware, meaning that all layers need to have the same tab indentation as the first layer.
It is also possible to define a layer which consists of multiple lines:
IP4: Src=192.168.12.3 Dst=192.168.12.2 NextHdr=UDP UDP: Src=40000 Dst=50000 Checksum=0 SCION: NextHdr=UDP CurrInfoF=4 CurrHopF=5 SrcType=IPv4 DstType=SVC ADDR: SrcIA=1-ff00:0:2 Src=172.16.2.1 DstIA=1-ff00:0:1 Dst=192.168.0.51 IF_1: ISD=1 Hops=3 Flags=Peer HF_1: ConsIngress=261 ConsEgress=0 Flags=Xover HF_2: ConsIngress=211 ConsEgress=151 Flags=Xover HF_3: ConsIngress=0 ConsEgress=621 UDP: Src=1111 Dst=2222
From the parsing point of view, everyline with deeper indentation than the layer itself belong to the layer, so in the example above, the SCION layer would consist of:
SCION: NextHdr=UDP CurrInfoF=4 CurrHopF=5 SrcType=IPv4 DstType=SVC ADDR: SrcIA=1-ff00:0:2 Src=172.16.2.1 DstIA=1-ff00:0:1 Dst=192.168.0.51 IF_1: ISD=1 Hops=3 Flags=Peer HF_1: ConsIngress=261 ConsEgress=0 Flags=Xover HF_2: ConsIngress=211 ConsEgress=151 Flags=Xover HF_3: ConsIngress=0 ConsEgress=621
Index ¶
- func HexToBytes(s string) common.RawBytes
- func HexToInt(s string) uint
- func HostAddrTypeFromString(ht string) addr.HostAddrType
- func ParseProto(enumMeta []golayers.EnumMetadata, protoName string) uint
- func SerializeLayers(w gopacket.SerializeBuffer, layers ...TaggedLayer) error
- func StrToBool(s string) bool
- func StrToInt(s string) int
- type EthernetTaggedLayer
- func (ether *EthernetTaggedLayer) Clone() TaggedLayer
- func (ether *EthernetTaggedLayer) Layer() gopacket.Layer
- func (t EthernetTaggedLayer) SerializeOptions() gopacket.SerializeOptions
- func (ether *EthernetTaggedLayer) String() string
- func (t EthernetTaggedLayer) Tag() string
- func (ether *EthernetTaggedLayer) Update(lines []string)
- type HBHTaggedLayer
- func (hbh *HBHTaggedLayer) Clone() TaggedLayer
- func (hbh *HBHTaggedLayer) Layer() gopacket.Layer
- func (hbh *HBHTaggedLayer) LayerType() gopacket.LayerType
- func (t HBHTaggedLayer) SerializeOptions() gopacket.SerializeOptions
- func (hbh *HBHTaggedLayer) String() string
- func (t HBHTaggedLayer) Tag() string
- func (hbh *HBHTaggedLayer) Update(lines []string)
- type IFStateInfoTaggedLayer
- type IFStateReqTaggedLayer
- type IP4TaggedLayer
- type InfoPathOffsets
- type InfoRevocation
- type LayerParser
- type RevInfo
- type SCMPTaggedLayer
- type ScionTaggedLayer
- func (scn *ScionTaggedLayer) Clone() TaggedLayer
- func (scn *ScionTaggedLayer) GenerateMac(hMac hash.Hash, infTag, hfTag, hfMacTag string)
- func (scn *ScionTaggedLayer) Layer() gopacket.Layer
- func (t ScionTaggedLayer) SerializeOptions() gopacket.SerializeOptions
- func (scn *ScionTaggedLayer) String() string
- func (t ScionTaggedLayer) Tag() string
- func (scn *ScionTaggedLayer) Update(lines []string)
- type SignedRevInfoTaggedLayer
- type TaggedLayer
- func EthernetParser(lines []string) TaggedLayer
- func HBHParser(lines []string) TaggedLayer
- func IFStateInfoParser(lines []string) TaggedLayer
- func IFStateReqParser(lines []string) TaggedLayer
- func IP4Parser(lines []string) TaggedLayer
- func SCMPParser(lines []string) TaggedLayer
- func ScionParser(lines []string) TaggedLayer
- func SignedRevInfoParser(lines []string) TaggedLayer
- func UDPParser(lines []string) TaggedLayer
- type TaggedLayers
- func (taggedLayers TaggedLayers) CloneAndUpdate(packetString string) TaggedLayers
- func (taggedLayers TaggedLayers) GenerateMac(scnTag string, hMac hash.Hash, infTag, hfTag, hfMacTag string)
- func (taggedLayers TaggedLayers) GetTaggedLayer(tag string) TaggedLayer
- func (taggedLayers TaggedLayers) Serialize() common.RawBytes
- func (taggedLayers TaggedLayers) SetChecksum(l4Tag, l3Tag string)
- func (taggedLayers TaggedLayers) String() string
- func (taggedLayers TaggedLayers) Update(packetString string)
- type UDPTaggedLayer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HexToBytes ¶
func HostAddrTypeFromString ¶
func HostAddrTypeFromString(ht string) addr.HostAddrType
func ParseProto ¶
func ParseProto(enumMeta []golayers.EnumMetadata, protoName string) uint
func SerializeLayers ¶
func SerializeLayers(w gopacket.SerializeBuffer, layers ...TaggedLayer) error
SerializeLayers serializes all gopacket.Layers to Bytes. We implement our own SerializeLayers (gopacket provides one) to allow for custom SerializeOptions per layer
Types ¶
type EthernetTaggedLayer ¶
func (*EthernetTaggedLayer) Clone ¶
func (ether *EthernetTaggedLayer) Clone() TaggedLayer
func (*EthernetTaggedLayer) Layer ¶
func (ether *EthernetTaggedLayer) Layer() gopacket.Layer
func (EthernetTaggedLayer) SerializeOptions ¶
func (t EthernetTaggedLayer) SerializeOptions() gopacket.SerializeOptions
func (*EthernetTaggedLayer) String ¶
func (ether *EthernetTaggedLayer) String() string
func (*EthernetTaggedLayer) Update ¶
func (ether *EthernetTaggedLayer) Update(lines []string)
type HBHTaggedLayer ¶
func (*HBHTaggedLayer) Clone ¶
func (hbh *HBHTaggedLayer) Clone() TaggedLayer
func (*HBHTaggedLayer) Layer ¶
func (hbh *HBHTaggedLayer) Layer() gopacket.Layer
func (*HBHTaggedLayer) LayerType ¶
func (hbh *HBHTaggedLayer) LayerType() gopacket.LayerType
XXX layers.Extension is missing following method to implement gopacket.Layer
func (HBHTaggedLayer) SerializeOptions ¶
func (t HBHTaggedLayer) SerializeOptions() gopacket.SerializeOptions
func (*HBHTaggedLayer) String ¶
func (hbh *HBHTaggedLayer) String() string
func (*HBHTaggedLayer) Update ¶
func (hbh *HBHTaggedLayer) Update(lines []string)
type IFStateInfoTaggedLayer ¶
type IFStateInfoTaggedLayer struct { gopacket.Payload path_mgmt.IFStateInfo RevInfo // contains filtered or unexported fields }
func (*IFStateInfoTaggedLayer) Clone ¶
func (i *IFStateInfoTaggedLayer) Clone() TaggedLayer
func (*IFStateInfoTaggedLayer) Layer ¶
func (p *IFStateInfoTaggedLayer) Layer() gopacket.Layer
func (IFStateInfoTaggedLayer) SerializeOptions ¶
func (t IFStateInfoTaggedLayer) SerializeOptions() gopacket.SerializeOptions
func (*IFStateInfoTaggedLayer) Update ¶
func (i *IFStateInfoTaggedLayer) Update(lines []string)
type IFStateReqTaggedLayer ¶
type IFStateReqTaggedLayer struct { gopacket.Payload path_mgmt.IFStateReq // contains filtered or unexported fields }
func (*IFStateReqTaggedLayer) Clone ¶
func (i *IFStateReqTaggedLayer) Clone() TaggedLayer
func (*IFStateReqTaggedLayer) Layer ¶
func (p *IFStateReqTaggedLayer) Layer() gopacket.Layer
func (IFStateReqTaggedLayer) SerializeOptions ¶
func (t IFStateReqTaggedLayer) SerializeOptions() gopacket.SerializeOptions
func (*IFStateReqTaggedLayer) Update ¶
func (i *IFStateReqTaggedLayer) Update(lines []string)
type IP4TaggedLayer ¶
func (*IP4TaggedLayer) Clone ¶
func (ip *IP4TaggedLayer) Clone() TaggedLayer
func (*IP4TaggedLayer) Layer ¶
func (ip *IP4TaggedLayer) Layer() gopacket.Layer
func (IP4TaggedLayer) SerializeOptions ¶
func (t IP4TaggedLayer) SerializeOptions() gopacket.SerializeOptions
func (*IP4TaggedLayer) String ¶
func (ip *IP4TaggedLayer) String() string
func (*IP4TaggedLayer) Update ¶
func (ip *IP4TaggedLayer) Update(lines []string)
type InfoPathOffsets ¶
type InfoPathOffsets struct {
scmp.InfoPathOffsets
}
type InfoRevocation ¶
type InfoRevocation struct {
scmp.InfoRevocation
}
type LayerParser ¶
type LayerParser func(lines []string) TaggedLayer
type SCMPTaggedLayer ¶
func (*SCMPTaggedLayer) Clone ¶
func (s *SCMPTaggedLayer) Clone() TaggedLayer
func (*SCMPTaggedLayer) Layer ¶
func (s *SCMPTaggedLayer) Layer() gopacket.Layer
func (SCMPTaggedLayer) SerializeOptions ¶
func (t SCMPTaggedLayer) SerializeOptions() gopacket.SerializeOptions
func (*SCMPTaggedLayer) String ¶
func (s *SCMPTaggedLayer) String() string
func (*SCMPTaggedLayer) Update ¶
func (s *SCMPTaggedLayer) Update(lines []string)
type ScionTaggedLayer ¶
func (*ScionTaggedLayer) Clone ¶
func (scn *ScionTaggedLayer) Clone() TaggedLayer
func (*ScionTaggedLayer) GenerateMac ¶
func (scn *ScionTaggedLayer) GenerateMac(hMac hash.Hash, infTag, hfTag, hfMacTag string)
func (*ScionTaggedLayer) Layer ¶
func (scn *ScionTaggedLayer) Layer() gopacket.Layer
func (ScionTaggedLayer) SerializeOptions ¶
func (t ScionTaggedLayer) SerializeOptions() gopacket.SerializeOptions
func (*ScionTaggedLayer) String ¶
func (scn *ScionTaggedLayer) String() string
func (*ScionTaggedLayer) Update ¶
func (scn *ScionTaggedLayer) Update(lines []string)
type SignedRevInfoTaggedLayer ¶
type SignedRevInfoTaggedLayer struct { gopacket.Payload SRevInfo *path_mgmt.SignedRevInfo RevInfo // contains filtered or unexported fields }
func (*SignedRevInfoTaggedLayer) Clone ¶
func (i *SignedRevInfoTaggedLayer) Clone() TaggedLayer
func (*SignedRevInfoTaggedLayer) Layer ¶
func (p *SignedRevInfoTaggedLayer) Layer() gopacket.Layer
func (SignedRevInfoTaggedLayer) SerializeOptions ¶
func (t SignedRevInfoTaggedLayer) SerializeOptions() gopacket.SerializeOptions
func (*SignedRevInfoTaggedLayer) Update ¶
func (i *SignedRevInfoTaggedLayer) Update(lines []string)
type TaggedLayer ¶
type TaggedLayer interface { gopacket.SerializableLayer SerializeOptions() gopacket.SerializeOptions Tag() string Layer() gopacket.Layer Clone() TaggedLayer Update([]string) }
func EthernetParser ¶
func EthernetParser(lines []string) TaggedLayer
func HBHParser ¶
func HBHParser(lines []string) TaggedLayer
func IFStateInfoParser ¶
func IFStateInfoParser(lines []string) TaggedLayer
IFStateInfoParser parses an Interface State Info with the following syntax:
IFStateInfo: IfID=121 Active=true
IFStateInfo: IfID=121 Active=false
SignRevInfo: IfID=121 IA=1-ff00:0:1 Link=peer TS=now TTL=60
The SignedRevInfo is optional.
func IFStateReqParser ¶
func IFStateReqParser(lines []string) TaggedLayer
IFStateReqParser parses an Interface State Request with the following syntax:
IFStateReq: IfID=121
func IP4Parser ¶
func IP4Parser(lines []string) TaggedLayer
func SCMPParser ¶
func SCMPParser(lines []string) TaggedLayer
func ScionParser ¶
func ScionParser(lines []string) TaggedLayer
func SignedRevInfoParser ¶
func SignedRevInfoParser(lines []string) TaggedLayer
SignedRevInfoParser parses an Interface State Info with the following syntax:
SignRevInfo: IfID=121 IA=1-ff00:0:1 Link=peer TS=now TTL=60
func UDPParser ¶
func UDPParser(lines []string) TaggedLayer
type TaggedLayers ¶
type TaggedLayers []TaggedLayer
func ParsePacket ¶
func ParsePacket(packetString string) TaggedLayers
func (TaggedLayers) CloneAndUpdate ¶
func (taggedLayers TaggedLayers) CloneAndUpdate(packetString string) TaggedLayers
func (TaggedLayers) GenerateMac ¶
func (taggedLayers TaggedLayers) GenerateMac(scnTag string, hMac hash.Hash, infTag, hfTag, hfMacTag string)
func (TaggedLayers) GetTaggedLayer ¶
func (taggedLayers TaggedLayers) GetTaggedLayer(tag string) TaggedLayer
func (TaggedLayers) Serialize ¶
func (taggedLayers TaggedLayers) Serialize() common.RawBytes
func (TaggedLayers) SetChecksum ¶
func (taggedLayers TaggedLayers) SetChecksum(l4Tag, l3Tag string)
func (TaggedLayers) String ¶
func (taggedLayers TaggedLayers) String() string
func (TaggedLayers) Update ¶
func (taggedLayers TaggedLayers) Update(packetString string)
type UDPTaggedLayer ¶
func (*UDPTaggedLayer) Clone ¶
func (udp *UDPTaggedLayer) Clone() TaggedLayer
func (*UDPTaggedLayer) Layer ¶
func (udp *UDPTaggedLayer) Layer() gopacket.Layer
func (UDPTaggedLayer) SerializeOptions ¶
func (t UDPTaggedLayer) SerializeOptions() gopacket.SerializeOptions
func (*UDPTaggedLayer) String ¶
func (udp *UDPTaggedLayer) String() string
func (*UDPTaggedLayer) Update ¶
func (udp *UDPTaggedLayer) Update(lines []string)