Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef SRC_BGP_EXTENDED_COMMUNITY_ESI_LABEL_H_ 6 : #define SRC_BGP_EXTENDED_COMMUNITY_ESI_LABEL_H_ 7 : 8 : #include <boost/array.hpp> 9 : #include <stdint.h> 10 : 11 : #include <string> 12 : 13 : #include "base/parse_object.h" 14 : #include "bgp/extended-community/types.h" 15 : 16 : class EsiLabel { 17 : public: 18 : static const int kSize = 8; 19 : typedef boost::array<uint8_t, kSize> bytes_type; 20 : 21 : explicit EsiLabel(const bytes_type &data); 22 : explicit EsiLabel(bool single_active); 23 : std::string ToString() const; 24 63 : bool single_active() const { return (data_[2] & 0x01); } 25 : 26 : const bytes_type &GetExtCommunity() const { 27 : return data_; 28 : } 29 46 : const uint64_t GetExtCommunityValue() const { 30 46 : return get_value(data_.begin(), 8); 31 : } 32 : 33 : private: 34 : std::string flags() const; 35 : int label() const; 36 : 37 : bytes_type data_; 38 : }; 39 : 40 : #endif // SRC_BGP_EXTENDED_COMMUNITY_ESI_LABEL_H_