1 |
93e1b16c
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* diag_arp.php
|
4 |
9da2cf1c
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
38809d47
|
Renato Botelho do Couto
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7 |
|
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8 |
8f585441
|
Luiz Souza
|
* Copyright (c) 2014-2021 Rubicon Communications, LLC (Netgate)
|
9 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
10 |
fd9ebcd5
|
Stephen Beaver
|
*
|
11 |
c5d81585
|
Renato Botelho
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
12 |
|
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
13 |
|
|
* All rights reserved.
|
14 |
fd9ebcd5
|
Stephen Beaver
|
*
|
15 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
16 |
|
|
* you may not use this file except in compliance with the License.
|
17 |
|
|
* You may obtain a copy of the License at
|
18 |
fd9ebcd5
|
Stephen Beaver
|
*
|
19 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
20 |
fd9ebcd5
|
Stephen Beaver
|
*
|
21 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
22 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
23 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
24 |
|
|
* See the License for the specific language governing permissions and
|
25 |
|
|
* limitations under the License.
|
26 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
27 |
93e1b16c
|
Scott Ullrich
|
|
28 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
29 |
|
|
##|*IDENT=page-diagnostics-arptable
|
30 |
5230f468
|
jim-p
|
##|*NAME=Diagnostics: ARP Table
|
31 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Diagnostics: ARP Table' page.
|
32 |
|
|
##|*MATCH=diag_arp.php*
|
33 |
|
|
##|-PRIV
|
34 |
|
|
|
35 |
868ba36d
|
Scott Ullrich
|
@ini_set('zlib.output_compression', 0);
|
36 |
|
|
@ini_set('implicit_flush', 1);
|
37 |
6b07c15a
|
Matthew Grooms
|
|
38 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
39 |
0b42c221
|
Steve Beaver
|
require_once("diag_arp.inc");
|
40 |
6090e85b
|
Bill Marquette
|
|
41 |
6ea0d41e
|
stilez
|
// delete arp entry
|
42 |
7f4268b6
|
Steve Beaver
|
if (isset($_POST['deleteentry'])) {
|
43 |
|
|
$ip = $_POST['deleteentry'];
|
44 |
6ea0d41e
|
stilez
|
if (is_ipaddrv4($ip)) {
|
45 |
7f4268b6
|
Steve Beaver
|
$ret = mwexec("arp -d " . $_POST['deleteentry'], true);
|
46 |
6ea0d41e
|
stilez
|
} else {
|
47 |
|
|
$ret = 1;
|
48 |
|
|
}
|
49 |
|
|
if ($ret) {
|
50 |
|
|
$savemsg = sprintf(gettext("%s is not a valid IPv4 address or could not be deleted."), $ip);
|
51 |
|
|
$savemsgtype = 'alert-warning';
|
52 |
|
|
} else {
|
53 |
|
|
$savemsg = sprintf(gettext("The ARP cache entry for %s has been deleted."), $ip);
|
54 |
|
|
$savemsgtype = 'success';
|
55 |
|
|
}
|
56 |
6f3f9671
|
Viktor G
|
} elseif (isset($_POST['cleararptable'])) {
|
57 |
|
|
$out = "";
|
58 |
|
|
$ret = exec("/usr/sbin/arp -d -a", $out, $arpTableRetVal);
|
59 |
|
|
if ($arpTableRetVal == 0) {
|
60 |
|
|
$savemsg = gettext("ARP Table has been cleared.");
|
61 |
|
|
$savemsgtype = 'success';
|
62 |
|
|
} else {
|
63 |
|
|
$savemsg = gettext("Unable to clear ARP Table.");
|
64 |
|
|
$savemsgtype = 'alert-warning';
|
65 |
|
|
}
|
66 |
6ea0d41e
|
stilez
|
}
|
67 |
|
|
|
68 |
fc259334
|
Seth Mos
|
|
69 |
0b42c221
|
Steve Beaver
|
$arp_table = prepare_ARP_table();
|
70 |
93e1b16c
|
Scott Ullrich
|
|
71 |
699737d9
|
Phil Davis
|
$pgtitle = array(gettext("Diagnostics"), gettext("ARP Table"));
|
72 |
fc259334
|
Seth Mos
|
include("head.inc");
|
73 |
20b9b335
|
Scott Ullrich
|
|
74 |
6ea0d41e
|
stilez
|
// Handle save msg if defined
|
75 |
|
|
if ($savemsg) {
|
76 |
|
|
print_info_box(htmlentities($savemsg), $savemsgtype);
|
77 |
|
|
}
|
78 |
93e1b16c
|
Scott Ullrich
|
?>
|
79 |
9297ad65
|
jim-p
|
<div class="panel panel-default" id="search-panel">
|
80 |
|
|
<div class="panel-heading">
|
81 |
|
|
<h2 class="panel-title">
|
82 |
|
|
<?=gettext('Search')?>
|
83 |
|
|
<span class="widget-heading-icon pull-right">
|
84 |
|
|
<a data-toggle="collapse" href="#search-panel_panel-body">
|
85 |
|
|
<i class="fa fa-plus-circle"></i>
|
86 |
|
|
</a>
|
87 |
|
|
</span>
|
88 |
|
|
</h2>
|
89 |
|
|
</div>
|
90 |
|
|
<div id="search-panel_panel-body" class="panel-body collapse in">
|
91 |
|
|
<div class="form-group">
|
92 |
|
|
<label class="col-sm-2 control-label">
|
93 |
|
|
<?=gettext("Search term")?>
|
94 |
|
|
</label>
|
95 |
|
|
<div class="col-sm-5"><input class="form-control" name="searchstr" id="searchstr" type="text"/></div>
|
96 |
|
|
<div class="col-sm-2">
|
97 |
|
|
<select id="where" class="form-control">
|
98 |
|
|
<option value="0"><?=gettext("Interface")?></option>
|
99 |
|
|
<option value="1"><?=gettext("IP Address")?></option>
|
100 |
|
|
<option value="2"><?=gettext("MAC Address")?></option>
|
101 |
|
|
<option value="3"><?=gettext("Hostname")?></option>
|
102 |
|
|
<option value="4"><?=gettext("Status")?></option>
|
103 |
|
|
<option value="5"><?=gettext("Link Type")?></option>
|
104 |
|
|
<option value="6" selected><?=gettext("All")?></option>
|
105 |
|
|
</select>
|
106 |
|
|
</div>
|
107 |
|
|
<div class="col-sm-3">
|
108 |
|
|
<a id="btnsearch" title="<?=gettext("Search")?>" class="btn btn-primary btn-sm"><i class="fa fa-search icon-embed-btn"></i><?=gettext("Search")?></a>
|
109 |
|
|
<a id="btnclear" title="<?=gettext("Clear")?>" class="btn btn-info btn-sm"><i class="fa fa-undo icon-embed-btn"></i><?=gettext("Clear")?></a>
|
110 |
|
|
</div>
|
111 |
|
|
<div class="col-sm-10 col-sm-offset-2">
|
112 |
|
|
<span class="help-block"><?=gettext('Enter a search string or *nix regular expression to filter entries.')?></span>
|
113 |
|
|
</div>
|
114 |
|
|
</div>
|
115 |
|
|
</div>
|
116 |
|
|
</div>
|
117 |
|
|
|
118 |
ac950976
|
Colin Fleming
|
<div class="panel panel-default">
|
119 |
|
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('ARP Table')?></h2></div>
|
120 |
|
|
<div class="panel-body">
|
121 |
|
|
|
122 |
89f64f0f
|
Sander van Leeuwen
|
<div class="table-responsive">
|
123 |
608947a8
|
Stephen Beaver
|
<table class="sortable-theme-bootstrap table table-striped table-hover" data-sortable>
|
124 |
89f64f0f
|
Sander van Leeuwen
|
<thead>
|
125 |
|
|
<tr>
|
126 |
|
|
<th><?= gettext("Interface")?></th>
|
127 |
|
|
<th><?= gettext("IP address")?></th>
|
128 |
|
|
<th><?= gettext("MAC address")?></th>
|
129 |
|
|
<th><?= gettext("Hostname")?></th>
|
130 |
9e3cb876
|
jim-p
|
<th><?= gettext("Status")?></th>
|
131 |
|
|
<th><?= gettext("Link Type")?></th>
|
132 |
6ea0d41e
|
stilez
|
<th data-sortable="false"><?=gettext("Actions")?></th>
|
133 |
89f64f0f
|
Sander van Leeuwen
|
</tr>
|
134 |
|
|
</thead>
|
135 |
|
|
<tbody>
|
136 |
947141fd
|
Phil Davis
|
|
137 |
82afb104
|
Stephen Beaver
|
<?php
|
138 |
6624a6be
|
Renato Botelho
|
foreach ($arp_table as $entry): ?>
|
139 |
89f64f0f
|
Sander van Leeuwen
|
<tr>
|
140 |
0b42c221
|
Steve Beaver
|
<td><?=$entry['interface']?></td>
|
141 |
6624a6be
|
Renato Botelho
|
<td><?=$entry['ip-address']?></td>
|
142 |
0b42c221
|
Steve Beaver
|
<td><?=$entry['mac-address']?></td>
|
143 |
|
|
<td><?=$entry['dnsresolve']?></td>
|
144 |
|
|
<td><?=$entry['expires']?></td>
|
145 |
6624a6be
|
Renato Botelho
|
<td><?=$entry['type']?></td>
|
146 |
6ea0d41e
|
stilez
|
<td>
|
147 |
6624a6be
|
Renato Botelho
|
<a class="fa fa-trash" title="<?=gettext('Delete arp cache entry')?>" href="diag_arp.php?deleteentry=<?=$entry['ip-address']?>" usepost></a>
|
148 |
6ea0d41e
|
stilez
|
</td>
|
149 |
89f64f0f
|
Sander van Leeuwen
|
</tr>
|
150 |
6624a6be
|
Renato Botelho
|
<?php
|
151 |
|
|
endforeach
|
152 |
|
|
?>
|
153 |
89f64f0f
|
Sander van Leeuwen
|
</tbody>
|
154 |
|
|
</table>
|
155 |
|
|
</div>
|
156 |
|
|
|
157 |
ac950976
|
Colin Fleming
|
</div>
|
158 |
|
|
</div>
|
159 |
|
|
|
160 |
6f3f9671
|
Viktor G
|
<nav class="action-buttons">
|
161 |
|
|
<button id="cleararp" class="btn btn-danger no-confirm">
|
162 |
|
|
<i class="fa fa-trash icon-embed-btn"></i>
|
163 |
|
|
<?=gettext("Clear ARP Table")?>
|
164 |
|
|
</button>
|
165 |
|
|
</nav>
|
166 |
|
|
|
167 |
cba48c64
|
Colin Fleming
|
<script type="text/javascript">
|
168 |
293ceb87
|
Colin Fleming
|
//<![CDATA[
|
169 |
a4af095c
|
Renato Botelho
|
// Clear the "loading" div once the page has loaded"
|
170 |
947141fd
|
Phil Davis
|
events.push(function() {
|
171 |
a4af095c
|
Renato Botelho
|
$('#loading').empty();
|
172 |
9297ad65
|
jim-p
|
|
173 |
|
|
// Make these controls plain buttons
|
174 |
|
|
$("#btnsearch").prop('type', 'button');
|
175 |
|
|
$("#btnclear").prop('type', 'button');
|
176 |
|
|
|
177 |
|
|
// Search for a term in the entry name and/or dn
|
178 |
|
|
$("#btnsearch").click(function() {
|
179 |
|
|
var searchstr = $('#searchstr').val().toLowerCase();
|
180 |
|
|
var table = $("table tbody");
|
181 |
|
|
var where = $('#where').val();
|
182 |
|
|
|
183 |
|
|
table.find('tr').each(function (i) {
|
184 |
|
|
var $tds = $(this).find('td'),
|
185 |
|
|
iface = $tds.eq(0).text().trim().toLowerCase(),
|
186 |
|
|
ipaddr = $tds.eq(1).text().trim().toLowerCase();
|
187 |
|
|
macaddr = $tds.eq(2).text().trim().toLowerCase();
|
188 |
|
|
hostname = $tds.eq(3).text().trim().toLowerCase();
|
189 |
|
|
stat = $tds.eq(4).text().trim().toLowerCase();
|
190 |
|
|
linktype = $tds.eq(5).text().trim().toLowerCase();
|
191 |
|
|
|
192 |
|
|
regexp = new RegExp(searchstr);
|
193 |
|
|
if (searchstr.length > 0) {
|
194 |
|
|
if (!(regexp.test(iface) && ((where == 0) || (where == 6))) &&
|
195 |
|
|
!(regexp.test(ipaddr) && ((where == 1) || (where == 6))) &&
|
196 |
|
|
!(regexp.test(macaddr) && ((where == 2) || (where == 6))) &&
|
197 |
|
|
!(regexp.test(hostname) && ((where == 3) || (where == 6))) &&
|
198 |
|
|
!(regexp.test(stat) && ((where == 4) || (where == 6))) &&
|
199 |
|
|
!(regexp.test(linktype) && ((where == 5) || (where == 6)))
|
200 |
|
|
) {
|
201 |
|
|
$(this).hide();
|
202 |
|
|
} else {
|
203 |
|
|
$(this).show();
|
204 |
|
|
}
|
205 |
|
|
} else {
|
206 |
|
|
$(this).show(); // A blank search string shows all
|
207 |
|
|
}
|
208 |
|
|
});
|
209 |
|
|
});
|
210 |
|
|
|
211 |
|
|
// Clear the search term and unhide all rows (that were hidden during a previous search)
|
212 |
|
|
$("#btnclear").click(function() {
|
213 |
|
|
var table = $("table tbody");
|
214 |
|
|
|
215 |
|
|
$('#searchstr').val("");
|
216 |
|
|
|
217 |
|
|
table.find('tr').each(function (i) {
|
218 |
|
|
$(this).show();
|
219 |
|
|
});
|
220 |
|
|
});
|
221 |
|
|
|
222 |
|
|
// Hitting the enter key will do the same as clicking the search button
|
223 |
|
|
$("#searchstr").on("keyup", function (event) {
|
224 |
|
|
if (event.keyCode == 13) {
|
225 |
|
|
$("#btnsearch").get(0).click();
|
226 |
|
|
}
|
227 |
|
|
});
|
228 |
|
|
|
229 |
6f3f9671
|
Viktor G
|
$('#cleararp').click(function() {
|
230 |
|
|
if (confirm("Are you sure you wish to clear ARP table?")) {
|
231 |
|
|
postSubmit({cleararptable: 'true'}, 'diag_arp.php');
|
232 |
|
|
}
|
233 |
|
|
});
|
234 |
|
|
|
235 |
a4af095c
|
Renato Botelho
|
});
|
236 |
0da0d43e
|
Phil Davis
|
//]]>
|
237 |
4a993c8f
|
Scott Ullrich
|
</script>
|
238 |
a4af095c
|
Renato Botelho
|
|
239 |
c40962e9
|
Phil Davis
|
<div class="infoblock blockopen">
|
240 |
0da0d43e
|
Phil Davis
|
<?php
|
241 |
5db70796
|
Phil Davis
|
print_info_box(sprintf(gettext('Local IPv6 peers use %1$sNDP%2$s instead of ARP.'), '<a href="diag_ndp.php">', '</a>') . '<br />' .
|
242 |
|
|
'<br />' . gettext('Permanent ARP entries are shown for local interfaces or static ARP entries.') .
|
243 |
|
|
'<br />' . gettext('Normal dynamic ARP entries show a countdown timer until they will expire and then be re-checked.') .
|
244 |
|
|
'<br />' . gettext('Incomplete ARP entries indicate that the target host has not yet replied to an ARP request.'), 'info', false);
|
245 |
c40962e9
|
Phil Davis
|
?>
|
246 |
|
|
</div>
|
247 |
93e1b16c
|
Scott Ullrich
|
|
248 |
c40962e9
|
Phil Davis
|
<?php
|
249 |
|
|
include("foot.inc");
|
250 |
|
|
?>
|