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