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