diff options
Diffstat (limited to 'routers/bird.php')
-rw-r--r-- | routers/bird.php | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/routers/bird.php b/routers/bird.php index b1a75b8..6d7a296 100644 --- a/routers/bird.php +++ b/routers/bird.php @@ -35,25 +35,25 @@ final class Bird extends Router { } } - if (match_ipv4($destination)) { - $ping = 'ping '.$this->global_config['tools']['ping_options'].' '. - (isset($hostname) ? $hostname : $destination); - } else if (match_ipv6($destination)) { + if (match_ipv6($destination)) { $ping = 'ping6 '.$this->global_config['tools']['ping_options'].' '. (isset($hostname) ? $hostname : $destination); + } else if (match_ipv4($destination)) { + $ping = 'ping '.$this->global_config['tools']['ping_options'].' '. + (isset($hostname) ? $hostname : $destination); } else { - throw new Exception('The parameter does not resolve to an IPv4/IPv6 address.'); + throw new Exception('The parameter does not resolve to an IPv6/IPv4 address.'); } if (($ping != null) && $this->has_source_interface_id()) { - if (match_ipv4($destination) && - ($this->get_source_interface_id('ipv4') != null)) { - $ping .= ' '.$this->global_config['tools']['ping_source_option'].' '. - $this->get_source_interface_id('ipv4'); - } else if (match_ipv6($destination) && + if (match_ipv6($destination) && ($this->get_source_interface_id('ipv6') != null)) { $ping .= ' '.$this->global_config['tools']['ping_source_option'].' '. $this->get_source_interface_id('ipv6'); + } else if (match_ipv4($destination) && + ($this->get_source_interface_id('ipv4') != null)) { + $ping .= ' '.$this->global_config['tools']['ping_source_option'].' '. + $this->get_source_interface_id('ipv4'); } } @@ -68,20 +68,20 @@ final class Bird extends Router { $destination = hostname_to_ip_address($hostname); if (!$destination) { - throw new Exception('No A or AAAA record found for '.$hostname); + throw new Exception('No AAAA or A record found for '.$hostname); } } - if (match_ipv4($destination)) { - $traceroute = $this->global_config['tools']['traceroute4'].' '. + if (match_ipv6($destination)) { + $traceroute = $this->global_config['tools']['traceroute6'].' '. $this->global_config['tools']['traceroute_options'].' '. (isset($hostname) ? $hostname : $destination); - } else if (match_ipv6($destination)) { - $traceroute = $this->global_config['tools']['traceroute6'].' '. + } else if (match_ipv4($destination)) { + $traceroute = $this->global_config['tools']['traceroute4'].' '. $this->global_config['tools']['traceroute_options'].' '. (isset($hostname) ? $hostname : $destination); } else { - throw new Exception('The parameter does not resolve to an IPv4/IPv6 address.'); + throw new Exception('The parameter does not resolve to an IPv6/IPv4 address.'); } if (($traceroute != null) && $this->has_source_interface_id()) { @@ -104,26 +104,26 @@ final class Bird extends Router { protected function build_commands($command, $parameter) { $commands = array(); - $birdc = 'birdc'; $birdc6 = 'birdc6'; + $birdc = 'birdc'; switch ($command) { case 'bgp': - if (match_ipv4($parameter, false)) { - $commands[] = $birdc.' \'show route for '.$parameter.'\''; - } else if (match_ipv6($parameter, false)) { + if (match_ipv6($parameter, false)) { $commands[] = $birdc6.' \'show route for '.$parameter.'\''; + } else if (match_ipv4($parameter, false)) { + $commands[] = $birdc.' \'show route for '.$parameter.'\''; } else { - throw new Exception('The parameter is not an IPv4/IPv6 address.'); + throw new Exception('The parameter is not an IPv6/IPv4 address.'); } break; case 'as-path-regex': if (match_aspath_regex($parameter)) { - $commands[] = $birdc.' \'show route where bgp_path ~ [= '. - $parameter.' =]\''; $commands[] = $birdc6.' \'show route where bgp_path ~ [= '. $parameter.' =]\''; + $commands[] = $birdc.' \'show route where bgp_path ~ [= '. + $parameter.' =]\''; } else { throw new Exception('The parameter is not an AS-Path regular expression.'); } @@ -131,10 +131,10 @@ final class Bird extends Router { case 'as': if (match_as($parameter)) { - $commands[] = $birdc.' \'show route where bgp_path ~ [= '. - $parameter.' =]\''; $commands[] = $birdc6.' \'show route where bgp_path ~ [= '. $parameter.' =]\''; + $commands[] = $birdc.' \'show route where bgp_path ~ [= '. + $parameter.' =]\''; } else { throw new Exception('The parameter is not an AS number.'); } |