OpenSDN source code
bgp_aspath.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef SRC_BGP_BGP_ASPATH_H_
6 #define SRC_BGP_BGP_ASPATH_H_
7 
8 #include <boost/intrusive_ptr.hpp>
9 #include <tbb/atomic.h>
10 
11 #include <algorithm>
12 #include <set>
13 #include <string>
14 #include <vector>
15 
16 #include "bgp/bgp_attr_base.h"
17 #include "bgp/bgp_common.h"
18 #include "base/parse_object.h"
19 #include "base/util.h"
20 
21 class BgpAttr;
22 class AsPathDB;
23 class As4PathDB;
24 class AsPath4ByteDB;
25 class BgpServer;
26 
27 struct AsPathSpec : public BgpAttribute {
28  static const int kSize = -1;
29  static const uint8_t kFlags = Transitive;
30  static const as2_t kMinPrivateAs = 64512;
31  static const as2_t kMaxPrivateAs = 65534;
32 
34  explicit AsPathSpec(const BgpAttribute &rhs) : BgpAttribute(rhs) {}
35  explicit AsPathSpec(const AsPathSpec &rhs) :
37  for (size_t i = 0; i < rhs.path_segments.size(); i++) {
38  PathSegment *ps = new PathSegment;
39  *ps = *rhs.path_segments[i];
40  path_segments.push_back(ps);
41  }
42  }
45  }
46  struct PathSegment : public ParseObject {
47  int CompareTo(const PathSegment &rhs) const {
50  return 0;
51  }
52 
54  AS_SET = 1,
55  AS_SEQUENCE = 2
56  };
58  std::vector<as2_t> path_segment;
59  };
60 
61  as2_t AsLeftMost() const;
62  bool AsLeftMostMatch(as2_t as) const;
63  as2_t AsLeftMostPublic() const;
64  bool AsPathLoop(as2_t as, uint8_t max_loop_count = 0) const;
65  static bool AsIsPrivate(as2_t as) {
66  return as >= kMinPrivateAs && as <= kMaxPrivateAs;
67  }
68 
69  virtual int CompareTo(const BgpAttribute &rhs_attr) const;
70  virtual void ToCanonical(BgpAttr *attr);
71  virtual size_t EncodeLength() const;
72  virtual std::string ToString() const;
73  AsPathSpec *Add(as2_t asn) const;
74  AsPathSpec *Add(const std::vector<as2_t> &asn_list) const;
75  AsPathSpec *Add(const std::vector<as_t> &asn_list) const;
76  AsPathSpec *Replace(as2_t old_asn, as2_t asn) const;
77  AsPathSpec *RemovePrivate(bool all, as2_t asn, as2_t peer_as) const;
78 
79  std::vector<PathSegment *> path_segments;
80 };
81 
82 class AsPath {
83 public:
84  explicit AsPath(AsPathDB *aspath_db) : aspath_db_(aspath_db) {
85  refcount_ = 0;
86  }
87  explicit AsPath(AsPathDB *aspath_db, const AsPathSpec &spec)
88  : aspath_db_(aspath_db), path_(spec) {
89  refcount_ = 0;
90  for (size_t i = 0; i < path_.path_segments.size(); i++) {
93  std::sort(ps->path_segment.begin(), ps->path_segment.end());
94  }
95  }
96  }
97  virtual ~AsPath() { }
98  virtual void Remove();
99  int AsCount() const {
100  int count = 0;
101  std::vector<AsPathSpec::PathSegment *>::const_iterator i;
102  for (i = path_.path_segments.begin(); i < path_.path_segments.end();
103  i++) {
104  if ((*i)->path_segment_type == AsPathSpec::PathSegment::AS_SET) {
105  count++;
106  } else {
107  count += (*i)->path_segment.size();
108  }
109  }
110  return count;
111  }
112 
113  int CompareTo(const AsPath &rhs) const {
114  const std::vector<AsPathSpec::PathSegment *> &lps = path_.path_segments;
115  const std::vector<AsPathSpec::PathSegment *> &rps =
116  rhs.path_.path_segments;
117 
118  KEY_COMPARE(lps.size(), rps.size());
119 
120  std::vector<AsPathSpec::PathSegment *>::const_iterator i, j;
121  for (i = lps.begin(), j = rps.begin(); i < lps.end(); i++, j++) {
122  int ret = (*i)->CompareTo(**j);
123  if (ret != 0) return ret;
124  }
125  return 0;
126  }
127  const AsPathSpec &path() const { return path_; }
128  bool empty() const { return path_.path_segments.empty(); }
129  as2_t neighbor_as() const { return path_.AsLeftMost(); }
130 
131  friend std::size_t hash_value(const AsPath &as_path) {
132  size_t hash = 0;
133  boost::hash_combine(hash, as_path.path().ToString());
134  return hash;
135  }
136 
137 private:
138  friend int intrusive_ptr_add_ref(const AsPath *cpath);
139  friend int intrusive_ptr_del_ref(const AsPath *cpath);
140  friend void intrusive_ptr_release(const AsPath *cpath);
141 
142  mutable tbb::atomic<int> refcount_;
145 };
146 
147 inline int intrusive_ptr_add_ref(const AsPath *cpath) {
148  return cpath->refcount_.fetch_and_increment();
149 }
150 
151 inline int intrusive_ptr_del_ref(const AsPath *cpath) {
152  return cpath->refcount_.fetch_and_decrement();
153 }
154 
155 inline void intrusive_ptr_release(const AsPath *cpath) {
156  int prev = cpath->refcount_.fetch_and_decrement();
157  if (prev == 1) {
158  AsPath *path = const_cast<AsPath *>(cpath);
159  path->Remove();
160  assert(path->refcount_ == 0);
161  delete path;
162  }
163 }
164 
165 typedef boost::intrusive_ptr<const AsPath> AsPathPtr;
166 
168  bool operator()(const AsPath *lhs, const AsPath *rhs) {
169  return lhs->CompareTo(*rhs) < 0;
170  }
171 };
172 
173 class AsPathDB : public BgpPathAttributeDB<AsPath, AsPathPtr, AsPathSpec,
174  AsPathCompare, AsPathDB> {
175 public:
176  explicit AsPathDB(BgpServer *server);
177 
178 private:
179 };
180 
181 struct AsPath4ByteSpec : public BgpAttribute {
182  static const int kSize = -1;
183  static const uint8_t kFlags = Transitive;
184  static const as_t kMinPrivateAs = 64512;
185  static const as_t kMaxPrivateAs = 65534;
186  static const as_t kMinPrivateAs4 = 4200000000;
187  static const as_t kMaxPrivateAs4 = 4294967294;
188 
190  explicit AsPath4ByteSpec(const BgpAttribute &rhs) : BgpAttribute(rhs) {}
191  explicit AsPath4ByteSpec(const AsPath4ByteSpec &rhs) :
193  for (size_t i = 0; i < rhs.path_segments.size(); i++) {
194  PathSegment *ps = new PathSegment;
195  *ps = *rhs.path_segments[i];
196  path_segments.push_back(ps);
197  }
198  }
201  }
202  struct PathSegment : public ParseObject {
203  int CompareTo(const PathSegment &rhs) const {
206  return 0;
207  }
208 
210  AS_SET = 1,
211  AS_SEQUENCE = 2
212  };
214  std::vector<as_t> path_segment;
215  };
216 
217  as_t AsLeftMost() const;
218  bool AsLeftMostMatch(as_t as) const;
219  as_t AsLeftMostPublic() const;
220  bool AsPathLoop(as_t as, uint8_t max_loop_count = 0) const;
221  static bool AsIsPrivate(as_t as) {
222  return ((as >= kMinPrivateAs && as <= kMaxPrivateAs) ||
223  (as >= kMinPrivateAs4 && as <= kMaxPrivateAs4));
224  }
225 
226  virtual int CompareTo(const BgpAttribute &rhs_attr) const;
227  virtual void ToCanonical(BgpAttr *attr);
228  virtual size_t EncodeLength() const;
229  virtual std::string ToString() const;
230  AsPath4ByteSpec *Add(as_t asn) const;
231  AsPath4ByteSpec *Add(const std::vector<as_t> &asn_list) const;
232  AsPath4ByteSpec *Replace(as_t old_asn, as_t asn) const;
233  AsPath4ByteSpec *RemovePrivate(bool all, as_t asn, as_t peer_as) const;
234 
235  std::vector<PathSegment *> path_segments;
236 };
237 
238 class AsPath4Byte {
239 public:
240  explicit AsPath4Byte(AsPath4ByteDB *aspath_db) : aspath_db_(aspath_db) {
241  refcount_ = 0;
242  }
243  explicit AsPath4Byte(AsPath4ByteDB *aspath_db, const AsPath4ByteSpec &spec)
244  : aspath_db_(aspath_db), path_(spec) {
245  refcount_ = 0;
246  for (size_t i = 0; i < path_.path_segments.size(); i++) {
249  std::sort(ps->path_segment.begin(), ps->path_segment.end());
250  }
251  }
252  }
253  virtual ~AsPath4Byte() { }
254  virtual void Remove();
255  int AsCount() const {
256  int count = 0;
257  std::vector<AsPath4ByteSpec::PathSegment *>::const_iterator i;
258  for (i = path_.path_segments.begin(); i < path_.path_segments.end();
259  i++) {
260  if ((*i)->path_segment_type ==
262  count++;
263  } else {
264  count += (*i)->path_segment.size();
265  }
266  }
267  return count;
268  }
269 
270  int CompareTo(const AsPath4Byte &rhs) const {
271  const std::vector<AsPath4ByteSpec::PathSegment *> &lps =
273  const std::vector<AsPath4ByteSpec::PathSegment *> &rps =
274  rhs.path_.path_segments;
275 
276  KEY_COMPARE(lps.size(), rps.size());
277 
278  std::vector<AsPath4ByteSpec::PathSegment *>::const_iterator i, j;
279  for (i = lps.begin(), j = rps.begin(); i < lps.end(); i++, j++) {
280  int ret = (*i)->CompareTo(**j);
281  if (ret != 0) return ret;
282  }
283  return 0;
284  }
285  const AsPath4ByteSpec &path() const { return path_; }
286  bool empty() const { return path_.path_segments.empty(); }
287  as_t neighbor_as() const { return path_.AsLeftMost(); }
288 
289  friend std::size_t hash_value(const AsPath4Byte &as_path) {
290  size_t hash = 0;
291  boost::hash_combine(hash, as_path.path().ToString());
292  return hash;
293  }
294 
295 private:
296  friend int intrusive_ptr_add_ref(const AsPath4Byte *cpath);
297  friend int intrusive_ptr_del_ref(const AsPath4Byte *cpath);
298  friend void intrusive_ptr_release(const AsPath4Byte *cpath);
299 
300  mutable tbb::atomic<int> refcount_;
303 };
304 
305 inline int intrusive_ptr_add_ref(const AsPath4Byte *cpath) {
306  return cpath->refcount_.fetch_and_increment();
307 }
308 
309 inline int intrusive_ptr_del_ref(const AsPath4Byte *cpath) {
310  return cpath->refcount_.fetch_and_decrement();
311 }
312 
313 inline void intrusive_ptr_release(const AsPath4Byte *cpath) {
314  int prev = cpath->refcount_.fetch_and_decrement();
315  if (prev == 1) {
316  AsPath4Byte *path = const_cast<AsPath4Byte *>(cpath);
317  path->Remove();
318  assert(path->refcount_ == 0);
319  delete path;
320  }
321 }
322 
323 typedef boost::intrusive_ptr<const AsPath4Byte> AsPath4BytePtr;
324 
326  bool operator()(const AsPath4Byte *lhs, const AsPath4Byte *rhs) {
327  return lhs->CompareTo(*rhs) < 0;
328  }
329 };
330 
331 class AsPath4ByteDB : public BgpPathAttributeDB<AsPath4Byte, AsPath4BytePtr,
332  AsPath4ByteSpec, AsPath4ByteCompare, AsPath4ByteDB> {
333 public:
334  explicit AsPath4ByteDB(BgpServer *server);
335 
336 private:
337 };
338 
339 typedef boost::intrusive_ptr<const AsPath4Byte> AsPath4BytePtr;
340 
341 struct As4PathSpec : public BgpAttribute {
342  static const int kSize = -1;
343  static const uint8_t kFlags = Transitive|Optional;
344  static const as_t kMinPrivateAs = 64512;
345  static const as_t kMaxPrivateAs = 65534;
346  static const as_t kMinPrivateAs4 = 4200000000;
347  static const as_t kMaxPrivateAs4 = 4294967294;
348 
350  explicit As4PathSpec(const BgpAttribute &rhs) : BgpAttribute(rhs) {}
351  explicit As4PathSpec(const As4PathSpec &rhs) :
353  for (size_t i = 0; i < rhs.path_segments.size(); i++) {
354  PathSegment *ps = new PathSegment;
355  *ps = *rhs.path_segments[i];
356  path_segments.push_back(ps);
357  }
358  }
361  }
362  struct PathSegment : public ParseObject {
363  int CompareTo(const PathSegment &rhs) const {
366  return 0;
367  }
368 
370  AS_SET = 1,
371  AS_SEQUENCE = 2
372  };
374  std::vector<as_t> path_segment;
375  };
376 
377  as_t AsLeftMost() const;
378  bool AsLeftMostMatch(as_t as) const;
379  as_t AsLeftMostPublic() const;
380  bool AsPathLoop(as_t as, uint8_t max_loop_count = 0) const;
381  static bool AsIsPrivate(as_t as) {
382  return ((as >= kMinPrivateAs && as <= kMaxPrivateAs) ||
383  (as >= kMinPrivateAs4 && as <= kMaxPrivateAs4));
384  }
385 
386  virtual int CompareTo(const BgpAttribute &rhs_attr) const;
387  virtual void ToCanonical(BgpAttr *attr);
388  virtual size_t EncodeLength() const;
389  virtual std::string ToString() const;
390  As4PathSpec *Add(as_t asn) const;
391  As4PathSpec *Add(const std::vector<as_t> &asn_list) const;
392  As4PathSpec *Replace(as_t old_asn, as_t asn) const;
393  As4PathSpec *RemovePrivate(bool all, as_t asn, as_t peer_as) const;
394 
395  std::vector<PathSegment *> path_segments;
396 };
397 
398 class As4Path {
399 public:
400  explicit As4Path(As4PathDB *aspath_db) : aspath_db_(aspath_db) {
401  refcount_ = 0;
402  }
403  explicit As4Path(As4PathDB *aspath_db, const As4PathSpec &spec)
404  : aspath_db_(aspath_db), path_(spec) {
405  refcount_ = 0;
406  for (size_t i = 0; i < path_.path_segments.size(); i++) {
409  std::sort(ps->path_segment.begin(), ps->path_segment.end());
410  }
411  }
412  }
413  virtual ~As4Path() { }
414  virtual void Remove();
415  int AsCount() const {
416  int count = 0;
417  std::vector<As4PathSpec::PathSegment *>::const_iterator i;
418  for (i = path_.path_segments.begin(); i < path_.path_segments.end();
419  i++) {
420  if ((*i)->path_segment_type == As4PathSpec::PathSegment::AS_SET) {
421  count++;
422  } else {
423  count += (*i)->path_segment.size();
424  }
425  }
426  return count;
427  }
428 
429  int CompareTo(const As4Path &rhs) const {
430  const std::vector<As4PathSpec::PathSegment *> &lps = path_.path_segments;
431  const std::vector<As4PathSpec::PathSegment *> &rps =
432  rhs.path_.path_segments;
433 
434  KEY_COMPARE(lps.size(), rps.size());
435 
436  std::vector<As4PathSpec::PathSegment *>::const_iterator i, j;
437  for (i = lps.begin(), j = rps.begin(); i < lps.end(); i++, j++) {
438  int ret = (*i)->CompareTo(**j);
439  if (ret != 0) return ret;
440  }
441  return 0;
442  }
443  const As4PathSpec &path() const { return path_; }
444  bool empty() const { return path_.path_segments.empty(); }
445  as_t neighbor_as() const { return path_.AsLeftMost(); }
446 
447  friend std::size_t hash_value(As4Path const &as_path) {
448  size_t hash = 0;
449  boost::hash_combine(hash, as_path.path().ToString());
450  return hash;
451  }
452 
453 private:
454  friend int intrusive_ptr_add_ref(const As4Path *cpath);
455  friend int intrusive_ptr_del_ref(const As4Path *cpath);
456  friend void intrusive_ptr_release(const As4Path *cpath);
457 
458  mutable tbb::atomic<int> refcount_;
461 };
462 
463 inline int intrusive_ptr_add_ref(const As4Path *cpath) {
464  return cpath->refcount_.fetch_and_increment();
465 }
466 
467 inline int intrusive_ptr_del_ref(const As4Path *cpath) {
468  return cpath->refcount_.fetch_and_decrement();
469 }
470 
471 inline void intrusive_ptr_release(const As4Path *cpath) {
472  int prev = cpath->refcount_.fetch_and_decrement();
473  if (prev == 1) {
474  As4Path *path = const_cast<As4Path *>(cpath);
475  path->Remove();
476  assert(path->refcount_ == 0);
477  delete path;
478  }
479 }
480 
481 typedef boost::intrusive_ptr<const As4Path> As4PathPtr;
482 
484  bool operator()(const As4Path *lhs, const As4Path *rhs) {
485  return lhs->CompareTo(*rhs) < 0;
486  }
487 };
488 
489 class As4PathDB : public BgpPathAttributeDB<As4Path, As4PathPtr, As4PathSpec,
490  As4PathCompare, As4PathDB> {
491 public:
492  explicit As4PathDB(BgpServer *server);
493 
494 private:
495 };
496 
497 typedef boost::intrusive_ptr<const As4Path> As4PathPtr;
498 #endif // SRC_BGP_BGP_ASPATH_H_
void intrusive_ptr_release(const AsPath *cpath)
Definition: bgp_aspath.h:155
int intrusive_ptr_del_ref(const AsPath *cpath)
Definition: bgp_aspath.h:151
boost::intrusive_ptr< const AsPath4Byte > AsPath4BytePtr
Definition: bgp_aspath.h:323
boost::intrusive_ptr< const As4Path > As4PathPtr
Definition: bgp_aspath.h:481
int intrusive_ptr_add_ref(const AsPath *cpath)
Definition: bgp_aspath.h:147
boost::intrusive_ptr< const AsPath > AsPathPtr
Definition: bgp_aspath.h:165
uint16_t as2_t
Definition: bgp_common.h:22
uint32_t as_t
Definition: bgp_common.h:21
As4PathDB(BgpServer *server)
Definition: bgp_aspath.cc:729
const As4PathSpec & path() const
Definition: bgp_aspath.h:443
friend int intrusive_ptr_add_ref(const As4Path *cpath)
Definition: bgp_aspath.h:463
tbb::atomic< int > refcount_
Definition: bgp_aspath.h:458
As4PathSpec path_
Definition: bgp_aspath.h:460
friend void intrusive_ptr_release(const As4Path *cpath)
Definition: bgp_aspath.h:471
friend int intrusive_ptr_del_ref(const As4Path *cpath)
Definition: bgp_aspath.h:467
int CompareTo(const As4Path &rhs) const
Definition: bgp_aspath.h:429
virtual void Remove()
Definition: bgp_aspath.cc:725
virtual ~As4Path()
Definition: bgp_aspath.h:413
As4Path(As4PathDB *aspath_db, const As4PathSpec &spec)
Definition: bgp_aspath.h:403
as_t neighbor_as() const
Definition: bgp_aspath.h:445
As4Path(As4PathDB *aspath_db)
Definition: bgp_aspath.h:400
bool empty() const
Definition: bgp_aspath.h:444
int AsCount() const
Definition: bgp_aspath.h:415
As4PathDB * aspath_db_
Definition: bgp_aspath.h:459
friend std::size_t hash_value(As4Path const &as_path)
Definition: bgp_aspath.h:447
AsPath4ByteDB(BgpServer *server)
Definition: bgp_aspath.cc:503
friend void intrusive_ptr_release(const AsPath4Byte *cpath)
Definition: bgp_aspath.h:313
const AsPath4ByteSpec & path() const
Definition: bgp_aspath.h:285
friend int intrusive_ptr_del_ref(const AsPath4Byte *cpath)
Definition: bgp_aspath.h:309
tbb::atomic< int > refcount_
Definition: bgp_aspath.h:300
bool empty() const
Definition: bgp_aspath.h:286
AsPath4ByteSpec path_
Definition: bgp_aspath.h:302
AsPath4Byte(AsPath4ByteDB *aspath_db, const AsPath4ByteSpec &spec)
Definition: bgp_aspath.h:243
virtual void Remove()
Definition: bgp_aspath.cc:499
int CompareTo(const AsPath4Byte &rhs) const
Definition: bgp_aspath.h:270
virtual ~AsPath4Byte()
Definition: bgp_aspath.h:253
AsPath4Byte(AsPath4ByteDB *aspath_db)
Definition: bgp_aspath.h:240
as_t neighbor_as() const
Definition: bgp_aspath.h:287
friend int intrusive_ptr_add_ref(const AsPath4Byte *cpath)
Definition: bgp_aspath.h:305
friend std::size_t hash_value(const AsPath4Byte &as_path)
Definition: bgp_aspath.h:289
int AsCount() const
Definition: bgp_aspath.h:255
AsPath4ByteDB * aspath_db_
Definition: bgp_aspath.h:301
AsPathDB(BgpServer *server)
Definition: bgp_aspath.cc:277
friend void intrusive_ptr_release(const AsPath *cpath)
Definition: bgp_aspath.h:155
tbb::atomic< int > refcount_
Definition: bgp_aspath.h:142
bool empty() const
Definition: bgp_aspath.h:128
friend int intrusive_ptr_del_ref(const AsPath *cpath)
Definition: bgp_aspath.h:151
AsPath(AsPathDB *aspath_db, const AsPathSpec &spec)
Definition: bgp_aspath.h:87
as2_t neighbor_as() const
Definition: bgp_aspath.h:129
friend std::size_t hash_value(const AsPath &as_path)
Definition: bgp_aspath.h:131
const AsPathSpec & path() const
Definition: bgp_aspath.h:127
int AsCount() const
Definition: bgp_aspath.h:99
AsPathDB * aspath_db_
Definition: bgp_aspath.h:143
friend int intrusive_ptr_add_ref(const AsPath *cpath)
Definition: bgp_aspath.h:147
virtual void Remove()
Definition: bgp_aspath.cc:273
AsPath(AsPathDB *aspath_db)
Definition: bgp_aspath.h:84
int CompareTo(const AsPath &rhs) const
Definition: bgp_aspath.h:113
virtual ~AsPath()
Definition: bgp_aspath.h:97
AsPathSpec path_
Definition: bgp_aspath.h:144
bool operator()(const As4Path *lhs, const As4Path *rhs)
Definition: bgp_aspath.h:484
int CompareTo(const PathSegment &rhs) const
Definition: bgp_aspath.h:363
std::vector< as_t > path_segment
Definition: bgp_aspath.h:374
As4PathSpec * Replace(as_t old_asn, as_t asn) const
Definition: bgp_aspath.cc:658
As4PathSpec(const As4PathSpec &rhs)
Definition: bgp_aspath.h:351
As4PathSpec * RemovePrivate(bool all, as_t asn, as_t peer_as) const
Definition: bgp_aspath.cc:680
bool AsLeftMostMatch(as_t as) const
Definition: bgp_aspath.cc:522
static const int kSize
Definition: bgp_aspath.h:342
std::vector< PathSegment * > path_segments
Definition: bgp_aspath.h:395
virtual std::string ToString() const
Definition: bgp_aspath.cc:561
As4PathSpec * Add(as_t asn) const
Definition: bgp_aspath.cc:618
as_t AsLeftMostPublic() const
Definition: bgp_aspath.cc:533
static const as_t kMaxPrivateAs4
Definition: bgp_aspath.h:347
bool AsPathLoop(as_t as, uint8_t max_loop_count=0) const
Definition: bgp_aspath.cc:602
virtual void ToCanonical(BgpAttr *attr)
Definition: bgp_aspath.cc:557
static const as_t kMinPrivateAs4
Definition: bgp_aspath.h:346
as_t AsLeftMost() const
Definition: bgp_aspath.cc:509
static const as_t kMaxPrivateAs
Definition: bgp_aspath.h:345
As4PathSpec(const BgpAttribute &rhs)
Definition: bgp_aspath.h:350
virtual size_t EncodeLength() const
Definition: bgp_aspath.cc:589
static const uint8_t kFlags
Definition: bgp_aspath.h:343
As4PathSpec * Add(const std::vector< as_t > &asn_list) const
static bool AsIsPrivate(as_t as)
Definition: bgp_aspath.h:381
virtual int CompareTo(const BgpAttribute &rhs_attr) const
Definition: bgp_aspath.cc:544
static const as_t kMinPrivateAs
Definition: bgp_aspath.h:344
bool operator()(const AsPath4Byte *lhs, const AsPath4Byte *rhs)
Definition: bgp_aspath.h:326
std::vector< as_t > path_segment
Definition: bgp_aspath.h:214
int CompareTo(const PathSegment &rhs) const
Definition: bgp_aspath.h:203
AsPath4ByteSpec * Add(const std::vector< as_t > &asn_list) const
as_t AsLeftMost() const
Definition: bgp_aspath.cc:283
static const as_t kMinPrivateAs4
Definition: bgp_aspath.h:186
virtual int CompareTo(const BgpAttribute &rhs_attr) const
Definition: bgp_aspath.cc:318
bool AsPathLoop(as_t as, uint8_t max_loop_count=0) const
Definition: bgp_aspath.cc:376
virtual std::string ToString() const
Definition: bgp_aspath.cc:335
static const as_t kMinPrivateAs
Definition: bgp_aspath.h:184
virtual size_t EncodeLength() const
Definition: bgp_aspath.cc:363
AsPath4ByteSpec(const BgpAttribute &rhs)
Definition: bgp_aspath.h:190
AsPath4ByteSpec * Add(as_t asn) const
Definition: bgp_aspath.cc:392
std::vector< PathSegment * > path_segments
Definition: bgp_aspath.h:235
static const as_t kMaxPrivateAs4
Definition: bgp_aspath.h:187
static const uint8_t kFlags
Definition: bgp_aspath.h:183
static const int kSize
Definition: bgp_aspath.h:182
AsPath4ByteSpec * Replace(as_t old_asn, as_t asn) const
Definition: bgp_aspath.cc:432
static bool AsIsPrivate(as_t as)
Definition: bgp_aspath.h:221
AsPath4ByteSpec * RemovePrivate(bool all, as_t asn, as_t peer_as) const
Definition: bgp_aspath.cc:454
bool AsLeftMostMatch(as_t as) const
Definition: bgp_aspath.cc:296
static const as_t kMaxPrivateAs
Definition: bgp_aspath.h:185
virtual void ToCanonical(BgpAttr *attr)
Definition: bgp_aspath.cc:331
AsPath4ByteSpec(const AsPath4ByteSpec &rhs)
Definition: bgp_aspath.h:191
as_t AsLeftMostPublic() const
Definition: bgp_aspath.cc:307
bool operator()(const AsPath *lhs, const AsPath *rhs)
Definition: bgp_aspath.h:168
int CompareTo(const PathSegment &rhs) const
Definition: bgp_aspath.h:47
std::vector< as2_t > path_segment
Definition: bgp_aspath.h:58
virtual size_t EncodeLength() const
Definition: bgp_aspath.cc:101
AsPathSpec(const BgpAttribute &rhs)
Definition: bgp_aspath.h:34
AsPathSpec(const AsPathSpec &rhs)
Definition: bgp_aspath.h:35
AsPathSpec * Add(const std::vector< as_t > &asn_list) const
virtual int CompareTo(const BgpAttribute &rhs_attr) const
Definition: bgp_aspath.cc:56
AsPathSpec * Add(const std::vector< as2_t > &asn_list) const
as2_t AsLeftMostPublic() const
Definition: bgp_aspath.cc:45
static const int kSize
Definition: bgp_aspath.h:28
AsPathSpec * Replace(as2_t old_asn, as2_t asn) const
Definition: bgp_aspath.cc:206
bool AsLeftMostMatch(as2_t as) const
Definition: bgp_aspath.cc:34
virtual std::string ToString() const
Definition: bgp_aspath.cc:73
AsPathSpec * Add(as2_t asn) const
Definition: bgp_aspath.cc:130
static const as2_t kMaxPrivateAs
Definition: bgp_aspath.h:31
static const uint8_t kFlags
Definition: bgp_aspath.h:29
as2_t AsLeftMost() const
Definition: bgp_aspath.cc:21
std::vector< PathSegment * > path_segments
Definition: bgp_aspath.h:79
static bool AsIsPrivate(as2_t as)
Definition: bgp_aspath.h:65
virtual void ToCanonical(BgpAttr *attr)
Definition: bgp_aspath.cc:69
bool AsPathLoop(as2_t as, uint8_t max_loop_count=0) const
Definition: bgp_aspath.cc:114
AsPathSpec * RemovePrivate(bool all, as2_t asn, as2_t peer_as) const
Definition: bgp_aspath.cc:228
static const as2_t kMinPrivateAs
Definition: bgp_aspath.h:30
#define KEY_COMPARE(x, y)
Definition: util.h:70
void STLDeleteValues(Container *container)
Definition: util.h:101