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-05-18 11:54: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 ctrlplane_rd_h
       6             : #define ctrlplane_rd_h
       7             : 
       8             : #include <boost/system/error_code.hpp>
       9             : #include "base/util.h"
      10             : 
      11             : class RouteDistinguisher {
      12             : public:
      13             :     static const size_t kSize = 8;
      14             :     static RouteDistinguisher kZeroRd;
      15             : 
      16             :     enum RDType {
      17             :         Type2ByteASBased = 0,
      18             :         TypeIpAddressBased = 1,
      19             :         Type4ByteASBased = 2,
      20             :     };
      21             : 
      22             :     RouteDistinguisher();
      23             : 
      24             :     explicit RouteDistinguisher(const uint8_t *data);
      25             :     RouteDistinguisher(uint32_t address, uint16_t vrf_id);
      26             :     RouteDistinguisher(uint16_t cluster_seed, uint32_t address,
      27             :                        uint16_t vrf_id);
      28             :     RouteDistinguisher(bool is_bgpaas, uint32_t asn, uint16_t vmi_index);
      29     6394323 :     RouteDistinguisher(const RouteDistinguisher &rhs) {
      30     6394323 :         memcpy(data_, rhs.data_, kSize);
      31     6394323 :     }
      32             : 
      33             :     std::string ToString() const;
      34             :     static RouteDistinguisher FromString(
      35             :         const std::string &str,
      36             :         boost::system::error_code *error = NULL);
      37             : 
      38     1702135 :     RouteDistinguisher &operator=(const RouteDistinguisher &rhs) {
      39     1702135 :         memcpy(data_, rhs.data_, kSize);
      40     1702135 :         return *this;
      41             :     }
      42             : 
      43      200979 :     bool IsZero() const { return CompareTo(RouteDistinguisher::kZeroRd) == 0; }
      44             :     uint16_t Type() const;
      45             :     uint32_t GetAddress() const;
      46             :     uint16_t GetVrfId() const;
      47             : 
      48             :     int CompareTo(const RouteDistinguisher &rhs) const;
      49       53482 :     bool operator==(const RouteDistinguisher &rhs) const {
      50       53482 :         return CompareTo(rhs) == 0;
      51             :     }
      52    35499282 :     bool operator<(const RouteDistinguisher &rhs) const {
      53    35499282 :         return CompareTo(rhs) < 0;
      54             :     }
      55        9173 :     bool operator>(const RouteDistinguisher &rhs) const {
      56        9173 :         return CompareTo(rhs) > 0;
      57             :     }
      58             : 
      59      350111 :     const uint8_t *GetData() const { return data_; }
      60             : 
      61             : private:
      62             :     uint8_t data_[kSize];
      63             : };
      64             : 
      65             : #endif

Generated by: LCOV version 1.14