1
|
<?php
|
2
|
/*
|
3
|
* status_interfaces.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
7
|
* All rights reserved.
|
8
|
*
|
9
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
10
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11
|
* All rights reserved.
|
12
|
*
|
13
|
* Redistribution and use in source and binary forms, with or without
|
14
|
* modification, are permitted provided that the following conditions are met:
|
15
|
*
|
16
|
* 1. Redistributions of source code must retain the above copyright notice,
|
17
|
* this list of conditions and the following disclaimer.
|
18
|
*
|
19
|
* 2. Redistributions in binary form must reproduce the above copyright
|
20
|
* notice, this list of conditions and the following disclaimer in
|
21
|
* the documentation and/or other materials provided with the
|
22
|
* distribution.
|
23
|
*
|
24
|
* 3. All advertising materials mentioning features or use of this software
|
25
|
* must display the following acknowledgment:
|
26
|
* "This product includes software developed by the pfSense Project
|
27
|
* for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
28
|
*
|
29
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
30
|
* endorse or promote products derived from this software without
|
31
|
* prior written permission. For written permission, please contact
|
32
|
* coreteam@pfsense.org.
|
33
|
*
|
34
|
* 5. Products derived from this software may not be called "pfSense"
|
35
|
* nor may "pfSense" appear in their names without prior written
|
36
|
* permission of the Electric Sheep Fencing, LLC.
|
37
|
*
|
38
|
* 6. Redistributions of any form whatsoever must retain the following
|
39
|
* acknowledgment:
|
40
|
*
|
41
|
* "This product includes software developed by the pfSense Project
|
42
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
43
|
*
|
44
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
45
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
46
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
47
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
48
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
49
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
50
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
51
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
52
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
53
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
54
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
55
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
56
|
*/
|
57
|
|
58
|
##|+PRIV
|
59
|
##|*IDENT=page-status-interfaces
|
60
|
##|*NAME=Status: Interfaces
|
61
|
##|*DESCR=Allow access to the 'Status: Interfaces' page.
|
62
|
##|*MATCH=status_interfaces.php*
|
63
|
##|-PRIV
|
64
|
|
65
|
require_once("guiconfig.inc");
|
66
|
require_once("shaper.inc");
|
67
|
require_once("filter.inc");
|
68
|
|
69
|
if ($_POST['ifdescr'] && $_POST['submit']) {
|
70
|
$interface = $_POST['ifdescr'];
|
71
|
if ($_POST['status'] == "up") {
|
72
|
if ($_POST['relinquish_lease']) {
|
73
|
dhcp_relinquish_lease($_POST['if'], $_POST['ifdescr'], $_POST['ipv']);
|
74
|
}
|
75
|
interface_bring_down($interface);
|
76
|
} else {
|
77
|
interface_configure($interface);
|
78
|
}
|
79
|
header("Location: status_interfaces.php");
|
80
|
exit;
|
81
|
}
|
82
|
|
83
|
$formtemplate = '<form name="%s" action="status_interfaces.php" method="post">' .
|
84
|
'<input type="hidden" name="ifdescr" value="%s" />' .
|
85
|
'<input type="hidden" name="status" value="%s" />' .
|
86
|
'%s' .
|
87
|
'<button type="submit" name="submit" class="btn btn-warning btn-xs" value="%s">' .
|
88
|
'<i class="fa fa-refresh icon-embed-btn"></i>' .
|
89
|
'%s' .
|
90
|
'</button>' .
|
91
|
'%s' .
|
92
|
'</form>';
|
93
|
|
94
|
// Display a term/definition pair
|
95
|
function showDef($show, $term, $def) {
|
96
|
if ($show) {
|
97
|
print('<dt>' . $term . '</dt>');
|
98
|
print('<dd>' . htmlspecialchars($def) . '</dd>');
|
99
|
}
|
100
|
}
|
101
|
|
102
|
// Display a term/definition pair with a button
|
103
|
function showDefBtn($show, $term, $def, $ifdescr, $btnlbl, $chkbox_relinquish_lease) {
|
104
|
global $formtemplate;
|
105
|
|
106
|
if ($show) {
|
107
|
print('<dt>' . $term . '</dt>');
|
108
|
print('<dd>');
|
109
|
printf($formtemplate, $term, $ifdescr, $show, htmlspecialchars($def) . ' ', $btnlbl, $btnlbl, $chkbox_relinquish_lease);
|
110
|
print('</dd>');
|
111
|
}
|
112
|
}
|
113
|
|
114
|
// Relinquish the DHCP lease from the server.
|
115
|
function dhcp_relinquish_lease($if, $ifdescr, $ipv) {
|
116
|
$leases_db = '/var/db/dhclient.leases.' . $if;
|
117
|
$conf_file = '/var/etc/dhclient_'.$ifdescr.'.conf';
|
118
|
$script_file = '/sbin/dhclient-script';
|
119
|
$ipv = ((int) $ipv == 6) ? '-6' : '-4';
|
120
|
|
121
|
if (file_exists($leases_db) && file_exists($script_file)) {
|
122
|
mwexec('/usr/local/sbin/dhclient {$ipv} -d -r' .
|
123
|
' -lf ' . escapeshellarg($leases_db) .
|
124
|
' -cf ' . escapeshellarg($conf_file) .
|
125
|
' -sf ' . escapeshellarg($script_file));
|
126
|
}
|
127
|
}
|
128
|
|
129
|
$pgtitle = array(gettext("Status"), gettext("Interfaces"));
|
130
|
$shortcut_section = "interfaces";
|
131
|
include("head.inc");
|
132
|
|
133
|
$ifdescrs = get_configured_interface_with_descr(false, true);
|
134
|
|
135
|
foreach ($ifdescrs as $ifdescr => $ifname):
|
136
|
$ifinfo = get_interface_info($ifdescr);
|
137
|
$mac_man = load_mac_manufacturer_table();
|
138
|
|
139
|
$chkbox_relinquish_lease = ' ' .
|
140
|
'<input type="checkbox" name="relinquish_lease" value="true" title="' . gettext("Send a gratuitous DHCP release packet to the server.") . '" /> ' . gettext("Relinquish Lease") .
|
141
|
'<input type="hidden" name="if" value='.$ifinfo['if'].' />';
|
142
|
$chkbox_relinquish_lease_v4 = $chkbox_relinquish_lease . '<input type="hidden" name="ipv" value=4 />';
|
143
|
$chkbox_relinquish_lease_v6 = $chkbox_relinquish_lease . '<input type="hidden" name="ipv" value=6 />';
|
144
|
?>
|
145
|
|
146
|
<div class="panel panel-default">
|
147
|
<div class="panel-heading"><h2 class="panel-title"><?=htmlspecialchars($ifname)?><?=gettext(" Interface "); ?>(<?=htmlspecialchars($ifdescr)?>, <?=htmlspecialchars($ifinfo['hwif'])?>)</h2></div>
|
148
|
<div class="panel-body">
|
149
|
<dl class="dl-horizontal">
|
150
|
<?php
|
151
|
showDef(true, gettext("Status"), $ifinfo['status']);
|
152
|
showDefBtn($ifinfo['dhcplink'], 'DHCP', $ifinfo['dhcplink'], $ifdescr, $ifinfo['dhcplink'] == "up" ? gettext("Release") : gettext("Renew"), $ifinfo['dhcplink'] == "up" ? $chkbox_relinquish_lease_v4 : '');
|
153
|
showDefBtn($ifinfo['dhcp6link'], 'DHCP6', $ifinfo['dhcp6link'], $ifdescr, $ifinfo['dhcp6link'] == "up" ? gettext("Release") : gettext("Renew"), $ifinfo['dhcp6link'] == "up" ? $chkbox_relinquish_lease_v6 : '');
|
154
|
showDefBtn($ifinfo['pppoelink'], 'PPPoE', $ifinfo['pppoelink'], $ifdescr, $ifinfo['pppoelink'] == "up" ? gettext("Disconnect") : gettext("Connect"), '');
|
155
|
showDefBtn($ifinfo['pptplink'], 'PPTP', $ifinfo['pptplink'], $ifdescr, $ifinfo['pptplink'] == "up" ? gettext("Disconnect") : gettext("Connect"), '');
|
156
|
showDefBtn($ifinfo['l2tplink'], 'L2TP', $ifinfo['l2tplink'], $ifdescr, $ifinfo['l2tplink'] == "up" ? gettext("Disconnect") : gettext("Connect"), '');
|
157
|
showDefBtn($ifinfo['ppplink'], 'PPP', $ifinfo['ppplink'], $ifdescr, ($ifinfo['ppplink'] == "up" && !$ifinfo['nodevice']) ? gettext("Disconnect") : gettext("Connect"), '');
|
158
|
showDef($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated'], gettext("Uptime") . ' ' . ($ifinfo['ppp_uptime_accumulated'] ? '(historical)':''), $ifinfo['ppp_uptime'] . $ifinfo['ppp_uptime_accumulated']);
|
159
|
showDef($ifinfo['cell_rssi'], gettext("Cell Signal (RSSI)"), $ifinfo['cell_rssi']);
|
160
|
showDef($ifinfo['cell_mode'], gettext("Cell Mode"), $ifinfo['cell_mode']);
|
161
|
showDef($ifinfo['cell_simstate'], gettext("Cell SIM State"), $ifinfo['cell_simstate']);
|
162
|
showDef($ifinfo['cell_service'], gettext("Cell Service"), $ifinfo['cell_service']);
|
163
|
showDef($ifinfo['cell_bwupstream'], gettext("Cell Upstream"), $ifinfo['cell_bwupstream']);
|
164
|
showDef($ifinfo['cell_bwdownstream'], gettext("Cell Downstream"), $ifinfo['cell_bwdownstream']);
|
165
|
showDef($ifinfo['cell_upstream'], gettext("Cell Current Up"), $ifinfo['cell_upstream']);
|
166
|
showDef($ifinfo['cell_downstream'], gettext("Cell Current Down"), $ifinfo['cell_downstream']);
|
167
|
|
168
|
if ($ifinfo['macaddr']) {
|
169
|
$mac=$ifinfo['macaddr'];
|
170
|
$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
|
171
|
showDef( $ifinfo['macaddr'], gettext('MAC Address'), $mac . (isset($mac_man[$mac_hi]) ? ' - ' . $mac_man[$mac_hi] : ''));
|
172
|
}
|
173
|
|
174
|
if ($ifinfo['status'] != "down") {
|
175
|
if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down") {
|
176
|
showDef($ifinfo['ipaddr'], gettext('IPv4 Address'), $ifinfo['ipaddr']);
|
177
|
showDef($ifinfo['subnet'], gettext('Subnet mask IPv4'), $ifinfo['subnet']);
|
178
|
showDef($ifinfo['gateway'], gettext('Gateway IPv4'), $ifinfo['gateway']);
|
179
|
showDef($ifinfo['linklocal'], gettext('IPv6 Link Local'), $ifinfo['linklocal']);
|
180
|
showDef($ifinfo['ipaddrv6'], gettext('IPv6 Address'), $ifinfo['ipaddrv6']);
|
181
|
showDef($ifinfo['subnetv6'], gettext('Subnet mask IPv6'), $ifinfo['subnetv6']);
|
182
|
showDef($ifinfo['gatewayv6'], gettext("Gateway IPv6"), $config['interfaces'][$ifdescr]['gatewayv6'] . " " . $ifinfo['gatewayv6']);
|
183
|
|
184
|
if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")) {
|
185
|
$dns_servers = get_dns_servers();
|
186
|
$dnscnt = 0;
|
187
|
foreach ($dns_servers as $dns) {
|
188
|
showDef(true, $dnscnt == 0 ? gettext('DNS servers'):'', $dns);
|
189
|
$dnscnt++;
|
190
|
}
|
191
|
}
|
192
|
}
|
193
|
|
194
|
showDef($ifinfo['mtu'], gettext("MTU"), $ifinfo['mtu']);
|
195
|
showDef($ifinfo['media'], gettext("Media"), $ifinfo['media']);
|
196
|
showDef($ifinfo['laggproto'], gettext("LAGG Protocol"), $ifinfo['laggproto']);
|
197
|
showDef($ifinfo['laggport'], gettext("LAGG Ports"), $laggport);
|
198
|
showDef($ifinfo['channel'], gettext("Channel"), $ifinfo['channel']);
|
199
|
showDef($ifinfo['ssid'], gettext("SSID"), $ifinfo['ssid']);
|
200
|
showDef($ifinfo['bssid'], gettext("BSSID"), $ifinfo['bssid']);
|
201
|
showDef($ifinfo['rate'], gettext("Rate"), $ifinfo['rate']);
|
202
|
showDef($ifinfo['rssi'], gettext("RSSI"), $ifinfo['rssi']);
|
203
|
showDef(true, gettext("In/out packets"),
|
204
|
$ifinfo['inpkts'] . '/' . $ifinfo['outpkts'] . " (" . format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");
|
205
|
showDef(true, gettext("In/out packets (pass)"),
|
206
|
$ifinfo['inpktspass'] . '/' . $ifinfo['outpktspass'] . " (" . format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
|
207
|
showDef(true, gettext("In/out packets (block)"),
|
208
|
$ifinfo['inpktsblock'] . '/' . $ifinfo['outpktsblock'] . " (" . format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
|
209
|
showDef(isset($ifinfo['inerrs']), gettext("In/out errors"), $ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);
|
210
|
showDef(isset($ifinfo['collisions']), gettext("Collisions"), $ifinfo['collisions']);
|
211
|
} // e-o-if ($ifinfo['status'] != "down")
|
212
|
|
213
|
showDef($ifinfo['bridge'], gettext('Bridge (') . $ifinfo['bridgeint'] . ')', $ifinfo['bridge']);
|
214
|
|
215
|
if (file_exists("/usr/bin/vmstat")) {
|
216
|
$real_interface = "";
|
217
|
$interrupt_total = "";
|
218
|
$interrupt_sec = "";
|
219
|
$real_interface = $ifinfo['hwif'];
|
220
|
$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
|
221
|
$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
|
222
|
|
223
|
if (strstr($interrupt_total, "hci")) {
|
224
|
$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
|
225
|
$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;
|
226
|
}
|
227
|
|
228
|
unset($interrupt_total);
|
229
|
|
230
|
showDef($interrupt_total, gettext('Total interrupts'), $interrupt_total);
|
231
|
showDef($interrupt_total, '', $interrupt_sec . " " . $interrupt_total);
|
232
|
}
|
233
|
?>
|
234
|
</dl>
|
235
|
</div>
|
236
|
</div>
|
237
|
|
238
|
<?php
|
239
|
endforeach;
|
240
|
|
241
|
print_info_box(gettext("Using dial-on-demand will bring the connection up again if any packet ".
|
242
|
"triggers it. To substantiate this point: disconnecting manually ".
|
243
|
"will <strong>not</strong> prevent dial-on-demand from making connections ".
|
244
|
"to the outside! Don't use dial-on-demand if the line ".
|
245
|
"is to be kept disconnected."), 'warning', false);
|
246
|
include("foot.inc");
|
247
|
?>
|