1 #include "hmbdc/Copyright.hpp"
4 #include <net/ethernet.h>
5 #include <netinet/in.h>
6 #include <netinet/ip.h>
7 #include <netinet/udp.h>
9 namespace hmbdc {
namespace comm {
namespace eth {
12 checksum(
const void *data, uint16_t len, uint32_t sum) {
13 auto addr = (
const uint8_t *)data;
17 for (i = 0; i < (len & ~1U); i += 2) {
18 sum += (u_int16_t)ntohs(*((u_int16_t *)(addr + i)));
37 cksum_add(uint16_t sum, uint16_t a) {
41 return (res + (res < a));
46 wrapsum(uint32_t sum) {
53 } __attribute__((__packed__));
57 struct ether_header eh;
63 } __attribute__((__packed__));
67 static_assert(
sizeof(
pkt) == 58u,
"wierd that size is not 58?");
72 struct ether_header eh;
80 return reinterpret_cast<pkt&
>(*this);
83 } __attribute__((__packed__));