Project

General

Profile

Download (8.56 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
 * 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
 *
17
 * http://www.apache.org/licenses/LICENSE-2.0
18
 *
19
 * 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
 */
25

    
26
##|+PRIV
27
##|*IDENT=page-status-interfaces
28
##|*NAME=Status: Interfaces
29
##|*DESCR=Allow access to the 'Status: Interfaces' page.
30
##|*MATCH=status_interfaces.php*
31
##|-PRIV
32

    
33
require_once("guiconfig.inc");
34
require_once("shaper.inc");
35
require_once("filter.inc");
36

    
37
if ($_POST['if'] && $_POST['submit']) {
38
	$interface = $_POST['if'];
39
	if ($_POST['status'] == "up") {
40
		interface_bring_down($interface);
41
	} else {
42
		interface_configure($interface);
43
	}
44
	header("Location: status_interfaces.php");
45
	exit;
46
}
47

    
48
$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
					'<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
					'</form>';
57

    
58
// Display a term/definition pair
59
function showDef($show, $term, $def) {
60
	if ($show) {
61
		print('<dt>' . $term . '</dt>');
62
		print('<dd>' . htmlspecialchars($def) . '</dd>');
63
	}
64
}
65

    
66
// Display a term/definition pair with a button
67
function showDefBtn($show, $term, $def, $ifval, $btnlbl) {
68
	global $formtemplate;
69

    
70
	if ($show) {
71
		print('<dt>' . $term . '</dt>');
72
		print('<dd>');
73
		printf($formtemplate, $term, $ifval, $show, htmlspecialchars($def)	. ' ', $btnlbl, $btnlbl);
74
		print('</dd>');
75
	}
76
}
77

    
78
$pgtitle = array(gettext("Status"), gettext("Interfaces"));
79
$shortcut_section = "interfaces";
80
include("head.inc");
81

    
82
$ifdescrs = get_configured_interface_with_descr(false, true);
83

    
84
foreach ($ifdescrs as $ifdescr => $ifname):
85
	$ifinfo = get_interface_info($ifdescr);
86
	$mac_man = load_mac_manufacturer_table();
87
?>
88

    
89
<div class="panel panel-default">
90
	<div class="panel-heading"><h2 class="panel-title"><?=htmlspecialchars($ifname)?><?=gettext(" Interface "); ?>(<?=htmlspecialchars($ifdescr)?>, <?=htmlspecialchars($ifinfo['hwif'])?>)</h2></div>
91
	<div class="panel-body">
92
		<dl class="dl-horizontal">
93
<?php
94
		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
		showDefBtn($ifinfo['ppplink'], 'PPP', $ifinfo['ppplink'], $ifdescr, ($ifinfo['ppplink'] == "up" && !$ifinfo['nodevice']) ? gettext("Disconnect") : gettext("Connect"));
101
		showDef($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated'], gettext("Uptime") . ' ' . ($ifinfo['ppp_uptime_accumulated'] ? '(historical)':''), $ifinfo['ppp_uptime'] . $ifinfo['ppp_uptime_accumulated']);
102
		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
			showDef( $ifinfo['macaddr'], gettext('MAC Address'), $mac . (isset($mac_man[$mac_hi]) ? ' - ' . $mac_man[$mac_hi] : ''));
115
		}
116

    
117
		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
				showDef($ifinfo['gatewayv6'], gettext("Gateway IPv6"), $config['interfaces'][$ifdescr]['gatewayv6'] . " " . $ifinfo['gatewayv6']);
126

    
127
				if ($ifdescr == "wan" && file_exists("{$g['etc_path']}/resolv.conf")) {
128
					$dns_servers = get_dns_servers();
129
					$dnscnt = 0;
130
					foreach ($dns_servers as $dns) {
131
						showDef(true, $dnscnt == 0 ? gettext('DNS servers'):'', $dns);
132
						$dnscnt++;
133
					}
134
				}
135
			}
136

    
137
			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
			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
			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
			showDef(isset($ifinfo['inerrs']), gettext("In/out errors"), $ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);
153
			showDef(isset($ifinfo['collisions']), gettext("Collisions"), $ifinfo['collisions']);
154
		} // e-o-if ($ifinfo['status'] != "down")
155

    
156
		showDef($ifinfo['bridge'], gettext('Bridge (') . $ifinfo['bridgeint'] . ')', $ifinfo['bridge']);
157

    
158
		if (file_exists("/usr/bin/vmstat")) {
159
			$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
			if (strstr($interrupt_total, "hci")) {
167
				$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
168
				$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;
169
			}
170

    
171
			unset($interrupt_total);
172

    
173
			showDef($interrupt_total, gettext('Total interrupts'), $interrupt_total);
174
			showDef($interrupt_total, '', $interrupt_sec . " " . $interrupt_total);
175
		}
176
?>
177
		</dl>
178
	</div>
179
</div>
180

    
181
<?php
182
	endforeach;
183

    
184
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
	    "to the outside! Don't use dial-on-demand if the line ".
188
	    "is to be kept disconnected."), 'warning', false);
189
include("foot.inc");
190
?>
(163-163/225)