Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 1 | # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 5 | import collections |
Christopher Wiley | 14796b3 | 2013-04-03 14:53:33 -0700 | [diff] [blame] | 6 | import logging |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 7 | import random |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 8 | import string |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 9 | import time |
Christopher Wiley | 14796b3 | 2013-04-03 14:53:33 -0700 | [diff] [blame] | 10 | |
Paul Stewart | c9628b3 | 2010-08-11 13:03:51 -0700 | [diff] [blame] | 11 | from autotest_lib.client.common_lib import error |
Christopher Wiley | 9adeb2a | 2014-06-19 14:36:13 -0700 | [diff] [blame] | 12 | from autotest_lib.client.common_lib import utils |
Paul Stewart | 6ddeba7 | 2013-11-18 10:08:23 -0800 | [diff] [blame] | 13 | from autotest_lib.client.common_lib.cros.network import interface |
Christopher Wiley | 594570d | 2014-03-14 16:50:15 -0700 | [diff] [blame] | 14 | from autotest_lib.client.common_lib.cros.network import netblock |
Christopher Wiley | 9adeb2a | 2014-06-19 14:36:13 -0700 | [diff] [blame] | 15 | from autotest_lib.client.common_lib.cros.network import ping_runner |
| 16 | from autotest_lib.server import hosts |
Paul Stewart | 2ee7fdf | 2011-05-19 16:29:23 -0700 | [diff] [blame] | 17 | from autotest_lib.server import site_linux_system |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 18 | from autotest_lib.server.cros import wifi_test_utils |
Christopher Wiley | 99d42c9 | 2013-07-09 16:40:16 -0700 | [diff] [blame] | 19 | from autotest_lib.server.cros.network import hostap_config |
Sam Leffler | 19bb0a7 | 2010-04-12 08:51:08 -0700 | [diff] [blame] | 20 | |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 21 | |
| 22 | StationInstance = collections.namedtuple('StationInstance', |
| 23 | ['ssid', 'interface', 'dev_type']) |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 24 | HostapdInstance = collections.namedtuple('HostapdInstance', |
| 25 | ['ssid', 'conf_file', 'log_file', |
| 26 | 'interface', 'config_dict']) |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 27 | |
Christopher Wiley | 9adeb2a | 2014-06-19 14:36:13 -0700 | [diff] [blame] | 28 | def build_router_hostname(client_hostname=None, router_hostname=None): |
| 29 | """Build a router hostname from a client hostname. |
| 30 | |
| 31 | @param client_hostname: string hostname of DUT connected to a router. |
| 32 | @param router_hostname: string hostname of router. |
| 33 | @return string hostname of connected router or None if the hostname |
| 34 | cannot be inferred from the client hostname. |
| 35 | |
| 36 | """ |
| 37 | if not router_hostname and not client_hostname: |
| 38 | raise error.TestError('Either client_hostname or router_hostname must ' |
| 39 | 'be specified to build_router_hostname.') |
| 40 | |
| 41 | if router_hostname: |
| 42 | return router_hostname |
| 43 | |
| 44 | if utils.host_is_in_lab_zone(client_hostname): |
| 45 | # Lab naming convention in: go/chromeos-lab-hostname-convention |
| 46 | return wifi_test_utils.get_router_addr_in_lab(client_hostname) |
| 47 | |
Christopher Wiley | a4754c0 | 2014-06-30 16:37:52 -0700 | [diff] [blame] | 48 | raise error.TestError('Could not infer router hostname from client ' |
Christopher Wiley | 9adeb2a | 2014-06-19 14:36:13 -0700 | [diff] [blame] | 49 | 'hostname: %s.' % client_hostname) |
| 50 | |
| 51 | |
| 52 | def build_router_proxy(test_name='', client_hostname=None, router_addr=None): |
| 53 | """Build up a LinuxRouter object. |
| 54 | |
| 55 | Verifies that the remote host responds to ping. |
| 56 | Either client_hostname or router_addr must be specified. |
| 57 | |
| 58 | @param test_name: string name of this test (e.g. 'network_WiFi_TestName'). |
| 59 | @param client_hostname: string hostname of DUT if we're in the lab. |
| 60 | @param router_addr: string DNS/IPv4 address to use for router host object. |
| 61 | |
| 62 | @return LinuxRouter or raise error.TestError on failure. |
| 63 | |
| 64 | """ |
Christopher Wiley | 297910b | 2014-07-01 13:53:19 -0700 | [diff] [blame] | 65 | router_hostname = build_router_hostname(client_hostname=client_hostname, |
| 66 | router_hostname=router_addr) |
Christopher Wiley | 9adeb2a | 2014-06-19 14:36:13 -0700 | [diff] [blame] | 67 | logging.info('Connecting to router at %s', router_hostname) |
| 68 | ping_helper = ping_runner.PingRunner() |
| 69 | if not ping_helper.simple_ping(router_hostname): |
| 70 | raise error.TestError('Router at %s is not pingable.' % |
| 71 | router_hostname) |
| 72 | |
| 73 | return LinuxRouter(hosts.create_host(router_hostname), test_name) |
| 74 | |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 75 | |
Paul Stewart | 2ee7fdf | 2011-05-19 16:29:23 -0700 | [diff] [blame] | 76 | class LinuxRouter(site_linux_system.LinuxSystem): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 77 | """Linux/mac80211-style WiFi Router support for WiFiTest class. |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 78 | |
| 79 | This class implements test methods/steps that communicate with a |
| 80 | router implemented with Linux/mac80211. The router must |
| 81 | be pre-configured to enable ssh access and have a mac80211-based |
| 82 | wireless device. We also assume hostapd 0.7.x and iw are present |
| 83 | and any necessary modules are pre-loaded. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 84 | |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 85 | """ |
| 86 | |
Christopher Wiley | 08aafb0 | 2014-04-22 17:38:21 -0700 | [diff] [blame] | 87 | KNOWN_TEST_PREFIX = 'network_WiFi_' |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 88 | POLLING_INTERVAL_SECONDS = 0.5 |
Christopher Wiley | 1defc24 | 2013-09-18 10:28:37 -0700 | [diff] [blame] | 89 | STARTUP_TIMEOUT_SECONDS = 10 |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 90 | SUFFIX_LETTERS = string.ascii_lowercase + string.digits |
Christopher Wiley | b1ade0a | 2013-09-16 13:09:55 -0700 | [diff] [blame] | 91 | SUBNET_PREFIX_OCTETS = (192, 168) |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 92 | |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 93 | HOSTAPD_CONF_FILE_PATTERN = '/tmp/hostapd-test-%s.conf' |
| 94 | HOSTAPD_LOG_FILE_PATTERN = '/tmp/hostapd-test-%s.log' |
Paul Stewart | 80bb337 | 2014-01-22 15:06:08 -0800 | [diff] [blame] | 95 | HOSTAPD_CONTROL_INTERFACE_PATTERN = '/tmp/hostapd-test-%s.ctrl' |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 96 | HOSTAPD_DRIVER_NAME = 'nl80211' |
| 97 | |
| 98 | STATION_CONF_FILE_PATTERN = '/tmp/wpa-supplicant-test-%s.conf' |
| 99 | STATION_LOG_FILE_PATTERN = '/tmp/wpa-supplicant-test-%s.log' |
| 100 | STATION_PID_FILE_PATTERN = '/tmp/wpa-supplicant-test-%s.pid' |
| 101 | |
Peter Qiu | c4beba0 | 2014-03-24 14:46:24 -0700 | [diff] [blame] | 102 | MGMT_FRAME_SENDER_LOG_FILE = '/tmp/send_management_frame-test.log' |
| 103 | |
Paul Stewart | 51b0f38 | 2013-06-12 09:03:02 -0700 | [diff] [blame] | 104 | def get_capabilities(self): |
| 105 | """@return iterable object of AP capabilities for this system.""" |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 106 | caps = set([self.CAPABILITY_IBSS]) |
Paul Stewart | 51b0f38 | 2013-06-12 09:03:02 -0700 | [diff] [blame] | 107 | try: |
| 108 | self.cmd_send_management_frame = wifi_test_utils.must_be_installed( |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 109 | self.host, '/usr/bin/send_management_frame') |
Paul Stewart | 51b0f38 | 2013-06-12 09:03:02 -0700 | [diff] [blame] | 110 | caps.add(self.CAPABILITY_SEND_MANAGEMENT_FRAME) |
| 111 | except error.TestFail: |
| 112 | pass |
| 113 | return super(LinuxRouter, self).get_capabilities().union(caps) |
| 114 | |
| 115 | |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 116 | @property |
| 117 | def router(self): |
| 118 | """Deprecated. Use self.host instead. |
| 119 | |
| 120 | @return Host object representing the remote router. |
| 121 | |
| 122 | """ |
| 123 | return self.host |
| 124 | |
| 125 | |
Christopher Wiley | aeef9b5 | 2014-03-11 12:24:11 -0700 | [diff] [blame] | 126 | @property |
| 127 | def wifi_ip(self): |
| 128 | """Simple accessor for the WiFi IP when there is only one AP. |
| 129 | |
| 130 | @return string IP of WiFi interface. |
| 131 | |
| 132 | """ |
| 133 | if len(self.local_servers) != 1: |
| 134 | raise error.TestError('Could not pick a WiFi IP to return.') |
| 135 | |
| 136 | return self.get_wifi_ip(0) |
| 137 | |
| 138 | |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 139 | def __init__(self, host, test_name): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 140 | """Build a LinuxRouter. |
| 141 | |
| 142 | @param host Host object representing the remote machine. |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 143 | @param test_name string name of this test. Used in SSID creation. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 144 | |
| 145 | """ |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 146 | super(LinuxRouter, self).__init__(host, 'router') |
Wade Guthrie | 24d1e31 | 2012-04-24 16:53:40 -0700 | [diff] [blame] | 147 | |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 148 | self.cmd_dhcpd = '/usr/sbin/dhcpd' |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 149 | self.cmd_hostapd = wifi_test_utils.must_be_installed( |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 150 | host, '/usr/sbin/hostapd') |
Christopher Wiley | 7337ff6 | 2013-10-03 17:21:46 -0700 | [diff] [blame] | 151 | self.cmd_hostapd_cli = wifi_test_utils.must_be_installed( |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 152 | host, '/usr/sbin/hostapd_cli') |
Paul Stewart | 6ddeba7 | 2013-11-18 10:08:23 -0800 | [diff] [blame] | 153 | self.cmd_wpa_supplicant = wifi_test_utils.must_be_installed( |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 154 | host, '/usr/sbin/wpa_supplicant') |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 155 | self.dhcpd_conf = '/tmp/dhcpd.%s.conf' |
| 156 | self.dhcpd_leases = '/tmp/dhcpd.leases' |
Nebojsa Sabovic | 138ff91 | 2010-04-06 15:47:42 -0700 | [diff] [blame] | 157 | |
Christopher Wiley | e5fdbdc | 2014-07-22 16:50:51 -0700 | [diff] [blame] | 158 | # Log the most recent message on the router so that we can rebuild the |
| 159 | # suffix relevant to us when debugging failures. |
| 160 | last_log_line = self.host.run('tail -1 /var/log/messages').stdout |
| 161 | # We're trying to get the timestamp from: |
| 162 | # 2014-07-23T17:29:34.961056+00:00 localhost kernel: blah blah blah |
| 163 | self._log_start_timestamp = last_log_line.strip().split(None, 2)[0] |
| 164 | logging.debug('Will only retrieve logs after %s.', |
| 165 | self._log_start_timestamp) |
| 166 | |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 167 | # hostapd configuration persists throughout the test, subsequent |
| 168 | # 'config' commands only modify it. |
Christopher Wiley | 08aafb0 | 2014-04-22 17:38:21 -0700 | [diff] [blame] | 169 | self._ssid_prefix = test_name |
| 170 | if self._ssid_prefix.startswith(self.KNOWN_TEST_PREFIX): |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 171 | # Many of our tests start with an uninteresting prefix. |
| 172 | # Remove it so we can have more unique bytes. |
Christopher Wiley | 08aafb0 | 2014-04-22 17:38:21 -0700 | [diff] [blame] | 173 | self._ssid_prefix = self._ssid_prefix[len(self.KNOWN_TEST_PREFIX):] |
| 174 | self._number_unique_ssids = 0 |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 175 | |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 176 | self._total_hostapd_instances = 0 |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 177 | self.local_servers = [] |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 178 | self.hostapd_instances = [] |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 179 | self.station_instances = [] |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 180 | self.dhcp_low = 1 |
| 181 | self.dhcp_high = 128 |
Paul Stewart | f05d7fd | 2011-04-06 16:19:37 -0700 | [diff] [blame] | 182 | |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 183 | # Kill hostapd and dhcp server if already running. |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 184 | self._kill_process_instance('hostapd', timeout_seconds=30) |
| 185 | self.stop_dhcp_server(instance=None) |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 186 | |
Nebojsa Sabovic | bc245c6 | 2010-04-28 16:58:50 -0700 | [diff] [blame] | 187 | # Place us in the US by default |
Christopher Wiley | 7bd2e08 | 2013-10-16 17:40:40 -0700 | [diff] [blame] | 188 | self.iw_runner.set_regulatory_domain('US') |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 189 | |
Peter Qiu | 2f97325 | 2014-02-20 15:30:37 -0800 | [diff] [blame] | 190 | # Reset all antennas to be active |
| 191 | self.set_default_antenna_bitmap() |
| 192 | |
Paul Stewart | f05d7fd | 2011-04-06 16:19:37 -0700 | [diff] [blame] | 193 | |
Christopher Wiley | f4bc88b | 2013-08-29 16:45:15 -0700 | [diff] [blame] | 194 | def close(self): |
| 195 | """Close global resources held by this system.""" |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 196 | self.deconfig() |
Christopher Wiley | e5fdbdc | 2014-07-22 16:50:51 -0700 | [diff] [blame] | 197 | # dnsmasq and hostapd cause interesting events to go to system logs. |
| 198 | # Retrieve only the suffix of the logs after the timestamp we stored on |
| 199 | # router creation. |
| 200 | self.host.run("sed -n -e '/%s/,$p' /var/log/messages >/tmp/router_log" % |
| 201 | self._log_start_timestamp, ignore_status=True) |
| 202 | self.host.get_file('/tmp/router_log', 'debug/router_host_messages') |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 203 | super(LinuxRouter, self).close() |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 204 | |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 205 | |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 206 | def has_local_server(self): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 207 | """@return True iff this router has local servers configured.""" |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 208 | return bool(self.local_servers) |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 209 | |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 210 | |
Peter Qiu | c89c9a2 | 2014-02-27 10:03:55 -0800 | [diff] [blame] | 211 | def start_hostapd(self, configuration): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 212 | """Start a hostapd instance described by conf. |
| 213 | |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 214 | @param configuration HostapConfig object. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 215 | |
| 216 | """ |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 217 | # Figure out the correct interface. |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 218 | interface = self.get_wlanif(configuration.frequency, 'managed') |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 219 | |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 220 | conf_file = self.HOSTAPD_CONF_FILE_PATTERN % interface |
| 221 | log_file = self.HOSTAPD_LOG_FILE_PATTERN % interface |
Paul Stewart | 80bb337 | 2014-01-22 15:06:08 -0800 | [diff] [blame] | 222 | control_interface = self.HOSTAPD_CONTROL_INTERFACE_PATTERN % interface |
Peter Qiu | c89c9a2 | 2014-02-27 10:03:55 -0800 | [diff] [blame] | 223 | hostapd_conf_dict = configuration.generate_dict( |
| 224 | interface, control_interface, |
Christopher Wiley | 08aafb0 | 2014-04-22 17:38:21 -0700 | [diff] [blame] | 225 | self._build_unique_ssid(configuration.ssid_suffix)) |
Christopher Wiley | faaecd8 | 2014-05-29 10:53:40 -0700 | [diff] [blame] | 226 | logging.debug('hostapd parameters: %r', hostapd_conf_dict) |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 227 | |
| 228 | # Generate hostapd.conf. |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 229 | self.router.run("cat <<EOF >%s\n%s\nEOF\n" % |
| 230 | (conf_file, '\n'.join( |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 231 | "%s=%s" % kv for kv in hostapd_conf_dict.iteritems()))) |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 232 | |
| 233 | # Run hostapd. |
Christopher Wiley | faaecd8 | 2014-05-29 10:53:40 -0700 | [diff] [blame] | 234 | logging.info('Starting hostapd on %s(%s) channel=%s...', |
| 235 | interface, self.iw_runner.get_interface(interface).phy, |
| 236 | configuration.channel) |
Christopher Wiley | 1defc24 | 2013-09-18 10:28:37 -0700 | [diff] [blame] | 237 | self.router.run('rm %s' % log_file, ignore_status=True) |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 238 | self.router.run('stop wpasupplicant', ignore_status=True) |
Christopher Wiley | 3c427cc | 2014-07-23 15:38:00 -0700 | [diff] [blame] | 239 | start_command = 'stdbuf -oL %s -dd -t %s &> %s & echo $!' % ( |
Christopher Wiley | 0f64b84 | 2014-04-30 15:43:50 -0700 | [diff] [blame] | 240 | self.cmd_hostapd, conf_file, log_file) |
| 241 | pid = int(self.router.run(start_command).stdout.strip()) |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 242 | self.hostapd_instances.append(HostapdInstance( |
| 243 | hostapd_conf_dict['ssid'], |
| 244 | conf_file, |
| 245 | log_file, |
| 246 | interface, |
| 247 | hostapd_conf_dict.copy())) |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 248 | |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 249 | # Wait for confirmation that the router came up. |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 250 | logging.info('Waiting for hostapd to startup.') |
| 251 | start_time = time.time() |
| 252 | while time.time() - start_time < self.STARTUP_TIMEOUT_SECONDS: |
| 253 | success = self.router.run( |
| 254 | 'grep "Completing interface initialization" %s' % log_file, |
| 255 | ignore_status=True).exit_status == 0 |
| 256 | if success: |
| 257 | break |
| 258 | |
Christopher Wiley | ebafa13 | 2014-07-15 10:18:28 -0700 | [diff] [blame] | 259 | # TODO(wiley) Remove this once we resolve crbug.com/393667 |
| 260 | self.host.run('tail -1 %s' % log_file, ignore_status=True) |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 261 | # A common failure is an invalid router configuration. |
| 262 | # Detect this and exit early if we see it. |
| 263 | bad_config = self.router.run( |
| 264 | 'grep "Interface initialization failed" %s' % log_file, |
| 265 | ignore_status=True).exit_status == 0 |
| 266 | if bad_config: |
| 267 | raise error.TestFail('hostapd failed to initialize AP ' |
| 268 | 'interface.') |
| 269 | |
| 270 | if pid: |
| 271 | early_exit = self.router.run('kill -0 %d' % pid, |
| 272 | ignore_status=True).exit_status |
| 273 | if early_exit: |
| 274 | raise error.TestFail('hostapd process terminated.') |
| 275 | |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 276 | time.sleep(self.POLLING_INTERVAL_SECONDS) |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 277 | else: |
| 278 | raise error.TestFail('Timed out while waiting for hostapd ' |
| 279 | 'to start.') |
| 280 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 281 | |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 282 | def _kill_process_instance(self, |
| 283 | process, |
| 284 | instance=None, |
| 285 | timeout_seconds=10, |
| 286 | ignore_timeouts=False): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 287 | """Kill a process on the router. |
| 288 | |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 289 | Kills remote program named |process| (optionally only a specific |
| 290 | |instance|). Wait |timeout_seconds| for |process| to die |
| 291 | before returning. If |ignore_timeouts| is False, raise |
| 292 | a TestError on timeouts. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 293 | |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 294 | @param process: string name of process to kill. |
| 295 | @param instance: string fragment of the command line unique to |
| 296 | this instance of the remote process. |
| 297 | @param timeout_seconds: float timeout in seconds to wait. |
| 298 | @param ignore_timeouts: True iff we should ignore failures to |
| 299 | kill processes. |
| 300 | @return True iff the specified process has exited. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 301 | |
Thieu Le | 7b23a54 | 2012-01-27 15:54:48 -0800 | [diff] [blame] | 302 | """ |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 303 | if instance is not None: |
Christopher Wiley | a4754c0 | 2014-06-30 16:37:52 -0700 | [diff] [blame] | 304 | search_arg = '-f "^%s.*%s"' % (process, instance) |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 305 | else: |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 306 | search_arg = process |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 307 | |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 308 | self.host.run('pkill %s' % search_arg, ignore_status=True) |
| 309 | is_dead = False |
| 310 | start_time = time.time() |
| 311 | while not is_dead and time.time() - start_time < timeout_seconds: |
| 312 | time.sleep(self.POLLING_INTERVAL_SECONDS) |
| 313 | is_dead = self.host.run( |
Christopher Wiley | a4754c0 | 2014-06-30 16:37:52 -0700 | [diff] [blame] | 314 | 'pgrep -l %s' % search_arg, |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 315 | ignore_status=True).exit_status != 0 |
| 316 | if is_dead or ignore_timeouts: |
| 317 | return is_dead |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 318 | |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 319 | raise error.TestError( |
| 320 | 'Timed out waiting for %s%s to die' % |
| 321 | (process, |
| 322 | '' if instance is None else ' (instance=%s)' % instance)) |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 323 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 324 | |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 325 | def kill_hostapd_instance(self, instance): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 326 | """Kills a hostapd instance. |
| 327 | |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 328 | @param instance HostapdInstance object. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 329 | |
| 330 | """ |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 331 | is_dead = self._kill_process_instance( |
Christopher Wiley | a4754c0 | 2014-06-30 16:37:52 -0700 | [diff] [blame] | 332 | self.cmd_hostapd, |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 333 | instance=instance.conf_file, |
| 334 | timeout_seconds=30, |
| 335 | ignore_timeouts=True) |
| 336 | if self.host.run('ls %s >/dev/null 2>&1' % instance.log_file, |
| 337 | ignore_status=True).exit_status: |
| 338 | logging.error('Did not collect hostapd log file because ' |
| 339 | 'it was missing.') |
| 340 | else: |
| 341 | self.router.get_file(instance.log_file, |
| 342 | 'debug/hostapd_router_%d_%s.log' % |
| 343 | (self._total_hostapd_instances, |
| 344 | instance.interface)) |
| 345 | self._total_hostapd_instances += 1 |
| 346 | if not is_dead: |
| 347 | raise error.TestError('Timed out killing hostapd.') |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 348 | |
Christopher Wiley | 7d414cc | 2013-04-17 17:26:32 -0700 | [diff] [blame] | 349 | |
Christopher Wiley | 08aafb0 | 2014-04-22 17:38:21 -0700 | [diff] [blame] | 350 | def _build_unique_ssid(self, suffix): |
| 351 | # Build our unique token by base-<len(self.SUFFIX_LETTERS)> encoding |
| 352 | # the number of APs we've constructed already. |
| 353 | base = len(self.SUFFIX_LETTERS) |
| 354 | number = self._number_unique_ssids |
| 355 | self._number_unique_ssids += 1 |
| 356 | unique = '' |
| 357 | while number or not unique: |
| 358 | unique = self.SUFFIX_LETTERS[number % base] + unique |
| 359 | number = number / base |
| 360 | # And salt the SSID so that tests running in adjacent cells are unlikely |
| 361 | # to pick the same SSID and we're resistent to beacons leaking out of |
| 362 | # cells. |
| 363 | salt = ''.join([random.choice(self.SUFFIX_LETTERS) for x in range(5)]) |
| 364 | return '_'.join([self._ssid_prefix, unique, salt, suffix])[-32:] |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 365 | |
| 366 | |
Christopher Wiley | 7d414cc | 2013-04-17 17:26:32 -0700 | [diff] [blame] | 367 | def hostap_configure(self, configuration, multi_interface=None): |
| 368 | """Build up a hostapd configuration file and start hostapd. |
| 369 | |
| 370 | Also setup a local server if this router supports them. |
| 371 | |
| 372 | @param configuration HosetapConfig object. |
| 373 | @param multi_interface bool True iff multiple interfaces allowed. |
| 374 | |
| 375 | """ |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 376 | if multi_interface is None and (self.hostapd_instances or |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 377 | self.station_instances): |
Christopher Wiley | 7d414cc | 2013-04-17 17:26:32 -0700 | [diff] [blame] | 378 | self.deconfig() |
Peter Qiu | c89c9a2 | 2014-02-27 10:03:55 -0800 | [diff] [blame] | 379 | self.start_hostapd(configuration) |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 380 | interface = self.hostapd_instances[-1].interface |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 381 | self.iw_runner.set_tx_power(interface, 'auto') |
| 382 | self.start_local_server(interface) |
Christopher Wiley | 7d414cc | 2013-04-17 17:26:32 -0700 | [diff] [blame] | 383 | logging.info('AP configured.') |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 384 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 385 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 386 | def ibss_configure(self, config): |
| 387 | """Configure a station based AP in IBSS mode. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 388 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 389 | Extract relevant configuration objects from |config| despite not |
| 390 | actually being a hostap managed endpoint. |
| 391 | |
| 392 | @param config HostapConfig object. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 393 | |
| 394 | """ |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 395 | if self.station_instances or self.hostapd_instances: |
Christopher Wiley | d89b528 | 2013-04-10 15:21:26 -0700 | [diff] [blame] | 396 | self.deconfig() |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 397 | interface = self.get_wlanif(config.frequency, 'ibss') |
Christopher Wiley | 08aafb0 | 2014-04-22 17:38:21 -0700 | [diff] [blame] | 398 | ssid = (config.ssid or self._build_unique_ssid(config.ssid_suffix)) |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 399 | # Connect the station |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 400 | self.router.run('%s link set %s up' % (self.cmd_ip, interface)) |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 401 | self.iw_runner.ibss_join(interface, ssid, config.frequency) |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 402 | # Always start a local server. |
| 403 | self.start_local_server(interface) |
| 404 | # Remember that this interface is up. |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 405 | self.station_instances.append( |
| 406 | StationInstance(ssid=ssid, interface=interface, |
| 407 | dev_type='ibss')) |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 408 | |
| 409 | |
Paul Stewart | 2bd823b | 2012-11-21 15:03:37 -0800 | [diff] [blame] | 410 | def local_server_address(self, index): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 411 | """Get the local server address for an interface. |
| 412 | |
| 413 | When we multiple local servers, we give them static IP addresses |
Christopher Wiley | b1ade0a | 2013-09-16 13:09:55 -0700 | [diff] [blame] | 414 | like 192.168.*.254. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 415 | |
| 416 | @param index int describing which local server this is for. |
| 417 | |
| 418 | """ |
Christopher Wiley | b1ade0a | 2013-09-16 13:09:55 -0700 | [diff] [blame] | 419 | return '%d.%d.%d.%d' % (self.SUBNET_PREFIX_OCTETS + (index, 254)) |
Paul Stewart | 2bd823b | 2012-11-21 15:03:37 -0800 | [diff] [blame] | 420 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 421 | |
Paul Stewart | 6ddeba7 | 2013-11-18 10:08:23 -0800 | [diff] [blame] | 422 | def local_peer_ip_address(self, index): |
| 423 | """Get the IP address allocated for the peer associated to the AP. |
| 424 | |
| 425 | This address is assigned to a locally associated peer device that |
| 426 | is created for the DUT to perform connectivity tests with. |
| 427 | When we have multiple local servers, we give them static IP addresses |
| 428 | like 192.168.*.253. |
| 429 | |
| 430 | @param index int describing which local server this is for. |
| 431 | |
| 432 | """ |
| 433 | return '%d.%d.%d.%d' % (self.SUBNET_PREFIX_OCTETS + (index, 253)) |
| 434 | |
| 435 | |
| 436 | def local_peer_mac_address(self): |
| 437 | """Get the MAC address of the peer interface. |
| 438 | |
| 439 | @return string MAC address of the peer interface. |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 440 | |
Paul Stewart | 6ddeba7 | 2013-11-18 10:08:23 -0800 | [diff] [blame] | 441 | """ |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 442 | iface = interface.Interface(self.station_instances[0].interface, |
| 443 | self.router) |
Paul Stewart | 6ddeba7 | 2013-11-18 10:08:23 -0800 | [diff] [blame] | 444 | return iface.mac_address |
| 445 | |
| 446 | |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 447 | def start_local_server(self, interface): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 448 | """Start a local server on an interface. |
| 449 | |
| 450 | @param interface string (e.g. wlan0) |
| 451 | |
| 452 | """ |
Christopher Wiley | 594570d | 2014-03-14 16:50:15 -0700 | [diff] [blame] | 453 | logging.info('Starting up local server...') |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 454 | |
| 455 | if len(self.local_servers) >= 256: |
| 456 | raise error.TestFail('Exhausted available local servers') |
| 457 | |
Christopher Wiley | 594570d | 2014-03-14 16:50:15 -0700 | [diff] [blame] | 458 | server_addr = netblock.Netblock.from_addr( |
| 459 | self.local_server_address(len(self.local_servers)), |
| 460 | prefix_len=24) |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 461 | |
| 462 | params = {} |
Christopher Wiley | 594570d | 2014-03-14 16:50:15 -0700 | [diff] [blame] | 463 | params['netblock'] = server_addr |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 464 | params['dhcp_range'] = ' '.join( |
Christopher Wiley | 594570d | 2014-03-14 16:50:15 -0700 | [diff] [blame] | 465 | (server_addr.get_addr_in_block(1), |
| 466 | server_addr.get_addr_in_block(128))) |
mukesh agrawal | 05c455a | 2011-10-12 13:40:27 -0700 | [diff] [blame] | 467 | params['interface'] = interface |
Christopher Wiley | 594570d | 2014-03-14 16:50:15 -0700 | [diff] [blame] | 468 | params['ip_params'] = ('%s broadcast %s dev %s' % |
| 469 | (server_addr.netblock, |
| 470 | server_addr.broadcast, |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 471 | interface)) |
| 472 | self.local_servers.append(params) |
| 473 | |
Christopher Wiley | 594570d | 2014-03-14 16:50:15 -0700 | [diff] [blame] | 474 | self.router.run('%s addr flush %s' % |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 475 | (self.cmd_ip, interface)) |
Christopher Wiley | 594570d | 2014-03-14 16:50:15 -0700 | [diff] [blame] | 476 | self.router.run('%s addr add %s' % |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 477 | (self.cmd_ip, params['ip_params'])) |
Christopher Wiley | 594570d | 2014-03-14 16:50:15 -0700 | [diff] [blame] | 478 | self.router.run('%s link set %s up' % |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 479 | (self.cmd_ip, interface)) |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 480 | self.start_dhcp_server(interface) |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 481 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 482 | |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 483 | def start_dhcp_server(self, interface): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 484 | """Start a dhcp server on an interface. |
| 485 | |
| 486 | @param interface string (e.g. wlan0) |
| 487 | |
| 488 | """ |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 489 | for server in self.local_servers: |
| 490 | if server['interface'] == interface: |
| 491 | params = server |
| 492 | break |
| 493 | else: |
| 494 | raise error.TestFail('Could not find local server ' |
| 495 | 'to match interface: %r' % interface) |
Christopher Wiley | 594570d | 2014-03-14 16:50:15 -0700 | [diff] [blame] | 496 | server_addr = params['netblock'] |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 497 | dhcpd_conf_file = self.dhcpd_conf % interface |
| 498 | dhcp_conf = '\n'.join([ |
| 499 | 'port=0', # disables DNS server |
| 500 | 'bind-interfaces', |
| 501 | 'log-dhcp', |
Christopher Wiley | 594570d | 2014-03-14 16:50:15 -0700 | [diff] [blame] | 502 | 'dhcp-range=%s' % ','.join((server_addr.get_addr_in_block(1), |
| 503 | server_addr.get_addr_in_block(128))), |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 504 | 'interface=%s' % params['interface'], |
| 505 | 'dhcp-leasefile=%s' % self.dhcpd_leases]) |
| 506 | self.router.run('cat <<EOF >%s\n%s\nEOF\n' % |
| 507 | (dhcpd_conf_file, dhcp_conf)) |
| 508 | self.router.run('dnsmasq --conf-file=%s' % dhcpd_conf_file) |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 509 | |
| 510 | |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 511 | def stop_dhcp_server(self, instance=None): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 512 | """Stop a dhcp server on the router. |
| 513 | |
| 514 | @param instance string instance to kill. |
| 515 | |
| 516 | """ |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 517 | self._kill_process_instance('dnsmasq', instance=instance) |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 518 | |
| 519 | |
Christopher Wiley | 8c5ae9a | 2013-12-04 14:57:56 -0800 | [diff] [blame] | 520 | def get_wifi_channel(self, ap_num): |
| 521 | """Return channel of BSS corresponding to |ap_num|. |
| 522 | |
| 523 | @param ap_num int which BSS to get the channel of. |
| 524 | @return int primary channel of BSS. |
| 525 | |
| 526 | """ |
| 527 | instance = self.hostapd_instances[ap_num] |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 528 | return instance.config_dict['channel'] |
Christopher Wiley | 8c5ae9a | 2013-12-04 14:57:56 -0800 | [diff] [blame] | 529 | |
| 530 | |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 531 | def get_wifi_ip(self, ap_num): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 532 | """Return IP address on the WiFi subnet of a local server on the router. |
| 533 | |
| 534 | If no local servers are configured (e.g. for an RSPro), a TestFail will |
| 535 | be raised. |
| 536 | |
| 537 | @param ap_num int which local server to get an address from. |
| 538 | |
| 539 | """ |
Christopher Wiley | 594570d | 2014-03-14 16:50:15 -0700 | [diff] [blame] | 540 | if not self.local_servers: |
| 541 | raise error.TestError('No IP address assigned') |
| 542 | |
| 543 | return self.local_servers[ap_num]['netblock'].addr |
| 544 | |
| 545 | |
| 546 | def get_wifi_ip_subnet(self, ap_num): |
| 547 | """Return subnet of WiFi AP instance. |
| 548 | |
| 549 | If no APs are configured a TestError will be raised. |
| 550 | |
| 551 | @param ap_num int which local server to get an address from. |
| 552 | |
| 553 | """ |
| 554 | if not self.local_servers: |
| 555 | raise error.TestError('No APs configured.') |
| 556 | |
| 557 | return self.local_servers[ap_num]['netblock'].subnet |
Paul Stewart | 5977da9 | 2011-06-01 19:14:08 -0700 | [diff] [blame] | 558 | |
| 559 | |
Christopher Wiley | a3effac | 2014-02-05 11:16:11 -0800 | [diff] [blame] | 560 | def get_hostapd_interface(self, ap_num): |
| 561 | """Get the name of the interface associated with a hostapd instance. |
| 562 | |
| 563 | @param ap_num: int hostapd instance number. |
| 564 | @return string interface name (e.g. 'managed0'). |
| 565 | |
| 566 | """ |
| 567 | if ap_num not in range(len(self.hostapd_instances)): |
| 568 | raise error.TestFail('Invalid instance number (%d) with %d ' |
| 569 | 'instances configured.' % |
| 570 | (ap_num, len(self.hostapd_instances))) |
| 571 | |
| 572 | instance = self.hostapd_instances[ap_num] |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 573 | return instance.interface |
Christopher Wiley | a3effac | 2014-02-05 11:16:11 -0800 | [diff] [blame] | 574 | |
| 575 | |
Paul Stewart | 17350be | 2012-12-14 13:34:54 -0800 | [diff] [blame] | 576 | def get_hostapd_mac(self, ap_num): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 577 | """Return the MAC address of an AP in the test. |
| 578 | |
| 579 | @param ap_num int index of local server to read the MAC address from. |
| 580 | @return string MAC address like 00:11:22:33:44:55. |
| 581 | |
| 582 | """ |
Paul Stewart | 2e5313a | 2014-02-14 09:12:02 -0800 | [diff] [blame] | 583 | interface_name = self.get_hostapd_interface(ap_num) |
| 584 | ap_interface = interface.Interface(interface_name, self.host) |
Christopher Wiley | 5689d36 | 2014-01-07 15:21:25 -0800 | [diff] [blame] | 585 | return ap_interface.mac_address |
Paul Stewart | 17350be | 2012-12-14 13:34:54 -0800 | [diff] [blame] | 586 | |
| 587 | |
Christopher Wiley | a3effac | 2014-02-05 11:16:11 -0800 | [diff] [blame] | 588 | def get_hostapd_phy(self, ap_num): |
| 589 | """Get name of phy for hostapd instance. |
| 590 | |
| 591 | @param ap_num int index of hostapd instance. |
| 592 | @return string phy name of phy corresponding to hostapd's |
| 593 | managed interface. |
| 594 | |
| 595 | """ |
| 596 | interface = self.iw_runner.get_interface( |
| 597 | self.get_hostapd_interface(ap_num)) |
| 598 | return interface.phy |
| 599 | |
| 600 | |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 601 | def deconfig(self): |
| 602 | """A legacy, deprecated alias for deconfig_aps.""" |
| 603 | self.deconfig_aps() |
Christopher Wiley | 4cd4b3f | 2013-11-11 17:27:28 -0800 | [diff] [blame] | 604 | |
| 605 | |
| 606 | def deconfig_aps(self, instance=None, silent=False): |
| 607 | """De-configure an AP (will also bring wlan down). |
| 608 | |
| 609 | @param instance: int or None. If instance is None, will bring down all |
| 610 | instances of hostapd. |
| 611 | @param silent: True if instances should be brought without de-authing |
| 612 | the DUT. |
| 613 | |
| 614 | """ |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 615 | if not self.hostapd_instances and not self.station_instances: |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 616 | return |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 617 | |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 618 | if self.hostapd_instances: |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 619 | local_servers = [] |
Christopher Wiley | 4cd4b3f | 2013-11-11 17:27:28 -0800 | [diff] [blame] | 620 | if instance is not None: |
| 621 | instances = [ self.hostapd_instances.pop(instance) ] |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 622 | for server in self.local_servers: |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 623 | if server['interface'] == instances[0].interface: |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 624 | local_servers = [server] |
| 625 | self.local_servers.remove(server) |
| 626 | break |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 627 | else: |
| 628 | instances = self.hostapd_instances |
| 629 | self.hostapd_instances = [] |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 630 | local_servers = self.local_servers |
| 631 | self.local_servers = [] |
Paul Stewart | 64cc429 | 2011-06-01 10:59:36 -0700 | [diff] [blame] | 632 | |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 633 | for instance in instances: |
Christopher Wiley | 4cd4b3f | 2013-11-11 17:27:28 -0800 | [diff] [blame] | 634 | if silent: |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 635 | # Deconfigure without notifying DUT. Remove the interface |
| 636 | # hostapd uses to send beacon and DEAUTH packets. |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 637 | self.remove_interface(instance.interface) |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 638 | |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 639 | self.kill_hostapd_instance(instance) |
| 640 | self.release_interface(instance.interface) |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 641 | if self.station_instances: |
Christopher Wiley | 05262d6 | 2013-04-17 17:53:59 -0700 | [diff] [blame] | 642 | local_servers = self.local_servers |
| 643 | self.local_servers = [] |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 644 | instance = self.station_instances.pop() |
| 645 | if instance.dev_type == 'ibss': |
| 646 | self.iw_runner.ibss_leave(instance.interface) |
| 647 | elif instance.dev_type == 'managed': |
Christopher Wiley | a4754c0 | 2014-06-30 16:37:52 -0700 | [diff] [blame] | 648 | self._kill_process_instance(self.cmd_wpa_supplicant, |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 649 | instance=instance.interface) |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 650 | else: |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 651 | self.iw_runner.disconnect_station(instance.interface) |
| 652 | self.router.run('%s link set %s down' % |
| 653 | (self.cmd_ip, instance.interface)) |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 654 | |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 655 | for server in local_servers: |
| 656 | self.stop_dhcp_server(server['interface']) |
| 657 | self.router.run("%s addr del %s" % |
| 658 | (self.cmd_ip, server['ip_params']), |
| 659 | ignore_status=True) |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 660 | |
Paul Stewart | 7cb1f06 | 2010-06-10 15:46:20 -0700 | [diff] [blame] | 661 | |
Christopher Wiley | 8c5ae9a | 2013-12-04 14:57:56 -0800 | [diff] [blame] | 662 | def confirm_pmksa_cache_use(self, instance=0): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 663 | """Verify that the PMKSA auth was cached on a hostapd instance. |
| 664 | |
Christopher Wiley | 8c5ae9a | 2013-12-04 14:57:56 -0800 | [diff] [blame] | 665 | @param instance int router instance number. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 666 | |
| 667 | """ |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 668 | log_file = self.hostapd_instances[instance].log_file |
Christopher Wiley | 8c5ae9a | 2013-12-04 14:57:56 -0800 | [diff] [blame] | 669 | pmksa_match = 'PMK from PMKSA cache' |
| 670 | result = self.router.run('grep -q "%s" %s' % (pmksa_match, log_file), |
| 671 | ignore_status=True) |
| 672 | if result.exit_status: |
| 673 | raise error.TestFail('PMKSA cache was not used in roaming.') |
Paul Stewart | 17350be | 2012-12-14 13:34:54 -0800 | [diff] [blame] | 674 | |
| 675 | |
Christopher Wiley | e0afecb | 2013-11-11 10:54:23 -0800 | [diff] [blame] | 676 | def get_ssid(self, instance=None): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 677 | """@return string ssid for the network stemming from this router.""" |
Christopher Wiley | e0afecb | 2013-11-11 10:54:23 -0800 | [diff] [blame] | 678 | if instance is None: |
| 679 | instance = 0 |
| 680 | if len(self.hostapd_instances) > 1: |
| 681 | raise error.TestFail('No instance of hostapd specified with ' |
| 682 | 'multiple instances present.') |
| 683 | |
Christopher Wiley | 3099be7 | 2013-11-06 16:49:02 -0800 | [diff] [blame] | 684 | if self.hostapd_instances: |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 685 | return self.hostapd_instances[instance].ssid |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 686 | |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 687 | if self.station_instances: |
| 688 | return self.station_instances[0].ssid |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 689 | |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 690 | raise error.TestFail('Requested ssid of an unconfigured AP.') |
Paul Stewart | 98022e2 | 2010-10-22 10:33:14 -0700 | [diff] [blame] | 691 | |
| 692 | |
Wade Guthrie | e4074dd | 2013-10-30 11:00:48 -0700 | [diff] [blame] | 693 | def deauth_client(self, client_mac): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 694 | """Deauthenticates a client described in params. |
| 695 | |
Wade Guthrie | e4074dd | 2013-10-30 11:00:48 -0700 | [diff] [blame] | 696 | @param client_mac string containing the mac address of the client to be |
| 697 | deauthenticated. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 698 | |
| 699 | """ |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 700 | control_if = self.hostapd_instances[-1].config_dict['ctrl_interface'] |
Paul Stewart | aa52e8c | 2011-05-24 08:46:23 -0700 | [diff] [blame] | 701 | self.router.run('%s -p%s deauthenticate %s' % |
Paul Stewart | 80bb337 | 2014-01-22 15:06:08 -0800 | [diff] [blame] | 702 | (self.cmd_hostapd_cli, control_if, client_mac)) |
Wade Guthrie | e4074dd | 2013-10-30 11:00:48 -0700 | [diff] [blame] | 703 | |
| 704 | |
Peter Qiu | c4beba0 | 2014-03-24 14:46:24 -0700 | [diff] [blame] | 705 | def send_management_frame_on_ap(self, frame_type, channel, instance=0): |
Paul Stewart | 51b0f38 | 2013-06-12 09:03:02 -0700 | [diff] [blame] | 706 | """Injects a management frame into an active hostapd session. |
| 707 | |
| 708 | @param frame_type string the type of frame to send. |
Peter Qiu | c4beba0 | 2014-03-24 14:46:24 -0700 | [diff] [blame] | 709 | @param channel int targeted channel |
Paul Stewart | 51b0f38 | 2013-06-12 09:03:02 -0700 | [diff] [blame] | 710 | @param instance int indicating which hostapd instance to inject into. |
| 711 | |
| 712 | """ |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 713 | hostap_interface = self.hostapd_instances[instance].interface |
Christopher Wiley | f671a5a | 2013-12-13 15:44:41 -0800 | [diff] [blame] | 714 | interface = self.get_wlanif(0, 'monitor', same_phy_as=hostap_interface) |
Paul Stewart | 51b0f38 | 2013-06-12 09:03:02 -0700 | [diff] [blame] | 715 | self.router.run("%s link set %s up" % (self.cmd_ip, interface)) |
Peter Qiu | c4beba0 | 2014-03-24 14:46:24 -0700 | [diff] [blame] | 716 | self.router.run('%s -i %s -t %s -c %d' % |
| 717 | (self.cmd_send_management_frame, interface, frame_type, |
| 718 | channel)) |
Christopher Wiley | f671a5a | 2013-12-13 15:44:41 -0800 | [diff] [blame] | 719 | self.release_interface(interface) |
Paul Stewart | 51b0f38 | 2013-06-12 09:03:02 -0700 | [diff] [blame] | 720 | |
| 721 | |
Peter Qiu | c4beba0 | 2014-03-24 14:46:24 -0700 | [diff] [blame] | 722 | def setup_management_frame_interface(self, channel): |
| 723 | """ |
| 724 | Setup interface for injecting management frames. |
| 725 | |
| 726 | @param channel int channel to inject the frames. |
| 727 | |
| 728 | @return string name of the interface. |
| 729 | |
| 730 | """ |
| 731 | frequency = hostap_config.HostapConfig.get_frequency_for_channel( |
| 732 | channel) |
| 733 | interface = self.get_wlanif(frequency, 'monitor') |
| 734 | self.iw_runner.set_freq(interface, frequency) |
| 735 | self.router.run('%s link set %s up' % (self.cmd_ip, interface)) |
| 736 | return interface |
| 737 | |
| 738 | |
| 739 | def send_management_frame(self, interface, frame_type, channel, |
| 740 | ssid_prefix=None, num_bss=None, |
| 741 | frame_count=None, delay=None): |
| 742 | """ |
| 743 | Injects management frames on specify channel |frequency|. |
| 744 | |
| 745 | This function will spawn off a new process to inject specified |
| 746 | management frames |frame_type| at the specified interface |interface|. |
| 747 | |
| 748 | @param interface string interface to inject frames. |
| 749 | @param frame_type string message type. |
| 750 | @param channel int targeted channel. |
| 751 | @param ssid_prefix string SSID prefix. |
| 752 | @param num_bss int number of BSS. |
| 753 | @param frame_count int number of frames to send. |
| 754 | @param delay int milliseconds delay between frames. |
| 755 | |
| 756 | @return int PID of the newly created process. |
| 757 | |
| 758 | """ |
| 759 | command = '%s -i %s -t %s -c %d' % (self.cmd_send_management_frame, |
| 760 | interface, frame_type, channel) |
| 761 | if ssid_prefix is not None: |
| 762 | command += ' -s %s' % (ssid_prefix) |
| 763 | if num_bss is not None: |
| 764 | command += ' -b %d' % (num_bss) |
| 765 | if frame_count is not None: |
| 766 | command += ' -n %d' % (frame_count) |
| 767 | if delay is not None: |
| 768 | command += ' -d %d' % (delay) |
| 769 | command += ' > %s 2>&1 & echo $!' % (self.MGMT_FRAME_SENDER_LOG_FILE) |
| 770 | pid = int(self.router.run(command).stdout) |
| 771 | return pid |
| 772 | |
| 773 | |
Paul Stewart | 2553694 | 2013-08-15 17:33:42 -0700 | [diff] [blame] | 774 | def detect_client_deauth(self, client_mac, instance=0): |
| 775 | """Detects whether hostapd has logged a deauthentication from |
| 776 | |client_mac|. |
| 777 | |
| 778 | @param client_mac string the MAC address of the client to detect. |
| 779 | @param instance int indicating which hostapd instance to query. |
| 780 | |
| 781 | """ |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 782 | interface = self.hostapd_instances[instance].interface |
Paul Stewart | 2553694 | 2013-08-15 17:33:42 -0700 | [diff] [blame] | 783 | deauth_msg = "%s: deauthentication: STA=%s" % (interface, client_mac) |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 784 | log_file = self.hostapd_instances[instance].log_file |
Paul Stewart | 2553694 | 2013-08-15 17:33:42 -0700 | [diff] [blame] | 785 | result = self.router.run("grep -qi '%s' %s" % (deauth_msg, log_file), |
| 786 | ignore_status=True) |
| 787 | return result.exit_status == 0 |
| 788 | |
| 789 | |
Paul Stewart | 4ae471e | 2013-09-04 15:42:35 -0700 | [diff] [blame] | 790 | def detect_client_coexistence_report(self, client_mac, instance=0): |
| 791 | """Detects whether hostapd has logged an action frame from |
| 792 | |client_mac| indicating information about 20/40MHz BSS coexistence. |
| 793 | |
| 794 | @param client_mac string the MAC address of the client to detect. |
| 795 | @param instance int indicating which hostapd instance to query. |
| 796 | |
| 797 | """ |
| 798 | coex_msg = ('nl80211: MLME event frame - hexdump(len=.*): ' |
| 799 | '.. .. .. .. .. .. .. .. .. .. %s ' |
| 800 | '.. .. .. .. .. .. .. .. 04 00.*48 01 ..' % |
| 801 | ' '.join(client_mac.split(':'))) |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 802 | log_file = self.hostapd_instances[instance].log_file |
Paul Stewart | 4ae471e | 2013-09-04 15:42:35 -0700 | [diff] [blame] | 803 | result = self.router.run("grep -qi '%s' %s" % (coex_msg, log_file), |
| 804 | ignore_status=True) |
| 805 | return result.exit_status == 0 |
| 806 | |
| 807 | |
Paul Stewart | 6ddeba7 | 2013-11-18 10:08:23 -0800 | [diff] [blame] | 808 | def add_connected_peer(self, instance=0): |
| 809 | """Configure a station connected to a running AP instance. |
| 810 | |
| 811 | Extract relevant configuration objects from the hostap |
| 812 | configuration for |instance| and generate a wpa_supplicant |
| 813 | instance that connects to it. This allows the DUT to interact |
| 814 | with a client entity that is also connected to the same AP. A |
| 815 | full wpa_supplicant instance is necessary here (instead of just |
| 816 | using the "iw" command to connect) since we want to enable |
| 817 | advanced features such as TDLS. |
| 818 | |
| 819 | @param instance int indicating which hostapd instance to connect to. |
| 820 | |
| 821 | """ |
| 822 | if not self.hostapd_instances: |
| 823 | raise error.TestFail('Hostapd is not configured.') |
| 824 | |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 825 | if self.station_instances: |
Paul Stewart | 6ddeba7 | 2013-11-18 10:08:23 -0800 | [diff] [blame] | 826 | raise error.TestFail('Station is already configured.') |
| 827 | |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 828 | ssid = self.get_ssid(instance) |
Christopher Wiley | d6e503c | 2014-06-23 15:53:47 -0700 | [diff] [blame] | 829 | hostap_conf = self.hostapd_instances[instance].config_dict |
Paul Stewart | 6ddeba7 | 2013-11-18 10:08:23 -0800 | [diff] [blame] | 830 | frequency = hostap_config.HostapConfig.get_frequency_for_channel( |
| 831 | hostap_conf['channel']) |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 832 | interface = self.get_wlanif(frequency, 'managed') |
Paul Stewart | 6ddeba7 | 2013-11-18 10:08:23 -0800 | [diff] [blame] | 833 | |
| 834 | # TODO(pstew): Configure other bits like PSK, 802.11n if tests |
| 835 | # require them... |
| 836 | supplicant_config = ( |
| 837 | 'network={\n' |
| 838 | ' ssid="%(ssid)s"\n' |
| 839 | ' key_mgmt=NONE\n' |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 840 | '}\n' % {'ssid': ssid} |
Paul Stewart | 6ddeba7 | 2013-11-18 10:08:23 -0800 | [diff] [blame] | 841 | ) |
| 842 | |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 843 | conf_file = self.STATION_CONF_FILE_PATTERN % interface |
| 844 | log_file = self.STATION_LOG_FILE_PATTERN % interface |
| 845 | pid_file = self.STATION_PID_FILE_PATTERN % interface |
Paul Stewart | 6ddeba7 | 2013-11-18 10:08:23 -0800 | [diff] [blame] | 846 | |
| 847 | self.router.run('cat <<EOF >%s\n%s\nEOF\n' % |
| 848 | (conf_file, supplicant_config)) |
| 849 | |
| 850 | # Connect the station. |
| 851 | self.router.run('%s link set %s up' % (self.cmd_ip, interface)) |
| 852 | start_command = ('%s -dd -t -i%s -P%s -c%s -D%s &> %s &' % |
| 853 | (self.cmd_wpa_supplicant, |
| 854 | interface, pid_file, conf_file, |
Christopher Wiley | eea1236 | 2013-12-12 17:24:29 -0800 | [diff] [blame] | 855 | self.HOSTAPD_DRIVER_NAME, log_file)) |
Paul Stewart | 6ddeba7 | 2013-11-18 10:08:23 -0800 | [diff] [blame] | 856 | self.router.run(start_command) |
| 857 | self.iw_runner.wait_for_link(interface) |
| 858 | |
| 859 | # Assign an IP address to this interface. |
| 860 | self.router.run('%s addr add %s/24 dev %s' % |
| 861 | (self.cmd_ip, self.local_peer_ip_address(instance), |
| 862 | interface)) |
| 863 | |
| 864 | # Since we now have two network interfaces connected to the same |
| 865 | # network, we need to disable the kernel's protection against |
| 866 | # incoming packets to an "unexpected" interface. |
| 867 | self.router.run('echo 2 > /proc/sys/net/ipv4/conf/%s/rp_filter' % |
| 868 | interface) |
| 869 | |
Paul Stewart | b01839b | 2013-12-06 15:49:56 -0800 | [diff] [blame] | 870 | # Similarly, we'd like to prevent the hostap interface from |
| 871 | # replying to ARP requests for the peer IP address and vice |
| 872 | # versa. |
| 873 | self.router.run('echo 1 > /proc/sys/net/ipv4/conf/%s/arp_ignore' % |
| 874 | interface) |
| 875 | self.router.run('echo 1 > /proc/sys/net/ipv4/conf/%s/arp_ignore' % |
| 876 | hostap_conf['interface']) |
| 877 | |
Christopher Wiley | 408d181 | 2014-01-13 15:27:43 -0800 | [diff] [blame] | 878 | self.station_instances.append( |
| 879 | StationInstance(ssid=ssid, interface=interface, |
| 880 | dev_type='managed')) |