OpenSDN source code
xmpp_message_builder.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 
7 
8 #include <boost/foreach.hpp>
9 
10 #include <algorithm>
11 
12 #include "bgp/ipeer.h"
13 #include "bgp/bgp_server.h"
14 #include "bgp/bgp_table.h"
18 #include "bgp/evpn/evpn_route.h"
19 #include "bgp/mvpn/mvpn_route.h"
22 #include "db/db.h"
23 #include "net/community_type.h"
24 #include "schema/xmpp_multicast_types.h"
25 #include "schema/xmpp_mvpn_types.h"
26 #include "schema/xmpp_enet_types.h"
27 #include "xmpp/xmpp_init.h"
28 
29 using pugi::xml_attribute;
30 using pugi::xml_document;
31 using pugi::xml_node;
32 using std::ostringstream;
33 using std::copy;
34 using std::fill;
35 using std::string;
36 using std::stringstream;
37 using std::vector;
38 
39 static inline const char *AfiName(uint16_t afi) {
40  switch (afi) {
41  case BgpAf::IPv4:
42  return "1";
43  break;
44  case BgpAf::IPv6:
45  return "2";
46  break;
47  case BgpAf::L2Vpn:
48  return "25";
49  break;
50  }
51  assert(false);
52  return NULL;
53 }
54 
55 static inline const char *XmppSafiName(uint8_t safi) {
56  switch (safi) {
57  case BgpAf::Unicast:
58  return "1";
59  break;
60  case BgpAf::Mpls:
61  return "4";
62  break;
63  case BgpAf::MVpn:
64  return "5";
65  break;
66  case BgpAf::Mcast:
67  return "241";
68  break;
69  case BgpAf::Enet:
70  return "242";
71  break;
72  }
73  assert(false);
74  return NULL;
75 }
76 
78  : table_(NULL),
79  writer_(XmlWriter(&repr_)),
80  is_reachable_(false),
81  cache_routes_(false),
82  repr_valid_(false),
83  mobility_(0, false),
84  etree_leaf_(false) {
86 }
87 
89 }
90 
93  table_ = NULL;
94  is_reachable_ = false;
95  cache_routes_ = false;
96  repr_valid_ = false;
97  repr_.clear();
98 }
99 
100 bool BgpXmppMessage::Start(const RibOut *ribout, bool cache_routes,
101  const RibOutAttr *roattr, const BgpRoute *route) {
102  Reset();
103  table_ = ribout->table();
104  is_reachable_ = roattr->IsReachable();
105  cache_routes_ = cache_routes;
106  Address::Family family = table_->family();
107 
108  if (is_reachable_) {
109  const BgpAttr *attr = roattr->attr();
110  ProcessCommunity(attr->community());
112  }
113 
114  // Reserve space for the begin line that contains the message opening tag
115  // with from and to attributes. Actual value gets patched in when GetData
116  // is called.
117  repr_.append(kMaxFromToLength, ' ');
118 
119  // Add opening tags for event and items. The closing tags are added when
120  // GetData is called.
121  repr_ += "\n\t<event xmlns=\"http://jabber.org/protocol/pubsub\">";
122  repr_ += "\n\t\t<items node=\"";
123  repr_ += AfiName(BgpAf::FamilyToAfi(family));
124  repr_ += "/";
126  repr_ += "/";
128  repr_ += "\">\n";
129 
130  if (table_->family() == Address::ERMVPN) {
131  AddMcastRoute(route, roattr);
132  } else if (table_->family() == Address::EVPN) {
133  AddEnetRoute(route, roattr);
134  } else if (table_->family() == Address::INET6) {
135  AddInet6Route(route, roattr);
136  } else if (table_->family() == Address::MVPN) {
137  AddMvpnRoute(route, roattr);
138  } else {
139  AddInetRoute(route, roattr);
140  }
141  return true;
142 }
143 
145 }
146 
147 bool BgpXmppMessage::AddRoute(const BgpRoute *route, const RibOutAttr *roattr) {
148  assert(is_reachable_ == roattr->IsReachable());
150  return false;
152  return false;
153 
154  if (is_reachable_) {
155  const BgpAttr *attr = roattr->attr();
156  ProcessCommunity(attr->community());
158  }
159 
160  if (table_->family() == Address::ERMVPN) {
161  return AddMcastRoute(route, roattr);
162  } else if (table_->family() == Address::EVPN) {
163  return AddEnetRoute(route, roattr);
164  } else if (table_->family() == Address::INET6) {
165  return AddInet6Route(route, roattr);
166  } else if (table_->family() == Address::MVPN) {
167  return AddMvpnRoute(route, roattr);
168  } else {
169  return AddInetRoute(route, roattr);
170  }
171 }
172 
174  const RibOutAttr::NextHop &nexthop,
175  autogen::ItemType *item) {
176  autogen::NextHopType item_nexthop;
177 
178  const IpAddress &address = nexthop.address();
179  if (address.is_v4()) {
180  item_nexthop.af = BgpAf::IPv4;
181  item_nexthop.address = address.to_v4().to_string();
182  } else {
183  item_nexthop.af = BgpAf::IPv6;
184  item_nexthop.address = address.to_v6().to_string();
185  }
186  item_nexthop.label = nexthop.label();
187  item_nexthop.virtual_network = GetVirtualNetwork(nexthop);
188  item_nexthop.tag_list.tag = nexthop.tag_list();
189  item_nexthop.is_new_tags_list = true;
190 
191  // If there's a non-zero label and encap list is empty use mpls over gre
192  // as default encap.
193  if (item_nexthop.label) {
194  vector<string> &encap_list =
195  item_nexthop.tunnel_encapsulation_list.tunnel_encapsulation;
196  if (nexthop.encap().empty()) {
197  encap_list.push_back(string("gre"));
198  } else {
199  encap_list = nexthop.encap();
200  }
201  }
202 
203  item->entry.next_hops.next_hop.push_back(item_nexthop);
204 }
205 
207  const RibOutAttr *roattr) {
208  if (!roattr->repr().empty()) {
209  repr_ += roattr->repr();
210  return;
211  }
212  Address::Family family = table_->family();
213 
214  autogen::ItemType item;
215  item.entry.nlri.af = BgpAf::FamilyToAfi(family);
216  item.entry.nlri.safi = BgpAf::FamilyToXmppSafi(family);
217  item.entry.nlri.address = route->ToString();
218  item.entry.version = 1;
219  item.entry.virtual_network = GetVirtualNetwork(route, roattr);
220  item.entry.local_preference = roattr->attr()->local_pref();
221  item.entry.med = roattr->attr()->med();
222  item.entry.sequence_number = mobility_.sequence_number;
223  item.entry.mobility.seqno = mobility_.sequence_number;
224  item.entry.mobility.sticky = mobility_.sticky;
225 
226  assert(!roattr->nexthop_list().empty());
227 
228  // Encode all next-hops in the list.
229  BOOST_FOREACH(const RibOutAttr::NextHop &nexthop, roattr->nexthop_list()) {
230  EncodeNextHop(route, nexthop, &item);
231  }
232 
233  for (vector<int>::const_iterator it = security_group_list_.begin();
234  it != security_group_list_.end(); ++it) {
235  item.entry.security_group_list.security_group.push_back(*it);
236  }
237 
238  for (vector<string>::const_iterator it = community_list_.begin();
239  it != community_list_.end(); ++it) {
240  item.entry.community_tag_list.community_tag.push_back(*it);
241  }
242 
243  // Encode load balance attribute.
245  load_balance_attribute_.Encode(&item.entry.load_balance);
246 
247  xml_node node = doc_.append_child("item");
248  node.append_attribute("id") = route->ToXmppIdString().c_str();
249 
250  // Remember the previous size.
251  // Using remove_child instead of reset allows memory pages allocated for
252  // the xml_document to be reused during the lifetime of the xml_document.
253  size_t pos = repr_.size();
254  item.Encode(&node);
255  doc_.print(writer_, "\t", pugi::format_default, pugi::encoding_auto, 3);
256  doc_.remove_child(node);
257 
258  // Cache the substring starting at the previous size.
259  if (cache_routes_)
260  roattr->set_repr(repr_, pos);
261 }
262 
264  repr_ += "\t\t\t<retract id=\"" + route->ToXmppIdString() + "\" />\n";
265 }
266 
268  const RibOutAttr *roattr) {
269  if (is_reachable_) {
271  AddIpReach(route, roattr);
272  } else {
274  AddIpUnreach(route);
275  }
276  return true;
277 }
278 
280  const RibOutAttr *roattr) {
281  if (is_reachable_) {
283  AddIpReach(route, roattr);
284  } else {
286  AddIpUnreach(route);
287  }
288  return true;
289 }
290 
292  const RibOutAttr::NextHop &nexthop,
293  autogen::EnetItemType *item) {
294  autogen::EnetNextHopType item_nexthop;
295 
296  item_nexthop.af = BgpAf::IPv4;
297  item_nexthop.address = nexthop.address().to_v4().to_string();
298  item_nexthop.label = nexthop.label();
299  item_nexthop.l3_label = nexthop.l3_label();
300  if (!nexthop.mac().IsZero())
301  item_nexthop.mac = nexthop.mac().ToString();
302 
303  // If encap list is empty use mpls over gre as default encap.
304  vector<string> &encap_list =
305  item_nexthop.tunnel_encapsulation_list.tunnel_encapsulation;
306  if (nexthop.encap().empty()) {
307  encap_list.push_back(string("gre"));
308  } else {
309  encap_list = nexthop.encap();
310  }
311  item_nexthop.tag_list.tag = nexthop.tag_list();
312  item_nexthop.is_new_tags_list = true;
313  item->entry.next_hops.next_hop.push_back(item_nexthop);
314 }
315 
317  const RibOutAttr *roattr) {
318  if (!roattr->repr().empty()) {
319  repr_ += roattr->repr();
320  return;
321  }
322  Address::Family family = table_->family();
323 
324  autogen::EnetItemType item;
325  item.entry.nlri.af = BgpAf::FamilyToAfi(family);
326  item.entry.nlri.safi = BgpAf::FamilyToXmppSafi(family);
327 
328  EvpnRoute *evpn_route =
329  static_cast<EvpnRoute *>(const_cast<BgpRoute *>(route));
330  const EvpnPrefix &evpn_prefix = evpn_route->GetPrefix();
331  item.entry.nlri.ethernet_tag = evpn_prefix.tag();
332  item.entry.nlri.mac = evpn_prefix.mac_addr().ToString();
333  item.entry.nlri.address = evpn_prefix.ip_address().to_string() + "/" +
334  integerToString(evpn_prefix.ip_address_length());
335  item.entry.nlri.source = evpn_prefix.source().to_string();
336  item.entry.nlri.group = evpn_prefix.group().to_string();
337 
338  item.entry.virtual_network = GetVirtualNetwork(route, roattr);
339  item.entry.local_preference = roattr->attr()->local_pref();
340  item.entry.med = roattr->attr()->med();
341  item.entry.sequence_number = mobility_.sequence_number;
342  item.entry.mobility.seqno = mobility_.sequence_number;
343  item.entry.mobility.sticky = mobility_.sticky;
344  item.entry.etree_leaf = etree_leaf_;
345 
346  for (vector<int>::const_iterator it = security_group_list_.begin();
347  it != security_group_list_.end(); ++it) {
348  item.entry.security_group_list.security_group.push_back(*it);
349  }
350 
351  const BgpOList *olist = roattr->attr()->olist().get();
352  assert((olist == NULL) != roattr->nexthop_list().empty());
353 
354  if (olist) {
355  assert(olist->olist().subcode == BgpAttribute::OList);
356  BOOST_FOREACH(const BgpOListElem *elem, olist->elements()) {
357  autogen::EnetNextHopType nh;
358  nh.af = BgpAf::IPv4;
359  nh.address = elem->address.to_string();
360  nh.label = elem->label;
361  nh.tunnel_encapsulation_list.tunnel_encapsulation = elem->encap;
362  item.entry.olist.next_hop.push_back(nh);
363  }
364  }
365 
366  const BgpOList *leaf_olist = roattr->attr()->leaf_olist().get();
367  assert((leaf_olist == NULL) != roattr->nexthop_list().empty());
368 
369  if (leaf_olist) {
370  assert(leaf_olist->olist().subcode == BgpAttribute::LeafOList);
371  BOOST_FOREACH(const BgpOListElem *elem, leaf_olist->elements()) {
372  autogen::EnetNextHopType nh;
373  nh.af = BgpAf::IPv4;
374  nh.address = elem->address.to_string();
375  nh.label = elem->label;
376  nh.tunnel_encapsulation_list.tunnel_encapsulation = elem->encap;
377  item.entry.leaf_olist.next_hop.push_back(nh);
378  }
379  }
380 
381  BOOST_FOREACH(const RibOutAttr::NextHop &nexthop, roattr->nexthop_list()) {
382  EncodeEnetNextHop(route, nexthop, &item);
383  }
384 
385  for (const auto &peer_name : route->peer_sources()) {
386  item.entry.peers.peer.push_back(peer_name);
387  }
388 
389  xml_node node = doc_.append_child("item");
390  node.append_attribute("id") = route->ToXmppIdString().c_str();
391 
392  // Remember the previous size.
393  // Using remove_child instead of reset allows memory pages allocated for
394  // the xml_document to be reused during the lifetime of the xml_document.
395  size_t pos = repr_.size();
396  item.Encode(&node);
397  doc_.print(writer_, "\t", pugi::format_default, pugi::encoding_auto, 3);
398  doc_.remove_child(node);
399 
400  // Cache the substring starting at the previous size.
401  if (cache_routes_)
402  roattr->set_repr(repr_, pos);
403 }
404 
406  repr_ += "\t\t\t<retract id=\"" + route->ToXmppIdString() + "\" />\n";
407 }
408 
410  const RibOutAttr *roattr) {
411  if (is_reachable_) {
413  AddEnetReach(route, roattr);
414  } else {
416  AddEnetUnreach(route);
417  }
418  return true;
419 }
420 
421 //
422 // Note that there's no need to cache the string representation since a given
423 // mcast route is sent to exactly one xmpp peer.
424 //
426  const RibOutAttr *roattr) {
427  Address::Family family = table_->family();
428  autogen::McastItemType item;
429  item.entry.nlri.af = BgpAf::FamilyToAfi(family);
430  item.entry.nlri.safi = BgpAf::FamilyToXmppSafi(family);
431 
432  ErmVpnRoute *ermvpn_route =
433  static_cast<ErmVpnRoute *>(const_cast<BgpRoute *>(route));
434  item.entry.nlri.group = ermvpn_route->GetPrefix().group().to_string();
435  item.entry.nlri.source = ermvpn_route->GetPrefix().source().to_string();
436  item.entry.nlri.source_label = roattr->label();
437  if (!roattr->source_address().is_unspecified()) {
438  item.entry.nlri.source_address =
439  roattr->source_address().to_string();
440  }
441 
442  const BgpOList *olist = roattr->attr()->olist().get();
443  assert(olist->olist().subcode == BgpAttribute::OList);
444  BOOST_FOREACH(const BgpOListElem *elem, olist->elements()) {
445  autogen::McastNextHopType nh;
446  nh.af = BgpAf::IPv4;
447  nh.address = elem->address.to_string();
448  nh.label = integerToString(elem->label);
449  nh.tunnel_encapsulation_list.tunnel_encapsulation = elem->encap;
450  item.entry.olist.next_hop.push_back(nh);
451  }
452 
453  // Using remove_child instead of reset allows memory pages allocated for
454  // the xml_document to be reused during the lifetime of the xml_document.
455  xml_node node = doc_.append_child("item");
456  node.append_attribute("id") = route->ToXmppIdString().c_str();
457  item.Encode(&node);
458  doc_.print(writer_, "\t", pugi::format_default, pugi::encoding_auto, 3);
459  doc_.remove_child(node);
460 }
461 
463  repr_ += "\t\t\t<retract id=\"" + route->ToXmppIdString() + "\" />\n";
464 }
465 
467  const RibOutAttr *roattr) {
468  if (is_reachable_) {
470  AddMcastReach(route, roattr);
471  } else {
473  AddMcastUnreach(route);
474  }
475  return true;
476 }
477 
479  const RibOutAttr *roattr) {
480  Address::Family family = table_->family();
481  autogen::MvpnItemType item;
482  item.entry.nlri.af = BgpAf::FamilyToAfi(family);
483  item.entry.nlri.safi = BgpAf::FamilyToXmppSafi(family);
484 
485  MvpnRoute *mvpn_route =
486  static_cast<MvpnRoute *>(const_cast<BgpRoute *>(route));
487  item.entry.nlri.group = mvpn_route->GetPrefix().group().to_string();
488  item.entry.nlri.source = mvpn_route->GetPrefix().source().to_string();
489  item.entry.nlri.route_type = mvpn_route->GetPrefix().type();
490  assert((item.entry.nlri.route_type == MvpnPrefix::SourceActiveADRoute) ||
491  (item.entry.nlri.route_type == MvpnPrefix::SourceTreeJoinRoute));
492 
493  if (item.entry.nlri.route_type == MvpnPrefix::SourceActiveADRoute) {
494  const BgpOList *olist = roattr->attr()->olist().get();
495  assert(olist->olist().subcode == BgpAttribute::OList);
496  BOOST_FOREACH(const BgpOListElem *elem, olist->elements()) {
497  autogen::MvpnNextHopType nh;
498  nh.af = BgpAf::IPv4;
499  nh.address = elem->address.to_string();
500  nh.label = elem->label;
501  nh.tunnel_encapsulation_list.tunnel_encapsulation = elem->encap;
502  item.entry.olist.next_hop.push_back(nh);
503  }
504  }
505 
506  // Using remove_child instead of reset allows memory pages allocated for
507  // the xml_document to be reused during the lifetime of the xml_document.
508  xml_node node = doc_.append_child("item");
509  node.append_attribute("id") = route->ToXmppIdString().c_str();
510  item.Encode(&node);
511  doc_.print(writer_, "\t", pugi::format_default, pugi::encoding_auto, 3);
512  doc_.remove_child(node);
513 }
514 
516  repr_ += "\t\t\t<retract id=\"" + route->ToXmppIdString() + "\" />\n";
517 }
518 
520  const RibOutAttr *roattr) {
521  if (is_reachable_) {
523  AddMvpnReach(route, roattr);
524  } else {
526  AddMvpnUnreach(route);
527  }
528  return true;
529 }
530 
531 const uint8_t *BgpXmppMessage::GetData(IPeerUpdate *peer, size_t *lenp,
532  const string **msg_str, string *temp) {
533  // Build begin line that contains message opening tag with from and to
534  // attributes.
535  msg_begin_.clear();
536  msg_begin_ += "\n<message from=\"";
538  msg_begin_ += "\" to=\"";
539  msg_begin_ += peer->ToString();
540  msg_begin_ += "/";
542  msg_begin_ += "\">";
543 
544  // Add closing tags if this is the first peer to which the message will
545  // be sent.
546  if (!repr_valid_) {
547  repr_ += "\t\t</items>\n\t</event>\n</message>\n";
548  repr_valid_ = true;
549  }
550 
551  // Replace the begin line if it fits in the space reserved at the start
552  // of repr_. Use fill and copy instead of string::replace as the latter
553  // seems to construct a new temporary string to hold the input data to
554  // be copied.
555  // Otherwise build a new string with the begin line and the rest of the
556  // message in repr_.
557  size_t begin_size = msg_begin_.size();
558  if (begin_size <= kMaxFromToLength) {
559  size_t extra = kMaxFromToLength - begin_size;
560  char *data = const_cast<char *>(repr_.c_str());
561  fill(data, data + extra, ' ');
562  copy(msg_begin_.c_str(), msg_begin_.c_str() + begin_size, data + extra);
563  *lenp = repr_.size() - extra;
564  *msg_str = &repr_;
565  return reinterpret_cast<const uint8_t *>(repr_.c_str()) + extra;
566  } else {
567  *temp = msg_begin_ + string(repr_, kMaxFromToLength);
568  *lenp = temp->size();
569  *msg_str = NULL;
570  return reinterpret_cast<const uint8_t *>(temp->c_str());
571  }
572 }
573 
575  community_list_.clear();
576  if (community == NULL)
577  return;
578  BOOST_FOREACH(uint32_t value, community->communities()) {
580  }
581 }
582 
585  mobility_.sticky = false;
586  etree_leaf_ = false;
587  security_group_list_.clear();
589  if (ext_community == NULL)
590  return;
591 
592  as_t as_number = table_->server()->autonomous_system();
593  bool sg_asn_match = true;
594  for (ExtCommunity::ExtCommunityList::const_iterator iter =
595  ext_community->communities().begin();
596  iter != ext_community->communities().end(); ++iter) {
597  if (ExtCommunity::is_security_group(*iter)) {
598  SecurityGroup sg(*iter);
599  if (as_number <= AS2_MAX)
600  if (sg.as_number() != as_number && !sg.IsGlobal())
601  continue;
602  security_group_list_.push_back(sg.security_group_id());
603  } else if (ExtCommunity::is_security_group4(*iter)) {
604  SecurityGroup4ByteAs sg(*iter);
605  if (sg.as_number() != as_number)
606  sg_asn_match = false;
607  } else if (ExtCommunity::is_mac_mobility(*iter)) {
608  MacMobility mm(*iter);
610  mobility_.sticky = mm.sticky();
611  } else if (ExtCommunity::is_load_balance(*iter)) {
612  LoadBalance load_balance(*iter);
613  load_balance.FillAttribute(&load_balance_attribute_);
614  } else if (ExtCommunity::is_etree(*iter)) {
615  ETree etree(*iter);
616  etree_leaf_ = etree.leaf();
617  }
618  }
619  if (!sg_asn_match)
620  security_group_list_.clear();
621 }
622 
624  const RibOutAttr::NextHop &nexthop) const {
625  int index = nexthop.origin_vn_index();
626  if (index > 0) {
627  const RoutingInstanceMgr *manager =
629  return manager->GetVirtualNetworkByVnIndex(index);
630  } else if (index == 0) {
632  } else {
633  return "unresolved";
634  }
635 }
636 
638  const RibOutAttr *roattr) const {
639  if (!is_reachable_) {
640  return "unresolved";
641  } else if (roattr->nexthop_list().empty()) {
642  if (roattr->vrf_originated()) {
644  } else {
645  return "unresolved";
646  }
647  } else {
648  return GetVirtualNetwork(roattr->nexthop_list().front());
649  }
650 }
651 
653 }
654 
656  return new BgpXmppMessage;
657 }
boost::asio::ip::address IpAddress
Definition: address.h:14
#define AS2_MAX
Definition: bgp_common.h:25
uint32_t as_t
Definition: bgp_common.h:22
Family
Definition: address.h:25
@ EVPN
Definition: address.h:32
@ ERMVPN
Definition: address.h:33
@ INET6
Definition: address.h:28
@ MVPN
Definition: address.h:34
static uint8_t FamilyToXmppSafi(Address::Family family)
Definition: bgp_af.cc:218
@ Enet
Definition: bgp_af.h:33
@ Unicast
Definition: bgp_af.h:26
@ MVpn
Definition: bgp_af.h:28
@ Mcast
Definition: bgp_af.h:32
@ Mpls
Definition: bgp_af.h:27
static Afi FamilyToAfi(Address::Family family)
Definition: bgp_af.cc:160
@ L2Vpn
Definition: bgp_af.h:22
@ IPv4
Definition: bgp_af.h:20
@ IPv6
Definition: bgp_af.h:21
uint32_t local_pref() const
Definition: bgp_attr.h:892
uint32_t med() const
Definition: bgp_attr.h:891
const Community * community() const
Definition: bgp_attr.h:917
BgpOListPtr olist() const
Definition: bgp_attr.h:931
BgpOListPtr leaf_olist() const
Definition: bgp_attr.h:932
const ExtCommunity * ext_community() const
Definition: bgp_attr.h:918
uint8_t subcode
Definition: bgp_attr_base.h:71
Ip4Address address
Definition: bgp_attr.h:673
std::vector< std::string > encap
Definition: bgp_attr.h:675
uint32_t label
Definition: bgp_attr.h:674
const BgpOListSpec & olist() const
Definition: bgp_attr.h:705
const Elements & elements() const
Definition: bgp_attr.h:715
const std::set< std::string > & peer_sources() const
Definition: bgp_route.h:86
virtual std::string ToXmppIdString() const
Definition: bgp_route.h:66
as_t autonomous_system() const
Definition: bgp_server.h:213
BgpServer * server()
Definition: bgp_table.cc:88
RoutingInstance * routing_instance()
Definition: bgp_table.h:148
virtual Address::Family family() const =0
virtual Message * Create() const
LoadBalance::LoadBalanceAttribute load_balance_attribute_
std::string GetVirtualNetwork(const RibOutAttr::NextHop &nexthop) const
std::vector< int > security_group_list_
void AddIpReach(const BgpRoute *route, const RibOutAttr *roattr)
void AddIpUnreach(const BgpRoute *route)
bool AddInet6Route(const BgpRoute *route, const RibOutAttr *roattr)
void AddEnetReach(const BgpRoute *route, const RibOutAttr *roattr)
virtual bool AddRoute(const BgpRoute *route, const RibOutAttr *roattr)
void ProcessExtCommunity(const ExtCommunity *ext_community)
virtual void Reset()
void EncodeNextHop(const BgpRoute *route, const RibOutAttr::NextHop &nexthop, autogen::ItemType *item)
void AddEnetUnreach(const BgpRoute *route)
bool AddEnetRoute(const BgpRoute *route, const RibOutAttr *roattr)
pugi::xml_document doc_
void ProcessCommunity(const Community *community)
virtual void Finish()
static const size_t kMaxFromToLength
MobilityInfo mobility_
void AddMvpnReach(const BgpRoute *route, const RibOutAttr *roattr)
static const uint32_t kMaxReachCount
bool AddMvpnRoute(const BgpRoute *route, const RibOutAttr *roattr)
const BgpTable * table_
void EncodeEnetNextHop(const BgpRoute *route, const RibOutAttr::NextHop &nexthop, autogen::EnetItemType *item)
bool AddMcastRoute(const BgpRoute *route, const RibOutAttr *roattr)
static const uint32_t kMaxUnreachCount
std::vector< std::string > community_list_
void AddMvpnUnreach(const BgpRoute *route)
void AddMcastUnreach(const BgpRoute *route)
bool AddInetRoute(const BgpRoute *route, const RibOutAttr *roattr)
virtual bool Start(const RibOut *ribout, bool cache_routes, const RibOutAttr *roattr, const BgpRoute *route)
void AddMcastReach(const BgpRoute *route, const RibOutAttr *roattr)
virtual const uint8_t * GetData(IPeerUpdate *peer, size_t *lenp, const std::string **msg_str, std::string *temp)
static const std::string CommunityToString(uint32_t comm)
const std::vector< uint32_t > & communities() const
Definition: community.h:68
virtual std::string ToString() const =0
Definition: etree.h:17
bool leaf() const
Definition: etree.cc:30
Ip4Address source() const
Definition: ermvpn_route.h:61
Ip4Address group() const
Definition: ermvpn_route.h:60
const ErmVpnPrefix & GetPrefix() const
Definition: ermvpn_route.h:82
uint32_t tag() const
IpAddress ip_address() const
uint8_t ip_address_length() const
const MacAddress & mac_addr() const
IpAddress source() const
IpAddress group() const
const EvpnPrefix & GetPrefix() const
static bool is_security_group4(const ExtCommunityValue &val)
Definition: community.h:316
const ExtCommunityList & communities() const
Definition: community.h:183
static bool is_load_balance(const ExtCommunityValue &val)
Definition: community.h:375
static bool is_security_group(const ExtCommunityValue &val)
Definition: community.h:307
static bool is_mac_mobility(const ExtCommunityValue &val)
Definition: community.h:230
static bool is_etree(const ExtCommunityValue &val)
Definition: community.h:243
virtual const std::string & ToString() const =0
void FillAttribute(LoadBalanceAttribute *attr)
std::string ToString() const
Definition: mac_address.cc:54
bool IsZero() const
Definition: mac_address.cc:30
bool sticky() const
Definition: mac_mobility.cc:29
uint32_t sequence_number() const
Definition: mac_mobility.cc:33
uint64_t num_reach_route_
virtual void Reset()
uint64_t num_unreach_route_
Ip4Address source() const
Definition: mvpn_route.h:76
uint8_t type() const
Definition: mvpn_route.h:73
@ SourceTreeJoinRoute
Definition: mvpn_route.h:47
@ SourceActiveADRoute
Definition: mvpn_route.h:45
Ip4Address group() const
Definition: mvpn_route.h:75
const MvpnPrefix & GetPrefix() const
Definition: mvpn_route.h:140
uint32_t label() const
Definition: bgp_ribout.h:59
uint32_t l3_label() const
Definition: bgp_ribout.h:60
std::vector< uint64_t > tag_list() const
Definition: bgp_ribout.h:64
std::vector< std::string > encap() const
Definition: bgp_ribout.h:63
const MacAddress & mac() const
Definition: bgp_ribout.h:58
int origin_vn_index() const
Definition: bgp_ribout.h:62
const IpAddress address() const
Definition: bgp_ribout.h:57
const BgpAttr * attr() const
Definition: bgp_ribout.h:99
const Ip4Address & source_address() const
Definition: bgp_ribout.h:123
bool vrf_originated() const
Definition: bgp_ribout.h:126
bool IsReachable() const
Definition: bgp_ribout.h:96
const NextHopList & nexthop_list() const
Definition: bgp_ribout.h:98
void set_repr(const std::string &repr, size_t pos=0) const
Definition: bgp_ribout.h:128
uint32_t label() const
Definition: bgp_ribout.h:117
const std::string & repr() const
Definition: bgp_ribout.h:127
BgpTable * table()
Definition: bgp_ribout.h:306
std::string GetVirtualNetworkByVnIndex(int vn_index) const
const std::string & name() const
const RoutingInstanceMgr * manager() const
const std::string GetVirtualNetworkName() const
as_t as_number() const
uint32_t security_group_id() const
bool IsGlobal() const
as2_t as_number() const
static const char * kControlNodeJID
Definition: xmpp_init.h:18
static const char * kBgpPeer
Definition: xmpp_init.h:25
static const std::string integerToString(const NumberType &num)
Definition: string_util.h:20
void Encode(autogen::LoadBalanceType *lb_type) const
Definition: load_balance.cc:48
static const char * AfiName(uint16_t afi)
static const char * XmppSafiName(uint8_t safi)