Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
85790edb
Commit
85790edb
authored
Jan 05, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(diagnostics/interface) add ndp frontend+api code
parent
0ad75221
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
154 additions
and
8 deletions
+154
-8
InterfaceController.php
...trollers/OPNsense/Diagnostics/Api/InterfaceController.php
+38
-8
InterfaceController.php
.../controllers/OPNsense/Diagnostics/InterfaceController.php
+12
-0
ndp.volt
src/opnsense/mvc/app/views/OPNsense/Diagnostics/ndp.volt
+104
-0
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/InterfaceController.php
View file @
85790edb
...
...
@@ -40,6 +40,18 @@ use \OPNsense\Core\Backend;
*/
class
InterfaceController
extends
ApiControllerBase
{
private
function
getInterfaceNames
()
{
// collect interface names
$intfmap
=
array
();
$config
=
Config
::
getInstance
()
->
object
()
;
if
(
$config
->
interfaces
!=
null
)
{
foreach
(
$config
->
interfaces
->
children
()
as
$key
=>
$node
)
{
$intfmap
[(
string
)
$node
->
if
]
=
!
empty
((
string
)
$node
->
descr
)
?
(
string
)
$node
->
descr
:
$key
;
}
}
return
$intfmap
;
}
/**
* retrieve system arp table contents
* @return array
...
...
@@ -50,14 +62,7 @@ class InterfaceController extends ApiControllerBase
$response
=
$backend
->
configdpRun
(
"interface list arp json"
);
$arptable
=
json_decode
(
$response
,
true
);
// collect interface names
$intfmap
=
array
();
$config
=
Config
::
getInstance
()
->
object
()
;
if
(
$config
->
interfaces
!=
null
)
{
foreach
(
$config
->
interfaces
->
children
()
as
$key
=>
$node
)
{
$intfmap
[(
string
)
$node
->
if
]
=
!
empty
((
string
)
$node
->
descr
)
?
(
string
)
$node
->
descr
:
$key
;
}
}
$intfmap
=
$this
->
getInterfaceNames
();
// merge arp output with interface names
if
(
is_array
(
$arptable
))
{
foreach
(
$arptable
as
&
$arpentry
)
{
...
...
@@ -71,4 +76,29 @@ class InterfaceController extends ApiControllerBase
return
$arptable
;
}
/**
* retrieve system ndp table contents
* @return array
*/
public
function
getNdpAction
()
{
$backend
=
new
Backend
();
$response
=
$backend
->
configdpRun
(
"interface list ndp json"
);
$ndptable
=
json_decode
(
$response
,
true
);
$intfmap
=
$this
->
getInterfaceNames
();
// merge ndp output with interface names
if
(
is_array
(
$ndptable
))
{
foreach
(
$ndptable
as
&
$ndpentry
)
{
if
(
array_key_exists
(
$ndpentry
[
'intf'
],
$intfmap
))
{
$ndpentry
[
'intf_description'
]
=
$intfmap
[
$ndpentry
[
'intf'
]];
}
else
{
$ndpentry
[
'intf_description'
]
=
""
;
}
}
}
return
$ndptable
;
}
}
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/InterfaceController.php
View file @
85790edb
...
...
@@ -36,9 +36,21 @@ use OPNsense\Base\IndexController;
*/
class
InterfaceController
extends
IndexController
{
/**
* system arp table
*/
public
function
arpAction
()
{
$this
->
view
->
title
=
"System ARP table"
;
$this
->
view
->
pick
(
'OPNsense/Diagnostics/arp'
);
}
/**
* system NDP table
*/
public
function
ndpAction
()
{
$this
->
view
->
title
=
"System NDP table"
;
$this
->
view
->
pick
(
'OPNsense/Diagnostics/ndp'
);
}
}
src/opnsense/mvc/app/views/OPNsense/Diagnostics/ndp.volt
0 → 100644
View file @
85790edb
{#
OPNsense® is Copyright © 2014 – 2016 by Deciso B.V.
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.
#}
<script type="text/javascript">
$( document ).ready(function() {
/**
* fetch system NDP table
*/
function updateNDP() {
var gridopt = {
ajax: false,
selection: false,
multiSelect: false
};
$("#grid-ndp").bootgrid('destroy');
ajaxGet(url = "/api/diagnostics/interface/getNdp",
sendData = {}, callback = function (data, status) {
if (status == "success") {
var html = [];
$.each(data, function (key, value) {
var fields = ["ip", "mac", "manufacturer", "intf", "intf_description"];
tr_str = '<tr>';
for (var i = 0; i < fields.length; i++) {
if (value[fields[i]] != null) {
tr_str += '<td>' + value[fields[i]] + '</td>';
} else {
tr_str += '<td></td>';
}
}
tr_str += '</tr>';
html.push(tr_str);
});
$("#grid-ndp > tbody").html(html.join(''));
}
$("#grid-ndp").bootgrid(gridopt);
}
);
}
// initial fetch
$("#refresh").click(updateNDP);
$("#refresh").click();
});
</script>
<div class="content-box">
<div class="content-box-main">
<div class="table-responsive">
<div class="col-sm-12">
<table id="grid-ndp" class="table table-condensed table-hover table-striped table-responsive">
<thead>
<tr>
<th data-column-id="ip" data-type="string" >{{ lang._('IPv6') }}</th>
<th data-column-id="mac" data-type="string" data-identifier="true">{{ lang._('MAC') }}</th>
<th data-column-id="manufacturer" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('Manufacturer') }}</th>
<th data-column-id="intf" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('Interface') }}</th>
<th data-column-id="intf_description" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('Interface name') }}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="col-sm-12">
<div class="row">
<div class="col-xs-12">
<div class="pull-right">
<button id="refresh" type="button" class="btn btn-default">
<span>{{ lang._('Refresh') }}</span>
<span class="fa fa-refresh"></span>
</button>
</div>
</div>
</div>
<hr/>
</div>
</div>
</div>
</div>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment