From 96900cbc6ec0fa1af02458f7700301cbb1b56ca3 Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Wed, 24 Jun 2020 15:12:09 +0200
Subject: [PATCH 1/4] RNR: move crc32 generation to config load time

During config reload the short_ssid was getting flushed. Move the
generation into the config loading code.

Signed-off-by: John Crispin <john@phrozen.org>
---
 hostapd/config_file.c | 7 +++++++
 src/ap/hostapd.c      | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)

--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -13,6 +13,7 @@
 
 #include "utils/common.h"
 #include "utils/uuid.h"
+#include "utils/crc32.h"
 #include "common/ieee802_11_defs.h"
 #include "common/sae.h"
 #include "crypto/sha256.h"
@@ -2359,6 +2360,12 @@ static int hostapd_config_fill(struct ho
 		}
 		os_memcpy(bss->ssid.ssid, pos, bss->ssid.ssid_len);
 		bss->ssid.ssid_set = 1;
+
+		/*
+		 * 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).
+		 */
+		bss->ssid.short_ssid = crc32(bss->ssid.ssid, bss->ssid.ssid_len);
 	} else if (os_strcmp(buf, "ssid2") == 0) {
 		size_t slen;
 		char *str = wpa_config_parse_string(pos, &slen);
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -13,7 +13,6 @@
 
 #include "utils/common.h"
 #include "utils/eloop.h"
-#include "utils/crc32.h"
 #include "common/ieee802_11_defs.h"
 #include "common/wpa_ctrl.h"
 #include "common/hw_features_common.h"
@@ -1247,12 +1246,6 @@ static int hostapd_setup_bss(struct host
 		os_memcpy(conf->ssid.ssid, ssid, conf->ssid.ssid_len);
 	}
 
-	/*
-	 * 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);
-
 	if (!hostapd_drv_none(hapd)) {
 		wpa_printf(MSG_DEBUG, "Using interface %s with hwaddr " MACSTR
 			   " and ssid \"%s\"",
