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 from autotest_lib.server import site_eap_tls | 7 from autotest_lib.server import site_eap_tls |
8 | 8 |
9 def isLinuxRouter(router): | 9 def isLinuxRouter(router): |
10 router_uname = router.run('uname').stdout | 10 router_uname = router.run('uname').stdout |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 if conf.get('hw_mode', 'b') == 'a': | 272 if conf.get('hw_mode', 'b') == 'a': |
273 conf['interface'] = self.wlanif5 | 273 conf['interface'] = self.wlanif5 |
274 else: | 274 else: |
275 conf['interface'] = self.wlanif2 | 275 conf['interface'] = self.wlanif2 |
276 | 276 |
277 # Generate hostapd.conf. | 277 # Generate hostapd.conf. |
278 self.router.run("cat <<EOF >%s\n%s\nEOF\n" % | 278 self.router.run("cat <<EOF >%s\n%s\nEOF\n" % |
279 (self.hostapd['file'], '\n'.join( | 279 (self.hostapd['file'], '\n'.join( |
280 "%s=%s" % kv for kv in conf.iteritems()))) | 280 "%s=%s" % kv for kv in conf.iteritems()))) |
281 | 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 |
282 # Run hostapd. | 291 # Run hostapd. |
283 logging.info("Starting hostapd...") | 292 logging.info("Starting hostapd...") |
284 self.router.run("%s -B %s" % | 293 self.router.run("%s -B %s" % |
285 (self.cmd_hostapd, self.hostapd['file'])) | 294 (self.cmd_hostapd, self.hostapd['file'])) |
286 | 295 |
287 | 296 |
288 # Set up the bridge. | 297 # Set up the bridge. |
289 logging.info("Setting up the bridge...") | |
290 if not multi_interface: | 298 if not multi_interface: |
291 self.router.run("%s setfd %s %d" % | 299 logging.info("Setting up the bridge...") |
292 (self.cmd_brctl, self.bridgeif, 0)) | |
293 self.router.run("%s addif %s %s" % | 300 self.router.run("%s addif %s %s" % |
294 (self.cmd_brctl, self.bridgeif, self.wiredif)) | 301 (self.cmd_brctl, self.bridgeif, self.wiredif)) |
295 self.router.run("%s link set %s up" % | 302 self.router.run("%s link set %s up" % |
296 (self.cmd_ip, self.wiredif)) | 303 (self.cmd_ip, self.wiredif)) |
297 self.router.run("%s link set %s up" % | 304 self.router.run("%s link set %s up" % |
298 (self.cmd_ip, self.bridgeif)) | 305 (self.cmd_ip, self.bridgeif)) |
299 self.hostapd['interface'] = conf['interface'] | 306 self.hostapd['interface'] = conf['interface'] |
300 | 307 |
301 logging.info("AP configured.") | 308 logging.info("AP configured.") |
302 | 309 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 | 344 |
338 def get_ssid(self): | 345 def get_ssid(self): |
339 return self.hostapd['conf']['ssid'] | 346 return self.hostapd['conf']['ssid'] |
340 | 347 |
341 | 348 |
342 def set_txpower(self, params): | 349 def set_txpower(self, params): |
343 self.router.run("%s dev %s set txpower %s" % | 350 self.router.run("%s dev %s set txpower %s" % |
344 (self.cmd_iw, params.get('interface', | 351 (self.cmd_iw, params.get('interface', |
345 self.hostapd['interface']), | 352 self.hostapd['interface']), |
346 params.get('power', 'auto'))) | 353 params.get('power', 'auto'))) |
OLD | NEW |