28 #include <boost/endian/conversion.hpp>
33 std::tuple<const ether_header*, std::string>
34 checkFrameHeader(span<const uint8_t> packet,
const Address& localAddr,
const Address& destAddr)
36 if (packet.size() < HDR_LEN + MIN_DATA_LEN)
37 return {
nullptr,
"Received frame too short: " + to_string(packet.size()) +
" bytes"};
39 const ether_header* eh =
reinterpret_cast<const ether_header*
>(packet.data());
43 uint16_t ethertype = boost::endian::big_to_native(eh->ether_type);
44 if (ethertype != ETHERTYPE_NDN)
45 return {
nullptr,
"Received frame with wrong ethertype: " + to_string(ethertype)};
48 Address shost(eh->ether_shost);
49 if (shost == localAddr)
50 return {
nullptr,
"Received frame sent by this host"};
52 Address dhost(eh->ether_dhost);
53 if (dhost != destAddr)
54 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)
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents,...