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