diff options
author | Guillaume Mazoyer <respawneral@gmail.com> | 2014-06-20 23:09:45 +0200 |
---|---|---|
committer | Guillaume Mazoyer <respawneral@gmail.com> | 2014-06-20 23:09:45 +0200 |
commit | b2c8f5e562e60eff4e544daa546eb67f8c41cda9 (patch) | |
tree | ce9584b642c1ee7b66edcc6e19bae02dd545e407 | |
parent | 4fc9117ddb70b3d62f6672ab3cfe51202f128872 (diff) |
Fix BIRD commands again.
-rw-r--r-- | routers/bird.php | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/routers/bird.php b/routers/bird.php index 16703c8..9b0923f 100644 --- a/routers/bird.php +++ b/routers/bird.php @@ -26,12 +26,15 @@ final class Bird extends Router { protected function build_commands($command, $parameters) { $commands = array(); + $birdc = '/usr/sbin/birdc'; + $birdc6 = '/usr/sbin/birdc6'; + switch ($command) { case 'bgp': if (match_ipv4($parameters)) { - $commands[] = 'birdc show route for '.$parameters; + $commands[] = $birdc.' \'show route for '.$parameters.'\''; } else if (match_ipv6($parameters)) { - $commands[] = 'birdc6 show route for '.$parameters; + $commands[] = $birdc6.' \'show route for '.$parameters.'\''; } else { throw new Exception('The parameter is not an IPv4/IPv6 address.'); } @@ -39,8 +42,10 @@ final class Bird extends Router { case 'as-path-regex': if (match_aspath_regex($parameters)) { - $commands[] = 'birdc show route where bgp_path ~ [= '.$parameters.' =]'; - $commands[] = 'birdc6 show route where bgp_path ~ [= '.$parameters.' =]'; + $commands[] = $birdc.' \'show route where bgp_path ~ [= '. + $parameters.' =]\''; + $commands[] = $birdc6.' \'show route where bgp_path ~ [= '. + $parameters.' =]\''; } else { throw new Exception('The parameter is not an AS-Path regular expression like ".*XXXX YYYY.*".'); } @@ -48,8 +53,10 @@ final class Bird extends Router { case 'as': if (match_as($parameters)) { - $commands[] = 'birdc show route where bgp_path ~ [= '.$parameters.' =]'; - $commands[] = 'birdc6 show route where bgp_path ~ [= '.$parameters.' =]'; + $commands[] = $birdc.' \'show route where bgp_path ~ [= '. + $parameters.' =]\''; + $commands[] = $birdc6.' \'show route where bgp_path ~ [= '. + $parameters.' =]\''; } else { throw new Exception('The parameter is not an AS number.'); } |