aboutsummaryrefslogtreecommitdiffstats
path: root/config/openbgpd
diff options
context:
space:
mode:
Diffstat (limited to 'config/openbgpd')
-rw-r--r--config/openbgpd/openbgpd.inc245
-rw-r--r--config/openbgpd/openbgpd_status.php6
2 files changed, 127 insertions, 124 deletions
diff --git a/config/openbgpd/openbgpd.inc b/config/openbgpd/openbgpd.inc
index 45449793..e1619a55 100644
--- a/config/openbgpd/openbgpd.inc
+++ b/config/openbgpd/openbgpd.inc
@@ -3,7 +3,7 @@
/* $Id$ */
/*
openbgpd.inc
- Copyright (C) 2007 Scott Ullrich (sullrich@gmail.com)
+ Copyright (C) 2007 Scott Ullrich (sullrich@gmail.com)
part of pfSense
All rights reserved.
@@ -63,122 +63,121 @@ function openbgpd_install_conf() {
// Since we need to embed this in a string, copy to a var. Can't embed constnats.
$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']);
- //$conffile = $config['installedpackages']['openbgpd']['rawconfig'];
- } else {
- // 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'])
- $openbgpd_rows = &$config['installedpackages']['openbgpd']['config'][0]['row'];
- if($config['installedpackages']['openbgpdgroups']['config'])
- $openbgpd_groups = &$config['installedpackages']['openbgpdgroups']['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";
-
- // Setup AS #
- if($openbgpd_conf['asnum'])
- $conffile .= "AS {$openbgpd_conf['asnum']}\n";
-
- if($openbgpd_conf['fibupdate'])
- $conffile .= "fib-update {$openbgpd_conf['fibupdate']}\n";
-
- // Setup holdtime if defined. Default is 90.
- if($openbgpd_conf['holdtime'])
- $conffile .= "holdtime {$openbgpd_conf['holdtime']}\n";
-
- // Specify listen ip
- if($openbgpd_conf['listenip'])
- $conffile .= "listen on {$openbgpd_conf['listenip']}\n";
-
- // Specify router id
- 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)
- $conffile .= "network {$row['networks']}\n";
-
- // Attach neighbors to their respective group owner
- 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']) {
- $conffile .= "\tneighbor {$neighbor['neighbor']} {\n";
- $conffile .= "\t\tdescr \"{$neighbor['descr']}\"\n";
- if($neighbor['md5sigpass']) {
- $conffile .= "\t\ttcp md5sig password {$neighbor['md5sigpass']}\n";
- }
- 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")
- $setlocaladdr = false;
- $conffile .= "\t\t{$row['parameters']} {$row['parmvalue']} \n";
- }
- }
- if ($setlocaladdr == true)
- $conffile .= "\t\tlocal-address {$openbgpd_conf['listenip']}\n";
- $conffile .= "}\n";
- }
- }
- }
- $conffile .= "}\n";
- }
- }
-
- // Handle neighbors that do not have a group assigned to them
- if(is_array($openbgpd_neighbors)) {
- foreach($openbgpd_neighbors as $neighbor) {
- $used_this_item = false;
- if($neighbor['groupname'] == "") {
- $conffile .= "neighbor {$neighbor['neighbor']} {\n";
- $conffile .= "\tdescr \"{$neighbor['descr']}\"\n";
- if ($neighbor['md5sigpass']) {
- $conffile .= "\ttcp md5sig password {$neighbor['md5sigpass']}\n";
- }
- if ($neighbor['md5sigkey']) {
- $conffile .= "\ttcp md5sig key {$neighbor['md5sigkey']}\n";
- }
- $setlocaladdr = true;
- if (is_array($neighbor['row'])) {
- foreach($neighbor['row'] as $row) {
- if ($row['parameters'] == "local-address")
- $setlocaladdr = false;
- $conffile .= "\t{$row['parameters']} {$row['parmvalue']} \n";
- }
+ 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']);
+ //$conffile = $config['installedpackages']['openbgpd']['rawconfig'];
+ } else {
+ // 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'])
+ $openbgpd_rows = &$config['installedpackages']['openbgpd']['config'][0]['row'];
+ if($config['installedpackages']['openbgpdgroups']['config'])
+ $openbgpd_groups = &$config['installedpackages']['openbgpdgroups']['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";
+
+ // Setup AS #
+ if($openbgpd_conf['asnum'])
+ $conffile .= "AS {$openbgpd_conf['asnum']}\n";
+
+ if($openbgpd_conf['fibupdate'])
+ $conffile .= "fib-update {$openbgpd_conf['fibupdate']}\n";
+
+ // Setup holdtime if defined. Default is 90.
+ if($openbgpd_conf['holdtime'])
+ $conffile .= "holdtime {$openbgpd_conf['holdtime']}\n";
+
+ // Specify listen ip
+ if($openbgpd_conf['listenip'])
+ $conffile .= "listen on {$openbgpd_conf['listenip']}\n";
+
+ // Specify router id
+ 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)
+ $conffile .= "network {$row['networks']}\n";
+
+ // Attach neighbors to their respective group owner
+ 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']) {
+ $conffile .= "\tneighbor {$neighbor['neighbor']} {\n";
+ $conffile .= "\t\tdescr \"{$neighbor['descr']}\"\n";
+ if($neighbor['md5sigpass']) {
+ $conffile .= "\t\ttcp md5sig password {$neighbor['md5sigpass']}\n";
+ }
+ 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")
+ $setlocaladdr = false;
+ $conffile .= "\t\t{$row['parameters']} {$row['parmvalue']} \n";
+ }
+ }
+ if ($setlocaladdr == true)
+ $conffile .= "\t\tlocal-address {$openbgpd_conf['listenip']}\n";
+ $conffile .= "}\n";
+ }
+ }
+ }
+ $conffile .= "}\n";
+ }
+ }
+
+ // Handle neighbors that do not have a group assigned to them
+ 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']) {
+ $conffile .= "\ttcp md5sig password {$neighbor['md5sigpass']}\n";
+ }
+ if ($neighbor['md5sigkey']) {
+ $conffile .= "\ttcp md5sig key {$neighbor['md5sigkey']}\n";
+ }
+ $setlocaladdr = true;
+ if (is_array($neighbor['row'])) {
+ foreach($neighbor['row'] as $row) {
+ if ($row['parameters'] == "local-address")
+ $setlocaladdr = false;
+ $conffile .= "\t{$row['parameters']} {$row['parmvalue']} \n";
+ }
+ }
+ if ($setlocaladdr == true)
+ $conffile .= "\tlocal-address {$openbgpd_conf['listenip']}\n";
+ $conffile .= "}\n";
+ }
+ }
+ }
+
+ // OpenBGPD filters
+ $conffile .= "deny from any\n";
+ $conffile .= "deny to any\n";
+ if(is_array($openbgpd_neighbors)) {
+ foreach($openbgpd_neighbors as $neighbor) {
+ $conffile .= "allow from {$neighbor['neighbor']}\n";
+ $conffile .= "allow to {$neighbor['neighbor']}\n";
+ }
+ }
}
- if ($setlocaladdr == true)
- $conffile .= "\tlocal-address {$openbgpd_conf['listenip']}\n";
- }
- $conffile .= "}\n";
- }
- }
-
- // OpenBGPD filters
- $conffile .= "deny from any\n";
- $conffile .= "deny to any\n";
- if(is_array($openbgpd_neighbors)) {
- foreach($openbgpd_neighbors as $neighbor) {
- $conffile .= "allow from {$neighbor['neighbor']}\n";
- $conffile .= "allow to {$neighbor['neighbor']}\n";
- }
- }
- }
safe_mkdir($bgpd_config_base);
- // Write out the configuration file
+ // Write out the configuration file
@file_put_contents("{$bgpd_config_base}/bgpd.conf", $conffile);
@chmod("{$bgpd_config_base}/bgpd.conf", 0600);
@@ -234,14 +233,14 @@ function openbgpd_get_raw_config() {
// serialize the raw openbgpd config file to config.xml
function openbgpd_put_raw_config($conffile) {
- global $config;
- if ($conffile == "")
- unset($config['installedpackages']['openbgpd']['rawconfig']);
- else {
- $config['installedpackages']['openbgpd']['rawconfig'] = array();
- $config['installedpackages']['openbgpd']['rawconfig']['item'] = explode("\n",$_POST['openbgpd_raw']);
- //$config['installedpackages']['openbgpd']['rawconfig'] = $conffile;
- }
+ global $config;
+ if ($conffile == "")
+ unset($config['installedpackages']['openbgpd']['rawconfig']);
+ else {
+ $config['installedpackages']['openbgpd']['rawconfig'] = array();
+ $config['installedpackages']['openbgpd']['rawconfig']['item'] = explode("\n",$_POST['openbgpd_raw']);
+ //$config['installedpackages']['openbgpd']['rawconfig'] = $conffile;
+ }
}
function deinstall_openbgpd() {
diff --git a/config/openbgpd/openbgpd_status.php b/config/openbgpd/openbgpd_status.php
index e6f69d07..6b27b4de 100644
--- a/config/openbgpd/openbgpd_status.php
+++ b/config/openbgpd/openbgpd_status.php
@@ -60,9 +60,13 @@ function doCmdT($title, $command) {
fclose($fd);
} else {
$fd = popen("{$command} 2>&1", "r");
+ $ct = 0;
while (($line = fgets($fd)) !== FALSE) {
echo htmlspecialchars($line, ENT_NOQUOTES);
- ob_flush();
+ if ($ct++ > 1000) {
+ ob_flush();
+ $ct = 0;
+ }
}
pclose($fd);
}