Add ping to IBSS mode tests

Determine what the router IP address is, and allow tests
to ping the router directly if in IBSS mode

BUG=n0ne
TEST=Run both "normal" MatFunc and IBSS tests.  Make sure "router"
parameter fails in non-IBSS

Change-Id: Ic177e335b69699c4220008195d87b6df459e3b6e
Reviewed-on: http://gerrit.chromium.org/gerrit/1937
Reviewed-by: 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 ce1051d..90cc857 100644
--- a/server/site_linux_router.py
+++ b/server/site_linux_router.py
@@ -34,7 +34,6 @@
         # Router host.
         self.router = host
 
-
         # hostapd configuration persists throughout the test, subsequent
         # 'config' commands only modify it.
         self.defssid = defssid
@@ -294,7 +293,9 @@
         addr = map(int, addr_str.split('.'))
         mask_bits = (-1 << (32-int(bits))) & 0xffffffff
         mask = [(mask_bits >> s) & 0xff for s in range(24, -1, -8)]
-        if idx == 'netmask':
+        if idx == 'local':
+            return addr_str
+        elif idx == 'netmask':
             return '.'.join(map(str, mask))
         elif idx == 'broadcast':
             offset = [m ^ 0xff for m in mask]
@@ -407,6 +408,13 @@
             self.station_config(params)
 
 
+    def get_wifi_ip(self):
+        if self.apmode:
+            raise error.TestFail("In AP mode, router has no IP address")
+        else:
+            self.station_local_addr('local')
+
+
     def deconfig(self, params):
         """ De-configure the AP (will also bring wlan and the bridge down) """