Merge branch 'acid-burn/networking_changes'
authoracid-burn <acid-burn@opendreambox.org>
Wed, 16 Mar 2011 15:13:20 +0000 (16:13 +0100)
committeracid-burn <acid-burn@opendreambox.org>
Wed, 16 Mar 2011 15:13:20 +0000 (16:13 +0100)
lib/python/Components/Network.py
lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py
lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py

index e980cb8c2f0dcd5a68a840297f1f8c0c323edcc8..0a01123679b7804fbad52742600d9b32bdbeff0e 100755 (executable)
@@ -171,11 +171,11 @@ class Network:
                                        if iface.has_key('gateway'):
                                                fp.write("      gateway %d.%d.%d.%d\n" % tuple(iface['gateway']))
                        if iface.has_key("configStrings"):
-                               fp.write("\n" + iface["configStrings"] + "\n")
+                               fp.write(iface["configStrings"])
                        if iface["preup"] is not False and not iface.has_key("configStrings"):
                                fp.write(iface["preup"])
                                fp.write(iface["postdown"])
-                       fp.write("\n")                          
+                       fp.write("\n")
                fp.close()
                self.writeNameserverConfig()
 
index baefd435846599e84293c55edb3363270f228471..480f201f53a50765ee478ba5385f857f22fb2a43 100755 (executable)
@@ -265,23 +265,22 @@ class wpaSupplicant:
                                fp.write('\tssid="'+essid+'"\n')
                        fp.write('\tscan_ssid=0\n')                     
                        if encrypted:
-                               if encryption == 'WPA' or encryption == 'WPA2' or encryption == 'WPA/WPA2' :
+                               if encryption in ('WPA', 'WPA2', 'WPA/WPA2'):
                                        fp.write('\tkey_mgmt=WPA-PSK\n')
-                                       
+               
                                        if encryption == 'WPA':
                                                fp.write('\tproto=WPA\n')
                                                fp.write('\tpairwise=TKIP\n')
                                                fp.write('\tgroup=TKIP\n')
                                        elif encryption == 'WPA2':
+                                               fp.write('\tproto=RSN\n')
+                                               fp.write('\tpairwise=CCMP\n')
+                                               fp.write('\tgroup=CCMP\n')
+                                       else:
                                                fp.write('\tproto=WPA RSN\n')
                                                fp.write('\tpairwise=CCMP TKIP\n')
-                                               fp.write('\tgroup=CCMP TKIP\n')                                         
-                                       else:
-                                               fp.write('\tproto=WPA WPA2\n')
-                                               fp.write('\tpairwise=CCMP\n')
-                                               fp.write('\tgroup=TKIP\n')                                      
+                                               fp.write('\tgroup=CCMP TKIP\n')
                                        fp.write('\tpsk="'+psk+'"\n')
-                                               
                                elif encryption == 'WEP':
                                        fp.write('\tkey_mgmt=NONE\n')
                                        if wepkeytype == 'ASCII':
@@ -319,23 +318,16 @@ class wpaSupplicant:
                                        
                                elif split[0] == 'proto':
                                        config.plugins.wlan.encryption.enabled.value = True
-                                       if split[1] == "WPA" :
+                                       if split[1] == 'WPA' :
                                                mode = 'WPA'
-                                       if split[1] == "WPA WPA2" :
-                                               mode = 'WPA/WPA2'
-                                       if split[1] == "WPA RSN" :
+                                       if split[1] == 'RSN':
                                                mode = 'WPA2'
+                                       if split[1] in ('WPA RSN', 'WPA WPA2'):
+                                               mode = 'WPA/WPA2'
+
                                        config.plugins.wlan.encryption.type.value = mode
                                        print "[Wlan.py] Got Encryption: "+mode
                                        
-                               #currently unused !
-                               #elif split[0] == 'key_mgmt':
-                               #       print "split[1]",split[1]
-                               #       if split[1] == "WPA-PSK" :
-                               #               config.plugins.wlan.encryption.enabled.value = True
-                               #               config.plugins.wlan.encryption.type.value = "WPA/WPA2"
-                               #       print "[Wlan.py] Got Encryption: "+ config.plugins.wlan.encryption.type.value
-                                       
                                elif split[0] == 'wep_key0':
                                        config.plugins.wlan.encryption.enabled.value = True
                                        config.plugins.wlan.encryption.type.value = 'WEP'
@@ -394,10 +386,6 @@ class wpaSupplicant:
                print "[Wlan.py] WS-CONFIG-->",wsconfig
                return wsconfig
 
-       
-       def restart(self, iface):
-               system("start-stop-daemon -K -x /usr/sbin/wpa_supplicant")
-               system("start-stop-daemon -S -x /usr/sbin/wpa_supplicant -- -B -i"+iface+" -c/etc/wpa_supplicant.conf")
 
 class Status:
        def __init__(self):
@@ -408,6 +396,7 @@ class Status:
        def stopWlanConsole(self):
                if self.WlanConsole is not None:
                        print "killing self.WlanConsole"
+                       self.WlanConsole.killAll()
                        self.WlanConsole = None
                        
        def getDataForInterface(self, iface, callback = None):
index adf47f0fa286fe3509d18f2a33c3b7e660528e35..efec340a22ee7a70011a699a21eec73d61b0a541 100644 (file)
@@ -454,13 +454,12 @@ def configStrings(iface):
                driver = iNetwork.detectWlanModule(iface)
        else:
                driver = 'dreambox'
-       if driver  in ('ralink', 'zydas'):
-               return "        pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -D"+driver+"\n        post-down wpa_cli terminate"
-       else:
-               if config.plugins.wlan.essid.value == "hidden...":
-                       return '        pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.hiddenessid.value+'"\n   pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -D'+driver+'\n    post-down wpa_cli terminate'
-               else:
-                       return '        pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.essid.value+'"\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -D'+driver+'\n    post-down wpa_cli terminate'
+       ret = ""
+       if driver == 'madwifi' and config.plugins.wlan.essid.value == "hidden...":
+               ret += "\tpre-up iwconfig " + iface + " essid \"" + config.plugins.wlan.hiddenessid.value + "\" || true\n"
+       ret += "\tpre-up wpa_supplicant -i" + iface + " -c/etc/wpa_supplicant.conf -B -dd -D" + driver + " || true\n"
+       ret += "\tpre-down wpa_cli -i" + iface + " terminate || true\n"
+       return ret
 
 def Plugins(**kwargs):
        return PluginDescriptor(name=_("Wireless LAN"), description=_("Connect to a Wireless Network"), where = PluginDescriptor.WHERE_NETWORKSETUP, needsRestart = False, fnc={"ifaceSupported": callFunction, "configStrings": configStrings, "WlanPluginEntry": lambda x: "Wireless Network Configuartion..."})