Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion routers/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
require_once('frr.php');
require_once('vyatta.php');
require_once('huawei.php');
require_once('includes/command_builder.php');
require_once('includes/utils.php');
require_once('auth/authentication.php');

Expand Down Expand Up @@ -142,6 +143,33 @@ protected abstract function build_ping($parameter, $routing_instance = false);

protected abstract function build_traceroute($parameter, $routing_instance = false);

public function build_any($command, $parameter = null, $routing_instance = false) {
try {
$cmd = new CommandBuilder();
$wrapper = $this->global_config['doc'][$command]['wrapper'] ?? '';
$raw_command = $this->global_config['doc'][$command]['command'];
$is_quoted = $this->global_config['doc'][$command]['quoted'] || false;
$accepts_parameters = $this->global_config['doc'][$command]['accepts_parameters'];

if ($is_quoted) {
$cmd->add($wrapper, '"', $raw_command);
if ($accepts_parameters) {
$cmd->add($parameter);
}
$cmd->add('"');
} else {
$cmd->add($wrapper, $raw_command);
if ($accepts_parameters) {
$cmd->add($parameter);
}
}

return array($cmd);
} catch (Exception $e) {
throw new Exception('Not implemented.');
}
}

private function build_commands($command, $parameter, $routing_instance = false) {
switch ($command) {
case 'bgp':
Expand Down Expand Up @@ -169,7 +197,8 @@ private function build_commands($command, $parameter, $routing_instance = false)
return $this->build_traceroute($parameter, $routing_instance);

default:
throw new Exception('Command not supported.');
//throw new Exception('Command not supported.');
return $this->build_any($command, $parameter, $routing_instance);
}

return null;
Expand Down