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