| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging, re, time | 5 import logging, re, time |
| 6 from autotest_lib.client.common_lib import error | 6 from autotest_lib.client.common_lib import error |
| 7 | 7 |
| 8 def isLinuxRouter(router): | 8 def isLinuxRouter(router): |
| 9 router_uname = router.run('uname').stdout | 9 router_uname = router.run('uname').stdout |
| 10 return re.search('Linux', router_uname) | 10 return re.search('Linux', router_uname) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 self.hostapd = { | 78 self.hostapd = { |
| 79 'configured': False, | 79 'configured': False, |
| 80 'file': "/tmp/hostapd-test.conf", | 80 'file': "/tmp/hostapd-test.conf", |
| 81 'driver': "nl80211", | 81 'driver': "nl80211", |
| 82 'conf': { | 82 'conf': { |
| 83 'ssid': defssid, | 83 'ssid': defssid, |
| 84 'bridge': self.bridgeif, | 84 'bridge': self.bridgeif, |
| 85 'hw_mode': 'g' | 85 'hw_mode': 'g' |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 self.station = { |
| 89 'configured': False, |
| 90 'conf': { |
| 91 'ssid': defssid, |
| 92 } |
| 93 } |
| 89 # Kill hostapd if already running. | 94 # Kill hostapd if already running. |
| 90 self.router.run("pkill hostapd >/dev/null 2>&1", ignore_status=True) | 95 self.router.run("pkill hostapd >/dev/null 2>&1", ignore_status=True) |
| 91 | 96 |
| 92 # Remove all bridges. | 97 # Remove all bridges. |
| 93 output = self.router.run("%s show" % self.cmd_brctl).stdout | 98 output = self.router.run("%s show" % self.cmd_brctl).stdout |
| 94 test = re.compile("^(\S+).*") | 99 test = re.compile("^(\S+).*") |
| 95 for line in output.splitlines()[1:]: | 100 for line in output.splitlines()[1:]: |
| 96 m = test.match(line) | 101 m = test.match(line) |
| 97 if m: | 102 if m: |
| 98 device = m.group(1) | 103 device = m.group(1) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 113 self.router.run("%s reg set US" % self.cmd_iw) | 118 self.router.run("%s reg set US" % self.cmd_iw) |
| 114 | 119 |
| 115 def create(self, params): | 120 def create(self, params): |
| 116 """ Create a wifi device of the specified type """ | 121 """ Create a wifi device of the specified type """ |
| 117 # | 122 # |
| 118 # AP mode is handled entirely by hostapd so we only | 123 # AP mode is handled entirely by hostapd so we only |
| 119 # have to setup others (mapping the bsd type to what | 124 # have to setup others (mapping the bsd type to what |
| 120 # iw wants) | 125 # iw wants) |
| 121 # | 126 # |
| 122 # map from bsd types to iw types | 127 # map from bsd types to iw types |
| 123 if params['type'] == "ap" or params['type'] == "hostap": | 128 self.apmode = params['type'] in ("ap", "hostap") |
| 124 self.apmode = True | 129 if not self.apmode: |
| 130 self.station['type'] = params['type'] |
| 125 phytype = { | 131 phytype = { |
| 126 "sta" : "managed", | 132 "sta" : "managed", |
| 127 "monitor" : "monitor", | 133 "monitor" : "monitor", |
| 128 "adhoc" : "adhoc", | 134 "adhoc" : "adhoc", |
| 129 "ibss" : "ibss", | 135 "ibss" : "ibss", |
| 130 "ap" : "managed", # NB: handled by hostapd | 136 "ap" : "managed", # NB: handled by hostapd |
| 131 "hostap" : "managed", # NB: handled by hostapd | 137 "hostap" : "managed", # NB: handled by hostapd |
| 132 "mesh" : "mesh", | 138 "mesh" : "mesh", |
| 133 "wds" : "wds", | 139 "wds" : "wds", |
| 134 }[params['type']] | 140 }[params['type']] |
| 135 | 141 |
| 136 self.router.run("%s phy %s interface add %s type %s" % | 142 self.router.run("%s phy %s interface add %s type %s" % |
| 137 (self.cmd_iw, self.phydev2, self.wlanif2, phytype)) | 143 (self.cmd_iw, self.phydev2, self.wlanif2, phytype)) |
| 138 self.router.run("%s phy %s interface add %s type %s" % | 144 self.router.run("%s phy %s interface add %s type %s" % |
| 139 (self.cmd_iw, self.phydev5, self.wlanif5, phytype)) | 145 (self.cmd_iw, self.phydev5, self.wlanif5, phytype)) |
| 140 | 146 |
| 141 | 147 |
| 142 def destroy(self, params): | 148 def destroy(self, params): |
| 143 """ Destroy a previously created device """ | 149 """ Destroy a previously created device """ |
| 144 # For linux, this is the same as deconfig. | 150 # For linux, this is the same as deconfig. |
| 145 self.deconfig(params) | 151 self.deconfig(params) |
| 146 | 152 |
| 147 | 153 |
| 148 | 154 |
| 149 def config(self, params): | 155 def hostap_config(self, params): |
| 150 """ Configure the AP per test requirements """ | 156 """ Configure the AP per test requirements """ |
| 151 | 157 |
| 152 multi_interface = 'multi_interface' in params | 158 multi_interface = 'multi_interface' in params |
| 153 if multi_interface: | 159 if multi_interface: |
| 154 params.pop('multi_interface') | 160 params.pop('multi_interface') |
| 155 elif self.hostapd['configured']: | 161 elif self.hostapd['configured'] or self.station['configured']: |
| 156 self.deconfig({}) | 162 self.deconfig({}) |
| 157 | 163 |
| 164 # Construct the hostapd.conf file and start hostapd. |
| 165 conf = self.hostapd['conf'] |
| 166 tx_power_params = {} |
| 167 htcaps = set() |
| 168 |
| 169 conf['driver'] = params.get('hostapd_driver', |
| 170 self.hostapd['driver']) |
| 171 |
| 172 for k, v in params.iteritems(): |
| 173 if k == 'ssid': |
| 174 conf['ssid'] = v |
| 175 elif k == 'ssid_suffix': |
| 176 conf['ssid'] = self.defssid + v |
| 177 elif k == 'channel': |
| 178 freq = int(v) |
| 179 |
| 180 # 2.4GHz |
| 181 if freq <= 2484: |
| 182 # Make sure hw_mode is set |
| 183 if conf.get('hw_mode') == 'a': |
| 184 conf['hw_mode'] = 'g' |
| 185 |
| 186 # Freq = 5 * chan + 2407, except channel 14 |
| 187 if freq == 2484: |
| 188 conf['channel'] = 14 |
| 189 else: |
| 190 conf['channel'] = (freq - 2407) / 5 |
| 191 # 5GHz |
| 192 else: |
| 193 # Make sure hw_mode is set |
| 194 conf['hw_mode'] = 'a' |
| 195 # Freq = 5 * chan + 4000 |
| 196 if freq < 5000: |
| 197 conf['channel'] = (freq - 4000) / 5 |
| 198 # Freq = 5 * chan + 5000 |
| 199 else: |
| 200 conf['channel'] = (freq - 5000) / 5 |
| 201 |
| 202 elif k == 'country': |
| 203 conf['country_code'] = v |
| 204 elif k == 'dotd': |
| 205 conf['ieee80211d'] = 1 |
| 206 elif k == '-dotd': |
| 207 conf['ieee80211d'] = 0 |
| 208 elif k == 'mode': |
| 209 if v == '11a': |
| 210 conf['hw_mode'] = 'a' |
| 211 elif v == '11g': |
| 212 conf['hw_mode'] = 'g' |
| 213 elif v == '11b': |
| 214 conf['hw_mode'] = 'b' |
| 215 elif v == '11n': |
| 216 conf['ieee80211n'] = 1 |
| 217 elif k == 'bintval': |
| 218 conf['beacon_int'] = v |
| 219 elif k == 'dtimperiod': |
| 220 conf['dtim_period'] = v |
| 221 elif k == 'rtsthreshold': |
| 222 conf['rts_threshold'] = v |
| 223 elif k == 'fragthreshold': |
| 224 conf['fragm_threshold'] = v |
| 225 elif k == 'shortpreamble': |
| 226 conf['preamble'] = 1 |
| 227 elif k == 'authmode': |
| 228 if v == "open": |
| 229 conf['auth_algs'] = 1 |
| 230 elif v == "shared": |
| 231 conf['auth_algs'] = 2 |
| 232 elif k == 'hidessid': |
| 233 conf['ignore_broadcast_ssid'] = 1 |
| 234 elif k == 'wme': |
| 235 conf['wmm_enabled'] = 1 |
| 236 elif k == '-wme': |
| 237 conf['wmm_enabled'] = 0 |
| 238 elif k == 'deftxkey': |
| 239 conf['wep_default_key'] = v |
| 240 elif k == 'ht20': |
| 241 htcaps.add('') # NB: ensure 802.11n setup below |
| 242 conf['wmm_enabled'] = 1 |
| 243 elif k == 'ht40': |
| 244 htcaps.add('[HT40-]') |
| 245 htcaps.add('[HT40+]') |
| 246 conf['wmm_enabled'] = 1 |
| 247 elif k == 'shortgi': |
| 248 htcaps.add('[SHORT-GI-20]') |
| 249 htcaps.add('[SHORT-GI-40]') |
| 250 elif k == 'pureg': |
| 251 pass # TODO(sleffler) need hostapd support |
| 252 elif k == 'puren': |
| 253 pass # TODO(sleffler) need hostapd support |
| 254 elif k == 'protmode': |
| 255 pass # TODO(sleffler) need hostapd support |
| 256 elif k == 'ht': |
| 257 htcaps.add('') # NB: ensure 802.11n setup below |
| 258 elif k == 'htprotmode': |
| 259 pass # TODO(sleffler) need hostapd support |
| 260 elif k == 'rifs': |
| 261 pass # TODO(sleffler) need hostapd support |
| 262 elif k == 'wepmode': |
| 263 pass # NB: meaningless for hostapd; ignore |
| 264 elif k == '-ampdu': |
| 265 pass # TODO(sleffler) need hostapd support |
| 266 elif k == 'txpower': |
| 267 tx_power_params['power'] = v |
| 268 else: |
| 269 conf[k] = v |
| 270 |
| 271 # Aggregate ht_capab. |
| 272 if htcaps: |
| 273 conf['ieee80211n'] = 1 |
| 274 conf['ht_capab'] = ''.join(htcaps) |
| 275 |
| 276 # Figure out the correct interface. |
| 277 if conf.get('hw_mode', 'b') == 'a': |
| 278 conf['interface'] = self.wlanif5 |
| 279 else: |
| 280 conf['interface'] = self.wlanif2 |
| 281 |
| 282 # Generate hostapd.conf. |
| 283 self.router.run("cat <<EOF >%s\n%s\nEOF\n" % |
| 284 (self.hostapd['file'], '\n'.join( |
| 285 "%s=%s" % kv for kv in conf.iteritems()))) |
| 286 |
| 287 if not multi_interface: |
| 288 logging.info("Initializing bridge...") |
| 289 self.router.run("%s addbr %s" % |
| 290 (self.cmd_brctl, self.bridgeif)) |
| 291 self.router.run("%s setfd %s %d" % |
| 292 (self.cmd_brctl, self.bridgeif, 0)) |
| 293 self.router.run("%s stp %s %d" % |
| 294 (self.cmd_brctl, self.bridgeif, 0)) |
| 295 |
| 296 # Run hostapd. |
| 297 logging.info("Starting hostapd...") |
| 298 self.router.run("%s -B %s" % |
| 299 (self.cmd_hostapd, self.hostapd['file'])) |
| 300 |
| 301 |
| 302 # Set up the bridge. |
| 303 if not multi_interface: |
| 304 logging.info("Setting up the bridge...") |
| 305 self.router.run("%s addif %s %s" % |
| 306 (self.cmd_brctl, self.bridgeif, self.wiredif)) |
| 307 self.router.run("%s link set %s up" % |
| 308 (self.cmd_ip, self.wiredif)) |
| 309 self.router.run("%s link set %s up" % |
| 310 (self.cmd_ip, self.bridgeif)) |
| 311 self.hostapd['interface'] = conf['interface'] |
| 312 else: |
| 313 tx_power_params['interface'] = conf['interface'] |
| 314 |
| 315 # Configure transmit power |
| 316 self.set_txpower(tx_power_params) |
| 317 |
| 318 logging.info("AP configured.") |
| 319 |
| 320 self.hostapd['configured'] = True |
| 321 |
| 322 |
| 323 def station_config(self, params): |
| 324 multi_interface = 'multi_interface' in params |
| 325 if multi_interface: |
| 326 params.pop('multi_interface') |
| 327 elif self.station['configured'] or self.hostapd['configured']: |
| 328 self.deconfig({}) |
| 329 |
| 330 interface = self.wlanif2 |
| 331 conf = self.station['conf'] |
| 332 for k, v in params.iteritems(): |
| 333 if k == 'ssid_suffix': |
| 334 conf['ssid'] = self.defssid + v |
| 335 elif k == 'channel': |
| 336 freq = int(v) |
| 337 if freq > 2484: |
| 338 interface = self.wlanif5 |
| 339 elif k == 'mode': |
| 340 if v == '11a': |
| 341 interface = self.wlanif5 |
| 342 else: |
| 343 conf[k] = v |
| 344 |
| 345 if not multi_interface: |
| 346 logging.info("Initializing bridge...") |
| 347 self.router.run("%s addbr %s" % |
| 348 (self.cmd_brctl, self.bridgeif)) |
| 349 self.router.run("%s setfd %s %d" % |
| 350 (self.cmd_brctl, self.bridgeif, 0)) |
| 351 self.router.run("%s stp %s %d" % |
| 352 (self.cmd_brctl, self.bridgeif, 0)) |
| 353 |
| 354 # Run interface configuration commands |
| 355 for k, v in conf.iteritems(): |
| 356 if k != 'ssid': |
| 357 self.router.run("%s dev %s set %s %s" % |
| 358 (self.cmd_iw, interface, k, v)) |
| 359 |
| 360 # Connect the station |
| 361 self.router.run("%s link set %s up" % (self.cmd_ip, interface)) |
| 362 connect_cmd = ('ibss join' if self.station['type'] == 'ibss' |
| 363 else 'connect') |
| 364 self.router.run("%s dev %s %s %s %d" % |
| 365 (self.cmd_iw, interface, connect_cmd, |
| 366 conf['ssid'], freq)) |
| 367 |
| 368 # Add wireless interface to the bridge |
| 369 self.router.run("%s addif %s %s" % |
| 370 (self.cmd_brctl, self.bridgeif, interface)) |
| 371 |
| 372 # Add interface to the bridge. |
| 373 # Bring up the bridge |
| 374 if not multi_interface: |
| 375 logging.info("Setting up the bridge...") |
| 376 self.router.run("%s addif %s %s" % |
| 377 (self.cmd_brctl, self.bridgeif, self.wiredif)) |
| 378 self.router.run("%s link set %s up" % |
| 379 (self.cmd_ip, self.wiredif)) |
| 380 self.router.run("%s link set %s up" % |
| 381 (self.cmd_ip, self.bridgeif)) |
| 382 |
| 383 self.station['configured'] = True |
| 384 self.station['interface'] = interface |
| 385 |
| 386 |
| 387 def config(self, params): |
| 158 if self.apmode: | 388 if self.apmode: |
| 159 # Construct the hostapd.conf file and start hostapd. | 389 self.hostap_config(params) |
| 160 conf = self.hostapd['conf'] | 390 else: |
| 161 tx_power_params = {} | 391 self.station_config(params) |
| 162 htcaps = set() | |
| 163 | |
| 164 conf['driver'] = params.get('hostapd_driver', | |
| 165 self.hostapd['driver']) | |
| 166 | |
| 167 for k, v in params.iteritems(): | |
| 168 if k == 'ssid': | |
| 169 conf['ssid'] = v | |
| 170 elif k == 'ssid_suffix': | |
| 171 conf['ssid'] = self.defssid + v | |
| 172 elif k == 'channel': | |
| 173 freq = int(v) | |
| 174 | |
| 175 # 2.4GHz | |
| 176 if freq <= 2484: | |
| 177 # Make sure hw_mode is set | |
| 178 if conf.get('hw_mode') == 'a': | |
| 179 conf['hw_mode'] = 'g' | |
| 180 | |
| 181 # Freq = 5 * chan + 2407, except channel 14 | |
| 182 if freq == 2484: | |
| 183 conf['channel'] = 14 | |
| 184 else: | |
| 185 conf['channel'] = (freq - 2407) / 5 | |
| 186 # 5GHz | |
| 187 else: | |
| 188 # Make sure hw_mode is set | |
| 189 conf['hw_mode'] = 'a' | |
| 190 # Freq = 5 * chan + 4000 | |
| 191 if freq < 5000: | |
| 192 conf['channel'] = (freq - 4000) / 5 | |
| 193 # Freq = 5 * chan + 5000 | |
| 194 else: | |
| 195 conf['channel'] = (freq - 5000) / 5 | |
| 196 | |
| 197 elif k == 'country': | |
| 198 conf['country_code'] = v | |
| 199 elif k == 'dotd': | |
| 200 conf['ieee80211d'] = 1 | |
| 201 elif k == '-dotd': | |
| 202 conf['ieee80211d'] = 0 | |
| 203 elif k == 'mode': | |
| 204 if v == '11a': | |
| 205 conf['hw_mode'] = 'a' | |
| 206 elif v == '11g': | |
| 207 conf['hw_mode'] = 'g' | |
| 208 elif v == '11b': | |
| 209 conf['hw_mode'] = 'b' | |
| 210 elif v == '11n': | |
| 211 conf['ieee80211n'] = 1 | |
| 212 elif k == 'bintval': | |
| 213 conf['beacon_int'] = v | |
| 214 elif k == 'dtimperiod': | |
| 215 conf['dtim_period'] = v | |
| 216 elif k == 'rtsthreshold': | |
| 217 conf['rts_threshold'] = v | |
| 218 elif k == 'fragthreshold': | |
| 219 conf['fragm_threshold'] = v | |
| 220 elif k == 'shortpreamble': | |
| 221 conf['preamble'] = 1 | |
| 222 elif k == 'authmode': | |
| 223 if v == "open": | |
| 224 conf['auth_algs'] = 1 | |
| 225 elif v == "shared": | |
| 226 conf['auth_algs'] = 2 | |
| 227 elif k == 'hidessid': | |
| 228 conf['ignore_broadcast_ssid'] = 1 | |
| 229 elif k == 'wme': | |
| 230 conf['wmm_enabled'] = 1 | |
| 231 elif k == '-wme': | |
| 232 conf['wmm_enabled'] = 0 | |
| 233 elif k == 'deftxkey': | |
| 234 conf['wep_default_key'] = v | |
| 235 elif k == 'ht20': | |
| 236 htcaps.add('') # NB: ensure 802.11n setup below | |
| 237 conf['wmm_enabled'] = 1 | |
| 238 elif k == 'ht40': | |
| 239 htcaps.add('[HT40-]') | |
| 240 htcaps.add('[HT40+]') | |
| 241 conf['wmm_enabled'] = 1 | |
| 242 elif k == 'shortgi': | |
| 243 htcaps.add('[SHORT-GI-20]') | |
| 244 htcaps.add('[SHORT-GI-40]') | |
| 245 elif k == 'pureg': | |
| 246 pass # TODO(sleffler) need hostapd support | |
| 247 elif k == 'puren': | |
| 248 pass # TODO(sleffler) need hostapd support | |
| 249 elif k == 'protmode': | |
| 250 pass # TODO(sleffler) need hostapd support | |
| 251 elif k == 'ht': | |
| 252 htcaps.add('') # NB: ensure 802.11n setup below | |
| 253 elif k == 'htprotmode': | |
| 254 pass # TODO(sleffler) need hostapd support | |
| 255 elif k == 'rifs': | |
| 256 pass # TODO(sleffler) need hostapd support | |
| 257 elif k == 'wepmode': | |
| 258 pass # NB: meaningless for hostapd; ignore | |
| 259 elif k == '-ampdu': | |
| 260 pass # TODO(sleffler) need hostapd support | |
| 261 elif k == 'txpower': | |
| 262 tx_power_params['power'] = v | |
| 263 else: | |
| 264 conf[k] = v | |
| 265 | |
| 266 # Aggregate ht_capab. | |
| 267 if htcaps: | |
| 268 conf['ieee80211n'] = 1 | |
| 269 conf['ht_capab'] = ''.join(htcaps) | |
| 270 | |
| 271 # Figure out the correct interface. | |
| 272 if conf.get('hw_mode', 'b') == 'a': | |
| 273 conf['interface'] = self.wlanif5 | |
| 274 else: | |
| 275 conf['interface'] = self.wlanif2 | |
| 276 | |
| 277 # Generate hostapd.conf. | |
| 278 self.router.run("cat <<EOF >%s\n%s\nEOF\n" % | |
| 279 (self.hostapd['file'], '\n'.join( | |
| 280 "%s=%s" % kv for kv in conf.iteritems()))) | |
| 281 | |
| 282 if not multi_interface: | |
| 283 logging.info("Initializing bridge...") | |
| 284 self.router.run("%s addbr %s" % | |
| 285 (self.cmd_brctl, self.bridgeif)) | |
| 286 self.router.run("%s setfd %s %d" % | |
| 287 (self.cmd_brctl, self.bridgeif, 0)) | |
| 288 self.router.run("%s stp %s %d" % | |
| 289 (self.cmd_brctl, self.bridgeif, 0)) | |
| 290 | |
| 291 # Run hostapd. | |
| 292 logging.info("Starting hostapd...") | |
| 293 self.router.run("%s -B %s" % | |
| 294 (self.cmd_hostapd, self.hostapd['file'])) | |
| 295 | |
| 296 | |
| 297 # Set up the bridge. | |
| 298 if not multi_interface: | |
| 299 logging.info("Setting up the bridge...") | |
| 300 self.router.run("%s addif %s %s" % | |
| 301 (self.cmd_brctl, self.bridgeif, self.wiredif)) | |
| 302 self.router.run("%s link set %s up" % | |
| 303 (self.cmd_ip, self.wiredif)) | |
| 304 self.router.run("%s link set %s up" % | |
| 305 (self.cmd_ip, self.bridgeif)) | |
| 306 self.hostapd['interface'] = conf['interface'] | |
| 307 else: | |
| 308 tx_power_params['interface'] = conf['interface'] | |
| 309 | |
| 310 # Configure transmit power | |
| 311 self.set_txpower(tx_power_params) | |
| 312 | |
| 313 logging.info("AP configured.") | |
| 314 | |
| 315 # else: | |
| 316 # # use iw to manually configure interface | |
| 317 | |
| 318 self.hostapd['configured'] = True | |
| 319 | 392 |
| 320 | 393 |
| 321 def deconfig(self, params): | 394 def deconfig(self, params): |
| 322 """ De-configure the AP (will also bring wlan and the bridge down) """ | 395 """ De-configure the AP (will also bring wlan and the bridge down) """ |
| 323 | 396 |
| 324 if not self.hostapd['configured']: | 397 if not self.hostapd['configured'] and not self.station['configured']: |
| 325 return | 398 return |
| 326 | 399 |
| 327 # Taking down hostapd takes wlan0 and mon.wlan0 down. | 400 # Taking down hostapd takes wlan0 and mon.wlan0 down. |
| 328 self.router.run("pkill hostapd >/dev/null 2>&1", ignore_status=True) | 401 if self.hostapd['configured']: |
| 329 # self.router.run("rm -f %s" % self.hostapd['file']) | 402 self.router.run("pkill hostapd >/dev/null 2>&1", ignore_status=True) |
| 403 # self.router.run("rm -f %s" % self.hostapd['file']) |
| 404 if self.station['configured']: |
| 405 if self.station['type'] == 'ibss': |
| 406 self.router.run("%s dev %s ibss leave" % |
| 407 (self.cmd_iw, self.station['interface'])) |
| 408 else: |
| 409 self.router.run("%s dev %s disconnect" % |
| 410 (self.cmd_iw, self.station['interface'])) |
| 411 self.router.run("%s link set %s down" % (self.cmd_ip, |
| 412 self.station['interface'])) |
| 330 | 413 |
| 331 # Try a couple times to remove the bridge; hostapd may still be exiting | 414 # Try a couple times to remove the bridge; hostapd may still be exiting |
| 332 for attempt in range(3): | 415 for attempt in range(3): |
| 333 self.router.run("%s link set %s down" % | 416 self.router.run("%s link set %s down" % |
| 334 (self.cmd_ip, self.bridgeif), ignore_status=True) | 417 (self.cmd_ip, self.bridgeif), ignore_status=True) |
| 335 | 418 |
| 336 result = self.router.run("%s delbr %s" % | 419 result = self.router.run("%s delbr %s" % |
| 337 (self.cmd_brctl, self.bridgeif), | 420 (self.cmd_brctl, self.bridgeif), |
| 338 ignore_status=True) | 421 ignore_status=True) |
| 339 if not result.stderr or 'No such device' in result.stderr: | 422 if not result.stderr or 'No such device' in result.stderr: |
| 340 break | 423 break |
| 341 time.sleep(1) | 424 time.sleep(1) |
| 342 else: | 425 else: |
| 343 raise error.TestFail("Unable to delete bridge %s: %s" % | 426 raise error.TestFail("Unable to delete bridge %s: %s" % |
| 344 (self.bridgeif, result.stderr)) | 427 (self.bridgeif, result.stderr)) |
| 345 | 428 |
| 346 | 429 |
| 347 self.hostapd['configured'] = False | 430 self.hostapd['configured'] = False |
| 431 self.station['configured'] = False |
| 348 | 432 |
| 349 | 433 |
| 350 def get_ssid(self): | 434 def get_ssid(self): |
| 351 return self.hostapd['conf']['ssid'] | 435 return self.hostapd['conf']['ssid'] |
| 352 | 436 |
| 353 | 437 |
| 354 def set_txpower(self, params): | 438 def set_txpower(self, params): |
| 355 self.router.run("%s dev %s set txpower %s" % | 439 self.router.run("%s dev %s set txpower %s" % |
| 356 (self.cmd_iw, params.get('interface', | 440 (self.cmd_iw, params.get('interface', |
| 357 self.hostapd['interface']), | 441 self.hostapd['interface']), |
| 358 params.get('power', 'auto'))) | 442 params.get('power', 'auto'))) |
| OLD | NEW |