mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
net/quagga: routing plugin; closes #88
This commit is contained in:
committed by
Franco Fichtner
parent
8d8ad6f66b
commit
81688ec524
@@ -0,0 +1,7 @@
|
||||
PLUGIN_NAME= quagga
|
||||
PLUGIN_VERSION= 0.0.1
|
||||
PLUGIN_COMMENT= Plugin to manage the quagga routing daemon software which offers routing protocols like RIP, IS-IS and OSPF to guide your packets through the sea
|
||||
PLUGIN_MAINTAINER= franz.fabian.94@gmail.com
|
||||
PLUGIN_DEVEL = yes
|
||||
|
||||
.include "../../Mk/plugins.mk"
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2017 Fabian Franz
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function quagga_services()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$services = array();
|
||||
|
||||
if (isset($config['OPNsense']['quagga']['general']['enabled']) && $config['OPNsense']['quagga']['general']['enabled'] == 1) {
|
||||
$services[] = array(
|
||||
'description' => gettext('Quagga is a deamon to add support of various routing protocols.'),
|
||||
'configd' => array(
|
||||
'restart' => array('quagga restart'),
|
||||
'start' => array('quagga start'),
|
||||
'stop' => array('quagga stop'),
|
||||
),
|
||||
'name' => 'quagga',
|
||||
);
|
||||
}
|
||||
|
||||
return $services;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
namespace OPNsense\Quagga\Api;
|
||||
|
||||
use \OPNsense\Base\ApiControllerBase;
|
||||
use \OPNsense\Quagga\General;
|
||||
use \OPNsense\Core\Config;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 - 2017 Deciso B.V.
|
||||
* Copyright (C) 2017 Fabian Franz
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
class GeneralController extends ApiControllerBase
|
||||
{
|
||||
public function getAction()
|
||||
{
|
||||
// define list of configurable settings
|
||||
$result = array();
|
||||
if ($this->request->isGet()) {
|
||||
$mdlGeneral = new General();
|
||||
$result['general'] = $mdlGeneral->getNodes();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function setAction()
|
||||
{
|
||||
$result = array("result"=>"failed");
|
||||
if ($this->request->isPost()) {
|
||||
// load model and update with provided data
|
||||
$mdlGeneral = new General();
|
||||
$mdlGeneral->setNodes($this->request->getPost("general"));
|
||||
|
||||
// perform validation
|
||||
$valMsgs = $mdlGeneral->performValidation();
|
||||
foreach ($valMsgs as $field => $msg) {
|
||||
if (!array_key_exists("validations", $result)) {
|
||||
$result["validations"] = array();
|
||||
}
|
||||
$result["validations"]["general.".$msg->getField()] = $msg->getMessage();
|
||||
}
|
||||
|
||||
// serialize model to config and save
|
||||
if ($valMsgs->count() == 0) {
|
||||
$mdlGeneral->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
$result["result"] = "saved";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
+312
@@ -0,0 +1,312 @@
|
||||
<?php
|
||||
namespace OPNsense\Quagga\Api;
|
||||
|
||||
use \OPNsense\Base\ApiControllerBase;
|
||||
use \OPNsense\Quagga\OSPF;
|
||||
use \OPNsense\Core\Config;
|
||||
use \OPNsense\Base\ApiMutableModelControllerBase;
|
||||
use \OPNsense\Base\UIModelGrid;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 - 2017 Deciso B.V.
|
||||
* Copyright (C) 2015 J. Schellevis - Deciso B.V.
|
||||
* Copyright (C) 2017 Fabian Franz
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
class OspfsettingsController extends ApiMutableModelControllerBase
|
||||
{
|
||||
static protected $internalModelName = 'OSPF';
|
||||
static protected $internalModelClass = '\OPNsense\Quagga\OSPF';
|
||||
public function getAction()
|
||||
{
|
||||
$result = array();
|
||||
if ($this->request->isGet()) {
|
||||
$mdlospf = new OSPF();
|
||||
$result['ospf'] = $mdlospf->getNodes();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function setAction()
|
||||
{
|
||||
$result = array("result"=>"failed");
|
||||
if ($this->request->isPost()) {
|
||||
// load model and update with provided data
|
||||
$mdlospf = new OSPF();
|
||||
$mdlospf->setNodes($this->request->getPost("ospf"));
|
||||
|
||||
// perform validation
|
||||
$valMsgs = $mdlospf->performValidation();
|
||||
foreach ($valMsgs as $field => $msg) {
|
||||
if (!array_key_exists("validations", $result)) {
|
||||
$result["validations"] = array();
|
||||
}
|
||||
$result["validations"]["general.".$msg->getField()] = $msg->getMessage();
|
||||
}
|
||||
|
||||
// serialize model to config and save
|
||||
if ($valMsgs->count() == 0) {
|
||||
$mdlospf->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
$result["result"] = "saved";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
public function searchNetworkAction()
|
||||
{
|
||||
$this->sessionClose();
|
||||
$mdlOSPF = $this->getModel();
|
||||
$grid = new UIModelGrid($mdlOSPF->networks->network);
|
||||
return $grid->fetchBindRequest(
|
||||
$this->request,
|
||||
array("enabled", "ipaddr", "netmask", "area")
|
||||
);
|
||||
}
|
||||
public function searchInterfaceAction()
|
||||
{
|
||||
$this->sessionClose();
|
||||
$mdlOSPF = $this->getModel();
|
||||
$grid = new UIModelGrid($mdlOSPF->interfaces->interface);
|
||||
return $grid->fetchBindRequest(
|
||||
$this->request,
|
||||
array("enabled", "interfacename", "networktype", "authtype", "area")
|
||||
);
|
||||
}
|
||||
public function getNetworkAction($uuid = null)
|
||||
{
|
||||
$mdlOSPF = $this->getModel();
|
||||
if ($uuid != null) {
|
||||
$node = $mdlOSPF->getNodeByReference('networks.network.' . $uuid);
|
||||
if ($node != null) {
|
||||
// return node
|
||||
return array("network" => $node->getNodes());
|
||||
}
|
||||
} else {
|
||||
$node = $mdlOSPF->networks->network->add();
|
||||
return array("network" => $node->getNodes());
|
||||
}
|
||||
return array();
|
||||
}
|
||||
public function getInterfaceAction($uuid = null)
|
||||
{
|
||||
$mdlOSPF = $this->getModel();
|
||||
if ($uuid != null) {
|
||||
$node = $mdlOSPF->getNodeByReference('interfaces.interface.' . $uuid);
|
||||
if ($node != null) {
|
||||
// return node
|
||||
return array("interface" => $node->getNodes());
|
||||
}
|
||||
} else {
|
||||
$node = $mdlOSPF->interfaces->interface->add();
|
||||
return array("interface" => $node->getNodes());
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
public function addNetworkAction()
|
||||
{
|
||||
$result = array("result" => "failed");
|
||||
if ($this->request->isPost() && $this->request->hasPost("network")) {
|
||||
$result = array("result" => "failed", "validations" => array());
|
||||
$mdlOSPF = $this->getModel();
|
||||
$node = $mdlOSPF->networks->network->Add();
|
||||
$node->setNodes($this->request->getPost("network"));
|
||||
$valMsgs = $mdlOSPF->performValidation();
|
||||
|
||||
foreach ($valMsgs as $field => $msg) {
|
||||
$fieldnm = str_replace($node->__reference, "network", $msg->getField());
|
||||
$result["validations"][$fieldnm] = $msg->getMessage();
|
||||
}
|
||||
|
||||
if (count($result['validations']) == 0) {
|
||||
// save config if validated correctly
|
||||
$mdlOSPF->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
$result["result"] = "saved";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function addInterfaceAction()
|
||||
{
|
||||
$result = array("result" => "failed");
|
||||
if ($this->request->isPost() && $this->request->hasPost("interface")) {
|
||||
$result = array("result" => "failed", "validations" => array());
|
||||
$mdlOSPF = $this->getModel();
|
||||
$node = $mdlOSPF->interfaces->interface->Add();
|
||||
$node->setNodes($this->request->getPost("interface"));
|
||||
$valMsgs = $mdlOSPF->performValidation();
|
||||
|
||||
foreach ($valMsgs as $field => $msg) {
|
||||
$fieldnm = str_replace($node->__reference, "interface", $msg->getField());
|
||||
$result["validations"][$fieldnm] = $msg->getMessage();
|
||||
}
|
||||
|
||||
if (count($result['validations']) == 0) {
|
||||
// save config if validated correctly
|
||||
$mdlOSPF->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
$result["result"] = "saved";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function delNetworkAction($uuid)
|
||||
{
|
||||
|
||||
$result = array("result" => "failed");
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$mdlOSPF = $this->getModel();
|
||||
if ($uuid != null) {
|
||||
if ($mdlOSPF->networks->network->del($uuid)) {
|
||||
$mdlOSPF->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
$result['result'] = 'deleted';
|
||||
} else {
|
||||
$result['result'] = 'not found';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function delInterfaceAction($uuid)
|
||||
{
|
||||
|
||||
$result = array("result" => "failed");
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$mdlOSPF = $this->getModel();
|
||||
if ($uuid != null) {
|
||||
if ($mdlOSPF->interfaces->interface->del($uuid)) {
|
||||
$mdlOSPF->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
$result['result'] = 'deleted';
|
||||
} else {
|
||||
$result['result'] = 'not found';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function setNetworkAction($uuid)
|
||||
{
|
||||
if ($this->request->isPost() && $this->request->hasPost("network")) {
|
||||
$mdlNetwork = $this->getModel();
|
||||
if ($uuid != null) {
|
||||
$node = $mdlNetwork->getNodeByReference('networks.network.' . $uuid);
|
||||
if ($node != null) {
|
||||
$result = array("result" => "failed", "validations" => array());
|
||||
$networkInfo = $this->request->getPost("network");
|
||||
|
||||
$node->setNodes($networkInfo);
|
||||
$valMsgs = $mdlNetwork->performValidation();
|
||||
foreach ($valMsgs as $field => $msg) {
|
||||
$fieldnm = str_replace($node->__reference, "network", $msg->getField());
|
||||
$result["validations"][$fieldnm] = $msg->getMessage();
|
||||
}
|
||||
|
||||
if (count($result['validations']) == 0) {
|
||||
// save config if validated correctly
|
||||
$mdlNetwork->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
$result = array("result" => "saved");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return array("result" => "failed");
|
||||
}
|
||||
public function setInterfaceAction($uuid)
|
||||
{
|
||||
if ($this->request->isPost() && $this->request->hasPost("interface")) {
|
||||
$mdlNetwork = $this->getModel();
|
||||
if ($uuid != null) {
|
||||
$node = $mdlNetwork->getNodeByReference('interfaces.interface.' . $uuid);
|
||||
if ($node != null) {
|
||||
$result = array("result" => "failed", "validations" => array());
|
||||
$interfaceInfo = $this->request->getPost("interface");
|
||||
|
||||
$node->setNodes($interfaceInfo);
|
||||
$valMsgs = $mdlNetwork->performValidation();
|
||||
foreach ($valMsgs as $field => $msg) {
|
||||
$fieldnm = str_replace($node->__reference, "interface", $msg->getField());
|
||||
$result["validations"][$fieldnm] = $msg->getMessage();
|
||||
}
|
||||
|
||||
if (count($result['validations']) == 0) {
|
||||
// save config if validated correctly
|
||||
$mdlNetwork->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
$result = array("result" => "saved");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return array("result" => "failed");
|
||||
}
|
||||
public function toggle_handler($uuid, $elements, $element)
|
||||
{
|
||||
|
||||
$result = array("result" => "failed");
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$mdlNetwork = $this->getModel();
|
||||
if ($uuid != null) {
|
||||
$node = $mdlNetwork->getNodeByReference($elements . '.'. $element .'.' . $uuid);
|
||||
if ($node != null) {
|
||||
if ($node->enabled->__toString() == "1") {
|
||||
$result['result'] = "Disabled";
|
||||
$node->enabled = "0";
|
||||
} else {
|
||||
$result['result'] = "Enabled";
|
||||
$node->enabled = "1";
|
||||
}
|
||||
// if item has toggled, serialize to config and save
|
||||
$mdlNetwork->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function toggleNetworkAction($uuid)
|
||||
{
|
||||
return $this->toggle_handler($uuid, 'networks', 'network');
|
||||
}
|
||||
public function toggleInterfaceAction($uuid)
|
||||
{
|
||||
return $this->toggle_handler($uuid, 'interfaces', 'interface');
|
||||
}
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2015 - 2017 Deciso B.V.
|
||||
* Copyright (C) 2017 Fabian Franz
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
namespace OPNsense\Quagga\Api;
|
||||
|
||||
use \OPNsense\Base\ApiControllerBase;
|
||||
use \OPNsense\Core\Backend;
|
||||
use \OPNsense\Quagga\General;
|
||||
|
||||
/**
|
||||
* Class ServiceController
|
||||
* @package OPNsense\Quagga
|
||||
*/
|
||||
class ServiceController extends ApiControllerBase
|
||||
{
|
||||
/**
|
||||
* start quagga service (in background)
|
||||
* @return array
|
||||
*/
|
||||
public function startAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$backend = new Backend();
|
||||
$response = $backend->configdRun("quagga start", true);
|
||||
return array("response" => $response);
|
||||
} else {
|
||||
return array("response" => array());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* stop quagga service
|
||||
* @return array
|
||||
*/
|
||||
public function stopAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$backend = new Backend();
|
||||
$response = $backend->configdRun("quagga stop");
|
||||
return array("response" => $response);
|
||||
} else {
|
||||
return array("response" => array());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* restart quagga service
|
||||
* @return array
|
||||
*/
|
||||
public function restartAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$backend = new Backend();
|
||||
$response = $backend->configdRun("quagga restart");
|
||||
return array("response" => $response);
|
||||
} else {
|
||||
return array("response" => array());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieve status of quagga
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function statusAction()
|
||||
{
|
||||
$backend = new Backend();
|
||||
$mdlGeneral = new General();
|
||||
$response = $backend->configdRun("quagga status");
|
||||
|
||||
if (strpos($response, "not running") > 0) {
|
||||
if ($mdlGeneral->enabled->__toString() == 1) {
|
||||
$status = "stopped";
|
||||
} else {
|
||||
$status = "disabled";
|
||||
}
|
||||
} elseif (strpos($response, "is running") > 0) {
|
||||
$status = "running";
|
||||
} elseif ($mdlGeneral->enabled->__toString() == 0) {
|
||||
$status = "disabled";
|
||||
} else {
|
||||
$status = "unkown";
|
||||
}
|
||||
|
||||
|
||||
return array("status" => $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* reconfigure quagga, generate config and reload
|
||||
*/
|
||||
public function reconfigureAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$force_restart = false;
|
||||
// close session for long running action
|
||||
$this->sessionClose();
|
||||
|
||||
$mdlGeneral = new General();
|
||||
$backend = new Backend();
|
||||
|
||||
$runStatus = $this->statusAction();
|
||||
|
||||
// stop squid when disabled
|
||||
if ($runStatus['status'] == "running" &&
|
||||
($mdlGeneral->enabled->__toString() == 0)) {
|
||||
$this->stopAction();
|
||||
}
|
||||
|
||||
// generate template
|
||||
$backend->configdRun('template reload OPNsense/Quagga');
|
||||
|
||||
// (res)start daemon
|
||||
if ($mdlGeneral->enabled->__toString() == 1) {
|
||||
if ($runStatus['status'] == "running" && !$force_restart) {
|
||||
$this->restartAction();
|
||||
} else {
|
||||
$this->startAction();
|
||||
}
|
||||
}
|
||||
|
||||
return array("status" => "ok");
|
||||
} else {
|
||||
return array("status" => "failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace OPNsense\Quagga;
|
||||
class BgpController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->title = gettext("BGP-Settings");
|
||||
$this->view->generalForm = $this->getForm("bgp");
|
||||
$this->view->pick('OPNsense/Quagga/bgp');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace OPNsense\Quagga;
|
||||
|
||||
/*
|
||||
Copyright (C) 2017 Fabian Franz
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
class GeneralController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->title = gettext("Routing-Settings");
|
||||
$this->view->generalForm = $this->getForm("general");
|
||||
$this->view->pick('OPNsense/Quagga/general');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace OPNsense\Quagga;
|
||||
class IsisController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->title = gettext("IS-IS-Settings");
|
||||
$this->view->generalForm = $this->getForm("isis");
|
||||
$this->view->pick('OPNsense/Quagga/isis');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace OPNsense\Quagga;
|
||||
|
||||
/*
|
||||
Copyright (C) 2017 Fabian Franz
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
class OspfController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->title = gettext("OSPF Settings");
|
||||
$this->view->generalForm = $this->getForm("ospf");
|
||||
$this->view->formDialogEditNetwork = $this->getForm("dialogEditOSPFNetwork");
|
||||
$this->view->formDialogEditInterface = $this->getForm("dialogEditOSPFInterface");
|
||||
$this->view->pick('OPNsense/Quagga/ospf');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace OPNsense\Quagga;
|
||||
class RipController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->title = gettext("RIP-Settings");
|
||||
$this->view->generalForm = $this->getForm("rip");
|
||||
$this->view->pick('OPNsense/Quagga/rip');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>routing.bgp.general.Enabled</id>
|
||||
<label>enable</label>
|
||||
<type>checkbox</type>
|
||||
<help>This will activate the ospf service.</help>
|
||||
</field>
|
||||
</form>
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>interface.enabled</id>
|
||||
<label>Enabled</label>
|
||||
<type>checkbox</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>interface.interfacename</id>
|
||||
<label>Interface</label>
|
||||
<style>tokenize</style>
|
||||
<type>select_multiple</type>
|
||||
<help>Select an interface where this settings apply to.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>interface.authtype</id>
|
||||
<label>Authentication Type</label>
|
||||
<type>select_multiple</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>interface.authkey</id>
|
||||
<label>Authentication Key</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>interface.area</id>
|
||||
<label>Area</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>interface.cost</id>
|
||||
<label>Cost</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>interface.hellointerval</id>
|
||||
<label>Hello Interval</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>interface.deadinterval</id>
|
||||
<label>Dead Interval</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>interface.retransmitinterval</id>
|
||||
<label>Retransmission Interval</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>interface.transmitdelay</id>
|
||||
<label>Retransmission Delay</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>interface.priority</id>
|
||||
<label>Priority</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>interface.networktype</id>
|
||||
<label>Network Type</label>
|
||||
<type>select_multiple</type>
|
||||
</field>
|
||||
</form>
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>network.enabled</id>
|
||||
<label>Enabled</label>
|
||||
<type>checkbox</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>network.ipaddr</id>
|
||||
<label>Network Address</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>network.netmask</id>
|
||||
<label>Network Mask</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>network.area</id>
|
||||
<label>Area</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
</form>
|
||||
@@ -0,0 +1,9 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>general.enabled</id>
|
||||
<label>enable</label>
|
||||
<type>checkbox</type>
|
||||
<help>This will activate the routing service.</help>
|
||||
</field>
|
||||
</form>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>routing.isis.general.Enabled</id>
|
||||
<label>enable</label>
|
||||
<type>checkbox</type>
|
||||
<help>This will activate the ospf service.</help>
|
||||
</field>
|
||||
</form>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>ospf.enabled</id>
|
||||
<label>Enable</label>
|
||||
<type>checkbox</type>
|
||||
<help>This will activate the ospf service.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>ospf.passiveinterfaces</id>
|
||||
<label>Passive Interfaces</label>
|
||||
<type>select_multiple</type>
|
||||
<style>tokenize</style>
|
||||
<help><![CDATA[Select the interfaces, where no OSPF-Packets should be sent to.]]></help>
|
||||
<hint>Type or select interface.</hint>
|
||||
</field>
|
||||
<field>
|
||||
<id>ospf.redistribute</id>
|
||||
<label>Route Redistribution</label>
|
||||
<type>select_multiple</type>
|
||||
<style>tokenize</style>
|
||||
<help><![CDATA[Select other routing sources, which should be redistributed to the other nodes.]]></help>
|
||||
<hint>Type or select a route source.</hint>
|
||||
</field>
|
||||
<field>
|
||||
<id>ospf.originate</id>
|
||||
<label>Advertise Default Gateway</label>
|
||||
<type>checkbox</type>
|
||||
<help>This will send the information that we have a default gateway.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>ospf.originatealways</id>
|
||||
<label>Always Advertise Default Gateway</label>
|
||||
<type>checkbox</type>
|
||||
<help>This will send the information that we have a default gateway, regardless of if it is available.</help>
|
||||
</field>
|
||||
|
||||
</form>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>routing.rip.general.Enabled</id>
|
||||
<label>enable</label>
|
||||
<type>checkbox</type>
|
||||
<help>This will activate the ospf service.</help>
|
||||
</field>
|
||||
</form>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<acl>
|
||||
<page-routing>
|
||||
<name>Routing</name>
|
||||
<patterns>
|
||||
<pattern>ui/quagga/*</pattern>
|
||||
<pattern>api/quagga/*</pattern>
|
||||
</patterns>
|
||||
</page-routing>
|
||||
</acl>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace OPNsense\Quagga;
|
||||
use OPNsense\Base\BaseModel;
|
||||
|
||||
/*
|
||||
Copyright (C) 2017 Fabian Franz
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
class General extends BaseModel
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<model>
|
||||
<mount>//OPNsense/quagga/general</mount>
|
||||
<description>OSPF Routing configuration</description>
|
||||
<items>
|
||||
<enabled type="BooleanField">
|
||||
<default>0</default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
</items>
|
||||
</model>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user