[PATCH 1/1] Use a less generic name for IEEE802.11 CRC-32 routine

Sergey Matyukevich geomatsi at gmail.com
Mon Sep 5 13:18:23 PDT 2022


Hostapd uses 'crc32' name for IEEE802.11 CRC-32 routine. This name is
too generic. Buildroot autobuilder detected build configuration that
failed to build due to the naming conflict: static linking with openssl
using zlib-ng as a zlib provider, e.g. see:
- http://autobuild.buildroot.net/results/9901df820d3afa4cde78e8ad6d62cb8ce7e69fdb/
- http://autobuild.buildroot.net/results/ac19975f0bf77f4a8ca574c374092ba81cd5a332/

Use a less generic name ieee80211_crc32 for IEEE802.11 CRC-32 routine
to avoid such naming conflicts.

Signed-off-by: Sergey Matyukevich <geomatsi at gmail.com>
---
 hostapd/config_file.c   |  4 ++--
 src/ap/hostapd.c        |  2 +-
 src/ap/neighbor_db.c    |  2 +-
 src/utils/crc32.c       |  2 +-
 src/utils/crc32.h       |  2 +-
 wlantest/process.c      |  2 +-
 wlantest/test_vectors.c | 14 +++++++-------
 wlantest/tkip.c         |  4 ++--
 wlantest/wep.c          |  2 +-
 9 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index b04c65570..5715ded42 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -2365,7 +2365,7 @@ static int hostapd_config_fill(struct hostapd_config *conf,
 		}
 		os_memcpy(ssid->ssid, pos, ssid->ssid_len);
 		ssid->ssid_set = 1;
