From 7436934fe3e1d28ca4c1124ccec5bbcdecdc986f Mon Sep 17 00:00:00 2001 From: Guillaume Mazoyer Date: Wed, 10 Dec 2014 20:47:56 +0100 Subject: 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. --- routers/cisco.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'routers/cisco.php') 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.'); } -- cgit v1.2.3