RIP Quagga (#102)

bump version, add RIP, bugfixes
This commit is contained in:
Fabian Franz 2017-03-27 21:51:04 +02:00 committed by GitHub
parent 158f2308a3
commit 2c9c63c8d9
10 changed files with 274 additions and 6 deletions

View file

@ -0,0 +1,75 @@
<?php
namespace OPNsense\Quagga\Api;
use \OPNsense\Base\ApiControllerBase;
use \OPNsense\Quagga\RIP;
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 RipController extends ApiControllerBase
{
public function getAction()
{
// define list of configurable settings
$result = array();
if ($this->request->isGet()) {
$mdlRIP = new RIP();
$result['rip'] = $mdlRIP->getNodes();
}
return $result;
}
public function setAction()
{
$result = array("result"=>"failed");
if ($this->request->isPost()) {
// load model and update with provided data
$mdlRIP = new RIP();
$mdlRIP->setNodes($this->request->getPost("rip"));
// perform validation
$valMsgs = $mdlRIP->performValidation();
foreach ($valMsgs as $field => $msg) {
if (!array_key_exists("validations", $result)) {
$result["validations"] = array();
}
$result["validations"]["rip.".$msg->getField()] = $msg->getMessage();
}
// serialize model to config and save
if ($valMsgs->count() == 0) {
$mdlRIP->serializeToConfig();
Config::getInstance()->save();
$result["result"] = "saved";
}
}
return $result;
}
}

View file

@ -5,8 +5,8 @@ class RipController extends \OPNsense\Base\IndexController
{
public function indexAction()
{
$this->view->title = gettext("RIP-Settings");
$this->view->generalForm = $this->getForm("rip");
$this->view->title = gettext("RIP Settings");
$this->view->ripForm = $this->getForm("rip");
$this->view->pick('OPNsense/Quagga/rip');
}
}

View file

@ -1,8 +1,38 @@
<form>
<field>
<id>routing.rip.general.Enabled</id>
<id>rip.enabled</id>
<label>enable</label>
<type>checkbox</type>
<help>This will activate the rip service.</help>
</field>
<field>
<id>rip.version</id>
<label>Version</label>
<type>text</type>
<help>Choose your RIP version (1 or 2). 1 is classful, 2 supports CIDR.</help>
</field>
<field>
<id>rip.passiveinterfaces</id>
<label>Passive Interfaces</label>
<type>select_multiple</type>
<style>tokenize</style>
<help><![CDATA[Select the interfaces, where no RIP-Packets should be sent to.]]></help>
<hint>Type or select interface.</hint>
</field>
<field>
<id>rip.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>rip.networks</id>
<label>Networks</label>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Select your Netzworks.</help>
</field>
</form>

View file

@ -1,7 +1,7 @@
<menu>
<Routing cssClass="fa fa-map-signs" order="45">
<General VisibleName="General" cssClass="fa fa-bolt fa-fw" url="/ui/quagga/general/index" order="1"/>
<!--<RIP VisibleName="RIP" cssClass="fa fa-bolt fa-fw" url="/ui/quagga/rip/index" order="10" />-->
<RIP VisibleName="RIP" cssClass="fa fa-bolt fa-fw" url="/ui/quagga/rip/index" order="10" />
<OSPF VisibleName="OSPF" cssClass="fa fa-bolt fa-fw" url="/ui/quagga/ospf/index" order="20" />
<!--<ISIS VisibleName="IS-IS" cssClass="fa fa-bolt fa-fw" url="/ui/quagga/isis/index" order="30" />
<BGP VisibleName="BGPv4" cssClass="fa fa-bolt fa-fw" url="/ui/quagga/bgp/index" order="40" />-->

View file

@ -0,0 +1,34 @@
<?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 RIP extends BaseModel
{
}

View file

@ -0,0 +1,45 @@
<model>
<mount>//OPNsense/quagga/rip</mount>
<description>RIP Routing configuration</description>
<items>
<enabled type="BooleanField">
<default>0</default>
<Required>Y</Required>
</enabled>
<version type="IntegerField">
<MinimumValue>1</MinimumValue>
<MaximumValue>2</MaximumValue>
<default>2</default>
<Required>Y</Required>
</version>
<networks type="CSVListField">
<default></default>
<Required>Y</Required>
<mask>/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2},)*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2})$/</mask>
</networks>
<passiveinterfaces type="InterfaceField">
<Required>N</Required>
<multiple>Y</multiple>
<default></default>
<filters>
<enable>/^(?!0).*$/</enable>
</filters>
</passiveinterfaces>
<redistribute type="OptionField">
<Required>N</Required>
<multiple>Y</multiple>
<default></default>
<OptionValues>
<babel>Babel routing protocol (Babel)</babel>
<bgp>Border Gateway Protocol (BGP)</bgp>
<connected>Connected routes (directly attached subnet or host)</connected>
<isis>Intermediate System to Intermediate System (IS-IS)</isis>
<kernel>Kernel routes (not installed via the zebra RIB)</kernel>
<pim>Protocol Independent Multicast (PIM)</pim>
<ospf>Open Shortest Path First (OSPF)</ospf>
<static>Statically configured routes</static>
</OptionValues>
</redistribute>
</items>
</model>

