LCOV - code coverage report
Current view: top level - net - rd.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 14 14 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 ctrlplane_rd_h
       7             : #define ctrlplane_rd_h
       8             : 
       9             : #include <boost/system/error_code.hpp>
      10             : #include "base/util.h"
      11             : 
      12             : class RouteDistinguisher {
      13             : public:
      14             :     static const size_t kSize = 8;
      15             :     static RouteDistinguisher kZeroRd;
      16             : 
      17             :     enum RDType {
      18             :         Type2ByteASBased = 0,
      19             :         TypeIpAddressBased = 1,
      20             :         Type4ByteASBased = 2,
      21             :     };
      22             : 
      23             :     RouteDistinguisher();
      24             : 
      25             :     explicit RouteDistinguisher(const uint8_t *data);
      26             :     RouteDistinguisher(uint32_t address, uint16_t vrf_id);
      27             :     RouteDistinguisher(uint16_t cluster_seed, uint32_t address,
      28             :                        uint16_t vrf_id);
      29             :     RouteDistinguisher(bool is_bgpaas, uint32_t asn, uint16_t vmi_index);
      30     6417699 :     RouteDistinguisher(const RouteDistinguisher &rhs) {
      31     6417699 :         memcpy(data_, rhs.data_, kSize);
      32     6417699 :     }
      33             : 
      34             :     std::string ToString() const;
      35             :     static RouteDistinguisher FromString(
      36             :         const std::string &str,
      37             :         boost::system::error_code *error = NULL);
      38             : 
      39     1722664 :     RouteDistinguisher &operator=(const RouteDistinguisher &rhs) {
      40     1722664 :         memcpy(data_, rhs.data_, kSize);
      41     1722664 :         return *this;
      42             :     }
      43             : 
      44      200620 :     bool IsZero() const { return CompareTo(RouteDistinguisher::kZeroRd) == 0; }
      45             :     uint16_t Type() const;
      46             :     uint32_t GetAddress() const;
      47             :     uint16_t GetVrfId() const;
      48             : 
      49             :     int CompareTo(const RouteDistinguisher &rhs) const;
      50       53708 :     bool operator==(const RouteDistinguisher &rhs) const {
      51       53708 :         return CompareTo(rhs) == 0;
      52             :     }
      53    35873089 :     bool operator<(const RouteDistinguisher &rhs) const {
      54    35873089 :         return CompareTo(rhs) < 0;
      55             :     }
      56        9200 :     bool operator>(const RouteDistinguisher &rhs) const {
      57        9200 :         return CompareTo(rhs) > 0;
      58             :     }
      59             : 
      60      356217 :     const uint8_t *GetData() const { return data_; }
      61             : 
      62             : private:
      63             :     uint8_t data_[kSize];
      64             : };
      65             : 
      66             : #endif

Generated by: LCOV version 1.14