Add an alternate detection technique for WiFi_Regulatory

In addition to testing for ping packet loss, also test for
reception of a DEAUTH frame at the AP.  Adherence in some
devices can only be detected by packet loss (they leave
the channel silently) so leave both detection methods in
parallel.

BUG=chrome-os-partner:20691
TEST=Run test on daisy, lumpy and a WP2 device

Change-Id: Id8610d5650c1dc0edf0c51933377bdb33f11c676
Reviewed-on: https://gerrit.chromium.org/gerrit/66015
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Commit-Queue: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/server/site_linux_router.py b/server/site_linux_router.py
index 6972425..827f2ab 100644
--- a/server/site_linux_router.py
+++ b/server/site_linux_router.py
@@ -785,6 +785,22 @@
         self._release_wlanif(interface)
 
 
+    def detect_client_deauth(self, client_mac, instance=0):
+        """Detects whether hostapd has logged a deauthentication from
+        |client_mac|.
+
+        @param client_mac string the MAC address of the client to detect.
+        @param instance int indicating which hostapd instance to query.
+
+        """
+        interface = self.hostapd_instances[instance]['interface']
+        deauth_msg = "%s: deauthentication: STA=%s" % (interface, client_mac)
+        log_file = self.hostapd_instances[instance]['log_file']
+        result = self.router.run("grep -qi '%s' %s" % (deauth_msg, log_file),
+                                 ignore_status=True)
+        return result.exit_status == 0
+
+
     def _pre_config_hook(self, config):
         """Hook for subclasses.