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

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #ifndef SRC_BGP_EXTENDED_COMMUNITY_VRF_ROUTE_IMPORT_H_
       7             : #define SRC_BGP_EXTENDED_COMMUNITY_VRF_ROUTE_IMPORT_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/extended-community/types.h"
      16             : #include "base/address.h"
      17             : 
      18             : class VrfRouteImport {
      19             : public:
      20             :     static const int kSize = 8;
      21             :     static VrfRouteImport null_rt_import;
      22             :     typedef boost::array<uint8_t, kSize> bytes_type;
      23             : 
      24             :     VrfRouteImport();
      25             :     explicit VrfRouteImport(const bytes_type &data);
      26             :     VrfRouteImport(const uint32_t bgp_id, const uint32_t ri_index);
      27             : 
      28          11 :     bool IsNull() const { return operator==(VrfRouteImport::null_rt_import); }
      29           8 :     uint8_t Type() const { return data_[0]; }
      30           8 :     uint8_t Subtype() const { return data_[1]; }
      31             :     Ip4Address GetIPv4Address() const;
      32             :     uint16_t GetNumber() const;
      33             : 
      34             :     bool operator<(const VrfRouteImport &rhs) const {
      35             :         return data_ < rhs.data_;
      36             :     }
      37             :     bool operator>(const VrfRouteImport &rhs) const {
      38             :         return data_ > rhs.data_;
      39             :     }
      40          11 :     bool operator==(const VrfRouteImport &rhs) const {
      41          11 :         return data_ == rhs.data_;
      42             :     }
      43             :     bool operator!=(const VrfRouteImport &rhs) const {
      44             :         return data_ != rhs.data_;
      45             :     }
      46             : 
      47         194 :     const bytes_type &GetExtCommunity() const { return data_; }
      48             :     const uint64_t GetExtCommunityValue() const {
      49             :         return get_value(data_.begin(), 8);
      50             :     }
      51             : 
      52             :     std::string ToString() const;
      53             :     static VrfRouteImport FromString(const std::string &str,
      54             :         boost::system::error_code *error = NULL);
      55             : 
      56             : private:
      57             :     bytes_type data_;
      58             : };
      59             : 
      60             : #endif  // SRC_BGP_EXTENDED_COMMUNITY_VRF_ROUTE_IMPORT_H_

Generated by: LCOV version 1.14