X-Git-Url: http://git.pjr.cc/?p=CBFWR.git;a=blobdiff_plain;f=bin%2Fcbfwrd.php;h=b8360e59edff9d8079bc2bf1f1d2981ae09f24ca;hp=3b2987015833f4447399c32120aee6037ad63c6c;hb=0f5458e4a9c18595f7d9501880011369e4e65942;hpb=90e37664d8296ebb5f3aae443b44b09f95826e90 diff --git a/bin/cbfwrd.php b/bin/cbfwrd.php index 3b29870..b8360e5 100644 --- a/bin/cbfwrd.php +++ b/bin/cbfwrd.php @@ -19,23 +19,71 @@ glcas_pluginLoader(); error_log("CBFWRD starting"); + $config = new Config(); +global $config; + +if(isset($argv[1])) { + if($argv[1] == "boot") { + // we get called here on boot. + $config->bootHardware(); + exit(0); + } +} // now we got into daemon modes $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; - - $comms->putConfig($config->getConfig()); - $msg = $comms->waitForMessage(); //echo "Got message: $msg\n"; + if($msg == "quit") $cont = false; + else cbfwd_commandProcessor($msg); +} + + +function cbfwd_commandProcessor($command) +{ + global $config; + $cmds = explode(" ", $command); + $comms = new Comms; - $cont = false; + $comms->lockConfigs(); + switch($cmds[0]) { + 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