changes on behalf of acid-burn
[enigma2.git] / lib / python / Components / Network.py
index 79ec1ed64f1831d3620b5ba14fed76968801a130..56506a50b725217bd03389cde93f15c221199a3a 100644 (file)
@@ -88,9 +88,9 @@ class Network:
                                data['mac'] = mac
                if not data.has_key('ip'):
                        data['dhcp'] = True
-                       data['ip'] = [192, 168, 1, 2]
-                       data['netmask'] = [255, 255, 255, 0]
-                       data['gateway'] = [192, 168, 1, 1]
+                       data['ip'] = [0, 0, 0, 0]
+                       data['netmask'] = [0, 0, 0, 0]
+                       data['gateway'] = [0, 0, 0, 0]
                        
                fp = popen("route -n | grep  " + iface)
                result = fp.readlines()
@@ -163,14 +163,25 @@ class Network:
                        if (currif != ""):
                                if (split[0] == "address"):
                                        ifaces[currif]["address"] = map(int, split[1].split('.'))
+                                       if self.ifaces[currif].has_key("ip"):
+                                               if self.ifaces[currif]["ip"] != ifaces[currif]["address"] and ifaces[currif]["dhcp"] == False:
+                                                       self.ifaces[currif]["ip"] = map(int, split[1].split('.'))
                                if (split[0] == "netmask"):
                                        ifaces[currif]["netmask"] = map(int, split[1].split('.'))
+                                       if self.ifaces[currif].has_key("netmask"):
+                                               if self.ifaces[currif]["netmask"] != ifaces[currif]["netmask"] and ifaces[currif]["dhcp"] == False:
+                                                       self.ifaces[currif]["netmask"] = map(int, split[1].split('.'))
                                if (split[0] == "gateway"):
                                        ifaces[currif]["gateway"] = map(int, split[1].split('.'))
+                                       if self.ifaces[currif].has_key("gateway"):
+                                               if self.ifaces[currif]["gateway"] != ifaces[currif]["gateway"] and ifaces[currif]["dhcp"] == False:
+                                                       self.ifaces[currif]["gateway"] = map(int, split[1].split('.'))                                  
                                if (split[0] == "pre-up"):
-                                       self.ifaces[currif]["preup"] = i
+                                       if self.ifaces[currif].has_key("preup"):
+                                               self.ifaces[currif]["preup"] = i
                                if (split[0] == "post-down"):
-                                       self.ifaces[currif]["postdown"] = i
+                                       if self.ifaces[currif].has_key("postdown"):
+                                               self.ifaces[currif]["postdown"] = i
 
                print "read interfaces:", ifaces
                for ifacename, iface in ifaces.items():
@@ -323,6 +334,12 @@ class Network:
                self.container.appClosed.get().remove(self.cmdFinished)
                self.container.dataAvail.get().remove(self.dataAvail)
 
+       def stopContainer(self):
+               self.container.kill()
+               
+       def ContainerRunning(self):
+               return self.container.running()
+
        def checkforInterface(self,iface):
                if self.getAdapterAttribute(iface, 'up') is True:
                        return True