Project

General

Profile

Download (13.3 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
				<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
132 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
133 0d7b21de sullrich
			<?php endif; ?>
134
			</a>
135
		</td>
136
	</tr>
137 633de329 gnhb
	<?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 81debd44 Chris Buechler
			if(isset($mac_man[$mac_hi])){ print "<span>" . $mac . " - " . htmlspecialchars($mac_man[$mac_hi]); print "</span>"; }
184 57f2840e Evgeny
			      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 bbcc0f9c Seth Mos
		<td width="22%" class="vncellt"><?=gettext("IPv4 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 bbcc0f9c Seth Mos
		<td width="22%" class="vncellt"><?=gettext("Subnet mask IPv4");?></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 bbcc0f9c Seth Mos
		<td width="22%" class="vncellt"><?=gettext("Gateway IPv4");?></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 bbcc0f9c Seth Mos
	<?php endif; ?>
214
	<?php if ($ifinfo['ipaddrv6']): ?>
215
	<tr>
216
		<td width="22%" class="vncellt"><?=gettext("IPv6 address");?></td>
217
		<td width="78%" class="listr">
218
			<?=htmlspecialchars($ifinfo['ipaddrv6']);?>
219
			&nbsp; 
220
		</td>
221
	</tr>
222
	<?php endif; ?><?php if ($ifinfo['subnetv6']): ?>
223
	<tr>
224
		<td width="22%" class="vncellt"><?=gettext("Subnet mask IPv6");?></td>
225
		<td width="78%" class="listr">
226
			<?=htmlspecialchars($ifinfo['subnetv6']);?>
227
		</td>
228
	</tr>
229
	<?php endif; ?><?php if ($ifinfo['gatewayv6']): ?>
230
	<tr>
231
		<td width="22%" class="vncellt"><?=gettext("Gateway IPv6");?></td>
232
		<td width="78%" class="listr">
233
			<?=htmlspecialchars($config['interfaces'][$ifdescr]['gatewayv6']);?>
234
			<?=htmlspecialchars($ifinfo['gatewayv6']);?>
235
		</td>
236
	</tr>
237 0d7b21de sullrich
	<?php endif; if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): ?>
238
	<tr>
239 c8927bfb Rafael Lucas
	<td width="22%" class="vncellt"><?=gettext("ISP DNS servers");?></td>
240 0d7b21de sullrich
	<td width="78%" class="listr">
241 6205a304 Scott Ullrich
		<?php
242
			$dns_servers = get_dns_servers();
243
			foreach($dns_servers as $dns) {
244
				echo "{$dns}<br>";
245 f559eaf6 Scott Ullrich
			}
246 6205a304 Scott Ullrich
		?>
247
		</td>
248 0d7b21de sullrich
	</tr>
249
	<?php endif; endif; if ($ifinfo['media']): ?>
250
	<tr>
251 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Media");?></td>
252 0d7b21de sullrich
		<td width="78%" class="listr">
253
			<?=htmlspecialchars($ifinfo['media']);?>
254
		</td>
255
	</tr>
256
<?php endif; ?><?php if ($ifinfo['channel']): ?>
257
	<tr>
258 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Channel");?></td>
259 0d7b21de sullrich
		<td width="78%" class="listr">
260
			<?=htmlspecialchars($ifinfo['channel']);?>
261
		</td>
262
	</tr>
263
<?php endif; ?><?php if ($ifinfo['ssid']): ?>
264
	<tr>
265 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("SSID");?></td>
266 0d7b21de sullrich
		<td width="78%" class="listr">
267
			<?=htmlspecialchars($ifinfo['ssid']);?>
268
		</td>
269
	</tr>
270
<?php endif; ?><?php if ($ifinfo['bssid']): ?>
271
	<tr>
272 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("BSSID");?></td>
273 0d7b21de sullrich
		<td width="78%" class="listr">
274
			<?=htmlspecialchars($ifinfo['bssid']);?>
275
		</td>
276
	</tr>
277
<?php endif; ?><?php if ($ifinfo['rate']): ?>
278
	<tr>
279 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Rate");?></td>
280 0d7b21de sullrich
		<td width="78%" class="listr">
281
			<?=htmlspecialchars($ifinfo['rate']);?>
282
		</td>
283
	</tr>
284
<?php endif; ?><?php if ($ifinfo['rssi']): ?>
285
	<tr>
286 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("RSSI");?></td>
287 0d7b21de sullrich
		<td width="78%" class="listr">
288
			<?=htmlspecialchars($ifinfo['rssi']);?>
289
		</td>
290
	</tr>
291
<?php endif; ?>
292
	<tr>
293 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out packets");?></td>
294 0d7b21de sullrich
		<td width="78%" class="listr">
295
		<?php
296
			echo htmlspecialchars($ifinfo['inpkts'] . "/" . $ifinfo['outpkts'] . " (");
297
			echo htmlspecialchars(format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");
298
		?>
299
		</td>
300
	</tr>
301
	<tr>
302 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out packets (pass)");?></td>
303 0d7b21de sullrich
		<td width="78%" class="listr">
304
			<?php
305
				echo htmlspecialchars($ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass'] . " (");
306
				echo htmlspecialchars(format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
307
			?>
308
		</td>
309
	</tr>
310
	<tr>
311 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out packets (block)");?></td>
312 0d7b21de sullrich
		<td width="78%" class="listr">
313
			<?php
314
				echo htmlspecialchars($ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock'] . " (");
315
				echo htmlspecialchars(format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
316
			?>
317
		</td>
318
	</tr>
319
<?php if (isset($ifinfo['inerrs'])): ?>
320
	<tr>
321 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out errors");?></td>
322 0d7b21de sullrich
		<td width="78%" class="listr">
323
			<?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?>
324
		</td>
325
	</tr>
326
<?php endif; ?>
327
<?php if (isset($ifinfo['collisions'])): ?>
328
	<tr>
329 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Collisions");?></td>
330 0d7b21de sullrich
		<td width="78%" class="listr">
331
			<?=htmlspecialchars($ifinfo['collisions']);?>
332
		</td>
333
	</tr>
334
<?php endif; ?>
335
<?php endif; ?>
336
<?php if ($ifinfo['bridge']): ?>
337
	<tr>
338 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?php printf(gettext("Bridge (%s)"),$ifinfo['bridgeint']);?></td>
339 0d7b21de sullrich
		<td width="78%" class="listr">
340
			<?=$ifinfo['bridge'];?>
341
		</td>
342
	</tr>
343
<?php endif; ?>
344
<?php if(file_exists("/usr/bin/vmstat")): ?>
345
<?php
346
	$real_interface = "";
347
	$interrupt_total = "";
348
	$interrupt_sec = "";
349
	$real_interface = $ifinfo['hwif'];
350
	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
351
	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
352
	if(strstr($interrupt_total, "hci")) {
353
		$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
354
		$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;          	
355
	}
356
	unset($interrupt_total); // XXX: FIX ME!  Need a regex and parse correct data 100% of the time.
357
?>
358
<?php if($interrupt_total): ?>
359
	<tr>
360 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Interrupts/Second");?></td>
361 0d7b21de sullrich
		<td width="78%" class="listr">
362
			<?php
363 ee644822 Carlos Eduardo Ramos
				echo $interrupt_total . " " . gettext("total");
364 0d7b21de sullrich
				echo "<br/>";
365 ee644822 Carlos Eduardo Ramos
				echo $interrupt_sec . " " . gettext("rate");
366 0d7b21de sullrich
			?>
367
		</td>
368
	</tr>
369
<?php endif; ?>
370
<?php endif; ?>
371
<?php $i++; endforeach; ?>
372
</table>
373 29ed06c9 Scott Ullrich
374 d290167c Seth Mos
<br/>
375 0d7b21de sullrich
376 c8927bfb Rafael Lucas
</strong><?php printf(gettext("Using dial-on-demand will bring the connection up again if any packet ".
377
"triggers it. To substantiate this point: disconnecting manually ".
378
"will %snot%s prevent dial-on-demand from making connections ".
379
"to the outside! Don't use dial-on-demand if you want to make sure that the line ".
380
"is kept disconnected."),'<strong>','</strong>')?>
381 71d9cd3d Scott Ullrich
382 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>