1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-22 05:48:03 +01:00

Fix scanning of hidden networks

This commit is contained in:
Tom Van Braeckel
2015-02-12 13:44:32 +01:00
parent b0184a6672
commit 8feb310a32
3 changed files with 16 additions and 3 deletions

View File

@@ -269,9 +269,12 @@ class WirelessInterface(Interface, BaseWirelessInterface):
self.CheckWirelessTools() self.CheckWirelessTools()
@neediface([]) @neediface([])
def GetNetworks(self): def GetNetworks(self, essid=None):
""" Get a list of available wireless networks. """ 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: Returns:
A list containing available wireless networks. A list containing available wireless networks.

View File

@@ -648,6 +648,7 @@ class Wireless(Controller):
# If there is a hidden essid then set it now, so that when it is # If there is a hidden essid then set it now, so that when it is
# scanned it will be recognized. # 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) essid = misc.Noneify(essid)
if essid is not None: if essid is not None:
print 'Setting hidden essid ' + essid print 'Setting hidden essid ' + essid
@@ -655,7 +656,7 @@ class Wireless(Controller):
# sleep for a bit; scanning to fast will result in nothing # sleep for a bit; scanning to fast will result in nothing
time.sleep(1) time.sleep(1)
aps = wiface.GetNetworks() aps = wiface.GetNetworks(essid)
aps.sort(cmp=comp, reverse=True) aps.sort(cmp=comp, reverse=True)
return aps return aps

View File

@@ -1339,14 +1339,23 @@ class BaseWirelessInterface(BaseInterface):
misc.Run(cmd) misc.Run(cmd)
@neediface([]) @neediface([])
def GetNetworks(self): def GetNetworks(self, essid=None):
""" Get a list of available wireless networks. """ Get a list of available wireless networks.
Returns: Returns:
A list containing available wireless networks. A list containing available wireless networks.
""" """
cmd = 'iwlist ' + self.iface + ' scan' 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: if self.verbose:
print cmd print cmd
results = misc.Run(cmd) results = misc.Run(cmd)