28 #include <boost/endian/conversion.hpp> 33 std::pair<const ether_header*, std::string>
35 const Address& localAddr,
const Address& destAddr)
37 if (length < HDR_LEN + MIN_DATA_LEN)
38 return {
nullptr,
"Received frame too short: " + to_string(length) +
" bytes"};
40 const ether_header* eh =
reinterpret_cast<const ether_header*
>(packet);
44 uint16_t ethertype = boost::endian::big_to_native(eh->ether_type);
45 if (ethertype != ETHERTYPE_NDN)
46 return {
nullptr,
"Received frame with wrong ethertype: " + to_string(ethertype)};
49 Address shost(eh->ether_shost);
50 if (shost == localAddr)
51 return {
nullptr,
"Received frame sent by this host"};
53 Address dhost(eh->ether_dhost);
54 if (dhost != destAddr)
55 return {
nullptr,
"Received frame addressed to another host or multicast group: " + dhost.toString()};
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
std::pair< const ether_header *, std::string > checkFrameHeader(const uint8_t *packet, size_t length, const Address &localAddr, const Address &destAddr)