diff options
Diffstat (limited to 'config/openospfd')
-rw-r--r-- | config/openospfd/openospfd.inc | 62 | ||||
-rw-r--r-- | config/openospfd/openospfd.xml | 64 |
2 files changed, 74 insertions, 52 deletions
diff --git a/config/openospfd/openospfd.inc b/config/openospfd/openospfd.inc index e759f7a3..8d8a59da 100644 --- a/config/openospfd/openospfd.inc +++ b/config/openospfd/openospfd.inc @@ -44,8 +44,6 @@ function ospfd_install_conf() { log_error("OSPFd: No config data found."); return; } - if($config['installedpackages']['ospfd']['config'][0]['row']) - $ospfd_rows = &$config['installedpackages']['ospfd']['config'][0]['row']; $conffile = "# This file was created by the pfSense package manager. Do not edit!\n\n"; @@ -56,20 +54,57 @@ function ospfd_install_conf() { if ($ospfd_conf['updatefib']) $conffile .= "fib-update no\n"; - if ($ospfd_conf['Redistributeconnectedsubnets']) + if ($ospfd_conf['redistributeconnectedsubnets']) $conffile .= "redistribute connected\n"; - if ($ospfd_conf['Redistributedefaultroute']) + if ($ospfd_conf['redistributedefaultroute']) $conffile .= "redistribute default\n"; - if ($ospfd_conf['Resdistributestatic']) + if ($ospfd_conf['resdistributestatic']) $conffile .= "redistribute static\n"; - $conffile .= "area {$ospfd_conf['Area']} {\n"; - + $conffile .= "area {$ospfd_conf['area']} {\n"; + $conffile .= "\tinterface " . $config['interfaces'][$ospfd_conf['interface']]['if']; + $options_present = false; + if (!empty($ospfd_conf['metric'])) { + $options_present = true; + $ifconfigs .= "\t\tmetric {$ospfd_conf['metric']}\n"; + } + if (!empty($ospfd_conf['hellointervalinseconds'])) { + $options_present = true; + $ifconfigs .= "\t\thello-interval {$ospfd_conf['hellointervalinseconds']}\n"; + } + if ($ospfd_conf['md5password'] && !empty($ospfd_conf['password'])) { + $options_present = true; + $ifconfigs .= "\t\tauth-type crypt\n"; + $ifconfigs .= "\t\tauth-md 1 \"" . substr($ospfd_conf['password'], 0, 15) . "\"\n"; + $ifconfigs .= "\t\tauth-md-keyid 1\n"; + } else if (!empty($ospfd_conf['passward'])) { + $options_present = true; + $ifconfigs .= "\t\tauth-type simple\n"; + $ifconfigs .= "\t\tauth-key \"" . substr($ospfd_conf['password'], 0, 7) . "\"\n"; + } + if (!empty($ospfd_conf['routerpriorityelections'])) { + $options_present = true; + $ifconfigs .= "\t\trouter-priority {$ospfd_conf['routerpriorityelections']}\n"; + } + if (!empty($ospfd_conf['retransmitinterval'])) { + $options_present = true; + $ifconfigs .= "\t\tretransmit-interval {$ospfd_conf['retransmitinterval']}\n"; + } + if (!empty($ospfd_conf['deadtimer'])) { + $options_present = true; + $ifconfigs .= "\t\trouter-dead-time {$ospfd_conf['deadtimer']}\n"; + } + if (!empty($ifconfigs)) { + $conffile .= " {\n {$ifconfigs} \n"; + if ($options_present == true) + $conffile .= "\t}\n"; + } else + $conffile .= "\n"; $conffile .= "}\n"; - } + } $fd = fopen("/usr/local/etc/ospfd.conf", "w"); @@ -99,6 +134,17 @@ function ospfd_install_conf() { conf_mount_ro(); } +function ospfd_validate_input() { + global $config, $g, $input_errors; + + if (!empty($_POST['routerid']) && !is_ipaddr($_POST['routerid'])) + $input_errors[] = "Router ID must be an address."; + if (!is_ipaddr($_POST['area'])) + $input_errors[] = "Area needs to be a valid ip_address."; + if ($_POST['md5password'] && empty($_POST['password'])) + $input_errors[] = "Please input a password."; +} + // get the raw ospfd confi file for manual inspection/editing function ospfd_get_raw_config() { return file_get_contents("/usr/local/etc/ospfd.conf"); diff --git a/config/openospfd/openospfd.xml b/config/openospfd/openospfd.xml index 89bb8d08..4d44b2ba 100644 --- a/config/openospfd/openospfd.xml +++ b/config/openospfd/openospfd.xml @@ -2,9 +2,10 @@ <name>OSPFd</name> <version>0.1</version> <title>Services: OSPFd</title> + <include_file>/usr/local/pkg/openospfd.inc</include_file> <aftersaveredirect>pkg_edit.php?xml=openospfd.xml&id=0</aftersaveredirect> <menu> - <name>OSFPd</name> + <name>OSPFd</name> <tooltiptext>Modify ospfd settings.</tooltiptext> <section>Services</section> <configfile>openospfd.xml</configfile> @@ -18,15 +19,16 @@ <fields> <field> <fielddescr>Router ID</fielddescr> - <fieldname>RouterID</fieldname> + <fieldname>routerid</fieldname> <description>Specify the Router ID.</description> <type>input</type> </field> <field> <fielddescr>Area</fielddescr> - <fieldname>Area</fieldname> + <fieldname>area</fieldname> <description>OSPF area for this instance of OSPFd.</description> <type>input</type> + <required/> </field> <field> <fielddescr>Update FIB (Routing table)</fielddescr> @@ -42,7 +44,7 @@ </field> <field> <fielddescr>Metric</fielddescr> - <fieldname>Metric</fieldname> + <fieldname>metric</fieldname> <description>Metric for this OSPF interface (leave blank for default).</description> <type>input</type> </field> @@ -54,83 +56,57 @@ </field> <field> <fielddescr>Password</fielddescr> - <fieldname>Password</fieldname> + <fieldname>password</fieldname> <description>Password for this OSPF interface.</description> <type>input</type> </field> <field> <fielddescr>Redistribute connected subnets</fielddescr> - <fieldname>Redistributeconnectedsubnets</fieldname> + <fieldname>redistributeconnectedsubnets</fieldname> <description>Enables the redistribution of connected networks (Default no)</description> <type>checkbox</type> </field> <field> <fielddescr>Redistribute default route</fielddescr> - <fieldname>Redistributedefaultroute</fieldname> + <fieldname>redistributedefaultroute</fieldname> <description>Enables the redistribution of a default route to this device (Default no)</description> <type>checkbox</type> </field> <field> <fielddescr>Router Priority</fielddescr> - <fieldname>Routerpriorityelections</fieldname> + <fieldname>routerpriorityelections</fieldname> <description>Router priority when participating in elections for DR (Default 1) Valid range is 0-255. 0 will cause the router to not participate in election.</description> <type>input</type> </field> <field> <fielddescr>Hello Interval</fielddescr> - <fieldname>HelloIntervalinseconds</fieldname> + <fieldname>hellointervalinseconds</fieldname> <description>Hello Interval this OSPF interface in seconds (Default 10).</description> <type>input</type> </field> <field> <fielddescr>Retransmit Interval</fielddescr> - <fieldname>RetransmitInterval</fieldname> + <fieldname>retransmitinterval</fieldname> <description>Retransmit Interval this OSPF interface in seconds (Default 5).</description> <type>input</type> </field> <field> <fielddescr>Dead Timer</fielddescr> - <fieldname>DeadTimer</fieldname> + <fieldname>deadtimer</fieldname> <description>Dead Timer for this OSPF interface in seconds (Default 40).</description> <type>input</type> </field> <field> <fielddescr>Redistribute static</fielddescr> - <fieldname>Resdistributestatic</fieldname> + <fieldname>resdistributestatic</fieldname> <description>Enables the redistribution of static routes</description> <type>checkbox</type> </field> </fields> - <custom_php_global_functions> - function sync_package_ospfd() { - conf_mount_rw(); - config_lock(); - global $config; - foreach($config['installedpackages']['ospfd']['config'] as $cf) { - if($cf['host'] != "") { - $start .= "/usr/local/sbin/ospfd "; - $start .= " -n {$cf['host']}"; - if($cf['port'] != "") - $start .= ":{$cf['port']}"; - if($cf['direction'] != "") - $start .= " -S {$cf['direction']}"; - if($cf['version'] != "") - $start .= " -v {$cf['version']}"; - write_rcfile(array( - "file" => "ospfd.sh", - "start" => $start, - "stop" => "/usr/bin/killall ospfd" - ) - ); - restart_service("ospfd"); - break; - } - } - conf_mount_ro(); - config_unlock(); - } - </custom_php_global_functions> - <custom_add_php_command> - sync_package_ospfd(); - </custom_add_php_command> + <custom_php_resync_config_command> + ospfd_install_conf(); + </custom_php_resync_config_command> + <custom_php_validation_command> + ospfd_validate_input(); + </custom_php_validation_command> </packagegui> |