1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
//! MRT table dump version 1 and 2 structs
use crateAttribute;
use crate;
use Serialize;
use HashMap;
use ;
/// TableDump message version 1
/// TableDump message version 2 enum
/// TableDump version 2 subtypes.
///
/// <https://www.iana.org/assignments/mrt/mrt.xhtml#subtype-codes>
/// AFI/SAFI-Specific RIB Subtypes.
///
/// ```text
/// The AFI/SAFI-specific RIB Subtypes consist of the RIB_IPV4_UNICAST,
/// RIB_IPV4_MULTICAST, RIB_IPV6_UNICAST, and RIB_IPV6_MULTICAST
/// Subtypes. These specific RIB table entries are given their own MRT
/// TABLE_DUMP_V2 subtypes as they are the most common type of RIB table
/// instances, and providing specific MRT subtypes for them permits more
/// compact encodings. These subtypes permit a single MRT record to
/// encode multiple RIB table entries for a single prefix. The Prefix
/// Length and Prefix fields are encoded in the same manner as the BGP
/// NLRI encoding for IPv4 and IPv6 prefixes. Namely, the Prefix field
/// contains address prefixes followed by enough trailing bits to make
/// the end of the field fall on an octet boundary. The value of
/// trailing bits is irrelevant.
///
/// 0 1 2 3
/// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | Sequence Number |
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | Prefix Length |
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | Prefix (variable) |
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | Entry Count | RIB Entries (variable)
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// ```
/// RIB generic entries subtype.
///
/// ```text
/// The RIB_GENERIC header is shown below. It is used to cover RIB
/// entries that do not fall under the common case entries defined above.
/// It consists of an AFI, Subsequent AFI (SAFI), and a single NLRI
/// entry. The NLRI information is specific to the AFI and SAFI values.
/// An implementation that does not recognize particular AFI and SAFI
/// values SHOULD discard the remainder of the MRT record.
/// 0 1 2 3
/// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | Sequence Number |
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | Address Family Identifier |Subsequent AFI |
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | Network Layer Reachability Information (variable) |
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | Entry Count | RIB Entries (variable)
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// ```
/// RIB entry.
///
/// ```text
/// The RIB Entries are repeated Entry Count times. These entries share
/// a common format as shown below. They include a Peer Index from the
/// PEER_INDEX_TABLE MRT record, an originated time for the RIB Entry,
/// and the BGP path attribute length and attributes. All AS numbers in
/// the AS_PATH attribute MUST be encoded as 4-byte AS numbers.
///
/// 0 1 2 3
/// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | Peer Index |
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | Originated Time |
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | Attribute Length |
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | BGP Attributes... (variable)
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// ```
/// peer index table.
///
/// ```text
/// An initial PEER_INDEX_TABLE MRT record provides the BGP ID of the
/// collector, an OPTIONAL view name, and a list of indexed peers.
/// Following the PEER_INDEX_TABLE MRT record, a series of MRT records is
/// used to encode RIB table entries. This series of MRT records uses
/// subtypes 2-6 and is separate from the PEER_INDEX_TABLE MRT record
/// itself and includes full MRT record headers. The RIB entry MRT
/// records MUST immediately follow the PEER_INDEX_TABLE MRT record.
/// ```
/// Peer struct.