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