1 |
8cccee1c
|
Scott Ullrich
|
<?php
|
2 |
5b237745
|
Scott Ullrich
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* status_interfaces.php
|
4 |
191cb31d
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
b8f91b7c
|
Luiz Souza
|
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
8 |
66c52114
|
Stephen Beaver
|
*
|
9 |
c5d81585
|
Renato Botelho
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
10 |
|
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11 |
|
|
* All rights reserved.
|
12 |
66c52114
|
Stephen Beaver
|
*
|
13 |
b12ea3fb
|
Renato Botelho
|
* 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 |
66c52114
|
Stephen Beaver
|
*
|
17 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
18 |
66c52114
|
Stephen Beaver
|
*
|
19 |
b12ea3fb
|
Renato Botelho
|
* 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 |
66c52114
|
Stephen Beaver
|
*/
|
25 |
5b237745
|
Scott Ullrich
|
|
26 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
27 |
|
|
##|*IDENT=page-status-interfaces
|
28 |
5230f468
|
jim-p
|
##|*NAME=Status: Interfaces
|
29 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Status: Interfaces' page.
|
30 |
|
|
##|*MATCH=status_interfaces.php*
|
31 |
|
|
##|-PRIV
|
32 |
|
|
|
33 |
51caa77a
|
Scott Ullrich
|
require_once("guiconfig.inc");
|
34 |
8fbe2ea4
|
doktornotor
|
require_once("interfaces.inc");
|
35 |
|
|
require_once("pfsense-utils.inc");
|
36 |
|
|
require_once("util.inc");
|
37 |
5b237745
|
Scott Ullrich
|
|
38 |
db0a2efc
|
NOYB
|
if ($_POST['ifdescr'] && $_POST['submit']) {
|
39 |
|
|
$interface = $_POST['ifdescr'];
|
40 |
42b0c921
|
Phil Davis
|
if ($_POST['status'] == "up") {
|
41 |
718432f1
|
NOYB
|
if ($_POST['relinquish_lease']) {
|
42 |
|
|
dhcp_relinquish_lease($_POST['if'], $_POST['ifdescr'], $_POST['ipv']);
|
43 |
|
|
}
|
44 |
80bf3f4a
|
Ermal Luçi
|
interface_bring_down($interface);
|
45 |
42b0c921
|
Phil Davis
|
} else {
|
46 |
bd06568f
|
sbeaver
|
interface_configure($interface);
|
47 |
42b0c921
|
Phil Davis
|
}
|
48 |
56e1d16e
|
Ermal Lu?i
|
header("Location: status_interfaces.php");
|
49 |
|
|
exit;
|
50 |
c26e2cf0
|
Scott Ullrich
|
}
|
51 |
|
|
|
52 |
bd06568f
|
sbeaver
|
$formtemplate = '<form name="%s" action="status_interfaces.php" method="post">' .
|
53 |
db0a2efc
|
NOYB
|
'<input type="hidden" name="ifdescr" value="%s" />' .
|
54 |
bd06568f
|
sbeaver
|
'<input type="hidden" name="status" value="%s" />' .
|
55 |
|
|
'%s' .
|
56 |
27d6a45b
|
jim-p
|
'<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 |
718432f1
|
NOYB
|
'%s' .
|
61 |
bd06568f
|
sbeaver
|
'</form>';
|
62 |
|
|
|
63 |
|
|
// Display a term/definition pair
|
64 |
|
|
function showDef($show, $term, $def) {
|
65 |
abe98adb
|
Phil Davis
|
if ($show) {
|
66 |
bd06568f
|
sbeaver
|
print('<dt>' . $term . '</dt>');
|
67 |
fb6c7bb8
|
sbeaver
|
print('<dd>' . htmlspecialchars($def) . '</dd>');
|
68 |
bd06568f
|
sbeaver
|
}
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
// Display a term/definition pair with a button
|
72 |
718432f1
|
NOYB
|
function showDefBtn($show, $term, $def, $ifdescr, $btnlbl, $chkbox_relinquish_lease) {
|
73 |
bd06568f
|
sbeaver
|
global $formtemplate;
|
74 |
|
|
|
75 |
abe98adb
|
Phil Davis
|
if ($show) {
|
76 |
bd06568f
|
sbeaver
|
print('<dt>' . $term . '</dt>');
|
77 |
|
|
print('<dd>');
|
78 |
718432f1
|
NOYB
|
printf($formtemplate, $term, $ifdescr, $show, htmlspecialchars($def) . ' ', $btnlbl, $btnlbl, $chkbox_relinquish_lease);
|
79 |
bd06568f
|
sbeaver
|
print('</dd>');
|
80 |
|
|
}
|
81 |
|
|
}
|
82 |
|
|
|
83 |
718432f1
|
NOYB
|
// 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 |
abe98adb
|
Phil Davis
|
$pgtitle = array(gettext("Status"), gettext("Interfaces"));
|
95 |
b32dd0a6
|
jim-p
|
$shortcut_section = "interfaces";
|
96 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
97 |
|
|
|
98 |
f593f80b
|
Phil Davis
|
$ifdescrs = get_configured_interface_with_descr(true);
|
99 |
8cccee1c
|
Scott Ullrich
|
|
100 |
66c52114
|
Stephen Beaver
|
foreach ($ifdescrs as $ifdescr => $ifname):
|
101 |
|
|
$ifinfo = get_interface_info($ifdescr);
|
102 |
|
|
$mac_man = load_mac_manufacturer_table();
|
103 |
718432f1
|
NOYB
|
|
104 |
|
|
$chkbox_relinquish_lease = ' ' .
|
105 |
d0718a0f
|
NOYB
|
'<input type="checkbox" name="relinquish_lease" value="true" title="' . gettext("Send a gratuitous DHCP release packet to the server.") . '" /> ' . gettext("Relinquish Lease") .
|
106 |
718432f1
|
NOYB
|
'<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 |
0d7b21de
|
sullrich
|
?>
|
110 |
bd06568f
|
sbeaver
|
|
111 |
|
|
<div class="panel panel-default">
|
112 |
3d7a8696
|
k-paulius
|
<div class="panel-heading"><h2 class="panel-title"><?=htmlspecialchars($ifname)?><?=gettext(" Interface "); ?>(<?=htmlspecialchars($ifdescr)?>, <?=htmlspecialchars($ifinfo['hwif'])?>)</h2></div>
|
113 |
fb6c7bb8
|
sbeaver
|
<div class="panel-body">
|
114 |
|
|
<dl class="dl-horizontal">
|
115 |
0d7b21de
|
sullrich
|
<?php
|
116 |
c5007d58
|
Phil Davis
|
showDef(true, gettext("Status"), $ifinfo['enable'] ? $ifinfo['status'] : gettext('disabled'));
|
117 |
718432f1
|
NOYB
|
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 |
7f0d6ccf
|
Phil Davis
|
showDef($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated'], gettext("Uptime") . ' ' . ($ifinfo['ppp_uptime_accumulated'] ? gettext('(historical)'):''), $ifinfo['ppp_uptime'] . $ifinfo['ppp_uptime_accumulated']);
|
124 |
fb6c7bb8
|
sbeaver
|
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 |
6bdfbf3b
|
jim-p
|
showDef( $ifinfo['macaddr'], gettext('MAC Address'), $mac . (isset($mac_man[$mac_hi]) ? ' - ' . $mac_man[$mac_hi] : ''));
|
137 |
|
|
}
|
138 |
bd06568f
|
sbeaver
|
|
139 |
fb6c7bb8
|
sbeaver
|
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 |
510e6f23
|
Chris Buechler
|
showDef($ifinfo['gatewayv6'], gettext("Gateway IPv6"), $config['interfaces'][$ifdescr]['gatewayv6'] . " " . $ifinfo['gatewayv6']);
|
148 |
fb6c7bb8
|
sbeaver
|
|
149 |
fc84b222
|
Renato Botelho
|
if ($ifdescr == "wan" && file_exists("{$g['etc_path']}/resolv.conf")) {
|
150 |
fb6c7bb8
|
sbeaver
|
$dns_servers = get_dns_servers();
|
151 |
|
|
$dnscnt = 0;
|
152 |
abe98adb
|
Phil Davis
|
foreach ($dns_servers as $dns) {
|
153 |
78869d5e
|
NOYB
|
showDef(true, $dnscnt == 0 ? gettext('DNS servers'):'', $dns);
|
154 |
fb6c7bb8
|
sbeaver
|
$dnscnt++;
|
155 |
bd06568f
|
sbeaver
|
}
|
156 |
|
|
}
|
157 |
fb6c7bb8
|
sbeaver
|
}
|
158 |
bd06568f
|
sbeaver
|
|
159 |
fb6c7bb8
|
sbeaver
|
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 |
abe98adb
|
Phil Davis
|
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 |
34446ef7
|
Phil Davis
|
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 |
abe98adb
|
Phil Davis
|
showDef(isset($ifinfo['inerrs']), gettext("In/out errors"), $ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);
|
175 |
|
|
showDef(isset($ifinfo['collisions']), gettext("Collisions"), $ifinfo['collisions']);
|
176 |
fb6c7bb8
|
sbeaver
|
} // e-o-if ($ifinfo['status'] != "down")
|
177 |
|
|
|
178 |
7f0d6ccf
|
Phil Davis
|
showDef($ifinfo['bridge'], sprintf(gettext('Bridge (%1$s)'), $ifinfo['bridgeint']), $ifinfo['bridge']);
|
179 |
fb6c7bb8
|
sbeaver
|
|
180 |
abe98adb
|
Phil Davis
|
if (file_exists("/usr/bin/vmstat")) {
|
181 |
fb6c7bb8
|
sbeaver
|
$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 |
abe98adb
|
Phil Davis
|
if (strstr($interrupt_total, "hci")) {
|
189 |
fb6c7bb8
|
sbeaver
|
$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
|
190 |
|
|
$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;
|
191 |
bd06568f
|
sbeaver
|
}
|
192 |
fb6c7bb8
|
sbeaver
|
|
193 |
|
|
unset($interrupt_total);
|
194 |
|
|
|
195 |
|
|
showDef($interrupt_total, gettext('Total interrupts'), $interrupt_total);
|
196 |
|
|
showDef($interrupt_total, '', $interrupt_sec . " " . $interrupt_total);
|
197 |
|
|
}
|
198 |
bd06568f
|
sbeaver
|
?>
|
199 |
fb6c7bb8
|
sbeaver
|
</dl>
|
200 |
bd06568f
|
sbeaver
|
</div>
|
201 |
|
|
</div>
|
202 |
0d7b21de
|
sullrich
|
|
203 |
db794357
|
Colin Fleming
|
<?php
|
204 |
|
|
endforeach;
|
205 |
71d9cd3d
|
Scott Ullrich
|
|
206 |
7f0d6ccf
|
Phil Davis
|
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 |
7c945f74
|
k-paulius
|
include("foot.inc");
|
212 |
|
|
?>
|