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

Side by Side Diff: server/site_linux_router.py

Issue 1763012: more WiFi testing fixes (Closed)
Patch Set: use rstrip to chop \n's 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') | server/site_wifitest.py » ('J')
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 13 matching lines...) Expand all
24 # Command locations. 24 # Command locations.
25 self.cmd_iw = "/usr/sbin/iw" 25 self.cmd_iw = "/usr/sbin/iw"
26 self.cmd_ip = "/usr/sbin/ip" 26 self.cmd_ip = "/usr/sbin/ip"
27 self.cmd_brctl = "/usr/sbin/brctl" 27 self.cmd_brctl = "/usr/sbin/brctl"
28 self.cmd_hostapd = "/usr/sbin/hostapd" 28 self.cmd_hostapd = "/usr/sbin/hostapd"
29 29
30 # Router host. 30 # Router host.
31 self.router = host 31 self.router = host
32 32
33 # Network interfaces. 33 # Network interfaces.
34 self.bridgeif = params.get('bridgeif', "br-lan") 34 self.bridgeif = params.get('bridgedev', "br-lan")
35 self.wiredif = params.get('wiredif', "eth1") 35 self.wiredif = params.get('wiredev', "eth1")
36 self.wlanif = "wlan0" 36 self.wlanif = "wlan0"
37 37
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)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 self.hostapd['driver']) 135 self.hostapd['driver'])
136 136
137 for k, v in params.iteritems(): 137 for k, v in params.iteritems():
138 if k == 'ssid': 138 if k == 'ssid':
139 conf['ssid'] = v 139 conf['ssid'] = v
140 elif k == 'channel': 140 elif k == 'channel':
141 freq = int(v) 141 freq = int(v)
142 142
143 # 2.4GHz 143 # 2.4GHz
144 if freq < 2500: 144 if freq < 2500:
145 if conf['hw_mode'] == 'a': 145 # TODO(sleffler) what's this for?
146 if conf.get('hw_mode') == 'a':
146 conf['hw_mode'] = 'b' 147 conf['hw_mode'] = 'b'
147 148
148 # Freq = 5 * chan + 2407 149 # Freq = 5 * chan + 2407
149 if freq >= 2412 and freq <= 2472: 150 if freq >= 2412 and freq <= 2472:
150 conf['channel'] = (freq - 2407) / 5 151 conf['channel'] = (freq - 2407) / 5
151 # Channel 14 is an exception 152 # Channel 14 is an exception
152 elif freq == 2484: 153 elif freq == 2484:
153 conf['channel'] = 14 154 conf['channel'] = 14
154 # 5GHz 155 # 5GHz
155 else: 156 else:
(...skipping 23 matching lines...) Expand all
179 elif k == 'bintval': 180 elif k == 'bintval':
180 conf['beacon_int'] = v 181 conf['beacon_int'] = v
181 elif k == 'dtimperiod': 182 elif k == 'dtimperiod':
182 conf['dtim_period'] = v 183 conf['dtim_period'] = v
183 elif k == 'rtsthreshold': 184 elif k == 'rtsthreshold':
184 conf['rts_threshold'] = v 185 conf['rts_threshold'] = v
185 elif k == 'fragthreshold': 186 elif k == 'fragthreshold':
186 conf['fragm_threshold'] = v 187 conf['fragm_threshold'] = v
187 elif k == 'shortpreamble': 188 elif k == 'shortpreamble':
188 conf['preamble'] = 1 189 conf['preamble'] = 1
190 elif k == 'protmode':
191 pass # TODO(sleffler) need hostapd support
189 elif k == 'authmode': 192 elif k == 'authmode':
190 if v == "open": 193 if v == "open":
191 conf['auth_algs'] = 1 194 conf['auth_algs'] = 1
192 elif v == "shared": 195 elif v == "shared":
193 conf['auth_algs'] = 2 196 conf['auth_algs'] = 2
194 elif k == 'hidessid': 197 elif k == 'hidessid':
195 conf['ignore_broadcast_ssid'] = 1 198 conf['ignore_broadcast_ssid'] = 1
196 elif k == 'wme': 199 elif k == 'wme':
197 conf['wmm_enabled'] = 1 200 conf['wmm_enabled'] = 1
198 elif k == '-wme': 201 elif k == '-wme':
199 conf['wmm_enabled'] = 0 202 conf['wmm_enabled'] = 0
200 elif k == 'deftxkey': 203 elif k == 'deftxkey':
201 conf['wep_default_key'] = v 204 conf['wep_default_key'] = v
202 elif k == 'ht20': 205 elif k == 'ht20':
206 htcaps.add('') # NB: ensure 802.11n setup below
203 conf['wmm_enabled'] = 1 207 conf['wmm_enabled'] = 1
204 elif k == 'ht40': 208 elif k == 'ht40':
205 htcaps.add('[HT40-]') 209 htcaps.add('[HT40-]')
206 htcaps.add('[HT40+]') 210 htcaps.add('[HT40+]')
207 conf['wmm_enabled'] = 1 211 conf['wmm_enabled'] = 1
208 elif k == 'shortgi': 212 elif k == 'shortgi':
209 htcaps.add('[SHORT-GI-20]') 213 htcaps.add('[SHORT-GI-20]')
210 htcaps.add('[SHORT-GI-40]') 214 htcaps.add('[SHORT-GI-40]')
211 elif k == 'pureg' or k == 'puren' or k == 'wepmode' \ 215 elif k == 'pureg':
212 or k == 'rifs' or k == 'protmode': 216 pass # TODO(sleffler) need hostapd support
213 # no support 217 elif k == 'puren':
214 pass 218 pass # TODO(sleffler) need hostapd support
219 elif k == 'ht':
220 htcaps.add('') # NB: ensure 802.11n setup below
221 elif k == 'htprotmode':
222 pass # TODO(sleffler) need hostapd support
223 elif k == 'rifs':
224 pass # TODO(sleffler) need hostapd support
225 elif k == 'wepmode':
226 pass # NB: meaningless for hostapd; ignore
215 else: 227 else:
216 conf[k] = v 228 conf[k] = v
217 229
218 # Aggregate ht_capab. 230 # Aggregate ht_capab.
219 if htcaps: 231 if htcaps:
220 conf['ieee80211n'] = 1 232 conf['ieee80211n'] = 1
221 conf['ht_capab'] = ''.join(htcaps) 233 conf['ht_capab'] = ''.join(htcaps)
222 234
223 # Generate hostapd.conf. 235 # Generate hostapd.conf.
224 self.router.run("cat <<EOF >%s\n%s\nEOF\n" % 236 self.router.run("cat <<EOF >%s\n%s\nEOF\n" %
(...skipping 30 matching lines...) Expand all
255 self.router.run("pkill hostapd >/dev/null 2>&1", ignore_status=True) 267 self.router.run("pkill hostapd >/dev/null 2>&1", ignore_status=True)
256 # self.router.run("rm -f %s" % self.hostapd['file']) 268 # self.router.run("rm -f %s" % self.hostapd['file'])
257 269
258 # Tear down the bridge. 270 # Tear down the bridge.
259 self.router.run("%s link set %s down" % (self.cmd_ip, self.bridgeif), 271 self.router.run("%s link set %s down" % (self.cmd_ip, self.bridgeif),
260 ignore_status=True) 272 ignore_status=True)
261 self.router.run("%s delbr %s" % (self.cmd_brctl, self.bridgeif), 273 self.router.run("%s delbr %s" % (self.cmd_brctl, self.bridgeif),
262 ignore_status=True) 274 ignore_status=True)
263 275
264 self.hostapd['configured'] = False 276 self.hostapd['configured'] = False
265
266 def client_check_config(self, params):
267 """
268 Check network configuration on client to verify parameters
269 have been negotiated during the connection to the router.
270 """
271 # XXX fill in
OLDNEW
« no previous file with comments | « no previous file | server/site_wifitest.py » ('j') | server/site_wifitest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698