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_EXTENDED_COMMUNITY_ESI_LABEL_H_ 7 : #define SRC_BGP_EXTENDED_COMMUNITY_ESI_LABEL_H_ 8 : 9 : #include <boost/array.hpp> 10 : #include <stdint.h> 11 : 12 : #include <string> 13 : 14 : #include "base/parse_object.h" 15 : #include "bgp/extended-community/types.h" 16 : 17 : class EsiLabel { 18 : public: 19 : static const int kSize = 8; 20 : typedef boost::array<uint8_t, kSize> bytes_type; 21 : 22 : explicit EsiLabel(const bytes_type &data); 23 : explicit EsiLabel(bool single_active); 24 : std::string ToString() const; 25 52 : bool single_active() const { return (data_[2] & 0x01); } 26 : 27 : const bytes_type &GetExtCommunity() const { 28 : return data_; 29 : } 30 46 : const uint64_t GetExtCommunityValue() const { 31 46 : return get_value(data_.begin(), 8); 32 : } 33 : 34 : private: 35 : std::string flags() const; 36 : int label() const; 37 : 38 : bytes_type data_; 39 : }; 40 : 41 : #endif // SRC_BGP_EXTENDED_COMMUNITY_ESI_LABEL_H_