From 641a91856da66f45a68226141958f46d8460c4b7 Mon Sep 17 00:00:00 2001 From: Daniel Hoffend Date: Thu, 27 Feb 2014 17:07:32 +0100 Subject: add support for quagga ospfd raw config support --- config/quagga_ospfd/quagga_ospfd.inc | 67 ++++++++++------------- config/quagga_ospfd/quagga_ospfd.xml | 11 +++- config/quagga_ospfd/quagga_ospfd_interfaces.xml | 4 ++ config/quagga_ospfd/quagga_ospfd_raw.xml | 71 +++++++++++++++++++++++++ config/quagga_ospfd/status_ospfd.php | 4 ++ 5 files changed, 117 insertions(+), 40 deletions(-) create mode 100644 config/quagga_ospfd/quagga_ospfd_raw.xml diff --git a/config/quagga_ospfd/quagga_ospfd.inc b/config/quagga_ospfd/quagga_ospfd.inc index 782baf0f..c709381a 100644 --- a/config/quagga_ospfd/quagga_ospfd.inc +++ b/config/quagga_ospfd/quagga_ospfd.inc @@ -74,20 +74,20 @@ function quagga_ospfd_install_conf() { $quagga_config_base = PKG_QUAGGA_CONFIG_BASE; $noaccept = ""; + + // generate ospfd.conf based on the assistant + if($config['installedpackages']['quaggaospfd']['config']) + $ospfd_conf = &$config['installedpackages']['quaggaospfd']['config'][0]; + else { + log_error("Quagga OSPFd: No config data found."); + return; + } - if ($config['installedpackages']['quaggaospfd']['rawconfig'] && $config['installedpackages']['quaggaospfd']['rawconfig']['item']) { + if (isset($config['installedpackages']['quaggaospfdraw']['config'][0]['ospfd']) + && !empty($config['installedpackages']['quaggaospfdraw']['config'][0]['ospfd'])) { // if there is a raw config specifyed in tthe config.xml use that instead of the assisted config - $conffile = implode("\n",$config['installedpackages']['quaggaospfd']['rawconfig']['item']); - //$conffile = $config['installedpackages']['quaggaospfd']['rawconfig']; + $conffile = str_replace("\r","",base64_decode($config['installedpackages']['quaggaospfdraw']['config'][0]['ospfd'])); } else { - // generate ospfd.conf based on the assistant - if($config['installedpackages']['quaggaospfd']['config']) - $ospfd_conf = &$config['installedpackages']['quaggaospfd']['config'][0]; - else { - log_error("Quagga OSPFd: No config data found."); - return; - } - $conffile = "# This file was created by the pfSense package manager. Do not edit!\n\n"; if($ospfd_conf['password']) @@ -242,17 +242,23 @@ function quagga_ospfd_install_conf() { fclose($fd); /* Make zebra config */ - $zebraconffile = "# This file was created by the pfSense package manager. Do not edit!\n\n"; - if($ospfd_conf['password']) - $zebraconffile .= "password {$ospfd_conf['password']}\n"; - if ($ospfd_conf['logging']) - $zebraconffile .= "log syslog\n"; - if (!empty($noaccept)) { - $zebraconffile .= $noaccept; - $zebraconffile .= "ip prefix-list ACCEPTFILTER permit any\n"; - $zebraconffile .= "route-map ACCEPTFILTER permit 10\n"; - $zebraconffile .= "match ip address prefix-list ACCEPTFILTER\n"; - $zebraconffile .= "ip protocol ospf route-map ACCEPTFILTER\n"; + if (isset($config['installedpackages']['quaggaospfdraw']['config'][0]['zebra']) + && !empty($config['installedpackages']['quaggaospfdraw']['config'][0]['zebra'])) { + // if there is a raw config specifyed in tthe config.xml use that instead of the assisted config + $zebraconffile = str_replace("\r","",base64_decode($config['installedpackages']['quaggaospfdraw']['config'][0]['zebra'])); + } else { + $zebraconffile = "# This file was created by the pfSense package manager. Do not edit!\n\n"; + if($ospfd_conf['password']) + $zebraconffile .= "password {$ospfd_conf['password']}\n"; + if ($ospfd_conf['logging']) + $zebraconffile .= "log syslog\n"; + if (!empty($noaccept)) { + $zebraconffile .= $noaccept; + $zebraconffile .= "ip prefix-list ACCEPTFILTER permit any\n"; + $zebraconffile .= "route-map ACCEPTFILTER permit 10\n"; + $zebraconffile .= "match ip address prefix-list ACCEPTFILTER\n"; + $zebraconffile .= "ip protocol ospf route-map ACCEPTFILTER\n"; + } } $fd = fopen("{$quagga_config_base}/zebra.conf", "w"); fwrite($fd, $zebraconffile); @@ -375,23 +381,6 @@ function quagga_ospfd_validate_input() { $input_errors[] = "Please select an interface to use for Quagga OSPFd."; } -// get the raw ospfd confi file for manual inspection/editing -function quagga_ospfd_get_raw_config() { - return file_get_contents(PKG_QUAGGA_CONFIG_BASE . "/ospfd.conf"); -} - -// serialize the raw ospfd confi file to config.xml -function quagga_ospfd_put_raw_config($conffile) { - global $config; - if ($conffile == "") - unset($config['installedpackages']['quaggaospfd']['rawconfig']); - else { - $config['installedpackages']['quaggaospfd']['rawconfig'] = array(); - $config['installedpackages']['quaggaospfd']['rawconfig']['item'] = explode("\n",$_POST['quagga_ospfd_raw']); - $config['installedpackages']['quaggaospfd']['rawconfig'] = $conffile; - } -} - function quagga_get_carp_status_by_ip($ipaddr) { $iface = trim(find_carp_interface($ipaddr)); if ($iface) { diff --git a/config/quagga_ospfd/quagga_ospfd.xml b/config/quagga_ospfd/quagga_ospfd.xml index c975961b..74ea76db 100644 --- a/config/quagga_ospfd/quagga_ospfd.xml +++ b/config/quagga_ospfd/quagga_ospfd.xml @@ -14,6 +14,11 @@ 644 http://www.pfsense.com/packages/config/quagga_ospfd/quagga_ospfd_interfaces.xml + + /usr/local/pkg/ + 644 + http://www.pfsense.com/packages/config/quagga_ospfd/quagga_ospfd_raw.xml + /usr/local/www/ 644 @@ -41,6 +46,10 @@ Interface Settings pkg.php?xml=quagga_ospfd_interfaces.xml + + Raw Config + pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0 + Status /status_ospfd.php @@ -199,4 +208,4 @@ quagga_ospfd_validate_input(); - \ No newline at end of file + diff --git a/config/quagga_ospfd/quagga_ospfd_interfaces.xml b/config/quagga_ospfd/quagga_ospfd_interfaces.xml index beb6f2b0..6e82fff8 100644 --- a/config/quagga_ospfd/quagga_ospfd_interfaces.xml +++ b/config/quagga_ospfd/quagga_ospfd_interfaces.xml @@ -26,6 +26,10 @@ pkg.php?xml=quagga_ospfd_interfaces.xml + + Raw Config + pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0 + Status /status_ospfd.php diff --git a/config/quagga_ospfd/quagga_ospfd_raw.xml b/config/quagga_ospfd/quagga_ospfd_raw.xml new file mode 100644 index 00000000..b34558de --- /dev/null +++ b/config/quagga_ospfd/quagga_ospfd_raw.xml @@ -0,0 +1,71 @@ + + quagga_ospfd_raw + 0.1 + Services: Quagga OSPFd + /usr/local/pkg/quagga_ospfd.inc + pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0 + + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/quagga_ospfd/quagga_ospfd.inc + + + OSPF + Modify Quagga RAW Config. +
Services
+ quagga_ospfd.xml + /pkg_edit.php?xml=quagga_ospfd.xml&id=0 +
+ + + Global Settings + pkg_edit.php?xml=quagga_ospfd.xml&id=0 + + + Interface Settings + pkg.php?xml=quagga_ospfd_interfaces.xml + + + Raw Config + pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0 + + + + Status + /status_ospfd.php + + + + Quagga OSPFd + quagga.sh + ospfd + + + Quagga Zebra + quagga.sh + zebra + + + + ospfd.conf + ospfd + Note: Once you click "Save" below, the assistant (in the "Global Settings" and "Interface Settings" tabs above) will be overridden with whatever you type here. To get back the assisted config save this form below once with both empty input fields. + textarea + base64 + 30 + 65 + + + zebra.conf + zebra + Note: Once you click "Save" below, the assistant (in the "Global Settings" and "Interface Settings" tabs above) will be overridden with whatever you type here. To get back the assisted config save this form below once with both empty input fields. + textarea + base64 + 30 + 65 + + + + quagga_ospfd_install_conf(); + +
diff --git a/config/quagga_ospfd/status_ospfd.php b/config/quagga_ospfd/status_ospfd.php index dc6c6aea..8ecf19d0 100644 --- a/config/quagga_ospfd/status_ospfd.php +++ b/config/quagga_ospfd/status_ospfd.php @@ -33,6 +33,7 @@ $pgtitle = "Quagga OSPF: Status"; include("head.inc"); $control_script = "/usr/local/bin/quaggactl"; +$pkg_homedir = "/var/etc/quagga"; /* List all of the commands as an index. */ function listCmds() { @@ -90,6 +91,7 @@ function doCmdT($title, $command) { $tab_array = array(); $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=quagga_ospfd.xml&id=0"); $tab_array[] = array(gettext("Interface Settings"), false, "/pkg.php?xml=quagga_ospfd_interfaces.xml"); + $tab_array[] = array(gettext("RAW Config"), false, "/pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0"); $tab_array[] = array(gettext("Status"), true, "/status_ospfd.php"); display_top_tabs($tab_array); ?> @@ -110,6 +112,8 @@ function doCmdT($title, $command) { defCmdT("Quagga OSPF Interfaces", "{$control_script} ospf interfaces"); defCmdT("Quagga OSPF CPU Usage", "{$control_script} ospf cpu"); defCmdT("Quagga OSPF Memory", "{$control_script} ospf mem"); + defCmdT("Quagga ospfd.conf", "/bin/cat {$pkg_homedir}/ospfd.conf"); + defCmdT("Quagga zebra.conf", "/bin/cat {$pkg_homedir}/zebra.conf"); ?>
-- cgit v1.2.3