more hardware probes.
authorpaulr <me@pjr.cc>
Mon, 19 Sep 2011 17:45:30 +0000 (03:45 +1000)
committerpaulr <me@pjr.cc>
Mon, 19 Sep 2011 17:45:30 +0000 (03:45 +1000)
libcbfwr/config.php

index e63f13c..d9a8eb2 100644 (file)
@@ -36,10 +36,10 @@ class Config {
                        }
                        
                        if($this->config["status"] == "conf") {
+                               
                                $this->loadConfig($this->config_file);
-                               print_r($this->config);
-                               $this->config = array();
                                $this->findHardware();
+                               
                                print_r($this->config);
                                $this->applyConfig();
                        } else {
@@ -57,18 +57,23 @@ class Config {
                // first, network interfaces
                $dh = opendir("/sys/class/net/");
                while(($fname = readdir($dh)) !== false) {
-                       if($fname != "." && $fname != ".." && $fname != "lo") {
-                               $this->config["hardware"]["netdev"][$fname]["int"] = true;
+                       if($fname != "." && $fname != ".." && $fname != "lo" && is_dir("/sys/class/net/$fname/")) {
+                               $this->config["hardware"]["netdev"][$fname]["name"] = $fname;
                                // now read drive name if you can
-                               $fp = fopen("/sys/class/net/$fname/device/uevent", "r");
-                               if($fp) while(!feof($fp)) {
-                                       $line = trim(fgets($fp));
-                                       $lpl = explode("=", $line);
-                                       if($lpl[0] == "DRIVER") {
-                                               $this->config["hardware"]["netdev"][$fname]["driver"] = $lpl[1];
+                               if(file_exists("/sys/class/net/$fname/device/uevent")) $fp = fopen("/sys/class/net/$fname/device/uevent", "r");
+                               else $fp = false;
+                               if($fp) {
+                                       while(!feof($fp)) {
+                                               $line = trim(fgets($fp));
+                                               $lpl = explode("=", $line);
+                                               if($lpl[0] == "DRIVER") {
+                                                       $this->config["hardware"]["netdev"][$fname]["driver"] = $lpl[1];
+                                               }
                                        }
+                                       fclose($fp);
                                }
-                               fclose($fp);
+                               if(file_exists("/sys/class/net/$fname/bonding")) $this->config["hardware"]["netdev"][$fname]["bonding"] = true;
+                               if(file_exists("/sys/class/net/$fname/bridge")) $this->config["hardware"]["netdev"][$fname]["bridge"] = true;
                        }
                }
        }