config stuff
authorpaulr <me@pjr.cc>
Thu, 22 Sep 2011 07:14:44 +0000 (17:14 +1000)
committerpaulr <me@pjr.cc>
Thu, 22 Sep 2011 07:14:44 +0000 (17:14 +1000)
libcbfwr/comms.php
libcbfwr/config.php
libcbfwr/fwui.php
libcbfwr/web.php
unittests/deleteshm.php [new file with mode: 0644]

index b0c4f04..7f89650 100644 (file)
@@ -37,6 +37,13 @@ class Comms {
                sem_release($this->semres);
        }
        
+       function deleteConfig($type)
+       {
+               global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY, $CONF_STORE_SIZE;
+               $shm_space = shm_attach($STORE_KEY, $CONF_STORE_SIZE);
+               
+               shm_remove_var($shm_space, $type);
+       }
        
        // type = 0 for the fs config
        // type = 1 for the boot hardware config
index 3c7a54f..3720d6a 100644 (file)
@@ -63,6 +63,7 @@ class Config {
                                        }
                                        fclose($fp);
                                }
+                               if(file_exists("/sys/class/net/$fname/mtu")) $this->config["hardware"]["netdev"][$fname]["mtu"] = file_get_contents("/sys/class/net/$fname/mtu");
                                if(file_exists("/sys/class/net/$fname/address")) $this->config["hardware"]["netdev"][$fname]["hwaddress"] = file_get_contents("/sys/class/net/$fname/address");
                                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;
index decadf2..5d78f38 100644 (file)
@@ -122,6 +122,9 @@ function CBFWInterfacesPageDisplay()
                
                // hw address
                if(isset($val["hwaddress"])) $table[$key]["hwaddress"] = $val["hwaddress"];
+               
+               // current mtu
+               if(isset($val["mtu"])) $table[$key]["mtu"] = $val["mtu"];
        }
        
        foreach($config["hardware"]["netdev"] as $key=>$val) {
index 87e7bf4..562d1db 100644 (file)
@@ -83,13 +83,17 @@ function CBFBuildHomePage($urls)
 {
        echo "Must remember this, gotta rules could apply to multiple zones not just one<br>";
        echo "i.e.: add rule reject from object/host/hostname to address6/2003::123 in zones Zone/zonename/rulenum Zone/zonename/rulenum";
-       $conf = new Config();
-       $conf->loadConfig();
+       
+       $comms = new Comms();
        
        echo "<pre>";
-       print_r($conf->getConfig());
+       print_r($comms->getConfig(0));
+       echo "\n\n\n";
+       print_r($comms->getConfig(1));
+       echo "\n\n\n";
+       print_r($comms->getConfig(2));
        echo "\n\n\n";
-       print_r($conf->getBootConfig());
+       print_r($comms->getConfig(3));
        echo "</pre>";
        
 }
diff --git a/unittests/deleteshm.php b/unittests/deleteshm.php
new file mode 100644 (file)
index 0000000..d773aa4
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+$CMD_ROOT_FS = realpath(dirname(__FILE__));
+$AM_DAEMON = false;
+
+global $CMD_ROOT_FS;
+global $AM_DAEMON;
+
+// add libglcas as if it were a path in ../libglcas
+if(file_exists("../libcbfwr")) {
+       $path = realpath($CMD_ROOT_FS."/../");
+       error_log("added cbfwr path as $path");
+       set_include_path(get_include_path().PATH_SEPARATOR.$path);
+}
+
+// include the based library
+require_once("libcbfwr/lib.php");
+
+glcas_pluginLoader();
+
+$comms = new Comms();
+
+for($i=0; $i<10; $i++) $comms->deleteConfig($i);
+
+?>
\ No newline at end of file