OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bgp_aspath.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include "bgp/bgp_aspath.h"
6 
7 #include <boost/assign/list_of.hpp>
8 #include <sstream>
9 
10 #include "bgp/bgp_proto.h"
11 
12 using boost::assign::list_of;
13 using std::copy;
14 using std::ostringstream;
15 using std::string;
16 using std::vector;
17 
18 //
19 // Return the left most AS.
20 //
22  if (path_segments.empty())
23  return 0;
24  if (path_segments[0]->path_segment_type == PathSegment::AS_SET)
25  return 0;
26  if (path_segments[0]->path_segment.empty())
27  return 0;
28  return (path_segments[0]->path_segment[0]);
29 }
30 
31 //
32 // Return true if left most AS matches the input.
33 //
35  if (path_segments.empty())
36  return false;
37  if (path_segments[0]->path_segment.empty())
38  return false;
39  return (path_segments[0]->path_segment[0] == as);
40 }
41 
42 //
43 // Return the left most public AS.
44 //
46  for (size_t i = 0; i < path_segments.size(); ++i) {
47  PathSegment *ps = path_segments[i];
48  for (size_t j = 0; j < path_segments[i]->path_segment.size(); ++j) {
49  if (!AsIsPrivate(ps->path_segment[j]))
50  return ps->path_segment[j];
51  }
52  }
53  return 0;
54 }
55 
56 int AsPathSpec::CompareTo(const BgpAttribute &rhs_attr) const {
57  int ret = BgpAttribute::CompareTo(rhs_attr);
58  if (ret != 0) return ret;
59  const AsPathSpec &rhs = static_cast<const AsPathSpec &>(rhs_attr);
60  KEY_COMPARE(path_segments.size(), rhs.path_segments.size());
61 
62  for (size_t i = 0; i < path_segments.size(); i++) {
63  int ret = path_segments[i]->CompareTo(*rhs.path_segments[i]);
64  if (ret != 0) return ret;
65  }
66  return 0;
67 }
68 
70  attr->set_as_path(this);
71 }
72 
73 string AsPathSpec::ToString() const {
74  ostringstream oss;
75 
76  for (size_t i = 0; i < path_segments.size(); i++) {
77  if (i != 0) oss << " ";
78  switch (path_segments[i]->path_segment_type) {
80  oss << "{";
81  for (size_t j = 0; j < path_segments[i]->path_segment.size(); j++) {
82  if (j != 0) oss << " ";
83  oss << path_segments[i]->path_segment[j];
84  }
85  oss << "}";
86  break;
88  for (size_t j = 0; j < path_segments[i]->path_segment.size(); j++) {
89  if (j != 0) oss << " ";
90  oss << path_segments[i]->path_segment[j];
91  }
92  break;
93  default:
94  break;
95  }
96  }
97 
98  return oss.str();
99 }
100 
101 size_t AsPathSpec::EncodeLength() const {
102  size_t sz = 0;
103  for (size_t i = 0; i < path_segments.size(); i++) {
104  sz += 2;
105  sz += path_segments[i]->path_segment.size() * 2;
106  }
107  return sz;
108 }
109 
110 //
111 // Check AsPathSpec for loops for the given as.
112 // Return true if the number of occurrences of as exceeds given max loop count.
113 //
114 bool AsPathSpec::AsPathLoop(as2_t as, uint8_t max_loop_count) const {
115  uint8_t loop_count = 0;
116  for (size_t i = 0; i < path_segments.size(); ++i) {
117  for (size_t j = 0; j < path_segments[i]->path_segment.size(); ++j) {
118  if (path_segments[i]->path_segment[j] == as &&
119  ++loop_count > max_loop_count) {
120  return true;
121  }
122  }
123  }
124  return false;
125 }
126 
127 //
128 // Create a new AsPathSpec by prepending the given asn at the beginning.
129 //
131  vector<as2_t> asn_list = list_of(asn);
132  return Add(asn_list);
133 }
134 
135 //
136 // Create a new AsPathSpec by prepending the given vector of asns at the
137 // beginning.
138 //
139 AsPathSpec *AsPathSpec::Add(const vector<as_t> &asn_list) const {
140  AsPathSpec *new_spec = new AsPathSpec;
141  PathSegment *ps = new PathSegment;
142  ps->path_segment_type = PathSegment::AS_SEQUENCE;
143  for (vector<as_t>::const_iterator it = asn_list.begin(); it !=
144  asn_list.end(); it++) {
145  if ((*it) <= AS2_MAX)
146  ps->path_segment.push_back((as2_t)(*it));
147  }
148  size_t first = 0;
149  size_t last = path_segments.size();
150  if (last &&
151  path_segments[0]->path_segment_type == PathSegment::AS_SEQUENCE &&
152  path_segments[0]->path_segment.size() + asn_list.size() <= 255) {
153  copy(path_segments[0]->path_segment.begin(),
154  path_segments[0]->path_segment.end(),
155  back_inserter(ps->path_segment));
156  new_spec->path_segments.push_back(ps);
157  first++;
158  } else {
159  new_spec->path_segments.push_back(ps);
160  }
161  if (first == last)
162  return new_spec;
163  for (size_t idx = first; idx < last; ++idx) {
164  PathSegment *ps = new PathSegment;
165  *ps = *path_segments[idx];
166  new_spec->path_segments.push_back(ps);
167  }
168  return new_spec;
169 }
170 
171 //
172 // Create a new AsPathSpec by prepending the given vector of asns at the
173 // beginning.
174 //
175 AsPathSpec *AsPathSpec::Add(const vector<as2_t> &asn_list) const {
176  AsPathSpec *new_spec = new AsPathSpec;
177  PathSegment *ps = new PathSegment;
178  ps->path_segment_type = PathSegment::AS_SEQUENCE;
179  ps->path_segment = asn_list;
180  size_t first = 0;
181  size_t last = path_segments.size();
182  if (last &&
183  path_segments[0]->path_segment_type == PathSegment::AS_SEQUENCE &&
184  path_segments[0]->path_segment.size() + asn_list.size() <= 255) {
185  copy(path_segments[0]->path_segment.begin(),
186  path_segments[0]->path_segment.end(),
187  back_inserter(ps->path_segment));
188  new_spec->path_segments.push_back(ps);
189  first++;
190  } else {
191  new_spec->path_segments.push_back(ps);
192  }
193  if (first == last)
194  return new_spec;
195  for (size_t idx = first; idx < last; ++idx) {
196  PathSegment *ps = new PathSegment;
197  *ps = *path_segments[idx];
198  new_spec->path_segments.push_back(ps);
199  }
200  return new_spec;
201 }
202 
203 //
204 // Create a new AsPathSpec by replacing the old asn with given asn.
205 //
207  AsPathSpec *new_spec = new AsPathSpec(*this);
208  for (size_t i = 0; i < new_spec->path_segments.size(); ++i) {
209  PathSegment *ps = new_spec->path_segments[i];
210  for (size_t j = 0; j < ps->path_segment.size(); ++j) {
211  if (ps->path_segment[j] == old_asn)
212  ps->path_segment[j] = asn;
213  }
214  }
215  return new_spec;
216 }
217 
218 //
219 // Create a new AsPathSpec by removing private asns. Stop looking for private
220 // asns when we encounter the first public asn or the peer asn.
221 // If all is true, remove all private asns i.e. do not stop when we encounter
222 // the first public asn or the peer asn.
223 // If asn is non-zero, replace private asns instead of removing them. Use the
224 // nearest public asn as the replacement value. If we haven't found a public
225 // asn, then use the given asn.
226 // If peer asn is non-zero, do not remove/replace it.
227 //
228 AsPathSpec *AsPathSpec::RemovePrivate(bool all, as2_t asn, as2_t peer_asn) const {
229  bool remove_replace_done = false;
230  AsPathSpec *new_spec = new AsPathSpec;
231  for (size_t i = 0; i < path_segments.size(); ++i) {
232  PathSegment *ps = path_segments[i];
233  PathSegment *new_ps = new PathSegment;
234 
235  // We've already removed/replaced all private asns that we can.
236  // Copy the entire segment instead of copying one as2_t at a time.
237  if (remove_replace_done) {
238  *new_ps = *ps;
239  new_spec->path_segments.push_back(new_ps);
240  continue;
241  }
242 
243  // Examine each as2_t in the path segment to build a modified version.
244  // Note down that we're done removing/replacing when we see a public
245  // asn or the peer asn.
246  new_ps->path_segment_type = ps->path_segment_type;
247  for (size_t j = 0; j < ps->path_segment.size(); ++j) {
248  if (remove_replace_done ||
249  !AsIsPrivate(ps->path_segment[j]) ||
250  ps->path_segment[j] == peer_asn) {
251  new_ps->path_segment.push_back(ps->path_segment[j]);
252  remove_replace_done = !all;
253  if (asn && !AsIsPrivate(ps->path_segment[j])) {
254  asn = ps->path_segment[j];
255  }
256  } else if (asn) {
257  new_ps->path_segment.push_back(asn);
258  }
259  }
260 
261  // Get rid of the new path segment if it's empty.
262  // Otherwise add it to the new spec.
263  if (new_ps->path_segment.empty()) {
264  delete new_ps;
265  } else {
266  new_spec->path_segments.push_back(new_ps);
267  }
268  }
269 
270  return new_spec;
271 }
272 
274  aspath_db_->Delete(this);
275 }
276 
278 }
279 
280 //
281 // Return the left most AS.
282 //
284  if (path_segments.empty())
285  return 0;
286  if (path_segments[0]->path_segment_type == PathSegment::AS_SET)
287  return 0;
288  if (path_segments[0]->path_segment.empty())
289  return 0;
290  return (path_segments[0]->path_segment[0]);
291 }
292 
293 //
294 // Return true if left most AS matches the input.
295 //
297  if (path_segments.empty())
298  return false;
299  if (path_segments[0]->path_segment.empty())
300  return false;
301  return (path_segments[0]->path_segment[0] == as);
302 }
303 
304 //
305 // Return the left most public AS.
306 //
308  for (size_t i = 0; i < path_segments.size(); ++i) {
309  PathSegment *ps = path_segments[i];
310  for (size_t j = 0; j < path_segments[i]->path_segment.size(); ++j) {
311  if (!AsIsPrivate(ps->path_segment[j]))
312  return ps->path_segment[j];
313  }
314  }
315  return 0;
316 }
317 
318 int AsPath4ByteSpec::CompareTo(const BgpAttribute &rhs_attr) const {
319  int ret = BgpAttribute::CompareTo(rhs_attr);
320  if (ret != 0) return ret;
321  const AsPath4ByteSpec &rhs = static_cast<const AsPath4ByteSpec &>(rhs_attr);
322  KEY_COMPARE(path_segments.size(), rhs.path_segments.size());
323 
324  for (size_t i = 0; i < path_segments.size(); i++) {
325  int ret = path_segments[i]->CompareTo(*rhs.path_segments[i]);
326  if (ret != 0) return ret;
327  }
328  return 0;
329 }
330 
332  attr->set_aspath_4byte(this);
333 }
334 
336  ostringstream oss;
337 
338  for (size_t i = 0; i < path_segments.size(); i++) {
339  if (i != 0) oss << " ";
340  switch (path_segments[i]->path_segment_type) {
342  oss << "{";
343  for (size_t j = 0; j < path_segments[i]->path_segment.size(); j++) {
344  if (j != 0) oss << " ";
345  oss << path_segments[i]->path_segment[j];
346  }
347  oss << "}";
348  break;
350  for (size_t j = 0; j < path_segments[i]->path_segment.size(); j++) {
351  if (j != 0) oss << " ";
352  oss << path_segments[i]->path_segment[j];
353  }
354  break;
355  default:
356  break;
357  }
358  }
359 
360  return oss.str();
361 }
362 
364  size_t sz = 0;
365  for (size_t i = 0; i < path_segments.size(); i++) {
366  sz += 2;
367  sz += path_segments[i]->path_segment.size() * 4;
368  }
369  return sz;
370 }
371 
372 //
373 // Check AsPath4ByteSpec for loops for the given as.
374 // Return true if the number of occurrences of as exceeds given max loop count.
375 //
376 bool AsPath4ByteSpec::AsPathLoop(as_t as, uint8_t max_loop_count) const {
377  uint8_t loop_count = 0;
378  for (size_t i = 0; i < path_segments.size(); ++i) {
379  for (size_t j = 0; j < path_segments[i]->path_segment.size(); ++j) {
380  if (path_segments[i]->path_segment[j] == as &&
381  ++loop_count > max_loop_count) {
382  return true;
383  }
384  }
385  }
386  return false;
387 }
388 
389 //
390 // Create a new AsPath4ByteSpec by prepending the given asn at the beginning.
391 //
393  vector<as_t> asn_list = list_of(asn);
394  return Add(asn_list);
395 }
396 
397 //
398 // Create a new AsPath4ByteSpec by prepending the given vector of asns at the
399 // beginning.
400 //
401 AsPath4ByteSpec *AsPath4ByteSpec::Add(const vector<as_t> &asn_list) const {
402  AsPath4ByteSpec *new_spec = new AsPath4ByteSpec;
403  PathSegment *ps = new PathSegment;
404  ps->path_segment_type = PathSegment::AS_SEQUENCE;
405  ps->path_segment = asn_list;
406  size_t first = 0;
407  size_t last = path_segments.size();
408  if (last &&
409  path_segments[0]->path_segment_type == PathSegment::AS_SEQUENCE &&
410  path_segments[0]->path_segment.size() + asn_list.size() <= 255) {
411  copy(path_segments[0]->path_segment.begin(),
412  path_segments[0]->path_segment.end(),
413  back_inserter(ps->path_segment));
414  new_spec->path_segments.push_back(ps);
415  first++;
416  } else {
417  new_spec->path_segments.push_back(ps);
418  }
419  if (first == last)
420  return new_spec;
421  for (size_t idx = first; idx < last; ++idx) {
422  PathSegment *ps = new PathSegment;
423  *ps = *path_segments[idx];
424  new_spec->path_segments.push_back(ps);
425  }
426  return new_spec;
427 }
428 
429 //
430 // Create a new AsPath4ByteSpec by replacing the old asn with given asn.
431 //
433  AsPath4ByteSpec *new_spec = new AsPath4ByteSpec(*this);
434  for (size_t i = 0; i < new_spec->path_segments.size(); ++i) {
435  PathSegment *ps = new_spec->path_segments[i];
436  for (size_t j = 0; j < ps->path_segment.size(); ++j) {
437  if (ps->path_segment[j] == old_asn)
438  ps->path_segment[j] = asn;
439  }
440  }
441  return new_spec;
442 }
443 
444 //
445 // Create a new AsPath4ByteSpec by removing private asns. Stop looking for private
446 // asns when we encounter the first public asn or the peer asn.
447 // If all is true, remove all private asns i.e. do not stop when we encounter
448 // the first public asn or the peer asn.
449 // If asn is non-zero, replace private asns instead of removing them. Use the
450 // nearest public asn as the replacement value. If we haven't found a public
451 // asn, then use the given asn.
452 // If peer asn is non-zero, do not remove/replace it.
453 //
454 AsPath4ByteSpec *AsPath4ByteSpec::RemovePrivate(bool all, as_t asn, as_t peer_asn) const {
455  bool remove_replace_done = false;
456  AsPath4ByteSpec *new_spec = new AsPath4ByteSpec;
457  for (size_t i = 0; i < path_segments.size(); ++i) {
458  PathSegment *ps = path_segments[i];
459  PathSegment *new_ps = new PathSegment;
460 
461  // We've already removed/replaced all private asns that we can.
462  // Copy the entire segment instead of copying one as_t at a time.
463  if (remove_replace_done) {
464  *new_ps = *ps;
465  new_spec->path_segments.push_back(new_ps);
466  continue;
467  }
468 
469  // Examine each as_t in the path segment to build a modified version.
470  // Note down that we're done removing/replacing when we see a public
471  // asn or the peer asn.
472  new_ps->path_segment_type = ps->path_segment_type;
473  for (size_t j = 0; j < ps->path_segment.size(); ++j) {
474  if (remove_replace_done ||
475  !AsIsPrivate(ps->path_segment[j]) ||
476  ps->path_segment[j] == peer_asn) {
477  new_ps->path_segment.push_back(ps->path_segment[j]);
478  remove_replace_done = !all;
479  if (asn && !AsIsPrivate(ps->path_segment[j])) {
480  asn = ps->path_segment[j];
481  }
482  } else if (asn) {
483  new_ps->path_segment.push_back(asn);
484  }
485  }
486 
487  // Get rid of the new path segment if it's empty.
488  // Otherwise add it to the new spec.
489  if (new_ps->path_segment.empty()) {
490  delete new_ps;
491  } else {
492  new_spec->path_segments.push_back(new_ps);
493  }
494  }
495 
496  return new_spec;
497 }
498 
500  aspath_db_->Delete(this);
501 }
502 
504 }
505 
506 //
507 // Return the left most AS.
508 //
510  if (path_segments.empty())
511  return 0;
512  if (path_segments[0]->path_segment_type == PathSegment::AS_SET)
513  return 0;
514  if (path_segments[0]->path_segment.empty())
515  return 0;
516  return (path_segments[0]->path_segment[0]);
517 }
518 
519 //
520 // Return true if left most AS matches the input.
521 //
523  if (path_segments.empty())
524  return false;
525  if (path_segments[0]->path_segment.empty())
526  return false;
527  return (path_segments[0]->path_segment[0] == as);
528 }
529 
530 //
531 // Return the left most public AS.
532 //
534  for (size_t i = 0; i < path_segments.size(); ++i) {
535  PathSegment *ps = path_segments[i];
536  for (size_t j = 0; j < path_segments[i]->path_segment.size(); ++j) {
537  if (!AsIsPrivate(ps->path_segment[j]))
538  return ps->path_segment[j];
539  }
540  }
541  return 0;
542 }
543 
544 int As4PathSpec::CompareTo(const BgpAttribute &rhs_attr) const {
545  int ret = BgpAttribute::CompareTo(rhs_attr);
546  if (ret != 0) return ret;
547  const As4PathSpec &rhs = static_cast<const As4PathSpec &>(rhs_attr);
548  KEY_COMPARE(path_segments.size(), rhs.path_segments.size());
549 
550  for (size_t i = 0; i < path_segments.size(); i++) {
551  int ret = path_segments[i]->CompareTo(*rhs.path_segments[i]);
552  if (ret != 0) return ret;
553  }
554  return 0;
555 }
556 
558  attr->set_as4_path(this);
559 }
560 
561 string As4PathSpec::ToString() const {
562  ostringstream oss;
563 
564  for (size_t i = 0; i < path_segments.size(); i++) {
565  if (i != 0) oss << " ";
566  switch (path_segments[i]->path_segment_type) {
568  oss << "{";
569  for (size_t j = 0; j < path_segments[i]->path_segment.size(); j++) {
570  if (j != 0) oss << " ";
571  oss << path_segments[i]->path_segment[j];
572  }
573  oss << "}";
574  break;
576  for (size_t j = 0; j < path_segments[i]->path_segment.size(); j++) {
577  if (j != 0) oss << " ";
578  oss << path_segments[i]->path_segment[j];
579  }
580  break;
581  default:
582  break;
583  }
584  }
585 
586  return oss.str();
587 }
588 
590  size_t sz = 0;
591  for (size_t i = 0; i < path_segments.size(); i++) {
592  sz += 2;
593  sz += path_segments[i]->path_segment.size() * 4;
594  }
595  return sz;
596 }
597 
598 //
599 // Check As4PathSpec for loops for the given as.
600 // Return true if the number of occurrences of as exceeds given max loop count.
601 //
602 bool As4PathSpec::AsPathLoop(as_t as, uint8_t max_loop_count) const {
603  uint8_t loop_count = 0;
604  for (size_t i = 0; i < path_segments.size(); ++i) {
605  for (size_t j = 0; j < path_segments[i]->path_segment.size(); ++j) {
606  if (path_segments[i]->path_segment[j] == as &&
607  ++loop_count > max_loop_count) {
608  return true;
609  }
610  }
611  }
612  return false;
613 }
614 
615 //
616 // Create a new As4PathSpec by prepending the given asn at the beginning.
617 //
619  vector<as_t> asn_list = list_of(asn);
620  return Add(asn_list);
621 }
622 
623 //
624 // Create a new As4PathSpec by prepending the given vector of asns at the
625 // beginning.
626 //
627 As4PathSpec *As4PathSpec::Add(const vector<as_t> &asn_list) const {
628  As4PathSpec *new_spec = new As4PathSpec;
629  PathSegment *ps = new PathSegment;
630  ps->path_segment_type = PathSegment::AS_SEQUENCE;
631  ps->path_segment = asn_list;
632  size_t first = 0;
633  size_t last = path_segments.size();
634  if (last &&
635  path_segments[0]->path_segment_type == PathSegment::AS_SEQUENCE &&
636  path_segments[0]->path_segment.size() + asn_list.size() <= 255) {
637  copy(path_segments[0]->path_segment.begin(),
638  path_segments[0]->path_segment.end(),
639  back_inserter(ps->path_segment));
640  new_spec->path_segments.push_back(ps);
641  first++;
642  } else {
643  new_spec->path_segments.push_back(ps);
644  }
645  if (first == last)
646  return new_spec;
647  for (size_t idx = first; idx < last; ++idx) {
648  PathSegment *ps = new PathSegment;
649  *ps = *path_segments[idx];
650  new_spec->path_segments.push_back(ps);
651  }
652  return new_spec;
653 }
654 
655 //
656 // Create a new As4PathSpec by replacing the old asn with given asn.
657 //
659  As4PathSpec *new_spec = new As4PathSpec(*this);
660  for (size_t i = 0; i < new_spec->path_segments.size(); ++i) {
661  PathSegment *ps = new_spec->path_segments[i];
662  for (size_t j = 0; j < ps->path_segment.size(); ++j) {
663  if (ps->path_segment[j] == old_asn)
664  ps->path_segment[j] = asn;
665  }
666  }
667  return new_spec;
668 }
669 
670 //
671 // Create a new As4PathSpec by removing private asns. Stop looking for private
672 // asns when we encounter the first public asn or the peer asn.
673 // If all is true, remove all private asns i.e. do not stop when we encounter
674 // the first public asn or the peer asn.
675 // If asn is non-zero, replace private asns instead of removing them. Use the
676 // nearest public asn as the replacement value. If we haven't found a public
677 // asn, then use the given asn.
678 // If peer asn is non-zero, do not remove/replace it.
679 //
680 As4PathSpec *As4PathSpec::RemovePrivate(bool all, as_t asn, as_t peer_asn) const {
681  bool remove_replace_done = false;
682  As4PathSpec *new_spec = new As4PathSpec;
683  for (size_t i = 0; i < path_segments.size(); ++i) {
684  PathSegment *ps = path_segments[i];
685  PathSegment *new_ps = new PathSegment;
686 
687  // We've already removed/replaced all private asns that we can.
688  // Copy the entire segment instead of copying one as_t at a time.
689  if (remove_replace_done) {
690  *new_ps = *ps;
691  new_spec->path_segments.push_back(new_ps);
692  continue;
693  }
694 
695  // Examine each as_t in the path segment to build a modified version.
696  // Note down that we're done removing/replacing when we see a public
697  // asn or the peer asn.
698  new_ps->path_segment_type = ps->path_segment_type;
699  for (size_t j = 0; j < ps->path_segment.size(); ++j) {
700  if (remove_replace_done ||
701  !AsIsPrivate(ps->path_segment[j]) ||
702  ps->path_segment[j] == peer_asn) {
703  new_ps->path_segment.push_back(ps->path_segment[j]);
704  remove_replace_done = !all;
705  if (asn && !AsIsPrivate(ps->path_segment[j])) {
706  asn = ps->path_segment[j];
707  }
708  } else if (asn) {
709  new_ps->path_segment.push_back(asn);
710  }
711  }
712 
713  // Get rid of the new path segment if it's empty.
714  // Otherwise add it to the new spec.
715  if (new_ps->path_segment.empty()) {
716  delete new_ps;
717  } else {
718  new_spec->path_segments.push_back(new_ps);
719  }
720  }
721 
722  return new_spec;
723 }
724 
726  aspath_db_->Delete(this);
727 }
728 
730 }
bool AsPathLoop(as2_t as, uint8_t max_loop_count=0) const
Definition: bgp_aspath.cc:114
virtual size_t EncodeLength() const
Definition: bgp_aspath.cc:101
virtual int CompareTo(const BgpAttribute &rhs_attr) const
Definition: bgp_aspath.cc:544
AsPath4ByteSpec * Replace(as_t old_asn, as_t asn) const
Definition: bgp_aspath.cc:432
bool AsLeftMostMatch(as_t as) const
Definition: bgp_aspath.cc:522
std::vector< PathSegment * > path_segments
Definition: bgp_aspath.h:235
AsPathSpec * Add(as2_t asn) const
Definition: bgp_aspath.cc:130
#define KEY_COMPARE(x, y)
Definition: util.h:70
virtual int CompareTo(const BgpAttribute &rhs_attr) const
Definition: bgp_aspath.cc:56
as_t AsLeftMostPublic() const
Definition: bgp_aspath.cc:307
virtual void ToCanonical(BgpAttr *attr)
Definition: bgp_aspath.cc:331
std::vector< as_t > path_segment
Definition: bgp_aspath.h:214
virtual std::string ToString() const
Definition: bgp_aspath.cc:73
as2_t AsLeftMost() const
Definition: bgp_aspath.cc:21
virtual void Remove()
Definition: bgp_aspath.cc:725
AsPath4ByteDB(BgpServer *server)
Definition: bgp_aspath.cc:503
uint32_t as_t
Definition: bgp_common.h:21
virtual void ToCanonical(BgpAttr *attr)
Definition: bgp_aspath.cc:557
void set_as_path(AsPathPtr aspath)
Definition: bgp_attr.cc:955
As4PathSpec * Add(as_t asn) const
Definition: bgp_aspath.cc:618
virtual void ToCanonical(BgpAttr *attr)
Definition: bgp_aspath.cc:69
std::vector< PathSegment * > path_segments
Definition: bgp_aspath.h:79
static bool AsIsPrivate(as_t as)
Definition: bgp_aspath.h:381
as_t AsLeftMostPublic() const
Definition: bgp_aspath.cc:533
AsPathSpec * RemovePrivate(bool all, as2_t asn, as2_t peer_as) const
Definition: bgp_aspath.cc:228
as_t AsLeftMost() const
Definition: bgp_aspath.cc:509
virtual int CompareTo(const BgpAttribute &rhs) const
virtual void Remove()
Definition: bgp_aspath.cc:499
uint16_t as2_t
Definition: bgp_common.h:22
bool AsLeftMostMatch(as2_t as) const
Definition: bgp_aspath.cc:34
As4PathDB(BgpServer *server)
Definition: bgp_aspath.cc:729
as_t AsLeftMost() const
Definition: bgp_aspath.cc:283
void Delete(Type *attr)
bool AsPathLoop(as_t as, uint8_t max_loop_count=0) const
Definition: bgp_aspath.cc:376
AsPathDB * aspath_db_
Definition: bgp_aspath.h:143
As4PathSpec * RemovePrivate(bool all, as_t asn, as_t peer_as) const
Definition: bgp_aspath.cc:680
virtual int CompareTo(const BgpAttribute &rhs_attr) const
Definition: bgp_aspath.cc:318
AsPath4ByteSpec * Add(as_t asn) const
Definition: bgp_aspath.cc:392
virtual std::string ToString() const
Definition: bgp_aspath.cc:335
static bool AsIsPrivate(as2_t as)
Definition: bgp_aspath.h:65
bool AsPathLoop(as_t as, uint8_t max_loop_count=0) const
Definition: bgp_aspath.cc:602
std::vector< as_t > path_segment
Definition: bgp_aspath.h:374
bool AsLeftMostMatch(as_t as) const
Definition: bgp_aspath.cc:296
As4PathDB * aspath_db_
Definition: bgp_aspath.h:459
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
AsPathDB(BgpServer *server)
Definition: bgp_aspath.cc:277
virtual size_t EncodeLength() const
Definition: bgp_aspath.cc:589
virtual void Remove()
Definition: bgp_aspath.cc:273
virtual size_t EncodeLength() const
Definition: bgp_aspath.cc:363
std::vector< as2_t > path_segment
Definition: bgp_aspath.h:58
std::vector< PathSegment * > path_segments
Definition: bgp_aspath.h:395
void set_aspath_4byte(AsPath4BytePtr aspath)
Definition: bgp_attr.cc:979
virtual std::string ToString() const
Definition: bgp_aspath.cc:561
void set_as4_path(As4PathPtr aspath)
Definition: bgp_attr.cc:967
AsPathSpec * Replace(as2_t old_asn, as2_t asn) const
Definition: bgp_aspath.cc:206
as2_t AsLeftMostPublic() const
Definition: bgp_aspath.cc:45
#define AS2_MAX
Definition: bgp_common.h:24
AsPath4ByteDB * aspath_db_
Definition: bgp_aspath.h:301
As4PathSpec * Replace(as_t old_asn, as_t asn) const
Definition: bgp_aspath.cc:658