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
6
#include "
bgp/extended-community/router_mac.h
"
7
8
#include <algorithm>
9
#include <string>
10
11
using
std::copy;
12
using
std::string;
13
14
RouterMac::RouterMac
(
const
MacAddress
&mac_addr) {
15
data_
[0] =
BgpExtendedCommunityType::Evpn
;
16
data_
[1] =
BgpExtendedCommunityEvpnSubType::RouterMac
;
17
copy(mac_addr.
GetData
(), mac_addr.
GetData
() + 6,
data_
.begin() + 2);
18
}
19
20
RouterMac::RouterMac
(
const
bytes_type
&data) {
21
copy(data.begin(), data.end(),
data_
.begin());
22
}
23
24
MacAddress
RouterMac::mac_address
()
const
{
25
uint8_t data[
RouterMac::kSize
];
26
copy(
data_
.begin(),
data_
.end(), &data[0]);
27
if
(data[0] ==
BgpExtendedCommunityType::Evpn
&&
28
data[1] ==
BgpExtendedCommunityEvpnSubType::RouterMac
) {
29
return
MacAddress
(&data[2]);
30
}
31
return
MacAddress::kZeroMac
;
32
}
33
34
string
RouterMac::ToString
() {
35
return
string(
"rtrmac:"
) +
mac_address
().
ToString
();
36
}
MacAddress
Definition:
mac_address.h:15
MacAddress::ToString
std::string ToString() const
Definition:
mac_address.cc:54
MacAddress::GetData
const uint8_t * GetData() const
Definition:
mac_address.h:144
MacAddress::kZeroMac
static const MacAddress kZeroMac
Definition:
mac_address.h:150
RouterMac::data_
bytes_type data_
Definition:
router_mac.h:36
RouterMac::kSize
static const int kSize
Definition:
router_mac.h:20
RouterMac::mac_address
MacAddress mac_address() const
Definition:
router_mac.cc:24
RouterMac::ToString
std::string ToString()
Definition:
router_mac.cc:34
RouterMac::RouterMac
RouterMac(const MacAddress &mac_addr)
Definition:
router_mac.cc:14
RouterMac::bytes_type
boost::array< uint8_t, kSize > bytes_type
Definition:
router_mac.h:21
router_mac.h
BgpExtendedCommunityEvpnSubType::RouterMac
@ RouterMac
Definition:
extended-community/types.h:45
BgpExtendedCommunityType::Evpn
@ Evpn
Definition:
extended-community/types.h:15
contrail
controller
src
bgp
extended-community
router_mac.cc
Generated by
1.9.1