Project

General

Profile

Download (8.79 KB) Statistics
| Branch: | Tag: | Revision:
1 8cccee1c Scott Ullrich
<?php
2 2bdf4a03 Scott Ullrich
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	status_interfaces.php
5 0d7b21de sullrich
	part of pfSense
6
	Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>.
7 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
8 8c3e8725 Scott Ullrich
	All rights reserved.
9 8cccee1c Scott Ullrich
10 8c3e8725 Scott Ullrich
	originally part of m0n0wall (http://m0n0.ch/wall)
11 c26e2cf0 Scott Ullrich
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
12 5b237745 Scott Ullrich
	All rights reserved.
13 8cccee1c Scott Ullrich
14 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16 8cccee1c Scott Ullrich
17 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19 8cccee1c Scott Ullrich
20 5b237745 Scott Ullrich
	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 8cccee1c Scott Ullrich
24 5b237745 Scott Ullrich
	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 bd06568f sbeaver
/*
36
	pfSense_MODULE: interfaces
37 1d333258 Scott Ullrich
*/
38 5b237745 Scott Ullrich
39 6b07c15a Matthew Grooms
##|+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 51caa77a Scott Ullrich
require_once("guiconfig.inc");
47 e8f35171 Ermal
require_once("shaper.inc");
48 c9a98f18 Phil Davis
require_once("filter.inc");
49 5b237745 Scott Ullrich
50 a03fb095 Renato Botelho
if ($_POST['if'] && $_POST['submit']) {
51 7c9710fc Renato Botelho
	$interface = $_POST['if'];
52 a03fb095 Renato Botelho
	if ($_POST['status'] == "up")
53 80bf3f4a Ermal Luçi
		interface_bring_down($interface);
54 a03fb095 Renato Botelho
	else
55 bd06568f sbeaver
		interface_configure($interface);
56 56e1d16e Ermal Lu?i
	header("Location: status_interfaces.php");
57
	exit;
58 c26e2cf0 Scott Ullrich
}
59
60 bd06568f sbeaver
$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 fb6c7bb8 sbeaver
		print('<dd>' . htmlspecialchars($def) . '</dd>');
72 bd06568f sbeaver
	}
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 fb6c7bb8 sbeaver
		printf($formtemplate, $term, $ifvalue, $show, htmlspecialchars($def)	. ' ', $btnlbl);
83 bd06568f sbeaver
		print('</dd>');
84
	}
85
}
86
87 ee644822 Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("Interfaces"));
88 b32dd0a6 jim-p
$shortcut_section = "interfaces";
89 4df96eff Scott Ullrich
include("head.inc");
90
91 bd06568f sbeaver
		$ifdescrs = get_configured_interface_with_descr(false, true);
92 8cccee1c Scott Ullrich
93 bd06568f sbeaver
		foreach ($ifdescrs as $ifdescr => $ifname):
94
			$ifinfo = get_interface_info($ifdescr);
95
			$mac_man = load_mac_manufacturer_table();
96 0d7b21de sullrich
?>
97 bd06568f sbeaver
98
<div class="panel panel-default">
99
	<div class="panel-heading"><?=htmlspecialchars($ifname)?><?=gettext(" interface "); ?>(<?=htmlspecialchars($ifdescr)?>, <?=htmlspecialchars($ifinfo['hwif'])?>)</div>
100 fb6c7bb8 sbeaver
	<div class="panel-body">
101
		<dl class="dl-horizontal">
102 0d7b21de sullrich
<?php
103 fb6c7bb8 sbeaver
		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 bd06568f sbeaver
			}
125
126 fb6c7bb8 sbeaver
		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 bd06568f sbeaver
					}
143
				}
144 fb6c7bb8 sbeaver
			}
145 bd06568f sbeaver
146 fb6c7bb8 sbeaver
			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 bd06568f sbeaver
			}
176 fb6c7bb8 sbeaver
177
			unset($interrupt_total);
178
179
			showDef($interrupt_total, gettext('Total interrupts'), $interrupt_total);
180
			showDef($interrupt_total, '', $interrupt_sec . " " . $interrupt_total);
181
		}
182
		break;
183
	endforeach;
184 bd06568f sbeaver
?>
185 fb6c7bb8 sbeaver
		</dl>
186 bd06568f sbeaver
	</div>
187
</div>
188 0d7b21de sullrich
189 fb6c7bb8 sbeaver
<div class="alert alert-warning" role="alert">
190
	<?=gettext("Using dial-on-demand will bring the connection up again if any packet ".
191
	"triggers it. To substantiate this point: disconnecting manually ".
192
	"will <strong>not</strong> prevent dial-on-demand from making connections ".
193
	"to the outside! Don't use dial-on-demand if you want to make sure that the line ".
194
	"is kept disconnected.");?>
195
</div>
196 71d9cd3d Scott Ullrich
197 fb6c7bb8 sbeaver
<?php include("foot.inc"); ?>