Documentation
¶
Overview ¶
Package mrt supports BGP data in MRT format (RFC6396)
Index ¶
Constants ¶
const ( // MRT header length HEADLEN = 12 // = timestamp(4) + type(2) + subtype (2) + length (4) // MRT maximum data length MAXLEN = math.MaxUint32 )
const (
// minimum MRT BgpMsg header length
BGPMSG_HEADLEN = 16
)
Variables ¶
var ( ErrShort = errors.New("message too short") ErrLong = errors.New("message too long") ErrLength = errors.New("invalid length") ErrType = errors.New("invalid MRT type") ErrSub = errors.New("invalid MRT subtype") ErrAF = errors.New("invalid Address Family") )
var DefaultReaderOptions = ReaderOptions{ Logger: &log.Logger, }
Default MRT-BGP reader options
Functions ¶
func SubStrings ¶
func SubStrings() []string
SubStrings returns a slice of all String values of the enum
func TypeStrings ¶
func TypeStrings() []string
TypeStrings returns a slice of all String values of the enum
Types ¶
type BgpMsg ¶
type BgpMsg struct {
Mrt *Mrt // parent MRT message
PeerAS uint32 // peer AS
LocalAS uint32 // local AS
Iface uint16 // interface index
PeerIP netip.Addr // peer IP address
LocalIP netip.Addr // local IP address
Data []byte // BGP message, referenced from Mrt
}
BgpMsg represents an MRT BGP4MP message
type Mrt ¶
type Mrt struct {
Time time.Time // message timestamp
Type Type // message type
Sub Sub // message subtype
Data []byte // message data (referenced or owned), can be nil
// contains filtered or unexported fields
}
Mrt represents a bare-bones MRT message (rfc6396/2).
func (*Mrt) Own ¶
func (m *Mrt) Own()
Own tags msg as the owner of referenced data. Does not copy the data.
func (*Mrt) Parse ¶
Parse parses the MRT message in raw. Does not copy. Returns the number of parsed bytes from raw.
type Reader ¶
type Reader struct {
*zerolog.Logger
Stats ReaderStats // our stats
Options ReaderOptions // options; do not modify after Attach()
// contains filtered or unexported fields
}
Reader reads MRT-BGP4MP messages into a pipe.Input.
func (*Reader) Attach ¶
Attach attaches the speaker to given upstream pipe direction. Must not be called more than once.
func (*Reader) ReadFromPath ¶
ReadFromPath opens and reads fpath into br, uncompressing if needed.
type ReaderOptions ¶
MRT-BGP Reader options
type ReaderStats ¶
type ReaderStats struct {
Parsed uint64 // parsed messages (total)
ParsedBgp uint64 // parsed BGP4MP messages
ParsedSkip uint64 // skipped non-BGP4MP messages
Short uint64 // data in buffer too short, should retry
Garbled uint64 // parse error
}
BGP reader statistics
type Sub ¶
type Sub uint16
MRT message subtype, see https://www.iana.org/assignments/mrt/mrt.xhtml
const ( BGP4MP_STATE_CHANGE Sub = 0 BGP4MP_STATE_CHANGE_AS4 Sub = 5 BGP4MP_MESSAGE Sub = 1 BGP4MP_MESSAGE_LOCAL Sub = 6 BGP4MP_MESSAGE_ADDPATH Sub = 8 BGP4MP_MESSAGE_LOCAL_ADDPATH Sub = 10 BGP4MP_MESSAGE_AS4 Sub = 4 BGP4MP_MESSAGE_AS4_LOCAL Sub = 7 BGP4MP_MESSAGE_AS4_ADDPATH Sub = 9 BGP4MP_MESSAGE_AS4_LOCAL_ADDPATH Sub = 11 )
func SubString ¶
SubString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
type Type ¶
type Type uint16
MRT message type, see https://www.iana.org/assignments/mrt/mrt.xhtml
func TypeString ¶
TypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.