Documentation
¶
Overview ¶
Package tlv implements a parser for TLV encoded babel messages defined in rfc8966
https://datatracker.ietf.org/doc/html/rfc8966#section-4 https://datatracker.ietf.org/doc/html/draft-ietf-babel-source-specific-07#section-7
Index ¶
- Constants
- Variables
- type AEType
- type Ack
- type AckReq
- type ErrSubTLVLength
- type ErrTLVLength
- type ErrorIpFromBytesLength
- type Hello
- type IHU
- type NextHop
- type PacketDecoder
- type Pad1
- type PadN
- type Raw
- type RouteRequest
- type RouterID
- type Scanner
- type SeqnoRequest
- type SourcePrefix
- type SubTLV
- type SubType
- type TLV
- type Type
- type Update
Constants ¶
const ( TypePad1 = Type(0) TypePadN = Type(1) TypeAckReq = Type(2) TypeAck = Type(3) TypeHello = Type(4) TypeIHU = Type(5) TypeRouterID = Type(6) TypeNextHop = Type(7) TypeUpdate = Type(8) TypeRouteRequest = Type(9) TypeSeqnoRequest = Type(10) TypeTSPC = Type(11) TypeHMAC = Type(12) )
Type TLV constants
const ( SubTypePad1 = SubType(0) SubTypePadN = SubType(1) SubTypeDiversity = SubType(2) SubTypeTimestamp = SubType(3) SubTypeSourcePrefix = SubType(128) )
SubType Sub-TLV constants
const ( AEWildcard = AEType(0) AEIPv4 = AEType(1) AEIPv6 = AEType(2) AEIPv6LL = AEType(3) AEIPv4oIPv6 = AEType(4) )
AEType AE constants
Variables ¶
var ( ErrRouterIDZeros = errors.New("Invalid RouterID: consists of all zeros") ErrRouterIDOnes = errors.New("Invalid RouterID: consists of all ones") )
Errors specific to RouterID.
Functions ¶
This section is empty.
Types ¶
type AEType ¶
type AEType uint8
AEType encodes the AE field in TLVs
func AEFromPrefix ¶
AEFromPrefix returns the address encoding of a prefix:
type ErrSubTLVLength ¶
type ErrSubTLVLength struct {
// contains filtered or unexported fields
}
ErrSubTLVLength is used to inform about invalid length fields in Sub-TLVs
func (ErrSubTLVLength) Error ¶
func (e ErrSubTLVLength) Error() string
type ErrTLVLength ¶
type ErrTLVLength struct {
// contains filtered or unexported fields
}
ErrTLVLength is used to inform about invalid length fields in TLVs
func (ErrTLVLength) Error ¶
func (e ErrTLVLength) Error() string
type ErrorIpFromBytesLength ¶ added in v0.3.0
type ErrorIpFromBytesLength struct {
// contains filtered or unexported fields
}
func (ErrorIpFromBytesLength) Error ¶ added in v0.3.0
func (e ErrorIpFromBytesLength) Error() string
type PacketDecoder ¶
type PacketDecoder struct {
// contains filtered or unexported fields
}
PacketDecoder splits a packet into TLVs and parses their content
func (*PacketDecoder) Err ¶
func (s *PacketDecoder) Err() error
Err returns the first error that occured during parsing.
func (*PacketDecoder) Reset ¶
func (s *PacketDecoder) Reset(b []byte, nexthop netip.Addr, ifindex int)
Reset clears the parser state and sets a new byte slice to work on.
func (*PacketDecoder) Scan ¶
func (s *PacketDecoder) Scan() bool
Scan parses the next TLV. Returns true on success or false on error and when no more TLVs can be found.
func (*PacketDecoder) SubTLV ¶
func (s *PacketDecoder) SubTLV() []byte
SubTLV returns the last successfully parsed Sub-TLV
func (*PacketDecoder) TLV ¶
func (s *PacketDecoder) TLV() TLV
TLV returns the last successfully parsed TLV
type Pad1 ¶
type Pad1 struct{}
Pad1 TLV
1 byte padding that is silently ignored. https://datatracker.ietf.org/doc/html/rfc8966#section-4.6.1
type PadN ¶
type PadN uint8
PadN TLV
Multi byte padding that is silently ignored. https://datatracker.ietf.org/doc/html/rfc8966#section-4.6.2
type RouteRequest ¶
RouteRequest TLV
https://datatracker.ietf.org/doc/html/rfc8966#section-4.6.10
func (RouteRequest) AE ¶
func (r RouteRequest) AE() AEType
AE returns the address encoding of the requested prefix
func (RouteRequest) L ¶
func (r RouteRequest) L() uint8
L depends on the requested prefix, at least 4.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner splits bytes into TLV tokens.
type SeqnoRequest ¶
type SeqnoRequest struct { // AE uint8 // Plen uint8 Seqno uint16 HopCount uint8 RouterID RouterID Prefix netip.Prefix }
SeqnoRequest TLV
https://datatracker.ietf.org/doc/html/rfc8966#section-4.6.11
func (SeqnoRequest) L ¶
func (r SeqnoRequest) L() uint8
L depends on the requested prefix, at least 14.
type SourcePrefix ¶
SourcePrefix Sub-TLV
https://datatracker.ietf.org/doc/html/draft-ietf-babel-source-specific-07#section-7.1
func SourcePrefixFromBytes ¶
func SourcePrefixFromBytes(b []byte) (SourcePrefix, []byte, error)
SourcePrefixFromBytes parses a SourcePrefix SubTLV
type SubType ¶
type SubType uint8
SubType encodes the type of Sub-TLV
func (SubType) IsMandatory ¶
IsMandatory checks if a Sub-TLV is mandatory
type Update ¶
type Update struct { // AE uint8 Flags uint8 // Plen uint8 Omitted uint8 Interval uint16 Seqno uint16 Metric uint16 RouterID RouterID Prefix netip.Prefix NextHop netip.Addr }
Update TLV
https://datatracker.ietf.org/doc/html/rfc8966#section-4.6.9
func (Update) FormatHeader ¶
FormatHeader returns a string of the most important fields except the prefix