OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
site_of_origin.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_EXTENDED_COMMUNITY_SITE_OF_ORIGIN_H_
6 #define SRC_BGP_EXTENDED_COMMUNITY_SITE_OF_ORIGIN_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 
16 class SiteOfOrigin {
17 public:
18  static const int kSize = 8;
20  typedef boost::array<uint8_t, kSize> bytes_type;
21 
22  SiteOfOrigin();
23  explicit SiteOfOrigin(const bytes_type &data);
24 
25  bool IsNull() const { return operator==(SiteOfOrigin::null_soo); }
26  uint8_t Type() const { return data_[0]; }
27  uint8_t Subtype() const { return data_[1]; }
28 
29  bool operator<(const SiteOfOrigin &rhs) const {
30  return data_ < rhs.data_;
31  }
32  bool operator>(const SiteOfOrigin &rhs) const {
33  return data_ > rhs.data_;
34  }
35  bool operator==(const SiteOfOrigin &rhs) const {
36  return data_ == rhs.data_;
37  }
38  bool operator!=(const SiteOfOrigin &rhs) const {
39  return data_ != rhs.data_;
40  }
41 
42  const bytes_type &GetExtCommunity() const { return data_; }
43  const uint64_t GetExtCommunityValue() const {
44  return get_value(data_.begin(), 8);
45  }
46 
47  std::string ToString() const;
48  static SiteOfOrigin FromString(const std::string &str,
49  boost::system::error_code *error = NULL);
50 
51 private:
53 };
54 
55 #endif // SRC_BGP_EXTENDED_COMMUNITY_SITE_OF_ORIGIN_H_
bool IsNull() const
std::string ToString() const
uint8_t Subtype() const
static SiteOfOrigin FromString(const std::string &str, boost::system::error_code *error=NULL)
boost::array< uint8_t, kSize > bytes_type
static uint64_t get_value(const uint8_t *data, int size)
Definition: parse_object.h:39
uint8_t Type() const
bool operator!=(const SiteOfOrigin &rhs) const
const uint64_t GetExtCommunityValue() const
static SiteOfOrigin null_soo
bool operator<(const SiteOfOrigin &rhs) const
bool operator>(const SiteOfOrigin &rhs) const
bool operator==(const SiteOfOrigin &rhs) const
static const int kSize
bytes_type data_
const bytes_type & GetExtCommunity() const