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-06-11 01:56:02 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             :  */
       4             : 
       5             : #ifndef SRC_BGP_RTARGET_RTARGET_ADDRESS_H_
       6             : #define SRC_BGP_RTARGET_RTARGET_ADDRESS_H_
       7             : 
       8             : #include <boost/array.hpp>
       9             : #include <boost/system/error_code.hpp>
      10             : 
      11             : #include <set>
      12             : #include <string>
      13             : 
      14             : #include <base/address.h>
      15             : 
      16             : class RouteTarget {
      17             : public:
      18             :     static const int kSize = 8;
      19             :     static RouteTarget null_rtarget;
      20             :     typedef boost::array<uint8_t, kSize> bytes_type;
      21             :     typedef std::set<RouteTarget> List;
      22             : 
      23             :     RouteTarget();
      24             :     explicit RouteTarget(const bytes_type &data);
      25             :     RouteTarget(const Ip4Address &address, uint16_t num);
      26             : 
      27             :     std::string ToString() const;
      28             : 
      29      186944 :     bool IsNull() const { return operator==(RouteTarget::null_rtarget); }
      30          23 :     uint8_t Type() { return data_[0]; }
      31          23 :     uint8_t Subtype() { return data_[1]; }
      32             : 
      33   118997525 :     bool operator<(const RouteTarget &rhs) const {
      34   118997525 :         return data_ < rhs.data_;
      35             :     }
      36     4015147 :     bool operator>(const RouteTarget &rhs) const {
      37     4015147 :         return data_ > rhs.data_;
      38             :     }
      39     3499894 :     bool operator==(const RouteTarget &rhs) const {
      40     3499894 :         return data_ == rhs.data_;
      41             :     }
      42             : 
      43             :     static RouteTarget FromString(const std::string &str,
      44             :                                   boost::system::error_code *error = NULL);
      45             : 
      46     2587350 :     const bytes_type &GetExtCommunity() const {
      47     2587350 :         return data_;
      48             :     }
      49             : 
      50             :     const uint64_t GetExtCommunityValue() const;
      51             : 
      52             : private:
      53             :     bytes_type data_;
      54             : };
      55             : 
      56             : #endif  // SRC_BGP_RTARGET_RTARGET_ADDRESS_H_

Generated by: LCOV version 1.14