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