mrt

package
Version: v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MRT_COMMON_HEADER_LEN = 12
)

Variables

This section is empty.

Functions

func SplitMrt

func SplitMrt(data []byte, atEOF bool) (advance int, token []byte, err error)

This function can be passed into a bufio.Scanner.Split() to read buffered mrt msgs

Types

type BGP4MPHeader

type BGP4MPHeader struct {
	PeerAS         uint32
	LocalAS        uint32
	InterfaceIndex uint16
	AddressFamily  uint16
	PeerIpAddress  net.IP
	LocalIpAddress net.IP
	// contains filtered or unexported fields
}

type BGP4MPMessage

type BGP4MPMessage struct {
	*BGP4MPHeader
	BGPMessage        *bgp.BGPMessage
	BGPMessagePayload []byte
	// contains filtered or unexported fields
}

func NewBGP4MPMessage

func NewBGP4MPMessage(peeras, localas uint32, intfindex uint16, peerip, localip string, isAS4 bool, msg *bgp.BGPMessage) *BGP4MPMessage

func NewBGP4MPMessageAddPath

func NewBGP4MPMessageAddPath(peeras, localas uint32, intfindex uint16, peerip, localip string, isAS4 bool, msg *bgp.BGPMessage) *BGP4MPMessage

func NewBGP4MPMessageLocal

func NewBGP4MPMessageLocal(peeras, localas uint32, intfindex uint16, peerip, localip string, isAS4 bool, msg *bgp.BGPMessage) *BGP4MPMessage

func NewBGP4MPMessageLocalAddPath

func NewBGP4MPMessageLocalAddPath(peeras, localas uint32, intfindex uint16, peerip, localip string, isAS4 bool, msg *bgp.BGPMessage) *BGP4MPMessage

func (*BGP4MPMessage) DecodeFromBytes

func (m *BGP4MPMessage) DecodeFromBytes(data []byte) error

func (*BGP4MPMessage) Serialize

func (m *BGP4MPMessage) Serialize() ([]byte, error)

func (*BGP4MPMessage) String

func (m *BGP4MPMessage) String() string

type BGP4MPStateChange

type BGP4MPStateChange struct {
	*BGP4MPHeader
	OldState BGPState
	NewState BGPState
}

func NewBGP4MPStateChange

func NewBGP4MPStateChange(peeras, localas uint32, intfindex uint16, peerip, localip string, isAS4 bool, oldstate, newstate BGPState) *BGP4MPStateChange

func (*BGP4MPStateChange) DecodeFromBytes

func (m *BGP4MPStateChange) DecodeFromBytes(data []byte) error

func (*BGP4MPStateChange) Serialize

func (m *BGP4MPStateChange) Serialize() ([]byte, error)

type BGPState

type BGPState uint16
const (
	IDLE        BGPState = 1
	CONNECT     BGPState = 2
	ACTIVE      BGPState = 3
	OPENSENT    BGPState = 4
	OPENCONFIRM BGPState = 5
	ESTABLISHED BGPState = 6
)

type Body

type Body interface {
	DecodeFromBytes([]byte) error
	Serialize() ([]byte, error)
}

type GeoPeer

type GeoPeer struct {
	Type      uint8
	BgpId     net.IP
	Latitude  float32
	Longitude float32
}

func NewGeoPeer

func NewGeoPeer(bgpid string, latitude float32, longitude float32) *GeoPeer

func (*GeoPeer) DecodeFromBytes

func (p *GeoPeer) DecodeFromBytes(data []byte) ([]byte, error)

func (*GeoPeer) Serialize

func (p *GeoPeer) Serialize() ([]byte, error)

func (*GeoPeer) String

func (p *GeoPeer) String() string

type GeoPeerTable

type GeoPeerTable struct {
	CollectorBgpId     net.IP
	CollectorLatitude  float32
	CollectorLongitude float32
	Peers              []*GeoPeer
}

