LCOV - code coverage report
Current view: top level - bgp/security_group - security_group.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 6 8 75.0 %
Date: 2026-11-09 02:10:49 Functions: 3 4 75.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14