OpenSDN source code
router_mac.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
7 
8 #include <algorithm>
9 #include <string>
10 
11 using std::copy;
12 using std::string;
13 
14 RouterMac::RouterMac(const MacAddress &mac_addr) {
17  copy(mac_addr.GetData(), mac_addr.GetData() + 6, data_.begin() + 2);
18 }
19 
21  copy(data.begin(), data.end(), data_.begin());
22 }
23 
25  uint8_t data[RouterMac::kSize];
26  copy(data_.begin(), data_.end(), &data[0]);
27  if (data[0] == BgpExtendedCommunityType::Evpn &&
29  return MacAddress(&data[2]);
30  }
31  return MacAddress::kZeroMac;
32 }
33 
35  return string("rtrmac:") + mac_address().ToString();
36 }
std::string ToString() const
Definition: mac_address.cc:54
const uint8_t * GetData() const
Definition: mac_address.h:144
static const MacAddress kZeroMac
Definition: mac_address.h:150
bytes_type data_
Definition: router_mac.h:36
static const int kSize
Definition: router_mac.h:20
MacAddress mac_address() const
Definition: router_mac.cc:24
std::string ToString()
Definition: router_mac.cc:34
RouterMac(const MacAddress &mac_addr)
Definition: router_mac.cc:14
boost::array< uint8_t, kSize > bytes_type
Definition: router_mac.h:21