8 #include <boost/assign/list_of.hpp>
13 using boost::assign::list_of;
15 using std::ostringstream;
49 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); ++j) {
59 if (ret != 0)
return ret;
65 if (ret != 0)
return ret;
78 if (i != 0) oss <<
" ";
82 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); j++) {
83 if (j != 0) oss <<
" ";
89 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); j++) {
90 if (j != 0) oss <<
" ";
116 uint8_t loop_count = 0;
118 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); ++j) {
120 ++loop_count > max_loop_count) {
132 vector<as2_t> asn_list = list_of(asn);
133 return Add(asn_list);
142 PathSegment *ps =
new PathSegment;
144 for (vector<as_t>::const_iterator it = asn_list.begin(); it !=
145 asn_list.end(); it++) {
147 ps->path_segment.push_back((
as2_t)(*it));
153 path_segments[0]->path_segment.size() + asn_list.size() <= 255) {
156 back_inserter(ps->path_segment));
164 for (
size_t idx = first; idx < last; ++idx) {
165 PathSegment *ps =
new PathSegment;
178 PathSegment *ps =
new PathSegment;
180 ps->path_segment = asn_list;
185 path_segments[0]->path_segment.size() + asn_list.size() <= 255) {
188 back_inserter(ps->path_segment));
196 for (
size_t idx = first; idx < last; ++idx) {
197 PathSegment *ps =
new PathSegment;
209 for (
size_t i = 0; i < new_spec->
path_segments.size(); ++i) {
230 bool remove_replace_done =
false;
238 if (remove_replace_done) {
249 if (remove_replace_done ||
253 remove_replace_done = !all;
311 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); ++j) {
321 if (ret != 0)
return ret;
327 if (ret != 0)
return ret;
340 if (i != 0) oss <<
" ";
344 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); j++) {
345 if (j != 0) oss <<
" ";
351 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); j++) {
352 if (j != 0) oss <<
" ";
378 uint8_t loop_count = 0;
380 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); ++j) {
382 ++loop_count > max_loop_count) {
394 vector<as_t> asn_list = list_of(asn);
395 return Add(asn_list);
404 PathSegment *ps =
new PathSegment;
406 ps->path_segment = asn_list;
411 path_segments[0]->path_segment.size() + asn_list.size() <= 255) {
414 back_inserter(ps->path_segment));
422 for (
size_t idx = first; idx < last; ++idx) {
423 PathSegment *ps =
new PathSegment;
435 for (
size_t i = 0; i < new_spec->
path_segments.size(); ++i) {
456 bool remove_replace_done =
false;
464 if (remove_replace_done) {
475 if (remove_replace_done ||
479 remove_replace_done = !all;
537 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); ++j) {
547 if (ret != 0)
return ret;
553 if (ret != 0)
return ret;
566 if (i != 0) oss <<
" ";
570 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); j++) {
571 if (j != 0) oss <<
" ";
577 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); j++) {
578 if (j != 0) oss <<
" ";
604 uint8_t loop_count = 0;
606 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); ++j) {
608 ++loop_count > max_loop_count) {
620 vector<as_t> asn_list = list_of(asn);
621 return Add(asn_list);
630 PathSegment *ps =
new PathSegment;
632 ps->path_segment = asn_list;
637 path_segments[0]->path_segment.size() + asn_list.size() <= 255) {
640 back_inserter(ps->path_segment));
648 for (
size_t idx = first; idx < last; ++idx) {
649 PathSegment *ps =
new PathSegment;
661 for (
size_t i = 0; i < new_spec->
path_segments.size(); ++i) {
682 bool remove_replace_done =
false;
690 if (remove_replace_done) {
701 if (remove_replace_done ||
705 remove_replace_done = !all;
As4PathDB(BgpServer *server)
AsPath4ByteDB(BgpServer *server)
AsPath4ByteDB * aspath_db_
AsPathDB(BgpServer *server)
void set_aspath_4byte(AsPath4BytePtr aspath)
void set_as_path(AsPathPtr aspath)
void set_as4_path(As4PathPtr aspath)
virtual int CompareTo(const BgpAttribute &rhs) const
std::vector< as_t > path_segment
As4PathSpec * Replace(as_t old_asn, as_t asn) const
As4PathSpec * RemovePrivate(bool all, as_t asn, as_t peer_as) const
bool AsLeftMostMatch(as_t as) const
std::vector< PathSegment * > path_segments
virtual std::string ToString() const
As4PathSpec * Add(as_t asn) const
as_t AsLeftMostPublic() const
bool AsPathLoop(as_t as, uint8_t max_loop_count=0) const
virtual void ToCanonical(BgpAttr *attr)
virtual size_t EncodeLength() const
static bool AsIsPrivate(as_t as)
virtual int CompareTo(const BgpAttribute &rhs_attr) const
std::vector< as_t > path_segment
virtual int CompareTo(const BgpAttribute &rhs_attr) const
bool AsPathLoop(as_t as, uint8_t max_loop_count=0) const
virtual std::string ToString() const
virtual size_t EncodeLength() const
AsPath4ByteSpec * Add(as_t asn) const
std::vector< PathSegment * > path_segments
AsPath4ByteSpec * Replace(as_t old_asn, as_t asn) const
static bool AsIsPrivate(as_t as)
AsPath4ByteSpec * RemovePrivate(bool all, as_t asn, as_t peer_as) const
bool AsLeftMostMatch(as_t as) const
virtual void ToCanonical(BgpAttr *attr)
as_t AsLeftMostPublic() const
std::vector< as2_t > path_segment
virtual size_t EncodeLength() const
virtual int CompareTo(const BgpAttribute &rhs_attr) const
as2_t AsLeftMostPublic() const
AsPathSpec * Replace(as2_t old_asn, as2_t asn) const
bool AsLeftMostMatch(as2_t as) const
virtual std::string ToString() const
AsPathSpec * Add(as2_t asn) const
std::vector< PathSegment * > path_segments
static bool AsIsPrivate(as2_t as)
virtual void ToCanonical(BgpAttr *attr)
bool AsPathLoop(as2_t as, uint8_t max_loop_count=0) const
AsPathSpec * RemovePrivate(bool all, as2_t asn, as2_t peer_as) const
#define KEY_COMPARE(x, y)