From 6d836f2583675e0e638b03e036b8149e5bdb699c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Wed, 13 Jan 2010 22:39:59 +0000 Subject: Make OSPFd package usable with one area. --- config/openospfd/openospfd.inc | 62 ++++++++++++++++++++++++++++++++++------ 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 @@ OSPFd 0.1 Services: OSPFd + /usr/local/pkg/openospfd.inc pkg_edit.php?xml=openospfd.xml&id=0 - OSFPd + OSPFd Modify ospfd settings.
Services
openospfd.xml @@ -18,15 +19,16 @@ Router ID - RouterID + routerid Specify the Router ID. input Area - Area + area OSPF area for this instance of OSPFd. input + Update FIB (Routing table) @@ -42,7 +44,7 @@ Metric - Metric + metric Metric for this OSPF interface (leave blank for default). input @@ -54,83 +56,57 @@ Password - Password + password Password for this OSPF interface. input Redistribute connected subnets - Redistributeconnectedsubnets + redistributeconnectedsubnets Enables the redistribution of connected networks (Default no) checkbox Redistribute default route - Redistributedefaultroute + redistributedefaultroute Enables the redistribution of a default route to this device (Default no) checkbox Router Priority - Routerpriorityelections + routerpriorityelections 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. input Hello Interval - HelloIntervalinseconds + hellointervalinseconds Hello Interval this OSPF interface in seconds (Default 10). input Retransmit Interval - RetransmitInterval + retransmitinterval Retransmit Interval this OSPF interface in seconds (Default 5). input Dead Timer - DeadTimer + deadtimer Dead Timer for this OSPF interface in seconds (Default 40). input Redistribute static - Resdistributestatic + resdistributestatic Enables the redistribution of static routes checkbox - - 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(); - } - - - sync_package_ospfd(); - + + ospfd_install_conf(); + + + ospfd_validate_input(); + -- cgit v1.2.3