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