OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vrf_route_import.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef SRC_BGP_EXTENDED_COMMUNITY_VRF_ROUTE_IMPORT_H_
6 #define SRC_BGP_EXTENDED_COMMUNITY_VRF_ROUTE_IMPORT_H_
7 
8 #include <boost/array.hpp>
9 #include <boost/system/error_code.hpp>
10 
11 #include <string>
12 
13 #include "base/parse_object.h"
15 #include "base/address.h"
16 
18 public:
19  static const int kSize = 8;
21  typedef boost::array<uint8_t, kSize> bytes_type;
22 
24  explicit VrfRouteImport(const bytes_type &data);
25  VrfRouteImport(const uint32_t bgp_id, const uint32_t ri_index);
26 
28  uint8_t Type() const { return data_[0]; }
29  uint8_t Subtype() const { return data_[1]; }
30  Ip4Address GetIPv4Address() const;
31  uint16_t GetNumber() const;
32 
33  bool operator<(const VrfRouteImport &rhs) const {
34  return data_ < rhs.data_;
35  }
36  bool operator>(const VrfRouteImport &rhs) const {
37  return data_ > rhs.data_;
38  }
39  bool operator==(const VrfRouteImport &rhs) const {
40  return data_ == rhs.data_;
41  }
42  bool operator!=(const VrfRouteImport &rhs) const {
43  return data_ != rhs.data_;
44  }
45 
46  const bytes_type &GetExtCommunity() const { return data_; }
47  const uint64_t GetExtCommunityValue() const {
48  return get_value(data_.begin(), 8);
49  }
50 
51  std::string ToString() const;
52  static VrfRouteImport FromString(const std::string &str,
53  boost::system::error_code *error = NULL);
54 
55 private:
57 };
58 
59 #endif // SRC_BGP_EXTENDED_COMMUNITY_VRF_ROUTE_IMPORT_H_
bool operator>(const VrfRouteImport &rhs) const
static uint64_t get_value(const uint8_t *data, int size)
Definition: parse_object.h:39
static VrfRouteImport null_rt_import
bool operator!=(const VrfRouteImport &rhs) const
uint16_t GetNumber() const
bool operator==(const VrfRouteImport &rhs) const
uint8_t Type() const
std::string ToString() const
boost::array< uint8_t, kSize > bytes_type
const uint64_t GetExtCommunityValue() const
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
bool operator<(const VrfRouteImport &rhs) const
static VrfRouteImport FromString(const std::string &str, boost::system::error_code *error=NULL)
bool IsNull() const
uint8_t Subtype() const
const bytes_type & GetExtCommunity() const
bytes_type data_
static const int kSize
Ip4Address GetIPv4Address() const