OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
etree.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef SRC_BGP_EXTENDED_COMMUNITY_ETREE_H_
6 #define SRC_BGP_EXTENDED_COMMUNITY_ETREE_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 ETree {
17 public:
18  static const int kSize = 8;
19  typedef boost::array<uint8_t, kSize> bytes_type;
20 
21  explicit ETree(bool leaf, int label=0);
22  explicit ETree(const bytes_type &data);
23 
24  bool leaf() const;
25  int label() const;
26 
27  const bytes_type &GetExtCommunity() const {
28  return data_;
29  }
30 
31  const uint64_t GetExtCommunityValue() const {
32  return get_value(data_.begin(), 8);
33  }
34 
35  std::string ToString();
36 
37 private:
39 };
40 
41 #endif // SRC_BGP_EXTENDED_COMMUNITY_ETREE_H_
int label() const
Definition: etree.cc:33
Definition: etree.h:16
ETree(bool leaf, int label=0)
Definition: etree.cc:16
const bytes_type & GetExtCommunity() const
Definition: etree.h:27
static uint64_t get_value(const uint8_t *data, int size)
Definition: parse_object.h:39
static const int kSize
Definition: etree.h:18
bytes_type data_
Definition: etree.h:38
bool leaf() const
Definition: etree.cc:29
boost::array< uint8_t, kSize > bytes_type
Definition: etree.h:19
const uint64_t GetExtCommunityValue() const
Definition: etree.h:31
std::string ToString()
Definition: etree.cc:44