mirror of
https://github.com/gryf/wicd.git
synced 2025-12-21 21:38:06 +01:00
Fix scanning of hidden networks
This commit is contained in:
@@ -269,9 +269,12 @@ class WirelessInterface(Interface, BaseWirelessInterface):
|
||||
self.CheckWirelessTools()
|
||||
|
||||
@neediface([])
|
||||
def GetNetworks(self):
|
||||
def GetNetworks(self, essid=None):
|
||||
""" Get a list of available wireless networks.
|
||||
|
||||
NOTE: the essid parameter is not used here,
|
||||
it was added for the iwlist scan for hidden networks.
|
||||
|
||||
Returns:
|
||||
A list containing available wireless networks.
|
||||
|
||||
|
||||
@@ -648,6 +648,7 @@ class Wireless(Controller):
|
||||
|
||||
# If there is a hidden essid then set it now, so that when it is
|
||||
# scanned it will be recognized.
|
||||
# Note: this does not always work, sometimes we have to pass it with "iwlist wlan0 scan essid -- XXXXX"
|
||||
essid = misc.Noneify(essid)
|
||||
if essid is not None:
|
||||
print 'Setting hidden essid ' + essid
|
||||
@@ -655,7 +656,7 @@ class Wireless(Controller):
|
||||
# sleep for a bit; scanning to fast will result in nothing
|
||||
time.sleep(1)
|
||||
|
||||
aps = wiface.GetNetworks()
|
||||
aps = wiface.GetNetworks(essid)
|
||||
aps.sort(cmp=comp, reverse=True)
|
||||
|
||||
return aps
|
||||
|
||||
@@ -1339,14 +1339,23 @@ class BaseWirelessInterface(BaseInterface):
|
||||
misc.Run(cmd)
|
||||
|
||||
@neediface([])
|
||||
def GetNetworks(self):
|
||||
def GetNetworks(self, essid=None):
|
||||
""" Get a list of available wireless networks.
|
||||
|
||||
Returns:
|
||||
A list containing available wireless networks.
|
||||
|
||||
"""
|
||||
|
||||
cmd = 'iwlist ' + self.iface + ' scan'
|
||||
|
||||
# If there is a hidden essid then it was set earlier, with iwconfig wlan0 essid,
|
||||
# but on some drivers (iwlwifi, in my case) we have to pass it to iwlist scan.
|
||||
essid = misc.Noneify(essid)
|
||||
if essid is not None:
|
||||
print 'Passing hidden essid to iwlist scan: ' + essid
|
||||
cmd = cmd + ' essid ' + essid
|
||||
|
||||
if self.verbose:
|
||||
print cmd
|
||||
results = misc.Run(cmd)
|
||||
|
||||
Reference in New Issue
Block a user