summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2013-08-20 14:37:02 -0300
committerRenato Botelho <garga@FreeBSD.org>2013-08-20 14:39:06 -0300
commit8f61cb87ecd12fe9da633546d59397dc2b61ebcc (patch)
tree919ebd7da0c224e1935e2860bff4fbdf3c8c969c
parent45ce573dae865e4ff9ae12fd89eeca5d5250b0cd (diff)
downloadpfsense-8f61cb87ecd12fe9da633546d59397dc2b61ebcc.zip
pfsense-8f61cb87ecd12fe9da633546d59397dc2b61ebcc.tar.gz
Add scope to target when it is a link-local, it helps ticket #3150
-rw-r--r--etc/inc/util.inc8
-rwxr-xr-xusr/local/www/diag_ping.php10
2 files changed, 16 insertions, 2 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index cb75798..d6d05ac 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -503,6 +503,14 @@ function is_linklocal($ipaddr) {
return (substr($ipaddr, 0, 5) == "fe80:");
}
+/* returns scope of a linklocal address */
+function get_ll_scope($addr) {
+ if (!is_linklocal($addr) || !strstr($addr, "%"))
+ return "";
+ list ($ll, $scope) = explode("%", $addr);
+ return $scope;
+}
+
/* returns true if $ipaddr is a valid literal IPv6 address */
function is_literalipaddrv6($ipaddr) {
if(preg_match("/\[([0-9a-f:]+)\]/i", $ipaddr, $match))
diff --git a/usr/local/www/diag_ping.php b/usr/local/www/diag_ping.php
index 2270264..6bb9184 100755
--- a/usr/local/www/diag_ping.php
+++ b/usr/local/www/diag_ping.php
@@ -147,15 +147,21 @@ include("head.inc"); ?>
echo "<font face='terminal' size='2'>";
echo "<strong>" . gettext("Ping output") . ":</strong><br>";
echo('<pre>');
+ $ifscope = '';
$command = "/sbin/ping";
if ($ipproto == "ipv6") {
$command .= "6";
$ifaddr = is_ipaddr($sourceip) ? $sourceip : get_interface_ipv6($sourceip);
+ if (is_linklocal($ifaddr))
+ $ifscope = get_ll_scope($ifaddr);
} else {
$ifaddr = is_ipaddr($sourceip) ? $sourceip : get_interface_ip($sourceip);
}
- if ($ifaddr && (is_ipaddr($host) || is_hostname($host)))
+ if ($ifaddr && (is_ipaddr($host) || is_hostname($host))) {
$srcip = "-S" . escapeshellarg($ifaddr);
+ if (is_linklocal($host) && !strstr($host, "%") && !empty($ifscope))
+ $host .= "%{$ifscope}";
+ }
$cmd = "{$command} {$srcip} -c" . escapeshellarg($count) . " " . escapeshellarg($host);
//echo "Ping command: {$cmd}\n";
@@ -173,4 +179,4 @@ include("head.inc"); ?>
</form>
</td></tr>
</table>
-<?php include("fend.inc"); ?> \ No newline at end of file
+<?php include("fend.inc"); ?>
OpenPOWER on IntegriCloud