net/quagga: merge version 1.3.2 from master

This commit is contained in:
Franco Fichtner 2017-07-23 11:03:31 +02:00
parent 16c2ff4cd1
commit 76cea19f79
8 changed files with 261 additions and 7 deletions

View file

@ -1,5 +1,5 @@
PLUGIN_NAME= quagga
PLUGIN_VERSION= 1.3.1
PLUGIN_VERSION= 1.3.2
PLUGIN_COMMENT= Quagga Routing Suite
PLUGIN_DEPENDS= quagga ruby
PLUGIN_MAINTAINER= franz.fabian.94@gmail.com

View file

@ -99,6 +99,16 @@ class OspfsettingsController extends ApiMutableModelControllerBase
array("enabled", "interfacename", "networktype", "authtype", "area")
);
}
public function searchPrefixlistAction()
{
$this->sessionClose();
$mdlOSPF = $this->getModel();
$grid = new UIModelGrid($mdlOSPF->prefixlists->prefixlist);
return $grid->fetchBindRequest(
$this->request,
array("enabled", "name", "seqnumber", "action", "network" )
);
}
public function getNetworkAction($uuid = null)
{
$mdlOSPF = $this->getModel();
@ -129,7 +139,21 @@ class OspfsettingsController extends ApiMutableModelControllerBase
}
return array();
}
public function getPrefixlistAction($uuid = null)
{
$mdlOSPF = $this->getModel();
if ($uuid != null) {
$node = $mdlOSPF->getNodeByReference('prefixlists.prefixlist.' . $uuid);
if ($node != null) {
// return node
return array("prefixlist" => $node->getNodes());
}
} else {
$node = $mdlOSPF->prefixlists->prefixlist->add();
return array("prefixlist" => $node->getNodes());
}
return array();
}
public function addNetworkAction()
{
$result = array("result" => "failed");
@ -180,6 +204,29 @@ class OspfsettingsController extends ApiMutableModelControllerBase
}
return $result;
}
public function addPrefixlistAction()
{
$result = array("result" => "failed");
if ($this->request->isPost() && $this->request->hasPost("prefixlist")) {
$result = array("result" => "failed", "validations" => array());
$mdlOSPF = $this->getModel();
$node = $mdlOSPF->prefixlists->prefixlist->Add();
$node->setNodes($this->request->getPost("prefixlist"));
$valMsgs = $mdlOSPF->performValidation();
foreach ($valMsgs as $field => $msg) {
$fieldnm = str_replace($node->__reference, "prefixlist", $msg->getField());
$result["validations"][$fieldnm] = $msg->getMessage();
}
if (count($result['validations']) == 0) {
// save config if validated correctly
$mdlOSPF->serializeToConfig();
Config::getInstance()->save();
unset($result['validations']);
$result["result"] = "saved";
}
}
return $result;
}
public function delNetworkAction($uuid)
{
@ -218,6 +265,23 @@ class OspfsettingsController extends ApiMutableModelControllerBase
}
return $result;
}
public function delPrefixlistAction($uuid)
{
$result = array("result" => "failed");
if ($this->request->isPost()) {
$mdlOSPF = $this->getModel();
if ($uuid != null) {
if ($mdlOSPF->prefixlists->prefixlist->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")) {
@ -276,6 +340,33 @@ class OspfsettingsController extends ApiMutableModelControllerBase
}
return array("result" => "failed");
}
public function setPrefixlistAction($uuid)
{
if ($this->request->isPost() && $this->request->hasPost("prefixlist")) {
$mdlNeighbor = $this->getModel();
if ($uuid != null) {
$node = $mdlNeighbor->getNodeByReference('prefixlists.prefixlist.' . $uuid);
if ($node != null) {
$result = array("result" => "failed", "validations" => array());
$prefixlistInfo = $this->request->getPost("prefixlist");
$node->setNodes($prefixlistInfo);
$valMsgs = $mdlNeighbor->performValidation();
foreach ($valMsgs as $field => $msg) {
$fieldnm = str_replace($node->__reference, "prefixlist", $msg->getField());
$result["validations"][$fieldnm] = $msg->getMessage();
}
if (count($result['validations']) == 0) {
// save config if validated correctly
$mdlNeighbor->serializeToConfig();
Config::getInstance()->save();
$result = array("result" => "saved");
}
return $result;
}
}
}
return array("result" => "failed");
}
public function toggle_handler($uuid, $elements, $element)
{
@ -310,4 +401,9 @@ class OspfsettingsController extends ApiMutableModelControllerBase
{
return $this->toggle_handler($uuid, 'interfaces', 'interface');
}
public function togglePrefixlistAction($uuid)
{
return $this->toggle_handler($uuid, 'prefixlists', 'prefixlist');
}
}

View file

@ -35,6 +35,7 @@ class OspfController extends \OPNsense\Base\IndexController
$this->view->generalForm = $this->getForm("ospf");
$this->view->formDialogEditNetwork = $this->getForm("dialogEditOSPFNetwork");
$this->view->formDialogEditInterface = $this->getForm("dialogEditOSPFInterface");
$this->view->formDialogEditPrefixLists = $this->getForm("dialogEditOSPFPrefixLists");
$this->view->pick('OPNsense/Quagga/ospf');
}
}

