LCOV - code coverage report
Current view: top level - bgp/extended-community - es_import.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 12 13 92.3 %
Date: 2026-06-11 01:56:02 Functions: 3 3 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             : #include "bgp/extended-community/es_import.h"
       6             : 
       7             : #include <algorithm>
       8             : #include <string>
       9             : 
      10             : #include "net/mac_address.h"
      11             : 
      12             : using std::copy;
      13             : using std::string;
      14             : 
      15           2 : EsImport::EsImport(const bytes_type &data) {
      16           2 :     copy(data.begin(), data.end(), data_.begin());
      17           2 : }
      18             : 
      19           2 : MacAddress EsImport::mac_address() const {
      20           4 :     if (data_[0] != BgpExtendedCommunityType::Evpn ||
      21           2 :         data_[1] != BgpExtendedCommunityEvpnSubType::EsImport)
      22           0 :         return MacAddress();
      23             :     uint8_t mac_bytes[6];
      24           2 :     copy(data_.begin() + 2, data_.end(), mac_bytes);
      25           2 :     return MacAddress(mac_bytes);
      26             : }
      27             : 
      28           2 : string EsImport::ToString() const {
      29           2 :     string temp("esimport:");
      30           6 :     return temp + mac_address().ToString();
      31           2 : }

Generated by: LCOV version 1.14