Project

General

Profile

Download (9.9 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	status_interfaces.php
4
*/
5
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *
8
 *	Some or all of this file is based on the m0n0wall project which is
9
 *	Copyright (c)  2004 Manuel Kasper (BSD 2 clause)
10
 *
11
 *	Redistribution and use in source and binary forms, with or without modification,
12
 *	are permitted provided that the following conditions are met:
13
 *
14
 *	1. Redistributions of source code must retain the above copyright notice,
15
 *		this list of conditions and the following disclaimer.
16
 *
17
 *	2. Redistributions in binary form must reproduce the above copyright
18
 *		notice, this list of conditions and the following disclaimer in
19
 *		the documentation and/or other materials provided with the
20
 *		distribution.
21
 *
22
 *	3. All advertising materials mentioning features or use of this software
23
 *		must display the following acknowledgment:
24
 *		"This product includes software developed by the pfSense Project
25
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
26
 *
27
 *	4. The names "pfSense" and "pfSense Project" must not be used to
28
 *		 endorse or promote products derived from this software without
29
 *		 prior written permission. For written permission, please contact
30
 *		 coreteam@pfsense.org.
31
 *
32
 *	5. Products derived from this software may not be called "pfSense"
33
 *		nor may "pfSense" appear in their names without prior written
34
 *		permission of the Electric Sheep Fencing, LLC.
35
 *
36
 *	6. Redistributions of any form whatsoever must retain the following
37
 *		acknowledgment:
38
 *
39
 *	"This product includes software developed by the pfSense Project
40
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
41
 *
42
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
43
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
46
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
54
 *
55
 *	====================================================================
56
 *
57
 */
58
/*
59
	pfSense_MODULE: interfaces
60
*/
61

    
62
##|+PRIV
63
##|*IDENT=page-status-interfaces
64
##|*NAME=Status: Interfaces
65
##|*DESCR=Allow access to the 'Status: Interfaces' page.
66
##|*MATCH=status_interfaces.php*
67
##|-PRIV
68

    
69
require_once("guiconfig.inc");
70
require_once("shaper.inc");
71
require_once("filter.inc");
72

    
73
if ($_POST['if'] && $_POST['submit']) {
74
	$interface = $_POST['if'];
75
	if ($_POST['status'] == "up") {
76
		interface_bring_down($interface);
77
	} else {
78
		interface_configure($interface);
79
	}
80
	header("Location: status_interfaces.php");
81
	exit;
82
}
83

    
84
$formtemplate = '<form name="%s" action="status_interfaces.php" method="post">' .
85
					'<input type="hidden" name="if" value="%s" />' .
86
					'<input type="hidden" name="status" value="%s" />' .
87
					'%s' .
88
					'<input type="submit" name="submit" class="btn btn-warning btn-xs" value="%s" />' .
89
					'</form>';
90

    
91
// Display a term/definition pair
92
function showDef($show, $term, $def) {
93
	if($show) {
94
		print('<dt>' . $term . '</dt>');
95
		print('<dd>' . htmlspecialchars($def) . '</dd>');
96
	}
97
}
98

    
99
// Display a term/definition pair with a button
100
function showDefBtn($show, $term, $def, $ifval, $btnlbl) {
101
	global $formtemplate;
102

    
103
	if($show) {
104
		print('<dt>' . $term . '</dt>');
105
		print('<dd>');
106
		printf($formtemplate, $term, $ifval, $show, htmlspecialchars($def)	. ' ', $btnlbl);
107
		print('</dd>');
108
	}
109
}
110

    
111
$pgtitle = array(gettext("Status"),gettext("Interfaces"));
112
$shortcut_section = "interfaces";
113
include("head.inc");
114

    
115
$ifdescrs = get_configured_interface_with_descr(false, true);
116

    
117
foreach ($ifdescrs as $ifdescr => $ifname):
118
	$ifinfo = get_interface_info($ifdescr);
119
	$mac_man = load_mac_manufacturer_table();
120
?>
121

    
122
<div class="panel panel-default">
123
	<div class="panel-heading"><h2 class="panel-title"><?=htmlspecialchars($ifname)?><?=gettext(" interface "); ?>(<?=htmlspecialchars($ifdescr)?>, <?=htmlspecialchars($ifinfo['hwif'])?>)</h2></div>
124
	<div class="panel-body">
125
		<dl class="dl-horizontal">
126
<?php
127
		showDef(true, gettext("Status"), $ifinfo['status']);
128
		showDefBtn($ifinfo['dhcplink'], 'DHCP', $ifinfo['dhcplink'], $ifdescr, $ifinfo['dhcplink'] == "up" ? gettext("Release") : gettext("Renew"));
129
		showDefBtn($ifinfo['dhcp6link'], 'DHCP6', $ifinfo['dhcp6link'], $ifdescr, $ifinfo['dhcp6link'] == "up" ? gettext("Release") : gettext("Renew"));
130
		showDefBtn($ifinfo['pppoelink'], 'PPPoE', $ifinfo['pppoelink'], $ifdescr, $ifinfo['pppoelink'] == "up" ? gettext("Disconnect") : gettext("Connect"));
131
		showDefBtn($ifinfo['pptplink'], 'PPTP', $ifinfo['pptplink'], $ifdescr, $ifinfo['pptplink'] == "up" ? gettext("Disconnect") : gettext("Connect"));
132
		showDefBtn($ifinfo['l2tplink'], 'L2TP', $ifinfo['l2tplink'], $ifdescr, $ifinfo['l2tplink'] == "up" ? gettext("Disconnect") : gettext("Connect"));
133
		showDefBtn($ifinfo['ppplink'], 'L2TP', $ifinfo['ppplink'], $ifdescr, ($ifinfo['ppplink'] == "up" && !$ifinfo['nodevice']) ? gettext("Disconnect") : gettext("Connect"));
134
		showDef($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated'], gettext("Uptime ") . $ifinfo['ppp_uptime_accumulated'] ? '(historical)':'', $ifinfo['ppp_uptime'] . $ifinfo['ppp_uptime_accumulated']);
135
		showDef($ifinfo['cell_rssi'], gettext("Cell Signal (RSSI)"), $ifinfo['cell_rssi']);
136
		showDef($ifinfo['cell_mode'], gettext("Cell Mode"), $ifinfo['cell_mode']);
137
		showDef($ifinfo['cell_simstate'], gettext("Cell SIM State"), $ifinfo['cell_simstate']);
138
		showDef($ifinfo['cell_service'], gettext("Cell Service"), $ifinfo['cell_service']);
139
		showDef($ifinfo['cell_bwupstream'], gettext("Cell Upstream"), $ifinfo['cell_bwupstream']);
140
		showDef($ifinfo['cell_bwdownstream'], gettext("Cell Downstream"), $ifinfo['cell_bwdownstream']);
141
		showDef($ifinfo['cell_upstream'], gettext("Cell Current Up"), $ifinfo['cell_upstream']);
142
		showDef($ifinfo['cell_downstream'], gettext("Cell Current Down"), $ifinfo['cell_downstream']);
143

    
144
		if ($ifinfo['macaddr']) {
145
			$mac=$ifinfo['macaddr'];
146
			$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
147
			showDef(isset($mac_man[$mac_hi]), gettext('MAC Address'), $mac . ' - ' . $mac_man[$mac_hi]);
148
			}
149

    
150
		if ($ifinfo['status'] != "down") {
151
			if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down") {
152
				showDef($ifinfo['ipaddr'], gettext('IPv4 Address'), $ifinfo['ipaddr']);
153
				showDef($ifinfo['subnet'], gettext('Subnet mask IPv4'), $ifinfo['subnet']);
154
				showDef($ifinfo['gateway'], gettext('Gateway IPv4'), $ifinfo['gateway']);
155
				showDef($ifinfo['linklocal'], gettext('IPv6 Link Local'), $ifinfo['linklocal']);
156
				showDef($ifinfo['ipaddrv6'], gettext('IPv6 Address'), $ifinfo['ipaddrv6']);
157
				showDef($ifinfo['subnetv6'], gettext('Subnet mask IPv6'), $ifinfo['subnetv6']);
158
				showDef($ifinfo['gatewayv6'], gettext("Gateway IPv6"), $config['interfaces'][$ifdescr]['gatewayv6'] . $ifinfo['gatewayv6']);
159

    
160
				if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")) {
161
					$dns_servers = get_dns_servers();
162
					$dnscnt = 0;
163
					foreach($dns_servers as $dns) {
164
						showDef(true, $dnscnt == 0 ? gettext('ISP DNS servers'):'', $dns);
165
						$dnscnt++;
166
					}
167
				}
168
			}
169

    
170
			showDef($ifinfo['mtu'], gettext("MTU"), $ifinfo['mtu']);
171
			showDef($ifinfo['media'], gettext("Media"), $ifinfo['media']);
172
			showDef($ifinfo['laggproto'], gettext("LAGG Protocol"), $ifinfo['laggproto']);
173
			showDef($ifinfo['laggport'],gettext("LAGG Ports"),$laggport);
174
			showDef($ifinfo['channel'],gettext("Channel"),$ifinfo['channel']);
175
			showDef($ifinfo['ssid'],gettext("SSID"),$ifinfo['ssid']);
176
			showDef($ifinfo['bssid'],gettext("BSSID"),$ifinfo['bssid']);
177
			showDef($ifinfo['rate'],gettext("Rate"),$ifinfo['rate']);
178
			showDef($ifinfo['rssi'],gettext("RSSI"),$ifinfo['rssi']);
179
			showDef(true,gettext("In/out packets"),$ifinfo['inpkts'] . '/' . $ifinfo['outpkts']);
180
			showDef(true,gettext("In/out packets (pass)"),$ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass']);
181
			showDef(true,gettext("In/out packets (block)"),$ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock']);
182
			showDef(isset($ifinfo['inerrs']),gettext("In/out errors"),$ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);
183
			showDef(isset($ifinfo['collisions']),gettext("Collisions"),$ifinfo['collisions']);
184
		} // e-o-if ($ifinfo['status'] != "down")
185

    
186
		showDef($ifinfo['bridge'], gettext('Bridge (') . $ifinfo['bridgeint'] . ')', $ifinfo['bridge']);
187

    
188
		if(file_exists("/usr/bin/vmstat")) {
189
			$real_interface = "";
190
			$interrupt_total = "";
191
			$interrupt_sec = "";
192
			$real_interface = $ifinfo['hwif'];
193
			$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
194
			$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
195

    
196
			if(strstr($interrupt_total, "hci")) {
197
				$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
198
				$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;
199
			}
200

    
201
			unset($interrupt_total);
202

    
203
			showDef($interrupt_total, gettext('Total interrupts'), $interrupt_total);
204
			showDef($interrupt_total, '', $interrupt_sec . " " . $interrupt_total);
205
		}
206
?>
207
		</dl>
208
	</div>
209
</div>
210

    
211
<?php
212
	endforeach;
213
?>
214

    
215
<div class="alert alert-warning" role="alert">
216
	<?=gettext("Using dial-on-demand will bring the connection up again if any packet ".
217
	"triggers it. To substantiate this point: disconnecting manually ".
218
	"will <strong>not</strong> prevent dial-on-demand from making connections ".
219
	"to the outside! Don't use dial-on-demand if you want to make sure that the line ".
220
	"is kept disconnected.");?>
221
</div>
222

    
223
<?php include("foot.inc"); ?>
(172-172/228)