7 #include <boost/foreach.hpp>
47 snprintf(start,
sizeof(start),
"Communities: %zu [",
communities.size());
52 snprintf(community,
sizeof(community),
" %X",
communities[i]);
61 : comm_db_(comm_db), communities_(spec.communities) {
64 vector<uint32_t>::iterator it =
86 for (
auto community : communities) {
90 vector<uint32_t>::iterator it =
97 for (
auto community : communities) {
103 for (
auto community : communities) {
115 if (community == value)
124 list->push_back(name);
145 const std::vector<uint32_t> &value) {
158 const std::vector<uint32_t> &value) {
171 const std::vector<uint32_t> &value) {
186 communities.push_back(value);
192 snprintf(repr,
sizeof(repr),
"ExtCommunity <code: %d, flags: %02x>:%d",
203 if (ret != 0)
return ret;
205 static_cast<const ExtCommunitySpec &>(rhs_attr).
communities);
214 for (vector<string>::size_type i = 0; i < encaps.size(); i++) {
215 string encap_str = encaps[i];
224 ExtCommunityList::const_iterator i, j;
238 for (ExtCommunityList::const_iterator it = list.begin();
239 it != list.end(); ++it) {
250 for (ExtCommunityList::const_iterator it = list.begin();
251 it != list.end(); ++it) {
259 ExtCommunityList::iterator it =
267 ExtCommunityList::iterator it =
273 const string &comm, boost::system::error_code *errorp) {
277 uint64_t value = strtoull(comm.c_str(), &end, 16);
278 if (value == 0 || *end) {
280 if (errorp != NULL) {
281 *errorp = make_error_code(
282 boost::system::errc::invalid_argument);
286 if (comm[0] ==
'0' && (comm[1] ==
'x' || comm[1] ==
'X')) {
287 if (comm.length() > 18 && errorp != NULL) {
289 *errorp = make_error_code(
290 boost::system::errc::invalid_argument);
294 if (comm.length() > 16 && errorp != NULL) {
296 *errorp = make_error_code(
297 boost::system::errc::invalid_argument);
306 const string &comm) {
309 size_t pos = comm.find(
':');
310 string first(comm.substr(0, pos));
311 boost::system::error_code error;
312 if (first ==
"soo") {
318 }
else if (first ==
"target") {
324 }
else if (first ==
"source-as") {
330 }
else if (first ==
"rt-import") {
336 }
else if (first ==
"subcluster") {
347 commList.push_back(value);
355 for (
size_t i = 0; i < comm.size(); i++) {
356 len += snprintf(temp+len,
sizeof(temp) - len,
"%02x", (comm)[i]);
358 return(
string(temp));
401 }
else if (
is_tag(comm)) {
418 for (ExtCommunityList::const_iterator it =
communities_.begin();
427 for (ExtCommunityList::const_iterator it =
communities_.begin();
436 if (asn <= 0xffffffff) {
447 for (ExtCommunityList::const_iterator it =
communities_.begin();
456 for (ExtCommunityList::const_iterator it =
communities_.begin();
467 for (ExtCommunityList::const_iterator it =
communities_.begin();
476 for (ExtCommunityList::iterator it =
communities_.begin();
487 for (ExtCommunityList::iterator it =
communities_.begin();
498 for (ExtCommunityList::iterator it =
communities_.begin();
510 for (ExtCommunityList::iterator it =
communities_.begin();
521 for (ExtCommunityList::iterator it =
communities_.begin();
532 for (ExtCommunityList::iterator it =
communities_.begin();
542 for (ExtCommunityList::iterator it =
communities_.begin();
553 for (ExtCommunityList::iterator it =
communities_.begin();
563 for (ExtCommunityList::iterator it =
communities_.begin();
574 for (ExtCommunityList::iterator it =
communities_.begin();
585 for (ExtCommunityList::iterator it =
communities_.begin();
596 vector<string> encap_list;
597 for (ExtCommunityList::const_iterator iter =
communities_.begin();
607 sort(encap_list.begin(), encap_list.end());
608 vector<string>::iterator encap_iter =
609 unique(encap_list.begin(), encap_list.end());
610 encap_list.erase(encap_iter, encap_list.end());
615 vector<int> tag_list;
616 for (ExtCommunityList::const_iterator iter =
communities_.begin();
623 tag_list.push_back(tag_comm.
tag());
626 sort(tag_list.begin(), tag_list.end());
627 vector<int>::iterator tag_iter = unique(tag_list.begin(), tag_list.end());
628 tag_list.erase(tag_iter, tag_list.end());
633 vector<int> tag_list;
634 for (ExtCommunityList::const_iterator iter =
communities_.begin();
642 tag_list.insert(tag_list.end(), matching_tag_list.begin(),
643 matching_tag_list.end());
644 tag_list.push_back(tag_comm.
tag());
646 if ((asn <= 0xffff) && tag_list.size() == 0)
649 sort(tag_list.begin(), tag_list.end());
650 vector<int>::iterator tag_iter = unique(tag_list.begin(), tag_list.end());
651 tag_list.erase(tag_iter, tag_list.end());
656 for (ExtCommunityList::const_iterator iter =
communities_.begin();
668 for (ExtCommunityList::const_iterator iter =
communities_.begin();
681 for (vector<uint64_t>::const_iterator it = spec.
communities.begin();
684 put_value(comm.data(), comm.size(), *it);
688 ExtCommunityList::iterator it =
712 list.push_back(value);
739 clone->
Append(export_list);
753 clone->
Append(export_list);
910 clone->
Append(tunnel_encaps);
const uint64_t GetExtCommunityValue() const
CommunityPtr Locate(Community *attr)
std::string ToString() const
#define KEY_COMPARE(x, y)
const bytes_type & GetExtCommunity() const
static SiteOfOrigin FromString(const std::string &str, boost::system::error_code *error=NULL)
void set_community(CommunityPtr comm)
std::string ToString() const
std::string ToString() const
std::string ToString() const
const bytes_type & GetExtCommunity() const
std::string ToXmppString()
static SourceAs FromString(const std::string &str, boost::system::error_code *error=NULL)
virtual int CompareTo(const BgpAttribute &rhs) const
static SubCluster FromString(const std::string &str, boost::system::error_code *error=NULL)
std::string ToString() const
TunnelEncapType::Encap tunnel_encap() const
std::string ToString() const
static RouteTarget FromString(const std::string &str, boost::system::error_code *error=NULL)
static VrfRouteImport FromString(const std::string &str, boost::system::error_code *error=NULL)
const bytes_type & GetExtCommunity() const
std::string ToString() const
std::string ToString() const
const bytes_type & GetExtCommunity() const
const bytes_type & GetExtCommunity() const
void set_ext_community(ExtCommunityPtr extcomm)
std::string ToString() const
std::string ToString() const
const bytes_type & GetExtCommunity() const
static void put_value(uint8_t *data, int size, uint64_t value)