From e2991ee5807a1cc812615b354e0492c8a6453daf Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 2 Sep 2015 16:16:50 +0300 Subject: [PATCH] Move CRC-32 routine from wlantest to src/utils This allows the CRC-32 routine to be shared for other purposes in addition to the WEP/TKIP/FCS within wlantest. Signed-off-by: Jouni Malinen --- src/utils/Makefile | 1 + {wlantest => src/utils}/crc32.c | 1 + src/utils/crc32.h | 14 ++++++++++++++ wlantest/Makefile | 2 -- wlantest/process.c | 1 + wlantest/test_vectors.c | 1 + wlantest/tkip.c | 1 + wlantest/wep.c | 1 + wlantest/wlantest.h | 1 - 9 files changed, 20 insertions(+), 3 deletions(-) rename {wlantest => src/utils}/crc32.c (99%) create mode 100644 src/utils/crc32.h diff --git a/src/utils/Makefile b/src/utils/Makefile index 8aad813cf..52efc5321 100644 --- a/src/utils/Makefile +++ b/src/utils/Makefile @@ -17,6 +17,7 @@ LIB_OBJS= \ base64.o \ bitfield.o \ common.o \ + crc32.o \ ip_addr.o \ radiotap.o \ trace.o \ diff --git a/wlantest/crc32.c b/src/utils/crc32.c similarity index 99% rename from wlantest/crc32.c rename to src/utils/crc32.c index adbbda5b7..12d9e2a70 100644 --- a/wlantest/crc32.c +++ b/src/utils/crc32.c @@ -9,6 +9,7 @@ #include "utils/includes.h" #include "utils/common.h" +#include "utils/crc32.h" /* * IEEE 802.11 FCS CRC32 diff --git a/src/utils/crc32.h b/src/utils/crc32.h new file mode 100644 index 000000000..dc31399be --- /dev/null +++ b/src/utils/crc32.h @@ -0,0 +1,14 @@ +/* + * 32-bit CRC for FCS calculation + * Copyright (c) 2010, Jouni Malinen + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#ifndef CRC32_H +#define CRC32_H + +u32 crc32(const u8 *frame, size_t frame_len); + +#endif /* CRC32_H */ diff --git a/wlantest/Makefile b/wlantest/Makefile index 320fdbbc2..746617598 100644 --- a/wlantest/Makefile +++ b/wlantest/Makefile @@ -69,7 +69,6 @@ OBJS += rx_ip.o OBJS += rx_tdls.o OBJS += bss.o OBJS += sta.o -OBJS += crc32.o OBJS += ccmp.o OBJS += tkip.o OBJS += ctrl.o @@ -81,7 +80,6 @@ OBJS += gcmp.o LIBS += -lpcap TOBJS += test_vectors.o -TOBJS += crc32.o TOBJS += ccmp.o TOBJS += tkip.o TOBJS += wep.o diff --git a/wlantest/process.c b/wlantest/process.c index 802d0af8f..54ddf6bad 100644 --- a/wlantest/process.c +++ b/wlantest/process.c @@ -9,6 +9,7 @@ #include "utils/includes.h" #include "utils/common.h" +#include "utils/crc32.h" #include "utils/radiotap.h" #include "utils/radiotap_iter.h" #include "common/ieee802_11_defs.h" diff --git a/wlantest/test_vectors.c b/wlantest/test_vectors.c index b15e5b399..ab9c0a39d 100644 --- a/wlantest/test_vectors.c +++ b/wlantest/test_vectors.c @@ -9,6 +9,7 @@ #include "utils/includes.h" #include "utils/common.h" +#include "utils/crc32.h" #include "utils/eloop.h" #include "common/ieee802_11_defs.h" #include "wlantest.h" diff --git a/wlantest/tkip.c b/wlantest/tkip.c index ed3d60146..63366d5e2 100644 --- a/wlantest/tkip.c +++ b/wlantest/tkip.c @@ -9,6 +9,7 @@ #include "utils/includes.h" #include "utils/common.h" +#include "utils/crc32.h" #include "common/ieee802_11_defs.h" #include "wlantest.h" diff --git a/wlantest/wep.c b/wlantest/wep.c index c4137f345..50e371fc5 100644 --- a/wlantest/wep.c +++ b/wlantest/wep.c @@ -9,6 +9,7 @@ #include "utils/includes.h" #include "utils/common.h" +#include "utils/crc32.h" #include "common/ieee802_11_defs.h" #include "wlantest.h" diff --git a/wlantest/wlantest.h b/wlantest/wlantest.h index 1ff579ffa..0de04c692 100644 --- a/wlantest/wlantest.h +++ b/wlantest/wlantest.h @@ -237,7 +237,6 @@ void wlantest_process(struct wlantest *wt, const u8 *data, size_t len); void wlantest_process_prism(struct wlantest *wt, const u8 *data, size_t len); void wlantest_process_80211(struct wlantest *wt, const u8 *data, size_t len); void wlantest_process_wired(struct wlantest *wt, const u8 *data, size_t len); -u32 crc32(const u8 *frame, size_t frame_len); int monitor_init(struct wlantest *wt, const char *ifname); int monitor_init_wired(struct wlantest *wt, const char *ifname); void monitor_deinit(struct wlantest *wt);