Project

General

Profile

Download (12.5 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 8c3e8725 Scott Ullrich
	All rights reserved.
8 8cccee1c Scott Ullrich
9 8c3e8725 Scott Ullrich
	originally part of m0n0wall (http://m0n0.ch/wall)
10 c26e2cf0 Scott Ullrich
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
11 5b237745 Scott Ullrich
	All rights reserved.
12 8cccee1c Scott Ullrich
13 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
14
	modification, are permitted provided that the following conditions are met:
15 8cccee1c Scott Ullrich
16 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
17
	   this list of conditions and the following disclaimer.
18 8cccee1c Scott Ullrich
19 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
20
	   notice, this list of conditions and the following disclaimer in the
21
	   documentation and/or other materials provided with the distribution.
22 8cccee1c Scott Ullrich
23 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
	POSSIBILITY OF SUCH DAMAGE.
33
*/
34 1d333258 Scott Ullrich
/*	
35
	pfSense_MODULE:	interfaces
36
*/
37 5b237745 Scott Ullrich
38 6b07c15a Matthew Grooms
##|+PRIV
39
##|*IDENT=page-status-interfaces
40
##|*NAME=Status: Interfaces page
41
##|*DESCR=Allow access to the 'Status: Interfaces' page.
42
##|*MATCH=status_interfaces.php*
43
##|-PRIV
44
45 51caa77a Scott Ullrich
require_once("guiconfig.inc");
46 5b237745 Scott Ullrich
47 07c17911 Ermal Luçi
if ($_GET['if']) {
48
	$interface = $_GET['if'];
49
	if ($_GET['action'] == "Disconnect" || $_GET['action'] == "Release") {
50 80bf3f4a Ermal Luçi
		interface_bring_down($interface);
51 07c17911 Ermal Luçi
	} else if ($_GET['action'] == "Connect" || $_GET['action'] == "Renew") {
52 80bf3f4a Ermal Luçi
		interface_configure($interface); 
53 c26e2cf0 Scott Ullrich
	}
54 56e1d16e Ermal Lu?i
	header("Location: status_interfaces.php");
55
	exit;
56 c26e2cf0 Scott Ullrich
}
57
58 ee644822 Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("Interfaces"));
59 4df96eff Scott Ullrich
include("head.inc");
60
61 5b237745 Scott Ullrich
?>
62 8cccee1c Scott Ullrich
63
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
64 5b237745 Scott Ullrich
<?php include("fbegin.inc"); ?>
65 0d7b21de sullrich
<table width="100%" border="0" cellspacing="0" cellpadding="0">
66
<?php 
67
	$i = 0; 
68
	$ifdescrs = get_configured_interface_with_descr(false, true);
69
	foreach ($ifdescrs as $ifdescr => $ifname):
70
	$ifinfo = get_interface_info($ifdescr);
71 57f2840e Evgeny
	// Load MAC-Manufacturer table
72
	$mac_man = load_mac_manufacturer_table();
73 0d7b21de sullrich
?>
74
<?php if ($i): ?>
75
	<tr>
76
		<td colspan="8" class="list" height="12"></td>
77
	</tr>
78
<?php endif; ?>
79
	<tr>
80
		<td colspan="2" class="listtopic">
81 ee644822 Carlos Eduardo Ramos
			<?=htmlspecialchars($ifname);?> <?=gettext("interface"); ?> (<?=htmlspecialchars($ifinfo['hwif']);?>)
82 0d7b21de sullrich
		</td>
83
	</tr>
84
	<tr>
85 ee644822 Carlos Eduardo Ramos
		<td width="22%" class="vncellt"><?=gettext("Status"); ?></td>
86 0d7b21de sullrich
		<td width="78%" class="listr">
87
			<?=htmlspecialchars($ifinfo['status']);?>
88
		</td>
89
	</tr>
90
	<?php if ($ifinfo['dhcplink']): ?>
91
	<tr>
92
		<td width="22%" class="vncellt">
93
			DHCP
94
		</td>
95
		<td width="78%" class="listr">
96
			<?=htmlspecialchars($ifinfo['dhcplink']);?>&nbsp;&nbsp;
97
			<?php if ($ifinfo['dhcplink'] == "up"): ?>
98
				<a href="status_interfaces.php?action=Release&if=<?php echo $ifdescr; ?>">
99 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Release");?>" class="formbtns">
100 0d7b21de sullrich
			<?php else: ?>
101
				<a href="status_interfaces.php?action=Renew&if=<?php echo $ifdescr; ?>">
102 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Renew");?>" class="formbtns">
103 0d7b21de sullrich
			<?php endif; ?>
104
			</a>
105
		</td>
106
	</tr>
107
	<?php endif; if ($ifinfo['pppoelink']): ?>
108
	<tr>
109 ee644822 Carlos Eduardo Ramos
		<td width="22%" class="vncellt"><?=gettext("PPPoE"); ?></td>
110 0d7b21de sullrich
		<td width="78%" class="listr">
111
			<?=htmlspecialchars($ifinfo['pppoelink']);?>&nbsp;&nbsp;
112
			<?php if ($ifinfo['pppoelink'] == "up"): ?>
113
				<a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
114 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
115 0d7b21de sullrich
			<?php else: ?>
116
				<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
117 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
118 0d7b21de sullrich
				<?php endif; ?>
119
			</a>
120
		</td>
121
	</tr>
122
	<?php  endif; if ($ifinfo['pptplink']): ?>
123
	<tr>
124 ee644822 Carlos Eduardo Ramos
		<td width="22%" class="vncellt"><?=gettext("PPTP"); ?></td>
125 0d7b21de sullrich
		<td width="78%" class="listr">
126
			<?=htmlspecialchars($ifinfo['pptplink']);?>&nbsp;&nbsp;
127
			<?php if ($ifinfo['pptplink'] == "up"): ?>
128
				<a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
129 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
130 0d7b21de sullrich
			<?php else: ?>
131 633de329 gnhb
				<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
132
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
133
			<?php endif; ?>
134
			</a>
135
		</td>
136
	</tr>
137
	<?php  endif; if ($ifinfo['l2tplink']): ?>
138
	<tr>
139
		<td width="22%" class="vncellt"><?=gettext("L2TP"); ?></td>
140
		<td width="78%" class="listr">
141
			<?=htmlspecialchars($ifinfo['l2tplink']);?>&nbsp;&nbsp;
142
			<?php if ($ifinfo['l2tplink'] == "up"): ?>
143
				<a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
144
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
145
			<?php else: ?>
146 0d7b21de sullrich
				<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
147 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
148 0d7b21de sullrich
			<?php endif; ?>
149
			</a>
150
		</td>
151
	</tr>
152
	<?php  endif; if ($ifinfo['ppplink']): ?>
153
	<tr>
154 ee644822 Carlos Eduardo Ramos
		<td width="22%" class="vncellt"><?=gettext("PPP"); ?></td>
155 0d7b21de sullrich
		<td width="78%" class="listr">
156 c90f2471 gnhb
			<?=htmlspecialchars($ifinfo['pppinfo']);?>
157
			<?php if ($ifinfo['ppplink'] == "up"): ?>
158 0d7b21de sullrich
				<a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
159 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
160 0d7b21de sullrich
			<?php else: ?>
161 c90f2471 gnhb
				<?php if (!$ifinfo['nodevice']): ?>
162 9ebe7028 gnhb
					<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
163 c8927bfb Rafael Lucas
					<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
164 9ebe7028 gnhb
				<?php endif; ?>
165 0d7b21de sullrich
			<?php endif; ?>
166
			</a>
167
		</td>
168
	</tr>
169 8eb2f33a Scott Ullrich
	<?php  endif; if ($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated']): ?>
170
	<tr>
171 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Uptime ");?><?php if ($ifinfo['ppp_uptime_accumulated']) echo "(historical)"; ?></td>
172 59db783a gnhb
		<td width="78%" class="listr">
173
			<?=htmlspecialchars($ifinfo['ppp_uptime']);?> <?=htmlspecialchars($ifinfo['ppp_uptime_accumulated']);?>
174
		</td>
175 8eb2f33a Scott Ullrich
        </tr>
176 0d7b21de sullrich
	<?php  endif; if ($ifinfo['macaddr']): ?>
177
	<tr>
178 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("MAC address");?></td>
179 0d7b21de sullrich
		<td width="78%" class="listr">
180 57f2840e Evgeny
			<?php 
181
			$mac=$ifinfo['macaddr']; 
182
			$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
183
			if(isset($mac_man[$mac_hi])){ print "<span title=\"$mac\">" . htmlspecialchars($mac_man[$mac_hi]); print "</span>"; }
184
			      else {print htmlspecialchars($mac);}
185
			?>
186 0d7b21de sullrich
		</td>
187
	</tr>
188
	<?php endif; if ($ifinfo['status'] != "down"): ?>
189
	<?php if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down"): ?>
190
	<?php if ($ifinfo['ipaddr']): ?>
191
	<tr>
192 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("IP address");?></td>
193 0d7b21de sullrich
		<td width="78%" class="listr">
194
			<?=htmlspecialchars($ifinfo['ipaddr']);?>
195
			&nbsp; 
196
		</td>
197
	</tr>
198
	<?php endif; ?><?php if ($ifinfo['subnet']): ?>
199
	<tr>
200 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Subnet mask");?></td>
201 0d7b21de sullrich
		<td width="78%" class="listr">
202
			<?=htmlspecialchars($ifinfo['subnet']);?>
203
		</td>
204
	</tr>
205
	<?php endif; ?><?php if ($ifinfo['gateway']): ?>
206
	<tr>
207 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Gateway");?></td>
208 0d7b21de sullrich
		<td width="78%" class="listr">
209 dde9a4fc Seth Mos
			<?=htmlspecialchars($config['interfaces'][$ifdescr]['gateway']);?>
210
			<?=htmlspecialchars($ifinfo['gateway']);?>
211 0d7b21de sullrich
		</td>
212
	</tr>
213
	<?php endif; if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): ?>
214
	<tr>
215 c8927bfb Rafael Lucas
	<td width="22%" class="vncellt"><?=gettext("ISP DNS servers");?></td>
216 0d7b21de sullrich
	<td width="78%" class="listr">
217 6205a304 Scott Ullrich
		<?php
218
			$dns_servers = get_dns_servers();
219
			foreach($dns_servers as $dns) {
220
				echo "{$dns}<br>";
221 f559eaf6 Scott Ullrich
			}
222 6205a304 Scott Ullrich
		?>
223
		</td>
224 0d7b21de sullrich
	</tr>
225
	<?php endif; endif; if ($ifinfo['media']): ?>
226
	<tr>
227 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Media");?></td>
228 0d7b21de sullrich
		<td width="78%" class="listr">
229
			<?=htmlspecialchars($ifinfo['media']);?>
230
		</td>
231
	</tr>
232
<?php endif; ?><?php if ($ifinfo['channel']): ?>
233
	<tr>
234 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Channel");?></td>
235 0d7b21de sullrich
		<td width="78%" class="listr">
236
			<?=htmlspecialchars($ifinfo['channel']);?>
237
		</td>
238
	</tr>
239
<?php endif; ?><?php if ($ifinfo['ssid']): ?>
240
	<tr>
241 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("SSID");?></td>
242 0d7b21de sullrich
		<td width="78%" class="listr">
243
			<?=htmlspecialchars($ifinfo['ssid']);?>
244
		</td>
245
	</tr>
246
<?php endif; ?><?php if ($ifinfo['bssid']): ?>
247
	<tr>
248 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("BSSID");?></td>
249 0d7b21de sullrich
		<td width="78%" class="listr">
250
			<?=htmlspecialchars($ifinfo['bssid']);?>
251
		</td>
252
	</tr>
253
<?php endif; ?><?php if ($ifinfo['rate']): ?>
254
	<tr>
255 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Rate");?></td>
256 0d7b21de sullrich
		<td width="78%" class="listr">
257
			<?=htmlspecialchars($ifinfo['rate']);?>
258
		</td>
259
	</tr>
260
<?php endif; ?><?php if ($ifinfo['rssi']): ?>
261
	<tr>
262 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("RSSI");?></td>
263 0d7b21de sullrich
		<td width="78%" class="listr">
264
			<?=htmlspecialchars($ifinfo['rssi']);?>
265
		</td>
266
	</tr>
267
<?php endif; ?>
268
	<tr>
269 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out packets");?></td>
270 0d7b21de sullrich
		<td width="78%" class="listr">
271
		<?php
272
			echo htmlspecialchars($ifinfo['inpkts'] . "/" . $ifinfo['outpkts'] . " (");
273
			echo htmlspecialchars(format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");
274
		?>
275
		</td>
276
	</tr>
277
	<tr>
278 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out packets (pass)");?></td>
279 0d7b21de sullrich
		<td width="78%" class="listr">
280
			<?php
281
				echo htmlspecialchars($ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass'] . " (");
282
				echo htmlspecialchars(format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
283
			?>
284
		</td>
285
	</tr>
286
	<tr>
287 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out packets (block)");?></td>
288 0d7b21de sullrich
		<td width="78%" class="listr">
289
			<?php
290
				echo htmlspecialchars($ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock'] . " (");
291
				echo htmlspecialchars(format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
292
			?>
293
		</td>
294
	</tr>
295
<?php if (isset($ifinfo['inerrs'])): ?>
296
	<tr>
297 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out errors");?></td>
298 0d7b21de sullrich
		<td width="78%" class="listr">
299
			<?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?>
300
		</td>
301
	</tr>
302
<?php endif; ?>
303
<?php if (isset($ifinfo['collisions'])): ?>
304
	<tr>
305 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Collisions");?></td>
306 0d7b21de sullrich
		<td width="78%" class="listr">
307
			<?=htmlspecialchars($ifinfo['collisions']);?>
308
		</td>
309
	</tr>
310
<?php endif; ?>
311
<?php endif; ?>
312
<?php if ($ifinfo['bridge']): ?>
313
	<tr>
314 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?php printf(gettext("Bridge (%s)"),$ifinfo['bridgeint']);?></td>
315 0d7b21de sullrich
		<td width="78%" class="listr">
316
			<?=$ifinfo['bridge'];?>
317
		</td>
318
	</tr>
319
<?php endif; ?>
320
<?php if(file_exists("/usr/bin/vmstat")): ?>
321
<?php
322
	$real_interface = "";
323
	$interrupt_total = "";
324
	$interrupt_sec = "";
325
	$real_interface = $ifinfo['hwif'];
326
	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
327
	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
328
	if(strstr($interrupt_total, "hci")) {
329
		$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
330
		$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;          	
331
	}
332
	unset($interrupt_total); // XXX: FIX ME!  Need a regex and parse correct data 100% of the time.
333
?>
334
<?php if($interrupt_total): ?>
335
	<tr>
336 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Interrupts/Second");?></td>
337 0d7b21de sullrich
		<td width="78%" class="listr">
338
			<?php
339 ee644822 Carlos Eduardo Ramos
				echo $interrupt_total . " " . gettext("total");
340 0d7b21de sullrich
				echo "<br/>";
341 ee644822 Carlos Eduardo Ramos
				echo $interrupt_sec . " " . gettext("rate");
342 0d7b21de sullrich
			?>
343
		</td>
344
	</tr>
345
<?php endif; ?>
346
<?php endif; ?>
347
<?php $i++; endforeach; ?>
348
</table>
349 29ed06c9 Scott Ullrich
350 d290167c Seth Mos
<br/>
351 0d7b21de sullrich
352 c8927bfb Rafael Lucas
</strong><?php printf(gettext("Using dial-on-demand will bring the connection up again if any packet ".
353
"triggers it. To substantiate this point: disconnecting manually ".
354
"will %snot%s prevent dial-on-demand from making connections ".
355
"to the outside! Don't use dial-on-demand if you want to make sure that the line ".
356
"is kept disconnected."),'<strong>','</strong>')?>
357 71d9cd3d Scott Ullrich
358 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>