forked from aristanetworks/EosSdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eth_types.cpp
59 lines (40 loc) · 1.09 KB
/
eth_types.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2014 Arista Networks, Inc. All rights reserved.
// Arista Networks, Inc. Confidential and Proprietary.
#include "eos/eth.h"
#include <assert.h>
#include <string.h>
namespace eos {
eth_addr_t::eth_addr_t(char const * addr) :
bytes_{} {
// TODO: No op impl.
}
eth_addr_t::eth_addr_t(std::string const & addr) :
bytes_{} {
// TODO: No op impl.
}
bool
eth_addr_t::operator<(eth_addr_t other) const {
return memcmp(bytes_, other.bytes_, 6) < 0;
}
uint8_t
eth_addr_t::byte(int index) const {
if (0 <= index && index <= 5) {
return bytes_[index];
}
assert(!"invalid byte index, must be in [0; 5].");
}
void
eth_addr_t::bytes(void * arr) const {
memcpy(arr, bytes_, sizeof(bytes_));
}
static inline std::string
internal_vlan_error_msg(vlan_id_t vlan) {
std::stringstream str;
str << "VLAN " << vlan << "is an internal VLAN and cannot be used on"
" a trunk port";
return str.str();
}
internal_vlan_error::internal_vlan_error(vlan_id_t vlan) noexcept :
configuration_error(internal_vlan_error_msg(vlan)), vlan_(vlan) {
}
}