7 #include <boost/assign/list_of.hpp>
12 using boost::assign::list_of;
14 using std::ostringstream;
48 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); ++j) {
58 if (ret != 0)
return ret;
64 if (ret != 0)
return ret;
77 if (i != 0) oss <<
" ";
81 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); j++) {
82 if (j != 0) oss <<
" ";
88 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); j++) {
89 if (j != 0) oss <<
" ";
115 uint8_t loop_count = 0;
117 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); ++j) {
119 ++loop_count > max_loop_count) {
131 vector<as2_t> asn_list = list_of(asn);
132 return Add(asn_list);
141 PathSegment *ps =
new PathSegment;
143 for (vector<as_t>::const_iterator it = asn_list.begin(); it !=
144 asn_list.end(); it++) {
146 ps->path_segment.push_back((
as2_t)(*it));
152 path_segments[0]->path_segment.size() + asn_list.size() <= 255) {
155 back_inserter(ps->path_segment));
163 for (
size_t idx = first; idx < last; ++idx) {
164 PathSegment *ps =
new PathSegment;
177 PathSegment *ps =
new PathSegment;
179 ps->path_segment = asn_list;
184 path_segments[0]->path_segment.size() + asn_list.size() <= 255) {
187 back_inserter(ps->path_segment));
195 for (
size_t idx = first; idx < last; ++idx) {
196 PathSegment *ps =
new PathSegment;
208 for (
size_t i = 0; i < new_spec->
path_segments.size(); ++i) {
229 bool remove_replace_done =
false;
237 if (remove_replace_done) {
248 if (remove_replace_done ||
252 remove_replace_done = !all;
310 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); ++j) {
320 if (ret != 0)
return ret;
326 if (ret != 0)
return ret;
339 if (i != 0) oss <<
" ";
343 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); j++) {
344 if (j != 0) oss <<
" ";
350 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); j++) {
351 if (j != 0) oss <<
" ";
377 uint8_t loop_count = 0;
379 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); ++j) {
381 ++loop_count > max_loop_count) {
393 vector<as_t> asn_list = list_of(asn);
394 return Add(asn_list);
403 PathSegment *ps =
new PathSegment;
405 ps->path_segment = asn_list;
410 path_segments[0]->path_segment.size() + asn_list.size() <= 255) {
413 back_inserter(ps->path_segment));
421 for (
size_t idx = first; idx < last; ++idx) {
422 PathSegment *ps =
new PathSegment;
434 for (
size_t i = 0; i < new_spec->
path_segments.size(); ++i) {
455 bool remove_replace_done =
false;
463 if (remove_replace_done) {
474 if (remove_replace_done ||
478 remove_replace_done = !all;
536 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); ++j) {
546 if (ret != 0)
return ret;
552 if (ret != 0)
return ret;
565 if (i != 0) oss <<
" ";
569 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); j++) {
570 if (j != 0) oss <<
" ";
576 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); j++) {
577 if (j != 0) oss <<
" ";
603 uint8_t loop_count = 0;
605 for (
size_t j = 0; j <
path_segments[i]->path_segment.size(); ++j) {
607 ++loop_count > max_loop_count) {
619 vector<as_t> asn_list = list_of(asn);
620 return Add(asn_list);
629 PathSegment *ps =
new PathSegment;
631 ps->path_segment = asn_list;
636 path_segments[0]->path_segment.size() + asn_list.size() <= 255) {
639 back_inserter(ps->path_segment));
647 for (
size_t idx = first; idx < last; ++idx) {
648 PathSegment *ps =
new PathSegment;
660 for (
size_t i = 0; i < new_spec->
path_segments.size(); ++i) {
681 bool remove_replace_done =
false;
689 if (remove_replace_done) {
700 if (remove_replace_done ||
704 remove_replace_done = !all;
bool AsPathLoop(as2_t as, uint8_t max_loop_count=0) const
virtual size_t EncodeLength() const
virtual int CompareTo(const BgpAttribute &rhs_attr) const
AsPath4ByteSpec * Replace(as_t old_asn, as_t asn) const
bool AsLeftMostMatch(as_t as) const
std::vector< PathSegment * > path_segments
AsPathSpec * Add(as2_t asn) const
#define KEY_COMPARE(x, y)
virtual int CompareTo(const BgpAttribute &rhs_attr) const
as_t AsLeftMostPublic() const
virtual void ToCanonical(BgpAttr *attr)
std::vector< as_t > path_segment
virtual std::string ToString() const
AsPath4ByteDB(BgpServer *server)
virtual void ToCanonical(BgpAttr *attr)
void set_as_path(AsPathPtr aspath)
As4PathSpec * Add(as_t asn) const
virtual void ToCanonical(BgpAttr *attr)
std::vector< PathSegment * > path_segments
static bool AsIsPrivate(as_t as)
as_t AsLeftMostPublic() const
AsPathSpec * RemovePrivate(bool all, as2_t asn, as2_t peer_as) const
virtual int CompareTo(const BgpAttribute &rhs) const
bool AsLeftMostMatch(as2_t as) const
As4PathDB(BgpServer *server)
bool AsPathLoop(as_t as, uint8_t max_loop_count=0) const
As4PathSpec * RemovePrivate(bool all, as_t asn, as_t peer_as) const
virtual int CompareTo(const BgpAttribute &rhs_attr) const
AsPath4ByteSpec * Add(as_t asn) const
virtual std::string ToString() const
static bool AsIsPrivate(as2_t as)
bool AsPathLoop(as_t as, uint8_t max_loop_count=0) const
std::vector< as_t > path_segment
bool AsLeftMostMatch(as_t as) const
static bool AsIsPrivate(as_t as)
AsPath4ByteSpec * RemovePrivate(bool all, as_t asn, as_t peer_as) const
AsPathDB(BgpServer *server)
virtual size_t EncodeLength() const
virtual size_t EncodeLength() const
std::vector< as2_t > path_segment
std::vector< PathSegment * > path_segments
void set_aspath_4byte(AsPath4BytePtr aspath)
virtual std::string ToString() const
void set_as4_path(As4PathPtr aspath)
AsPathSpec * Replace(as2_t old_asn, as2_t asn) const
as2_t AsLeftMostPublic() const
AsPath4ByteDB * aspath_db_
As4PathSpec * Replace(as_t old_asn, as_t asn) const