func NewGeoPeerTable

func NewGeoPeerTable(bgpid string, latitude float32, longitude float32, peers []*GeoPeer) *GeoPeerTable

func (*GeoPeerTable) DecodeFromBytes

func (t *GeoPeerTable) DecodeFromBytes(data []byte) error

func (*GeoPeerTable) Serialize

func (t *GeoPeerTable) Serialize() ([]byte, error)

func (*GeoPeerTable) String

func (t *GeoPeerTable) String() string

type MRTHeader

type MRTHeader struct {
	Timestamp uint32
	Type      MRTType
	SubType   uint16
	Len       uint32
}

func NewMRTHeader

func NewMRTHeader(timestamp uint32, t MRTType, subtype MRTSubTyper, l uint32) (*MRTHeader, error)

func (*MRTHeader) DecodeFromBytes

func (h *MRTHeader) DecodeFromBytes(data []byte) error

func (*MRTHeader) GetTime

func (h *MRTHeader) GetTime() time.Time

func (*MRTHeader) Serialize

func (h *MRTHeader) Serialize() ([]byte, error)

type MRTMessage

type MRTMessage struct {
	Header MRTHeader
	Body   Body
}

func NewMRTMessage

func NewMRTMessage(timestamp uint32, t MRTType, subtype MRTSubTyper, body Body) (*MRTMessage, error)

func ParseMRTBody

func ParseMRTBody(h *MRTHeader, data []byte) (*MRTMessage, error)

func (*MRTMessage) Serialize

func (m *MRTMessage) Serialize() ([]byte, error)

type MRTSubTypeBGP4MP

type MRTSubTypeBGP4MP uint16
const (
	STATE_CHANGE              MRTSubTypeBGP4MP = 0
	MESSAGE                   MRTSubTypeBGP4MP = 1
	MESSAGE_AS4               MRTSubTypeBGP4MP = 4
	STATE_CHANGE_AS4          MRTSubTypeBGP4MP = 5
	MESSAGE_LOCAL             MRTSubTypeBGP4MP = 6
	MESSAGE_AS4_LOCAL         MRTSubTypeBGP4MP = 7
	MESSAGE_ADDPATH           MRTSubTypeBGP4MP = 8  // RFC8050
	MESSAGE_AS4_ADDPATH       MRTSubTypeBGP4MP = 9  // RFC8050
	MESSAGE_LOCAL_ADDPATH     MRTSubTypeBGP4MP = 10 // RFC8050
	MESSAGE_AS4_LOCAL_ADDPATH MRTSubTypeBGP4MP = 11 // RFC8050
)

func (MRTSubTypeBGP4MP) ToUint16

func (t MRTSubTypeBGP4MP) ToUint16() uint16

type MRTSubTypeTableDumpv2

type MRTSubTypeTableDumpv2 uint16
const (
	PEER_INDEX_TABLE           MRTSubTypeTableDumpv2 = 1
	RIB_IPV4_UNICAST           MRTSubTypeTableDumpv2 = 2
	RIB_IPV4_MULTICAST         MRTSubTypeTableDumpv2 = 3
	RIB_IPV6_UNICAST           MRTSubTypeTableDumpv2 = 4
	RIB_IPV6_MULTICAST         MRTSubTypeTableDumpv2 = 5
	RIB_GENERIC                MRTSubTypeTableDumpv2 = 6
	GEO_PEER_TABLE             MRTSubTypeTableDumpv2 = 7  // RFC6397
	RIB_IPV4_UNICAST_ADDPATH   MRTSubTypeTableDumpv2 = 8  // RFC8050
	RIB_IPV4_MULTICAST_ADDPATH MRTSubTypeTableDumpv2 = 9  // RFC8050
	RIB_IPV6_UNICAST_ADDPATH   MRTSubTypeTableDumpv2 = 10 // RFC8050
	RIB_IPV6_MULTICAST_ADDPATH MRTSubTypeTableDumpv2 = 11 // RFC8050
	RIB_GENERIC_ADDPATH        MRTSubTypeTableDumpv2 = 12 // RFC8050
)

