summaryrefslogtreecommitdiff
path: root/src/lib/frct_pci.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-08-22 15:42:23 +0000
committerdimitri staessens <dimitri.staessens@ugent.be>2017-08-22 15:42:23 +0000
commit49eeec30ebc8b050dd69926047c2baebebe7f550 (patch)
tree5cd831f6a777d9be5d14e8aff1a66897d8163e19 /src/lib/frct_pci.c
parentfb771c0cf876ad58c50551b90dacc0b5689dae05 (diff)
parent743c2f69744fe3f0dac11e467a92ff5e4d80280b (diff)
downloadouroboros-49eeec30ebc8b050dd69926047c2baebebe7f550.tar.gz
ouroboros-49eeec30ebc8b050dd69926047c2baebebe7f550.zip
Merged in sandervrijders/ouroboros/be-crc (pull request #561)
lib: Fix CRC check and add frct_clear
Diffstat (limited to 'src/lib/frct_pci.c')
-rw-r--r--src/lib/frct_pci.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/lib/frct_pci.c b/src/lib/frct_pci.c
index 392e11c6..5ee14829 100644
--- a/src/lib/frct_pci.c
+++ b/src/lib/frct_pci.c
@@ -24,6 +24,9 @@
#include <ouroboros/hash.h>
#include <ouroboros/errno.h>
+#define OUROBOROS_PREFIX "frct-pci"
+#include <ouroboros/logs.h>
+
#include <assert.h>
#include <string.h>
@@ -73,6 +76,7 @@ int frct_pci_des(struct shm_du_buff * sdb,
uint8_t * head;
uint8_t * tail;
uint32_t crc;
+ uint32_t crc2;
assert(sdb);
assert(pci);
@@ -89,10 +93,14 @@ int frct_pci_des(struct shm_du_buff * sdb,
if (tail == NULL)
return -EPERM;
- mem_hash(HASH_CRC32, &crc, head, tail - head);
+ mem_hash(HASH_CRC32, &crc, head,
+ tail - head - hash_len(HASH_CRC32));
+
+ memcpy(&crc2, tail - hash_len(HASH_CRC32),
+ hash_len(HASH_CRC32));
/* Corrupted SDU */
- if (crc != 0)
+ if (crc != crc2)
return -1;
shm_du_buff_tail_release(sdb, hash_len(HASH_CRC32));