Looks like we don't get FCS from the kernel, so get rid of CRC32

This commit is contained in:
Juhani Krekelä 2019-07-04 12:26:03 +03:00
parent b009bf6d37
commit 8baa39bb8d
1 changed files with 0 additions and 43 deletions

View File

@ -15,34 +15,6 @@
#include <sys/types.h>
#include <unistd.h>
uint32_t crc32_table[256];
void precompute_crc32_table(void) {
for (size_t index = 0; index < 256; index++) {
uint32_t value = index;
for (size_t i = 0; i < 8; i++) {
uint32_t low_bit = value & 1;
value = value >> 1;
if (low_bit) {
value ^= 0xEDB88320;
}
}
crc32_table[index] = value;
}
}
uint32_t crc32(unsigned char *buf, size_t len) {
uint32_t value = 0xffffffff;
for (size_t index = 0; index < len; index++) {
value = crc32_table[(value & 0xff) ^ buf[index]] ^ (value >> 8);
}
return value ^ 0xffffffff;
}
char hexify(int nybble) {
assert(0 <= nybble && nybble <= 16);
return "0123456789abcdef"[nybble];
@ -64,9 +36,6 @@ int main(int argc, char **argv) {
exit(1);
}
// Set up CRC32
precompute_crc32_table();
// Create a packet socket
errno = 0;
int packet_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
@ -104,7 +73,6 @@ int main(int argc, char **argv) {
if (frame_length == -1) {
err(1, "recv");
}
size_t frame_data_length = frame_length <= 1522 ? frame_length : 1522;
if (frame_length < 64) {
errno = 0;
@ -114,17 +82,6 @@ int main(int argc, char **argv) {
continue;
}
// Compute the CRC32 of the frame
uint32_t crc32_residue = crc32(frame, frame_data_length);
if (crc32_residue != 0xc704dd7b) {
errno = 0;
if (printf("CRC failed (%04"PRIx32")\n", crc32_residue) == -1) {
err(1, "printf");
}
continue;
}
// Extract the MACs
// 012345 012345
// dest source