33 using std::ostringstream;
47 for (Route::PathList::const_iterator it =
GetPathList().begin();
49 const BgpPath *path =
static_cast<const BgpPath *
>(it.operator->());
146 for (Route::PathList::const_iterator it =
GetPathList().begin();
149 if (dynamic_cast<const BgpSecondaryPath *>(it.operator->())) {
153 const BgpPath *path =
static_cast<const BgpPath *
>(it.operator->());
172 for (Route::PathList::iterator it =
GetPathList().begin();
184 if (!include_secondary &&
185 dynamic_cast<BgpSecondaryPath *>(it.operator->())) {
196 bool include_secondary)
const {
205 for (Route::PathList::iterator it =
GetPathList().begin();
227 for (Route::PathList::iterator it =
GetPathList().begin();
230 if (dynamic_cast<BgpSecondaryPath *>(it.operator->())) {
254 return FindPath(src, NULL, path_id);
264 for (Route::PathList::iterator it =
GetPathList().begin();
271 if (dynamic_cast<BgpSecondaryPath *>(it.operator->())) {
301 for (Route::PathList::iterator it =
GetPathList().begin(), next = it;
309 if (dynamic_cast<BgpSecondaryPath *>(it.operator->())) {
353 for (Route::PathList::const_iterator it =
GetPathList().begin();
355 const BgpPath *path =
static_cast<const BgpPath *
>(it.operator->());
374 for (Route::PathList::iterator it =
GetPathList().begin();
384 if (path && path->
src_rt() == src_rt &&
399 for (Route::PathList::iterator it =
GetPathList().begin();
409 if (path && path->
src_rt() == src_rt &&
433 ShowRouteBrief *show_route)
const {
435 vector<ShowRoutePathBrief> show_route_paths;
436 for (Route::PathList::const_iterator it =
GetPathList().begin();
438 const BgpPath *path =
static_cast<const BgpPath *
>(it.operator->());
439 ShowRoutePathBrief srp;
450 srp.set_next_hop(attr->
nexthop().to_string());
452 show_route_paths.push_back(srp);
454 show_route->set_paths(show_route_paths);
458 ShowRoutePath *show_path) {
460 vector<string> cluster_list = vector<string>();
461 for (vector<uint32_t>::const_iterator it = list.begin(); it != list.end();
463 cluster_list.push_back(
Ip4Address(*it).to_string());
465 show_path->set_cluster_list(cluster_list);
469 ShowRoutePath *show_path, vector<string> *communities) {
475 ShowRoutePath *show_path, vector<string> *communities) {
478 vector<string> tunnel_encap = vector<string>();
481 for (ExtCommunity::ExtCommunityList::const_iterator it = v.begin();
482 it != v.end(); ++it) {
485 communities->push_back(rt.
ToString());
488 communities->push_back(dgw.
ToString());
491 communities->push_back(es_import.
ToString());
494 communities->push_back(esi_label.
ToString());
497 communities->push_back(mm.
ToString());
501 communities->push_back(lsn.
ToString());
504 communities->push_back(etree.
ToString());
507 communities->push_back(router_mac.
ToString());
510 communities->push_back(origin_vn.
ToString());
511 int vn_index = origin_vn.
vn_index();
512 show_path->set_origin_vn(
516 communities->push_back(sg.
ToString());
519 communities->push_back(sg.
ToString());
522 communities->push_back(soo.
ToString());
525 communities->push_back(encap.
ToString());
530 communities->push_back(load_balance.
ToString());
532 ShowLoadBalance show_load_balance;
534 show_path->set_load_balance(show_load_balance);
537 communities->push_back(tag.
ToString());
540 communities->push_back(tag.
ToString());
543 communities->push_back(sas.
ToString());
546 communities->push_back(sc.
ToString());
549 communities->push_back(rt_import.
ToString());
552 communities->push_back(mf.
ToString());
555 int len = snprintf(temp,
sizeof(temp),
"ext community: ");
556 for (
size_t i = 0; i < it->size(); i++) {
557 len += snprintf(temp+len,
sizeof(temp) - len,
"%02x", (*it)[i]);
559 communities->push_back(
string(temp));
562 show_path->set_tunnel_encap(tunnel_encap);
566 ShowRoutePath *show_path) {
567 vector<ShowEdgeForwarding> show_ef_list;
568 vector<EdgeForwardingSpec::Edge *> edge_list =
570 for (vector<EdgeForwardingSpec::Edge *>::const_iterator it =
571 edge_list.begin(); it != edge_list.end(); ++it) {
573 ShowEdgeForwarding show_ef;
576 show_ef.set_in_address_label(oss.str());
580 show_ef.set_out_address_label(oss.str());
581 show_ef_list.push_back(show_ef);
583 show_path->set_edge_forwarding(show_ef_list);
587 ShowRoutePath *show_path) {
588 vector<ShowEdgeDiscovery> show_ed_list;
589 vector<EdgeDiscoverySpec::Edge *> edge_list =
592 for (vector<EdgeDiscoverySpec::Edge *>::const_iterator it =
594 it != edge_list.end(); ++it, ++idx) {
596 ShowEdgeDiscovery show_ed;
598 uint32_t first_label, last_label;
600 show_ed.set_address(oss.str());
603 edge->
GetLabels(&first_label, &last_label);
604 oss << first_label <<
"-" << last_label;
605 show_ed.set_labels(oss.str());
606 show_ed_list.push_back(show_ed);
608 show_path->set_edge_discovery(show_ed_list);
612 ShowRoutePath *show_path) {
614 vector<string> origin_vn_path = vector<string>();
615 for (OriginVnPath::OriginVnList::const_iterator it = v.begin();
616 it != v.end(); ++it) {
618 origin_vn_path.push_back(origin_vn.
ToString());
620 show_path->set_origin_vn_path(origin_vn_path);
628 spt.set_identifier(pmsi_tunnel->
identifier().to_string());
629 spt.set_label(pmsi_tunnel->
GetLabel(ext));
631 show_path->set_pmsi_tunnel(spt);
635 ShowRoute *show_route,
const string &source,
const string &protocol)
const {
639 show_route->set_last_modified(
642 vector<ShowRoutePath> show_route_paths;
643 for (Route::PathList::const_iterator it =
GetPathList().begin();
645 const BgpPath *path =
static_cast<const BgpPath *
>(it.operator->());
650 if (!source.empty() && (!peer || source != peer->
ToString()))
663 srp.set_local_as(bgp_peer->
local_as());
664 srp.set_peer_as(bgp_peer->
peer_as());
689 srp.set_med(attr->
med());
690 srp.set_next_hop(attr->
nexthop().to_string());
693 srp.set_last_modified(
698 srp.set_replicated(
true);
701 srp.set_replicated(
false);
707 srp.set_secondary_tables(
708 replicator->GetReplicatedTableNameList(table,
this, path));
714 vector<string> communities;
722 if (!communities.empty()){
723 srp.set_communities(communities);
725 if (srp.get_origin_vn().empty() &&
742 show_route_paths.push_back(srp);
744 show_route->set_paths(show_route_paths);
758 if (!config_manager_) {
void UpdatePathCount(const BgpPath *path, int count)
void FillRouteInfo(const BgpTable *table, ShowRouteBrief *show_route) const
void ShowAttribute(ShowLoadBalance *show_load_balance) const
const Community * community() const
const Ip4Address identifier() const
static void FillRoutePathCommunityInfo(const Community *comm, ShowRoutePath *show_path, vector< string > *communities)
Ip4Address GetInboundIp4Address() const
std::vector< OriginVnValue > OriginVnList
static Family VpnFamilyFromFamily(Family family)
const ClusterListSpec & cluster_list() const
void Sort(Compare compare, const Path *prev_front)
uint32_t local_pref() const
const IpAddress & nexthop() const
const BgpPath * BestPath() const
TypePtr Locate(Type *attr)
const AsPathSpec & path() const
void GetLabels(uint32_t *first_label, uint32_t *last_label) const
std::vector< std::string > GetTunnelFlagsStrings() const
DBTableBase * get_table() const
bool RemoveSecondaryPath(const BgpRoute *src_rt, BgpPath::PathSource src, const IPeer *peer, uint32_t path_id)
std::string ToString() const
std::string ToString() const
const EdgeForwardingSpec & edge_forwarding() const
virtual bool IsVpnTable() const
static const std::string & TunnelEncapToString(TunnelEncapType::Encap encap)
RoutingInstance * routing_instance()
static const char * kMasterInstance
boost::asio::ip::address IpAddress
const uint32_t GetPathId() const
const OriginVnPath * origin_vn_path() const
virtual std::string ToString() const
std::string ToString() const
const BgpPath * FindPath(BgpPath::PathSource src) const
const Ip4Address & originator_id() const
RoutePathReplicator * replicator(Address::Family family)
static void FillOriginVnPathInfo(const OriginVnPath *ovnpath, ShowRoutePath *show_path)
static void FillEdgeDiscoveryInfo(const EdgeDiscovery *edge_discovery, ShowRoutePath *show_path)
std::string ToString() const
virtual Address::Family family() const =0
uint32_t GetFlags() const
std::string origin_string() const
std::vector< uint32_t > cluster_list
std::string ToString() const
std::string GetSourceString(bool combine_bgp_and_xmpp=false) const
Ip4Address GetIp4Address() const
const uint64_t last_change_at() const
boost::intrusive_ptr< const BgpAttr > BgpAttrPtr
const std::string & sub_protocol() const
Ip4Address GetOutboundIp4Address() const
static void FillRoutePathExtCommunityInfo(const BgpTable *table, const ExtCommunity *extcomm, ShowRoutePath *show_path, vector< string > *communities)
PathSource GetSource() const
static const std::string integerToString(const NumberType &num)
const AsPath4Byte * aspath_4byte() const
virtual bool IsRoutingPolicySupported() const
const ClusterList * cluster_list() const
ExtCommunityDB * extcomm_db()
std::string ToString() const
BgpConfigManager * config_manager()
std::string GetTunnelArTypeString() const
virtual const std::string & ToString() const =0
static void FillPmsiTunnelInfo(const PmsiTunnel *pmsi_tunnel, const ExtCommunity *ext, ShowRoutePath *show_path)
TunnelEncapType::Encap tunnel_encap() const
static boost::posix_time::ptime UTCUsecToPTime(uint64_t tusec)
virtual std::string ToString() const =0
std::string ToString() const
void UpdatePeerRefCount(int count, Address::Family family) const
bool IsVrfOriginated() const
const std::string & name() const
const EdgeDiscoverySpec & edge_discovery() const
const As4Path * as4_path() const
uint32_t GetLabel() const
static void FillRoutePathClusterListInfo(const ClusterList *clist, ShowRoutePath *show_path)
virtual std::string ToString() const
bool ProcessRoutingPolicy(const BgpRoute *route, BgpPath *path) const
uint32_t sequence_number() const
boost::asio::ip::address_v4 Ip4Address
uint32_t subcluster_id() const
const AsPath * as_path() const
uint32_t SubClusterId() const
void InsertPath(BgpPath *path)
const BgpAttr * GetOriginalAttr() const
bool DuplicateForwardingPath(const BgpPath *in_path) const
bool RemovePath(BgpPath::PathSource src, const IPeer *peer=NULL, uint32_t path_id=0)
const RoutingInstanceMgr * manager() const
const Path * front() const
BgpPath * FindSecondaryPath(BgpRoute *src_rt, BgpPath::PathSource src, const IPeer *peer, uint32_t path_id)
const ExtCommunity * ext_community() const
const BgpRoute * src_rt() const
const OriginVnList & origin_vns() const
const AsPath4ByteSpec & path() const
void AddExtCommunitySubCluster(uint32_t subcluster_id)
static bool PathSelection(const Path &path1, const Path &path2)
std::string GetVirtualNetworkByVnIndex(int vn_index) const
const BgpAttr * GetAttr() const
std::vector< std::string > GetFlagsStringList() const
std::string ToString() const
const std::string GetVirtualNetworkName() const
void set_med(uint32_t med)
std::string ToString() const
const PmsiTunnelSpec & pmsi_tunnel() const
std::string GetTunnelTypeString() const
const uint64_t time_stamp_usecs() const
void DeletePath(BgpPath *path)
const EdgeForwarding * edge_forwarding() const
const As4PathSpec & path() const
std::string ToString() const
DBTablePartBase * get_table_partition() const
const BgpTable * src_table() const
const EdgeDiscovery * edge_discovery() const
static void FillEdgeForwardingInfo(const EdgeForwarding *edge_forwarding, ShowRoutePath *show_path)
std::string ToString() const
std::string bgp_identifier_string() const
virtual std::string ToString() const
const PmsiTunnel * pmsi_tunnel() const
virtual const BgpProtocolConfig * GetProtocolConfig(const std::string &instance_name) const =0
virtual void ProcessPathTunnelEncapsulation(const BgpPath *path, BgpAttr *attr, ExtCommunityDB *extcomm_db, const BgpTable *table) const =0
virtual bool IsReplicated() const
void insert(const Path *path)
virtual bool IsValid() const
void SetAttr(const BgpAttrPtr attr, const BgpAttrPtr original_attr)
uint32_t GetLabel(const ExtCommunity *ext) const
const PathList & GetPathList() const