func (MRTSubTypeTableDumpv2) ToUint16

func (t MRTSubTypeTableDumpv2) ToUint16() uint16

type MRTSubTyper

type MRTSubTyper interface {
	ToUint16() uint16
}

type MRTType

type MRTType uint16
const (
	NULL         MRTType = 0  // deprecated
	START        MRTType = 1  // deprecated
	DIE          MRTType = 2  // deprecated
	I_AM_DEAD    MRTType = 3  // deprecated
	PEER_DOWN    MRTType = 4  // deprecated
	BGP          MRTType = 5  // deprecated
	RIP          MRTType = 6  // deprecated
	IDRP         MRTType = 7  // deprecated
	RIPNG        MRTType = 8  // deprecated
	BGP4PLUS     MRTType = 9  // deprecated
	BGP4PLUS01   MRTType = 10 // deprecated
	OSPFv2       MRTType = 11
	TABLE_DUMP   MRTType = 12
	TABLE_DUMPv2 MRTType = 13
	BGP4MP       MRTType = 16
	BGP4MP_ET    MRTType = 17
	ISIS         MRTType = 32
	ISIS_ET      MRTType = 33
	OSPFv3       MRTType = 48
	OSPFv3_ET    MRTType = 49
)

type Peer

type Peer struct {
	Type      uint8
	BgpId     net.IP
	IpAddress net.IP
	AS        uint32
}

func NewPeer

func NewPeer(bgpid string, ipaddr string, asn uint32, isAS4 bool) *Peer

func (*Peer) DecodeFromBytes

func (p *Peer) DecodeFromBytes(data []byte) ([]byte, error)

func (*Peer) Serialize

func (p *Peer) Serialize() ([]byte, error)

func (*Peer) String

func (p *Peer) String() string

type PeerIndexTable

type PeerIndexTable struct {
	CollectorBgpId net.IP
	ViewName       string
	Peers          []*Peer
}

func NewPeerIndexTable

func NewPeerIndexTable(bgpid string, viewname string, peers []*Peer) *PeerIndexTable

func (*PeerIndexTable) DecodeFromBytes

func (t *PeerIndexTable) DecodeFromBytes(data []byte) error

func (*PeerIndexTable) Serialize

func (t *PeerIndexTable) Serialize() ([]byte, error)

func (*PeerIndexTable) String

func (t *PeerIndexTable) String() string

type Rib

type Rib struct {
	SequenceNumber uint32
	Prefix         bgp.AddrPrefixInterface
	Entries        []*RibEntry
	RouteFamily    bgp.RouteFamily
	// contains filtered or unexported fields
}

func NewRib

func NewRib(seq uint32, prefix bgp.AddrPrefixInterface, entries []*RibEntry) *Rib

func (*Rib) DecodeFromBytes

func (u *Rib) DecodeFromBytes(data []byte) error

func (*Rib) Serialize

func (u *Rib) Serialize() ([]byte, error)

func (*Rib) String

func (u *Rib) String() string

type RibEntry

type RibEntry struct {
	PeerIndex      uint16
	OriginatedTime uint32
	PathIdentifier uint32
	PathAttributes []bgp.PathAttributeInterface
	// contains filtered or unexported fields
}

func NewRibEntry

func NewRibEntry(index uint16, time uint32, pathId uint32, pathAttrs []bgp.PathAttributeInterface, isAddPath bool) *RibEntry

func (*RibEntry) DecodeFromBytes

func (e *RibEntry) DecodeFromBytes(data []byte) ([]byte, error)

func (*RibEntry) Serialize

func (e *RibEntry) Serialize() ([]byte, error)

func (*RibEntry) String

func (e *RibEntry) String() string

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL