Project

General

Profile

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

    
58
##|+PRIV
59
##|*IDENT=page-status-interfaces
60
##|*NAME=Status: Interfaces
61
##|*DESCR=Allow access to the 'Status: Interfaces' page.
62
##|*MATCH=status_interfaces.php*
63
##|-PRIV
64

    
65
require_once("guiconfig.inc");
66
require_once("shaper.inc");
67
require_once("filter.inc");
68

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

    
80
$formtemplate = '<form name="%s" action="status_interfaces.php" method="post">' .
81
					'<input type="hidden" name="if" value="%s" />' .
82
					'<input type="hidden" name="status" value="%s" />' .
83
					'%s' .
84
					'<button type="submit" name="submit" class="btn btn-warning btn-xs" value="%s">' .
85
					'<i class="fa fa-refresh icon-embed-btn"></i>' .
86
					'%s' .
87
					'</button>' .
88
					'</form>';
89

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

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

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

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

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

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

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

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

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

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

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

    
188
		showDef($ifinfo['bridge'], gettext('Bridge (') . $ifinfo['bridgeint'] . ')', $ifinfo['bridge']);
189

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

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

    
203
			unset($interrupt_total);
204

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

    
213
<?php
214
	endforeach;
215

    
216
print_info_box(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 the line ".
220
	    "is to be kept disconnected."), 'warning', false);
221
include("foot.inc");
222
?>
(165-165/227)