28 #include <arpa/inet.h> 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 if (ntohs(eh->ether_type) != ETHERTYPE_NDN)
45 return {
nullptr,
"Received frame with wrong ethertype: " + to_string(ntohs(eh->ether_type))};
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()};
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)