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