server: Extend certificate enrollment status operation to use a wildcard

If the STAUT MAC address is not known (e.g., when MAC address
randomization is used), it can be difficult to get the database cleared
and status fetched during a test sequence. As a workaround, allow a
special ClientMACAddr value "any" to be used to match any entry. This
will not work if there are multiple different test sequences in
parallel, but should work with the specific case of a setup where only a
single test instance can occur at the time.

For example, this type of a sequence could be used to perform a test:

server_reset_default,Program,HS2-R2,ClientMACAddr,any
sta_osu,interface,wlan0
server_request_status,Program,HS2-R2,Device,OSUServer,ClientMACAddr,any,Status,OSU,Timeout,60

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
diff --git a/server.c b/server.c
index c89f59f..be8d4e1 100644
--- a/server.c
+++ b/server.c
@@ -245,8 +245,12 @@
 				SERVER_DB);
 		return -1;
 	}
-	sql = sqlite3_mprintf("DELETE FROM cert_enroll WHERE mac_addr=%Q",
-			      addr);
+
+	if (strcasecmp(addr, "any") == 0)
+		sql = sqlite3_mprintf("DELETE FROM cert_enroll");
+	else
+		sql = sqlite3_mprintf("DELETE FROM cert_enroll WHERE mac_addr=%Q",
+				      addr);
 	if (!sql) {
 		sqlite3_close(db);
 		return -1;
@@ -486,8 +490,11 @@
 {
 	char *sql, *last_serial = NULL;
 
-	sql = sqlite3_mprintf("SELECT serialnum FROM cert_enroll WHERE mac_addr=%Q",
-			      addr);
+	if (!addr || strcasecmp(addr, "any") == 0)
+		sql = sqlite3_mprintf("SELECT serialnum FROM cert_enroll");
+	else
+		sql = sqlite3_mprintf("SELECT serialnum FROM cert_enroll WHERE mac_addr=%Q",
+				      addr);
 	if (!sql)
 		return NULL;
 	sigma_dut_print(dut, DUT_MSG_DEBUG, "SQL: %s", sql);
@@ -938,7 +945,7 @@
 		return aaa_auth_status(dut, conn, cmd, resp, timeout);
 	}
 
-	if (osu && status && strcasecmp(status, "OSU") == 0 && addr)
+	if (osu && status && strcasecmp(status, "OSU") == 0)
 		return osu_cert_enroll_status(dut, conn, cmd, addr, timeout);
 
 	if (osu && status && strcasecmp(status, "PolicyProvisioning") == 0 &&