1
|
<?php
|
2
|
/*
|
3
|
* status_interfaces.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2016 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
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
14
|
* you may not use this file except in compliance with the License.
|
15
|
* You may obtain a copy of the License at
|
16
|
*
|
17
|
* http://www.apache.org/licenses/LICENSE-2.0
|
18
|
*
|
19
|
* Unless required by applicable law or agreed to in writing, software
|
20
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
21
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
22
|
* See the License for the specific language governing permissions and
|
23
|
* limitations under the License.
|
24
|
*/
|
25
|
|
26
|
##|+PRIV
|
27
|
##|*IDENT=page-status-interfaces
|
28
|
##|*NAME=Status: Interfaces
|
29
|
##|*DESCR=Allow access to the 'Status: Interfaces' page.
|
30
|
##|*MATCH=status_interfaces.php*
|
31
|
##|-PRIV
|
32
|
|
33
|
require_once("guiconfig.inc");
|
34
|
require_once("shaper.inc");
|
35
|
require_once("filter.inc");
|
36
|
|
37
|
if ($_POST['ifdescr'] && $_POST['submit']) {
|
38
|
$interface = $_POST['ifdescr'];
|
39
|
if ($_POST['status'] == "up") {
|
40
|
if ($_POST['relinquish_lease']) {
|
41
|
dhcp_relinquish_lease($_POST['if'], $_POST['ifdescr'], $_POST['ipv']);
|
42
|
}
|
43
|
interface_bring_down($interface);
|
44
|
} else {
|
45
|
interface_configure($interface);
|
46
|
}
|
47
|
header("Location: status_interfaces.php");
|
48
|
exit;
|
49
|
}
|
50
|
|
51
|
$formtemplate = '<form name="%s" action="status_interfaces.php" method="post">' .
|
52
|
'<input type="hidden" name="ifdescr" value="%s" />' .
|
53
|
'<input type="hidden" name="status" value="%s" />' .
|
54
|
'%s' .
|
55
|
'<button type="submit" name="submit" class="btn btn-warning btn-xs" value="%s">' .
|
56
|
'<i class="fa fa-refresh icon-embed-btn"></i>' .
|
57
|
'%s' .
|
58
|
'</button>' .
|
59
|
'%s' .
|
60
|
'</form>';
|
61
|
|
62
|
// Display a term/definition pair
|
63
|
function showDef($show, $term, $def) {
|
64
|
if ($show) {
|
65
|
print('<dt>' . $term . '</dt>');
|
66
|
print('<dd>' . htmlspecialchars($def) . '</dd>');
|
67
|
}
|
68
|
}
|
69
|
|
70
|
// Display a term/definition pair with a button
|
71
|
function showDefBtn($show, $term, $def, $ifdescr, $btnlbl, $chkbox_relinquish_lease) {
|
72
|
global $formtemplate;
|
73
|
|
74
|
if ($show) {
|
75
|
print('<dt>' . $term . '</dt>');
|
76
|
print('<dd>');
|
77
|
printf($formtemplate, $term, $ifdescr, $show, htmlspecialchars($def) . ' ', $btnlbl, $btnlbl, $chkbox_relinquish_lease);
|
78
|
print('</dd>');
|
79
|
}
|
80
|
}
|
81
|
|
82
|
// Relinquish the DHCP lease from the server.
|
83
|
function dhcp_relinquish_lease($if, $ifdescr, $ipv) {
|
84
|
$leases_db = '/var/db/dhclient.leases.' . $if;
|
85
|
$conf_file = '/var/etc/dhclient_'.$ifdescr.'.conf';
|
86
|
$script_file = '/usr/local/sbin/pfSense-dhclient-script';
|
87
|
|
88
|
if (file_exists($leases_db) && file_exists($script_file)) {
|
89
|
mwexec('/usr/local/sbin/dhclient -'.$ipv.' -d -r -lf '.$leases_db.' -cf '.$conf_file.' -sf '.$script_file);
|
90
|
}
|
91
|
}
|
92
|
|
93
|
$pgtitle = array(gettext("Status"), gettext("Interfaces"));
|
94
|
$shortcut_section = "interfaces";
|
95
|
include("head.inc");
|
96
|
|
97
|
$ifdescrs = get_configured_interface_with_descr(false, true);
|
98
|
|
99
|
foreach ($ifdescrs as $ifdescr => $ifname):
|
100
|
$ifinfo = get_interface_info($ifdescr);
|
101
|
$mac_man = load_mac_manufacturer_table();
|
102
|
|
103
|
$chkbox_relinquish_lease = ' ' .
|
104
|
'<input type="checkbox" name="relinquish_lease" value="true" title="' . gettext("Send a gratuitous DHCP release packet to the server.") . '" /> ' . gettext("Relinquish Lease") .
|
105
|
'<input type="hidden" name="if" value='.$ifinfo['if'].' />';
|
106
|
$chkbox_relinquish_lease_v4 = $chkbox_relinquish_lease . '<input type="hidden" name="ipv" value=4 />';
|
107
|
$chkbox_relinquish_lease_v6 = $chkbox_relinquish_lease . '<input type="hidden" name="ipv" value=6 />';
|
108
|
?>
|
109
|
|
110
|
<div class="panel panel-default">
|
111
|
<div class="panel-heading"><h2 class="panel-title"><?=htmlspecialchars($ifname)?><?=gettext(" Interface "); ?>(<?=htmlspecialchars($ifdescr)?>, <?=htmlspecialchars($ifinfo['hwif'])?>)</h2></div>
|
112
|
<div class="panel-body">
|
113
|
<dl class="dl-horizontal">
|
114
|
<?php
|
115
|
showDef(true, gettext("Status"), $ifinfo['status']);
|
116
|
showDefBtn($ifinfo['dhcplink'], 'DHCP', $ifinfo['dhcplink'], $ifdescr, $ifinfo['dhcplink'] == "up" ? gettext("Release") : gettext("Renew"), $ifinfo['dhcplink'] == "up" ? $chkbox_relinquish_lease_v4 : '');
|
117
|
showDefBtn($ifinfo['dhcp6link'], 'DHCP6', $ifinfo['dhcp6link'], $ifdescr, $ifinfo['dhcp6link'] == "up" ? gettext("Release") : gettext("Renew"), $ifinfo['dhcp6link'] == "up" ? $chkbox_relinquish_lease_v6 : '');
|
118
|
showDefBtn($ifinfo['pppoelink'], 'PPPoE', $ifinfo['pppoelink'], $ifdescr, $ifinfo['pppoelink'] == "up" ? gettext("Disconnect") : gettext("Connect"), '');
|
119
|
showDefBtn($ifinfo['pptplink'], 'PPTP', $ifinfo['pptplink'], $ifdescr, $ifinfo['pptplink'] == "up" ? gettext("Disconnect") : gettext("Connect"), '');
|
120
|
showDefBtn($ifinfo['l2tplink'], 'L2TP', $ifinfo['l2tplink'], $ifdescr, $ifinfo['l2tplink'] == "up" ? gettext("Disconnect") : gettext("Connect"), '');
|
121
|
showDefBtn($ifinfo['ppplink'], 'PPP', $ifinfo['ppplink'], $ifdescr, ($ifinfo['ppplink'] == "up" && !$ifinfo['nodevice']) ? gettext("Disconnect") : gettext("Connect"), '');
|
122
|
showDef($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated'], gettext("Uptime") . ' ' . ($ifinfo['ppp_uptime_accumulated'] ? '(historical)':''), $ifinfo['ppp_uptime'] . $ifinfo['ppp_uptime_accumulated']);
|
123
|
showDef($ifinfo['cell_rssi'], gettext("Cell Signal (RSSI)"), $ifinfo['cell_rssi']);
|
124
|
showDef($ifinfo['cell_mode'], gettext("Cell Mode"), $ifinfo['cell_mode']);
|
125
|
showDef($ifinfo['cell_simstate'], gettext("Cell SIM State"), $ifinfo['cell_simstate']);
|
126
|
showDef($ifinfo['cell_service'], gettext("Cell Service"), $ifinfo['cell_service']);
|
127
|
showDef($ifinfo['cell_bwupstream'], gettext("Cell Upstream"), $ifinfo['cell_bwupstream']);
|
128
|
showDef($ifinfo['cell_bwdownstream'], gettext("Cell Downstream"), $ifinfo['cell_bwdownstream']);
|
129
|
showDef($ifinfo['cell_upstream'], gettext("Cell Current Up"), $ifinfo['cell_upstream']);
|
130
|
showDef($ifinfo['cell_downstream'], gettext("Cell Current Down"), $ifinfo['cell_downstream']);
|
131
|
|
132
|
if ($ifinfo['macaddr']) {
|
133
|
$mac=$ifinfo['macaddr'];
|
134
|
$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
|
135
|
showDef( $ifinfo['macaddr'], gettext('MAC Address'), $mac . (isset($mac_man[$mac_hi]) ? ' - ' . $mac_man[$mac_hi] : ''));
|
136
|
}
|
137
|
|
138
|
if ($ifinfo['status'] != "down") {
|
139
|
if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down") {
|
140
|
showDef($ifinfo['ipaddr'], gettext('IPv4 Address'), $ifinfo['ipaddr']);
|
141
|
showDef($ifinfo['subnet'], gettext('Subnet mask IPv4'), $ifinfo['subnet']);
|
142
|
showDef($ifinfo['gateway'], gettext('Gateway IPv4'), $ifinfo['gateway']);
|
143
|
showDef($ifinfo['linklocal'], gettext('IPv6 Link Local'), $ifinfo['linklocal']);
|
144
|
showDef($ifinfo['ipaddrv6'], gettext('IPv6 Address'), $ifinfo['ipaddrv6']);
|
145
|
showDef($ifinfo['subnetv6'], gettext('Subnet mask IPv6'), $ifinfo['subnetv6']);
|
146
|
showDef($ifinfo['gatewayv6'], gettext("Gateway IPv6"), $config['interfaces'][$ifdescr]['gatewayv6'] . " " . $ifinfo['gatewayv6']);
|
147
|
|
148
|
if ($ifdescr == "wan" && file_exists("{$g['etc_path']}/resolv.conf")) {
|
149
|
$dns_servers = get_dns_servers();
|
150
|
$dnscnt = 0;
|
151
|
foreach ($dns_servers as $dns) {
|
152
|
showDef(true, $dnscnt == 0 ? gettext('DNS servers'):'', $dns);
|
153
|
$dnscnt++;
|
154
|
}
|
155
|
}
|
156
|
}
|
157
|
|
158
|
showDef($ifinfo['mtu'], gettext("MTU"), $ifinfo['mtu']);
|
159
|
showDef($ifinfo['media'], gettext("Media"), $ifinfo['media']);
|
160
|
showDef($ifinfo['laggproto'], gettext("LAGG Protocol"), $ifinfo['laggproto']);
|
161
|
showDef($ifinfo['laggport'], gettext("LAGG Ports"), $laggport);
|
162
|
showDef($ifinfo['channel'], gettext("Channel"), $ifinfo['channel']);
|
163
|
showDef($ifinfo['ssid'], gettext("SSID"), $ifinfo['ssid']);
|
164
|
showDef($ifinfo['bssid'], gettext("BSSID"), $ifinfo['bssid']);
|
165
|
showDef($ifinfo['rate'], gettext("Rate"), $ifinfo['rate']);
|
166
|
showDef($ifinfo['rssi'], gettext("RSSI"), $ifinfo['rssi']);
|
167
|
showDef(true, gettext("In/out packets"),
|
168
|
$ifinfo['inpkts'] . '/' . $ifinfo['outpkts'] . " (" . format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");
|
169
|
showDef(true, gettext("In/out packets (pass)"),
|
170
|
$ifinfo['inpktspass'] . '/' . $ifinfo['outpktspass'] . " (" . format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
|
171
|
showDef(true, gettext("In/out packets (block)"),
|
172
|
$ifinfo['inpktsblock'] . '/' . $ifinfo['outpktsblock'] . " (" . format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
|
173
|
showDef(isset($ifinfo['inerrs']), gettext("In/out errors"), $ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);
|
174
|
showDef(isset($ifinfo['collisions']), gettext("Collisions"), $ifinfo['collisions']);
|
175
|
} // e-o-if ($ifinfo['status'] != "down")
|
176
|
|
177
|
showDef($ifinfo['bridge'], gettext('Bridge (') . $ifinfo['bridgeint'] . ')', $ifinfo['bridge']);
|
178
|
|
179
|
if (file_exists("/usr/bin/vmstat")) {
|
180
|
$real_interface = "";
|
181
|
$interrupt_total = "";
|
182
|
$interrupt_sec = "";
|
183
|
$real_interface = $ifinfo['hwif'];
|
184
|
$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
|
185
|
$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
|
186
|
|
187
|
if (strstr($interrupt_total, "hci")) {
|
188
|
$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
|
189
|
$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;
|
190
|
}
|
191
|
|
192
|
unset($interrupt_total);
|
193
|
|
194
|
showDef($interrupt_total, gettext('Total interrupts'), $interrupt_total);
|
195
|
showDef($interrupt_total, '', $interrupt_sec . " " . $interrupt_total);
|
196
|
}
|
197
|
?>
|
198
|
</dl>
|
199
|
</div>
|
200
|
</div>
|
201
|
|
202
|
<?php
|
203
|
endforeach;
|
204
|
|
205
|
print_info_box(gettext("Using dial-on-demand will bring the connection up again if any packet ".
|
206
|
"triggers it. To substantiate this point: disconnecting manually ".
|
207
|
"will <strong>not</strong> prevent dial-on-demand from making connections ".
|
208
|
"to the outside! Don't use dial-on-demand if the line ".
|
209
|
"is to be kept disconnected."), 'warning', false);
|
210
|
include("foot.inc");
|
211
|
?>
|