Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : #ifndef SRC_BGP_TUNNEL_ENCAP_TUNNEL_ENCAP_H_ 7 : #define SRC_BGP_TUNNEL_ENCAP_TUNNEL_ENCAP_H_ 8 : 9 : #include "net/tunnel_encap_type.h" 10 : 11 : #include <boost/array.hpp> 12 : #include <boost/system/error_code.hpp> 13 : 14 : #include <string> 15 : 16 : #include "base/parse_object.h" 17 : 18 : class TunnelEncap { 19 : public: 20 : static const int kSize = 8; 21 : typedef boost::array<uint8_t, kSize> bytes_type; 22 : 23 : explicit TunnelEncap(TunnelEncapType::Encap encap); 24 : explicit TunnelEncap(std::string encap); 25 : explicit TunnelEncap(const bytes_type &data); 26 : 27 : TunnelEncapType::Encap tunnel_encap() const; 28 : 29 32242 : const bytes_type &GetExtCommunity() const { 30 32242 : return data_; 31 : } 32 : 33 33693 : const uint64_t GetExtCommunityValue() const { 34 33693 : return get_value(data_.begin(), 8); 35 : } 36 : std::string ToString(); 37 : std::string ToXmppString(); 38 : 39 : private: 40 : bytes_type data_; 41 : }; 42 : 43 : #endif // SRC_BGP_TUNNEL_ENCAP_TUNNEL_ENCAP_H_