summaryrefslogtreecommitdiff
path: root/routers/juniper.php
diff options
context:
space:
mode:
authorGuillaume Mazoyer <respawneral@gmail.com>2014-12-10 20:47:56 +0100
committerGuillaume Mazoyer <respawneral@gmail.com>2014-12-10 20:47:56 +0100
commit7436934fe3e1d28ca4c1124ccec5bbcdecdc986f (patch)
treee6c5fac19adeccb4cc3c360b0e101d6f669614b8 /routers/juniper.php
parentbcb3cc4dc275098c33ebc46fb49ef0397242b1ba (diff)
Add option to specify an interface or an address for routers.
The interface is used on routers to source ping and traceroute. On software routers, an address is required instead of the interface.
Diffstat (limited to 'routers/juniper.php')
-rw-r--r--routers/juniper.php23
1 files changed, 20 insertions, 3 deletions
diff --git a/routers/juniper.php b/routers/juniper.php
index 6c6acf7..fefdf1c 100644
--- a/routers/juniper.php
+++ b/routers/juniper.php
@@ -64,17 +64,34 @@ final class Juniper extends Router {
case 'ping':
if (match_ipv4($parameters) || match_ipv6($parameters) ||
match_fqdn($parameters)) {
- $commands[] = 'ping count 10 '.$parameters.' rapid';
+ $ping = 'ping count 10 rapid '.$parameters;
+ if (isset($this->config['source-interface-id'])) {
+ $ping .= ' interface '.$this->config['source-interface-id'];
+ }
+ $commands[] = $ping;
} else {
throw new Exception('The parameter is not an IPv4/IPv6 address or a FQDN.');
}
break;
case 'traceroute':
+ $append = null;
+ if (isset($this->config['source-interface-id'])) {
+ $append = ' interface '.$this->config['source-interface-id'];
+ }
+
if (match_ipv4($parameters)) {
- $commands[] = 'traceroute '.$parameters.' as-number-lookup';
+ $traceroute = 'traceroute as-number-lookup '.$parameters;
+ if ($append != null) {
+ $traceroute .= $append;
+ }
+ $commands[] = $traceroute;
} else if (match_ipv6($parameters) || match_fqdn($parameters)) {
- $commands[] = 'traceroute '.$parameters;
+ $traceroute = 'traceroute '.$parameters;
+ if ($append != null) {
+ $traceroute .= $append;
+ }
+ $commands[] = $traceroute;
} else {
throw new Exception('The parameter is not an IPv4/IPv6 address or a FQDN.');
}