X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=metacube2.cpp;h=6b68132237af229745ea032d3e0411e2b5eced04;hb=4a0187ffb4075b4d217b8d9e9c96cac548b199d8;hp=1bf9efb8a1cb7bfa941c1f386ab93be5a6b06f27;hpb=ae6eccf4792e276970fa4fb985dc4588947b767b;p=nageru diff --git a/metacube2.cpp b/metacube2.cpp index 1bf9efb..6b68132 100644 --- a/metacube2.cpp +++ b/metacube2.cpp @@ -7,6 +7,9 @@ #include "metacube2.h" +#include +#include + /* * https://www.ece.cmu.edu/~koopman/pubs/KoopmanCRCWebinar9May2012.pdf * recommends this for messages as short as ours (see table at page 34). @@ -44,5 +47,14 @@ uint16_t metacube2_compute_crc(const struct metacube2_block_header *hdr) } } + /* + * Invert the checksum for metadata packets, so that clients that + * don't understand metadata will ignore it as broken. There will + * probably be logging, but apart from that, it's harmless. + */ + if (ntohs(hdr->flags) & METACUBE_FLAGS_METADATA) { + crc ^= 0xffff; + } + return crc; }