diff options
author | Daniel Hoffend <dh@dotlan.net> | 2014-02-27 17:07:32 +0100 |
---|---|---|
committer | Daniel Hoffend <dh@dotlan.net> | 2014-02-27 17:07:32 +0100 |
commit | 641a91856da66f45a68226141958f46d8460c4b7 (patch) | |
tree | 6b73fd071e8ab9f8c7ac36da8dc1a9999874e9ce | |
parent | 464a48605e7e8edfe0b2476ac66deb23e937dc3f (diff) | |
download | pfsense-packages-641a91856da66f45a68226141958f46d8460c4b7.tar.gz pfsense-packages-641a91856da66f45a68226141958f46d8460c4b7.tar.bz2 pfsense-packages-641a91856da66f45a68226141958f46d8460c4b7.zip |
add support for quagga ospfd raw config support
-rw-r--r-- | config/quagga_ospfd/quagga_ospfd.inc | 67 | ||||
-rw-r--r-- | config/quagga_ospfd/quagga_ospfd.xml | 11 | ||||
-rw-r--r-- | config/quagga_ospfd/quagga_ospfd_interfaces.xml | 4 | ||||
-rw-r--r-- | config/quagga_ospfd/quagga_ospfd_raw.xml | 71 | ||||
-rw-r--r-- | config/quagga_ospfd/status_ospfd.php | 4 |
5 files changed, 117 insertions, 40 deletions
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 @@ -15,6 +15,11 @@ <item>http://www.pfsense.com/packages/config/quagga_ospfd/quagga_ospfd_interfaces.xml</item> </additional_files_needed> <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>644</chmod> + <item>http://www.pfsense.com/packages/config/quagga_ospfd/quagga_ospfd_raw.xml</item> + </additional_files_needed> + <additional_files_needed> <prefix>/usr/local/www/</prefix> <chmod>644</chmod> <item>http://www.pfsense.com/packages/config/quagga_ospfd/status_ospfd.php</item> @@ -42,6 +47,10 @@ <url>pkg.php?xml=quagga_ospfd_interfaces.xml</url> </tab> <tab> + <text>Raw Config</text> + <url>pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0</url> + </tab> + <tab> <text>Status</text> <url>/status_ospfd.php</url> </tab> @@ -199,4 +208,4 @@ <custom_php_validation_command> quagga_ospfd_validate_input(); </custom_php_validation_command> -</packagegui>
\ No newline at end of file +</packagegui> 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 @@ -27,6 +27,10 @@ <active/> </tab> <tab> + <text>Raw Config</text> + <url>pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0</url> + </tab> + <tab> <text>Status</text> <url>/status_ospfd.php</url> </tab> 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 @@ +<packagegui> + <name>quagga_ospfd_raw</name> + <version>0.1</version> + <title>Services: Quagga OSPFd</title> + <include_file>/usr/local/pkg/quagga_ospfd.inc</include_file> + <aftersaveredirect>pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0</aftersaveredirect> + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>077</chmod> + <item>http://www.pfsense.com/packages/config/quagga_ospfd/quagga_ospfd.inc</item> + </additional_files_needed> + <menu> + <name>OSPF</name> + <tooltiptext>Modify Quagga RAW Config.</tooltiptext> + <section>Services</section> + <configfile>quagga_ospfd.xml</configfile> + <url>/pkg_edit.php?xml=quagga_ospfd.xml&id=0</url> + </menu> + <tabs> + <tab> + <text>Global Settings</text> + <url>pkg_edit.php?xml=quagga_ospfd.xml&id=0</url> + </tab> + <tab> + <text>Interface Settings</text> + <url>pkg.php?xml=quagga_ospfd_interfaces.xml</url> + </tab> + <tab> + <text>Raw Config</text> + <url>pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0</url> + <active/> + </tab> + <tab> + <text>Status</text> + <url>/status_ospfd.php</url> + </tab> + </tabs> + <service> + <name>Quagga OSPFd</name> + <rcfile>quagga.sh</rcfile> + <executable>ospfd</executable> + </service> + <service> + <name>Quagga Zebra</name> + <rcfile>quagga.sh</rcfile> + <executable>zebra</executable> + </service> + <fields> + <field> + <fielddescr>ospfd.conf</fielddescr> + <fieldname>ospfd</fieldname> + <description>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.</description> + <type>textarea</type> + <encoding>base64</encoding> + <rows>30</rows> + <cols>65</cols> + </field> + <field> + <fielddescr>zebra.conf</fielddescr> + <fieldname>zebra</fieldname> + <description>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.</description> + <type>textarea</type> + <encoding>base64</encoding> + <rows>30</rows> + <cols>65</cols> + </field> + </fields> + <custom_php_resync_config_command> + quagga_ospfd_install_conf(); + </custom_php_resync_config_command> +</packagegui> 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"); ?> <div id="cmdspace" style="width:100%"> <?php listCmds(); ?> |