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