74 std::vector<std::shared_ptr<BgpPathAttrib>>
attribs;
113 if (this->src > other.src)
return false;
116 if (this->weight > other.weight)
return true;
117 if (this->weight < other.weight)
return false;
119 uint32_t other_med = 0;
120 uint32_t this_med = 0;
122 uint32_t other_orig_as = 0;
123 uint32_t this_orig_as = 0;
125 uint8_t other_origin = 0;
126 uint8_t this_origin = 0;
128 uint8_t other_as_path_len = 0;
129 uint8_t this_as_path_len = 0;
131 uint32_t other_local_pref = 100;
132 uint32_t this_local_pref = 100;
135 for (
const std::shared_ptr<BgpPathAttrib> &attr : other.attribs) {
136 if (attr->type_code == MULTI_EXIT_DISC) {
141 if (attr->type_code == ORIGIN) {
143 other_origin = orig.origin;
147 if (attr->type_code == AS_PATH) {
150 if (seg.
type == AS_SEQUENCE) {
151 other_as_path_len = seg.
value.size();
152 other_orig_as = seg.
value.back();
158 if (attr->type_code == LOCAL_PREF) {
165 for (
const std::shared_ptr<BgpPathAttrib> &attr : attribs) {
166 if (attr->type_code == MULTI_EXIT_DISC) {
171 if (attr->type_code == ORIGIN) {
173 this_origin = orig.origin;
177 if (attr->type_code == AS_PATH) {
180 if (seg.
type == AS_SEQUENCE) {
181 this_as_path_len = seg.
value.size();
182 this_orig_as = seg.
value.back();
188 if (attr->type_code == LOCAL_PREF) {
195 if (this_local_pref > other_local_pref)
return true;
196 else if (this_local_pref < other_local_pref)
return false;
197 else if (other_as_path_len > this_as_path_len)
return true;
198 else if (other_as_path_len < this_as_path_len)
return false;
199 else if (other_origin > this_origin)
return true;
200 else if (other_origin < this_origin)
return false;
201 else if (other_orig_as == this_orig_as && other_med > this_med)
return true;
202 else if (other_orig_as == this_orig_as && other_med < this_med)
return false;
203 else if (other.update_id > update_id)
return true;
204 else if (other.update_id < update_id)
return false;
205 else if (htonl(other.src_router_id) > htonl(src_router_id))
return true;
234 if (a == NULL)
return b;
235 if (b == NULL)
return a;
241 if (ra.getLength() > rb.getLength())
return a;
244 if (ra.getLength() == rb.getLength()) {
246 return (*b > *a) ? b : a;
261 if (a == NULL)
return b;
262 if (b == NULL)
return a;
268 if (ra.getLength() > rb.getLength())
return a;
271 if (ra.getLength() == rb.getLength()) {
273 return (*b > *a) ? b : a;
static T * selectEntry(T *a, T *b)
Select an entry from two to use.
std::vector< std::shared_ptr< BgpPathAttrib > > attribs
Path attributes for this entry.
std::vector< uint32_t > value
The segment value.
BgpRibEntry()
Construct a new BgpRibEntry.
The base of BGP RIB entry.
uint32_t local_pref
Local Pref.
std::vector< BgpAsPathSegment > as_paths
The AS Path segments.
BgpRouteSource src
Source of this entry.
uint8_t type
Segment type.
uint32_t ibgp_peer_asn
ASN of the IBGP peer. (Valid iff src == SRC_IBGP)
int32_t weight
Weight of this entry.
uint32_t src_router_id
The originating BGP speaker's ID of this entry. (network bytes order)
An AS_PATH or AS4_PATH segment.
Prefix6 route
The prefix of this entry.
static const T * selectEntry(const T *a, const T *b)
Select an entry from two to use.
Multi Exit Discriminator attribute.
BgpRouteStatus status
Status of this entry.
uint64_t update_id
The update ID.
bool operator>(const T &other) const
Test if this entry has greater weight then anoter entry. Please note that weight are only calculated ...