OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
189  // If there's a non-zero label and encap list is empty use mpls over gre
190  // as default encap.
191  if (item_nexthop.label) {
192  vector<string> &encap_list =
193  item_nexthop.tunnel_encapsulation_list.tunnel_encapsulation;
194  if (nexthop.encap().empty()) {
195  encap_list.push_back(string("gre"));
196  } else {
197  encap_list = nexthop.encap();
198  }
199  }
200 
201  item->entry.next_hops.next_hop.push_back(item_nexthop);
202 }
203 
205  const RibOutAttr *roattr) {
206  if (!roattr->repr().empty()) {
207  repr_ += roattr->repr();
208  return;
209  }
210  Address::Family family = table_->family();
211 
212  autogen::ItemType item;
213  item.entry.nlri.af = BgpAf::FamilyToAfi(family);
214  item.entry.nlri.safi = BgpAf::FamilyToXmppSafi(family);
215  item.entry.nlri.address = route->ToString();
216  item.entry.version = 1;
217  item.entry.virtual_network = GetVirtualNetwork(route, roattr);
218  item.entry.local_preference = roattr->attr()->local_pref();
219  item.entry.med = roattr->attr()->med();
220  item.entry.sequence_number = mobility_.sequence_number;
221  item.entry.mobility.seqno = mobility_.sequence_number;
222  item.entry.mobility.sticky = mobility_.sticky;
223 
224  assert(!roattr->nexthop_list().empty());
225 
226  // Encode all next-hops in the list.
227  BOOST_FOREACH(const RibOutAttr::NextHop &nexthop, roattr->nexthop_list()) {
228  EncodeNextHop(route, nexthop, &item);
229  }
230 
231  for (vector<int>::const_iterator it = security_group_list_.begin();
232  it != security_group_list_.end(); ++it) {
233  item.entry.security_group_list.security_group.push_back(*it);
234  }
235 
236  for (vector<string>::const_iterator it = community_list_.begin();
237  it != community_list_.end(); ++it) {
238  item.entry.community_tag_list.community_tag.push_back(*it);
239  }
240 
241  // Encode load balance attribute.
243  load_balance_attribute_.Encode(&item.entry.load_balance);
244 
245  xml_node node = doc_.append_child("item");
246  node.append_attribute("id") = route->ToXmppIdString().c_str();
247 
248  // Remember the previous size.
249  // Using remove_child instead of reset allows memory pages allocated for
250  // the xml_document to be reused during the lifetime of the xml_document.
251  size_t pos = repr_.size();
252  item.Encode(&node);
253  doc_.print(writer_, "\t", pugi::format_default, pugi::encoding_auto, 3);
254  doc_.remove_child(node);
255 
256  // Cache the substring starting at the previous size.
257  if (cache_routes_)
258  roattr->set_repr(repr_, pos);
259 }
260 
262  repr_ += "\t\t\t<retract id=\"" + route->ToXmppIdString() + "\" />\n";
263 }
264 
266  const RibOutAttr *roattr) {
267  if (is_reachable_) {
269  AddIpReach(route, roattr);
270  } else {
272  AddIpUnreach(route);
273  }
274  return true;
275 }
276 
278  const RibOutAttr *roattr) {
279  if (is_reachable_) {
281  AddIpReach(route, roattr);
282  } else {
284  AddIpUnreach(route);
285  }
286  return true;
287 }
288 
290  const RibOutAttr::NextHop &nexthop,
291  autogen::EnetItemType *item) {
292  autogen::EnetNextHopType item_nexthop;
293 
294  item_nexthop.af = BgpAf::IPv4;
295  item_nexthop.address = nexthop.address().to_v4().to_string();
296  item_nexthop.label = nexthop.label();
297  item_nexthop.l3_label = nexthop.l3_label();
298  if (!nexthop.mac().IsZero())
299  item_nexthop.mac = nexthop.mac().ToString();
300 
301  // If encap list is empty use mpls over gre as default encap.
302  vector<string> &encap_list =
303  item_nexthop.tunnel_encapsulation_list.tunnel_encapsulation;
304  if (nexthop.encap().empty()) {
305  encap_list.push_back(string("gre"));
306  } else {
307  encap_list = nexthop.encap();
308  }
309  item_nexthop.tag_list.tag = nexthop.tag_list();
310  item->entry.next_hops.next_hop.push_back(item_nexthop);
311 }
312 
314  const RibOutAttr *roattr) {
315  if (!roattr->repr().empty()) {
316  repr_ += roattr->repr();
317  return;
318  }
319  Address::Family family = table_->family();
320 
321  autogen::EnetItemType item;
322  item.entry.nlri.af = BgpAf::FamilyToAfi(family);
323  item.entry.nlri.safi = BgpAf::FamilyToXmppSafi(family);
324 
325  EvpnRoute *evpn_route =
326  static_cast<EvpnRoute *>(const_cast<BgpRoute *>(route));
327  const EvpnPrefix &evpn_prefix = evpn_route->GetPrefix();
328  item.entry.nlri.ethernet_tag = evpn_prefix.tag();
329  item.entry.nlri.mac = evpn_prefix.mac_addr().ToString();
330  item.entry.nlri.address = evpn_prefix.ip_address().to_string() + "/" +
331  integerToString(evpn_prefix.ip_address_length());
332  item.entry.nlri.source = evpn_prefix.source().to_string();
333  item.entry.nlri.group = evpn_prefix.group().to_string();
334 
335  item.entry.virtual_network = GetVirtualNetwork(route, roattr);
336  item.entry.local_preference = roattr->attr()->local_pref();
337  item.entry.med = roattr->attr()->med();
338  item.entry.sequence_number = mobility_.sequence_number;
339  item.entry.mobility.seqno = mobility_.sequence_number;
340  item.entry.mobility.sticky = mobility_.sticky;
341  item.entry.etree_leaf = etree_leaf_;
342 
343  for (vector<int>::const_iterator it = security_group_list_.begin();
344  it != security_group_list_.end(); ++it) {
345  item.entry.security_group_list.security_group.push_back(*it);
346  }
347 
348  const BgpOList *olist = roattr->attr()->olist().get();
349  assert((olist == NULL) != roattr->nexthop_list().empty());
350 
351  if (olist) {
352  assert(olist->olist().subcode == BgpAttribute::OList);
353  BOOST_FOREACH(const BgpOListElem *elem, olist->elements()) {
354  autogen::EnetNextHopType nh;
355  nh.af = BgpAf::IPv4;
356  nh.address = elem->address.to_string();
357  nh.label = elem->label;
358  nh.tunnel_encapsulation_list.tunnel_encapsulation = elem->encap;
359  item.entry.olist.next_hop.push_back(nh);
360  }
361  }
362 
363  const BgpOList *leaf_olist = roattr->attr()->leaf_olist().get();
364  assert((leaf_olist == NULL) != roattr->nexthop_list().empty());
365 
366  if (leaf_olist) {
367  assert(leaf_olist->olist().subcode == BgpAttribute::LeafOList);
368  BOOST_FOREACH(const BgpOListElem *elem, leaf_olist->elements()) {
369  autogen::EnetNextHopType nh;
370  nh.af = BgpAf::IPv4;
371  nh.address = elem->address.to_string();
372  nh.label = elem->label;
373  nh.tunnel_encapsulation_list.tunnel_encapsulation = elem->encap;
374  item.entry.leaf_olist.next_hop.push_back(nh);
375  }
376  }
377 
378  BOOST_FOREACH(const RibOutAttr::NextHop &nexthop, roattr->nexthop_list()) {
379  EncodeEnetNextHop(route, nexthop, &item);
380  }
381 
382  xml_node node = doc_.append_child("item");
383  node.append_attribute("id") = route->ToXmppIdString().c_str();
384 
385  // Remember the previous size.
386  // Using remove_child instead of reset allows memory pages allocated for
387  // the xml_document to be reused during the lifetime of the xml_document.
388  size_t pos = repr_.size();
389  item.Encode(&node);
390  doc_.print(writer_, "\t", pugi::format_default, pugi::encoding_auto, 3);
391  doc_.remove_child(node);
392 
393  // Cache the substring starting at the previous size.
394  if (cache_routes_)
395  roattr->set_repr(repr_, pos);
396 }
397 
399  repr_ += "\t\t\t<retract id=\"" + route->ToXmppIdString() + "\" />\n";
400 }
401 
403  const RibOutAttr *roattr) {
404  if (is_reachable_) {
406  AddEnetReach(route, roattr);
407  } else {
409  AddEnetUnreach(route);
410  }
411  return true;
412 }
413 
414 //
415 // Note that there's no need to cache the string representation since a given
416 // mcast route is sent to exactly one xmpp peer.
417 //
419  const RibOutAttr *roattr) {
420  Address::Family family = table_->family();
421  autogen::McastItemType item;
422  item.entry.nlri.af = BgpAf::FamilyToAfi(family);
423  item.entry.nlri.safi = BgpAf::FamilyToXmppSafi(family);
424 
425  ErmVpnRoute *ermvpn_route =
426  static_cast<ErmVpnRoute *>(const_cast<BgpRoute *>(route));
427  item.entry.nlri.group = ermvpn_route->GetPrefix().group().to_string();
428  item.entry.nlri.source = ermvpn_route->GetPrefix().source().to_string();
429  item.entry.nlri.source_label = roattr->label();
430  if (!roattr->source_address().is_unspecified()) {
431  item.entry.nlri.source_address =
432  roattr->source_address().to_string();
433  }
434 
435  const BgpOList *olist = roattr->attr()->olist().get();
436  assert(olist->olist().subcode == BgpAttribute::OList);
437  BOOST_FOREACH(const BgpOListElem *elem, olist->elements()) {
438  autogen::McastNextHopType nh;
439  nh.af = BgpAf::IPv4;
440  nh.address = elem->address.to_string();
441  nh.label = integerToString(elem->label);
442  nh.tunnel_encapsulation_list.tunnel_encapsulation = elem->encap;
443  item.entry.olist.next_hop.push_back(nh);
444  }
445 
446  // Using remove_child instead of reset allows memory pages allocated for
447  // the xml_document to be reused during the lifetime of the xml_document.
448  xml_node node = doc_.append_child("item");
449  node.append_attribute("id") = route->ToXmppIdString().c_str();
450  item.Encode(&node);
451  doc_.print(writer_, "\t", pugi::format_default, pugi::encoding_auto, 3);
452  doc_.remove_child(node);
453 }
454 
456  repr_ += "\t\t\t<retract id=\"" + route->ToXmppIdString() + "\" />\n";
457 }
458 
460  const RibOutAttr *roattr) {
461  if (is_reachable_) {
463  AddMcastReach(route, roattr);
464  } else {
466  AddMcastUnreach(route);
467  }
468  return true;
469 }
470 
472  const RibOutAttr *roattr) {
473  Address::Family family = table_->family();
474  autogen::MvpnItemType item;
475  item.entry.nlri.af = BgpAf::FamilyToAfi(family);
476  item.entry.nlri.safi = BgpAf::FamilyToXmppSafi(family);
477 
478  MvpnRoute *mvpn_route =
479  static_cast<MvpnRoute *>(const_cast<BgpRoute *>(route));
480  item.entry.nlri.group = mvpn_route->GetPrefix().group().to_string();
481  item.entry.nlri.source = mvpn_route->GetPrefix().source().to_string();
482  item.entry.nlri.route_type = mvpn_route->GetPrefix().type();
483  assert((item.entry.nlri.route_type == MvpnPrefix::SourceActiveADRoute) ||
484  (item.entry.nlri.route_type == MvpnPrefix::SourceTreeJoinRoute));
485 
486  if (item.entry.nlri.route_type == MvpnPrefix::SourceActiveADRoute) {
487  const BgpOList *olist = roattr->attr()->olist().get();
488  assert(olist->olist().subcode == BgpAttribute::OList);
489  BOOST_FOREACH(const BgpOListElem *elem, olist->elements()) {
490  autogen::MvpnNextHopType nh;
491  nh.af = BgpAf::IPv4;
492  nh.address = elem->address.to_string();
493  nh.label = elem->label;
494  nh.tunnel_encapsulation_list.tunnel_encapsulation = elem->encap;
495  item.entry.olist.next_hop.push_back(nh);
496  }
497  }
498 
499  // Using remove_child instead of reset allows memory pages allocated for
500  // the xml_document to be reused during the lifetime of the xml_document.
501  xml_node node = doc_.append_child("item");
502  node.append_attribute("id") = route->ToXmppIdString().c_str();
503  item.Encode(&node);
504  doc_.print(writer_, "\t", pugi::format_default, pugi::encoding_auto, 3);
505  doc_.remove_child(node);
506 }
507 
509  repr_ += "\t\t\t<retract id=\"" + route->ToXmppIdString() + "\" />\n";
510 }
511 
513  const RibOutAttr *roattr) {
514  if (is_reachable_) {
516  AddMvpnReach(route, roattr);
517  } else {
519  AddMvpnUnreach(route);
520  }
521  return true;
522 }
523 
524 const uint8_t *BgpXmppMessage::GetData(IPeerUpdate *peer, size_t *lenp,
525  const string **msg_str, string *temp) {
526  // Build begin line that contains message opening tag with from and to
527  // attributes.
528  msg_begin_.clear();
529  msg_begin_ += "\n<message from=\"";
531  msg_begin_ += "\" to=\"";
532  msg_begin_ += peer->ToString();
533  msg_begin_ += "/";
535  msg_begin_ += "\">";
536 
537  // Add closing tags if this is the first peer to which the message will
538  // be sent.
539  if (!repr_valid_) {
540  repr_ += "\t\t</items>\n\t</event>\n</message>\n";
541  repr_valid_ = true;
542  }
543 
544  // Replace the begin line if it fits in the space reserved at the start
545  // of repr_. Use fill and copy instead of string::replace as the latter
546  // seems to construct a new temporary string to hold the input data to
547  // be copied.
548  // Otherwise build a new string with the begin line and the rest of the
549  // message in repr_.
550  size_t begin_size = msg_begin_.size();
551  if (begin_size <= kMaxFromToLength) {
552  size_t extra = kMaxFromToLength - begin_size;
553  char *data = const_cast<char *>(repr_.c_str());
554  fill(data, data + extra, ' ');
555  copy(msg_begin_.c_str(), msg_begin_.c_str() + begin_size, data + extra);
556  *lenp = repr_.size() - extra;
557  *msg_str = &repr_;
558  return reinterpret_cast<const uint8_t *>(repr_.c_str()) + extra;
559  } else {
560  *temp = msg_begin_ + string(repr_, kMaxFromToLength);
561  *lenp = temp->size();
562  *msg_str = NULL;
563  return reinterpret_cast<const uint8_t *>(temp->c_str());
564  }
565 }
566 
568  community_list_.clear();
569  if (community == NULL)
570  return;
571  BOOST_FOREACH(uint32_t value, community->communities()) {
573  }
574 }
575 
578  mobility_.sticky = false;
579  etree_leaf_ = false;
580  security_group_list_.clear();
582  if (ext_community == NULL)
583  return;
584 
585  as_t as_number = table_->server()->autonomous_system();
586  bool sg_asn_match = true;
587  for (ExtCommunity::ExtCommunityList::const_iterator iter =
588  ext_community->communities().begin();
589  iter != ext_community->communities().end(); ++iter) {
590  if (ExtCommunity::is_security_group(*iter)) {
591  SecurityGroup sg(*iter);
592  if (as_number <= AS2_MAX)
593  if (sg.as_number() != as_number && !sg.IsGlobal())
594  continue;
595  security_group_list_.push_back(sg.security_group_id());
596  } else if (ExtCommunity::is_security_group4(*iter)) {
597  SecurityGroup4ByteAs sg(*iter);
598  if (sg.as_number() != as_number)
599  sg_asn_match = false;
600  } else if (ExtCommunity::is_mac_mobility(*iter)) {
601  MacMobility mm(*iter);
603  mobility_.sticky = mm.sticky();
604  } else if (ExtCommunity::is_load_balance(*iter)) {
605  LoadBalance load_balance(*iter);
606  load_balance.FillAttribute(&load_balance_attribute_);
607  } else if (ExtCommunity::is_etree(*iter)) {
608  ETree etree(*iter);
609  etree_leaf_ = etree.leaf();
610  }
611  }
612  if (!sg_asn_match)
613  security_group_list_.clear();
614 }
615 
617  const RibOutAttr::NextHop &nexthop) const {
618  int index = nexthop.origin_vn_index();
619  if (index > 0) {
620  const RoutingInstanceMgr *manager =
622  return manager->GetVirtualNetworkByVnIndex(index);
623  } else if (index == 0) {
625  } else {
626  return "unresolved";
627  }
628 }
629 
631  const RibOutAttr *roattr) const {
632  if (!is_reachable_) {
633  return "unresolved";
634  } else if (roattr->nexthop_list().empty()) {
635  if (roattr->vrf_originated()) {
637  } else {
638  return "unresolved";
639  }
640  } else {
641  return GetVirtualNetwork(roattr->nexthop_list().front());
642  }
643 }
644 
646 }
647 
649  return new BgpXmppMessage;
650 }
virtual std::string ToXmppIdString() const
Definition: bgp_route.h:64
const Community * community() const
Definition: bgp_attr.h:914
const std::vector< uint32_t > & communities() const
Definition: community.h:65
std::vector< std::string > encap
Definition: bgp_attr.h:674
static const size_t kMaxFromToLength
static const uint32_t kMaxUnreachCount
const BgpOListSpec & olist() const
Definition: bgp_attr.h:704
void EncodeEnetNextHop(const BgpRoute *route, const RibOutAttr::NextHop &nexthop, autogen::EnetItemType *item)
BgpTable * table()
Definition: bgp_ribout.h:304
uint32_t local_pref() const
Definition: bgp_attr.h:889
void AddIpReach(const BgpRoute *route, const RibOutAttr *roattr)
const MacAddress & mac_addr() const
Definition: etree.h:16
LoadBalance::LoadBalanceAttribute load_balance_attribute_
const ErmVpnPrefix & GetPrefix() const
Definition: ermvpn_route.h:81
const BgpAttr * attr() const
Definition: bgp_ribout.h:97
const MacAddress & mac() const
Definition: bgp_ribout.h:56
uint32_t tag() const
static bool is_security_group(const ExtCommunityValue &val)
Definition: community.h:304
void EncodeNextHop(const BgpRoute *route, const RibOutAttr::NextHop &nexthop, autogen::ItemType *item)
const NextHopList & nexthop_list() const
Definition: bgp_ribout.h:96
bool AddMvpnRoute(const BgpRoute *route, const RibOutAttr *roattr)
RoutingInstance * routing_instance()
Definition: bgp_table.h:148
Family
Definition: address.h:24
static const uint32_t kMaxReachCount
static const std::string CommunityToString(uint32_t comm)
boost::asio::ip::address IpAddress
Definition: address.h:13
BgpOListPtr olist() const
Definition: bgp_attr.h:925
void ProcessExtCommunity(const ExtCommunity *ext_community)
std::vector< std::string > encap() const
Definition: bgp_ribout.h:61
const std::string & name() const
bool AddEnetRoute(const BgpRoute *route, const RibOutAttr *roattr)
virtual const std::string & ToString() const =0
virtual bool Start(const RibOut *ribout, bool cache_routes, const RibOutAttr *roattr, const BgpRoute *route)
const std::string & repr() const
Definition: bgp_ribout.h:125
void AddMvpnReach(const BgpRoute *route, const RibOutAttr *roattr)
uint64_t num_unreach_route_
virtual Address::Family family() const =0
uint32_t as_t
Definition: bgp_common.h:21
uint32_t security_group_id() const
void Encode(autogen::LoadBalanceType *lb_type) const
Definition: load_balance.cc:47
Ip4Address address
Definition: bgp_attr.h:672
virtual const uint8_t * GetData(IPeerUpdate *peer, size_t *lenp, const std::string **msg_str, std::string *temp)
void AddIpUnreach(const BgpRoute *route)
const Ip4Address & source_address() const
Definition: bgp_ribout.h:121
std::string ToString() const
Definition: mac_address.cc:53
virtual bool AddRoute(const BgpRoute *route, const RibOutAttr *roattr)
static bool is_security_group4(const ExtCommunityValue &val)
Definition: community.h:313
void ProcessCommunity(const Community *community)
uint8_t type() const
Definition: mvpn_route.h:72
bool vrf_originated() const
Definition: bgp_ribout.h:124
bool sticky() const
Definition: mac_mobility.cc:28
bool IsZero() const
Definition: mac_address.cc:29
std::vector< int > security_group_list_
static const std::string integerToString(const NumberType &num)
Definition: string_util.h:19
static const char * AfiName(uint16_t afi)
void AddEnetReach(const BgpRoute *route, const RibOutAttr *roattr)
const ExtCommunityList & communities() const
Definition: community.h:180
uint64_t num_reach_route_
IpAddress source() const
uint32_t l3_label() const
Definition: bgp_ribout.h:58
bool AddMcastRoute(const BgpRoute *route, const RibOutAttr *roattr)
std::string GetVirtualNetwork(const RibOutAttr::NextHop &nexthop) const
void AddMvpnUnreach(const BgpRoute *route)
virtual std::string ToString() const =0
uint8_t ip_address_length() const
static uint8_t FamilyToXmppSafi(Address::Family family)
Definition: bgp_af.cc:217
bool IsReachable() const
Definition: bgp_ribout.h:94
virtual Message * Create() const
void set_repr(const std::string &repr, size_t pos=0) const
Definition: bgp_ribout.h:126
Ip4Address source() const
Definition: ermvpn_route.h:60
uint32_t sequence_number() const
Definition: mac_mobility.cc:32
bool leaf() const
Definition: etree.cc:29
std::vector< int > tag_list() const
Definition: bgp_ribout.h:62
bool AddInetRoute(const BgpRoute *route, const RibOutAttr *roattr)
Ip4Address group() const
Definition: ermvpn_route.h:59
static Afi FamilyToAfi(Address::Family family)
Definition: bgp_af.cc:159
BgpServer * server()
Definition: bgp_table.cc:88
const RoutingInstanceMgr * manager() const
virtual void Finish()
const EvpnPrefix & GetPrefix() const
as2_t as_number() const
void AddEnetUnreach(const BgpRoute *route)
uint32_t label() const
Definition: bgp_ribout.h:115
const ExtCommunity * ext_community() const
Definition: bgp_attr.h:915
bool IsGlobal() const
MobilityInfo mobility_
void AddMcastReach(const BgpRoute *route, const RibOutAttr *roattr)
std::vector< std::string > community_list_
const Elements & elements() const
Definition: bgp_attr.h:714
const IpAddress address() const
Definition: bgp_ribout.h:55
std::string GetVirtualNetworkByVnIndex(int vn_index) const
uint32_t label
Definition: bgp_attr.h:673
const std::string GetVirtualNetworkName() const
as_t as_number() const
IpAddress group() const
IpAddress ip_address() const
int origin_vn_index() const
Definition: bgp_ribout.h:60
pugi::xml_document doc_
static bool is_etree(const ExtCommunityValue &val)
Definition: community.h:240
virtual void Reset()
virtual void Reset()
bool AddInet6Route(const BgpRoute *route, const RibOutAttr *roattr)
void AddMcastUnreach(const BgpRoute *route)
Ip4Address source() const
Definition: mvpn_route.h:75
uint32_t med() const
Definition: bgp_attr.h:888
uint32_t label() const
Definition: bgp_ribout.h:57
const MvpnPrefix & GetPrefix() const
Definition: mvpn_route.h:139
uint8_t subcode
Definition: bgp_attr_base.h:69
BgpOListPtr leaf_olist() const
Definition: bgp_attr.h:926
as_t autonomous_system() const
Definition: bgp_server.h:205
static const char * XmppSafiName(uint8_t safi)
static const char * kBgpPeer
Definition: xmpp_init.h:24
static const char * kControlNodeJID
Definition: xmpp_init.h:17
void FillAttribute(LoadBalanceAttribute *attr)
static bool is_mac_mobility(const ExtCommunityValue &val)
Definition: community.h:227
#define AS2_MAX
Definition: bgp_common.h:24
static bool is_load_balance(const ExtCommunityValue &val)
Definition: community.h:372
Ip4Address group() const
Definition: mvpn_route.h:74
const BgpTable * table_