Project

General

Profile

Download (8.56 KB) Statistics
| Branch: | Tag: | Revision:
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 81299b5c Renato Botelho
 * Copyright (c) 2004-2016 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 e8f35171 Ermal
require_once("shaper.inc");
35 c9a98f18 Phil Davis
require_once("filter.inc");
36 5b237745 Scott Ullrich
37 a03fb095 Renato Botelho
if ($_POST['if'] && $_POST['submit']) {
38 7c9710fc Renato Botelho
	$interface = $_POST['if'];
39 42b0c921 Phil Davis
	if ($_POST['status'] == "up") {
40 80bf3f4a Ermal Luçi
		interface_bring_down($interface);
41 42b0c921 Phil Davis
	} else {
42 bd06568f sbeaver
		interface_configure($interface);
43 42b0c921 Phil Davis
	}
44 56e1d16e Ermal Lu?i
	header("Location: status_interfaces.php");
45
	exit;
46 c26e2cf0 Scott Ullrich
}
47
48 bd06568f sbeaver
$formtemplate = '<form name="%s" action="status_interfaces.php" method="post">' .
49
					'<input type="hidden" name="if" value="%s" />' .
50
					'<input type="hidden" name="status" value="%s" />' .
51
					'%s' .
52 27d6a45b jim-p
					'<button type="submit" name="submit" class="btn btn-warning btn-xs" value="%s">' .
53
					'<i class="fa fa-refresh icon-embed-btn"></i>' .
54
					'%s' .
55
					'</button>' .
56 bd06568f sbeaver
					'</form>';
57
58
// Display a term/definition pair
59
function showDef($show, $term, $def) {
60 abe98adb Phil Davis
	if ($show) {
61 bd06568f sbeaver
		print('<dt>' . $term . '</dt>');
62 fb6c7bb8 sbeaver
		print('<dd>' . htmlspecialchars($def) . '</dd>');
63 bd06568f sbeaver
	}
64
}
65
66
// Display a term/definition pair with a button
67
function showDefBtn($show, $term, $def, $ifval, $btnlbl) {
68
	global $formtemplate;
69
70 abe98adb Phil Davis
	if ($show) {
71 bd06568f sbeaver
		print('<dt>' . $term . '</dt>');
72
		print('<dd>');
73 27d6a45b jim-p
		printf($formtemplate, $term, $ifval, $show, htmlspecialchars($def)	. ' ', $btnlbl, $btnlbl);
74 bd06568f sbeaver
		print('</dd>');
75
	}
76
}
77
78 abe98adb Phil Davis
$pgtitle = array(gettext("Status"), gettext("Interfaces"));
79 b32dd0a6 jim-p
$shortcut_section = "interfaces";
80 4df96eff Scott Ullrich
include("head.inc");
81
82 66c52114 Stephen Beaver
$ifdescrs = get_configured_interface_with_descr(false, true);
83 8cccee1c Scott Ullrich
84 66c52114 Stephen Beaver
foreach ($ifdescrs as $ifdescr => $ifname):
85
	$ifinfo = get_interface_info($ifdescr);
86
	$mac_man = load_mac_manufacturer_table();
87 0d7b21de sullrich
?>
88 bd06568f sbeaver
89
<div class="panel panel-default">
90 3d7a8696 k-paulius
	<div class="panel-heading"><h2 class="panel-title"><?=htmlspecialchars($ifname)?><?=gettext(" Interface "); ?>(<?=htmlspecialchars($ifdescr)?>, <?=htmlspecialchars($ifinfo['hwif'])?>)</h2></div>
91 fb6c7bb8 sbeaver
	<div class="panel-body">
92
		<dl class="dl-horizontal">
93 0d7b21de sullrich
<?php
94 fb6c7bb8 sbeaver
		showDef(true, gettext("Status"), $ifinfo['status']);
95
		showDefBtn($ifinfo['dhcplink'], 'DHCP', $ifinfo['dhcplink'], $ifdescr, $ifinfo['dhcplink'] == "up" ? gettext("Release") : gettext("Renew"));
