Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: server/site_linux_router.py

Issue 1812002: More work on wifi tests (Closed)
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | server/site_wifitest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 # Remove all wifi devices. 79 # Remove all wifi devices.
80 output = self.router.run("%s dev" % self.cmd_iw).stdout 80 output = self.router.run("%s dev" % self.cmd_iw).stdout
81 test = re.compile("[\s]*Interface (.*)") 81 test = re.compile("[\s]*Interface (.*)")
82 for line in output.splitlines(): 82 for line in output.splitlines():
83 m = test.match(line) 83 m = test.match(line)
84 if m: 84 if m:
85 device = m.group(1) 85 device = m.group(1)
86 self.router.run("%s link set %s down" % (self.cmd_ip, device)) 86 self.router.run("%s link set %s down" % (self.cmd_ip, device))
87 self.router.run("%s dev %s del" % (self.cmd_iw, device)) 87 self.router.run("%s dev %s del" % (self.cmd_iw, device))
88 88
89 # Place us in the US by default
90 self.router.run("%s reg set US" % self.cmd_iw)
89 91
90 def create(self, params): 92 def create(self, params):
91 """ Create a wifi device of the specified type """ 93 """ Create a wifi device of the specified type """
92 # 94 #
93 # AP mode is handled entirely by hostapd so we only 95 # AP mode is handled entirely by hostapd so we only
94 # have to setup others (mapping the bsd type to what 96 # have to setup others (mapping the bsd type to what
95 # iw wants) 97 # iw wants)
96 # 98 #
97 # map from bsd types to iw types 99 # map from bsd types to iw types
98 if params['type'] == "ap" or params['type'] == "hostap": 100 if params['type'] == "ap" or params['type'] == "hostap":
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 conf['channel'] = (freq - 2407) / 5 153 conf['channel'] = (freq - 2407) / 5
152 # Channel 14 is an exception 154 # Channel 14 is an exception
153 elif freq == 2484: 155 elif freq == 2484:
154 conf['channel'] = 14 156 conf['channel'] = 14
155 # 5GHz 157 # 5GHz
156 else: 158 else:
157 # Make sure hw_mode is set 159 # Make sure hw_mode is set
158 conf['hw_mode'] = 'a' 160 conf['hw_mode'] = 'a'
159 # Freq = 5 * chan + 4000 161 # Freq = 5 * chan + 4000
160 if freq >= 4915 and freq <= 4980: 162 if freq >= 4915 and freq <= 4980:
161 conf['channel'] = 183 + (freq - 4915) / 5 163 conf['channel'] = (freq - 4000) / 5
162 # Freq = 5 * chan + 5000 164 # Freq = 5 * chan + 5000
163 elif freq >= 5035 and freq <= 5825: 165 elif freq >= 5035 and freq <= 5825:
164 conf['channel'] = (freq - 5000) / 5 166 conf['channel'] = (freq - 5000) / 5
165 167
166 elif k == 'country': 168 elif k == 'country':
167 conf['country_code'] = v 169 conf['country_code'] = v
168 elif k == 'dotd': 170 elif k == 'dotd':
169 conf['ieee80211d'] = 1 171 conf['ieee80211d'] = 1
170 elif k == '-dotd': 172 elif k == '-dotd':
171 conf['ieee80211d'] = 0 173 conf['ieee80211d'] = 0
172 elif k == 'mode': 174 elif k == 'mode':
173 if v == '11a': 175 if v == '11a':
174 conf['hw_mode'] = 'a' 176 conf['hw_mode'] = 'a'
175 elif v == '11g': 177 elif v == '11g':
176 conf['hw_mode'] = 'g' 178 conf['hw_mode'] = 'g'
177 elif v == '11b': 179 elif v == '11b':
178 conf['hw_mode'] = 'b' 180 conf['hw_mode'] = 'b'
179 elif v == '11n': 181 elif v == '11n':
180 conf['ieee80211n'] = 1 182 conf['ieee80211n'] = 1
181 elif k == 'bintval': 183 elif k == 'bintval':
182 conf['beacon_int'] = v 184 conf['beacon_int'] = v
183 elif k == 'dtimperiod': 185 elif k == 'dtimperiod':
184 conf['dtim_period'] = v 186 conf['dtim_period'] = v
185 elif k == 'rtsthreshold': 187 elif k == 'rtsthreshold':
186 conf['rts_threshold'] = v 188 conf['rts_threshold'] = v
187 elif k == 'fragthreshold': 189 elif k == 'fragthreshold':
188 conf['fragm_threshold'] = v 190 conf['fragm_threshold'] = v
189 elif k == 'shortpreamble': 191 elif k == 'shortpreamble':
190 conf['preamble'] = 1 192 conf['preamble'] = 1
191 elif k == 'protmode':
192 pass # TODO(sleffler) need hostapd support
193 elif k == 'authmode': 193 elif k == 'authmode':
194 if v == "open": 194 if v == "open":
195 conf['auth_algs'] = 1 195 conf['auth_algs'] = 1
196 elif v == "shared": 196 elif v == "shared":
197 conf['auth_algs'] = 2 197 conf['auth_algs'] = 2
198 elif k == 'hidessid': 198 elif k == 'hidessid':
199 conf['ignore_broadcast_ssid'] = 1 199 conf['ignore_broadcast_ssid'] = 1
200 elif k == 'wme': 200 elif k == 'wme':
201 conf['wmm_enabled'] = 1 201 conf['wmm_enabled'] = 1
202 elif k == '-wme': 202 elif k == '-wme':
203 conf['wmm_enabled'] = 0 203 conf['wmm_enabled'] = 0
204 elif k == 'deftxkey': 204 elif k == 'deftxkey':
205 conf['wep_default_key'] = v 205 conf['wep_default_key'] = v
206 elif k == 'ht20': 206 elif k == 'ht20':
207 htcaps.add('') # NB: ensure 802.11n setup below 207 htcaps.add('') # NB: ensure 802.11n setup below
208 conf['wmm_enabled'] = 1 208 conf['wmm_enabled'] = 1
209 elif k == 'ht40': 209 elif k == 'ht40':
210 htcaps.add('[HT40-]') 210 htcaps.add('[HT40-]')
211 htcaps.add('[HT40+]') 211 htcaps.add('[HT40+]')
212 conf['wmm_enabled'] = 1 212 conf['wmm_enabled'] = 1
213 elif k == 'shortgi': 213 elif k == 'shortgi':
214 htcaps.add('[SHORT-GI-20]') 214 htcaps.add('[SHORT-GI-20]')
215 htcaps.add('[SHORT-GI-40]') 215 htcaps.add('[SHORT-GI-40]')
216 elif k == 'pureg': 216 elif k == 'pureg':
217 pass # TODO(sleffler) need hostapd support 217 pass # TODO(sleffler) need hostapd support
218 elif k == 'puren': 218 elif k == 'puren':
219 pass # TODO(sleffler) need hostapd support 219 pass # TODO(sleffler) need hostapd support
220 elif k == 'protmode':
221 pass # TODO(sleffler) need hostapd support
220 elif k == 'ht': 222 elif k == 'ht':
221 htcaps.add('') # NB: ensure 802.11n setup below 223 htcaps.add('') # NB: ensure 802.11n setup below
222 elif k == 'htprotmode': 224 elif k == 'htprotmode':
223 pass # TODO(sleffler) need hostapd support 225 pass # TODO(sleffler) need hostapd support
224 elif k == 'rifs': 226 elif k == 'rifs':
225 pass # TODO(sleffler) need hostapd support 227 pass # TODO(sleffler) need hostapd support
226 elif k == 'wepmode': 228 elif k == 'wepmode':
227 pass # NB: meaningless for hostapd; ignore 229 pass # NB: meaningless for hostapd; ignore
230 elif k == '-ampdu':
231 pass # TODO(sleffler) need hostapd support
228 else: 232 else:
229 conf[k] = v 233 conf[k] = v
230 234
231 # Aggregate ht_capab. 235 # Aggregate ht_capab.
232 if htcaps: 236 if htcaps:
233 conf['ieee80211n'] = 1 237 conf['ieee80211n'] = 1
234 conf['ht_capab'] = ''.join(htcaps) 238 conf['ht_capab'] = ''.join(htcaps)
235 239
236 # Generate hostapd.conf. 240 # Generate hostapd.conf.
237 self.router.run("cat <<EOF >%s\n%s\nEOF\n" % 241 self.router.run("cat <<EOF >%s\n%s\nEOF\n" %
(...skipping 30 matching lines...) Expand all
268 self.router.run("pkill hostapd >/dev/null 2>&1", ignore_status=True) 272 self.router.run("pkill hostapd >/dev/null 2>&1", ignore_status=True)
269 # self.router.run("rm -f %s" % self.hostapd['file']) 273 # self.router.run("rm -f %s" % self.hostapd['file'])
270 274
271 # Tear down the bridge. 275 # Tear down the bridge.
272 self.router.run("%s link set %s down" % (self.cmd_ip, self.bridgeif), 276 self.router.run("%s link set %s down" % (self.cmd_ip, self.bridgeif),
273 ignore_status=True) 277 ignore_status=True)
274 self.router.run("%s delbr %s" % (self.cmd_brctl, self.bridgeif), 278 self.router.run("%s delbr %s" % (self.cmd_brctl, self.bridgeif),
275 ignore_status=True) 279 ignore_status=True)
276 280
277 self.hostapd['configured'] = False 281 self.hostapd['configured'] = False
OLDNEW
« no previous file with comments | « no previous file | server/site_wifitest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698