aboutsummaryrefslogtreecommitdiffstats
path: root/config/openbgpd
diff options
context:
space:
mode:
Diffstat (limited to 'config/openbgpd')
-rw-r--r--config/openbgpd/openbgpd.xml3
-rw-r--r--config/openbgpd/openbgpd_status.php271
2 files changed, 185 insertions, 89 deletions
diff --git a/config/openbgpd/openbgpd.xml b/config/openbgpd/openbgpd.xml
index 2d28de0f..73bda244 100644
--- a/config/openbgpd/openbgpd.xml
+++ b/config/openbgpd/openbgpd.xml
@@ -49,6 +49,7 @@
<name>bgpd</name>
<rcfile>bgpd.sh</rcfile>
<executable>bgpd</executable>
+ <description>OpenBSD BGP Daemon</description>
</service>
<additional_files_needed>
<prefix>/usr/local/www/</prefix>
@@ -151,7 +152,7 @@
<description></description>
<rowhelper>
<rowhelperfield>
- <fielddescr>Announce the specified network as belonging to our AS. If set to connected, routes to directly attached networks will be announced. If set to static, all static routes will be announced.</fielddescr>
+ <fielddescr>Announce the specified network as belonging to our AS. If set to "(inet|inet6)connected", inet or inet6 routes to directly attached networks will be announced. If set to "(inet|inet6) static", all inet or inet6 static routes will be announced.</fielddescr>
<fieldname>networks</fieldname>
<description>Network that you would like to advertise</description>
<type>input</type>
diff --git a/config/openbgpd/openbgpd_status.php b/config/openbgpd/openbgpd_status.php
index 6b27b4de..99076d12 100644
--- a/config/openbgpd/openbgpd_status.php
+++ b/config/openbgpd/openbgpd_status.php
@@ -3,7 +3,7 @@
/*
openbgpd_status.php
part of pfSense (http://www.pfsense.com/)
- Copyright (C) 2007 Scott Ullrich (sullrich@gmail.com)
+ Copyright (C) 2007 Scott Ullrich (sullrich@gmail.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,28 @@
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");
+
+if (isset($_REQUEST['isAjax'])) {
+ if (isset($_REQUEST['cmd']) && isset($commands[$_REQUEST['cmd']])) {
+ echo "{$_REQUEST['cmd']}\n";
+ if (isset($_REQUEST['count']))
+ echo " of " . countCmdT($commands[$_REQUEST['cmd']]['command']) . " items";
+ 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
@@ -37,85 +59,178 @@ else
include("head.inc");
-function doCmdT($title, $command) {
- echo "<p>\n";
- echo "<a name=\"" . $title . "\">\n";
- echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
- echo "<tr><td class=\"listtopic\">" . $title . "</td></tr>\n";
- echo "<tr><td class=\"listlr\"><pre>"; /* no newline after pre */
-
- if ($command == "dumpconfigxml") {
- $fd = @fopen("/conf/config.xml", "r");
- if ($fd) {
- while (!feof($fd)) {
- $line = fgets($fd);
- /* remove sensitive contents */
- $line = preg_replace("/<password>.*?<\\/password>/", "<password>xxxxx</password>", $line);
- $line = preg_replace("/<pre-shared-key>.*?<\\/pre-shared-key>/", "<pre-shared-key>xxxxx</pre-shared-key>", $line);
- $line = preg_replace("/<rocommunity>.*?<\\/rocommunity>/", "<rocommunity>xxxxx</rocommunity>", $line);
- $line = str_replace("\t", " ", $line);
- echo htmlspecialchars($line,ENT_NOQUOTES);
- }
- }
- fclose($fd);
- } else {
- $fd = popen("{$command} 2>&1", "r");
- $ct = 0;
- while (($line = fgets($fd)) !== FALSE) {
- echo htmlspecialchars($line, ENT_NOQUOTES);
- if ($ct++ > 1000) {
- ob_flush();
- $ct = 0;
- }
+function doCmdT($command, $limit = "all", $filter = "", $header_size = 0) {
+ $grepline = "";
+ if (!empty($filter)) {
+ $ini = ($header_size > 0 ? $header_size+1 : 1);
+ $grepline = " | /usr/bin/sed -e '{$ini},\$ { /" . escapeshellarg(htmlspecialchars($filter)) . "/!d; };'";
+ }
+ if (is_numeric($limit) && $limit > 0) {
+ $limit += $header_size;
+ $headline = " | /usr/bin/head -n {$limit}";
+ }
+
+ $fd = popen("{$command}{$grepline}{$headline} 2>&1", "r");
+ $ct = 0;
+ $result = "";
+ while (($line = fgets($fd)) !== FALSE) {
+ $result .= htmlspecialchars($line, ENT_NOQUOTES);
+ if ($ct++ > 1000) {
+ ob_flush();
+ $ct = 0;
}
- pclose($fd);
}
- echo "</pre></tr>\n";
- echo "</table>\n";
+ pclose($fd);
+
+ return $result;
}
-/* Execute a command, giving it a title which is the same as the command. */
-function doCmd($command) {
- doCmdT($command,$command);
+function countCmdT($command) {
+ $fd = popen("{$command} 2>&1", "r");
+ $c = 0;
+ while (fgets($fd) !== FALSE)
+ $c++;
+
+ pclose($fd);
+
+ return $c;
}
-/* Define a command, with a title, to be executed later. */
-function defCmdT($title, $command) {
- global $commands;
- $title = htmlspecialchars($title,ENT_NOQUOTES);
- $commands[] = array($title, $command);
+function showCmdT($idx, $data) {
+ echo "<p>\n";
+ echo "<a name=\"" . $data['title'] . "\">&nbsp;</a>\n";
+ echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
+ echo "<tr><td colspan=\"2\" class=\"listtopic\">" . $data['title'] . "</td></tr>\n";
+
+ $limit_default = "all";
+ if ($data['has_filter']) {
+ $limit_options = array("10", "50", "100", "200", "500", "1000", "all");
+ $limit_default = "100";
+
+ echo "<tr><td class=\"listhdr\" style=\"font-weight:bold;\">\n";
+ echo "Display <select onchange=\"update_filter('{$idx}','{$data['header_size']}');\" name=\"{$idx}_limit\" id=\"{$idx}_limit\">\n";
+ foreach ($limit_options as $item)
+ echo "<option value='{$item}' " . ($item == $limit_default ? "selected" : "") . ">{$item}</option>\n";
+ echo "</select> <span name=\"{$idx}_count\" id=\"{$idx}_count\">items</span></td>\n";
+ echo "<td class=\"listhdr\" align=\"right\" style=\"font-weight:bold;\">Filter expression: \n";
+ echo "<input type=\"text\" name=\"{$idx}_filter\" id=\"{$idx}_filter\" class=\"formfld search\" value=\"" . htmlspecialchars($_REQUEST["{$idx}_filter"]) . "\" size=\"30\" />\n";
+ echo "<input type=\"button\" class=\"formbtn\" value=\"Filter\" onclick=\"update_filter('{$idx}','{$data['header_size']}');\" />\n";
+ echo "</td></tr>\n";
+ }
+
+ 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";
}
-/* Define a command, with a title which is the same as the command,
- * to be executed later.
- */
-function defCmd($command) {
- defCmdT($command,$command);
+/* 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);
+ $commands[$idx] = array(
+ 'title' => $title,
+ 'command' => $command,
+ 'has_filter' => $has_filter,
+ 'header_size' => $header_size);
}
/* List all of the commands as an index. */
function listCmds() {
- global $commands;
- echo "<p>This status page includes the following information:\n";
- echo "<ul width=\"700\">\n";
- for ($i = 0; isset($commands[$i]); $i++ ) {
- echo "<li><strong><a href=\"#" . $commands[$i][0] . "\">" . $commands[$i][0] . "</a></strong></li>\n";
- }
- echo "</ul>\n";
+ global $commands;
+ echo "<p>This status page includes the following information:\n";
+ echo "<ul width=\"700\">\n";
+ 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;
- for ($i = 0; isset($commands[$i]); $i++ ) {
- doCmdT($commands[$i][0], $commands[$i][1]);
- }
+ global $commands;
+ foreach ($commands as $idx => $command)
+ showCmdT($idx, $command);
}
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+
+<script type="text/javascript">
+//<![CDATA[
+
+ function update_count(cmd, header_size) {
+ var url = "openbgpd_status.php";
+ var params = "isAjax=true&count=true&cmd=" + cmd + "&header_size=" + header_size;
+ var myAjax = new Ajax.Request(
+ url,
+ {
+ method: 'post',
+ parameters: params,
+ onComplete: update_count_callback
+ });
+ }
+
+ function update_count_callback(transport) {
+ // First line contain field id to be updated
+ var responseTextArr = transport.responseText.split("\n");
+
+ document.getElementById(responseTextArr[0] + "_count").innerHTML = responseTextArr[1];
+ }
+
+ function update_filter(cmd, header_size) {
+ var url = "openbgpd_status.php";
+ var filter = "";
+ var limit = "all";
+ var limit_field = document.getElementById(cmd + "_limit");
+ if (limit_field) {
+ var index = limit_field.selectedIndex;
+ limit = limit_field.options[index].value;
+ filter = document.getElementById(cmd + "_filter").value;
+ }
+ var params = "isAjax=true&cmd=" + cmd + "&limit=" + limit + "&filter=" + filter + "&header_size=" + header_size;
+ var myAjax = new Ajax.Request(
+ url,
+ {
+ method: 'post',
+ parameters: params,
+ onComplete: update_filter_callback
+ });
+ }
+
+ function update_filter_callback(transport) {
+ // First line contain field id to be updated
+ var responseTextArr = transport.responseText.split("\n");
+ var id = responseTextArr.shift();
+
+ document.getElementById(id).textContent = responseTextArr.join("\n");
+ }
+
+//]]>
+</script>
+
<?php include("fbegin.inc"); ?>
+<script type="text/javascript">
+//<![CDATA[
+
+ function exec_all_cmds() {
+<?php
+ foreach ($commands as $idx => $command) {
+ if ($command['has_filter'])
+ echo "\t\tupdate_count('{$idx}', {$command['header_size']});\n";
+ echo "\t\tupdate_filter('{$idx}', {$command['header_size']});\n";
+ }
+?>
+ }
+
+if (typeof jQuery == 'undefined')
+ document.observe('dom:loaded', function(){setTimeout('exec_all_cmds()', 5000);});
+else
+ jQuery(document).ready(function(){setTimeout('exec_all_cmds()', 5000);});
+
+//]]>
+</script>
+
<?php
if ($config['version'] < 6)
echo '<p class="pgtitle">' . $pgtitle . '</font></p>';
@@ -136,37 +251,17 @@ function execCmds() {
?>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td class="tabcont" >
- <form action="tinydns_status.php" method="post">
- </form>
- </td>
- </tr>
- <tr>
- <td class="tabcont" >
-
-<?php
-
-defCmdT("OpenBGPD Summary","bgpctl show summary");
-defCmdT("OpenBGPD Interfaces","bgpctl show interfaces");
-defCmdT("OpenBGPD Routing","bgpctl show rib");
-defCmdT("OpenBGPD Forwarding","bgpctl show fib");
-defCmdT("OpenBGPD Network","bgpctl show network");
-defCmdT("OpenBGPD Network","bgpctl show network");
-defCmdT("OpenBGPD Nexthops","bgpctl show nexthop");
-defCmdT("OpenBGPD IP","bgpctl show ip bgp");
-defCmdT("OpenBGPD Neighbors","bgpctl show neighbor");
+ <tr>
+ <td class="tabcont" >
-?>
- <div id="cmdspace" style="width:100%">
- <?php listCmds(); ?>
-
- <?php execCmds(); ?>
- </div>
-
- </table>
- </td>
- </tr>
+ <div id="cmdspace" style="width:100%">
+ <?php listCmds(); ?>
+
+ <?php execCmds(); ?>
+ </div>
+
+ </td>
+ </tr>
</table>
</div>