running configuration and deltas and shit
[CBFWR.git] / bin / cbfwrd.php
index 7271d4a..b8360e5 100644 (file)
@@ -21,6 +21,7 @@ error_log("CBFWRD starting");
 
 
 $config = new Config();
+global $config;
 
 if(isset($argv[1])) {
        if($argv[1] == "boot") {
@@ -35,13 +36,13 @@ $cont = true;
 
 // setup our sem/shm stuff
 
-// this stuff needs to go in comms
+// do the initial stuff
+$comms = new Comms;
+$config->loadConfig();
+$rawconf = $config->getConfig();
+$comms->putConfig($rawconf);
+
 while($cont) {
-       $comms = new Comms;
-       
-       $config->loadConfig();
-       $comms->putConfig($config->getConfig());
-       
        $msg = $comms->waitForMessage();
        
        //echo "Got message: $msg\n";
@@ -52,11 +53,37 @@ while($cont) {
 
 function cbfwd_commandProcessor($command)
 {
+       global $config;
        $cmds = explode(" ", $command);
+       $comms = new Comms;
        
+       $comms->lockConfigs();
        switch($cmds[0]) {
-               case "...":
+               case "goodone":
+                       break;
+                       
+               // interface change requests
+               case "interface":
+                       $int = $cmds[1];
+                       if($cmds[2] == "changename") {
+                               $rawconf = $comms->getConfig();
+                               if(isset($rawconf["interface"]["$int"]["name"])) $rawconf["interface"]["$int"]["name"] = $cmds[3];
+                               $comms->putConfig($rawconf);
+                       }
                        break;
+                       
+               case "zone":
+                       $cmd = $cmds[1];
+                       switch($cmd) {
+                               case "add":
+                                       $zonename = $cmds[2];
+                                       $rawconf = $comms->getConfig();
+                                       $rawconf["zone"][$zonename]["name"] = 1;
+                                       $comms->putConfig($rawconf);
+                                       break;
+                                       
+                       }
        }
+       $comms->unlockConfigs();
 }
 ?>
\ No newline at end of file