forked from sony/nmos-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlldp_frame.h
41 lines (32 loc) · 1.39 KB
/
lldp_frame.h
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
#ifndef LLDP_LLDP_FRAME_H
#define LLDP_LLDP_FRAME_H
#include "lldp/lldp.h"
namespace lldp
{
namespace details
{
// LLDP EtherType
const uint16_t lldp_ether_type = 0x88CC;
struct lldp_frame
{
std::vector<uint8_t> destination_mac_address;
std::vector<uint8_t> source_mac_address;
lldp_data_unit lldpdu;
lldp_frame(std::vector<uint8_t> destination_mac_address = {}, std::vector<uint8_t> source_mac_address = {}, lldp_data_unit lldpdu = {})
: destination_mac_address(std::move(destination_mac_address))
, source_mac_address(std::move(source_mac_address))
, lldpdu(std::move(lldpdu))
{}
auto tied() const -> decltype(std::tie(destination_mac_address, source_mac_address, lldpdu)) { return std::tie(destination_mac_address, source_mac_address, lldpdu); }
friend bool operator==(const lldp_frame& lhs, const lldp_frame& rhs) { return lhs.tied() == rhs.tied(); }
friend bool operator!=(const lldp_frame& lhs, const lldp_frame& rhs) { return !(lhs == rhs); }
};
// encode an LLDP frame
// may throw
std::vector<uint8_t> make_lldp_frame(const lldp_frame& lldp_frame);
// decode an LLDP frame
// may throw
lldp_frame parse_lldp_frame(const uint8_t* data, size_t len);
}
}
#endif