View file

@ -1 +1,58 @@
{{ partial("layout_partials/base_form",['fields':generalForm,'id':'frm_ospf_settings'])}}
{#
OPNsense® is Copyright © 2014 2017 by Deciso B.V.
This file is Copyright © 2017 by 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.
#}{{ partial("layout_partials/base_form",['fields':ripForm,'id':'frm_rip_settings'])}}
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Save') }}</b></button>
</div>
<script type="text/javascript">
$(document).ready(function() {
var data_get_map = {'frm_rip_settings':"/api/quagga/rip/get"};
mapDataToFormUI(data_get_map).done(function(data){
formatTokenizersUI();
$('.selectpicker').selectpicker('refresh');
});
ajaxCall(url="/api/quagga/service/status", sendData={}, callback=function(data,status) {
updateServiceStatusUI(data['status']);
});
// link save button to API set action
$("#saveAct").click(function(){
saveFormToEndpoint(url="/api/quagga/rip/set",formid='frm_rip_settings',callback_ok=function(){
ajaxCall(url="/api/quagga/service/reconfigure", sendData={}, callback=function(data,status) {
ajaxCall(url="/api/quagga/service/status", sendData={}, callback=function(data,status) {
updateServiceStatusUI(data['status']);
});
});
});
});
});
</script>

View file

@ -1,3 +1,4 @@
ospfd.conf:/usr/local/etc/quagga/ospfd.conf
ripd.conf:/usr/local/etc/quagga/ripd.conf
quagga:/etc/rc.conf.d/quagga
zebra.conf:/usr/local/etc/quagga/zebra.conf

View file

@ -7,7 +7,7 @@ quagga_opnsense_bootup_run="/usr/local/opnsense/scripts/quagga/setup.sh"
quagga_daemons="zebra{%
if helpers.exists('OPNsense.quagga.ospf.enabled') and OPNsense.quagga.ospf.enabled == '1' %} ospfd{% endif %}{%
if helpers.exists('OPNsense.quagga.rip.enabled') and OPNsense.quagga.ripd.enabled == '1' %} ripd{% endif %}{%
if helpers.exists('OPNsense.quagga.rip.enabled') and OPNsense.quagga.rip.enabled == '1' %} ripd{% endif %}{%
if helpers.exists('OPNsense.quagga.bgp.enabled') and OPNsense.quagga.bgp.enabled == '1' %} bgpd{% endif %}{%
if helpers.exists('OPNsense.quagga.ospf6.enabled') and OPNsense.quagga.ospf6.enabled == '1' %} ospf6d{% endif %}{%
if helpers.exists('OPNsense.quagga.ripng.enabled') and OPNsense.quagga.ripng.enabled == '1' %} ripngd{% endif %}{%

View file

@ -0,0 +1,26 @@
!
! Zebra configuration saved from vty
! 2017/03/26 22:40:16
!
!
router zebra
no redistribute rip
!
router rip
version {{ OPNsense.quagga.rip.version }}
{% if helpers.exists('OPNsense.quagga.rip.redistribute') and OPNsense.quagga.rip.redistribute != '' %}
{% for line in OPNsense.quagga.rip.redistribute.split(',') %}
redistribute {{ line }}
{% endfor %}{% endif %}
{% if helpers.exists('OPNsense.quagga.rip.networks') %}
{% for network in OPNsense.quagga.rip.networks.split(',') %}
network {{ network }}
{% endfor %}
{% endif %}
{% if helpers.exists('OPNsense.quagga.rip.passiveinterfaces') and OPNsense.quagga.rip.passiveinterfaces != '' %}
{% for line in OPNsense.quagga.rip.passiveinterfaces.split(',') %}
passive-interface {{ line }}
{% endfor %}{% endif %}
!
line vty
!