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 | 14796b3 | 2013-04-03 14:53:33 -0700 | [diff] [blame] | 5 | import logging |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 6 | import random |
Christopher Wiley | 14796b3 | 2013-04-03 14:53:33 -0700 | [diff] [blame] | 7 | import re |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 8 | import string |
Christopher Wiley | 14796b3 | 2013-04-03 14:53:33 -0700 | [diff] [blame] | 9 | |
Wade Guthrie | e4074dd | 2013-10-30 11:00:48 -0700 | [diff] [blame] | 10 | from autotest_lib.client.common_lib import base_utils |
Paul Stewart | c9628b3 | 2010-08-11 13:03:51 -0700 | [diff] [blame] | 11 | from autotest_lib.client.common_lib import error |
Paul Stewart | 2ee7fdf | 2011-05-19 16:29:23 -0700 | [diff] [blame] | 12 | from autotest_lib.server import site_linux_system |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 13 | from autotest_lib.server.cros import wifi_test_utils |
Christopher Wiley | 99d42c9 | 2013-07-09 16:40:16 -0700 | [diff] [blame] | 14 | from autotest_lib.server.cros.network import hostap_config |
Sam Leffler | 19bb0a7 | 2010-04-12 08:51:08 -0700 | [diff] [blame] | 15 | |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 16 | def isLinuxRouter(host): |
| 17 | """Check if host is a linux router. |
| 18 | |
| 19 | @param host Host object representing the remote machine. |
| 20 | @return True iff remote system is a Linux system. |
| 21 | |
| 22 | """ |
| 23 | router_uname = host.run('uname').stdout |
Sam Leffler | 19bb0a7 | 2010-04-12 08:51:08 -0700 | [diff] [blame] | 24 | return re.search('Linux', router_uname) |
| 25 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 26 | |
Paul Stewart | 2ee7fdf | 2011-05-19 16:29:23 -0700 | [diff] [blame] | 27 | class LinuxRouter(site_linux_system.LinuxSystem): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 28 | """Linux/mac80211-style WiFi Router support for WiFiTest class. |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 29 | |
| 30 | This class implements test methods/steps that communicate with a |
| 31 | router implemented with Linux/mac80211. The router must |
| 32 | be pre-configured to enable ssh access and have a mac80211-based |
| 33 | wireless device. We also assume hostapd 0.7.x and iw are present |
| 34 | and any necessary modules are pre-loaded. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 35 | |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 36 | """ |
| 37 | |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 38 | KNOWN_TEST_PREFIX = 'network_WiFi' |
Christopher Wiley | 1defc24 | 2013-09-18 10:28:37 -0700 | [diff] [blame] | 39 | STARTUP_POLLING_INTERVAL_SECONDS = 0.5 |
| 40 | STARTUP_TIMEOUT_SECONDS = 10 |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 41 | SUFFIX_LETTERS = string.ascii_lowercase + string.digits |
Christopher Wiley | b1ade0a | 2013-09-16 13:09:55 -0700 | [diff] [blame] | 42 | SUBNET_PREFIX_OCTETS = (192, 168) |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 43 | |
Paul Stewart | 51b0f38 | 2013-06-12 09:03:02 -0700 | [diff] [blame] | 44 | def get_capabilities(self): |
| 45 | """@return iterable object of AP capabilities for this system.""" |
| 46 | caps = set() |
| 47 | try: |
| 48 | self.cmd_send_management_frame = wifi_test_utils.must_be_installed( |
| 49 | self.router, '/usr/bin/send_management_frame') |
| 50 | caps.add(self.CAPABILITY_SEND_MANAGEMENT_FRAME) |
| 51 | except error.TestFail: |
| 52 | pass |
| 53 | return super(LinuxRouter, self).get_capabilities().union(caps) |
| 54 | |
| 55 | |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 56 | def __init__(self, host, params, test_name): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 57 | """Build a LinuxRouter. |
| 58 | |
| 59 | @param host Host object representing the remote machine. |
| 60 | @param params dict of settings from site_wifitest based tests. |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 61 | @param test_name string name of this test. Used in SSID creation. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 62 | |
| 63 | """ |
| 64 | site_linux_system.LinuxSystem.__init__(self, host, params, 'router') |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 65 | self._remove_interfaces() |
Paul Stewart | 2ee7fdf | 2011-05-19 16:29:23 -0700 | [diff] [blame] | 66 | |
Wade Guthrie | 24d1e31 | 2012-04-24 16:53:40 -0700 | [diff] [blame] | 67 | # Router host. |
| 68 | self.router = host |
| 69 | |
Christopher Wiley | 4bca01e | 2013-09-13 13:36:39 -0700 | [diff] [blame] | 70 | self.cmd_dhcpd = params.get('cmd_dhcpd', '/usr/sbin/dhcpd') |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 71 | self.cmd_hostapd = wifi_test_utils.must_be_installed( |
| 72 | host, params.get('cmd_hostapd', '/usr/sbin/hostapd')) |
Christopher Wiley | 7337ff6 | 2013-10-03 17:21:46 -0700 | [diff] [blame] | 73 | self.cmd_hostapd_cli = wifi_test_utils.must_be_installed( |
| 74 | host, params.get('cmd_hostapd_cli', '/usr/sbin/hostapd_cli')) |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 75 | self.dhcpd_conf = '/tmp/dhcpd.%s.conf' |
| 76 | self.dhcpd_leases = '/tmp/dhcpd.leases' |
Nebojsa Sabovic | 138ff91 | 2010-04-06 15:47:42 -0700 | [diff] [blame] | 77 | |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 78 | # hostapd configuration persists throughout the test, subsequent |
| 79 | # 'config' commands only modify it. |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 80 | self.ssid_prefix = test_name |
| 81 | if self.ssid_prefix.startswith(self.KNOWN_TEST_PREFIX): |
| 82 | # Many of our tests start with an uninteresting prefix. |
| 83 | # Remove it so we can have more unique bytes. |
| 84 | self.ssid_prefix = self.ssid_prefix[len(self.KNOWN_TEST_PREFIX):] |
| 85 | self.ssid_prefix = self.ssid_prefix.lstrip('_') |
| 86 | self.ssid_prefix += '_' |
| 87 | |
Paul Stewart | d5aafa9 | 2013-03-24 19:06:14 -0700 | [diff] [blame] | 88 | self.default_config = { |
Paul Stewart | d5aafa9 | 2013-03-24 19:06:14 -0700 | [diff] [blame] | 89 | 'hw_mode': 'g', |
| 90 | 'ctrl_interface': '/tmp/hostapd-test.control', |
| 91 | 'logger_syslog': '-1', |
| 92 | 'logger_syslog_level': '0' |
| 93 | } |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 94 | self.hostapd = { |
| 95 | 'configured': False, |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 96 | 'config_file': "/tmp/hostapd-test-%s.conf", |
| 97 | 'log_file': "/tmp/hostapd-test-%s.log", |
Christopher Wiley | 1defc24 | 2013-09-18 10:28:37 -0700 | [diff] [blame] | 98 | 'pid_file': "/tmp/hostapd-test-%s.pid", |
Paul Stewart | f854d2e | 2011-05-04 13:19:18 -0700 | [diff] [blame] | 99 | 'log_count': 0, |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 100 | 'driver': "nl80211", |
Paul Stewart | d5aafa9 | 2013-03-24 19:06:14 -0700 | [diff] [blame] | 101 | 'conf': self.default_config.copy() |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 102 | } |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 103 | self.station = { |
| 104 | 'configured': False, |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 105 | 'conf': {}, |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 106 | } |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 107 | self.local_servers = [] |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 108 | self.hostapd_instances = [] |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 109 | self.force_local_server = "force_local_server" in params |
| 110 | self.dhcp_low = 1 |
| 111 | self.dhcp_high = 128 |
Paul Stewart | f05d7fd | 2011-04-06 16:19:37 -0700 | [diff] [blame] | 112 | |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 113 | # Kill hostapd and dhcp server if already running. |
Thieu Le | 7b23a54 | 2012-01-27 15:54:48 -0800 | [diff] [blame] | 114 | self.kill_hostapd() |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 115 | self.stop_dhcp_servers() |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 116 | |
Nebojsa Sabovic | bc245c6 | 2010-04-28 16:58:50 -0700 | [diff] [blame] | 117 | # Place us in the US by default |
Christopher Wiley | 7bd2e08 | 2013-10-16 17:40:40 -0700 | [diff] [blame] | 118 | self.iw_runner.set_regulatory_domain('US') |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 119 | |
Paul Stewart | f05d7fd | 2011-04-06 16:19:37 -0700 | [diff] [blame] | 120 | |
Christopher Wiley | f4bc88b | 2013-08-29 16:45:15 -0700 | [diff] [blame] | 121 | def close(self): |
| 122 | """Close global resources held by this system.""" |
| 123 | self.destroy() |
| 124 | super(LinuxRouter, self).close() |
| 125 | |
| 126 | |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 127 | def create(self, params): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 128 | """Create a wifi device of the specified type. |
Christopher Wiley | 14796b3 | 2013-04-03 14:53:33 -0700 | [diff] [blame] | 129 | |
| 130 | @param params dict containing the device type under key 'type'. |
| 131 | |
| 132 | """ |
| 133 | self.create_wifi_device(params['type']) |
| 134 | |
| 135 | |
| 136 | def create_wifi_device(self, device_type='hostap'): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 137 | """Create a wifi device of the specified type. |
Christopher Wiley | 14796b3 | 2013-04-03 14:53:33 -0700 | [diff] [blame] | 138 | |
| 139 | Defaults to creating a hostap managed device. |
| 140 | |
| 141 | @param device_type string device type. |
| 142 | |
| 143 | """ |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 144 | # |
| 145 | # AP mode is handled entirely by hostapd so we only |
| 146 | # have to setup others (mapping the bsd type to what |
| 147 | # iw wants) |
| 148 | # |
| 149 | # map from bsd types to iw types |
Christopher Wiley | 14796b3 | 2013-04-03 14:53:33 -0700 | [diff] [blame] | 150 | self.apmode = device_type in ('ap', 'hostap') |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 151 | if not self.apmode: |
Christopher Wiley | 14796b3 | 2013-04-03 14:53:33 -0700 | [diff] [blame] | 152 | self.station['type'] = device_type |
Paul Stewart | 2ee7fdf | 2011-05-19 16:29:23 -0700 | [diff] [blame] | 153 | self.phytype = { |
Christopher Wiley | 14796b3 | 2013-04-03 14:53:33 -0700 | [diff] [blame] | 154 | 'sta' : 'managed', |
| 155 | 'monitor' : 'monitor', |
| 156 | 'adhoc' : 'adhoc', |
| 157 | 'ibss' : 'ibss', |
| 158 | 'ap' : 'managed', # NB: handled by hostapd |
| 159 | 'hostap' : 'managed', # NB: handled by hostapd |
| 160 | 'mesh' : 'mesh', |
| 161 | 'wds' : 'wds', |
| 162 | }[device_type] |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 163 | |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 164 | |
Christopher Wiley | d89b528 | 2013-04-10 15:21:26 -0700 | [diff] [blame] | 165 | def destroy(self, params={}): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 166 | """Destroy a previously created device. |
| 167 | |
| 168 | @param params dict of site_wifitest parameters. |
| 169 | |
| 170 | """ |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 171 | self.deconfig(params) |
Paul Stewart | d5aafa9 | 2013-03-24 19:06:14 -0700 | [diff] [blame] | 172 | self.hostapd['conf'] = self.default_config.copy() |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 173 | |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 174 | |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 175 | def has_local_server(self): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 176 | """@return True iff this router has local servers configured.""" |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 177 | return bool(self.local_servers) |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 178 | |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 179 | |
Paul Stewart | 9e3ff0b | 2011-08-17 20:35:19 -0700 | [diff] [blame] | 180 | def cleanup(self, params): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 181 | """Clean up any resources in use. |
| 182 | |
| 183 | @param params dict of site_wifitest parameters. |
| 184 | |
| 185 | """ |
Paul Stewart | 9e3ff0b | 2011-08-17 20:35:19 -0700 | [diff] [blame] | 186 | # For linux, this is a no-op |
| 187 | pass |
| 188 | |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 189 | |
Christopher Wiley | 7337ff6 | 2013-10-03 17:21:46 -0700 | [diff] [blame] | 190 | def get_hostapd_start_command(self, log_file, pid_file, conf_file): |
| 191 | return '%s -dd -t -P %s %s &> %s &' % ( |
| 192 | self.cmd_hostapd, pid_file, conf_file, log_file) |
| 193 | |
| 194 | |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 195 | def start_hostapd(self, conf, params): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 196 | """Start a hostapd instance described by conf. |
| 197 | |
| 198 | @param conf dict of hostapd configuration parameters. |
| 199 | @param params dict of site_wifitest parameters. |
| 200 | |
| 201 | """ |
Christopher Wiley | 7d414cc | 2013-04-17 17:26:32 -0700 | [diff] [blame] | 202 | logging.info('Starting hostapd with parameters: %r', conf) |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 203 | # Figure out the correct interface. |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 204 | interface = self._get_wlanif(self.hostapd['frequency'], |
| 205 | self.phytype, |
| 206 | mode=conf.get('hw_mode', 'b')) |
| 207 | |
| 208 | conf_file = self.hostapd['config_file'] % interface |
| 209 | log_file = self.hostapd['log_file'] % interface |
Christopher Wiley | 1defc24 | 2013-09-18 10:28:37 -0700 | [diff] [blame] | 210 | pid_file = self.hostapd['pid_file'] % interface |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 211 | conf['interface'] = interface |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 212 | |
| 213 | # Generate hostapd.conf. |
| 214 | self._pre_config_hook(conf) |
| 215 | self.router.run("cat <<EOF >%s\n%s\nEOF\n" % |
| 216 | (conf_file, '\n'.join( |
| 217 | "%s=%s" % kv for kv in conf.iteritems()))) |
| 218 | |
| 219 | # Run hostapd. |
| 220 | logging.info("Starting hostapd...") |
Christopher Wiley | 1defc24 | 2013-09-18 10:28:37 -0700 | [diff] [blame] | 221 | self.router.run('rm %s' % log_file, ignore_status=True) |
| 222 | self.router.run('rm %s' % pid_file, ignore_status=True) |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 223 | self._pre_start_hook(params) |
Christopher Wiley | 7337ff6 | 2013-10-03 17:21:46 -0700 | [diff] [blame] | 224 | start_command = self.get_hostapd_start_command( |
| 225 | log_file, pid_file, conf_file) |
| 226 | self.router.run(start_command) |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 227 | self.hostapd_instances.append({ |
Christopher Wiley | 3099be7 | 2013-11-06 16:49:02 -0800 | [diff] [blame] | 228 | 'ssid': conf['ssid'], |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 229 | 'conf_file': conf_file, |
| 230 | 'log_file': log_file, |
Christopher Wiley | 1defc24 | 2013-09-18 10:28:37 -0700 | [diff] [blame] | 231 | 'interface': interface, |
| 232 | 'pid_file': pid_file |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 233 | }) |
| 234 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 235 | |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 236 | def _kill_process_instance(self, process, instance=None, wait=0): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 237 | """Kill a process on the router. |
| 238 | |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 239 | Kills program named |process|, optionally only a specific |
| 240 | |instance|. If |wait| is specified, we makes sure |process| exits |
| 241 | before returning. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 242 | |
| 243 | @param process string name of process to kill. |
| 244 | @param instance string instance of process to kill. |
| 245 | @param wait int timeout in seconds to wait for. |
| 246 | |
Thieu Le | 7b23a54 | 2012-01-27 15:54:48 -0800 | [diff] [blame] | 247 | """ |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 248 | if instance: |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 249 | search_arg = '-f "%s.*%s"' % (process, instance) |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 250 | else: |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 251 | search_arg = process |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 252 | |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 253 | cmd = "pkill %s >/dev/null 2>&1" % search_arg |
| 254 | |
| 255 | if wait: |
| 256 | cmd += (" && while pgrep %s &> /dev/null; do sleep 1; done" % |
| 257 | search_arg) |
| 258 | self.router.run(cmd, timeout=wait, ignore_status=True) |
| 259 | else: |
| 260 | self.router.run(cmd, ignore_status=True) |
| 261 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 262 | |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 263 | def kill_hostapd_instance(self, instance): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 264 | """Kills a hostapd instance. |
| 265 | |
| 266 | @param instance string instance to kill. |
| 267 | |
| 268 | """ |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 269 | self._kill_process_instance('hostapd', instance, 30) |
Thieu Le | 7b23a54 | 2012-01-27 15:54:48 -0800 | [diff] [blame] | 270 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 271 | |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 272 | def kill_hostapd(self): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 273 | """Kill all hostapd instances.""" |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 274 | self.kill_hostapd_instance(None) |
| 275 | |
Christopher Wiley | 7d414cc | 2013-04-17 17:26:32 -0700 | [diff] [blame] | 276 | |
| 277 | def __get_default_hostap_config(self): |
| 278 | """@return dict of default options for hostapd.""" |
| 279 | conf = self.hostapd['conf'] |
| 280 | # default RTS and frag threshold to ``off'' |
| 281 | conf['rts_threshold'] = '2347' |
| 282 | conf['fragm_threshold'] = '2346' |
| 283 | conf['driver'] = self.hostapd['driver'] |
Christopher Wiley | 0ff28ab | 2013-08-12 13:23:04 -0700 | [diff] [blame] | 284 | conf['ssid'] = self._build_ssid('') |
Christopher Wiley | 7d414cc | 2013-04-17 17:26:32 -0700 | [diff] [blame] | 285 | return conf |
| 286 | |
| 287 | |
Christopher Wiley | 0ff28ab | 2013-08-12 13:23:04 -0700 | [diff] [blame] | 288 | def _build_ssid(self, suffix): |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 289 | unique_salt = ''.join([random.choice(self.SUFFIX_LETTERS) |
| 290 | for x in range(5)]) |
| 291 | return (self.ssid_prefix + unique_salt + suffix)[-32:] |
| 292 | |
| 293 | |
Christopher Wiley | 7d414cc | 2013-04-17 17:26:32 -0700 | [diff] [blame] | 294 | def hostap_configure(self, configuration, multi_interface=None): |
| 295 | """Build up a hostapd configuration file and start hostapd. |
| 296 | |
| 297 | Also setup a local server if this router supports them. |
| 298 | |
| 299 | @param configuration HosetapConfig object. |
| 300 | @param multi_interface bool True iff multiple interfaces allowed. |
| 301 | |
| 302 | """ |
| 303 | if multi_interface is None and (self.hostapd['configured'] or |
| 304 | self.station['configured']): |
| 305 | self.deconfig() |
| 306 | # Start with the default hostapd config parameters. |
| 307 | conf = self.__get_default_hostap_config() |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 308 | conf['ssid'] = (configuration.ssid or |
Christopher Wiley | 0ff28ab | 2013-08-12 13:23:04 -0700 | [diff] [blame] | 309 | self._build_ssid(configuration.ssid_suffix)) |
Christopher Wiley | 9b40620 | 2013-05-06 14:07:49 -0700 | [diff] [blame] | 310 | if configuration.bssid: |
| 311 | conf['bssid'] = configuration.bssid |
Christopher Wiley | 7d414cc | 2013-04-17 17:26:32 -0700 | [diff] [blame] | 312 | conf['channel'] = configuration.channel |
| 313 | self.hostapd['frequency'] = configuration.frequency |
| 314 | conf['hw_mode'] = configuration.hw_mode |
| 315 | if configuration.hide_ssid: |
| 316 | conf['ignore_broadcast_ssid'] = 1 |
| 317 | if configuration.is_11n: |
| 318 | conf['ieee80211n'] = 1 |
Christopher Wiley | 32fbb7a | 2013-09-18 14:30:50 -0700 | [diff] [blame] | 319 | conf['ht_capab'] = configuration.hostapd_ht_capabilities |
Christopher Wiley | 7d414cc | 2013-04-17 17:26:32 -0700 | [diff] [blame] | 320 | if configuration.wmm_enabled: |
| 321 | conf['wmm_enabled'] = 1 |
| 322 | if configuration.require_ht: |
| 323 | conf['require_ht'] = 1 |
Christopher Wiley | 9fa7c63 | 2013-05-01 11:58:06 -0700 | [diff] [blame] | 324 | if configuration.beacon_interval: |
| 325 | conf['beacon_int'] = configuration.beacon_interval |
Christopher Wiley | a51258e | 2013-05-03 13:05:06 -0700 | [diff] [blame] | 326 | if configuration.dtim_period: |
| 327 | conf['dtim_period'] = configuration.dtim_period |
Christopher Wiley | e1235b6 | 2013-05-03 15:09:34 -0700 | [diff] [blame] | 328 | if configuration.frag_threshold: |
| 329 | conf['fragm_threshold'] = configuration.frag_threshold |
Christopher Wiley | ebdc27d | 2013-06-28 14:35:41 -0700 | [diff] [blame] | 330 | if configuration.pmf_support: |
| 331 | conf['ieee80211w'] = configuration.pmf_support |
Paul Stewart | 4ae471e | 2013-09-04 15:42:35 -0700 | [diff] [blame] | 332 | if configuration.obss_interval: |
| 333 | conf['obss_interval'] = configuration.obss_interval |
Christopher Wiley | b8921c7 | 2013-06-13 09:51:47 -0700 | [diff] [blame] | 334 | conf.update(configuration.get_security_hostapd_conf()) |
Christopher Wiley | a89706d | 2013-06-12 13:20:58 -0700 | [diff] [blame] | 335 | |
Wade Guthrie | fcaaf02 | 2013-09-06 11:12:22 -0700 | [diff] [blame] | 336 | # TODO(wiley): Remove this multi_interface flag when the bridge router |
| 337 | # class is gone. |
| 338 | params = {'multi_interface': 1} if multi_interface else {} |
| 339 | self.start_hostapd(conf, params) |
Christopher Wiley | 7d414cc | 2013-04-17 17:26:32 -0700 | [diff] [blame] | 340 | # Configure transmit power |
| 341 | tx_power_params = {'interface': conf['interface']} |
| 342 | # TODO(wiley) support for setting transmit power |
| 343 | self.set_txpower(tx_power_params) |
| 344 | if self.force_local_server: |
| 345 | self.start_local_server(conf['interface']) |
Wade Guthrie | fcaaf02 | 2013-09-06 11:12:22 -0700 | [diff] [blame] | 346 | self._post_start_hook(params) |
Christopher Wiley | 7d414cc | 2013-04-17 17:26:32 -0700 | [diff] [blame] | 347 | logging.info('AP configured.') |
| 348 | self.hostapd['configured'] = True |
| 349 | |
| 350 | |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 351 | def hostap_config(self, params): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 352 | """Configure the AP per test requirements. |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 353 | |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 354 | @param params dict of site_wifitest parameters. |
| 355 | |
| 356 | """ |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 357 | # keep parameter modifications local-only |
| 358 | orig_params = params |
| 359 | params = params.copy() |
| 360 | |
Paul Stewart | 45338d2 | 2010-10-21 10:57:02 -0700 | [diff] [blame] | 361 | multi_interface = 'multi_interface' in params |
| 362 | if multi_interface: |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 363 | # remove non-hostapd config item from params |
Paul Stewart | 45338d2 | 2010-10-21 10:57:02 -0700 | [diff] [blame] | 364 | params.pop('multi_interface') |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 365 | elif self.hostapd['configured'] or self.station['configured']: |
Christopher Wiley | d89b528 | 2013-04-10 15:21:26 -0700 | [diff] [blame] | 366 | self.deconfig() |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 367 | |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 368 | local_server = params.pop('local_server', False) |
| 369 | |
Christopher Wiley | 7d414cc | 2013-04-17 17:26:32 -0700 | [diff] [blame] | 370 | conf = self.__get_default_hostap_config() |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 371 | tx_power_params = {} |
| 372 | htcaps = set() |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 373 | |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 374 | for k, v in params.iteritems(): |
| 375 | if k == 'ssid': |
| 376 | conf['ssid'] = v |
| 377 | elif k == 'ssid_suffix': |
Christopher Wiley | 0ff28ab | 2013-08-12 13:23:04 -0700 | [diff] [blame] | 378 | conf['ssid'] = self._build_ssid(v) |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 379 | elif k == 'channel': |
| 380 | freq = int(v) |
Paul Stewart | 2ee7fdf | 2011-05-19 16:29:23 -0700 | [diff] [blame] | 381 | self.hostapd['frequency'] = freq |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 382 | |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 383 | # 2.4GHz |
| 384 | if freq <= 2484: |
| 385 | # Make sure hw_mode is set |
| 386 | if conf.get('hw_mode') == 'a': |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 387 | conf['hw_mode'] = 'g' |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 388 | |
| 389 | # Freq = 5 * chan + 2407, except channel 14 |
| 390 | if freq == 2484: |
| 391 | conf['channel'] = 14 |
| 392 | else: |
| 393 | conf['channel'] = (freq - 2407) / 5 |
| 394 | # 5GHz |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 395 | else: |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 396 | # Make sure hw_mode is set |
| 397 | conf['hw_mode'] = 'a' |
| 398 | # Freq = 5 * chan + 4000 |
| 399 | if freq < 5000: |
| 400 | conf['channel'] = (freq - 4000) / 5 |
| 401 | # Freq = 5 * chan + 5000 |
| 402 | else: |
| 403 | conf['channel'] = (freq - 5000) / 5 |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 404 | |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 405 | elif k == 'country': |
| 406 | conf['country_code'] = v |
| 407 | elif k == 'dotd': |
| 408 | conf['ieee80211d'] = 1 |
| 409 | elif k == '-dotd': |
| 410 | conf['ieee80211d'] = 0 |
| 411 | elif k == 'mode': |
| 412 | if v == '11a': |
| 413 | conf['hw_mode'] = 'a' |
| 414 | elif v == '11g': |
| 415 | conf['hw_mode'] = 'g' |
| 416 | elif v == '11b': |
| 417 | conf['hw_mode'] = 'b' |
| 418 | elif v == '11n': |
| 419 | conf['ieee80211n'] = 1 |
| 420 | elif k == 'bintval': |
| 421 | conf['beacon_int'] = v |
| 422 | elif k == 'dtimperiod': |
| 423 | conf['dtim_period'] = v |
| 424 | elif k == 'rtsthreshold': |
| 425 | conf['rts_threshold'] = v |
| 426 | elif k == 'fragthreshold': |
| 427 | conf['fragm_threshold'] = v |
| 428 | elif k == 'shortpreamble': |
| 429 | conf['preamble'] = 1 |
| 430 | elif k == 'authmode': |
| 431 | if v == "open": |
| 432 | conf['auth_algs'] = 1 |
| 433 | elif v == "shared": |
| 434 | conf['auth_algs'] = 2 |
| 435 | elif k == 'hidessid': |
| 436 | conf['ignore_broadcast_ssid'] = 1 |
| 437 | elif k == 'wme': |
| 438 | conf['wmm_enabled'] = 1 |
| 439 | elif k == '-wme': |
| 440 | conf['wmm_enabled'] = 0 |
| 441 | elif k == 'deftxkey': |
| 442 | conf['wep_default_key'] = v |
| 443 | elif k == 'ht20': |
| 444 | htcaps.add('') # NB: ensure 802.11n setup below |
| 445 | conf['wmm_enabled'] = 1 |
| 446 | elif k == 'ht40': |
| 447 | htcaps.add('[HT40-]') |
| 448 | htcaps.add('[HT40+]') |
| 449 | conf['wmm_enabled'] = 1 |
Paul Stewart | c1df8d6 | 2011-04-07 14:28:15 -0700 | [diff] [blame] | 450 | elif k in ('ht40+', 'ht40-'): |
| 451 | htcaps.add('[%s]' % k.upper()) |
| 452 | conf['wmm_enabled'] = 1 |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 453 | elif k == 'shortgi': |
| 454 | htcaps.add('[SHORT-GI-20]') |
| 455 | htcaps.add('[SHORT-GI-40]') |
| 456 | elif k == 'pureg': |
| 457 | pass # TODO(sleffler) need hostapd support |
| 458 | elif k == 'puren': |
| 459 | pass # TODO(sleffler) need hostapd support |
| 460 | elif k == 'protmode': |
| 461 | pass # TODO(sleffler) need hostapd support |
| 462 | elif k == 'ht': |
| 463 | htcaps.add('') # NB: ensure 802.11n setup below |
| 464 | elif k == 'htprotmode': |
| 465 | pass # TODO(sleffler) need hostapd support |
| 466 | elif k == 'rifs': |
| 467 | pass # TODO(sleffler) need hostapd support |
| 468 | elif k == 'wepmode': |
| 469 | pass # NB: meaningless for hostapd; ignore |
| 470 | elif k == '-ampdu': |
| 471 | pass # TODO(sleffler) need hostapd support |
| 472 | elif k == 'txpower': |
| 473 | tx_power_params['power'] = v |
Nebojsa Sabovic | 60ae146 | 2010-05-07 16:14:45 -0700 | [diff] [blame] | 474 | else: |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 475 | conf[k] = v |
Nebojsa Sabovic | 60ae146 | 2010-05-07 16:14:45 -0700 | [diff] [blame] | 476 | |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 477 | # Aggregate ht_capab. |
| 478 | if htcaps: |
| 479 | conf['ieee80211n'] = 1 |
| 480 | conf['ht_capab'] = ''.join(htcaps) |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 481 | |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 482 | self.start_hostapd(conf, orig_params) |
Paul Stewart | 1ae854b | 2011-02-08 15:10:14 -0800 | [diff] [blame] | 483 | |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 484 | # Configure transmit power |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 485 | tx_power_params['interface'] = conf['interface'] |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 486 | self.set_txpower(tx_power_params) |
Nebojsa Sabovic | 138ff91 | 2010-04-06 15:47:42 -0700 | [diff] [blame] | 487 | |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 488 | if self.force_local_server or local_server is not False: |
| 489 | self.start_local_server(conf['interface']) |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 490 | |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 491 | self._post_start_hook(orig_params) |
| 492 | |
| 493 | logging.info("AP configured.") |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 494 | self.hostapd['configured'] = True |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 495 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 496 | |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 497 | @staticmethod |
| 498 | def ip_addr(netblock, idx): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 499 | """Simple IPv4 calculator. |
| 500 | |
| 501 | Takes host address in "IP/bits" notation and returns netmask, broadcast |
| 502 | address as well as integer offsets into the address range. |
| 503 | |
| 504 | @param netblock string host address in "IP/bits" notation. |
| 505 | @param idx string describing what to return. |
| 506 | @return string containing something you hopefully requested. |
| 507 | |
Paul Stewart | f05d7fd | 2011-04-06 16:19:37 -0700 | [diff] [blame] | 508 | """ |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 509 | addr_str,bits = netblock.split('/') |
Paul Stewart | f05d7fd | 2011-04-06 16:19:37 -0700 | [diff] [blame] | 510 | addr = map(int, addr_str.split('.')) |
| 511 | mask_bits = (-1 << (32-int(bits))) & 0xffffffff |
| 512 | mask = [(mask_bits >> s) & 0xff for s in range(24, -1, -8)] |
Paul Stewart | 5977da9 | 2011-06-01 19:14:08 -0700 | [diff] [blame] | 513 | if idx == 'local': |
| 514 | return addr_str |
| 515 | elif idx == 'netmask': |
Paul Stewart | f05d7fd | 2011-04-06 16:19:37 -0700 | [diff] [blame] | 516 | return '.'.join(map(str, mask)) |
| 517 | elif idx == 'broadcast': |
| 518 | offset = [m ^ 0xff for m in mask] |
| 519 | else: |
| 520 | offset = [(idx >> s) & 0xff for s in range(24, -1, -8)] |
| 521 | return '.'.join(map(str, [(a & m) + o |
| 522 | for a, m, o in zip(addr, mask, offset)])) |
| 523 | |
| 524 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 525 | def ibss_configure(self, config): |
| 526 | """Configure a station based AP in IBSS mode. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 527 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 528 | Extract relevant configuration objects from |config| despite not |
| 529 | actually being a hostap managed endpoint. |
| 530 | |
| 531 | @param config HostapConfig object. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 532 | |
| 533 | """ |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 534 | if self.station['configured'] or self.hostapd['configured']: |
Christopher Wiley | d89b528 | 2013-04-10 15:21:26 -0700 | [diff] [blame] | 535 | self.deconfig() |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 536 | interface = self._get_wlanif(config.frequency, self.phytype, |
| 537 | config.hw_mode) |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 538 | self.station['conf']['ssid'] = (config.ssid or |
Christopher Wiley | 0ff28ab | 2013-08-12 13:23:04 -0700 | [diff] [blame] | 539 | self._build_ssid(config.ssid_suffix)) |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 540 | # Connect the station |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 541 | self.router.run('%s link set %s up' % (self.cmd_ip, interface)) |
Christopher Wiley | 7bd2e08 | 2013-10-16 17:40:40 -0700 | [diff] [blame] | 542 | self.iw_runner.ibss_join( |
| 543 | interface, self.station['conf']['ssid'], config.frequency) |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 544 | # Always start a local server. |
| 545 | self.start_local_server(interface) |
| 546 | # Remember that this interface is up. |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 547 | self.station['configured'] = True |
| 548 | self.station['interface'] = interface |
| 549 | |
| 550 | |
Paul Stewart | 2bd823b | 2012-11-21 15:03:37 -0800 | [diff] [blame] | 551 | def local_server_address(self, index): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 552 | """Get the local server address for an interface. |
| 553 | |
| 554 | When we multiple local servers, we give them static IP addresses |
Christopher Wiley | b1ade0a | 2013-09-16 13:09:55 -0700 | [diff] [blame] | 555 | like 192.168.*.254. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 556 | |
| 557 | @param index int describing which local server this is for. |
| 558 | |
| 559 | """ |
Christopher Wiley | b1ade0a | 2013-09-16 13:09:55 -0700 | [diff] [blame] | 560 | return '%d.%d.%d.%d' % (self.SUBNET_PREFIX_OCTETS + (index, 254)) |
Paul Stewart | 2bd823b | 2012-11-21 15:03:37 -0800 | [diff] [blame] | 561 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 562 | |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 563 | def start_local_server(self, interface): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 564 | """Start a local server on an interface. |
| 565 | |
| 566 | @param interface string (e.g. wlan0) |
| 567 | |
| 568 | """ |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 569 | logging.info("Starting up local server...") |
| 570 | |
| 571 | if len(self.local_servers) >= 256: |
| 572 | raise error.TestFail('Exhausted available local servers') |
| 573 | |
Paul Stewart | 2bd823b | 2012-11-21 15:03:37 -0800 | [diff] [blame] | 574 | netblock = '%s/24' % self.local_server_address(len(self.local_servers)) |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 575 | |
| 576 | params = {} |
| 577 | params['netblock'] = netblock |
| 578 | params['subnet'] = self.ip_addr(netblock, 0) |
| 579 | params['netmask'] = self.ip_addr(netblock, 'netmask') |
| 580 | params['dhcp_range'] = ' '.join( |
| 581 | (self.ip_addr(netblock, self.dhcp_low), |
| 582 | self.ip_addr(netblock, self.dhcp_high))) |
mukesh agrawal | 05c455a | 2011-10-12 13:40:27 -0700 | [diff] [blame] | 583 | params['interface'] = interface |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 584 | |
| 585 | params['ip_params'] = ("%s broadcast %s dev %s" % |
| 586 | (netblock, |
| 587 | self.ip_addr(netblock, 'broadcast'), |
| 588 | interface)) |
| 589 | self.local_servers.append(params) |
| 590 | |
| 591 | self.router.run("%s addr flush %s" % |
| 592 | (self.cmd_ip, interface)) |
| 593 | self.router.run("%s addr add %s" % |
| 594 | (self.cmd_ip, params['ip_params'])) |
| 595 | self.router.run("%s link set %s up" % |
| 596 | (self.cmd_ip, interface)) |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 597 | self.start_dhcp_server(interface) |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 598 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 599 | |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 600 | def start_dhcp_server(self, interface): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 601 | """Start a dhcp server on an interface. |
| 602 | |
| 603 | @param interface string (e.g. wlan0) |
| 604 | |
| 605 | """ |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 606 | conf_file = self.dhcpd_conf % interface |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 607 | dhcp_conf = '\n'.join(map( |
| 608 | lambda server_conf: \ |
| 609 | "subnet %(subnet)s netmask %(netmask)s {\n" \ |
| 610 | " range %(dhcp_range)s;\n" \ |
| 611 | "}" % server_conf, |
| 612 | self.local_servers)) |
| 613 | self.router.run("cat <<EOF >%s\n%s\nEOF\n" % |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 614 | (conf_file, |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 615 | '\n'.join(('ddns-update-style none;', dhcp_conf)))) |
| 616 | self.router.run("touch %s" % self.dhcpd_leases) |
| 617 | |
| 618 | self.router.run("pkill dhcpd >/dev/null 2>&1", ignore_status=True) |
| 619 | self.router.run("%s -q -cf %s -lf %s" % |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 620 | (self.cmd_dhcpd, conf_file, self.dhcpd_leases)) |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 621 | |
| 622 | |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 623 | def stop_dhcp_server(self, instance=None): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 624 | """Stop a dhcp server on the router. |
| 625 | |
| 626 | @param instance string instance to kill. |
| 627 | |
| 628 | """ |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 629 | self._kill_process_instance('dhcpd', instance, 0) |
| 630 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 631 | |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 632 | def stop_dhcp_servers(self): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 633 | """Stop all dhcp servers on the router.""" |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 634 | self.stop_dhcp_server(None) |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 635 | |
| 636 | |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 637 | def config(self, params): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 638 | """Configure an AP based on site_wifitest parameters. |
| 639 | |
| 640 | @param params dict of site_wifitest parameters. |
| 641 | |
| 642 | """ |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 643 | if self.apmode: |
| 644 | self.hostap_config(params) |
| 645 | else: |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 646 | config = hostap_config.HostapConfig( |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 647 | frequency=int(params.get('channel', None))) |
| 648 | self.ibss_configure(config) |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 649 | |
| 650 | |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 651 | def get_wifi_ip(self, ap_num): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 652 | """Return IP address on the WiFi subnet of a local server on the router. |
| 653 | |
| 654 | If no local servers are configured (e.g. for an RSPro), a TestFail will |
| 655 | be raised. |
| 656 | |
| 657 | @param ap_num int which local server to get an address from. |
| 658 | |
| 659 | """ |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 660 | if self.local_servers: |
| 661 | return self.ip_addr(self.local_servers[ap_num]['netblock'], |
| 662 | 'local') |
| 663 | else: |
| 664 | raise error.TestFail("No IP address assigned") |
Paul Stewart | 5977da9 | 2011-06-01 19:14:08 -0700 | [diff] [blame] | 665 | |
| 666 | |
Paul Stewart | 17350be | 2012-12-14 13:34:54 -0800 | [diff] [blame] | 667 | def get_hostapd_mac(self, ap_num): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 668 | """Return the MAC address of an AP in the test. |
| 669 | |
| 670 | @param ap_num int index of local server to read the MAC address from. |
| 671 | @return string MAC address like 00:11:22:33:44:55. |
| 672 | |
| 673 | """ |
Paul Stewart | 17350be | 2012-12-14 13:34:54 -0800 | [diff] [blame] | 674 | instance = self.hostapd_instances[ap_num] |
| 675 | interface = instance['interface'] |
| 676 | result = self.router.run('%s addr show %s' % (self.cmd_ip, interface)) |
| 677 | # Example response: |
| 678 | # 1: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 UP qlen 1000 |
| 679 | # link/ether 99:88:77:66:55:44 brd ff:ff:ff:ff:ff:ff |
| 680 | # inet 10.0.0.1/8 brd 10.255.255.255 scope global eth0 |
| 681 | # inet6 fe80::6a7f:74ff:fe66:5544/64 scope link |
| 682 | # we want the MAC address after the "link/ether" above. |
| 683 | parts = result.stdout.split(' ') |
| 684 | return parts[parts.index('link/ether') + 1] |
| 685 | |
| 686 | |
Christopher Wiley | d89b528 | 2013-04-10 15:21:26 -0700 | [diff] [blame] | 687 | def deconfig(self, params={}): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 688 | """De-configure the AP (will also bring wlan down). |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 689 | |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 690 | @param params dict of parameters from site_wifitest. |
| 691 | |
| 692 | """ |
Christopher Wiley | 4cd4b3f | 2013-11-11 17:27:28 -0800 | [diff] [blame^] | 693 | self.deconfig_aps(instance=params.get('instance', None), |
| 694 | silent='silent' in params) |
| 695 | |
| 696 | |
| 697 | def deconfig_aps(self, instance=None, silent=False): |
| 698 | """De-configure an AP (will also bring wlan down). |
| 699 | |
| 700 | @param instance: int or None. If instance is None, will bring down all |
| 701 | instances of hostapd. |
| 702 | @param silent: True if instances should be brought without de-authing |
| 703 | the DUT. |
| 704 | |
| 705 | """ |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 706 | if not self.hostapd['configured'] and not self.station['configured']: |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 707 | return |
Sam Leffler | 6969d1d | 2010-03-15 16:07:11 -0700 | [diff] [blame] | 708 | |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 709 | if self.hostapd['configured']: |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 710 | local_servers = [] |
Christopher Wiley | 4cd4b3f | 2013-11-11 17:27:28 -0800 | [diff] [blame^] | 711 | if instance is not None: |
| 712 | instances = [ self.hostapd_instances.pop(instance) ] |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 713 | for server in self.local_servers: |
| 714 | if server['interface'] == instances[0]['interface']: |
| 715 | local_servers = [server] |
| 716 | self.local_servers.remove(server) |
| 717 | break |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 718 | else: |
| 719 | instances = self.hostapd_instances |
| 720 | self.hostapd_instances = [] |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 721 | local_servers = self.local_servers |
| 722 | self.local_servers = [] |
Paul Stewart | 64cc429 | 2011-06-01 10:59:36 -0700 | [diff] [blame] | 723 | |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 724 | for instance in instances: |
Christopher Wiley | 4cd4b3f | 2013-11-11 17:27:28 -0800 | [diff] [blame^] | 725 | if silent: |
Paul Stewart | 2173781 | 2012-12-06 11:03:32 -0800 | [diff] [blame] | 726 | # Deconfigure without notifying DUT. Remove the interface |
| 727 | # hostapd uses to send beacon and DEAUTH packets. |
| 728 | self._remove_interface(instance['interface'], True) |
| 729 | |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 730 | self.kill_hostapd_instance(instance['conf_file']) |
Christopher Wiley | 7337ff6 | 2013-10-03 17:21:46 -0700 | [diff] [blame] | 731 | if wifi_test_utils.is_installed(self.host, |
| 732 | instance['log_file']): |
| 733 | self.router.get_file(instance['log_file'], |
| 734 | 'debug/hostapd_router_%d_%s.log' % |
| 735 | (self.hostapd['log_count'], |
| 736 | instance['interface'])) |
| 737 | else: |
| 738 | logging.error('Did not collect hostapd log file because ' |
| 739 | 'it was missing.') |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 740 | self._release_wlanif(instance['interface']) |
| 741 | # self.router.run("rm -f %(log_file)s %(conf_file)s" % instance) |
Paul Stewart | f854d2e | 2011-05-04 13:19:18 -0700 | [diff] [blame] | 742 | self.hostapd['log_count'] += 1 |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 743 | if self.station['configured']: |
Christopher Wiley | 05262d6 | 2013-04-17 17:53:59 -0700 | [diff] [blame] | 744 | local_servers = self.local_servers |
| 745 | self.local_servers = [] |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 746 | if self.station['type'] == 'ibss': |
Christopher Wiley | 7bd2e08 | 2013-10-16 17:40:40 -0700 | [diff] [blame] | 747 | self.iw_runner.ibss_leave(self.station['interface']) |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 748 | else: |
Christopher Wiley | 7bd2e08 | 2013-10-16 17:40:40 -0700 | [diff] [blame] | 749 | self.iw_runner.disconnect_station(self.station['interface']) |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 750 | self.router.run("%s link set %s down" % (self.cmd_ip, |
| 751 | self.station['interface'])) |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 752 | |
Paul Stewart | 326badb | 2012-12-18 14:18:54 -0800 | [diff] [blame] | 753 | for server in local_servers: |
| 754 | self.stop_dhcp_server(server['interface']) |
| 755 | self.router.run("%s addr del %s" % |
| 756 | (self.cmd_ip, server['ip_params']), |
| 757 | ignore_status=True) |
Nebojsa Sabovic | 4cc2ce9 | 2010-04-21 15:08:01 -0700 | [diff] [blame] | 758 | |
| 759 | self.hostapd['configured'] = False |
Paul Stewart | c2b3de8 | 2011-03-03 14:45:31 -0800 | [diff] [blame] | 760 | self.station['configured'] = False |
Paul Stewart | 7cb1f06 | 2010-06-10 15:46:20 -0700 | [diff] [blame] | 761 | |
| 762 | |
Paul Stewart | 17350be | 2012-12-14 13:34:54 -0800 | [diff] [blame] | 763 | def verify_pmksa_auth(self, params): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 764 | """Verify that the PMKSA auth was cached on a hostapd instance. |
| 765 | |
| 766 | @param params dict with optional key 'instance' (defaults to 0). |
| 767 | |
| 768 | """ |
Paul Stewart | 17350be | 2012-12-14 13:34:54 -0800 | [diff] [blame] | 769 | instance_num = params.get('instance', 0) |
| 770 | instance = self.hostapd_instances[instance_num] |
| 771 | pmksa_match = 'PMK from PMKSA cache - skip IEEE 802.1X.EAP' |
| 772 | self.router.run('grep -q "%s" %s' % (pmksa_match, instance['log_file'])) |
| 773 | |
| 774 | |
Christopher Wiley | e0afecb | 2013-11-11 10:54:23 -0800 | [diff] [blame] | 775 | def get_ssid(self, instance=None): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 776 | """@return string ssid for the network stemming from this router.""" |
Christopher Wiley | e0afecb | 2013-11-11 10:54:23 -0800 | [diff] [blame] | 777 | if instance is None: |
| 778 | instance = 0 |
| 779 | if len(self.hostapd_instances) > 1: |
| 780 | raise error.TestFail('No instance of hostapd specified with ' |
| 781 | 'multiple instances present.') |
| 782 | |
Christopher Wiley | 3099be7 | 2013-11-06 16:49:02 -0800 | [diff] [blame] | 783 | if self.hostapd_instances: |
| 784 | return self.hostapd_instances[instance]['ssid'] |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 785 | |
Christopher Wiley | 3166e43 | 2013-08-06 09:53:12 -0700 | [diff] [blame] | 786 | if not 'ssid' in self.station['conf']: |
| 787 | raise error.TestFail('Requested ssid of an unconfigured AP.') |
| 788 | |
Christopher Wiley | 1febd6a | 2013-06-03 13:59:48 -0700 | [diff] [blame] | 789 | return self.station['conf']['ssid'] |
Paul Stewart | 98022e2 | 2010-10-22 10:33:14 -0700 | [diff] [blame] | 790 | |
| 791 | |
| 792 | def set_txpower(self, params): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 793 | """Set the transmission power for an interface. |
| 794 | |
| 795 | Assumes that we want to refer to the first hostapd instance unless |
| 796 | 'interface' is defined in params. Sets the transmission power to |
| 797 | 'auto' if 'power' is not defined in params. |
| 798 | |
| 799 | @param params dict of parameters as described above. |
| 800 | |
| 801 | """ |
Paul Stewart | 548cf45 | 2012-11-27 17:46:23 -0800 | [diff] [blame] | 802 | interface = params.get('interface', |
| 803 | self.hostapd_instances[0]['interface']) |
| 804 | power = params.get('power', 'auto') |
Christopher Wiley | 7bd2e08 | 2013-10-16 17:40:40 -0700 | [diff] [blame] | 805 | self.iw_runner.set_tx_power(interface, power) |
Paul Stewart | aa52e8c | 2011-05-24 08:46:23 -0700 | [diff] [blame] | 806 | |
| 807 | |
Wade Guthrie | e4074dd | 2013-10-30 11:00:48 -0700 | [diff] [blame] | 808 | def deauth_client(self, client_mac): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 809 | """Deauthenticates a client described in params. |
| 810 | |
Wade Guthrie | e4074dd | 2013-10-30 11:00:48 -0700 | [diff] [blame] | 811 | @param client_mac string containing the mac address of the client to be |
| 812 | deauthenticated. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 813 | |
| 814 | """ |
Paul Stewart | aa52e8c | 2011-05-24 08:46:23 -0700 | [diff] [blame] | 815 | self.router.run('%s -p%s deauthenticate %s' % |
| 816 | (self.cmd_hostapd_cli, |
| 817 | self.hostapd['conf']['ctrl_interface'], |
Wade Guthrie | e4074dd | 2013-10-30 11:00:48 -0700 | [diff] [blame] | 818 | client_mac)) |
| 819 | |
| 820 | |
| 821 | @base_utils.deprecated |
| 822 | def deauth(self, params): |
| 823 | """Deauthenticates a client described in params. |
| 824 | |
| 825 | Deprecated: Call 'deauth_client', instead. |
| 826 | |
| 827 | @param params dict containing a key 'client'. |
| 828 | |
| 829 | """ |
| 830 | self.deauth_client(params['client']) |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 831 | |
| 832 | |
Paul Stewart | 51b0f38 | 2013-06-12 09:03:02 -0700 | [diff] [blame] | 833 | def send_management_frame(self, frame_type, instance=0): |
| 834 | """Injects a management frame into an active hostapd session. |
| 835 | |
| 836 | @param frame_type string the type of frame to send. |
| 837 | @param instance int indicating which hostapd instance to inject into. |
| 838 | |
| 839 | """ |
| 840 | hostap_interface = self.hostapd_instances[instance]['interface'] |
| 841 | interface = self._get_wlanif(0, 'monitor', same_phy_as=hostap_interface) |
| 842 | self.router.run("%s link set %s up" % (self.cmd_ip, interface)) |
| 843 | self.router.run('%s %s %s' % |
| 844 | (self.cmd_send_management_frame, interface, frame_type)) |
| 845 | self._release_wlanif(interface) |
| 846 | |
| 847 | |
Paul Stewart | 2553694 | 2013-08-15 17:33:42 -0700 | [diff] [blame] | 848 | def detect_client_deauth(self, client_mac, instance=0): |
| 849 | """Detects whether hostapd has logged a deauthentication from |
| 850 | |client_mac|. |
| 851 | |
| 852 | @param client_mac string the MAC address of the client to detect. |
| 853 | @param instance int indicating which hostapd instance to query. |
| 854 | |
| 855 | """ |
| 856 | interface = self.hostapd_instances[instance]['interface'] |
| 857 | deauth_msg = "%s: deauthentication: STA=%s" % (interface, client_mac) |
| 858 | log_file = self.hostapd_instances[instance]['log_file'] |
| 859 | result = self.router.run("grep -qi '%s' %s" % (deauth_msg, log_file), |
| 860 | ignore_status=True) |
| 861 | return result.exit_status == 0 |
| 862 | |
| 863 | |
Paul Stewart | 4ae471e | 2013-09-04 15:42:35 -0700 | [diff] [blame] | 864 | def detect_client_coexistence_report(self, client_mac, instance=0): |
| 865 | """Detects whether hostapd has logged an action frame from |
| 866 | |client_mac| indicating information about 20/40MHz BSS coexistence. |
| 867 | |
| 868 | @param client_mac string the MAC address of the client to detect. |
| 869 | @param instance int indicating which hostapd instance to query. |
| 870 | |
| 871 | """ |
| 872 | coex_msg = ('nl80211: MLME event frame - hexdump(len=.*): ' |
| 873 | '.. .. .. .. .. .. .. .. .. .. %s ' |
| 874 | '.. .. .. .. .. .. .. .. 04 00.*48 01 ..' % |
| 875 | ' '.join(client_mac.split(':'))) |
| 876 | log_file = self.hostapd_instances[instance]['log_file'] |
| 877 | result = self.router.run("grep -qi '%s' %s" % (coex_msg, log_file), |
| 878 | ignore_status=True) |
| 879 | return result.exit_status == 0 |
| 880 | |
| 881 | |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 882 | def _pre_config_hook(self, config): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 883 | """Hook for subclasses. |
| 884 | |
| 885 | Run after gathering configuration parameters, |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 886 | but before writing parameters to config file. |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 887 | |
| 888 | @param config dict containing hostapd config parameters. |
| 889 | |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 890 | """ |
| 891 | pass |
| 892 | |
| 893 | |
| 894 | def _pre_start_hook(self, params): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 895 | """Hook for subclasses. |
| 896 | |
| 897 | Run after generating hostapd config file, but before starting hostapd. |
| 898 | |
| 899 | @param params dict parameters from site_wifitest. |
| 900 | |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 901 | """ |
| 902 | pass |
| 903 | |
| 904 | |
| 905 | def _post_start_hook(self, params): |
Christopher Wiley | f99e6cc | 2013-04-19 10:12:43 -0700 | [diff] [blame] | 906 | """Hook for subclasses run after starting hostapd. |
| 907 | |
| 908 | @param params dict parameters from site_wifitest. |
| 909 | |
| 910 | """ |
mukesh agrawal | fe0e85b | 2011-08-09 14:24:15 -0700 | [diff] [blame] | 911 | pass |