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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 multi_interface = 'multi_interface' in params | 152 multi_interface = 'multi_interface' in params |
153 if multi_interface: | 153 if multi_interface: |
154 params.pop('multi_interface') | 154 params.pop('multi_interface') |
155 elif self.hostapd['configured']: | 155 elif self.hostapd['configured']: |
156 self.deconfig({}) | 156 self.deconfig({}) |
157 | 157 |
158 if self.apmode: | 158 if self.apmode: |
159 # Construct the hostapd.conf file and start hostapd. | 159 # Construct the hostapd.conf file and start hostapd. |
160 conf = self.hostapd['conf'] | 160 conf = self.hostapd['conf'] |
| 161 tx_power_params = {} |
161 htcaps = set() | 162 htcaps = set() |
162 | 163 |
163 conf['driver'] = params.get('hostapd_driver', | 164 conf['driver'] = params.get('hostapd_driver', |
164 self.hostapd['driver']) | 165 self.hostapd['driver']) |
165 | 166 |
166 for k, v in params.iteritems(): | 167 for k, v in params.iteritems(): |
167 if k == 'ssid': | 168 if k == 'ssid': |
168 conf['ssid'] = v | 169 conf['ssid'] = v |
169 elif k == 'ssid_suffix': | 170 elif k == 'ssid_suffix': |
170 conf['ssid'] = self.defssid + v | 171 conf['ssid'] = self.defssid + v |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 elif k == 'ht': | 251 elif k == 'ht': |
251 htcaps.add('') # NB: ensure 802.11n setup below | 252 htcaps.add('') # NB: ensure 802.11n setup below |
252 elif k == 'htprotmode': | 253 elif k == 'htprotmode': |
253 pass # TODO(sleffler) need hostapd support | 254 pass # TODO(sleffler) need hostapd support |
254 elif k == 'rifs': | 255 elif k == 'rifs': |
255 pass # TODO(sleffler) need hostapd support | 256 pass # TODO(sleffler) need hostapd support |
256 elif k == 'wepmode': | 257 elif k == 'wepmode': |
257 pass # NB: meaningless for hostapd; ignore | 258 pass # NB: meaningless for hostapd; ignore |
258 elif k == '-ampdu': | 259 elif k == '-ampdu': |
259 pass # TODO(sleffler) need hostapd support | 260 pass # TODO(sleffler) need hostapd support |
| 261 elif k == 'txpower': |
| 262 tx_power_params['power'] = v |
260 else: | 263 else: |
261 conf[k] = v | 264 conf[k] = v |
262 | 265 |
263 # Aggregate ht_capab. | 266 # Aggregate ht_capab. |
264 if htcaps: | 267 if htcaps: |
265 conf['ieee80211n'] = 1 | 268 conf['ieee80211n'] = 1 |
266 conf['ht_capab'] = ''.join(htcaps) | 269 conf['ht_capab'] = ''.join(htcaps) |
267 | 270 |
268 # Figure out the correct interface. | 271 # Figure out the correct interface. |
269 if conf.get('hw_mode', 'b') == 'a': | 272 if conf.get('hw_mode', 'b') == 'a': |
(...skipping 24 matching lines...) Expand all Loading... |
294 # Set up the bridge. | 297 # Set up the bridge. |
295 if not multi_interface: | 298 if not multi_interface: |
296 logging.info("Setting up the bridge...") | 299 logging.info("Setting up the bridge...") |
297 self.router.run("%s addif %s %s" % | 300 self.router.run("%s addif %s %s" % |
298 (self.cmd_brctl, self.bridgeif, self.wiredif)) | 301 (self.cmd_brctl, self.bridgeif, self.wiredif)) |
299 self.router.run("%s link set %s up" % | 302 self.router.run("%s link set %s up" % |
300 (self.cmd_ip, self.wiredif)) | 303 (self.cmd_ip, self.wiredif)) |
301 self.router.run("%s link set %s up" % | 304 self.router.run("%s link set %s up" % |
302 (self.cmd_ip, self.bridgeif)) | 305 (self.cmd_ip, self.bridgeif)) |
303 self.hostapd['interface'] = conf['interface'] | 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) |
304 | 312 |
305 logging.info("AP configured.") | 313 logging.info("AP configured.") |
306 | 314 |
307 # else: | 315 # else: |
308 # # use iw to manually configure interface | 316 # # use iw to manually configure interface |
309 | 317 |
310 self.hostapd['configured'] = True | 318 self.hostapd['configured'] = True |
311 | 319 |
312 | 320 |
313 def deconfig(self, params): | 321 def deconfig(self, params): |
(...skipping 27 matching lines...) Expand all Loading... |
341 | 349 |
342 def get_ssid(self): | 350 def get_ssid(self): |
343 return self.hostapd['conf']['ssid'] | 351 return self.hostapd['conf']['ssid'] |
344 | 352 |
345 | 353 |
346 def set_txpower(self, params): | 354 def set_txpower(self, params): |
347 self.router.run("%s dev %s set txpower %s" % | 355 self.router.run("%s dev %s set txpower %s" % |
348 (self.cmd_iw, params.get('interface', | 356 (self.cmd_iw, params.get('interface', |
349 self.hostapd['interface']), | 357 self.hostapd['interface']), |
350 params.get('power', 'auto'))) | 358 params.get('power', 'auto'))) |
OLD | NEW |