Line data Source code
1 : /* 2 : * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef SRC_BGP_EXTENDED_COMMUNITY_TAG_H_ 6 : #define SRC_BGP_EXTENDED_COMMUNITY_TAG_H_ 7 : 8 : #include <boost/array.hpp> 9 : #include <stdint.h> 10 : #include <string> 11 : 12 : #include "base/parse_object.h" 13 : #include "bgp/bgp_common.h" 14 : 15 : class Tag { 16 : public: 17 : static const int kSize = 8; 18 : static const int kMinGlobalId = 8000000; 19 : typedef boost::array<uint8_t, kSize> bytes_type; 20 : 21 : explicit Tag(const bytes_type &data); 22 : explicit Tag(as2_t asn, int tag); 23 : std::string ToString() const; 24 : 25 : bool IsGlobal() const; 26 : as2_t as_number() const; 27 : int tag() const; 28 : 29 8 : const uint64_t GetExtCommunityValue() const { 30 8 : return get_value(data_.begin(), 8); 31 : } 32 : 33 : private: 34 : bytes_type data_; 35 : }; 36 : 37 : class Tag4ByteAs { 38 : public: 39 : static const int kSize = 8; 40 : static const int kMinGlobalId = 8000000; 41 : typedef boost::array<uint8_t, kSize> bytes_type; 42 : 43 : explicit Tag4ByteAs(const bytes_type &data); 44 : explicit Tag4ByteAs(as_t asn, int tag); 45 : std::string ToString() const; 46 : 47 : bool IsGlobal() const; 48 : as_t as_number() const; 49 : int tag() const; 50 : 51 0 : const uint64_t GetExtCommunityValue() const { 52 0 : return get_value(data_.begin(), 8); 53 : } 54 : 55 : private: 56 : bytes_type data_; 57 : }; 58 : 59 : #endif // SRC_BGP_EXTENDED_COMMUNITY_TAG_H_