View file

@ -20,4 +20,16 @@
<type>text</type>
<help>Area in wildcard mask style like 0.0.0.0 and no decimal 0</help>
</field>
<field>
<id>network.linkedPrefixlistIn</id>
<label>Prefix-List In</label>
<type>dropdown</type>
<help>Prefix-List for inbound direction</help>
</field>
<field>
<id>network.linkedPrefixlistOut</id>
<label>Prefix-List Out</label>
<type>dropdown</type>
<help>Prefix-List for outbound direction</help>
</field>
</form>

View file

@ -0,0 +1,32 @@
<form>
<field>
<id>prefixlist.enabled</id>
<label>Enabled</label>
<type>checkbox</type>
<help>Enable / Disable</help>
</field>
<field>
<id>prefixlist.name</id>
<label>Name</label>
<type>text</type>
<help>The name of your Prefix-List, please choose one near to the result you want to achieve.</help>
</field>
<field>
<id>prefixlist.seqnumber</id>
<label>Number</label>
<type>text</type>
<help>The ACL sequence number (10-99)</help>
</field>
<field>
<id>prefixlist.action</id>
<label>Action</label>
<type>select_multiple</type>
<help>Set permit for match or deny to negate the rule.</help>
</field>
<field>
<id>prefixlist.network</id>
<label>Network</label>
<type>text</type>
<help>The network pattern you want to match. It's not validated so please be careful!</help>
</field>
</form>

View file

@ -27,12 +27,9 @@
<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>
<rip>Routing Information Protocol (RIP)</rip>
<static>Statically configured routes</static>
</OptionValues>
@ -60,6 +57,32 @@
<MaximumValue>32</MaximumValue>
<ValidationMessage>Network mask must be between 0 and 32.</ValidationMessage>
</netmask>
<linkedPrefixlistIn type="ModelRelationField">
<Model>
<template>
<source>OPNsense.quagga.ospf</source>
<items>prefixlists.prefixlist</items>
<display>name</display>
<group>name</group>
</template>
</Model>
<ValidationMessage>Related Prefix-List item not found</ValidationMessage>
<Multiple>N</Multiple>
<Required>N</Required>
</linkedPrefixlistIn>
<linkedPrefixlistOut type="ModelRelationField">
<Model>
<template>
<source>OPNsense.quagga.ospf</source>
<items>prefixlists.prefixlist</items>
<display>name</display>
<group>name</group>
</template>
</Model>
<ValidationMessage>Related Prefix-List item not found</ValidationMessage>
<Multiple>N</Multiple>
<Required>N</Required>
</linkedPrefixlistOut>
</network>
</networks>
<interfaces>
@ -144,5 +167,35 @@
</networktype>
</interface>
</interfaces>
<prefixlists>
<prefixlist type="ArrayField">
<enabled type="BooleanField">
<default>1</default>
<Required>Y</Required>
</enabled>
<name type="TextField">
<default></default>
<Required>Y</Required>
</name>
<seqnumber type="IntegerField">
<default></default>
<Required>Y</Required>
<MinimumValue>10</MinimumValue>
<MaximumValue>99</MaximumValue>
</seqnumber>
<action type="OptionField">
<default></default>
<Required>Y</Required>
<OptionValues>
<permit>Permit</permit>
<deny>Deny</deny>
</OptionValues>
</action>
<network type="TextField">
<default></default>
<Required>Y</Required>
</network>
</prefixlist>
</prefixlists>
</items>
</model>

View file

