summaryrefslogtreecommitdiff
path: root/src/dgram/dgram_link.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dgram/dgram_link.c')
-rw-r--r--src/dgram/dgram_link.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/dgram/dgram_link.c b/src/dgram/dgram_link.c
index 47646d6..03c4159 100644
--- a/src/dgram/dgram_link.c
+++ b/src/dgram/dgram_link.c
@@ -36,6 +36,7 @@
#include <string.h>
#include "if_ether.h"
#include "dgram.h"
+#include "crc.h"
tx_len_t
dgram_send(struct onet_link *link, mac_addr_t dst, void *buf, uint16_t len)
@@ -80,13 +81,16 @@ dgram_send(struct onet_link *link, mac_addr_t dst, void *buf, uint16_t len)
return len;
}
+#include <stdio.h>
rx_len_t
dgram_recv(struct onet_link *link, void *buf, uint16_t len)
{
socklen_t addr_len;
struct sockaddr_ll saddr;
+ struct onet_dgram *o1p_hdr;
struct ether_hdr *hdr;
size_t dgram_len, recv_len;
+ uint32_t crc;
uint16_t proto;
mac_addr_t dest_mac;
char *p;
@@ -133,6 +137,12 @@ dgram_recv(struct onet_link *link, void *buf, uint16_t len)
continue;
}
+ o1p_hdr = DGRAM_HDR(p);
+ crc = crc32(o1p_hdr, sizeof(*o1p_hdr) - sizeof(crc));
+ if (crc != o1p_hdr->crc32) {
+ continue;
+ }
+
/* If this is for everyone, take it */
if (dest_mac == MAC_BROADCAST) {
break;