96
		showDefBtn($ifinfo['dhcp6link'], 'DHCP6', $ifinfo['dhcp6link'], $ifdescr, $ifinfo['dhcp6link'] == "up" ? gettext("Release") : gettext("Renew"));
97
		showDefBtn($ifinfo['pppoelink'], 'PPPoE', $ifinfo['pppoelink'], $ifdescr, $ifinfo['pppoelink'] == "up" ? gettext("Disconnect") : gettext("Connect"));
98
		showDefBtn($ifinfo['pptplink'], 'PPTP', $ifinfo['pptplink'], $ifdescr, $ifinfo['pptplink'] == "up" ? gettext("Disconnect") : gettext("Connect"));
99
		showDefBtn($ifinfo['l2tplink'], 'L2TP', $ifinfo['l2tplink'], $ifdescr, $ifinfo['l2tplink'] == "up" ? gettext("Disconnect") : gettext("Connect"));
100 17580434 Chris Buechler
		showDefBtn($ifinfo['ppplink'], 'PPP', $ifinfo['ppplink'], $ifdescr, ($ifinfo['ppplink'] == "up" && !$ifinfo['nodevice']) ? gettext("Disconnect") : gettext("Connect"));
101 6e682644 jim-p
		showDef($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated'], gettext("Uptime") . ' ' . ($ifinfo['ppp_uptime_accumulated'] ? '(historical)':''), $ifinfo['ppp_uptime'] . $ifinfo['ppp_uptime_accumulated']);
102 fb6c7bb8 sbeaver
		showDef($ifinfo['cell_rssi'], gettext("Cell Signal (RSSI)"), $ifinfo['cell_rssi']);
103
		showDef($ifinfo['cell_mode'], gettext("Cell Mode"), $ifinfo['cell_mode']);
104
		showDef($ifinfo['cell_simstate'], gettext("Cell SIM State"), $ifinfo['cell_simstate']);
105
		showDef($ifinfo['cell_service'], gettext("Cell Service"), $ifinfo['cell_service']);
106
		showDef($ifinfo['cell_bwupstream'], gettext("Cell Upstream"), $ifinfo['cell_bwupstream']);
107
		showDef($ifinfo['cell_bwdownstream'], gettext("Cell Downstream"), $ifinfo['cell_bwdownstream']);
108
		showDef($ifinfo['cell_upstream'], gettext("Cell Current Up"), $ifinfo['cell_upstream']);
109
		showDef($ifinfo['cell_downstream'], gettext("Cell Current Down"), $ifinfo['cell_downstream']);
110
111
		if ($ifinfo['macaddr']) {
112
			$mac=$ifinfo['macaddr'];
113
			$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
114 6bdfbf3b jim-p
			showDef( $ifinfo['macaddr'], gettext('MAC Address'), $mac . (isset($mac_man[$mac_hi]) ? ' - ' . $mac_man[$mac_hi] : ''));
115
		}
116 bd06568f sbeaver
117 fb6c7bb8 sbeaver
		if ($ifinfo['status'] != "down") {
118
			if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down") {
119
				showDef($ifinfo['ipaddr'], gettext('IPv4 Address'), $ifinfo['ipaddr']);
120
				showDef($ifinfo['subnet'], gettext('Subnet mask IPv4'), $ifinfo['subnet']);
121
				showDef($ifinfo['gateway'], gettext('Gateway IPv4'), $ifinfo['gateway']);
122
				showDef($ifinfo['linklocal'], gettext('IPv6 Link Local'), $ifinfo['linklocal']);
123
				showDef($ifinfo['ipaddrv6'], gettext('IPv6 Address'), $ifinfo['ipaddrv6']);
124
				showDef($ifinfo['subnetv6'], gettext('Subnet mask IPv6'), $ifinfo['subnetv6']);
125 510e6f23 Chris Buechler
				showDef($ifinfo['gatewayv6'], gettext("Gateway IPv6"), $config['interfaces'][$ifdescr]['gatewayv6'] . " " . $ifinfo['gatewayv6']);
126 fb6c7bb8 sbeaver
127
				if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")) {
128
					$dns_servers = get_dns_servers();
129
					$dnscnt = 0;
130 abe98adb Phil Davis
					foreach ($dns_servers as $dns) {
131 78869d5e NOYB
						showDef(true, $dnscnt == 0 ? gettext('DNS servers'):'', $dns);
132 fb6c7bb8 sbeaver
						$dnscnt++;
133 bd06568f sbeaver
					}
134
				}
135 fb6c7bb8 sbeaver
			}
