OpenSDN source code
bgp_proto.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 
6 #include "bgp/bgp_proto.h"
7 
8 #include <boost/foreach.hpp>
9 
10 #include <algorithm>
11 #include <list>
12 #include <map>
13 #include <utility>
14 
15 #include "base/proto.h"
16 #include "bgp/bgp_log.h"
17 #include "bgp/bgp_peer.h"
18 #include "bgp/bgp_server.h"
19 #include "net/bgp_af.h"
20 
21 using boost::system::error_code;
22 using boost::tie;
23 using std::cout;
24 using std::endl;
25 using std::string;
26 using std::vector;
27 
28 namespace mpl = boost::mpl;
29 
31  : BgpMessage(OPEN), as_num(-1), holdtime(-1), identifier(-1) {
32 }
33 
35  STLDeleteValues(&opt_params);
36 }
37 
38 //
39 // Validate the capabilities in an incoming Open Message.
40 //
41 // Return the capability code that's missing if a problem is detected.
42 // Return 0 if capabilities in the message are OK.
43 //
44 // Note that we must not generate an error if we see a capability that we
45 // do not support.
46 //
47 // Go through all the capabilities and make sure that there's at least one
48 // MpExtension with an (afi, safi) pair that's also configured on the peer.
49 //
50 //
52  bool mp_extension_ok = false;
53 
54  // Go through each OptParam in the OpenMessage.
55  for (vector<OptParam *>::const_iterator param_it = opt_params.begin();
56  param_it != opt_params.end(); ++param_it) {
57  const OptParam *param = *param_it;
58 
59  // Go through each Capability in the OptParam.
60  for (vector<Capability *>::const_iterator cap_it =
61  param->capabilities.begin();
62  cap_it != param->capabilities.end(); ++cap_it) {
63  const Capability *cap = *cap_it;
64 
65  // See if the (afi,safi) in the MpExtension is configured on peer.
66  if (cap->code == Capability::MpExtension) {
67  const uint8_t *data = cap->capability.data();
68  uint16_t afi = get_value(data, 2);
69  uint8_t safi = get_value(data + 3, 1);
70  Address::Family family = BgpAf::AfiSafiToFamily(afi, safi);
71  if (peer->LookupFamily(family))
72  mp_extension_ok = true;
73  }
74 
75  if (cap->code == Capability::AS4Support &&
76  peer->server()->enable_4byte_as()) {
77  const uint8_t *data = cap->capability.data();
78  as_t asn = get_value(data, 4);
79  if (asn != peer->peer_as()) {
81  BGP_PEER_DIR_IN, "Bad Peer AS Number: " << asn <<
82  ", Configured peer ASN: " << peer->peer_as());
84  }
85  }
86  }
87  }
88 
89  if (!mp_extension_ok) {
91  BGP_PEER_DIR_IN, "Unsupported Capability: " <<
92  Capability::CapabilityToString(Capability::MpExtension) <<
93  " (" << Capability::MpExtension << ")");
95  }
96 
97  return 0;
98 }
99 
100 //
101 // Validate an incoming Open Message.
102 //
103 // Return one of the values from BgpProto::Notification::OpenMsgSubCode if
104 // an error is detected.
105 // Return 0 if message is OK.
106 //
108  if (identifier == 0) {
110  BGP_PEER_DIR_IN, "Bad BGP Identifier: " << 0);
112  }
113  if (identifier == peer->server()->bgp_identifier()) {
116  "Bad (Same as mine) BGP Identifier: " <<
117  Ip4Address(identifier).to_string());
119  }
120  if (as_num != AS_TRANS && as_num != peer->peer_as()) {
122  BGP_PEER_DIR_IN, "Bad Peer AS Number: " << as_num);
124  }
125 
126  return ValidateCapabilities(peer);
127 }
128 
131  uint16_t gr_time, bool restarted, bool notification,
132  const vector<uint8_t> &gr_afi_flags,
133  const vector<Address::Family> &gr_families) {
134  assert((gr_time & ~RestartTimeMask) == 0);
135  uint16_t restart_flags = restarted ? RestartedFlag : 0;
136  restart_flags |= notification ? NotificationFlag : 0;
137  const uint16_t gr_bytes = restart_flags | gr_time;
138 
139  vector<uint8_t> restart_cap;
140  restart_cap.push_back(gr_bytes >> 8);
141  restart_cap.push_back(gr_bytes & 0xFF);
142 
143  size_t i = 0;
144  BOOST_FOREACH(const Address::Family family, gr_families) {
145  uint16_t afi;
146  uint8_t safi;
147  tie(afi, safi) = BgpAf::FamilyToAfiSafi(family);
148  restart_cap.push_back(0);
149  restart_cap.push_back(afi);
150  restart_cap.push_back(safi);
151  restart_cap.push_back(gr_afi_flags[i++]);
152  }
153  return new Capability(GracefulRestart, restart_cap.data(),
154  restart_cap.size());
155 }
156 
158  vector<string> *families) {
159  families->clear();
160  BOOST_FOREACH(Capability::GR::Family gr_family, gr_params.families) {
161  Address::Family family =
162  BgpAf::AfiSafiToFamily(gr_family.afi, gr_family.safi);
163  if (family == Address::UNSPEC) {
164  families->push_back(BgpAf::ToString(gr_family.afi, gr_family.safi));
165  } else {
166  families->push_back(Address::FamilyToString(family));
167  }
168  }
169 
170  // Keep the list sorted and unique.
171  sort(families->begin(), families->end());
172  families->erase(unique(families->begin(), families->end()),
173  families->end() );
174 }
175 
177  const vector<Capability *> &capabilities) {
178  gr_params->Initialize();
179 
180  // Find and process all GR capabilities. We are expected to receive only
181  // one. Otherwise, the only the last one should be taken into effect.
182  bool found = false;
183  for (vector<Capability *>::const_iterator cap_it = capabilities.begin();
184  cap_it != capabilities.end(); ++cap_it) {
185  if ((*cap_it)->code != GracefulRestart)
186  continue;
187  found = true;
188  gr_params->Initialize();
189 
190  uint8_t *data = (*cap_it)->capability.data();
191  uint16_t bytes = get_value(data, 2);
192  gr_params->set_flags(bytes);
193  gr_params->set_time(bytes);
194 
195  size_t offset = 2;
196  while (offset < (*cap_it)->capability.size()) {
197  uint16_t afi = get_value(data + offset, 2);
198  uint8_t safi = get_value(data + offset + 2, 1);
199  uint8_t flags = get_value(data + offset + 3, 1);
200  gr_params->families.push_back(Family(afi, safi, flags));
201  offset += 4;
202  }
203  }
204  return found;
205 }
206 
209  uint8_t llgr_afi_flags, const vector<Address::Family> &llgr_families) {
210  assert((llgr_time & ~RestartTimeMask) == 0);
211  vector<uint8_t> llgr_cap;
212  BOOST_FOREACH(const Address::Family family, llgr_families) {
213  uint16_t afi;
214  uint8_t safi;
215  tie(afi, safi) = BgpAf::FamilyToAfiSafi(family);
216  llgr_cap.push_back(0);
217  llgr_cap.push_back(afi);
218  llgr_cap.push_back(safi);
219  llgr_cap.push_back(llgr_afi_flags);
220  llgr_cap.push_back((llgr_time & 0x00FF0000) >> 16);
221  llgr_cap.push_back((llgr_time & 0x0000FF00) >> 8);
222  llgr_cap.push_back((llgr_time & 0x000000FF) >> 0);
223  }
224  return new Capability(LongLivedGracefulRestart, llgr_cap.data(),
225  llgr_cap.size());
226 }
227 
229  const vector<Capability *> &capabilities) {
230  llgr_params->Initialize();
231 
232  // Find and process all LLGR capabilities. We are expected to receive only
233  // one. Otherwise, the only the last one should be taken into effect.
234  bool found = false;
235  for (vector<Capability *>::const_iterator cap_it = capabilities.begin();
236  cap_it != capabilities.end(); ++cap_it) {
237  if ((*cap_it)->code != LongLivedGracefulRestart)
238  continue;
239  found = true;
240  llgr_params->Initialize();
241 
242  uint8_t *data = (*cap_it)->capability.data();
243  size_t offset = 0;
244  uint32_t max_time = 0;
245  while (offset < (*cap_it)->capability.size()) {
246  uint16_t afi = get_value(data + offset, 2);
247  uint8_t safi = get_value(data + offset + 2, 1);
248  uint8_t flags = get_value(data + offset + 3, 1);
249  uint32_t time = get_value(data + offset + 4, 3);
250  llgr_params->families.push_back(Family(afi, safi, flags, time));
251 
252  if (time > max_time)
253  max_time = time;
254  offset += 7;
255  }
256  llgr_params->time = max_time;
257  }
258  return found;
259 }
260 
262  const LLGR &llgr_params, vector<string> *families) {
263  families->clear();
264  BOOST_FOREACH(Capability::LLGR::Family llgr_family, llgr_params.families) {
265  Address::Family family =
266  BgpAf::AfiSafiToFamily(llgr_family.afi, llgr_family.safi);
267  if (family == Address::UNSPEC) {
268  families->push_back(BgpAf::ToString(llgr_family.afi,
269  llgr_family.safi));
270  } else {
271  families->push_back(Address::FamilyToString(family));
272  }
273  }
274 
275  // Keep the list sorted and unique.
276  sort(families->begin(), families->end());
277  families->erase(unique(families->begin(), families->end()),
278  families->end() );
279 }
280 
281 const string BgpProto::OpenMessage::ToString() const {
282  std::ostringstream os;
283 
284  error_code ec;
285  os << "AS " << as_num;
286  os << ", Hold Time " << holdtime;
287  os << ", Identifier " << Ip4Address(identifier).to_string(ec);
288 
289  // Go through each OptParam in the OpenMessage.
290  for (vector<OptParam *>::const_iterator param_it = opt_params.begin();
291  param_it != opt_params.end(); ++param_it) {
292  const OptParam *param = *param_it;
293 
294  // Go through each Capability in the OptParam.
295  vector<Capability *>::const_iterator cap_it =
296  param->capabilities.begin();
297  while (cap_it != param->capabilities.end()) {
298  const Capability *cap = *cap_it;
299 
300  os << ", Code " << Capability::CapabilityToString(cap->code);
301 
302  if (cap->code == Capability::MpExtension) {
303  const uint8_t *data = cap->capability.data();
304  uint16_t afi = get_value(data, 2);
305  uint8_t safi = get_value(data + 3, 1);
306  Address::Family family = BgpAf::AfiSafiToFamily(afi, safi);
307  os << " Family " << Address::FamilyToString(family);
308  }
309 
310  if (++cap_it == param->capabilities.end())
311  break;
312  }
313 
314  Capability::GR gr_params = Capability::GR();
315  if (Capability::GR::Decode(&gr_params, param->capabilities)) {
316  os << ", GR_Flags 0x" << std::hex << int(gr_params.flags);
317  os << ", GR_Time " << gr_params.time;
318  BOOST_FOREACH(Capability::GR::Family family, gr_params.families) {
319  os << ", GR_family " <<
320  BgpAf::AfiSafiToFamily(family.afi, family.safi);
321  os << ", GR_family_flags 0x" << std::hex << int(family.flags);
322  }
323  }
324 
325  Capability::LLGR llgr_params = Capability::LLGR();
326  if (Capability::LLGR::Decode(&llgr_params, param->capabilities)) {
327  BOOST_FOREACH(Capability::LLGR::Family family,
328  llgr_params.families) {
329  os << ", LLGR_family " <<
330  BgpAf::AfiSafiToFamily(family.afi, family.safi);
331  os << ", LLGR_family_flags 0x" << std::hex << int(family.flags);
332  os << ", LLGR_Time " << family.time << " Seconds";
333  }
334  }
335  }
336 
337  return os.str();
338 }
339 
341  : BgpMessage(NOTIFICATION), error(0), subcode(0) {
342 }
343 
344 const string BgpProto::Notification::ToString() const {
345  return toString(static_cast<BgpProto::Notification::Code>(error), subcode);
346 }
347 
349  BgpProto::Notification::Code code, int sub_code) {
350  string msg("");
351  switch (code) {
352  case MsgHdrErr:
353  msg += string("Message Header Error:") +
354  MsgHdrSubcodeToString(static_cast<MsgHdrSubCode>(sub_code));
355  break;
356  case OpenMsgErr:
357  msg += string("OPEN Message Error:") +
358  OpenMsgSubcodeToString(static_cast<OpenMsgSubCode>(sub_code));
359  break;
360  case UpdateMsgErr:
361  msg += string("UPDATE Message Error:") +
362  UpdateMsgSubCodeToString(
363  static_cast<UpdateMsgSubCode>(sub_code));
364  break;
365  case HoldTimerExp:
366  msg += "Hold Timer Expired";
367  break;
368  case FSMErr:
369  msg += string("Finite State Machine Error:") +
370  FsmSubcodeToString(static_cast<FsmSubcode>(sub_code));
371  break;
372  case Cease:
373  msg += string("Cease:") +
374  CeaseSubcodeToString(static_cast<CeaseSubCode>(sub_code));
375  break;
376  default:
377  msg += "Unknown";
378  break;
379  }
380  return msg;
381 }
382 
384  : BgpMessage(KEEPALIVE) {
385 }
386 
388  : BgpMessage(UPDATE) {
389 }
390 
392  STLDeleteValues(&withdrawn_routes);
393  STLDeleteValues(&path_attributes);
394  STLDeleteValues(&nlri);
395 }
396 
398  bool operator()(BgpAttribute *lhs, BgpAttribute *rhs) const {
399  return lhs->code < rhs->code;
400  }
401 };
402 
403 //
404 // Validate an incoming Update Message
405 // Returns 0 if message is OK
406 // Returns one of the values from enum UpdateMsgSubCode if an error is detected
407 //
408 int BgpProto::Update::Validate(const BgpPeer *peer, string *data) {
409  BgpAttrCodeCompare comp;
410  std::sort(path_attributes.begin(), path_attributes.end(), comp);
411  bool origin = false, nh = false, as_path = false, mp_reach_nlri = false,
412  local_pref = false;
413 
414  bool ibgp = (peer->PeerType() == IBGP);
415 
416  BgpAttrSpec::const_iterator it;
417  string rxed_attr("Path attributes : ");
418  for (it = path_attributes.begin(); it < path_attributes.end(); it++) {
419  if (it+1 < path_attributes.end() && (*it)->code == (*(it+1))->code) {
420  // Duplicate attributes
422  }
423 
424  rxed_attr += (*it)->ToString() + " ";
425 
426  if ((*it)->code == BgpAttribute::Origin)
427  origin = true;
428  if ((*it)->code == BgpAttribute::LocalPref) {
429  local_pref = true;
430  } else if ((*it)->code == BgpAttribute::NextHop) {
431  nh = true;
432  } else if ((*it)->code == BgpAttribute::AsPath) {
433  as_path = true;
434  if (peer && peer->IsAs4Supported()) {
435  AsPath4ByteSpec *asp = static_cast<AsPath4ByteSpec *>(*it);
436  // Check segments size for ebgp.
437  // IBGP can have empty path for routes that are originated.
438  if (!ibgp) {
439  if (!asp->path_segments.size() ||
440  !asp->path_segments[0]->path_segment.size())
442  }
443  } else {
444  AsPathSpec *asp = static_cast<AsPathSpec *>(*it);
445  // Check segments size for ebgp.
446  // IBGP can have empty path for routes that are originated.
447  if (!ibgp) {
448  if (!asp->path_segments.size() ||
449  !asp->path_segments[0]->path_segment.size())
451  }
452  }
453  } else if ((*it)->code == BgpAttribute::MPReachNlri) {
454  mp_reach_nlri = true;
455  }
456  }
457 
458  BGP_LOG_PEER(Message, const_cast<BgpPeer *>(peer),
459  SandeshLevel::SYS_DEBUG, BGP_LOG_FLAG_TRACE,
460  BGP_PEER_DIR_IN, rxed_attr);
461  if (nlri.size() > 0 && !nh) {
462  // next-hop attribute must be present if IPv4 NLRI is present
463  char attrib_type = BgpAttribute::NextHop;
464  *data = string(&attrib_type, 1);
466  }
467  if (nlri.size() > 0 || mp_reach_nlri) {
468  // origin and as_path must be present if any NLRI is present
469  if (!origin) {
470  char attrib_type = BgpAttribute::Origin;
471  *data = string(&attrib_type, 1);
473  }
474  if (!as_path) {
475  char attrib_type = BgpAttribute::AsPath;
476  *data = string(&attrib_type, 1);
478  }
479 
480  // All validations for IBGP
481  if (ibgp && !local_pref) {
482  // If IBGP, local_pref is mandatory
483  char attrib_type = BgpAttribute::LocalPref;
484  *data = string(&attrib_type, 1);
486  }
487  }
488  return 0;
489 }
490 
492  KEY_COMPARE(withdrawn_routes.size(), rhs.withdrawn_routes.size());
493  for (size_t i = 0; i < withdrawn_routes.size(); i++) {
494  KEY_COMPARE(withdrawn_routes[i]->prefixlen,
495  rhs.withdrawn_routes[i]->prefixlen);
496  KEY_COMPARE(withdrawn_routes[i]->prefix,
497  rhs.withdrawn_routes[i]->prefix);
498  }
499 
500  KEY_COMPARE(path_attributes.size(), rhs.path_attributes.size());
501  for (size_t i = 0; i < rhs.path_attributes.size(); i++) {
502  int ret = path_attributes[i]->CompareTo(*rhs.path_attributes[i]);
503  if (ret != 0) {
504  cout << "Unequal " << TYPE_NAME(*path_attributes[i]) << endl;
505  return ret;
506  }
507  }
508 
509  KEY_COMPARE(nlri.size(), rhs.nlri.size());
510  for (size_t i = 0; i < rhs.nlri.size(); i++) {
511  KEY_COMPARE(nlri[i]->prefixlen, rhs.nlri[i]->prefixlen);
512  KEY_COMPARE(nlri[i]->prefix, rhs.nlri[i]->prefix);
513  }
514  return 0;
515 }
516 
517 class BgpMarker : public ProtoElement<BgpMarker> {
518 public:
519  static const int kSize = 16;
520  static const int kErrorCode = BgpProto::Notification::MsgHdrErr;
521  static const int kErrorSubcode = BgpProto::Notification::ConnNotSync;
522  static bool Verifier(const void *obj, const uint8_t *data, size_t size,
523  ParseContext *context) {
524  for (int i = 0; i < 16; i++) {
525  if (data[i] != 0xff) return false;
526  }
527  return true;
528  }
529  static void Writer(const void *msg, uint8_t *data, size_t size) {
530  for (int i = 0; i < 16; i++) {
531  data[i] = 0xff;
532  }
533  }
534 };
535 
536 class BgpMsgLength : public ProtoElement<BgpMsgLength> {
537 public:
538  static const int kSize = 2;
539  static const int kErrorCode = BgpProto::Notification::MsgHdrErr;
540  static const int kErrorSubcode = BgpProto::Notification::BadMsgLength;
541  struct Offset {
542  string operator()() {
543  return "BgpMsgLength";
544  }
545  };
547  static bool Verifier(const void *obj, const uint8_t *data, size_t size,
548  ParseContext *context) {
549  int value = get_short(data);
550  if (value < BgpProto::kMinMessageSize ||
551  value > BgpProto::kMaxMessageSize) {
552  return false;
553  }
554  if ((size_t) value < context->offset() + size) {
555  return false;
556  }
557  return true;
558  }
559  struct SetLength {
560  static void Callback(EncodeContext *context, uint8_t *data,
561  int offset, int element_size) {
562  put_value(data, kSize, context->length());
563  }
564  };
566 };
567 
568 // BGP OPEN
569 class BgpOpenVersion : public ProtoElement<BgpOpenVersion> {
570 public:
571  static const int kSize = 1;
572  static const int kErrorCode = BgpProto::Notification::OpenMsgErr;
573  static const int kErrorSubcode = BgpProto::Notification::UnsupportedVersion;
574  static bool Verifier(const void * obj, const uint8_t *data, size_t size,
575  ParseContext *context) {
576  return data[0] == 0x4;
577  }
578  static void Writer(const void *msg, uint8_t *data, size_t size) {
579  *data = 0x4;
580  }
581 };
582 
583 class BgpOpenAsNum : public ProtoElement<BgpOpenAsNum> {
584 public:
585  static const int kSize = 2;
586  typedef Accessor<BgpProto::OpenMessage, uint32_t,
588 };
589 
590 class BgpHoldTime : public ProtoElement<BgpHoldTime> {
591 public:
592  static const int kSize = 2;
593  static const int kErrorCode = BgpProto::Notification::OpenMsgErr;
594  static const int kErrorSubcode =
596  static bool Verifier(const BgpProto::OpenMessage *obj, const uint8_t *data,
597  size_t size, ParseContext *context) {
598  uint16_t value = get_value(data, 2);
599  return (value == 0 || value >= 3);
600  }
601  typedef Accessor<BgpProto::OpenMessage, int32_t,
603 };
604 
605 class BgpIdentifier : public ProtoElement<BgpIdentifier> {
606 public:
607  static const int kSize = 4;
608  typedef Accessor<BgpProto::OpenMessage, uint32_t,
610 };
611 
612 class BgpOpenCapabilityCode : public ProtoElement<BgpOpenCapabilityCode> {
613 public:
614  static const int kSize = 1;
617 };
618 
619 class BgpOpenCapabilityLength : public ProtoElement<BgpOpenCapabilityLength> {
620 public:
621  static const int kSize = 1;
622  typedef int SequenceLength;
623 };
624 
625 class BgpOpenCapabilityValue : public ProtoElement<BgpOpenCapabilityValue> {
626 public:
627  static const int kSize = -1;
630 };
631 
632 class BgpOpenCapability : public ProtoSequence<BgpOpenCapability> {
633 public:
636 };
637 
638 class BgpOpenCapabilities : public ProtoSequence<BgpOpenCapabilities> {
639 public:
640  static const int kSize = 1;
641  static const int kMinOccurs = 0;
642  static const int kMaxOccurs = -1;
643  typedef mpl::list<BgpOpenCapability> Sequence;
644 
646  vector<BgpProto::OpenMessage::Capability *>,
648 
649  struct OptMatch {
651  return !ctx->capabilities.empty();
652  }
653  };
655 };
656 
657 class BgpOpenOptParamChoice : public ProtoChoice<BgpOpenOptParamChoice> {
658 public:
659  static const int kSize = 1;
660  static const int kErrorCode = BgpProto::Notification::OpenMsgErr;
661  static const int kErrorSubcode =
663  typedef mpl::map<
664  mpl::pair<mpl::int_<BgpProto::OpenMessage::OPEN_OPT_CAPABILITIES>,
667 };
668 
669 class BgpOpenOptParam : public ProtoSequence<BgpOpenOptParam> {
670 public:
671  static const int kSize = 1;
672  static const int kMinOccurs = 0;
673  static const int kMaxOccurs = -1;
675  vector<BgpProto::OpenMessage::OptParam *>,
677  typedef mpl::list<BgpOpenOptParamChoice> Sequence;
678 };
679 
680 class BgpOpenMessage : public ProtoSequence<BgpOpenMessage> {
681 public:
682  typedef mpl::list<BgpOpenVersion,
683  BgpOpenAsNum,
684  BgpHoldTime,
688 };
689 
690 class NotificationErrorCode : public ProtoElement<NotificationErrorCode> {
691 public:
692  static const int kSize = 1;
693  typedef Accessor<BgpProto::Notification, int,
695 };
696 
697 class NotificationErrorSubcode : public ProtoElement<NotificationErrorSubcode> {
698 public:
699  static const int kSize = 1;
700  typedef Accessor<BgpProto::Notification, int,
702 };
703 
704 class NotificationData : public ProtoElement<NotificationData> {
705 public:
706  static const int kSize = -1;
707  typedef Accessor<BgpProto::Notification, string,
709 };
710 
711 class BgpNotificationMessage : public ProtoSequence<BgpNotificationMessage> {
712 public:
713  typedef mpl::list<NotificationErrorCode,
717 };
718 
719 class BgpKeepaliveMessage : public ProtoSequence<BgpKeepaliveMessage> {
720 public:
721  typedef mpl::list<> Sequence;
723 };
724 
725 class BgpPrefixLen : public ProtoElement<BgpPrefixLen> {
726 public:
727  static const int kSize = 1;
728  struct PrefixLen {
729  int operator()(BgpProtoPrefix *obj, const uint8_t *data, size_t size) {
730  int bits = data[0];
731  return (bits + 7) / 8;
732  }
733  };
735  typedef Accessor<BgpProtoPrefix, int,
737 };
738 
739 class BgpPrefixAddress : public ProtoElement<BgpPrefixAddress> {
740 public:
741  static const int kSize = -1;
742  typedef VectorAccessor<BgpProtoPrefix, uint8_t,
744 };
745 
747  public ProtoSequence<BgpUpdateWithdrawnRoutes> {
748 public:
749  static const int kSize = 2;
750  static const int kMinOccurs = 0;
751  static const int kMaxOccurs = -1;
752  static const int kErrorCode = BgpProto::Notification::UpdateMsgErr;
753  static const int kErrorSubcode =
755 
757  vector<BgpProtoPrefix *>,
759 
760  struct OptMatch {
761  bool match(const BgpProto::Update *ctx) {
762  return !ctx->withdrawn_routes.empty();
763  }
764  };
766 
767  typedef mpl::list<BgpPrefixLen, BgpPrefixAddress> Sequence;
768 };
769 
770 class BgpPathAttrLength : public ProtoElement<BgpPathAttrLength> {
771 public:
772  static const int kSize = -1;
773  struct AttrLen {
775  const uint8_t *data, size_t &size) {
776  if (obj->flags & BgpAttribute::ExtendedLength) {
777  // Extended Length: use 2 bytes to read
778  size = 2;
779  } else {
780  size = 1;
781  }
782  return get_value(data, size);
783  }
784  };
786  struct AttrSizeSet {
787  static int get(const BgpAttribute *obj) {
789  // Extended Length: use 2 bytes to read
790  return 2;
791  } else {
792  return 1;
793  }
794  }
795  };
797 };
798 
799 template <class Derived>
801  Derived *operator()(const BgpAttribute *attr) {
802  return new Derived(*attr);
803  }
804 };
805 
806 template <class C>
808  static bool Verifier(const C *obj, const uint8_t *data, size_t size,
809  ParseContext *context) {
810  int pre = (obj->flags & BgpAttribute::ExtendedLength) ? 4 : 3;
811  if (C::kSize > 0 &&
812  static_cast<int>(context->total_size()) != C::kSize) {
813  int offset = pre + context->total_size() - context->size();
816  TYPE_NAME(C), data - offset, context->total_size() + pre);
817  return false;
818  }
819  if ((obj->flags & BgpAttribute::FLAG_MASK) != C::kFlags) {
820  int offset = pre + context->total_size() - context->size();
823  TYPE_NAME(C), data - offset, context->total_size() + pre);
824  return false;
825  }
826  return true;
827  }
828 };
829 
830 template <>
832  static bool Verifier(const BgpAttrOrigin *obj, const uint8_t *data,
833  size_t size, ParseContext *context) {
834  int pre = (obj->flags & BgpAttribute::ExtendedLength) ? 4 : 3;
835  if (context->size() != 1) {
838  "BgpAttrOrigin", data - pre, size + pre);
839  return false;
840  }
844  "BgpAttrOrigin", data - pre, size + pre);
845  return false;
846  }
847  uint8_t value = data[0];
848  if (value != BgpAttrOrigin::IGP && value != BgpAttrOrigin::EGP &&
849  value != BgpAttrOrigin::INCOMPLETE) {
852  "BgpAttrOrigin", data - pre, size + pre);
853  return false;
854  }
855  return true;
856  }
857 };
858 
859 template <>
861  static bool Verifier(const BgpAttrNextHop *obj, const uint8_t *data,
862  size_t size, ParseContext *context) {
863  int pre = (obj->flags & BgpAttribute::ExtendedLength) ? 4 : 3;
864  if (static_cast<int>(context->size()) != BgpAttrNextHop::kSize) {
867  "BgpAttrNextHop", data - pre, size + pre);
868  return false;
869  }
873  "BgpAttrNextHop", data - pre, size + pre);
874  return false;
875  }
876  uint32_t value = get_value(data, size);
877  // TODO(sbansal): More checks are needed
878  if (value == 0) {
881  "BgpAttrNextHop", data - pre, size + pre);
882  return false;
883  }
884  return true;
885  }
886 };
887 
888 template <>
889 struct BgpAttributeVerifier<AsPathSpec::PathSegment> {
890  static bool Verifier(const AsPathSpec::PathSegment *obj,
891  const uint8_t *data, size_t size,
892  ParseContext *context) {
893  return true;
894  }
895 };
896 
897 template <>
898 struct BgpAttributeVerifier<AsPath4ByteSpec::PathSegment> {
899  static bool Verifier(const AsPath4ByteSpec::PathSegment *obj,
900  const uint8_t *data, size_t size,
901  ParseContext *context) {
902  return true;
903  }
904 };
905 
906 template <>
907 struct BgpAttributeVerifier<As4PathSpec::PathSegment> {
908  static bool Verifier(const As4PathSpec::PathSegment *obj,
909  const uint8_t *data, size_t size,
910  ParseContext *context) {
911  return true;
912  }
913 };
914 
915 template <int Size, class C, typename T, T C::*Member>
917  public ProtoElement<BgpAttributeValue<Size, C, T, Member> > {
918 public:
919  static const int kSize = Size;
920  static bool Verifier(const C *obj, const uint8_t *data, size_t size,
921  ParseContext *context) {
922  return BgpAttributeVerifier<C>::Verifier(obj, data, size, context);
923  }
925 };
926 
927 template <class C, int Size, typename T, T C::*M>
929  public ProtoSequence<BgpAttrTemplate<C, Size, T, M> > {
930 public:
931  static const int kErrorCode = BgpProto::Notification::UpdateMsgErr;
932  static const int kErrorSubcode = BgpProto::Notification::AttribLengthError;
933  typedef C ContextType;
935  typedef mpl::list<BgpPathAttrLength, BgpAttributeValue<Size, C, T, M>
937 };
938 
940  public ProtoSequence<BgpPathAttributeAtomicAggregate> {
941 public:
942  static bool Verifier(const BgpAttrAtomicAggregate * obj,
943  const uint8_t *data, size_t size,
944  ParseContext *context) {
945  if (data[0] != 0) {
948  "BgpAttrAtomicAggregate", data - 2, data[0] + 3);
949  return false;
950  }
954  "BgpAttrAtomicAggregate", data - 2, 3);
955  return false;
956  }
957  return true;
958  }
961  typedef mpl::list<BgpPathAttrLength> Sequence;
962 };
963 
965  public ProtoSequence<BgpPathAttributeAggregator> {
966 public:
969  typedef mpl::list<BgpPathAttrLength,
975 };
976 
978  public ProtoSequence<BgpPathAttributeAggregator4Byte> {
979 public:
982  typedef mpl::list<BgpPathAttrLength,
988 };
989 
991  public ProtoSequence<BgpPathAttributeAs4Aggregator> {
992 public:
995  typedef mpl::list<BgpPathAttrLength,
1001 };
1002 
1004  public ProtoElement<BgpPathAttrAsPathSegmentLength> {
1005 public:
1006  static const int kSize = 1;
1009  const uint8_t *data, size_t size) {
1010  return get_value(data, 1) * 2;
1011  }
1012  };
1014  struct SetLength {
1015  static void Callback(EncodeContext *context, uint8_t *data,
1016  int offset, int element_size) {
1017  int len = get_value(data, kSize);
1018  put_value(data, kSize, len/2);
1019  }
1020  };
1022 };
1023 
1025  public ProtoElement<BgpPathAttrAsPath4ByteSegmentLength> {
1026 public:
1027  static const int kSize = 1;
1030  const uint8_t *data, size_t size) {
1031  return get_value(data, 1) * 4;
1032  }
1033  };
1035  struct SetLength {
1036  static void Callback(EncodeContext *context, uint8_t *data,
1037  int offset, int element_size) {
1038  int len = get_value(data, kSize);
1039  put_value(data, kSize, len/4);
1040  }
1041  };
1043 };
1044 
1046  public ProtoElement<BgpPathAttrAs4PathSegmentLength> {
1047 public:
1048  static const int kSize = 1;
1051  const uint8_t *data, size_t size) {
1052  return get_value(data, 1) * 4;
1053  }
1054  };
1056  struct SetLength {
1057  static void Callback(EncodeContext *context, uint8_t *data,
1058  int offset, int element_size) {
1059  int len = get_value(data, kSize);
1060  put_value(data, kSize, len/4);
1061  }
1062  };
1064 };
1065 
1066 
1068  public ProtoElement<BgpPathAttrAsPathSegmentValue> {
1069 public:
1070  static const int kSize = -1;
1073 };
1074 
1076  public ProtoElement<BgpPathAttrAsPath4ByteSegmentValue> {
1077 public:
1078  static const int kSize = -1;
1081 };
1082 
1084  public ProtoElement<BgpPathAttrAs4PathSegmentValue> {
1085 public:
1086  static const int kSize = -1;
1089 };
1090 
1092  public ProtoSequence<BgpPathAttrAsPathSegmentList> {
1093 public:
1094  static const int kMinOccurs = 0;
1095  static const int kMaxOccurs = -1;
1096 
1097  static bool Verifier(const AsPathSpec *obj, const uint8_t *data,
1098  size_t size, ParseContext *context) {
1099  return BgpAttributeVerifier<AsPathSpec>::Verifier(obj, data, size,
1100  context);
1101  }
1102 
1104  vector<AsPathSpec::PathSegment *>,
1106 
1107  typedef mpl::list<BgpAttributeValue<1, AsPathSpec::PathSegment, int,
1112 };
1113 
1115  public ProtoSequence<BgpPathAttrAsPath4ByteSegmentList> {
1116 public:
1117  static const int kMinOccurs = 0;
1118  static const int kMaxOccurs = -1;
1119 
1120  static bool Verifier(const AsPath4ByteSpec *obj, const uint8_t *data,
1121  size_t size, ParseContext *context) {
1122  return BgpAttributeVerifier<AsPath4ByteSpec>::Verifier(obj, data, size,
1123  context);
1124  }
1125 
1127  vector<AsPath4ByteSpec::PathSegment *>,
1129 
1130  typedef mpl::list<BgpAttributeValue<1, AsPath4ByteSpec::PathSegment, int,
1135 };
1136 
1138  public ProtoSequence<BgpPathAttrAs4PathSegmentList> {
1139 public:
1140  static const int kMinOccurs = 0;
1141  static const int kMaxOccurs = -1;
1142 
1143  static bool Verifier(const As4PathSpec *obj, const uint8_t *data,
1144  size_t size, ParseContext *context) {
1145  return BgpAttributeVerifier<As4PathSpec>::Verifier(obj, data, size,
1146  context);
1147  }
1148 
1150  vector<As4PathSpec::PathSegment *>,
1152 
1153  typedef mpl::list<BgpAttributeValue<1, As4PathSpec::PathSegment, int,
1158 };
1159 
1160 class BgpPathAttributeAsPath : public ProtoSequence<BgpPathAttributeAsPath> {
1161 public:
1164  typedef mpl::list<BgpPathAttrLength, BgpPathAttrAsPathSegmentList> Sequence;
1165 };
1166 
1168  public ProtoSequence<BgpPathAttributeAsPath4Byte> {
1169 public:
1172  typedef mpl::list<BgpPathAttrLength,
1174 };
1175 
1176 class BgpPathAttributeAs4Path : public ProtoSequence<BgpPathAttributeAs4Path> {
1177 public:
1180  typedef mpl::list<BgpPathAttrLength, BgpPathAttrAs4PathSegmentList> Sequence;
1181 };
1182 
1183 class BgpPathAttributeFlags : public ProtoElement<BgpPathAttributeFlags> {
1184 public:
1185  static const int kSize = 1;
1186  struct FlagsAccessor {
1187  static void set(BgpAttribute *obj, uint8_t value) {
1188  obj->flags = value;
1189  }
1190  static uint8_t get(const BgpAttribute *obj) {
1191  return obj->GetEncodeFlags();
1192  }
1193  };
1195 };
1196 
1198  public ProtoElement<BgpPathAttributeCommunityList> {
1199 public:
1200  static const int kSize = -1;
1201  static bool Verifier(const CommunitySpec *obj, const uint8_t *data,
1202  size_t size, ParseContext *context) {
1203  return BgpAttributeVerifier<CommunitySpec>::Verifier(obj, data, size,
1204  context);
1205  }
1206 
1207  typedef VectorAccessor<CommunitySpec, uint32_t,
1209 };
1210 
1212  public ProtoSequence<BgpPathAttributeCommunities> {
1213 public:
1216  typedef mpl::list<BgpPathAttrLength,
1218 };
1219 
1221  public ProtoElement<BgpPathAttributeExtendedCommunityList> {
1222 public:
1223  static const int kSize = -1;
1224  static bool Verifier(const ExtCommunitySpec *obj, const uint8_t *data,
1225  size_t size, ParseContext *context) {
1226  return BgpAttributeVerifier<ExtCommunitySpec>::Verifier(obj, data, size,
1227  context);
1228  }
1229 
1230  typedef VectorAccessor<ExtCommunitySpec, uint64_t,
1232 };
1233 
1235  public ProtoSequence<BgpPathAttributeExtendedCommunities> {
1236 public:
1239  typedef mpl::list<BgpPathAttrLength,
1241 };
1242 
1244  public ProtoElement<BgpPathAttributeLargeCommunityList> {
1245 public:
1246  static const int kSize = -1;
1247  static bool Verifier(const LargeCommunitySpec *obj, const uint8_t *data,
1248  size_t size, ParseContext *context) {
1250  size,
1251  context);
1252  }
1253 
1254  typedef VectorAccessor<LargeCommunitySpec, uint32_t,
1256 };
1257 
1259  public ProtoSequence<BgpPathAttributeLargeCommunities> {
1260 public:
1263  typedef mpl::list<BgpPathAttrLength,
1265 };
1266 
1268  public ProtoElement<BgpPathAttributeClusterListData> {
1269 public:
1270  static const int kSize = -1;
1271  typedef VectorAccessor<ClusterListSpec, uint32_t,
1273 };
1274 
1276  public ProtoSequence<BgpPathAttributeClusterList> {
1277 public:
1280  typedef mpl::list<BgpPathAttrLength,
1282 };
1283 
1285  public ProtoElement<BgpPathAttributeOriginVnList> {
1286 public:
1287  static const int kSize = -1;
1288  static bool Verifier(const OriginVnPathSpec *obj, const uint8_t *data,
1289  size_t size, ParseContext *context) {
1290  return BgpAttributeVerifier<OriginVnPathSpec>::Verifier(obj, data, size,
1291  context);
1292  }
1293 
1294  typedef VectorAccessor<OriginVnPathSpec, uint64_t,
1296 };
1297 
1299  public ProtoSequence<BgpPathAttributeOriginVnPath> {
1300 public:
1303  typedef mpl::list<BgpPathAttrLength, BgpPathAttributeOriginVnList> Sequence;
1304 };
1305 
1307  public ProtoElement<BgpPathAttributePmsiTunnelIdentifier> {
1308 public:
1309  static const int kSize = -1;
1310  static bool Verifier(const PmsiTunnelSpec *obj, const uint8_t *data,
1311  size_t size, ParseContext *context) {
1313  obj, data, size, context);
1314  }
1315 
1316  typedef VectorAccessor<PmsiTunnelSpec, uint8_t,
1318 };
1319 
1321  public ProtoSequence<BgpPathAttributePmsiTunnel> {
1322 public:
1325  typedef mpl::list<BgpPathAttrLength,
1327  uint8_t, &PmsiTunnelSpec::tunnel_flags>,
1329  uint8_t, &PmsiTunnelSpec::tunnel_type>,
1331  uint32_t, &PmsiTunnelSpec::label>,
1333 };
1334 
1336  public ProtoElement<BgpPathAttributeDiscoveryEdgeAddressLen> {
1337 public:
1338  static const int kSize = 1;
1339  static bool Verifier(const void *obj, const uint8_t *data,
1340  size_t size, ParseContext *context) {
1341  uint8_t value = get_value(data, 1);
1342  return (value == 4);
1343  }
1344  typedef int SequenceLength;
1345 };
1346 
1348  public ProtoElement<BgpPathAttributeDiscoveryEdgeAddressValue> {
1349 public:
1350  static const int kSize = -1;
1351  typedef VectorAccessor<EdgeDiscoverySpec::Edge, uint8_t,
1353 };
1354 
1356  public ProtoSequence<BgpPathAttributeDiscoveryEdgeAddress> {
1357 public:
1358  typedef mpl::list<BgpPathAttributeDiscoveryEdgeAddressLen,
1360 };
1361 
1363  public ProtoElement<BgpPathAttributeDiscoveryEdgeLabelLen> {
1364 public:
1365  static const int kSize = 1;
1366  static bool Verifier(const void *obj, const uint8_t *data,
1367  size_t size, ParseContext *context) {
1368  uint8_t value = get_value(data, 1);
1369  return (value > 0 && value % 8 == 0);
1370  }
1371  typedef int SequenceLength;
1372 };
1373 
1375  public ProtoElement<BgpPathAttributeDiscoveryEdgeLabelValues> {
1376 public:
1377  static const int kSize = -1;
1378  typedef VectorAccessor<EdgeDiscoverySpec::Edge, uint32_t,
1380 };
1381 
1383  public ProtoSequence<BgpPathAttributeDiscoveryEdgeLabels> {
1384 public:
1385  typedef mpl::list<BgpPathAttributeDiscoveryEdgeLabelLen,
1387 };
1388 
1390  public ProtoSequence<BgpPathAttributeDiscoveryEdgeList> {
1391 public:
1392  static const int kMinOccurs = 1;
1393  static const int kMaxOccurs = -1;
1394 
1395  static bool Verifier(const EdgeDiscoverySpec *obj, const uint8_t *data,
1396  size_t size, ParseContext *context) {
1398  obj, data, size, context);
1399  }
1400 
1402  vector<EdgeDiscoverySpec::Edge *>,
1404 
1405  typedef mpl::list<BgpPathAttributeDiscoveryEdgeAddress,
1407 };
1408 
1410  public ProtoSequence<BgpPathAttributeEdgeDiscovery> {
1411 public:
1414  typedef mpl::list<BgpPathAttrLength,
1416 };
1417 
1419  public ProtoElement<BgpPathAttributeForwardingEdgeLen> {
1420 public:
1421  static const int kSize = 1;
1422  static bool Verifier(const void *obj, const uint8_t *data,
1423  size_t size, ParseContext *context) {
1424  uint8_t value = get_value(data, 1);
1425  return (value == 4);
1426  }
1427  struct GetLength {
1429  const uint8_t *data, size_t size) {
1430  obj->address_len = get_value(data, 1) * 2 + 8;
1431  return obj->address_len;
1432  }
1433  };
1435  struct SetLength {
1436  static void Callback(EncodeContext *context, uint8_t *data,
1437  int offset, int element_size) {
1438  int len = get_value(data, kSize);
1439  put_value(data, kSize, (len - 8) / 2);
1440  }
1441  };
1443 };
1444 
1446  public ProtoElement<BgpPathAttributeForwardingEdgeAddressLen> {
1447 public:
1448  static const int kSize = 0;
1449  struct GetLength {
1451  const uint8_t *data, size_t size) {
1452  return (obj->address_len - 8) / 2;
1453  }
1454  };
1456 };
1457 
1459  public ProtoElement<BgpPathAttributeForwardingEdgeInAddressValue> {
1460 public:
1461  static const int kSize = -1;
1462  typedef VectorAccessor<EdgeForwardingSpec::Edge, uint8_t,
1464 };
1465 
1467  public ProtoSequence<BgpPathAttributeForwardingEdgeInAddress> {
1468 public:
1469  static const int kMinOccurs = 1;
1470  static const int kMaxOccurs = 1;
1471  typedef mpl::list<BgpPathAttributeForwardingEdgeAddressLen,
1473 };
1474 
1476  public ProtoElement<BgpPathAttributeForwardingEdgeInLabel> {
1477 public:
1478  static const int kSize = 4;
1479  typedef Accessor<EdgeForwardingSpec::Edge, uint32_t,
1481 };
1482 
1484  public ProtoElement<BgpPathAttributeForwardingEdgeOutAddressValue> {
1485 public:
1486  static const int kSize = -1;
1487  typedef VectorAccessor<EdgeForwardingSpec::Edge, uint8_t,
1489 };
1490 
1492  public ProtoSequence<BgpPathAttributeForwardingEdgeOutAddress> {
1493 public:
1494  static const int kMinOccurs = 1;
1495  static const int kMaxOccurs = 1;
1496  typedef mpl::list<BgpPathAttributeForwardingEdgeAddressLen,
1498 };
1499 
1501  public ProtoElement<BgpPathAttributeForwardingEdgeOutLabel> {
1502 public:
1503  static const int kSize = 4;
1504  typedef Accessor<EdgeForwardingSpec::Edge, uint32_t,
1506 };
1507 
1509  public ProtoSequence<BgpPathAttributeForwardingEdgeList> {
1510 public:
1511  static const int kMinOccurs = 1;
1512  static const int kMaxOccurs = -1;
1513 
1514  static bool Verifier(const EdgeForwardingSpec *obj, const uint8_t *data,
1515  size_t size, ParseContext *context) {
1517  obj, data, size, context);
1518  }
1519 
1521  vector<EdgeForwardingSpec::Edge *>,
1523 
1524  typedef mpl::list<BgpPathAttributeForwardingEdgeLen,
1529 };
1530 
1532  public ProtoSequence<BgpPathAttributeEdgeForwarding> {
1533 public:
1536  typedef mpl::list<BgpPathAttrLength,
1538 };
1539 
1540 class BgpPathAttributeReserved : public ProtoElement<BgpPathAttributeReserved> {
1541 public:
1542  static const int kSize = 1;
1543  static void Writer(const void *msg, uint8_t *data, size_t size) {
1544  *data = 0;
1545  }
1546 };
1547 
1549  public ProtoElement<BgpPathAttributeMpNlriNextHopLength> {
1550 public:
1551  static const int kSize = 1;
1552  static const int kErrorCode = BgpProto::Notification::UpdateMsgErr;
1553  static const int kErrorSubcode =
1555  typedef int SequenceLength;
1556  static bool Verifier(const BgpMpNlri *obj, const uint8_t *data, size_t size,
1557  ParseContext *context) {
1558  uint8_t len = get_value(data, kSize);
1559  uint16_t afi = obj->afi;
1560  uint8_t safi = obj->safi;
1561  if (afi == BgpAf::IPv4 && safi == BgpAf::Unicast) {
1562  return (len == Address::kMaxV4Bytes);
1563  } else if (afi == BgpAf::IPv4 && safi == BgpAf::Mpls) {
1564  return (len == Address::kMaxV4Bytes);
1565  } else if (afi == BgpAf::IPv4 && safi == BgpAf::Vpn) {
1567  } else if (afi == BgpAf::IPv6 && safi == BgpAf::Unicast) {
1568  return (len == Address::kMaxV6Bytes ||
1569  len == 2 * Address::kMaxV6Bytes);
1570  } else if (afi == BgpAf::IPv6 && safi == BgpAf::Vpn) {
1572  } else if (afi == BgpAf::L2Vpn && safi == BgpAf::EVpn) {
1573  return (len == Address::kMaxV4Bytes);
1574  } else if (afi == BgpAf::IPv4 && safi == BgpAf::RTarget) {
1575  return (len == Address::kMaxV4Bytes);
1576  } else if (afi == BgpAf::IPv4 && safi == BgpAf::ErmVpn) {
1577  return (len == Address::kMaxV4Bytes);
1578  } else if (afi == BgpAf::IPv4 && safi == BgpAf::MVpn) {
1579  return (len == Address::kMaxV4Bytes);
1580  }
1581  return false;
1582  }
1583 };
1584 
1585 
1587  public ProtoElement<BgpPathAttributeMpNlriNexthopAddr> {
1588 public:
1589  static const int kSize = -1;
1591 };
1592 
1594  public ProtoSequence<BgpPathAttributeMpNlriNextHop> {
1595 public:
1596  typedef mpl::list<BgpPathAttributeMpNlriNextHopLength,
1598 };
1599 
1600 class BgpPathAttributeMpNlri : public ProtoSequence<BgpPathAttributeMpNlri> {
1601 public:
1602  static const int kMinOccurs = 0;
1603  static const int kMaxOccurs = -1;
1604 
1605  struct OptMatch {
1606  bool match(const BgpMpNlri *obj) {
1607  return ((obj->afi == BgpAf::IPv4 && obj->safi == BgpAf::Unicast) ||
1608  (obj->afi == BgpAf::IPv4 && obj->safi == BgpAf::Mpls) ||
1609  (obj->afi == BgpAf::IPv4 && obj->safi == BgpAf::Vpn) ||
1610  (obj->afi == BgpAf::IPv6 && obj->safi == BgpAf::Unicast) ||
1611  (obj->afi == BgpAf::IPv6 && obj->safi == BgpAf::Vpn) ||
1612  (obj->afi == BgpAf::IPv4 && obj->safi == BgpAf::RTarget));
1613  }
1614  };
1615 
1619  typedef mpl::list<BgpPrefixLen, BgpPrefixAddress> Sequence;
1620 };
1621 
1622 class BgpMvpnNlriType : public ProtoElement<BgpMvpnNlriType> {
1623 public:
1624  static const int kSize = 1;
1625  typedef Accessor<BgpProtoPrefix, uint8_t,
1627 };
1628 
1629 class BgpMvpnNlriLen : public ProtoElement<BgpMvpnNlriLen> {
1630 public:
1631  static const int kSize = 1;
1632 
1633  struct MvpnPrefixLen {
1634  static void set(BgpProtoPrefix *obj, int value) {
1635  obj->prefixlen = value * 8;
1636  }
1637 
1638  static int get(const BgpProtoPrefix *obj) {
1639  return obj->prefixlen / 8;
1640  }
1641  };
1642 
1643 
1644  typedef int SequenceLength;
1645 
1647 };
1648 
1650  : public ProtoSequence<BgpPathAttributeMpMvpnNlri> {
1651 public:
1652  static const int kMinOccurs = 0;
1653  static const int kMaxOccurs = -1;
1654 
1655  struct OptMatch {
1656  bool match(const BgpMpNlri *obj) {
1657  return ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::MVpn));
1658  }
1659  };
1660 
1662 
1665 
1666  typedef mpl::list<BgpMvpnNlriType, BgpMvpnNlriLen,
1668 };
1669 
1670 class BgpErmVpnNlriType : public ProtoElement<BgpErmVpnNlriType> {
1671 public:
1672  static const int kSize = 1;
1673  typedef Accessor<BgpProtoPrefix, uint8_t,
1675 };
1676 
1677 class BgpErmVpnNlriLen : public ProtoElement<BgpErmVpnNlriLen> {
1678 public:
1679  static const int kSize = 1;
1680 
1682  static void set(BgpProtoPrefix *obj, int value) {
1683  obj->prefixlen = value * 8;
1684  }
1685 
1686  static int get(const BgpProtoPrefix *obj) {
1687  return obj->prefixlen / 8;
1688  }
1689  };
1690 
1691 
1692  typedef int SequenceLength;
1693 
1695 };
1696 
1698  : public ProtoSequence<BgpPathAttributeMpErmVpnNlri> {
1699 public:
1700  static const int kMinOccurs = 0;
1701  static const int kMaxOccurs = -1;
1702 
1703  struct OptMatch {
1704  bool match(const BgpMpNlri *obj) {
1705  return ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::ErmVpn));
1706  }
1707  };
1708 
1710 
1713 
1714  typedef mpl::list<BgpErmVpnNlriType, BgpErmVpnNlriLen,
1716 };
1717 
1718 class BgpEvpnNlriType : public ProtoElement<BgpEvpnNlriType> {
1719 public:
1720  static const int kSize = 1;
1721  typedef Accessor<BgpProtoPrefix, uint8_t,
1723 };
1724 
1725 class BgpEvpnNlriLen : public ProtoElement<BgpEvpnNlriLen> {
1726 public:
1727  static const int kSize = 1;
1728 
1729  struct EvpnPrefixLen {
1730  static void set(BgpProtoPrefix *obj, int value) {
1731  obj->prefixlen = value * 8;
1732  }
1733 
1734  static int get(const BgpProtoPrefix *obj) {
1735  return obj->prefixlen / 8;
1736  }
1737  };
1738 
1739 
1740  typedef int SequenceLength;
1741 
1743 };
1744 
1746  public ProtoSequence<BgpPathAttributeMpEvpnNlri> {
1747 public:
1748  static const int kMinOccurs = 0;
1749  static const int kMaxOccurs = -1;
1750 
1751  struct OptMatch {
1752  bool match(const BgpMpNlri *obj) {
1753  return ((obj->afi == BgpAf::L2Vpn) && (obj->safi == BgpAf::EVpn));
1754  }
1755  };
1756 
1760  typedef mpl::list<BgpEvpnNlriType, BgpEvpnNlriLen,
1762 };
1763 
1765  public ProtoChoice<BgpPathAttributeMpNlriChoice> {
1766 public:
1767  static const int kSize = 0;
1768  struct MpChoice {
1769  static void set(BgpMpNlri *obj, int &value) {
1770  if ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::Unicast)) {
1771  value = 0;
1772  }
1773  if ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::Mpls)) {
1774  value = 0;
1775  }
1776  if ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::Vpn)) {
1777  value = 0;
1778  }
1779  if ((obj->afi == BgpAf::IPv6) && (obj->safi == BgpAf::Unicast)) {
1780  value = 0;
1781  }
1782  if ((obj->afi == BgpAf::IPv6) && (obj->safi == BgpAf::Vpn)) {
1783  value = 0;
1784  }
1785  if ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::RTarget)) {
1786  value = 0;
1787  }
1788  if ((obj->afi == BgpAf::L2Vpn) && (obj->safi == BgpAf::EVpn)) {
1789  value = 1;
1790  }
1791  if ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::ErmVpn)) {
1792  value = 2;
1793  }
1794  if ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::MVpn)) {
1795  value = 3;
1796  }
1797  }
1798 
1799  static int get(BgpMpNlri *obj) {
1800  if ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::Unicast)) {
1801  return 0;
1802  }
1803  if ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::Mpls)) {
1804  return 0;
1805  }
1806  if ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::Vpn)) {
1807  return 0;
1808  }
1809  if ((obj->afi == BgpAf::IPv6) && (obj->safi == BgpAf::Unicast)) {
1810  return 0;
1811  }
1812  if ((obj->afi == BgpAf::IPv6) && (obj->safi == BgpAf::Vpn)) {
1813  return 0;
1814  }
1815  if ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::RTarget)) {
1816  return 0;
1817  }
1818  if ((obj->afi == BgpAf::L2Vpn) && (obj->safi == BgpAf::EVpn)) {
1819  return 1;
1820  }
1821  if ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::ErmVpn)) {
1822  return 2;
1823  }
1824  if ((obj->afi == BgpAf::IPv4) && (obj->safi == BgpAf::MVpn)) {
1825  return 3;
1826  }
1827  return -1;
1828  }
1829  };
1830 
1831  typedef MpChoice Setter;
1832  typedef mpl::map<
1833  mpl::pair<mpl::int_<0>, BgpPathAttributeMpNlri>,
1834  mpl::pair<mpl::int_<1>, BgpPathAttributeMpEvpnNlri>,
1835  mpl::pair<mpl::int_<2>, BgpPathAttributeMpErmVpnNlri>,
1836  mpl::pair<mpl::int_<3>, BgpPathAttributeMpMvpnNlri>
1838 };
1839 
1841 public ProtoSequence<BgpPathAttributeMpReachNlriSequence> {
1842 public:
1843  struct Offset {
1844  string operator()() {
1845  return "MpReachUnreachNlri";
1846  }
1847  };
1851  typedef mpl::list<BgpPathAttrLength,
1857 };
1858 
1860 public ProtoSequence<BgpPathAttributeMpUnreachNlriSequence> {
1861 public:
1862  struct Offset {
1863  string operator()() {
1864  return "MpReachUnreachNlri";
1865  }
1866  };
1870  typedef mpl::list<BgpPathAttrLength,
1874 };
1875 
1876 class BgpPathAttrUnknownValue : public ProtoElement<BgpPathAttrUnknownValue> {
1877 public:
1878  static const int kSize = -1;
1879  static bool Verifier(BgpAttrUnknown *obj, const uint8_t *data, size_t size,
1880  ParseContext *context) {
1881  int pre = (obj->flags & BgpAttribute::ExtendedLength) ? 4 : 3;
1882  if (!(obj->flags & BgpAttribute::Optional)) {
1885  "BgpAttrUnknown", data - pre, context->size() + pre);
1886  return false;
1887  }
1888  return true;
1889  }
1890  typedef VectorAccessor<BgpAttrUnknown, uint8_t,
1892 };
1893 
1894 class BgpPathAttributeUnknown : public ProtoSequence<BgpPathAttributeUnknown> {
1895 public:
1898  typedef mpl::list<BgpPathAttrLength, BgpPathAttrUnknownValue> Sequence;
1899 };
1900 
1901 class BgpPathAttribute : public ProtoChoice<BgpPathAttribute> {
1902 public:
1903  static const int kSize = 1;
1904 
1906  typedef mpl::map<
1907  mpl::pair<mpl::int_<BgpAttribute::Origin>,
1910  mpl::pair<mpl::int_<BgpAttribute::AsPath>, BgpPathAttributeAsPath>,
1911  mpl::pair<mpl::int_<BgpAttribute::As4Path>, BgpPathAttributeAs4Path>,
1912  mpl::pair<mpl::int_<BgpAttribute::NextHop>,
1913  BgpAttrTemplate<BgpAttrNextHop, 4, uint32_t,
1915  mpl::pair<mpl::int_<BgpAttribute::MultiExitDisc>,
1918  mpl::pair<mpl::int_<BgpAttribute::LocalPref>,
1919  BgpAttrTemplate<BgpAttrLocalPref, 4, uint32_t,
1921  mpl::pair<mpl::int_<BgpAttribute::AtomicAggregate>,
1923  mpl::pair<mpl::int_<BgpAttribute::Aggregator>,
1925  mpl::pair<mpl::int_<BgpAttribute::As4Aggregator>,
1927  mpl::pair<mpl::int_<BgpAttribute::Communities>,
1929  mpl::pair<mpl::int_<BgpAttribute::OriginatorId>,
1930  BgpAttrTemplate<BgpAttrOriginatorId, 4, uint32_t,
1932  mpl::pair<mpl::int_<BgpAttribute::ClusterList>,
1934  mpl::pair<mpl::int_<BgpAttribute::MPReachNlri>,
1936  mpl::pair<mpl::int_<BgpAttribute::MPUnreachNlri>,
1938  mpl::pair<mpl::int_<BgpAttribute::ExtendedCommunities>,
1940  mpl::pair<mpl::int_<BgpAttribute::LargeCommunities>,
1942  mpl::pair<mpl::int_<BgpAttribute::PmsiTunnel>,
1944  mpl::pair<mpl::int_<BgpAttribute::McastEdgeDiscovery>,
1946  mpl::pair<mpl::int_<BgpAttribute::McastEdgeForwarding>,
1948  mpl::pair<mpl::int_<BgpAttribute::OriginVnPath>,
1950  mpl::pair<mpl::int_<-1>, BgpPathAttributeUnknown>
1952 };
1953 
1954 class BgpPathAttributeAs4 : public ProtoChoice<BgpPathAttributeAs4> {
1955 public:
1956  static const int kSize = 1;
1957 
1959  typedef mpl::map<
1960  mpl::pair<mpl::int_<BgpAttribute::Origin>,
1963  mpl::pair<mpl::int_<BgpAttribute::AsPath>,
1965  mpl::pair<mpl::int_<BgpAttribute::As4Path>, BgpPathAttributeAs4Path>,
1966  mpl::pair<mpl::int_<BgpAttribute::NextHop>,
1967  BgpAttrTemplate<BgpAttrNextHop, 4, uint32_t,
1969  mpl::pair<mpl::int_<BgpAttribute::MultiExitDisc>,
1972  mpl::pair<mpl::int_<BgpAttribute::LocalPref>,
1973  BgpAttrTemplate<BgpAttrLocalPref, 4, uint32_t,
1975  mpl::pair<mpl::int_<BgpAttribute::AtomicAggregate>,
1977  mpl::pair<mpl::int_<BgpAttribute::Aggregator>,
1979  mpl::pair<mpl::int_<BgpAttribute::As4Aggregator>,
1981  mpl::pair<mpl::int_<BgpAttribute::Communities>,
1983  mpl::pair<mpl::int_<BgpAttribute::OriginatorId>,
1984  BgpAttrTemplate<BgpAttrOriginatorId, 4, uint32_t,
1986  mpl::pair<mpl::int_<BgpAttribute::ClusterList>,
1988  mpl::pair<mpl::int_<BgpAttribute::MPReachNlri>,
1990  mpl::pair<mpl::int_<BgpAttribute::MPUnreachNlri>,
1992  mpl::pair<mpl::int_<BgpAttribute::ExtendedCommunities>,
1994  mpl::pair<mpl::int_<BgpAttribute::LargeCommunities>,
1996  mpl::pair<mpl::int_<BgpAttribute::PmsiTunnel>,
1998  mpl::pair<mpl::int_<BgpAttribute::McastEdgeDiscovery>,
2000  mpl::pair<mpl::int_<BgpAttribute::McastEdgeForwarding>,
2002  mpl::pair<mpl::int_<BgpAttribute::OriginVnPath>,
2004  mpl::pair<mpl::int_<-1>, BgpPathAttributeUnknown>
2006 };
2007 
2008 class BgpPathAttributeList : public ProtoSequence<BgpPathAttributeList> {
2009 public:
2010  static const int kSize = 2;
2011  static const int kMinOccurs = 0;
2012  static const int kMaxOccurs = -1;
2013  static const int kErrorCode = BgpProto::Notification::UpdateMsgErr;
2014  static const int kErrorSubcode =
2016  struct Offset {
2017  string operator()() {
2018  return "BgpPathAttribute";
2019  }
2020  };
2023  vector<BgpAttribute *>,
2025  typedef mpl::list<BgpPathAttributeFlags, BgpPathAttribute> Sequence;
2026 };
2027 
2028 class BgpPathAttributeAs4List : public ProtoSequence<BgpPathAttributeAs4List> {
2029 public:
2030  static const int kSize = 2;
2031  static const int kMinOccurs = 0;
2032  static const int kMaxOccurs = -1;
2033  static const int kErrorCode = BgpProto::Notification::UpdateMsgErr;
2034  static const int kErrorSubcode =
2036  struct Offset {
2037  string operator()() {
2038  return "BgpPathAttribute";
2039  }
2040  };
2043  vector<BgpAttribute *>,
2045  typedef mpl::list<BgpPathAttributeFlags, BgpPathAttributeAs4> Sequence;
2046 };
2047 
2048 class BgpUpdateNlri : public ProtoSequence<BgpUpdateNlri> {
2049 public:
2050  static const int kMinOccurs = 0;
2051  static const int kMaxOccurs = -1;
2052 
2054  vector<BgpProtoPrefix *>,
2056 
2057  struct OptMatch {
2058  bool match(const BgpProto::Update *ctx) {
2059  return !ctx->nlri.empty();
2060  }
2061  };
2063  typedef mpl::list<BgpPrefixLen, BgpPrefixAddress> Sequence;
2064 };
2065 
2066 class BgpUpdateMessageAs4 : public ProtoSequence<BgpUpdateMessageAs4> {
2067 public:
2071 };
2072 
2073 class BgpUpdateMessage : public ProtoSequence<BgpUpdateMessage> {
2074 public:
2078 };
2079 
2080 class BgpMsgType : public ProtoChoice<BgpMsgType> {
2081 public:
2082  static const int kSize = 1;
2083  static const int kErrorCode = BgpProto::Notification::MsgHdrErr;
2084  static const int kErrorSubcode = BgpProto::Notification::BadMsgType;
2085  typedef mpl::map<
2086  mpl::pair<mpl::int_<BgpProto::OPEN>, BgpOpenMessage>,
2087  mpl::pair<mpl::int_<BgpProto::NOTIFICATION>, BgpNotificationMessage>,
2088  mpl::pair<mpl::int_<BgpProto::KEEPALIVE>, BgpKeepaliveMessage>,
2089  mpl::pair<mpl::int_<BgpProto::UPDATE>, BgpUpdateMessage>
2091 };
2092 
2093 class BgpMsgTypeAs4 : public ProtoChoice<BgpMsgTypeAs4> {
2094 public:
2095  static const int kSize = 1;
2096  static const int kErrorCode = BgpProto::Notification::MsgHdrErr;
2097  static const int kErrorSubcode = BgpProto::Notification::BadMsgType;
2098  typedef mpl::map<
2099  mpl::pair<mpl::int_<BgpProto::OPEN>, BgpOpenMessage>,
2100  mpl::pair<mpl::int_<BgpProto::NOTIFICATION>, BgpNotificationMessage>,
2101  mpl::pair<mpl::int_<BgpProto::KEEPALIVE>, BgpKeepaliveMessage>,
2102  mpl::pair<mpl::int_<BgpProto::UPDATE>, BgpUpdateMessageAs4>
2104 };
2105 
2106 class BgpProtocol : public ProtoSequence<BgpProtocol> {
2107 public:
2108  typedef mpl::list<BgpMarker, BgpMsgLength, BgpMsgType> Sequence;
2109 };
2110 
2111 class BgpProtocolAs4 : public ProtoSequence<BgpProtocolAs4> {
2112 public:
2113  typedef mpl::list<BgpMarker, BgpMsgLength, BgpMsgTypeAs4> Sequence;
2114 };
2115 
2116 BgpProto::BgpMessage *BgpProto::Decode(const uint8_t *data, size_t size,
2117  ParseErrorContext *ec, bool as4) {
2118  ParseContext context;
2119  int result;
2120  if (as4) {
2121  result = BgpProtocolAs4::Parse(data, size, &context,
2122  reinterpret_cast<void *>(NULL));
2123  } else {
2124  result = BgpProtocol::Parse(data, size, &context,
2125  reinterpret_cast<void *>(NULL));
2126  }
2127  if (result < 0) {
2128  if (ec) {
2129  *ec = context.error_context();
2130  }
2131  return NULL;
2132  }
2133  return static_cast<BgpMessage *>(context.release());
2134 }
2135 
2136 int BgpProto::Encode(const BgpMessage *msg, uint8_t *data, size_t size,
2137  EncodeOffsets *offsets, bool as4) {
2138  EncodeContext ctx;
2139  int result;
2140  if (as4) {
2141  result = BgpProtocolAs4::Encode(&ctx, msg, data, size);
2142  } else {
2143  result = BgpProtocol::Encode(&ctx, msg, data, size);
2144  }
2145  if (offsets) {
2146  *offsets = ctx.encode_offsets();
2147  }
2148  return result;
2149 }
2150 
2151 int BgpProto::Encode(const BgpMpNlri *msg, uint8_t *data, size_t size,
2152  EncodeOffsets *offsets) {
2153  EncodeContext ctx;
2154  int result = 0;
2155  if ((msg->afi == BgpAf::L2Vpn) && (msg->safi == BgpAf::EVpn)) {
2156  result = BgpPathAttributeMpEvpnNlri::Encode(&ctx, msg, data, size);
2157  } else if ((msg->afi == BgpAf::IPv4) && (msg->safi == BgpAf::ErmVpn)) {
2158  result = BgpPathAttributeMpErmVpnNlri::Encode(&ctx, msg, data, size);
2159  } else if ((msg->afi == BgpAf::IPv4) && (msg->safi == BgpAf::MVpn)) {
2160  result = BgpPathAttributeMpMvpnNlri::Encode(&ctx, msg, data, size);
2161  } else {
2162  result = BgpPathAttributeMpNlri::Encode(&ctx, msg, data, size);
2163  }
2164  if (offsets) {
2165  *offsets = ctx.encode_offsets();
2166  }
2167  return result;
2168 }
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:15
#define AS_TRANS
Definition: bgp_common.h:24
uint16_t as2_t
Definition: bgp_common.h:23
uint32_t as_t
Definition: bgp_common.h:22
#define BGP_LOG_FLAG_ALL
Definition: bgp_log.h:45
#define BGP_LOG_PEER(type, peer, level, flags, dir, arg)
Definition: bgp_log.h:160
#define BGP_LOG_PEER_WARNING(type, peer, flags, dir, arg)
Definition: bgp_log.h:183
#define BGP_PEER_DIR_IN
Definition: bgp_log.h:140
#define BGP_LOG_FLAG_TRACE
Definition: bgp_log.h:44
Family
Definition: address.h:25
@ UNSPEC
Definition: address.h:26
static const uint8_t kMaxV6Bytes
Definition: address.h:22
static std::string FamilyToString(Family fmly)
Definition: address.cc:64
static const uint8_t kMaxV4Bytes
Definition: address.h:20
@ ErmVpn
Definition: bgp_af.h:34
@ RTarget
Definition: bgp_af.h:31
@ EVpn
Definition: bgp_af.h:29
@ Unicast
Definition: bgp_af.h:26
@ MVpn
Definition: bgp_af.h:28
@ Vpn
Definition: bgp_af.h:30
@ Mpls
Definition: bgp_af.h:27
static std::pair< uint16_t, uint8_t > FamilyToAfiSafi(Address::Family family)
Definition: bgp_af.cc:131
@ L2Vpn
Definition: bgp_af.h:22
@ IPv4
Definition: bgp_af.h:20
@ IPv6
Definition: bgp_af.h:21
static Address::Family AfiSafiToFamily(uint16_t afi, uint8_t safi)
Definition: bgp_af.cc:72
static std::string ToString(uint16_t afi, uint8_t safi)
Definition: bgp_af.cc:15
BgpContextSwap< C > ContextSwap
Definition: bgp_proto.cc:934
mpl::list< BgpPathAttrLength, BgpAttributeValue< Size, C, T, M > > Sequence
Definition: bgp_proto.cc:936
Accessor< C, T, Member > Setter
Definition: bgp_proto.cc:924
static bool Verifier(const C *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:920
uint8_t flags
Definition: bgp_attr_base.h:72
uint8_t GetEncodeFlags() const
static const uint8_t FLAG_MASK
Definition: bgp_attr_base.h:69
uint8_t code
Definition: bgp_attr_base.h:70
ErmVpnPrefixLen Setter
Definition: bgp_proto.cc:1694
Accessor< BgpProtoPrefix, uint8_t, &BgpProtoPrefix::type > Setter
Definition: bgp_proto.cc:1674
EvpnPrefixLen Setter
Definition: bgp_proto.cc:1742
Accessor< BgpProtoPrefix, uint8_t, &BgpProtoPrefix::type > Setter
Definition: bgp_proto.cc:1722
Accessor< BgpProto::OpenMessage, int32_t, &BgpProto::OpenMessage::holdtime > Setter
Definition: bgp_proto.cc:602
static bool Verifier(const BgpProto::OpenMessage *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:596
Accessor< BgpProto::OpenMessage, uint32_t, &BgpProto::OpenMessage::identifier > Setter
Definition: bgp_proto.cc:609
BgpProto::Keepalive ContextType
Definition: bgp_proto.cc:722
mpl::list Sequence
Definition: bgp_proto.cc:721
static bool Verifier(const void *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:522
static void Writer(const void *msg, uint8_t *data, size_t size)
Definition: bgp_proto.cc:529
Offset SaveOffset
Definition: bgp_proto.cc:546
SetLength EncodingCallback
Definition: bgp_proto.cc:565
static bool Verifier(const void *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:547
mpl::map< mpl::pair< mpl::int_< BgpProto::OPEN >, BgpOpenMessage >, mpl::pair< mpl::int_< BgpProto::NOTIFICATION >, BgpNotificationMessage >, mpl::pair< mpl::int_< BgpProto::KEEPALIVE >, BgpKeepaliveMessage >, mpl::pair< mpl::int_< BgpProto::UPDATE >, BgpUpdateMessageAs4 > > Choice
Definition: bgp_proto.cc:2103
mpl::map< mpl::pair< mpl::int_< BgpProto::OPEN >, BgpOpenMessage >, mpl::pair< mpl::int_< BgpProto::NOTIFICATION >, BgpNotificationMessage >, mpl::pair< mpl::int_< BgpProto::KEEPALIVE >, BgpKeepaliveMessage >, mpl::pair< mpl::int_< BgpProto::UPDATE >, BgpUpdateMessage > > Choice
Definition: bgp_proto.cc:2090
MvpnPrefixLen Setter
Definition: bgp_proto.cc:1646
Accessor< BgpProtoPrefix, uint8_t, &BgpProtoPrefix::type > Setter
Definition: bgp_proto.cc:1626
BgpProto::Notification ContextType
Definition: bgp_proto.cc:716
mpl::list< NotificationErrorCode, NotificationErrorSubcode, NotificationData > Sequence
Definition: bgp_proto.cc:715
Accessor< BgpProto::OpenMessage, uint32_t, &BgpProto::OpenMessage::as_num > Setter
Definition: bgp_proto.cc:587
OptMatch ContextMatch
Definition: bgp_proto.cc:654
mpl::list< BgpOpenCapability > Sequence
Definition: bgp_proto.cc:643
CollectionAccessor< BgpProto::OpenMessage::OptParam, vector< BgpProto::OpenMessage::Capability * >, &BgpProto::OpenMessage::OptParam::capabilities > ContextStorer
Definition: bgp_proto.cc:647
Accessor< BgpProto::OpenMessage::Capability, int, &BgpProto::OpenMessage::Capability::code > Setter
Definition: bgp_proto.cc:616
VectorAccessor< BgpProto::OpenMessage::Capability, uint8_t, &BgpProto::OpenMessage::Capability::capability > Setter
Definition: bgp_proto.cc:629
mpl::list< BgpOpenCapabilityCode, BgpOpenCapabilityLength, BgpOpenCapabilityValue > Sequence
Definition: bgp_proto.cc:635
BgpProto::OpenMessage ContextType
Definition: bgp_proto.cc:687
mpl::list< BgpOpenVersion, BgpOpenAsNum, BgpHoldTime, BgpIdentifier, BgpOpenOptParam > Sequence
Definition: bgp_proto.cc:686
mpl::map< mpl::pair< mpl::int_< BgpProto::OpenMessage::OPEN_OPT_CAPABILITIES >, BgpOpenCapabilities > > Choice
Definition: bgp_proto.cc:666
mpl::list< BgpOpenOptParamChoice > Sequence
Definition: bgp_proto.cc:677
CollectionAccessor< BgpProto::OpenMessage, vector< BgpProto::OpenMessage::OptParam * >, &BgpProto::OpenMessage::opt_params > ContextStorer
Definition: bgp_proto.cc:676
static bool Verifier(const void *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:574
static void Writer(const void *msg, uint8_t *data, size_t size)
Definition: bgp_proto.cc:578
PathSegmentLength SequenceLength
Definition: bgp_proto.cc:1055
CollectionAccessor< As4PathSpec, vector< As4PathSpec::PathSegment * >, &As4PathSpec::path_segments > ContextStorer
Definition: bgp_proto.cc:1151
mpl::list< BgpAttributeValue< 1, As4PathSpec::PathSegment, int, &As4PathSpec::PathSegment::path_segment_type >, BgpPathAttrAs4PathSegmentLength, BgpPathAttrAs4PathSegmentValue > Sequence
Definition: bgp_proto.cc:1157
static bool Verifier(const As4PathSpec *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1143
VectorAccessor< As4PathSpec::PathSegment, as_t, &As4PathSpec::PathSegment::path_segment > Setter
Definition: bgp_proto.cc:1088
mpl::list< BgpAttributeValue< 1, AsPath4ByteSpec::PathSegment, int, &AsPath4ByteSpec::PathSegment::path_segment_type >, BgpPathAttrAsPath4ByteSegmentLength, BgpPathAttrAsPath4ByteSegmentValue > Sequence
Definition: bgp_proto.cc:1134
static bool Verifier(const AsPath4ByteSpec *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1120
CollectionAccessor< AsPath4ByteSpec, vector< AsPath4ByteSpec::PathSegment * >, &AsPath4ByteSpec::path_segments > ContextStorer
Definition: bgp_proto.cc:1128
VectorAccessor< AsPath4ByteSpec::PathSegment, as_t, &AsPath4ByteSpec::PathSegment::path_segment > Setter
Definition: bgp_proto.cc:1080
PathSegmentLength SequenceLength
Definition: bgp_proto.cc:1013
mpl::list< BgpAttributeValue< 1, AsPathSpec::PathSegment, int, &AsPathSpec::PathSegment::path_segment_type >, BgpPathAttrAsPathSegmentLength, BgpPathAttrAsPathSegmentValue > Sequence
Definition: bgp_proto.cc:1111
static bool Verifier(const AsPathSpec *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1097
CollectionAccessor< AsPathSpec, vector< AsPathSpec::PathSegment * >, &AsPathSpec::path_segments > ContextStorer
Definition: bgp_proto.cc:1105
VectorAccessor< AsPathSpec::PathSegment, as2_t, &AsPathSpec::PathSegment::path_segment > Setter
Definition: bgp_proto.cc:1072
AttrSizeSet SizeSetter
Definition: bgp_proto.cc:796
AttrLen SequenceLength
Definition: bgp_proto.cc:785
VectorAccessor< BgpAttrUnknown, uint8_t, &BgpAttrUnknown::value > Setter
Definition: bgp_proto.cc:1891
static bool Verifier(BgpAttrUnknown *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1879
BgpAttr4ByteAggregator ContextType
Definition: bgp_proto.cc:980
BgpContextSwap< BgpAttr4ByteAggregator > ContextSwap
Definition: bgp_proto.cc:981
mpl::list< BgpPathAttrLength, BgpAttributeValue< 4, BgpAttr4ByteAggregator, as_t, &BgpAttr4ByteAggregator::as_num >, BgpAttributeValue< 4, BgpAttr4ByteAggregator, uint32_t, &BgpAttr4ByteAggregator::address > > Sequence
Definition: bgp_proto.cc:987
mpl::list< BgpPathAttrLength, BgpAttributeValue< 2, BgpAttrAggregator, as2_t, &BgpAttrAggregator::as_num >, BgpAttributeValue< 4, BgpAttrAggregator, uint32_t, &BgpAttrAggregator::address > > Sequence
Definition: bgp_proto.cc:974
BgpAttrAggregator ContextType
Definition: bgp_proto.cc:967
BgpContextSwap< BgpAttrAggregator > ContextSwap
Definition: bgp_proto.cc:968
mpl::list< BgpPathAttrLength, BgpAttributeValue< 4, BgpAttrAs4Aggregator, as_t, &BgpAttrAs4Aggregator::as_num >, BgpAttributeValue< 4, BgpAttrAs4Aggregator, uint32_t, &BgpAttrAs4Aggregator::address > > Sequence
Definition: bgp_proto.cc:1000
BgpContextSwap< BgpAttrAs4Aggregator > ContextSwap
Definition: bgp_proto.cc:994
BgpAttrAs4Aggregator ContextType
Definition: bgp_proto.cc:993
mpl::list< BgpPathAttributeFlags, BgpPathAttributeAs4 > Sequence
Definition: bgp_proto.cc:2045
CollectionAccessor< BgpProto::Update, vector< BgpAttribute * >, &BgpProto::Update::path_attributes > ContextStorer
Definition: bgp_proto.cc:2044
BgpContextSwap< As4PathSpec > ContextSwap
Definition: bgp_proto.cc:1179
mpl::list< BgpPathAttrLength, BgpPathAttrAs4PathSegmentList > Sequence
Definition: bgp_proto.cc:1180
mpl::map< mpl::pair< mpl::int_< BgpAttribute::Origin >, BgpAttrTemplate< BgpAttrOrigin, 1, int, &BgpAttrOrigin::origin > >, mpl::pair< mpl::int_< BgpAttribute::AsPath >, BgpPathAttributeAsPath4Byte >, mpl::pair< mpl::int_< BgpAttribute::As4Path >, BgpPathAttributeAs4Path >, mpl::pair< mpl::int_< BgpAttribute::NextHop >, BgpAttrTemplate< BgpAttrNextHop, 4, uint32_t, &BgpAttrNextHop::nexthop > >, mpl::pair< mpl::int_< BgpAttribute::MultiExitDisc >, BgpAttrTemplate< BgpAttrMultiExitDisc, 4, uint32_t, &BgpAttrMultiExitDisc::med > >, mpl::pair< mpl::int_< BgpAttribute::LocalPref >, BgpAttrTemplate< BgpAttrLocalPref, 4, uint32_t, &BgpAttrLocalPref::local_pref > >, mpl::pair< mpl::int_< BgpAttribute::AtomicAggregate >, BgpPathAttributeAtomicAggregate >, mpl::pair< mpl::int_< BgpAttribute::Aggregator >, BgpPathAttributeAggregator4Byte >, mpl::pair< mpl::int_< BgpAttribute::As4Aggregator >, BgpPathAttributeAs4Aggregator >, mpl::pair< mpl::int_< BgpAttribute::Communities >, BgpPathAttributeCommunities >, mpl::pair< mpl::int_< BgpAttribute::OriginatorId >, BgpAttrTemplate< BgpAttrOriginatorId, 4, uint32_t, &BgpAttrOriginatorId::originator_id > >, mpl::pair< mpl::int_< BgpAttribute::ClusterList >, BgpPathAttributeClusterList >, mpl::pair< mpl::int_< BgpAttribute::MPReachNlri >, BgpPathAttributeMpReachNlriSequence >, mpl::pair< mpl::int_< BgpAttribute::MPUnreachNlri >, BgpPathAttributeMpUnreachNlriSequence >, mpl::pair< mpl::int_< BgpAttribute::ExtendedCommunities >, BgpPathAttributeExtendedCommunities >, mpl::pair< mpl::int_< BgpAttribute::LargeCommunities >, BgpPathAttributeLargeCommunities >, mpl::pair< mpl::int_< BgpAttribute::PmsiTunnel >, BgpPathAttributePmsiTunnel >, mpl::pair< mpl::int_< BgpAttribute::McastEdgeDiscovery >, BgpPathAttributeEdgeDiscovery >, mpl::pair< mpl::int_< BgpAttribute::McastEdgeForwarding >, BgpPathAttributeEdgeForwarding >, mpl::pair< mpl::int_< BgpAttribute::OriginVnPath >, BgpPathAttributeOriginVnPath >, mpl::pair< mpl::int_<-1 >, BgpPathAttributeUnknown > > Choice
Definition: bgp_proto.cc:2005
Accessor< BgpAttribute, uint8_t, &BgpAttribute::code > Setter
Definition: bgp_proto.cc:1958
mpl::list< BgpPathAttrLength, BgpPathAttrAsPath4ByteSegmentList > Sequence
Definition: bgp_proto.cc:1173
AsPath4ByteSpec ContextType
Definition: bgp_proto.cc:1170
BgpContextSwap< AsPath4ByteSpec > ContextSwap
Definition: bgp_proto.cc:1171
BgpContextSwap< AsPathSpec > ContextSwap
Definition: bgp_proto.cc:1163
mpl::list< BgpPathAttrLength, BgpPathAttrAsPathSegmentList > Sequence
Definition: bgp_proto.cc:1164
BgpAttrAtomicAggregate ContextType
Definition: bgp_proto.cc:959
mpl::list< BgpPathAttrLength > Sequence
Definition: bgp_proto.cc:961
static bool Verifier(const BgpAttrAtomicAggregate *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:942
BgpContextSwap< BgpAttrAtomicAggregate > ContextSwap
Definition: bgp_proto.cc:960
VectorAccessor< ClusterListSpec, uint32_t, &ClusterListSpec::cluster_list > Setter
Definition: bgp_proto.cc:1272
mpl::list< BgpPathAttrLength, BgpPathAttributeClusterListData > Sequence
Definition: bgp_proto.cc:1281
ClusterListSpec ContextType
Definition: bgp_proto.cc:1278
BgpContextSwap< ClusterListSpec > ContextSwap
Definition: bgp_proto.cc:1279
BgpContextSwap< CommunitySpec > ContextSwap
Definition: bgp_proto.cc:1215
mpl::list< BgpPathAttrLength, BgpPathAttributeCommunityList > Sequence
Definition: bgp_proto.cc:1217
static bool Verifier(const CommunitySpec *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1201
VectorAccessor< CommunitySpec, uint32_t, &CommunitySpec::communities > Setter
Definition: bgp_proto.cc:1208
static bool Verifier(const void *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1339
VectorAccessor< EdgeDiscoverySpec::Edge, uint8_t, &EdgeDiscoverySpec::Edge::address > Setter
Definition: bgp_proto.cc:1352
mpl::list< BgpPathAttributeDiscoveryEdgeAddressLen, BgpPathAttributeDiscoveryEdgeAddressValue > Sequence
Definition: bgp_proto.cc:1359
static bool Verifier(const void *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1366
VectorAccessor< EdgeDiscoverySpec::Edge, uint32_t, &EdgeDiscoverySpec::Edge::labels > Setter
Definition: bgp_proto.cc:1379
mpl::list< BgpPathAttributeDiscoveryEdgeLabelLen, BgpPathAttributeDiscoveryEdgeLabelValues > Sequence
Definition: bgp_proto.cc:1386
CollectionAccessor< EdgeDiscoverySpec, vector< EdgeDiscoverySpec::Edge * >, &EdgeDiscoverySpec::edge_list > ContextStorer
Definition: bgp_proto.cc:1403
static bool Verifier(const EdgeDiscoverySpec *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1395
mpl::list< BgpPathAttributeDiscoveryEdgeAddress, BgpPathAttributeDiscoveryEdgeLabels > Sequence
Definition: bgp_proto.cc:1406
mpl::list< BgpPathAttrLength, BgpPathAttributeDiscoveryEdgeList > Sequence
Definition: bgp_proto.cc:1415
BgpContextSwap< EdgeDiscoverySpec > ContextSwap
Definition: bgp_proto.cc:1413
EdgeDiscoverySpec ContextType
Definition: bgp_proto.cc:1412
EdgeForwardingSpec ContextType
Definition: bgp_proto.cc:1534
mpl::list< BgpPathAttrLength, BgpPathAttributeForwardingEdgeList > Sequence
Definition: bgp_proto.cc:1537
BgpContextSwap< EdgeForwardingSpec > ContextSwap
Definition: bgp_proto.cc:1535
BgpContextSwap< ExtCommunitySpec > ContextSwap
Definition: bgp_proto.cc:1238
mpl::list< BgpPathAttrLength, BgpPathAttributeExtendedCommunityList > Sequence
Definition: bgp_proto.cc:1240
static bool Verifier(const ExtCommunitySpec *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1224
VectorAccessor< ExtCommunitySpec, uint64_t, &ExtCommunitySpec::communities > Setter
Definition: bgp_proto.cc:1231
FlagsAccessor Setter
Definition: bgp_proto.cc:1194
VectorAccessor< EdgeForwardingSpec::Edge, uint8_t, &EdgeForwardingSpec::Edge::inbound_address > Setter
Definition: bgp_proto.cc:1463
mpl::list< BgpPathAttributeForwardingEdgeAddressLen, BgpPathAttributeForwardingEdgeInAddressValue > Sequence
Definition: bgp_proto.cc:1472
Accessor< EdgeForwardingSpec::Edge, uint32_t, &EdgeForwardingSpec::Edge::inbound_label > Setter
Definition: bgp_proto.cc:1480
static bool Verifier(const void *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1422
CollectionAccessor< EdgeForwardingSpec, vector< EdgeForwardingSpec::Edge * >, &EdgeForwardingSpec::edge_list > ContextStorer
Definition: bgp_proto.cc:1522
static bool Verifier(const EdgeForwardingSpec *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1514
mpl::list< BgpPathAttributeForwardingEdgeLen, BgpPathAttributeForwardingEdgeInAddress, BgpPathAttributeForwardingEdgeInLabel, BgpPathAttributeForwardingEdgeOutAddress, BgpPathAttributeForwardingEdgeOutLabel > Sequence
Definition: bgp_proto.cc:1528
VectorAccessor< EdgeForwardingSpec::Edge, uint8_t, &EdgeForwardingSpec::Edge::outbound_address > Setter
Definition: bgp_proto.cc:1488
mpl::list< BgpPathAttributeForwardingEdgeAddressLen, BgpPathAttributeForwardingEdgeOutAddressValue > Sequence
Definition: bgp_proto.cc:1497
Accessor< EdgeForwardingSpec::Edge, uint32_t, &EdgeForwardingSpec::Edge::outbound_label > Setter
Definition: bgp_proto.cc:1505
LargeCommunitySpec ContextType
Definition: bgp_proto.cc:1261
mpl::list< BgpPathAttrLength, BgpPathAttributeLargeCommunityList > Sequence
Definition: bgp_proto.cc:1264
BgpContextSwap< LargeCommunitySpec > ContextSwap
Definition: bgp_proto.cc:1262
static bool Verifier(const LargeCommunitySpec *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1247
VectorAccessor< LargeCommunitySpec, uint32_t, &LargeCommunitySpec::communities > Setter
Definition: bgp_proto.cc:1255
CollectionAccessor< BgpProto::Update, vector< BgpAttribute * >, &BgpProto::Update::path_attributes > ContextStorer
Definition: bgp_proto.cc:2024
mpl::list< BgpPathAttributeFlags, BgpPathAttribute > Sequence
Definition: bgp_proto.cc:2025
mpl::list< BgpErmVpnNlriType, BgpErmVpnNlriLen, BgpPrefixAddress > Sequence
Definition: bgp_proto.cc:1715
CollectionAccessor< BgpMpNlri, vector< BgpProtoPrefix * >, &BgpMpNlri::nlri > ContextStorer
Definition: bgp_proto.cc:1712
CollectionAccessor< BgpMpNlri, vector< BgpProtoPrefix * >, &BgpMpNlri::nlri > ContextStorer
Definition: bgp_proto.cc:1759
mpl::list< BgpEvpnNlriType, BgpEvpnNlriLen, BgpPrefixAddress > Sequence
Definition: bgp_proto.cc:1761
mpl::list< BgpMvpnNlriType, BgpMvpnNlriLen, BgpPrefixAddress > Sequence
Definition: bgp_proto.cc:1667
CollectionAccessor< BgpMpNlri, vector< BgpProtoPrefix * >, &BgpMpNlri::nlri > ContextStorer
Definition: bgp_proto.cc:1664
mpl::map< mpl::pair< mpl::int_< 0 >, BgpPathAttributeMpNlri >, mpl::pair< mpl::int_< 1 >, BgpPathAttributeMpEvpnNlri >, mpl::pair< mpl::int_< 2 >, BgpPathAttributeMpErmVpnNlri >, mpl::pair< mpl::int_< 3 >, BgpPathAttributeMpMvpnNlri > > Choice
Definition: bgp_proto.cc:1837
static bool Verifier(const BgpMpNlri *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1556
mpl::list< BgpPathAttributeMpNlriNextHopLength, BgpPathAttributeMpNlriNexthopAddr > Sequence
Definition: bgp_proto.cc:1597
VectorAccessor< BgpMpNlri, uint8_t, &BgpMpNlri::nexthop > Setter
Definition: bgp_proto.cc:1590
mpl::list< BgpPrefixLen, BgpPrefixAddress > Sequence
Definition: bgp_proto.cc:1619
CollectionAccessor< BgpMpNlri, vector< BgpProtoPrefix * >, &BgpMpNlri::nlri > ContextStorer
Definition: bgp_proto.cc:1618
mpl::list< BgpPathAttrLength, BgpAttributeValue< 2, BgpMpNlri, uint16_t, &BgpMpNlri::afi >, BgpAttributeValue< 1, BgpMpNlri, uint8_t, &BgpMpNlri::safi >, BgpPathAttributeMpNlriNextHop, BgpPathAttributeReserved, BgpPathAttributeMpNlriChoice > Sequence
Definition: bgp_proto.cc:1856
BgpContextSwap< BgpMpNlri > ContextSwap
Definition: bgp_proto.cc:1850
BgpContextSwap< BgpMpNlri > ContextSwap
Definition: bgp_proto.cc:1869
mpl::list< BgpPathAttrLength, BgpAttributeValue< 2, BgpMpNlri, uint16_t, &BgpMpNlri::afi >, BgpAttributeValue< 1, BgpMpNlri, uint8_t, &BgpMpNlri::safi >, BgpPathAttributeMpNlriChoice > Sequence
Definition: bgp_proto.cc:1873
static bool Verifier(const OriginVnPathSpec *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1288
VectorAccessor< OriginVnPathSpec, uint64_t, &OriginVnPathSpec::origin_vns > Setter
Definition: bgp_proto.cc:1295
BgpContextSwap< OriginVnPathSpec > ContextSwap
Definition: bgp_proto.cc:1302
OriginVnPathSpec ContextType
Definition: bgp_proto.cc:1301
mpl::list< BgpPathAttrLength, BgpPathAttributeOriginVnList > Sequence
Definition: bgp_proto.cc:1303
VectorAccessor< PmsiTunnelSpec, uint8_t, &PmsiTunnelSpec::identifier > Setter
Definition: bgp_proto.cc:1317
static bool Verifier(const PmsiTunnelSpec *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:1310
PmsiTunnelSpec ContextType
Definition: bgp_proto.cc:1323
BgpContextSwap< PmsiTunnelSpec > ContextSwap
Definition: bgp_proto.cc:1324
mpl::list< BgpPathAttrLength, BgpAttributeValue< 1, PmsiTunnelSpec, uint8_t, &PmsiTunnelSpec::tunnel_flags >, BgpAttributeValue< 1, PmsiTunnelSpec, uint8_t, &PmsiTunnelSpec::tunnel_type >, BgpAttributeValue< 3, PmsiTunnelSpec, uint32_t, &PmsiTunnelSpec::label >, BgpPathAttributePmsiTunnelIdentifier > Sequence
Definition: bgp_proto.cc:1332
static void Writer(const void *msg, uint8_t *data, size_t size)
Definition: bgp_proto.cc:1543
BgpContextSwap< BgpAttrUnknown > ContextSwap
Definition: bgp_proto.cc:1897
BgpAttrUnknown ContextType
Definition: bgp_proto.cc:1896
mpl::list< BgpPathAttrLength, BgpPathAttrUnknownValue > Sequence
Definition: bgp_proto.cc:1898
mpl::map< mpl::pair< mpl::int_< BgpAttribute::Origin >, BgpAttrTemplate< BgpAttrOrigin, 1, int, &BgpAttrOrigin::origin > >, mpl::pair< mpl::int_< BgpAttribute::AsPath >, BgpPathAttributeAsPath >, mpl::pair< mpl::int_< BgpAttribute::As4Path >, BgpPathAttributeAs4Path >, mpl::pair< mpl::int_< BgpAttribute::NextHop >, BgpAttrTemplate< BgpAttrNextHop, 4, uint32_t, &BgpAttrNextHop::nexthop > >, mpl::pair< mpl::int_< BgpAttribute::MultiExitDisc >, BgpAttrTemplate< BgpAttrMultiExitDisc, 4, uint32_t, &BgpAttrMultiExitDisc::med > >, mpl::pair< mpl::int_< BgpAttribute::LocalPref >, BgpAttrTemplate< BgpAttrLocalPref, 4, uint32_t, &BgpAttrLocalPref::local_pref > >, mpl::pair< mpl::int_< BgpAttribute::AtomicAggregate >, BgpPathAttributeAtomicAggregate >, mpl::pair< mpl::int_< BgpAttribute::Aggregator >, BgpPathAttributeAggregator >, mpl::pair< mpl::int_< BgpAttribute::As4Aggregator >, BgpPathAttributeAs4Aggregator >, mpl::pair< mpl::int_< BgpAttribute::Communities >, BgpPathAttributeCommunities >, mpl::pair< mpl::int_< BgpAttribute::OriginatorId >, BgpAttrTemplate< BgpAttrOriginatorId, 4, uint32_t, &BgpAttrOriginatorId::originator_id > >, mpl::pair< mpl::int_< BgpAttribute::ClusterList >, BgpPathAttributeClusterList >, mpl::pair< mpl::int_< BgpAttribute::MPReachNlri >, BgpPathAttributeMpReachNlriSequence >, mpl::pair< mpl::int_< BgpAttribute::MPUnreachNlri >, BgpPathAttributeMpUnreachNlriSequence >, mpl::pair< mpl::int_< BgpAttribute::ExtendedCommunities >, BgpPathAttributeExtendedCommunities >, mpl::pair< mpl::int_< BgpAttribute::LargeCommunities >, BgpPathAttributeLargeCommunities >, mpl::pair< mpl::int_< BgpAttribute::PmsiTunnel >, BgpPathAttributePmsiTunnel >, mpl::pair< mpl::int_< BgpAttribute::McastEdgeDiscovery >, BgpPathAttributeEdgeDiscovery >, mpl::pair< mpl::int_< BgpAttribute::McastEdgeForwarding >, BgpPathAttributeEdgeForwarding >, mpl::pair< mpl::int_< BgpAttribute::OriginVnPath >, BgpPathAttributeOriginVnPath >, mpl::pair< mpl::int_<-1 >, BgpPathAttributeUnknown > > Choice
Definition: bgp_proto.cc:1951
Accessor< BgpAttribute, uint8_t, &BgpAttribute::code > Setter
Definition: bgp_proto.cc:1905
virtual BgpProto::BgpPeerType PeerType() const
Definition: bgp_peer.h:210
virtual BgpServer * server()
Definition: bgp_peer.h:159
virtual bool IsAs4Supported() const
Definition: bgp_peer.h:316
as_t peer_as() const
Definition: bgp_peer.h:186
bool LookupFamily(Address::Family family)
Definition: bgp_peer.h:199
VectorAccessor< BgpProtoPrefix, uint8_t, &BgpProtoPrefix::prefix > Setter
Definition: bgp_proto.cc:743
Accessor< BgpProtoPrefix, int, &BgpProtoPrefix::prefixlen > Setter
Definition: bgp_proto.cc:736
PrefixLen SequenceLength
Definition: bgp_proto.cc:734
@ NOTIFICATION
Definition: bgp_proto.h:25
@ UPDATE
Definition: bgp_proto.h:24
@ KEEPALIVE
Definition: bgp_proto.h:26
static const int kMinMessageSize
Definition: bgp_proto.h:441
static const int kMaxMessageSize
Definition: bgp_proto.h:442
static BgpMessage * Decode(const uint8_t *data, size_t size, ParseErrorContext *ec=NULL, bool as4=false)
Definition: bgp_proto.cc:2116
static int Encode(const BgpMessage *msg, uint8_t *data, size_t size, EncodeOffsets *offsets=NULL, bool as4=false)
Definition: bgp_proto.cc:2136
mpl::list< BgpMarker, BgpMsgLength, BgpMsgTypeAs4 > Sequence
Definition: bgp_proto.cc:2113
mpl::list< BgpMarker, BgpMsgLength, BgpMsgType > Sequence
Definition: bgp_proto.cc:2108
bool enable_4byte_as() const
Definition: bgp_server.cc:735
uint32_t bgp_identifier() const
Definition: bgp_server.h:216
mpl::list< BgpUpdateWithdrawnRoutes, BgpPathAttributeAs4List, BgpUpdateNlri > Sequence
Definition: bgp_proto.cc:2069
BgpProto::Update ContextType
Definition: bgp_proto.cc:2070
mpl::list< BgpUpdateWithdrawnRoutes, BgpPathAttributeList, BgpUpdateNlri > Sequence
Definition: bgp_proto.cc:2076
BgpProto::Update ContextType
Definition: bgp_proto.cc:2077
OptMatch ContextMatch
Definition: bgp_proto.cc:2062
CollectionAccessor< BgpProto::Update, vector< BgpProtoPrefix * >, &BgpProto::Update::nlri > ContextStorer
Definition: bgp_proto.cc:2055
mpl::list< BgpPrefixLen, BgpPrefixAddress > Sequence
Definition: bgp_proto.cc:2063
mpl::list< BgpPrefixLen, BgpPrefixAddress > Sequence
Definition: bgp_proto.cc:767
CollectionAccessor< BgpProto::Update, vector< BgpProtoPrefix * >, &BgpProto::Update::withdrawn_routes > ContextStorer
Definition: bgp_proto.cc:758
EncodeOffsets & encode_offsets()
std::vector< uint64_t > communities
Definition: community.h:146
This class encapsulates the wire-format representation of a BGP Large Community attribute and provide...
Definition: community.h:509
std::vector< uint32_t > communities
Vector of community values. Each Large Community value consists of three 4-byte fields (12 bytes tota...
Definition: community.h:541
Accessor< BgpProto::Notification, string, &BgpProto::Notification::data > Setter
Definition: bgp_proto.cc:708
Accessor< BgpProto::Notification, int, &BgpProto::Notification::error > Setter
Definition: bgp_proto.cc:694
Accessor< BgpProto::Notification, int, &BgpProto::Notification::subcode > Setter
Definition: bgp_proto.cc:701
const ParseErrorContext & error_context()
void SetError(int error, int subcode, std::string type, const uint8_t *data, int data_size)
static int Encode(EncodeContext *context, const T *msg, uint8_t *data, size_t size)
static int Parse(const uint8_t *data, size_t size, ParseContext *context, T *obj)
static const size_t kSize
Definition: rd.h:14
static uint16_t get_short(const void *ptr)
#define TYPE_NAME(_type)
Definition: logging.h:33
static void put_value(uint8_t *data, int size, uint64_t value)
Definition: parse_object.h:56
static uint64_t get_value(const uint8_t *data, int size)
Definition: parse_object.h:40
static const map< MatchProtocol::MatchProtocolType, string > toString
std::vector< as_t > path_segment
Definition: bgp_aspath.h:375
std::vector< PathSegment * > path_segments
Definition: bgp_aspath.h:396
std::vector< as_t > path_segment
Definition: bgp_aspath.h:215
std::vector< PathSegment * > path_segments
Definition: bgp_aspath.h:236
std::vector< as2_t > path_segment
Definition: bgp_aspath.h:59
std::vector< PathSegment * > path_segments
Definition: bgp_aspath.h:80
uint32_t address
Definition: bgp_attr.h:163
static const uint8_t kFlags
Definition: bgp_attr.h:124
bool operator()(BgpAttribute *lhs, BgpAttribute *rhs) const
Definition: bgp_proto.cc:398
uint32_t local_pref
Definition: bgp_attr.h:116
static const int kSize
Definition: bgp_attr.h:63
static const uint8_t kFlags
Definition: bgp_attr.h:64
uint32_t nexthop
Definition: bgp_attr.h:83
static const uint8_t kFlags
Definition: bgp_attr.h:43
uint32_t originator_id
Definition: bgp_attr.h:198
std::vector< uint8_t > value
Definition: bgp_attr.h:767
static bool Verifier(const As4PathSpec::PathSegment *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:908
static bool Verifier(const AsPath4ByteSpec::PathSegment *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:899
static bool Verifier(const AsPathSpec::PathSegment *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:890
static bool Verifier(const BgpAttrNextHop *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:861
static bool Verifier(const BgpAttrOrigin *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:832
static bool Verifier(const C *obj, const uint8_t *data, size_t size, ParseContext *context)
Definition: bgp_proto.cc:808
Derived * operator()(const BgpAttribute *attr)
Definition: bgp_proto.cc:801
static int get(const BgpProtoPrefix *obj)
Definition: bgp_proto.cc:1686
static void set(BgpProtoPrefix *obj, int value)
Definition: bgp_proto.cc:1682
static void set(BgpProtoPrefix *obj, int value)
Definition: bgp_proto.cc:1730
static int get(const BgpProtoPrefix *obj)
Definition: bgp_proto.cc:1734
uint8_t safi
Definition: bgp_attr.h:309
uint16_t afi
Definition: bgp_attr.h:308
std::vector< BgpProtoPrefix * > nlri
Definition: bgp_attr.h:312
static void Callback(EncodeContext *context, uint8_t *data, int offset, int element_size)
Definition: bgp_proto.cc:560
static int get(const BgpProtoPrefix *obj)
Definition: bgp_proto.cc:1638
static void set(BgpProtoPrefix *obj, int value)
Definition: bgp_proto.cc:1634
bool match(const BgpProto::OpenMessage::OptParam *ctx)
Definition: bgp_proto.cc:650
int operator()(As4PathSpec::PathSegment *obj, const uint8_t *data, size_t size)
Definition: bgp_proto.cc:1050
static void Callback(EncodeContext *context, uint8_t *data, int offset, int element_size)
Definition: bgp_proto.cc:1057
int operator()(AsPath4ByteSpec::PathSegment *obj, const uint8_t *data, size_t size)
Definition: bgp_proto.cc:1029
static void Callback(EncodeContext *context, uint8_t *data, int offset, int element_size)
Definition: bgp_proto.cc:1036
int operator()(AsPathSpec::PathSegment *obj, const uint8_t *data, size_t size)
Definition: bgp_proto.cc:1008
static void Callback(EncodeContext *context, uint8_t *data, int offset, int element_size)
Definition: bgp_proto.cc:1015
int operator()(BgpAttribute *obj, const uint8_t *data, size_t &size)
Definition: bgp_proto.cc:774
static int get(const BgpAttribute *obj)
Definition: bgp_proto.cc:787
static void set(BgpAttribute *obj, uint8_t value)
Definition: bgp_proto.cc:1187
static uint8_t get(const BgpAttribute *obj)
Definition: bgp_proto.cc:1190
int operator()(EdgeForwardingSpec::Edge *obj, const uint8_t *data, size_t size)
Definition: bgp_proto.cc:1450
int operator()(EdgeForwardingSpec::Edge *obj, const uint8_t *data, size_t size)
Definition: bgp_proto.cc:1428
static void Callback(EncodeContext *context, uint8_t *data, int offset, int element_size)
Definition: bgp_proto.cc:1436
bool match(const BgpMpNlri *obj)
Definition: bgp_proto.cc:1704
bool match(const BgpMpNlri *obj)
Definition: bgp_proto.cc:1752
bool match(const BgpMpNlri *obj)
Definition: bgp_proto.cc:1656
static void set(BgpMpNlri *obj, int &value)
Definition: bgp_proto.cc:1769
static int get(BgpMpNlri *obj)
Definition: bgp_proto.cc:1799
bool match(const BgpMpNlri *obj)
Definition: bgp_proto.cc:1606
int operator()(BgpProtoPrefix *obj, const uint8_t *data, size_t size)
Definition: bgp_proto.cc:729
std::vector< uint8_t > prefix
virtual const std::string ToString() const
Definition: bgp_proto.cc:344
static const std::string toString(Code code, int subcode)
Definition: bgp_proto.cc:348
static Capability * Encode(uint16_t gr_time, bool restarted, bool notification, const std::vector< uint8_t > &gr_afi_flags, const std::vector< Address::Family > &gr_families)
Definition: bgp_proto.cc:130
std::vector< Family > families
Definition: bgp_proto.h:171
void set_flags(uint16_t gr_cap_bytes)
Definition: bgp_proto.h:163
void set_time(uint16_t gr_cap_bytes)
Definition: bgp_proto.h:166
static void GetFamilies(const GR &gr_params, std::vector< std::string > *families)
Definition: bgp_proto.cc:157
static bool Decode(GR *gr_params, const std::vector< Capability * > &capabilities)
Definition: bgp_proto.cc:176
static void GetFamilies(const LLGR &llgr_params, std::vector< std::string > *families)
Definition: bgp_proto.cc:261
static Capability * Encode(uint32_t llgr_time, uint8_t llgr_afi_flags, const std::vector< Address::Family > &llgr_families)
Definition: bgp_proto.cc:208
static bool Decode(LLGR *llgr_params, const std::vector< Capability * > &capabilities)
Definition: bgp_proto.cc:228
std::vector< uint8_t > capability
Definition: bgp_proto.h:211
std::vector< Capability * > capabilities
Definition: bgp_proto.h:218
int ValidateCapabilities(BgpPeer *peer) const
Definition: bgp_proto.cc:51
int Validate(BgpPeer *peer) const
Definition: bgp_proto.cc:107
virtual const std::string ToString() const
Definition: bgp_proto.cc:281
std::vector< OptParam * > opt_params
Definition: bgp_proto.h:220
std::vector< BgpAttribute * > path_attributes
Definition: bgp_proto.h:436
std::vector< BgpProtoPrefix * > withdrawn_routes
Definition: bgp_proto.h:435
std::vector< BgpProtoPrefix * > nlri
Definition: bgp_proto.h:437
int Validate(const BgpPeer *, std::string *data)
Definition: bgp_proto.cc:408
int CompareTo(const Update &rhs) const
Definition: bgp_proto.cc:491
bool match(const BgpProto::Update *ctx)
Definition: bgp_proto.cc:2058
bool match(const BgpProto::Update *ctx)
Definition: bgp_proto.cc:761
std::vector< uint32_t > cluster_list
Definition: bgp_attr.h:218
std::vector< uint32_t > communities
Definition: community.h:36
std::vector< uint8_t > address
Definition: bgp_attr.h:456
std::vector< uint32_t > labels
Definition: bgp_attr.h:457
EdgeList edge_list
Definition: bgp_attr.h:460
std::vector< uint8_t > inbound_address
Definition: bgp_attr.h:562
std::vector< uint8_t > outbound_address
Definition: bgp_attr.h:562
EdgeList edge_list
Definition: bgp_attr.h:567
std::vector< uint64_t > origin_vns
uint8_t tunnel_flags
Definition: bgp_attr.h:359
std::vector< uint8_t > identifier
Definition: bgp_attr.h:362
uint8_t tunnel_type
Definition: bgp_attr.h:360
uint32_t label
Definition: bgp_attr.h:361
#define KEY_COMPARE(x, y)
Definition: util.h:71
void STLDeleteValues(Container *container)
Definition: util.h:102