diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ipcpd/normal/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/ipcpd/normal/crc32.h | 29 | ||||
-rw-r--r-- | src/ipcpd/normal/shm_pci.c | 2 | ||||
-rw-r--r-- | src/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/lib/crc32.c (renamed from src/ipcpd/normal/crc32.c) | 30 |
5 files changed, 18 insertions, 45 deletions
diff --git a/src/ipcpd/normal/CMakeLists.txt b/src/ipcpd/normal/CMakeLists.txt index 157baa9e..bae2f69a 100644 --- a/src/ipcpd/normal/CMakeLists.txt +++ b/src/ipcpd/normal/CMakeLists.txt @@ -25,7 +25,6 @@ protobuf_generate_c(RO_SRCS RO_HDRS ro.proto) set(SOURCE_FILES # Add source files here addr_auth.c - crc32.c dir.c fmgr.c frct.c diff --git a/src/ipcpd/normal/crc32.h b/src/ipcpd/normal/crc32.h deleted file mode 100644 index 8580e553..00000000 --- a/src/ipcpd/normal/crc32.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * 32-bit Cyclic Redundancy Check - * - * Sander Vrijders <[email protected]> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef OUROBOROS_IPCPD_NORMAL_CRC32_H -#define OUROBOROS_IPCPD_NORMAL_CRC32_H - -#include <stdint.h> - -void crc32(uint32_t * crc, const uint8_t * buf, size_t len); - -#endif /* OUROBOROS_IPCPD_NORMAL_CRC32_H */ diff --git a/src/ipcpd/normal/shm_pci.c b/src/ipcpd/normal/shm_pci.c index c648618a..4d66bf06 100644 --- a/src/ipcpd/normal/shm_pci.c +++ b/src/ipcpd/normal/shm_pci.c @@ -24,13 +24,13 @@ #include <ouroboros/logs.h> #include <ouroboros/errno.h> +#include <ouroboros/crc32.h> #include <stdlib.h> #include <string.h> #include "shm_pci.h" #include "frct.h" -#include "crc32.h" #include "ribmgr.h" #define PDU_TYPE_SIZE 1 diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 688cf6f5..44e34139 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -31,6 +31,7 @@ set(SOURCE_FILES cacep.c cdap.c cdap_req.c + crc32.c dev.c hashtable.c irm.c diff --git a/src/ipcpd/normal/crc32.c b/src/lib/crc32.c index 98c91fb8..8cafe5b5 100644 --- a/src/ipcpd/normal/crc32.c +++ b/src/lib/crc32.c @@ -5,23 +5,22 @@ * * Sander Vrijders <[email protected]> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA */ -#include <stddef.h> - -#include "crc32.h" +#include <ouroboros/crc32.h> static const uint32_t crc32_table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, @@ -69,14 +68,17 @@ static const uint32_t crc32_table[256] = { 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; -void crc32(uint32_t * crc, const uint8_t * buf, size_t len) +void crc32(uint32_t * crc, + const void * buf, + size_t len) { size_t n; *crc = *crc ^ 0xffffffff; for (n = 0; n < len; n++) - *crc = crc32_table[(*crc ^ buf[n]) & 0xff] ^ (*crc >> 8); + *crc = crc32_table[(*crc ^ ((uint8_t *) buf)[n]) & 0xff] + ^ (*crc >> 8); *crc = *crc ^ 0xffffffff; } |