Project

General

Profile

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