LCOV - code coverage report
Current view: top level - bgp/extended-community - site_of_origin.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 10 10 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 SRC_BGP_EXTENDED_COMMUNITY_SITE_OF_ORIGIN_H_
       7             : #define SRC_BGP_EXTENDED_COMMUNITY_SITE_OF_ORIGIN_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             : 
      17             : class SiteOfOrigin {
      18             : public:
      19             :     static const int kSize = 8;
      20             :     static SiteOfOrigin null_soo;
      21             :     typedef boost::array<uint8_t, kSize> bytes_type;
      22             : 
      23             :     SiteOfOrigin();
      24             :     explicit SiteOfOrigin(const bytes_type &data);
      25             : 
      26       39964 :     bool IsNull() const { return operator==(SiteOfOrigin::null_soo); }
      27          24 :     uint8_t Type() const { return data_[0]; }
      28          24 :     uint8_t Subtype() const { return data_[1]; }
      29             : 
      30             :     bool operator<(const SiteOfOrigin &rhs) const {
      31             :         return data_ < rhs.data_;
      32             :     }
      33             :     bool operator>(const SiteOfOrigin &rhs) const {
      34             :         return data_ > rhs.data_;
      35             :     }
      36       39964 :     bool operator==(const SiteOfOrigin &rhs) const {
      37       39964 :         return data_ == rhs.data_;
      38             :     }
      39         192 :     bool operator!=(const SiteOfOrigin &rhs) const {
      40         192 :         return data_ != rhs.data_;
      41             :     }
      42             : 
      43         211 :     const bytes_type &GetExtCommunity() const { return data_; }
      44          48 :     const uint64_t GetExtCommunityValue() const {
      45          48 :         return get_value(data_.begin(), 8);
      46             :     }
      47             : 
      48             :     std::string ToString() const;
      49             :     static SiteOfOrigin FromString(const std::string &str,
      50             :         boost::system::error_code *error = NULL);
      51             : 
      52             : private:
      53             :     bytes_type data_;
      54             : };
      55             : 
      56             : #endif  // SRC_BGP_EXTENDED_COMMUNITY_SITE_OF_ORIGIN_H_

Generated by: LCOV version 1.14