@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
<li class="active"><a data-toggle="tab" href="#general">{{ lang._('General') }}</a></li>
<li><a data-toggle="tab" href="#networks">{{ lang._('Networks') }}</a></li>
<li><a data-toggle="tab" href="#interfaces">{{ lang._('Interfaces') }}</a></li>
<li><a data-toggle="tab" href="#prefixlists">{{ lang._('Prefix Lists') }}</a></li>
</ul>
<div class="tab-content content-box tab-content">
<div id="general" class="tab-pane fade in active">
@ -98,7 +99,32 @@ POSSIBILITY OF SUCH DAMAGE.
</tfoot>
</table>
</div>
<div id="prefixlists" class="tab-pane fade in">
<table id="grid-prefixlists" class="table table-responsive" data-editDialog="DialogEditPrefixLists">
<thead>
<tr>
<th data-column-id="enabled" data-type="string" data-formatter="rowtoggle" data-sortable="false">{{ lang._('Enabled') }}</th>
<th data-column-id="name" data-type="string" data-visible="true" data-sortable="true">{{ lang._('Name') }}</th>
<th data-column-id="seqnumber" data-type="string" data-visible="true" data-sortable="true">{{ lang._('Secquence Number') }}</th>
<th data-column-id="action" data-type="string" data-visible="true" data-sortable="false">{{ lang._('Action') }}</th>
<th data-column-id="network" data-type="string" data-visible="true" data-sortable="false">{{ lang._('Network') }}</th>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="commands" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td colspan="5"></td>
<td>
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
<!-- <button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button> -->
</td>
</tr>
</tfoot>
</table>
</div>
</div>
<script type="text/javascript">
@ -142,10 +168,20 @@ $( document ).ready(function() {
'options':{selection:false, multiSelect:false}
}
);
$("#grid-prefixlists").UIBootgrid(
{ 'search':'/api/quagga/ospfsettings/searchPrefixlist',
'get':'/api/quagga/ospfsettings/getPrefixlist/',
'set':'/api/quagga/ospfsettings/setPrefixlist/',
'add':'/api/quagga/ospfsettings/addPrefixlist/',
'del':'/api/quagga/ospfsettings/delPrefixlist/',
'toggle':'/api/quagga/ospfsettings/togglePrefixlist/',
'options':{selection:false, multiSelect:false}
}
);
});
</script>
{{ partial("layout_partials/base_dialog",['fields':formDialogEditNetwork,'id':'DialogEditNetwork','label':lang._('Edit Network')])}}
{{ partial("layout_partials/base_dialog",['fields':formDialogEditInterface,'id':'DialogEditInterface','label':lang._('Edit Interface')])}}
{{ partial("layout_partials/base_dialog",['fields':formDialogEditPrefixLists,'id':'DialogEditPrefixLists','label':lang._('Edit Prefix Lists')])}}

View file

@ -42,6 +42,22 @@ router ospf
{% if network.enabled == '1' %}
network {{ network.ipaddr }}/{{ network.netmask }} area {{ network.area }}
{% endif %}
{% if network.linkedPrefixlistIn|default("") != "" %}
{% for prefixlist in network.linkedPrefixlistIn.split(",") %}
{% set prefixlist2_data = helpers.getUUID(prefixlist) %}
{% if prefixlist2_data != {} and prefixlist2_data.enabled == '1' %}
area {{ network.area }} filter-list prefix {{ prefixlist2_data.name }} in
{% endif %}
{% endfor %}
{% endif %}
{% if network.linkedPrefixlistOut|default("") != "" %}
{% for prefixlist in network.linkedPrefixlistOut.split(",") %}
{% set prefixlist_data = helpers.getUUID(prefixlist) %}
{% if prefixlist_data != {} and prefixlist_data.enabled == '1' %}
area {{ network.area }} filter-list prefix {{ prefixlist_data.name }} out
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% if helpers.exists('OPNsense.quagga.ospf.originate') and OPNsense.quagga.ospf.originate == '1' %}
@ -49,6 +65,14 @@ router ospf
{% endif %}
!
{% if helpers.exists('OPNsense.quagga.ospf.prefixlists.prefixlist') %}
{% for prefixlist in helpers.sortDictList(OPNsense.quagga.ospf.prefixlists.prefixlist, 'name', 'seqnumber' ) %}
{% if prefixlist.enabled == '1' %}
ip prefix-list {{ prefixlist.name }} seq {{ prefixlist.seqnumber }} {{ prefixlist.action }} {{ prefixlist.network }}
{% endif %}
{% endfor %}
{% endif %}
!
line vty
!
{% endif %}