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 : #include "bgp/extended-community/es_import.h" 7 : 8 : #include <algorithm> 9 : #include <string> 10 : 11 : #include "net/mac_address.h" 12 : 13 : using std::copy; 14 : using std::string; 15 : 16 2 : EsImport::EsImport(const bytes_type &data) { 17 2 : copy(data.begin(), data.end(), data_.begin()); 18 2 : } 19 : 20 2 : MacAddress EsImport::mac_address() const { 21 4 : if (data_[0] != BgpExtendedCommunityType::Evpn || 22 2 : data_[1] != BgpExtendedCommunityEvpnSubType::EsImport) 23 0 : return MacAddress(); 24 : uint8_t mac_bytes[6]; 25 2 : copy(data_.begin() + 2, data_.end(), mac_bytes); 26 2 : return MacAddress(mac_bytes); 27 : } 28 : 29 2 : string EsImport::ToString() const { 30 2 : string temp("esimport:"); 31 6 : return temp + mac_address().ToString(); 32 2 : }