136 bd06568f sbeaver
137 fb6c7bb8 sbeaver
			showDef($ifinfo['mtu'], gettext("MTU"), $ifinfo['mtu']);
138
			showDef($ifinfo['media'], gettext("Media"), $ifinfo['media']);
139
			showDef($ifinfo['laggproto'], gettext("LAGG Protocol"), $ifinfo['laggproto']);
140 abe98adb Phil Davis
			showDef($ifinfo['laggport'], gettext("LAGG Ports"), $laggport);
141
			showDef($ifinfo['channel'], gettext("Channel"), $ifinfo['channel']);
142
			showDef($ifinfo['ssid'], gettext("SSID"), $ifinfo['ssid']);
143
			showDef($ifinfo['bssid'], gettext("BSSID"), $ifinfo['bssid']);
144
			showDef($ifinfo['rate'], gettext("Rate"), $ifinfo['rate']);
145
			showDef($ifinfo['rssi'], gettext("RSSI"), $ifinfo['rssi']);
146 34446ef7 Phil Davis
			showDef(true, gettext("In/out packets"),
147
			    $ifinfo['inpkts'] . '/' . $ifinfo['outpkts'] . " (" . format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");
148
			showDef(true, gettext("In/out packets (pass)"),
149
			    $ifinfo['inpktspass'] . '/' . $ifinfo['outpktspass'] . " (" . format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
150
			showDef(true, gettext("In/out packets (block)"),
151
			    $ifinfo['inpktsblock'] . '/' . $ifinfo['outpktsblock'] . " (" . format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
152 abe98adb Phil Davis
			showDef(isset($ifinfo['inerrs']), gettext("In/out errors"), $ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);
153
			showDef(isset($ifinfo['collisions']), gettext("Collisions"), $ifinfo['collisions']);
154 fb6c7bb8 sbeaver
		} // e-o-if ($ifinfo['status'] != "down")
155
156
		showDef($ifinfo['bridge'], gettext('Bridge (') . $ifinfo['bridgeint'] . ')', $ifinfo['bridge']);
157
158 abe98adb Phil Davis
		if (file_exists("/usr/bin/vmstat")) {
159 fb6c7bb8 sbeaver
			$real_interface = "";
160
			$interrupt_total = "";
161
			$interrupt_sec = "";
162
			$real_interface = $ifinfo['hwif'];
163
			$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
164
			$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
165
166 abe98adb Phil Davis
			if (strstr($interrupt_total, "hci")) {
167 fb6c7bb8 sbeaver
				$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
168
				$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;
169 bd06568f sbeaver
			}
170 fb6c7bb8 sbeaver
171
			unset($interrupt_total);
172
173
			showDef($interrupt_total, gettext('Total interrupts'), $interrupt_total);
174
			showDef($interrupt_total, '', $interrupt_sec . " " . $interrupt_total);
175
		}
176 bd06568f sbeaver
?>
177 fb6c7bb8 sbeaver
		</dl>
178 bd06568f sbeaver
	</div>
179
</div>
180 0d7b21de sullrich
181 db794357 Colin Fleming
<?php
182
	endforeach;
183 71d9cd3d Scott Ullrich
184 7c945f74 k-paulius
print_info_box(gettext("Using dial-on-demand will bring the connection up again if any packet ".
185
	    "triggers it. To substantiate this point: disconnecting manually ".
186
	    "will <strong>not</strong> prevent dial-on-demand from making connections ".
187 530c7ccf NOYB
	    "to the outside! Don't use dial-on-demand if the line ".
188
	    "is to be kept disconnected."), 'warning', false);
189 7c945f74 k-paulius
include("foot.inc");
190
?>