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 re | 5 import re |
6 | 6 |
7 def isLinuxRouter(router): | 7 def isLinuxRouter(router): |
8 router_uname = router.run('uname').stdout | 8 router_uname = router.run('uname').stdout |
9 return re.search('Linux', router_uname) | 9 return re.search('Linux', router_uname) |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 # Default to 1st available wireless phy. | 38 # Default to 1st available wireless phy. |
39 if "phydev" not in params: | 39 if "phydev" not in params: |
40 output = self.router.run("%s list" % self.cmd_iw).stdout | 40 output = self.router.run("%s list" % self.cmd_iw).stdout |
41 test = re.compile("Wiphy (.*)") | 41 test = re.compile("Wiphy (.*)") |
42 for line in output.splitlines(): | 42 for line in output.splitlines(): |
43 m = test.match(line) | 43 m = test.match(line) |
44 if m: | 44 if m: |
45 self.phydev = m.group(1) | 45 self.phydev = m.group(1) |
46 break | 46 break |
47 else: | 47 else: |
48 raise Exception("No Wireless NIC detected on the device") | 48 raise error.TestFail("No Wireless NIC detected on the device") |
49 else: | 49 else: |
50 self.phydev = params['phydev'] | 50 self.phydev = params['phydev'] |
51 | 51 |
52 | 52 |
53 # hostapd configuration persists throughout the test, subsequent | 53 # hostapd configuration persists throughout the test, subsequent |
54 # 'config' commands only modify it. | 54 # 'config' commands only modify it. |
55 self.hostapd = { | 55 self.hostapd = { |
56 'configured': False, | 56 'configured': False, |
57 'file': "/tmp/%s.conf" % self.phydev, | 57 'file': "/tmp/%s.conf" % self.phydev, |
58 'driver': "nl80211", | 58 'driver': "nl80211", |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 """ Configure the AP per test requirements """ | 124 """ Configure the AP per test requirements """ |
125 | 125 |
126 if self.hostapd['configured']: | 126 if self.hostapd['configured']: |
127 self.deconfig({}) | 127 self.deconfig({}) |
128 | 128 |
129 if self.apmode: | 129 if self.apmode: |
130 # Construct the hostapd.conf file and start hostapd. | 130 # Construct the hostapd.conf file and start hostapd. |
131 conf = self.hostapd['conf'] | 131 conf = self.hostapd['conf'] |
132 htcaps = set() | 132 htcaps = set() |
133 | 133 |
134 conf['driver'] = params.get('hostapd_driver', self.hostapd['driver']
) | 134 conf['driver'] = params.get('hostapd_driver', |
| 135 self.hostapd['driver']) |
135 | 136 |
136 for k, v in params.iteritems(): | 137 for k, v in params.iteritems(): |
137 if k == 'ssid': | 138 if k == 'ssid': |
138 conf['ssid'] = v | 139 conf['ssid'] = v |
139 elif k == 'channel': | 140 elif k == 'channel': |
140 freq = int(v) | 141 freq = int(v) |
141 | 142 |
142 # 2.4GHz | 143 # 2.4GHz |
143 if freq < 2500: | 144 if freq < 2500: |
144 if conf['hw_mode'] == 'a': | 145 if conf['hw_mode'] == 'a': |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 conf['wep_default_key'] = v | 201 conf['wep_default_key'] = v |
201 elif k == 'ht20': | 202 elif k == 'ht20': |
202 conf['wmm_enabled'] = 1 | 203 conf['wmm_enabled'] = 1 |
203 elif k == 'ht40': | 204 elif k == 'ht40': |
204 htcaps.add('[HT40-]') | 205 htcaps.add('[HT40-]') |
205 htcaps.add('[HT40+]') | 206 htcaps.add('[HT40+]') |
206 conf['wmm_enabled'] = 1 | 207 conf['wmm_enabled'] = 1 |
207 elif k == 'shortgi': | 208 elif k == 'shortgi': |
208 htcaps.add('[SHORT-GI-20]') | 209 htcaps.add('[SHORT-GI-20]') |
209 htcaps.add('[SHORT-GI-40]') | 210 htcaps.add('[SHORT-GI-40]') |
210 elif k == 'pureg' or k == 'puren' or k == 'wepmode' or k == 'rif
s': | 211 elif k == 'pureg' or k == 'puren' or k == 'wepmode' \ |
| 212 or k == 'rifs' or k == 'protmode': |
211 # no support | 213 # no support |
212 pass | 214 pass |
213 else: | 215 else: |
214 conf[k] = v | 216 conf[k] = v |
215 | 217 |
216 # Aggregate ht_capab. | 218 # Aggregate ht_capab. |
217 if htcaps: | 219 if htcaps: |
218 conf['ieee80211n'] = 1 | 220 conf['ieee80211n'] = 1 |
219 conf['ht_capab'] = ''.join(htcaps) | 221 conf['ht_capab'] = ''.join(htcaps) |
220 | 222 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 ignore_status=True) | 262 ignore_status=True) |
261 | 263 |
262 self.hostapd['configured'] = False | 264 self.hostapd['configured'] = False |
263 | 265 |
264 def client_check_config(self, params): | 266 def client_check_config(self, params): |
265 """ | 267 """ |
266 Check network configuration on client to verify parameters | 268 Check network configuration on client to verify parameters |
267 have been negotiated during the connection to the router. | 269 have been negotiated during the connection to the router. |
268 """ | 270 """ |
269 # XXX fill in | 271 # XXX fill in |
OLD | NEW |