-		ssid->short_ssid = crc32(ssid->ssid, ssid->ssid_len);
+		ssid->short_ssid = ieee80211_crc32(ssid->ssid, ssid->ssid_len);
 	} else if (os_strcmp(buf, "ssid2") == 0) {
 		struct hostapd_ssid *ssid = &bss->ssid;
 		size_t slen;
@@ -2379,7 +2379,7 @@ static int hostapd_config_fill(struct hostapd_config *conf,
 		os_memcpy(ssid->ssid, str, slen);
 		ssid->ssid_len = slen;
 		ssid->ssid_set = 1;
-		ssid->short_ssid = crc32(ssid->ssid, ssid->ssid_len);
+		ssid->short_ssid = ieee80211_crc32(ssid->ssid, ssid->ssid_len);
 		os_free(str);
 	} else if (os_strcmp(buf, "utf8_ssid") == 0) {
 		bss->ssid.utf8_ssid = atoi(pos) > 0;
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 05faa0f14..99df96c69 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -1238,7 +1238,7 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
 	 * Short SSID calculation is identical to FCS and it is defined in
 	 * IEEE P802.11-REVmd/D3.0, 9.4.2.170.3 (Calculating the Short-SSID).
 	 */
-	conf->ssid.short_ssid = crc32(conf->ssid.ssid, conf->ssid.ssid_len);
+	conf->ssid.short_ssid = ieee80211_crc32(conf->ssid.ssid, conf->ssid.ssid_len);
 
 	if (!hostapd_drv_none(hapd)) {
 		wpa_printf(MSG_DEBUG, "Using interface %s with hwaddr " MACSTR
diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c
index 52f25eb7a..5b276e8da 100644
--- a/src/ap/neighbor_db.c
+++ b/src/ap/neighbor_db.c
@@ -136,7 +136,7 @@ int hostapd_neighbor_set(struct hostapd_data *hapd, const u8 *bssid,
 
 	os_memcpy(entry->bssid, bssid, ETH_ALEN);
 	os_memcpy(&entry->ssid, ssid, sizeof(entry->ssid));
-	entry->short_ssid = crc32(ssid->ssid, ssid->ssid_len);
+	entry->short_ssid = ieee80211_crc32(ssid->ssid, ssid->ssid_len);
 
 	entry->nr = wpabuf_dup(nr);
 	if (!entry->nr)
diff --git a/src/utils/crc32.c b/src/utils/crc32.c
index 12d9e2a70..371254994 100644
--- a/src/utils/crc32.c
+++ b/src/utils/crc32.c
@@ -72,7 +72,7 @@ static const u32 crc32_table[256] = {
 };
 
 
-u32 crc32(const u8 *frame, size_t frame_len)
+u32 ieee80211_crc32(const u8 *frame, size_t frame_len)
 {
 	size_t i;
 	u32 crc;
diff --git a/src/utils/crc32.h b/src/utils/crc32.h
index dc31399be..71a19dc5f 100644
--- a/src/utils/crc32.h
+++ b/src/utils/crc32.h
@@ -9,6 +9,6 @@
 #ifndef CRC32_H
 #define CRC32_H
 
-u32 crc32(const u8 *frame, size_t frame_len);
+u32 ieee80211_crc32(const u8 *frame, size_t frame_len);
 
 #endif /* CRC32_H */
diff --git a/wlantest/process.c b/wlantest/process.c
index 4d174bada..92dd0a6d8 100644
--- a/wlantest/process.c
+++ b/wlantest/process.c
@@ -264,7 +264,7 @@ static void tx_status(struct wlantest *wt, const u8 *data, size_t len, int ack)
 
 static int check_fcs(const u8 *frame, size_t frame_len, const u8 *fcs)
 {
-	if (WPA_GET_LE32(fcs) != crc32(frame, frame_len))
+	if (WPA_GET_LE32(fcs) != ieee80211_crc32(frame, frame_len))
 		return -1;
 	return 0;
 }
diff --git a/wlantest/test_vectors.c b/wlantest/test_vectors.c
index 7f39c4264..8270d31ad 100644
--- a/wlantest/test_vectors.c
+++ b/wlantest/test_vectors.c
@@ -114,7 +114,7 @@ static void test_vector_ccmp(void)
 	}
 
 	wpa_hexdump(MSG_INFO, "Encrypted MPDU (without FCS)", enc, enc_len);
-	WPA_PUT_LE32(fcs, crc32(enc, enc_len));
+	WPA_PUT_LE32(fcs, ieee80211_crc32(enc, enc_len));
 	wpa_hexdump(MSG_INFO, "FCS", fcs, sizeof(fcs));
 
 	wpa_debug_level = MSG_INFO;
@@ -243,7 +243,7 @@ static void test_vector_ccmp_pv1(void)
 	wpa_hexdump(MSG_INFO, "Encrypted Frame Header", enc, 12);
 	wpa_hexdump(MSG_INFO, "Encrypted Frame Frame Body",
 		    enc + 12, enc_len - 12);
-	WPA_PUT_LE32(fcs, crc32(enc, enc_len));
+	WPA_PUT_LE32(fcs, ieee80211_crc32(enc, enc_len));
 	wpa_hexdump(MSG_INFO, "Encrypted Frame FCS", fcs, sizeof(fcs));
 
 	wpa_printf(MSG_INFO,
@@ -293,7 +293,7 @@ static void test_vector_ccmp_pv1(void)
 	wpa_hexdump(MSG_INFO, "Encrypted Frame Header", enc, 18);
 	wpa_hexdump(MSG_INFO, "Encrypted Frame Frame Body",
 		    enc + 18, enc_len - 18);
-	WPA_PUT_LE32(fcs, crc32(enc, enc_len));
+	WPA_PUT_LE32(fcs, ieee80211_crc32(enc, enc_len));
 	wpa_hexdump(MSG_INFO, "Encrypted Frame FCS", fcs, sizeof(fcs));
 
 	wpa_printf(MSG_INFO,
@@ -337,7 +337,7 @@ static void test_vector_ccmp_pv1(void)
 	wpa_hexdump(MSG_INFO, "Encrypted Frame Header", enc, 16);
 	wpa_hexdump(MSG_INFO, "Encrypted Frame Frame Body",
 		    enc + 16, enc_len - 16);
-	WPA_PUT_LE32(fcs, crc32(enc, enc_len));
+	WPA_PUT_LE32(fcs, ieee80211_crc32(enc, enc_len));
 	wpa_hexdump(MSG_INFO, "Encrypted Frame FCS", fcs, sizeof(fcs));
 
 	wpa_debug_level = MSG_INFO;
@@ -598,7 +598,7 @@ static int run_gcmp(int idx, const struct gcmp_test *vector)
 		wpa_printf(MSG_ERROR, "GCMP test mpdu #%d MIC mismatch", idx);
 		err++;
 	}
-	WPA_PUT_LE32(fcs, crc32(enc, enc_len));
+	WPA_PUT_LE32(fcs, ieee80211_crc32(enc, enc_len));
 	wpa_hexdump(MSG_INFO, "FCS", fcs, sizeof(fcs));
 
 	wpa_debug_level = MSG_INFO;
@@ -700,7 +700,7 @@ static int test_vector_gcmp_256(void)
 		wpa_printf(MSG_ERROR, "GCMP-256 test vector mismatch");
 		err++;
 	}
-	WPA_PUT_LE32(fcs, crc32(enc, enc_len));
+	WPA_PUT_LE32(fcs, ieee80211_crc32(enc, enc_len));
 	wpa_hexdump(MSG_INFO, "FCS", fcs, sizeof(fcs));
 
 	wpa_debug_level = MSG_INFO;
@@ -778,7 +778,7 @@ static int test_vector_ccmp_256(void)
 		wpa_printf(MSG_ERROR, "CCMP-256 test vector mismatch");
 		err++;
 	}
-	WPA_PUT_LE32(fcs, crc32(enc, enc_len));
+	WPA_PUT_LE32(fcs, ieee80211_crc32(enc, enc_len));
 	wpa_hexdump(MSG_INFO, "FCS", fcs, sizeof(fcs));
 
 	wpa_debug_level = MSG_INFO;
diff --git a/wlantest/tkip.c b/wlantest/tkip.c
index 843f6518a..201561150 100644
--- a/wlantest/tkip.c
+++ b/wlantest/tkip.c
@@ -329,7 +329,7 @@ u8 * tkip_decrypt(const u8 *tk, const struct ieee80211_hdr *hdr,
 		return NULL;
 	wep_crypt(rc4key, plain, plain_len);
 
-	icv = crc32(plain, plain_len - 4);
+	icv = ieee80211_crc32(plain, plain_len - 4);
 	rx_icv = WPA_GET_LE32(plain + plain_len - 4);
 	if (icv != rx_icv) {
 		wpa_printf(MSG_INFO, "TKIP ICV mismatch in frame from " MACSTR,
@@ -482,7 +482,7 @@ u8 * tkip_encrypt(const u8 *tk, u8 *frame, size_t len, size_t hdrlen, u8 *qos,
 	os_memcpy(pos, frame + hdrlen, len - hdrlen);
 	os_memcpy(pos + len - hdrlen, mic, sizeof(mic));
 	WPA_PUT_LE32(pos + len - hdrlen + sizeof(mic),
-		     crc32(pos, len - hdrlen + sizeof(mic)));
+		     ieee80211_crc32(pos, len - hdrlen + sizeof(mic)));
 	wep_crypt(rc4key, pos, len - hdrlen + sizeof(mic) + 4);
 
 	*encrypted_len = len + 8 + sizeof(mic) + 4;
diff --git a/wlantest/wep.c b/wlantest/wep.c
index 50e371fc5..6f8f13ac3 100644
--- a/wlantest/wep.c
+++ b/wlantest/wep.c
@@ -59,7 +59,7 @@ static int try_wep(const u8 *key, size_t key_len, const u8 *data,
 
 	os_memcpy(plain, data, data_len);
 	wep_crypt(k, plain, data_len);
-	icv = crc32(plain, data_len - 4);
+	icv = ieee80211_crc32(plain, data_len - 4);
 	rx_icv = WPA_GET_LE32(plain + data_len - 4);
 	if (icv != rx_icv)
 		return -1;
-- 
2.37.1




More information about the Hostap mailing list