28 #include <boost/endian/conversion.hpp>
32 std::tuple<const ether_header*, std::string>
33 checkFrameHeader(span<const uint8_t> packet,
const Address& localAddr,
const Address& destAddr)
35 if (packet.size() < HDR_LEN + MIN_DATA_LEN)
36 return {
nullptr,
"Received frame too short: " + std::to_string(packet.size()) +
" bytes"};
38 const ether_header* eh =
reinterpret_cast<const ether_header*
>(packet.data());
42 uint16_t ethertype = boost::endian::big_to_native(eh->ether_type);
43 if (ethertype != ETHERTYPE_NDN)
44 return {
nullptr,
"Received frame with wrong ethertype: " + std::to_string(ethertype)};
47 Address shost(eh->ether_shost);
48 if (shost == localAddr)
49 return {
nullptr,
"Received frame sent by this host"};
51 Address dhost(eh->ether_dhost);
52 if (dhost != destAddr)
53 return {
nullptr,
"Received frame addressed to another host or multicast group: " + dhost.toString()};
std::tuple< const ether_header *, std::string > checkFrameHeader(span< const uint8_t > packet, const Address &localAddr, const Address &destAddr)