mrt

package module
v0.0.0-...-6ebc97f Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MIT Imports: 8 Imported by: 0

README

go-mrt

fork of https://github.com/kaorimatz/go-mrt

and some changes for rfc8050

the original repo is pretty good but don't support rfc8050

Go library for parsing MRT format data

Documentation

Index

Constants

View Source
const (
	TABLE_DUMP_V2_SUBTYPE_PEER_INDEX_TABLE = iota + 1
	TABLE_DUMP_V2_SUBTYPE_RIB_IPv4_UNICAST
	TABLE_DUMP_V2_SUBTYPE_RIB_IPv4_MULTICAST
	TABLE_DUMP_V2_SUBTYPE_RIB_IPv6_UNICAST
	TABLE_DUMP_V2_SUBTYPE_RIB_IPv6_MULTICAST
	TABLE_DUMP_V2_SUBTYPE_RIB_GENERIC
	TABLE_DUMP_V2_SUBTYPE_GEO_PEER_TABLE
	TABLE_DUMP_V2_SUBTYPE_RIB_IPv4_UNICAST_ADDPATH
	TABLE_DUMP_V2_SUBTYPE_RIB_IPv4_MULTICAST_ADDPATH
	TABLE_DUMP_V2_SUBTYPE_RIB_IPv6_UNICAST_ADDPATH
	TABLE_DUMP_V2_SUBTYPE_RIB_IPv6_MULTICAST_ADDPATH
	TABLE_DUMP_V2_SUBTYPE_RIB_GENERIC_ADDPATH
)
View Source
const (
	TYPE_OSPFv2        RecordType = 11
	TYPE_TABLE_DUMP               = 12
	TYPE_TABLE_DUMP_V2            = 13
	TYPE_BGP4MP                   = 16
	TYPE_BGP4MP_ET                = 17
	TYPE_ISIS                     = 32
	TYPE_ISIS_ET                  = 33
	TYPE_OSPFv3                   = 48
	TYPE_OSPFv3_ET                = 49
)
View Source
const (
	TABLE_DUMP_SUBTYPE_AFI_IPv4 = 1
	TABLE_DUMP_SUBTYPE_AFI_IPv6 = 2
)
View Source
const (
	BGP4MP_SUBTYPE_BGP4MP_STATE_CHANGE      = 0
	BGP4MP_SUBTYPE_BGP4MP_MESSAGE           = 1
	BGP4MP_SUBTYPE_BGP4MP_MESSAGE_AS4       = 4
	BGP4MP_SUBTYPE_BGP4MP_STATE_CHANGE_AS4  = 5
	BGP4MP_SUBTYPE_BGP4MP_MESSAGE_LOCAL     = 6
	BGP4MP_SUBTYPE_BGP4MP_MESSAGE_AS4_LOCAL = 7
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AFI

type AFI uint16
const (
	AFIIPv4 AFI = 1
	AFIIPv6     = 2
)

type AS

type AS []byte

func (AS) MarshalText

func (as AS) MarshalText() ([]byte, error)

func (AS) String

func (as AS) String() string

type BGP4MPMessage

type BGP4MPMessage struct {
	PeerAS         AS
	LocalAS        AS
	InterfaceIndex uint16
	AFI            AFI
	PeerIPAddress  net.IP
	LocalIPAddress net.IP
	BGPMessage     *BGPMessage
	// contains filtered or unexported fields
}

func (*BGP4MPMessage) DecodeBytes

func (r *BGP4MPMessage) DecodeBytes(data []byte) error

func (*BGP4MPMessage) Subtype

func (h *BGP4MPMessage) Subtype() uint16

func (*BGP4MPMessage) Timestamp

func (h *BGP4MPMessage) Timestamp() time.Time

func (*BGP4MPMessage) Type

func (h *BGP4MPMessage) Type() RecordType

type BGP4MPStateChange

type BGP4MPStateChange struct {
	PeerAS         AS
	LocalAS        AS
	InterfaceIndex uint16
	AFI            AFI
	PeerIPAddress  net.IP
	LocalIPAddress net.IP
	OldState       uint16
	NewState       uint16
	// contains filtered or unexported fields
}

func (*BGP4MPStateChange) DecodeBytes

func (r *BGP4MPStateChange) DecodeBytes(data []byte) error

func (*BGP4MPStateChange) Subtype

func (h *BGP4MPStateChange) Subtype() uint16

func (*BGP4MPStateChange) Timestamp

func (h *BGP4MPStateChange) Timestamp() time.Time

func (*BGP4MPStateChange) Type

func (h *BGP4MPStateChange) Type() RecordType

type BGPASPathSegment

type BGPASPathSegment struct {
	Type  BGPASPathSegmentType
	Value []AS
}

type BGPASPathSegmentType

type BGPASPathSegmentType uint8
const (
	BGPASPathSegmentTypeASSet BGPASPathSegmentType = iota + 1
	BGPASPathSegmentTypeASSequence
)

type BGPClusterID

type BGPClusterID net.IP

type BGPCommunity

type BGPCommunity uint32

type BGPExtendedCommunity

type BGPExtendedCommunity [8]byte

type BGPKeepaliveMessage

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

func (*BGPKeepaliveMessage) Type

func (h *BGPKeepaliveMessage) Type() BGPMessageType

type BGPLargeCommunity

type BGPLargeCommunity [12]byte

type BGPMessage

type BGPMessage interface {
	Type() BGPMessageType
}

type BGPMessageType

type BGPMessageType uint8
const (
	BGPMessageTypeOpen BGPMessageType = iota + 1
	BGPMessageTypeUpdate
	BGPMessageTypeNotification
	BGPMessageTypeKeepalive
)

type BGPNotificationMessage

type BGPNotificationMessage struct {
	ErrorCode    uint8
	ErrorSubcode uint8
	Data         []byte
	// contains filtered or unexported fields
}

func (*BGPNotificationMessage) Type

func (h *BGPNotificationMessage) Type() BGPMessageType

type BGPOpenMessage

type BGPOpenMessage struct {
	Version            uint8
	MyAS               AS
	HoldTime           time.Duration
	BGPIdentifier      net.IP
	OptionalParameters []*OptionalParameter
	// contains filtered or unexported fields
}

func (*BGPOpenMessage) Type

func (h *BGPOpenMessage) Type() BGPMessageType

type BGPPathAttribute

type BGPPathAttribute struct {
	Flag     uint8
	TypeCode uint8
	Value    interface{}
}

type BGPPathAttributeASPath

type BGPPathAttributeASPath []*BGPASPathSegment

type BGPPathAttributeAggregator

type BGPPathAttributeAggregator struct {
	AS        AS
	IPAddress net.IP
}

type BGPPathAttributeClusterList

type BGPPathAttributeClusterList []BGPClusterID

type BGPPathAttributeCommunities

type BGPPathAttributeCommunities []BGPCommunity

type BGPPathAttributeExtendedCommunities

type BGPPathAttributeExtendedCommunities []BGPExtendedCommunity

type BGPPathAttributeLargeCommunities

type BGPPathAttributeLargeCommunities []BGPLargeCommunity

type BGPPathAttributeMPReachNLRI

type BGPPathAttributeMPReachNLRI struct {
	AFI     AFI
	SAFI    SAFI
	NextHop net.IP
	NLRI    []*net.IPNet
}

type BGPPathAttributeMPUnreachNLRI

type BGPPathAttributeMPUnreachNLRI struct {
	AFI             AFI
	SAFI            SAFI
	WithdrawnRoutes []*net.IPNet
}

type BGPPathAttributeOrigin

type BGPPathAttributeOrigin uint8
const (
	BGPPathAttributeOriginIGP BGPPathAttributeOrigin = iota
	BGPPathAttributeOriginEGP
	BGPPathAttributeOriginIncomplete
)

type BGPUpdateMessage

type BGPUpdateMessage struct {
	WithdrawnRoutes []*net.IPNet
	PathAttributes  []*BGPPathAttribute
	NLRI            []*net.IPNet
	// contains filtered or unexported fields
}

func (*BGPUpdateMessage) Type

func (h *BGPUpdateMessage) Type() BGPMessageType

type ISIS

type ISIS struct {
	ISISPDU []byte
	// contains filtered or unexported fields
}

func (*ISIS) DecodeBytes

func (r *ISIS) DecodeBytes(data []byte) error

func (*ISIS) Subtype

func (h *ISIS) Subtype() uint16

func (*ISIS) Timestamp

func (h *ISIS) Timestamp() time.Time

func (*ISIS) Type

func (h *ISIS) Type() RecordType

type OSPFv2

type OSPFv2 struct {
	RemoteIPAddress     net.IP
	LocalIPAddress      net.IP
	OSPFMessageContents []byte
	// contains filtered or unexported fields
}

func (*OSPFv2) DecodeBytes

func (r *OSPFv2) DecodeBytes(data []byte) error

func (*OSPFv2) Subtype

func (h *OSPFv2) Subtype() uint16

func (*OSPFv2) Timestamp

func (h *OSPFv2) Timestamp() time.Time

func (*OSPFv2) Type

func (h *OSPFv2) Type() RecordType

type OSPFv3

type OSPFv3 struct {
	AFI                 AFI
	RemoteIPAddress     net.IP
	LocalIPAddress      net.IP
	OSPFMessageContents []byte
	// contains filtered or unexported fields
}

func (*OSPFv3) DecodeBytes

func (r *OSPFv3) DecodeBytes(data []byte) error

func (*OSPFv3) Subtype

func (h *OSPFv3) Subtype() uint16

func (*OSPFv3) Timestamp

func (h *OSPFv3) Timestamp() time.Time

func (*OSPFv3) Type

func (h *OSPFv3) Type() RecordType

type OptionalParameter

type OptionalParameter struct {
	Type  uint8
	Value []byte
}

type Reader

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

func NewReader

func NewReader(r io.Reader) *Reader

func (*Reader) Next

func (r *Reader) Next() (Record, error)

type Record

type Record interface {
	Timestamp() time.Time
	Type() RecordType
	Subtype() uint16
	DecodeBytes([]byte) error
}

type RecordType

type RecordType uint16

func (RecordType) HasExtendedTimestamp

func (t RecordType) HasExtendedTimestamp() bool

type SAFI

type SAFI uint8
const (
	SAFIUnicast   SAFI = 1
	SAFIMulticast      = 2
)

type TableDump

type TableDump struct {
	ViewNumber     uint16
	SequenceNumber uint16
	Prefix         *net.IPNet
	OriginatedTime time.Time
	PeerIPAddress  net.IP
	PeerAS         AS
	BGPAttributes  []*BGPPathAttribute
	// contains filtered or unexported fields
}

func (*TableDump) DecodeBytes

func (r *TableDump) DecodeBytes(data []byte) error

func (*TableDump) Subtype

func (h *TableDump) Subtype() uint16

func (*TableDump) Timestamp

func (h *TableDump) Timestamp() time.Time

func (*TableDump) Type

func (h *TableDump) Type() RecordType

type TableDumpV2PeerEntry

type TableDumpV2PeerEntry struct {
	PeerType      uint8
	PeerBGPID     net.IP
	PeerIPAddress net.IP
	PeerAS        AS
}

type TableDumpV2PeerIndexTable

type TableDumpV2PeerIndexTable struct {
	CollectorBGPID net.IP
	ViewName       string
	PeerEntries    []*TableDumpV2PeerEntry
	// contains filtered or unexported fields
}

func (*TableDumpV2PeerIndexTable) DecodeBytes

func (r *TableDumpV2PeerIndexTable) DecodeBytes(data []byte) error

func (*TableDumpV2PeerIndexTable) Subtype

func (h *TableDumpV2PeerIndexTable) Subtype() uint16

func (*TableDumpV2PeerIndexTable) Timestamp

func (h *TableDumpV2PeerIndexTable) Timestamp() time.Time

func (*TableDumpV2PeerIndexTable) Type

func (h *TableDumpV2PeerIndexTable) Type() RecordType

type TableDumpV2RIB

type TableDumpV2RIB struct {
	SequenceNumber uint32
	Prefix         *net.IPNet
	RIBEntries     []*TableDumpV2RIBEntry
	// contains filtered or unexported fields
}

func (*TableDumpV2RIB) DecodeBytes

func (r *TableDumpV2RIB) DecodeBytes(data []byte) error

func (*TableDumpV2RIB) Subtype

func (h *TableDumpV2RIB) Subtype() uint16

func (*TableDumpV2RIB) Timestamp

func (h *TableDumpV2RIB) Timestamp() time.Time

func (*TableDumpV2RIB) Type

func (h *TableDumpV2RIB) Type() RecordType

type TableDumpV2RIBEntry

type TableDumpV2RIBEntry struct {
	PeerIndex      uint16
	OriginatedTime time.Time
	PathIdentifier uint32
	BGPAttributes  []*BGPPathAttribute
}

type TableDumpV2RIBGeneric

type TableDumpV2RIBGeneric struct {
	SequenceNumber uint32
	AFI            AFI
	SAFI           SAFI
	NLRI           []byte
	RIBEntries     []*TableDumpV2RIBEntry
	// contains filtered or unexported fields
}

func (*TableDumpV2RIBGeneric) DecodeBytes

func (r *TableDumpV2RIBGeneric) DecodeBytes(data []byte) error

func (*TableDumpV2RIBGeneric) Subtype

func (h *TableDumpV2RIBGeneric) Subtype() uint16

func (*TableDumpV2RIBGeneric) Timestamp

func (h *TableDumpV2RIBGeneric) Timestamp() time.Time

func (*TableDumpV2RIBGeneric) Type

func (h *TableDumpV2RIBGeneric) Type() RecordType

Jump to

Keyboard shortcuts

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