aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-09-08 08:51:29 -0300
committerRenato Botelho <renato@netgate.com>2015-09-08 08:51:29 -0300
commite1d80111ffcde59922a392554c8083db7631110a (patch)
tree76f1acd861879048786b804e8ff147509fcc8522 /config
parent837033d94cc3cc39a1777258c0cf412dc3b34161 (diff)
parent478c67fd0a36ba840474db0e63873c46350b72db (diff)
downloadpfsense-packages-e1d80111ffcde59922a392554c8083db7631110a.tar.gz
pfsense-packages-e1d80111ffcde59922a392554c8083db7631110a.tar.bz2
pfsense-packages-e1d80111ffcde59922a392554c8083db7631110a.zip
Merge pull request #1049 from doktornotor/patch-21
Diffstat (limited to 'config')
-rw-r--r--config/openbgpd/openbgpd.inc229
-rw-r--r--config/openbgpd/openbgpd_groups.xml81
-rw-r--r--config/openbgpd/openbgpd_neighbors.xml131
-rw-r--r--config/openbgpd/openbgpd_raw.php58
-rw-r--r--config/openbgpd/openbgpd_status.php70
5 files changed, 282 insertions, 287 deletions
diff --git a/config/openbgpd/openbgpd.inc b/config/openbgpd/openbgpd.inc
index 102c937d..93364be9 100644
--- a/config/openbgpd/openbgpd.inc
+++ b/config/openbgpd/openbgpd.inc
@@ -1,8 +1,9 @@
<?php
/*
openbgpd.inc
+ part of pfSense (https://www.pfSense.org/)
Copyright (C) 2007 Scott Ullrich (sullrich@gmail.com)
- part of pfSense
+ Copyright (C) 2015 ESF, LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -32,100 +33,113 @@ require_once("service-utils.inc");
define('PKG_BGPD_CONFIG_BASE', '/var/etc/openbgpd');
-$pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
-if ($pf_version == "2.1" || $pf_version == "2.2")
+$pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3);
+if ($pf_version == "2.1" || $pf_version == "2.2") {
define('PKG_BGPD_BIN', '/usr/pbi/openbgpd-' . php_uname("m") . '/sbin');
-else
+} else {
define('PKG_BGPD_BIN','/usr/local/sbin');
+}
-define('PKG_BGPD_LOGIN', "_bgpd");
-define('PKG_BGPD_UID', "130");
-define('PKG_BGPD_GROUP', "_bgpd");
-define('PKG_BGPD_GID', "130");
-define('PKG_BGPD_GECOS', "BGP Daemon");
-define('PKG_BGPD_HOMEDIR', "/var/empty");
-define('PKG_BGPD_SHELL', "/usr/sbin/nologin");
+define('PKG_BGPD_LOGIN', "_bgpd");
+define('PKG_BGPD_UID', "130");
+define('PKG_BGPD_GROUP', "_bgpd");
+define('PKG_BGPD_GID', "130");
+define('PKG_BGPD_GECOS', "BGP Daemon");
+define('PKG_BGPD_HOMEDIR', "/var/empty");
+define('PKG_BGPD_SHELL', "/usr/sbin/nologin");
function openbgpd_install_conf() {
global $config, $g;
- $pkg_login = PKG_BGPD_LOGIN;
- $pkg_uid = PKG_BGPD_UID;
- $pkg_group = PKG_BGPD_GROUP;
- $pkg_gid = PKG_BGPD_GID;
- $pkg_gecos = PKG_BGPD_GECOS;
- $pkg_homedir = PKG_BGPD_HOMEDIR;
- $pkg_shell = PKG_BGPD_SHELL;
- $pkg_bin = PKG_BGPD_BIN;
+ $pkg_login = PKG_BGPD_LOGIN;
+ $pkg_uid = PKG_BGPD_UID;
+ $pkg_group = PKG_BGPD_GROUP;
+ $pkg_gid = PKG_BGPD_GID;
+ $pkg_gecos = PKG_BGPD_GECOS;
+ $pkg_homedir = PKG_BGPD_HOMEDIR;
+ $pkg_shell = PKG_BGPD_SHELL;
+ $pkg_bin = PKG_BGPD_BIN;
conf_mount_rw();
- // Since we need to embed this in a string, copy to a var. Can't embed constnats.
+ // Since we need to embed this in a string, copy to a var. Can't embed constants.
$bgpd_config_base = PKG_BGPD_CONFIG_BASE;
if ($config['installedpackages']['openbgpd']['rawconfig'] && $config['installedpackages']['openbgpd']['rawconfig']['item']) {
- // if there is a raw config specified in the config.xml use that instead of the assisted config
- $conffile = implode("\n",$config['installedpackages']['openbgpd']['rawconfig']['item']);
+ // If there is a raw config specified in the config.xml, use that instead of the assisted config
+ $conffile = implode("\n", $config['installedpackages']['openbgpd']['rawconfig']['item']);
//$conffile = $config['installedpackages']['openbgpd']['rawconfig'];
} else {
- // generate bgpd.conf based on the assistant
- if($config['installedpackages']['openbgpd']['config'])
+ // Generate bgpd.conf based on the assistant
+ if ($config['installedpackages']['openbgpd']['config']) {
$openbgpd_conf = &$config['installedpackages']['openbgpd']['config'][0];
- if($config['installedpackages']['openbgpd']['config'][0]['row'])
+ }
+ if ($config['installedpackages']['openbgpd']['config'][0]['row']) {
$openbgpd_rows = &$config['installedpackages']['openbgpd']['config'][0]['row'];
- if($config['installedpackages']['openbgpdgroups']['config'])
+ }
+ if ($config['installedpackages']['openbgpdgroups']['config']) {
$openbgpd_groups = &$config['installedpackages']['openbgpdgroups']['config'];
- if($config['installedpackages']['openbgpdneighbors']['config'])
+ }
+ if ($config['installedpackages']['openbgpdneighbors']['config']) {
$openbgpd_neighbors = &$config['installedpackages']['openbgpdneighbors']['config'];
+ }
- $conffile = "# This file was created by the package manager. Do not edit!\n\n";
+ $conffile = "# This file was created by the package manager. Do not edit!\n\n";
// Setup AS #
- if($openbgpd_conf['asnum'])
+ if ($openbgpd_conf['asnum']) {
$conffile .= "AS {$openbgpd_conf['asnum']}\n";
+ }
- if($openbgpd_conf['fibupdate'])
+ if ($openbgpd_conf['fibupdate']) {
$conffile .= "fib-update {$openbgpd_conf['fibupdate']}\n";
+ }
- // Setup holdtime if defined. Default is 90.
- if($openbgpd_conf['holdtime'])
+ // Setup holdtime if defined. Default is 90.
+ if ($openbgpd_conf['holdtime']) {
$conffile .= "holdtime {$openbgpd_conf['holdtime']}\n";
+ }
- // Specify listen ip
- if(!empty($openbgpd_conf['listenip']))
+ // Specify listen IP
+ if (!empty($openbgpd_conf['listenip'])) {
$conffile .= "listen on {$openbgpd_conf['listenip']}\n";
- else
+ } else {
$conffile .= "listen on 0.0.0.0\n";
-
+ }
+
// Specify router id
- if($openbgpd_conf['routerid'])
+ if ($openbgpd_conf['routerid']) {
$conffile .= "router-id {$openbgpd_conf['routerid']}\n";
+ }
// Handle advertised networks
- if($config['installedpackages']['openbgpd']['config'][0]['row'])
- if(is_array($openbgpd_rows))
- foreach($openbgpd_rows as $row)
+ if ($config['installedpackages']['openbgpd']['config'][0]['row']) {
+ if (is_array($openbgpd_rows)) {
+ foreach ($openbgpd_rows as $row) {
$conffile .= "network {$row['networks']}\n";
-
+ }
+ }
+ }
// Attach neighbors to their respective group owner
- if(is_array($openbgpd_groups)) {
- foreach($openbgpd_groups as $group) {
+ if (is_array($openbgpd_groups)) {
+ foreach ($openbgpd_groups as $group) {
$conffile .= "group \"{$group['name']}\" {\n";
$conffile .= " remote-as {$group['remoteas']}\n";
- if(is_array($openbgpd_neighbors)) {
- foreach($openbgpd_neighbors as $neighbor) {
- if($neighbor['groupname'] == $group['name']) {
+ if (is_array($openbgpd_neighbors)) {
+ foreach ($openbgpd_neighbors as $neighbor) {
+ if ($neighbor['groupname'] == $group['name']) {
$conffile .= "\tneighbor {$neighbor['neighbor']} {\n";
$conffile .= "\t\tdescr \"{$neighbor['descr']}\"\n";
- if($neighbor['md5sigpass']) {
+ if ($neighbor['md5sigpass']) {
$conffile .= "\t\ttcp md5sig password {$neighbor['md5sigpass']}\n";
}
- if($neighbor['md5sigkey']) {
+ if ($neighbor['md5sigkey']) {
$conffile .= "\t\ttcp md5sig key {$neighbor['md5sigkey']}\n";
}
$setlocaladdr = true;
if (is_array($neighbor['row'])) {
- foreach($neighbor['row'] as $row) {
- if ($row['parameters'] == "local-address")
+ foreach ($neighbor['row'] as $row) {
+ if ($row['parameters'] == "local-address") {
$setlocaladdr = false;
+ }
$conffile .= "\t\t{$row['parameters']} {$row['parmvalue']} \n";
}
}
@@ -136,7 +150,6 @@ function openbgpd_install_conf() {
$conffile .= "\t\tlocal-address 0.0.0.0\n";
}
}
-
$conffile .= "}\n";
}
}
@@ -146,12 +159,12 @@ function openbgpd_install_conf() {
}
// Handle neighbors that do not have a group assigned to them
- if(is_array($openbgpd_neighbors)) {
- foreach($openbgpd_neighbors as $neighbor) {
- if($neighbor['groupname'] == "") {
+ if (is_array($openbgpd_neighbors)) {
+ foreach ($openbgpd_neighbors as $neighbor) {
+ if ($neighbor['groupname'] == "") {
$conffile .= "neighbor {$neighbor['neighbor']} {\n";
$conffile .= "\tdescr \"{$neighbor['descr']}\"\n";
- if ($neighbor['md5sigpass']) {
+ if ($neighbor['md5sigpass']) {
$conffile .= "\ttcp md5sig password {$neighbor['md5sigpass']}\n";
}
if ($neighbor['md5sigkey']) {
@@ -159,17 +172,18 @@ function openbgpd_install_conf() {
}
$setlocaladdr = true;
if (is_array($neighbor['row'])) {
- foreach($neighbor['row'] as $row) {
- if ($row['parameters'] == "local-address")
+ foreach ($neighbor['row'] as $row) {
+ if ($row['parameters'] == "local-address") {
$setlocaladdr = false;
+ }
$conffile .= "\t{$row['parameters']} {$row['parmvalue']} \n";
}
}
- if ($setlocaladdr == true && !empty($openbgpd_conf['listenip']))
+ if ($setlocaladdr == true && !empty($openbgpd_conf['listenip'])) {
$conffile .= "\tlocal-address {$openbgpd_conf['listenip']}\n";
- else
+ } else {
$conffile .= "\tlocal-address 0.0.0.0\n";
-
+ }
$conffile .= "}\n";
}
}
@@ -178,8 +192,8 @@ function openbgpd_install_conf() {
// OpenBGPD filters
$conffile .= "deny from any\n";
$conffile .= "deny to any\n";
- if(is_array($openbgpd_neighbors)) {
- foreach($openbgpd_neighbors as $neighbor) {
+ if (is_array($openbgpd_neighbors)) {
+ foreach ($openbgpd_neighbors as $neighbor) {
$conffile .= "allow from {$neighbor['neighbor']}\n";
$conffile .= "allow to {$neighbor['neighbor']}\n";
}
@@ -194,7 +208,7 @@ function openbgpd_install_conf() {
$carp_ip_status_check = "";
if (is_ipaddr($openbgpd_conf['carpstatusip'])) {
- $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3);
+ $pfs_version = substr(trim(file_get_contents("/etc/version")), 0, 3);
switch ($pfs_version) {
case "2.0":
case "2.1":
@@ -233,22 +247,22 @@ EOF;
// Create rc.d file
$rc_file_stop = <<<EOF
-killall -TERM bgpd
+/usr/bin/killall -TERM bgpd
EOF;
$rc_file_start = <<<EOF
-if [ `pw groupshow {$pkg_group} 2>&1 | grep -c "pw: unknown group"` -gt 0 ]; then
+if [ `/usr/sbin/pw groupshow {$pkg_group} 2>&1 | /usr/bin/grep -c "pw: unknown group"` -gt 0 ]; then
/usr/sbin/pw groupadd {$pkg_group} -g {$pkg_gid}
fi
-if [ `pw usershow {$pkg_login} 2>&1 | grep -c "pw: no such user"` -gt 0 ]; then
+if [ `/usr/sbin/pw usershow {$pkg_login} 2>&1 | /usr/bin/grep -c "pw: no such user"` -gt 0 ]; then
/usr/sbin/pw useradd {$pkg_login} -u {$pkg_uid} -g {$pkg_gid} -c "{$pkg_gecos}" -d {$pkg_homedir} -s {$pkg_shell}
fi
/bin/mkdir -p {$bgpd_config_base}
/usr/sbin/chown -R root:wheel {$bgpd_config_base}
-/bin/chmod 0600 {$bgpd_config_base}/bgpd.conf
+/bin/chmod 0600 {$bgpd_config_base}/bgpd.conf
-NUMBGPD=`ps auxw | grep -c '[b]gpd.*parent'`
+NUMBGPD=`/bin/ps auxw | /usr/bin/grep -c '[b]gpd.*parent'`
if [ \${NUMBGPD} -lt 1 ] ; then
{$carp_ip_status_check}
{$pkg_bin}/bgpd -f {$bgpd_config_base}/bgpd.conf
@@ -259,13 +273,13 @@ EOF;
write_rcfile(array(
"file" => "bgpd.sh",
"start" => $rc_file_start,
- "stop" => $rc_file_stop
+ "stop" => $rc_file_stop
)
);
unset($rc_file_start, $rc_file_stop);
$_gb = exec("/sbin/sysctl net.inet.ip.ipsec_in_use=1");
- // bgpd process running? if so reload, else start.
+ // Is bgpd process running? If so, reload, else start.
// Kick off newly created rc.d script
if (is_ipaddr($openbgpd_conf['carpstatusip'])) {
@@ -274,7 +288,7 @@ EOF;
// Stop the service if the VIP is in BACKUP or INIT state.
case "BACKUP":
case "INIT":
- exec("/usr/local/etc/rc.d/bgpd.sh stop");
+ stop_service("bgpd");
break;
// Start the service if the VIP is MASTER state.
case "MASTER":
@@ -291,30 +305,31 @@ EOF;
}
function openbgpd_restart() {
- if(is_openbgpd_running() == true) {
+ if (is_openbgpd_running() == true) {
exec("{$pkg_bin}/bgpctl reload");
} else {
exec("{$pkg_bin}/bgpd -f {$bgpd_config_base}/bgpd.conf");
}
}
-// get the raw openbgpd confi file for manual inspection/editing
+// Get the raw openbgpd config file for manual inspection/editing
function openbgpd_get_raw_config() {
$conf = PKG_BGPD_CONFIG_BASE . "/bgpd.conf";
- if (file_exists($conf))
+ if (file_exists($conf)) {
return file_get_contents($conf);
- else
+ } else {
return "";
+ }
}
-// serialize the raw openbgpd config file to config.xml
+// Serialize the raw openbgpd config file to config.xml
function openbgpd_put_raw_config($conffile) {
global $config;
- if ($conffile == "")
+ if ($conffile == "") {
unset($config['installedpackages']['openbgpd']['rawconfig']);
- else {
+ } else {
$config['installedpackages']['openbgpd']['rawconfig'] = array();
- $config['installedpackages']['openbgpd']['rawconfig']['item'] = explode("\n",$_POST['openbgpd_raw']);
+ $config['installedpackages']['openbgpd']['rawconfig']['item'] = explode("\n", $_POST['openbgpd_raw']);
//$config['installedpackages']['openbgpd']['rawconfig'] = $conffile;
}
}
@@ -322,20 +337,25 @@ function openbgpd_put_raw_config($conffile) {
function check_group_usage($groupname) {
global $config, $g;
- if($config['installedpackages']['openbgpd']['config'])
+ if ($config['installedpackages']['openbgpd']['config']) {
$openbgpd_conf = &$config['installedpackages']['openbgpd']['config'][0];
- if($config['installedpackages']['openbgpd']['config'][0]['row'])
+ }
+ if ($config['installedpackages']['openbgpd']['config'][0]['row']) {
$openbgpd_rows = &$config['installedpackages']['openbgpd']['config'][0]['row'];
- if($config['installedpackages']['openbgpdgroups']['config'])
+ }
+ if ($config['installedpackages']['openbgpdgroups']['config']) {
$openbgpd_groups = &$config['installedpackages']['openbgpdgroups']['config'];
- if($config['installedpackages']['openbgpdneighbors']['config'])
+ }
+ if ($config['installedpackages']['openbgpdneighbors']['config']) {
$openbgpd_neighbors = &$config['installedpackages']['openbgpdneighbors']['config'];
+ }
- if(is_array($openbgpd_groups)) {
- foreach($openbgpd_groups as $group) {
- foreach($openbgpd_neighbors as $neighbor) {
- if($neighbor['groupname'] == $group['name'])
+ if (is_array($openbgpd_groups)) {
+ foreach ($openbgpd_groups as $group) {
+ foreach ($openbgpd_neighbors as $neighbor) {
+ if ($neighbor['groupname'] == $group['name']) {
return $neighbor['groupname'];
+ }
}
}
}
@@ -345,36 +365,39 @@ function check_group_usage($groupname) {
function bgpd_validate_input() {
global $config, $g, $input_errors;
-
- if (!empty($_POST['asnum']) && !is_numeric($_POST['asnum']))
+ if (!empty($_POST['asnum']) && !is_numeric($_POST['asnum'])) {
$input_errors[] = "AS must be entered as a number only.";
+ }
- if (!empty($_POST['routerid']) && !is_ipaddr($_POST['routerid']))
+ if (!empty($_POST['routerid']) && !is_ipaddr($_POST['routerid'])) {
$input_errors[] = "Router ID must be an IP address.";
+ }
- if (!empty($_POST['holdtime']) && !is_numeric($_POST['holdtime']))
+ if (!empty($_POST['holdtime']) && !is_numeric($_POST['holdtime'])) {
$input_errors[] = "Holdtime must be entered as a number.";
+ }
- if (!empty($_POST['listenip']) && !is_ipaddr($_POST['listenip']))
+ if (!empty($_POST['listenip']) && !is_ipaddr($_POST['listenip'])) {
$input_errors[] = "Listen IP must be an IP address or blank to bind to all IPs.";
-
+ }
}
function bgpd_validate_group() {
global $config, $g, $id, $input_errors;
- if (!is_numeric($_POST['remoteas']))
+ if (!is_numeric($_POST['remoteas'])) {
$input_errors[] = "Remote AS must be entered as a number only.";
+ }
- if ($_POST['name'] == "")
+ if ($_POST['name'] == "") {
$input_errors[] = "You must enter a name.";
+ }
$_POST['name'] = remove_bad_chars($_POST['name']);
-
}
function remove_bad_chars($string) {
- return preg_replace('/[^a-z|_|0-9]/i','',$string);
+ return preg_replace('/[^a-z|_|0-9]/i','', $string);
}
function grey_out_value_boxes() {
@@ -411,11 +434,12 @@ EOF;
}
function is_openbgpd_running() {
- $status = `ps auxw | grep -c '[b]gpd.*parent'`;
- if(intval($status) > 0)
+ $status = shell_exec("/bin/ps auxw | /usr/bin/grep -c '[b]gpd.*parent'");
+ if (intval($status) > 0) {
return true;
- else
+ } else {
return false;
+ }
}
function openbgpd_get_carp_status_by_ip($ipaddr) {
@@ -423,8 +447,9 @@ function openbgpd_get_carp_status_by_ip($ipaddr) {
if ($iface) {
$status = get_carp_interface_status($iface);
// If there is no status for that interface, return null.
- if (!$status)
+ if (!$status) {
$status = null;
+ }
} else {
// If there is no VIP by that IP, return null.
$status = null;
@@ -440,7 +465,7 @@ function openbgpd_plugin_carp($pluginparams) {
// $pluginparams['interface'] contains the affected interface
/* If there is no bgp config, then stop */
- if(is_array($config['installedpackages']['openbgpd']['config'])) {
+ if (is_array($config['installedpackages']['openbgpd']['config'])) {
$openbgpd_conf = &$config['installedpackages']['openbgpd']['config'][0];
} else {
return null;
diff --git a/config/openbgpd/openbgpd_groups.xml b/config/openbgpd/openbgpd_groups.xml
index 3ece75f2..2c6f8be7 100644
--- a/config/openbgpd/openbgpd_groups.xml
+++ b/config/openbgpd/openbgpd_groups.xml
@@ -2,47 +2,47 @@
<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
<packagegui>
- <copyright>
- <![CDATA[
+ <copyright>
+ <![CDATA[
/* $Id$ */
-/* ========================================================================== */
+/* ====================================================================================== */
/*
- openbgpd_groups.xml
- part of pfSense (http://www.pfSense.com)
- Copyright (C) 2007 Scott Ullrich (sullrich@gmail.com)
- All rights reserved.
- */
-/* ========================================================================== */
+ openbgpd_groups.xml
+ part of pfSense (https://www.pfSense.org/)
+ Copyright (C) 2007 Scott Ullrich (sullrich@gmail.com)
+ Copyright (C) 2015 ESF, LLC
+ All rights reserved.
+*/
+/* ====================================================================================== */
/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- */
-/* ========================================================================== */
- ]]>
- </copyright>
- <description>Describe your package here</description>
- <requirements>Describe your package requirements here</requirements>
- <faq>Currently there are no FAQ items provided.</faq>
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+/* ====================================================================================== */
+ ]]>
+ </copyright>
<name>OpenBGPDGroups</name>
- <version>1</version>
+ <version>0.9.3.6</version>
<title>Services: OpenBGPD Groups</title>
<include_file>/usr/local/pkg/openbgpd.inc</include_file>
<tabs>
@@ -59,11 +59,11 @@
<url>/pkg.php?xml=openbgpd_groups.xml</url>
<active/>
</tab>
- <tab>
- <text>Raw config</text>
- <url>/openbgpd_raw.php</url>
- </tab>
- <tab>
+ <tab>
+ <text>Raw config</text>
+ <url>/openbgpd_raw.php</url>
+ </tab>
+ <tab>
<text>Status</text>
<url>/openbgpd_status.php</url>
</tab>
@@ -86,21 +86,18 @@
<field>
<fielddescr>Name</fielddescr>
<fieldname>name</fieldname>
- <description></description>
<type>input</type>
<size>35</size>
</field>
<field>
<fielddescr>Remote AS</fielddescr>
<fieldname>remoteas</fieldname>
- <description></description>
<type>input</type>
<size>8</size>
</field>
<field>
<fielddescr>Description</fielddescr>
<fieldname>descr</fieldname>
- <description></description>
<type>input</type>
<size>80</size>
</field>
diff --git a/config/openbgpd/openbgpd_neighbors.xml b/config/openbgpd/openbgpd_neighbors.xml
index 5553c022..6872b793 100644
--- a/config/openbgpd/openbgpd_neighbors.xml
+++ b/config/openbgpd/openbgpd_neighbors.xml
@@ -2,47 +2,47 @@
<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
<packagegui>
- <copyright>
- <![CDATA[
+ <copyright>
+ <![CDATA[
/* $Id$ */
-/* ========================================================================== */
+/* ====================================================================================== */
/*
- openbgpd_neighbors.xml
- part of pfSense (http://www.pfSense.com)
- Copyright (C) 2007 Scott Ullrich (sullrich@gmail.com)
- All rights reserved.
- */
-/* ========================================================================== */
+ openbgpd_neighbors.xml
+ part of pfSense (https://www.pfSense.org/)
+ Copyright (C) 2007 Scott Ullrich (sullrich@gmail.com)
+ Copyright (C) 2015 ESF, LLC
+ All rights reserved.
+*/
+/* ====================================================================================== */
/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- */
-/* ========================================================================== */
- ]]>
- </copyright>
- <description>Describe your package here</description>
- <requirements>Describe your package requirements here</requirements>
- <faq>Currently there are no FAQ items provided.</faq>
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+/* ====================================================================================== */
+ ]]>
+ </copyright>
<name>OpenBGPDNeighbors</name>
- <version>1</version>
+ <version>0.9.3.6</version>
<title>Services: OpenBGPD Neighbors</title>
<include_file>/usr/local/pkg/openbgpd.inc</include_file>
<tabs>
@@ -76,7 +76,7 @@
<columnitem>
<fielddescr>Group</fielddescr>
<fieldname>groupname</fieldname>
- </columnitem>
+ </columnitem>
<columnitem>
<fielddescr>Neighbor</fielddescr>
<fieldname>neighbor</fieldname>
@@ -100,13 +100,13 @@
<field>
<fielddescr>TCP-MD5 key</fielddescr>
<fieldname>md5sigkey</fieldname>
- <description>The md5 key to communicate with the peer. Does not work with Cisco BGP routers. If the Local Addr option is not set listening ip will be used.</description>
+ <description>The MD5 key to communicate with the peer. Does not work with Cisco BGP routers. If the 'Local Addr' option is not set, listening IP will be used.</description>
<type>input</type>
</field>
<field>
<fielddescr>TCP-MD5 password</fielddescr>
<fieldname>md5sigpass</fieldname>
- <description>The md5 password to communicate with the peer. Use this when communicating with a Cisco BGP router. If the Local Addr option is not set listenning ip will be used.</description>
+ <description>The MD5 password to communicate with the peer. Use this when communicating with a Cisco BGP router. If the 'Local Addr' option is not set, listening IP will be used.</description>
<type>input</type>
</field>
<field>
@@ -124,13 +124,13 @@
<field>
<fielddescr>Neighbor Parameters</fielddescr>
<fieldname>Neighbor Parameters</fieldname>
- <type>rowhelper</type>
- <rowhelper>
+ <type>rowhelper</type>
+ <rowhelper>
<rowhelperfield>
- <fielddescr>Parameters</fielddescr>
- <fieldname>parameters</fieldname>
- <description>Neighbor settings.</description>
- <type>select</type>
+ <fielddescr>Parameters</fielddescr>
+ <fieldname>parameters</fieldname>
+ <description>Neighbor settings</description>
+ <type>select</type>
<options>
<option><name>Announce all</name><value>announce all</value></option>
<option><name>Announce none</name><value>announce none</value></option>
@@ -148,40 +148,42 @@
<option><name>Softreconfig out no</name><value>softreconfig out no</value></option>
<option><name>Tcp md5sig password X</name><value>tcp md5sig password</value></option>
<option><name>Local address X</name><value>local-address</value></option>
- <option><name>set nexthop X</name><value>set nexthop</value></option>
- <option><name>set nexthop blackhole</name><value>set nexthop blackhole</value></option>
- <option><name>set nexthop reject</name><value>set nexthop reject</value></option>
- <option><name>set nexthop no-modify</name><value>set nexthop no-modify</value></option>
- <option><name>set nexthop self</name><value>set nexthop self</value></option>
+ <option><name>set nexthop X</name><value>set nexthop</value></option>
+ <option><name>set nexthop blackhole</name><value>set nexthop blackhole</value></option>
+ <option><name>set nexthop reject</name><value>set nexthop reject</value></option>
+ <option><name>set nexthop no-modify</name><value>set nexthop no-modify</value></option>
+ <option><name>set nexthop self</name><value>set nexthop self</value></option>
</options>
</rowhelperfield>
<rowhelperfield>
- <fielddescr>Value</fielddescr>
- <fieldname>parmvalue</fieldname>
- <type>input</type>
- <size>25</size>
+ <fielddescr>Value</fielddescr>
+ <fieldname>parmvalue</fieldname>
+ <type>input</type>
+ <size>25</size>
</rowhelperfield>
- </rowhelper>
+ </rowhelper>
</field>
</fields>
<custom_php_command_before_form>
+ <![CDATA[
$newoptions = array();
$new_groups = array();
- if($config['installedpackages']['openbgpdgroups']['config']) {
- foreach($config['installedpackages']['openbgpdgroups']['config'] as $item)
- $new_groups[] = $item['name'];
- $counter = 0;
- foreach($new_groups as $group) {
+ if ($config['installedpackages']['openbgpdgroups']['config']) {
+ foreach ($config['installedpackages']['openbgpdgroups']['config'] as $item) {
+ $new_groups[] = $item['name'];
+ }
+ $counter = 0;
+ foreach ($new_groups as $group) {
$newoptions['option'][$counter]['name'] = $group;
$newoptions['option'][$counter]['value'] = $group;
$counter++;
- }
+ }
$newoptions['option'][$counter]['name'] = "";
- $newoptions['option'][$counter]['value'] = "";
+ $newoptions['option'][$counter]['value'] = "";
$pkg['fields']['field'][4]['options'] = $newoptions;
$counter = 0;
- foreach($pkg['fields']['field'] as $field) {
- if($field['name'] == "group") {
+ foreach ($pkg['fields']['field'] as $field) {
+ if ($field['name'] == "group") {
$foundgroupid = $counter;
echo "found it: $counter";
}
@@ -190,11 +192,10 @@
} else {
$newoptions['option'][0]['name'] = "";
$newoptions['option'][0]['value'] = "";
- $pkg['fields']['field'][4]['options'] =$newoptions;
+ $pkg['fields']['field'][4]['options'] = $newoptions;
}
+ ]]>
</custom_php_command_before_form>
- <custom_php_deinstall_command>
- </custom_php_deinstall_command>
<custom_php_resync_config_command>
openbgpd_install_conf();
</custom_php_resync_config_command>
diff --git a/config/openbgpd/openbgpd_raw.php b/config/openbgpd/openbgpd_raw.php
index ac6826b3..72a961a3 100644
--- a/config/openbgpd/openbgpd_raw.php
+++ b/config/openbgpd/openbgpd_raw.php
@@ -1,9 +1,9 @@
<?php
-/* $Id$ */
/*
openbgpd_raw.php
- part of pfSense (https://www.pfsense.org/)
- Copyright (C) 2009 Aarno Aukia (aarnoaukia@gmail.com)
+ part of pfSense (https://www.pfSense.org/)
+ Copyright (C) 2009 Aarno Aukia (aarnoaukia@gmail.com)
+ Copyright (C) 2015 ESF, LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -27,36 +27,26 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
-
require("guiconfig.inc");
require("openbgpd.inc");
global $config;
if (isset($_POST['openbgpd_raw'])) {
- openbgpd_put_raw_config($_POST['openbgpd_raw']);
- write_config();
- openbgpd_install_conf();
+ openbgpd_put_raw_config($_POST['openbgpd_raw']);
+ write_config();
+ openbgpd_install_conf();
}
$openbgpd_raw = openbgpd_get_raw_config();
-if ($config['version'] >= 6)
- $pgtitle = array("OpenBGPD", "Raw config");
-else
- $pgtitle = "OpenBGPD: Raw config";
-
+$pgtitle = array("OpenBGPD", "Raw config");
include("head.inc");
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
-<?php
- if ($config['version'] < 6)
- echo '<p class="pgtitle">' . $pgtitle . '</font></p>';
-?>
-
<?php if ($savemsg) print_info_box($savemsg); ?>
<div id="mainlevel">
@@ -71,29 +61,21 @@ include("head.inc");
display_top_tabs($tab_array);
?>
</table>
-
<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <form action="openbgpd_raw.php" method="post" name="iform" id="iform">
- <tr>
- <td class="tabcont" >
- You can edit the raw bgpd.conf here.<br>
- Note: Once you click "Save" below, the assistant (in the "Settings", "Neighbors" and "Groups" tabs above) will be overridden with whatever you type here. To get back the assisted config save this form below once with an empty input field.
- </td>
- </tr>
- <tr>
- <td class="tabcont" >
- <textarea name="openbgpd_raw" rows="40" cols="80"><? echo $openbgpd_raw; ?></textarea>
- </td>
- </tr>
- <tr>
- <td>
- <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" on
- click="history.back()">
- </td>
- </tr>
- </form>
+ <form action="openbgpd_raw.php" method="post" name="iform" id="iform">
+ <tr><td class="tabcont" >
+ You can edit the raw bgpd.conf here.<br />
+ Note: Once you click "Save" below, the assistant (in the "Settings", "Neighbors" and "Groups" tabs above) will be overridden with whatever you type here.<br />
+ To get back the assisted config, save this form below once with an empty input field.
+ </td></tr>
+ <tr><td class="tabcont" >
+ <textarea name="openbgpd_raw" rows="40" cols="80"><? echo $openbgpd_raw; ?></textarea>
+ </td></tr>
+ <tr><td>
+ <input name="Submit" type="submit" class="formbtn" value="Save" /><input class="formbtn" type="button" value="Cancel" onclick="history.back()" />
+ </td></tr>
+ </form>
</table>
-
</div>
<?php include("fend.inc"); ?>
diff --git a/config/openbgpd/openbgpd_status.php b/config/openbgpd/openbgpd_status.php
index 58d63795..ed23499f 100644
--- a/config/openbgpd/openbgpd_status.php
+++ b/config/openbgpd/openbgpd_status.php
@@ -1,9 +1,9 @@
<?php
-/* $Id$ */
/*
openbgpd_status.php
- part of pfSense (https://www.pfsense.org/)
+ part of pfSense (https://www.pfSense.org/)
Copyright (C) 2007 Scott Ullrich (sullrich@gmail.com)
+ Copyright (C) 2015 ESF, LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -27,36 +27,32 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
-
require("guiconfig.inc");
$commands = array();
-defCmdT("summary", "OpenBGPD Summary", "/usr/local/sbin/bgpctl show summary");
-defCmdT("interfaces", "OpenBGPD Interfaces", "/usr/local/sbin/bgpctl show interfaces");
-defCmdT("routing", "OpenBGPD Routing", "/usr/local/sbin/bgpctl show rib", true, 4);
-defCmdT("forwarding", "OpenBGPD Forwarding", "/usr/local/sbin/bgpctl show fib", true, 5);
-defCmdT("network", "OpenBGPD Network", "/usr/local/sbin/bgpctl show network");
-defCmdT("nexthops", "OpenBGPD Nexthops", "/usr/local/sbin/bgpctl show nexthop");
-defCmdT("ip", "OpenBGPD IP", "/usr/local/sbin/bgpctl show ip bgp", true, 4);
-defCmdT("neighbors", "OpenBGPD Neighbors", "/usr/local/sbin/bgpctl show neighbor");
+defCmdT("summary", "OpenBGPD Summary", "/usr/local/sbin/bgpctl show summary");
+defCmdT("interfaces", "OpenBGPD Interfaces", "/usr/local/sbin/bgpctl show interfaces");
+defCmdT("routing", "OpenBGPD Routing", "/usr/local/sbin/bgpctl show rib", true, 4);
+defCmdT("forwarding", "OpenBGPD Forwarding", "/usr/local/sbin/bgpctl show fib", true, 5);
+defCmdT("network", "OpenBGPD Network", "/usr/local/sbin/bgpctl show network");
+defCmdT("nexthops", "OpenBGPD Nexthops", "/usr/local/sbin/bgpctl show nexthop");
+defCmdT("ip", "OpenBGPD IP", "/usr/local/sbin/bgpctl show ip bgp", true, 4);
+defCmdT("neighbors", "OpenBGPD Neighbors", "/usr/local/sbin/bgpctl show neighbor");
if (isset($_REQUEST['isAjax'])) {
if (isset($_REQUEST['cmd']) && isset($commands[$_REQUEST['cmd']])) {
echo "{$_REQUEST['cmd']}\n";
- if (isset($_REQUEST['count']))
+ if (isset($_REQUEST['count'])) {
echo " of " . countCmdT($commands[$_REQUEST['cmd']]['command']) . " items";
- else
+ } else {
echo htmlspecialchars_decode(doCmdT($commands[$_REQUEST['cmd']]['command'], $_REQUEST['limit'], $_REQUEST['filter'], $_REQUEST['header_size']));
+ }
}
exit;
}
-if ($config['version'] >= 6)
- $pgtitle = array("OpenBGPD", "Status");
-else
- $pgtitle = "OpenBGPD: Status";
-
+$pgtitle = array("OpenBGPD", "Status");
include("head.inc");
function doCmdT($command, $limit = "all", $filter = "", $header_size = 0) {
@@ -88,9 +84,9 @@ function doCmdT($command, $limit = "all", $filter = "", $header_size = 0) {
function countCmdT($command) {
$fd = popen("{$command} 2>&1", "r");
$c = 0;
- while (fgets($fd) !== FALSE)
+ while (fgets($fd) !== FALSE) {
$c++;
-
+ }
pclose($fd);
return $c;
@@ -118,7 +114,7 @@ function showCmdT($idx, $data) {
echo "</td></tr>\n";
}
- echo "<tr><td colspan=\"2\" class=\"listlr\"><pre id=\"{$idx}\">"; /* no newline after pre */
+ echo "<tr><td colspan=\"2\" class=\"listlr\"><pre id=\"{$idx}\">"; // no newline after pre
echo "Gathering data, please wait...\n";
echo "</pre></td></tr>\n";
echo "</table>\n";
@@ -127,7 +123,7 @@ function showCmdT($idx, $data) {
/* Define a command, with a title, to be executed later. */
function defCmdT($idx, $title, $command, $has_filter = false, $header_size = 0) {
global $commands;
- $title = htmlspecialchars($title,ENT_NOQUOTES);
+ $title = htmlspecialchars($title, ENT_NOQUOTES);
$commands[$idx] = array(
'title' => $title,
'command' => $command,
@@ -140,16 +136,18 @@ function listCmds() {
global $commands;
echo "<p>This status page includes the following information:\n";
echo "<ul width=\"700\">\n";
- foreach ($commands as $idx => $command)
+ foreach ($commands as $idx => $command) {
echo "<li><strong><a href=\"#" . $command['title'] . "\">" . $command['title'] . "</a></strong></li>\n";
+ }
echo "</ul>\n";
}
/* Execute all of the commands which were defined by a call to defCmd. */
function execCmds() {
global $commands;
- foreach ($commands as $idx => $command)
+ foreach ($commands as $idx => $command) {
showCmdT($idx, $command);
+ }
}
?>
@@ -216,8 +214,9 @@ function execCmds() {
function exec_all_cmds() {
<?php
foreach ($commands as $idx => $command) {
- if ($command['has_filter'])
+ if ($command['has_filter']) {
echo "\t\tupdate_count('{$idx}', {$command['header_size']});\n";
+ }
echo "\t\tupdate_filter('{$idx}', {$command['header_size']});\n";
}
?>
@@ -231,11 +230,6 @@ else
//]]>
</script>
-<?php
- if ($config['version'] < 6)
- echo '<p class="pgtitle">' . $pgtitle . '</font></p>';
-?>
-
<?php if ($savemsg) print_info_box($savemsg); ?>
<div id="mainlevel">
@@ -251,17 +245,13 @@ else
?>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td class="tabcont" >
-
- <div id="cmdspace" style="width:100%">
- <?php listCmds(); ?>
-
- <?php execCmds(); ?>
- </div>
+ <tr><td class="tabcont" >
+ <div id="cmdspace" style="width:100%">
+ <?php listCmds(); ?>
- </td>
- </tr>
+ <?php execCmds(); ?>
+ </div>
+ </td></tr>
</table>
</div>