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