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