diff options
author | Guillaume Mazoyer <respawneral@gmail.com> | 2014-12-10 20:47:56 +0100 |
---|---|---|
committer | Guillaume Mazoyer <respawneral@gmail.com> | 2014-12-10 20:47:56 +0100 |
commit | 7436934fe3e1d28ca4c1124ccec5bbcdecdc986f (patch) | |
tree | e6c5fac19adeccb4cc3c360b0e101d6f669614b8 /routers/cisco.php | |
parent | bcb3cc4dc275098c33ebc46fb49ef0397242b1ba (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/cisco.php')
-rw-r--r-- | routers/cisco.php | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/routers/cisco.php b/routers/cisco.php index bc34653..285653a 100644 --- a/routers/cisco.php +++ b/routers/cisco.php @@ -57,7 +57,11 @@ final class Cisco extends Router { case 'ping': if (match_ipv4($parameters) || match_ipv6($parameters) || match_fqdn($parameters)) { - $commands[] = 'ping '.$parameters.' repeat 10'; + $ping = 'ping '.$parameters.' repeat 10'; + if (isset($this->config['source-interface-id'])) { + $ping .= ' source '.$this->config['source-interface-id']; + } + $commands[] = $ping; } else { throw new Exception('The parameter is not an IPv4/IPv6 address.'); } @@ -65,7 +69,11 @@ final class Cisco extends Router { case 'traceroute': if (match_ipv4($parameters) || match_ipv6($parameters) || match_fqdn($parameters)) { - $commands[] = 'traceroute '.$parameters; + $traceroute = 'traceroute '.$parameters; + if (isset($this->config['source-interface-id'])) { + $traceroute .= ' source '.$this->config['source-interface-id']; + } + $commands[] = $traceroute; } else { throw new Exception('The parameter is not an IPv4/IPv6 address.'); } |