summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/configuration.md35
-rw-r--r--includes/config.defaults.php17
-rw-r--r--routers/bird.php26
-rw-r--r--routers/quagga.php26
4 files changed, 88 insertions, 16 deletions
diff --git a/docs/configuration.md b/docs/configuration.md
index a50a5fc..d237231 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -213,6 +213,41 @@ $config['misc']['allow_reserved_ip'] = true;
If set to true, allows reserved the use of IPv4 addresses (0.0.0.0/8,
169.254.0.0/16, 192.0.2.0/24 and 224.0.0.0/4) as parameters.
+### Tools
+
+The tools that are used by this software are **ping** and **traceroute** for
+routers based on BIRD and Quagga. However some people might want to be able to
+customize the way these tools are used.
+
+```php
+$config['tools']['ping_options'] = '-A -c 10';
+```
+This variable is a string with all ping options to be used.
+
+```php
+$config['tools']['ping_source_option'] = '-I';
+```
+This variable is a string giving the option to source a ping from an IP
+address. It should probably not be changed.
+
+```php
+$config['tools']['traceroute4'] = 'traceroute -4';
+$config['tools']['traceroute6'] = 'traceroute -6';
+```
+These variables give the binary with the option to be used to do a traceroute.
+
+```php
+$config['tools']['traceroute_options'] = '-A -q1 -N32 -w1 -m15';
+```
+This variables is a string with all traceroute options to be used.
+
+```php
+$config['tools']['traceroute_source_option'] = '-s';
+```
+This vairiable is a string giving the option to source a traceroute from an IP
+address. it should probably not be changed unless when using another tool to
+traceroute an destination IP.
+
### Documentation
The documentation configuration should probably not be modified but here
diff --git a/includes/config.defaults.php b/includes/config.defaults.php
index 87c6dae..5aa9e39 100644
--- a/includes/config.defaults.php
+++ b/includes/config.defaults.php
@@ -93,6 +93,23 @@ $config = array(
'allow_reserved_ip' => true
),
+ // Tools used for some processing
+ 'tools' => array(
+ // Options to be used when pinging from a UNIX host (case of BIRD
+ // and Quagga)
+ 'ping_options' => '-A -c 10',
+ // Source option to use when pinging
+ 'ping_source_option' => '-I',
+ // Traceroute tool to be used (can be traceroute or mtr)
+ 'traceroute4' => 'traceroute -4',
+ 'traceroute6' => 'traceroute -6',
+ // Options to be used when tracerouting from a UNIX host (case of BIRD
+ // and Quagga)
+ 'traceroute_options' => '-A -q1 -N32 -w1 -m15',
+ // Source option to use when tracerouting
+ 'traceroute_source_option' => '-s'
+ ),
+
// Documentation (must be HTML)
'doc' => array(
// Documentation for the 'show route' query
diff --git a/routers/bird.php b/routers/bird.php
index 5c30e35..fe9b197 100644
--- a/routers/bird.php
+++ b/routers/bird.php
@@ -36,9 +36,11 @@ final class Bird extends Router {
}
if (match_ipv4($destination)) {
- $ping = 'ping -A -c 10 '.(isset($fqdn) ? $fqdn : $destination);
+ $ping = 'ping '.$this->global_config['tools']['ping_options'].' '.
+ (isset($fqdn) ? $fqdn : $destination);
} else if (match_ipv6($destination)) {
- $ping = 'ping6 -A -c 10 '.(isset($fqdn) ? $fqdn : $destination);
+ $ping = 'ping6 '.$this->global_config['tools']['ping_options'].' '.
+ (isset($fqdn) ? $fqdn : $destination);
} else {
throw new Exception('The parameter does not resolve to an IPv4/IPv6 address.');
}
@@ -46,10 +48,12 @@ final class Bird extends Router {
if (($ping != null) && $this->has_source_interface_id()) {
if (match_ipv4($destination) &&
($this->get_source_interface_id('ipv4') != null)) {
- $ping .= ' -I '.$this->get_source_interface_id('ipv4');
+ $ping .= ' '.$this->global_config['tools']['ping_source_option'].' '.
+ $this->get_source_interface_id('ipv4');
} else if (match_ipv6($destination) &&
($this->get_source_interface_id('ipv6') != null)) {
- $ping .= ' -I '.$this->get_source_interface_id('ipv6');
+ $ping .= ' '.$this->global_config['tools']['ping_source_option'].' '.
+ $this->get_source_interface_id('ipv6');
}
}
@@ -69,10 +73,12 @@ final class Bird extends Router {
}
if (match_ipv4($destination)) {
- $traceroute = 'traceroute -4 -A -q1 -N32 -w1 -m15 '.
+ $traceroute = $this->global_config['tools']['traceroute4'].' '.
+ $this->global_config['tools']['traceroute_options'].' '.
(isset($fqdn) ? $fqdn : $destination);
} else if (match_ipv6($destination)) {
- $traceroute = 'traceroute -6 -A -q1 -N32 -w1 -m15 '.
+ $traceroute = $this->global_config['tools']['traceroute6'].' '.
+ $this->global_config['tools']['traceroute_options'].' '.
(isset($fqdn) ? $fqdn : $destination);
} else {
throw new Exception('The parameter does not resolve to an IPv4/IPv6 address.');
@@ -81,10 +87,14 @@ final class Bird extends Router {
if (($traceroute != null) && $this->has_source_interface_id()) {
if (match_ipv4($destination) &&
($this->get_source_interface_id('ipv4') != null)) {
- $traceroute .= ' -s '.$this->get_source_interface_id('ipv4');
+ $traceroute .= ' '.
+ $this->global_config['tools']['traceroute_source_option'].' '.
+ $this->get_source_interface_id('ipv4');
} else if (match_ipv6($destination) &&
($this->get_source_interface_id('ipv6') != null)) {
- $traceroute .= ' -s '.$this->get_source_interface_id('ipv6');
+ $traceroute .= ' '.
+ $this->global_config['tools']['traceroute_source_option'].' '.
+ $this->get_source_interface_id('ipv6');
}
}
diff --git a/routers/quagga.php b/routers/quagga.php
index 58b2cda..1944273 100644
--- a/routers/quagga.php
+++ b/routers/quagga.php
@@ -36,9 +36,11 @@ final class Quagga extends Router {
}
if (match_ipv4($destination)) {
- $ping = 'ping -A -c 10 '.(isset($fqdn) ? $fqdn : $destination);
+ $ping = 'ping '.$this->global_config['tools']['ping_options'].' '.
+ (isset($fqdn) ? $fqdn : $destination);
} else if (match_ipv6($destination)) {
- $ping = 'ping6 -A -c 10 '.(isset($fqdn) ? $fqdn : $destination);
+ $ping = 'ping6 '.$this->global_config['tools']['ping_options'].' '.
+ (isset($fqdn) ? $fqdn : $destination);
} else {
throw new Exception('The parameter does not resolve to an IPv4/IPv6 address.');
}
@@ -46,10 +48,12 @@ final class Quagga extends Router {
if (($ping != null) && $this->has_source_interface_id()) {
if (match_ipv4($destination) &&
($this->get_source_interface_id('ipv4') != null)) {
- $ping .= ' -I '.$this->get_source_interface_id('ipv4');
+ $ping .= ' '.$this->global_config['tools']['ping_source_option'].' '.
+ $this->get_source_interface_id('ipv4');
} else if (match_ipv6($destination) &&
($this->get_source_interface_id('ipv6') != null)) {
- $ping .= ' -I '.$this->get_source_interface_id('ipv6');
+ $ping .= ' '.$this->global_config['tools']['ping_source_option'].' '.
+ $this->get_source_interface_id('ipv6');
}
}
@@ -69,10 +73,12 @@ final class Quagga extends Router {
}
if (match_ipv4($destination)) {
- $traceroute = 'traceroute -4 -A -q1 -N32 -w1 -m15 '.
+ $traceroute = $this->global_config['tools']['traceroute4'].' '.
+ $this->global_config['tools']['traceroute_options'].' '.
(isset($fqdn) ? $fqdn : $destination);
} else if (match_ipv6($destination)) {
- $traceroute = 'traceroute -6 -A -q1 -N32 -w1 -m15 '.
+ $traceroute = $this->global_config['tools']['traceroute6'].' '.
+ $this->global_config['tools']['traceroute_options'].' '.
(isset($fqdn) ? $fqdn : $destination);
} else {
throw new Exception('The parameter does not resolve to an IPv4/IPv6 address.');
@@ -81,10 +87,14 @@ final class Quagga extends Router {
if (($traceroute != null) && $this->has_source_interface_id()) {
if (match_ipv4($destination) &&
($this->get_source_interface_id('ipv4') != null)) {
- $traceroute .= ' -s '.$this->get_source_interface_id('ipv4');
+ $traceroute .= ' '.
+ $this->global_config['tools']['traceroute_source_option'].' '.
+ $this->get_source_interface_id('ipv4');
} else if (match_ipv6($destination) &&
($this->get_source_interface_id('ipv6') != null)) {
- $traceroute .= ' -s '.$this->get_source_interface_id('ipv6');
+ $traceroute .= ' '.
+ $this->global_config['tools']['traceroute_source_option'].' '.
+ $this->get_source_interface_id('ipv6');
}
}