LCOV - code coverage report
Current view: top level - bgp/rtarget - rtarget_address.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 11 11 100.0 %
Date: 2026-11-09 02:10:49 Functions: 7 7 100.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_RTARGET_RTARGET_ADDRESS_H_
       7             : #define SRC_BGP_RTARGET_RTARGET_ADDRESS_H_
       8             : 
       9             : #include <boost/array.hpp>
      10             : #include <boost/system/error_code.hpp>
      11             : 
      12             : #include <set>
      13             : #include <string>
      14             : 
      15             : #include <base/address.h>
      16             : 
      17             : class RouteTarget {
      18             : public:
      19             :     static const int kSize = 8;
      20             :     static RouteTarget null_rtarget;
      21             :     typedef boost::array<uint8_t, kSize> bytes_type;
      22             :     typedef std::set<RouteTarget> List;
      23             : 
      24             :     RouteTarget();
      25             :     explicit RouteTarget(const bytes_type &data);
      26             :     RouteTarget(const Ip4Address &address, uint16_t num);
      27             : 
      28             :     std::string ToString() const;
      29             : 
      30      186945 :     bool IsNull() const { return operator==(RouteTarget::null_rtarget); }
      31          23 :     uint8_t Type() { return data_[0]; }
      32          23 :     uint8_t Subtype() { return data_[1]; }
      33             : 
      34   120552287 :     bool operator<(const RouteTarget &rhs) const {
      35   120552287 :         return data_ < rhs.data_;
      36             :     }
      37     4164714 :     bool operator>(const RouteTarget &rhs) const {
      38     4164714 :         return data_ > rhs.data_;
      39             :     }
      40     3599358 :     bool operator==(const RouteTarget &rhs) const {
      41     3599358 :         return data_ == rhs.data_;
      42             :     }
      43             : 
      44             :     static RouteTarget FromString(const std::string &str,
      45             :                                   boost::system::error_code *error = NULL);
      46             : 
      47     2587516 :     const bytes_type &GetExtCommunity() const {
      48     2587516 :         return data_;
      49             :     }
      50             : 
      51             :     const uint64_t GetExtCommunityValue() const;
      52             : 
      53             : private:
      54             :     bytes_type data_;
      55             : };
      56             : 
      57             : #endif  // SRC_BGP_RTARGET_RTARGET_ADDRESS_H_

Generated by: LCOV version 1.14