LCOV - code coverage report
Current view: top level - net - esi.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 17 17 100.0 %
Date: 2026-05-18 11:54:02 Functions: 9 9 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_NET_ESI_H_
       6             : #define SRC_NET_ESI_H_
       7             : 
       8             : #include <boost/system/error_code.hpp>
       9             : #include <string>
      10             : 
      11             : #include "base/util.h"
      12             : 
      13             : class EthernetSegmentId {
      14             : public:
      15             :     static const int kSize = 10;
      16             :     static const EthernetSegmentId kZeroEsi;
      17             :     static const EthernetSegmentId kMaxEsi;
      18             : 
      19             :     enum EsiType {
      20             :         CONFIGURED = 0,
      21             :         LACP_BASED = 1,
      22             :         STP_BASED = 2,
      23             :         MAC_BASED = 3,
      24             :         IP_BASED = 4,
      25             :         AS_BASED = 5
      26             :     };
      27             : 
      28             :     EthernetSegmentId();
      29             :     EthernetSegmentId(const uint8_t *data);
      30     3876041 :     EthernetSegmentId(const EthernetSegmentId &rhs) {
      31     3876041 :         memcpy(data_, rhs.data_, kSize);
      32     3876041 :     }
      33             : 
      34             :     std::string ToString() const;
      35             :     static EthernetSegmentId FromString(const std::string &str,
      36             :         boost::system::error_code *errorp = NULL);
      37             : 
      38       38384 :     EthernetSegmentId &operator=(const EthernetSegmentId &rhs) {
      39       38384 :         memcpy(data_, rhs.data_, kSize);
      40       38384 :         return *this;
      41             :     }
      42             : 
      43        8608 :     bool IsZero() const { return CompareTo(EthernetSegmentId::kZeroEsi) == 0; }
      44        3243 :     uint8_t Type() const { return data_[0]; }
      45             : 
      46             :     int CompareTo(const EthernetSegmentId &rhs) const;
      47          56 :     bool operator==(const EthernetSegmentId &rhs) const {
      48          56 :         return CompareTo(rhs) == 0;
      49             :     }
      50          34 :     bool operator!=(const EthernetSegmentId &rhs) const {
      51          34 :         return CompareTo(rhs) != 0;
      52             :     }
      53    28682643 :     bool operator<(const EthernetSegmentId &rhs) const {
      54    28682643 :         return CompareTo(rhs) < 0;
      55             :     }
      56           2 :     bool operator>(const EthernetSegmentId &rhs) const {
      57           2 :         return CompareTo(rhs) > 0;
      58             :     }
      59             : 
      60       37224 :     const uint8_t *GetData() const { return data_; }
      61             : 
      62             : private:
      63             :     uint8_t data_[kSize];
      64             : };
      65             : 
      66             : #endif  // SRC_NET_ESI_H_

Generated by: LCOV version 1.14