Project

General

Profile

Download (16.5 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / status_interfaces.php @ a1b66bec

1
<?php
2
/* $Id$ */
3
/*
4
	status_interfaces.php
5
	part of pfSense
6
	Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>.
7
	All rights reserved.
8

    
9
	originally part of m0n0wall (http://m0n0.ch/wall)
10
	Copyright (C) 2003-2005 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 the
21
	   documentation and/or other materials provided with the distribution.
22

    
23
	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
/*	
35
	pfSense_MODULE:	interfaces
36
*/
37

    
38
##|+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
require_once("guiconfig.inc");
46
require_once("shaper.inc");
47
require_once("filter.inc");
48

    
49
if ($_POST['if'] && $_POST['submit']) {
50
	$interface = $_POST['if'];
51
	if ($_POST['status'] == "up")
52
		interface_bring_down($interface);
53
	else
54
		interface_configure($interface); 
55
	header("Location: status_interfaces.php");
56
	exit;
57
}
58

    
59
$pgtitle = array(gettext("Status"),gettext("Interfaces"));
60
$shortcut_section = "interfaces";
61
include("head.inc");
62

    
63
?>
64

    
65
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
66
<?php include("fbegin.inc"); ?>
67
<table width="100%" border="0" cellspacing="0" cellpadding="0" summary="status interfaces">
68
<?php 
69
	$i = 0; 
70
	$ifdescrs = get_configured_interface_with_descr(false, true);
71
	foreach ($ifdescrs as $ifdescr => $ifname):
72
	$ifinfo = get_interface_info($ifdescr);
73
	// Load MAC-Manufacturer table
74
	$mac_man = load_mac_manufacturer_table();
75
?>
76
<?php if ($i): ?>
77
	<tr>
78
		<td colspan="8" class="list" height="12"></td>
79
	</tr>
80
<?php endif; ?>
81
	<tr>
82
		<td colspan="2" class="listtopic">
83
			<?=htmlspecialchars($ifname);?> <?=gettext("interface"); ?> (<?=htmlspecialchars($ifdescr);?>, <?=htmlspecialchars($ifinfo['hwif']);?>)
84
		</td>
85
	</tr>
86
	<tr>
87
		<td width="22%" class="vncellt"><?=gettext("Status"); ?></td>
88
		<td width="78%" class="listr">
89
			<?=htmlspecialchars($ifinfo['status']);?>
90
		</td>
91
	</tr>
92
	<?php if ($ifinfo['dhcplink']): ?>
93
	<tr>
94
		<td width="22%" class="vncellt">
95
			DHCP
96
		</td>
97
		<td width="78%" class="listr">
98
			<form name="dhcplink_form" action="status_interfaces.php" method="post">
99
				<input type="hidden" name="if" value="<?php echo $ifdescr; ?>" />
100
				<input type="hidden" name="status" value="<?php echo $ifinfo['dhcplink']; ?>" />
101
				<?=htmlspecialchars($ifinfo['dhcplink']);?>&nbsp;&nbsp;
102
				<?php $action = ($ifinfo['dhcplink'] == "up" ? gettext("Release") : gettext("Renew")); ?>
103
				<input type="submit" name="submit" class="formbtn" value="<?php echo $action; ?>" />
104
			</form>
105
		</td>
106
	</tr>
107
	<?php endif;
108
	if ($ifinfo['dhcp6link']): ?>
109
	<tr>
110
		<td width="22%" class="vncellt">
111
			DHCP6
112
		</td>
113
		<td width="78%" class="listr">
114
			<form name="dhcp6link_form" action="status_interfaces.php" method="post">
115
				<input type="hidden" name="if" value="<?php echo $ifdescr; ?>" />
116
				<input type="hidden" name="status" value="<?php echo $ifinfo['dhcp6link']; ?>" />
117
				<?=htmlspecialchars($ifinfo['dhcp6link']);?>&nbsp;&nbsp;
118
				<?php $action = ($ifinfo['dhcp6link'] == "up" ? gettext("Release") : gettext("Renew")); ?>
119
				<input type="submit" name="submit" class="formbtn" value="<?php echo $action; ?>" />
120
			</form>
121
		</td>
122
	</tr>
123
	<?php endif; if ($ifinfo['pppoelink']): ?>
124
	<tr>
125
		<td width="22%" class="vncellt"><?=gettext("PPPoE"); ?></td>
126
		<td width="78%" class="listr">
127
			<form name="pppoelink_form" action="status_interfaces.php" method="post">
128
				<input type="hidden" name="if" value="<?php echo $ifdescr; ?>" />
129
				<input type="hidden" name="status" value="<?php echo $ifinfo['pppoelink']; ?>" />
130
				<?=htmlspecialchars($ifinfo['pppoelink']);?>&nbsp;&nbsp;
131
				<?php $action = ($ifinfo['pppoelink'] == "up" ? gettext("Disconnect") : gettext("Connect")); ?>
132
				<input type="submit" name="submit" class="formbtn" value="<?php echo $action; ?>" />
133
			</form>
134
		</td>
135
	</tr>
136
	<?php  endif; if ($ifinfo['pptplink']): ?>
137
	<tr>
138
		<td width="22%" class="vncellt"><?=gettext("PPTP"); ?></td>
139
		<td width="78%" class="listr">
140
			<form name="pptplink_form" action="status_interfaces.php" method="post">
141
				<input type="hidden" name="if" value="<?php echo $ifdescr; ?>" />
142
				<input type="hidden" name="status" value="<?php echo $ifinfo['pptplink']; ?>" />
143
				<?=htmlspecialchars($ifinfo['pptplink']);?>&nbsp;&nbsp;
144
				<?php $action = ($ifinfo['pptplink'] == "up" ? gettext("Disconnect") : gettext("Connect")); ?>
145
				<input type="submit" name="submit" class="formbtn" value="<?php echo $action; ?>" />
146
			</form>
147
		</td>
148
	</tr>
149
	<?php  endif; if ($ifinfo['l2tplink']): ?>
150
	<tr>
151
		<td width="22%" class="vncellt"><?=gettext("L2TP"); ?></td>
152
		<td width="78%" class="listr">
153
			<form name="l2tplink_form" action="status_interfaces.php" method="post">
154
				<input type="hidden" name="if" value="<?php echo $ifdescr; ?>" />
155
				<input type="hidden" name="status" value="<?php echo $ifinfo['l2tplink']; ?>" />
156
				<?=htmlspecialchars($ifinfo['l2tplink']);?>&nbsp;&nbsp;
157
				<?php $action = ($ifinfo['l2tplink'] == "up" ? gettext("Disconnect") : gettext("Connect")); ?>
158
				<input type="submit" name="submit" class="formbtn" value="<?php echo $action; ?>" />
159
			</form>
160
		</td>
161
	</tr>
162
	<?php  endif; if ($ifinfo['ppplink']): ?>
163
	<tr>
164
		<td width="22%" class="vncellt"><?=gettext("PPP"); ?></td>
165
		<td width="78%" class="listr">
166
			<form name="ppplink_form" action="status_interfaces.php" method="post">
167
				<input type="hidden" name="if" value="<?php echo $ifdescr; ?>" />
168
				<input type="hidden" name="status" value="<?php echo $ifinfo['ppplink']; ?>" />
169
				<?=htmlspecialchars($ifinfo['ppplink']);?>
170
				<?php if ($ifinfo['ppplink'] == "up"): ?>
171
					<input type="submit" name="submit" class="formbtn" value="<?php echo gettext("Disconnect"); ?>" />
172
				<?php else: ?>
173
					<?php if (!$ifinfo['nodevice']): ?>
174
						<input type="submit" name="submit" class="formbtn" value="<?php echo gettext("Connect"); ?>" />
175
					<?php endif; ?>
176
				<?php endif; ?>
177
			</form>
178
		</td>
179
	</tr>
180
	<?php  endif; if ($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated']): ?>
181
	<tr>
182
		<td width="22%" class="vncellt"><?=gettext("Uptime ");?><?php if ($ifinfo['ppp_uptime_accumulated']) echo "(historical)"; ?></td>
183
		<td width="78%" class="listr">
184
			<?=htmlspecialchars($ifinfo['ppp_uptime']);?> <?=htmlspecialchars($ifinfo['ppp_uptime_accumulated']);?>
185
		</td>
186
        </tr>
187
	<?php  endif; if ($ifinfo['cell_rssi']): ?>
188
	<tr>
189
		<td width="22%" class="vncellt"><?=gettext("Cell Signal (RSSI)");?></td>
190
		<td width="78%" class="listr">
191
			<?=htmlspecialchars($ifinfo['cell_rssi']);?>
192
		</td>
193
        </tr>
194
	<?php  endif; if ($ifinfo['cell_mode']): ?>
195
	<tr>
196
		<td width="22%" class="vncellt"><?=gettext("Cell Mode");?></td>
197
		<td width="78%" class="listr">
198
			<?=htmlspecialchars($ifinfo['cell_mode']);?>
199
		</td>
200
        </tr>
201
	<?php  endif; if ($ifinfo['cell_simstate']): ?>
202
	<tr>
203
		<td width="22%" class="vncellt"><?=gettext("Cell SIM State");?></td>
204
		<td width="78%" class="listr">
205
			<?=htmlspecialchars($ifinfo['cell_simstate']);?>
206
		</td>
207
        </tr>
208
	<?php  endif; if ($ifinfo['cell_service']): ?>
209
	<tr>
210
		<td width="22%" class="vncellt"><?=gettext("Cell Service");?></td>
211
		<td width="78%" class="listr">
212
			<?=htmlspecialchars($ifinfo['cell_service']);?>
213
		</td>
214
        </tr>
215
	<?php  endif; if ($ifinfo['cell_bwupstream']): ?>
216
	<tr>
217
		<td width="22%" class="vncellt"><?=gettext("Cell Upstream");?></td>
218
		<td width="78%" class="listr">
219
			<?=htmlspecialchars($ifinfo['cell_bwupstream']);?> kbit/s
220
		</td>
221
        </tr>
222
	<?php  endif; if ($ifinfo['cell_bwdownstream']): ?>
223
	<tr>
224
		<td width="22%" class="vncellt"><?=gettext("Cell Downstream");?></td>
225
		<td width="78%" class="listr">
226
			<?=htmlspecialchars($ifinfo['cell_bwdownstream']);?> kbit/s
227
		</td>
228
        </tr>
229
	<?php  endif; if ($ifinfo['cell_upstream']): ?>
230
	<tr>
231
		<td width="22%" class="vncellt"><?=gettext("Cell Current Up");?></td>
232
		<td width="78%" class="listr">
233
			<?=htmlspecialchars($ifinfo['cell_upstream']);?> kbit/s
234
		</td>
235
        </tr>
236
	<?php  endif; if ($ifinfo['cell_downstream']): ?>
237
	<tr>
238
		<td width="22%" class="vncellt"><?=gettext("Cell Current Down");?></td>
239
		<td width="78%" class="listr">
240
			<?=htmlspecialchars($ifinfo['cell_downstream']);?> kbit/s
241
		</td>
242
        </tr>
243
	<?php  endif; if ($ifinfo['macaddr']): ?>
244
	<tr>
245
		<td width="22%" class="vncellt"><?=gettext("MAC address");?></td>
246
		<td width="78%" class="listr">
247
			<?php 
248
			$mac=$ifinfo['macaddr']; 
249
			$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
250
			if(isset($mac_man[$mac_hi])){ print "<span>" . $mac . " - " . htmlspecialchars($mac_man[$mac_hi]); print "</span>"; }
251
			      else {print htmlspecialchars($mac);}
252
			?>
253
		</td>
254
	</tr>
255
	<?php endif; if ($ifinfo['status'] != "down"): ?>
256
	<?php if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down"): ?>
257
	<?php if ($ifinfo['ipaddr']): ?>
258
	<tr>
259
		<td width="22%" class="vncellt"><?=gettext("IPv4 address");?></td>
260
		<td width="78%" class="listr">
261
			<?=htmlspecialchars($ifinfo['ipaddr']);?>
262
			&nbsp; 
263
		</td>
264
	</tr>
265
	<?php endif; ?><?php if ($ifinfo['subnet']): ?>
266
	<tr>
267
		<td width="22%" class="vncellt"><?=gettext("Subnet mask IPv4");?></td>
268
		<td width="78%" class="listr">
269
			<?=htmlspecialchars($ifinfo['subnet']);?>
270
		</td>
271
	</tr>
272
	<?php endif; ?><?php if ($ifinfo['gateway']): ?>
273
	<tr>
274
		<td width="22%" class="vncellt"><?=gettext("Gateway IPv4");?></td>
275
		<td width="78%" class="listr">
276
			<?=htmlspecialchars($config['interfaces'][$ifdescr]['gateway']);?>
277
			<?=htmlspecialchars($ifinfo['gateway']);?>
278
		</td>
279
	</tr>
280
	<?php endif; ?><?php if ($ifinfo['linklocal']): ?>
281
	<tr>
282
		<td width="22%" class="vncellt"><?=gettext("IPv6 Link Local");?></td>
283
		<td width="78%" class="listr">
284
			<?=htmlspecialchars($ifinfo['linklocal']);?>
285
			&nbsp; 
286
		</td>
287
	</tr>
288
	<?php endif; ?><?php if ($ifinfo['ipaddrv6']): ?>
289
	<tr>
290
		<td width="22%" class="vncellt"><?=gettext("IPv6 address");?></td>
291
		<td width="78%" class="listr">
292
			<?=htmlspecialchars($ifinfo['ipaddrv6']);?>
293
			&nbsp; 
294
		</td>
295
	</tr>
296
	<?php endif; ?><?php if ($ifinfo['subnetv6']): ?>
297
	<tr>
298
		<td width="22%" class="vncellt"><?=gettext("Subnet mask IPv6");?></td>
299
		<td width="78%" class="listr">
300
			<?=htmlspecialchars($ifinfo['subnetv6']);?>
301
		</td>
302
	</tr>
303
	<?php endif; ?><?php if ($ifinfo['gatewayv6']): ?>
304
	<tr>
305
		<td width="22%" class="vncellt"><?=gettext("Gateway IPv6");?></td>
306
		<td width="78%" class="listr">
307
			<?=htmlspecialchars($config['interfaces'][$ifdescr]['gatewayv6']);?>
308
			<?=htmlspecialchars($ifinfo['gatewayv6']);?>
309
		</td>
310
	</tr>
311
	<?php endif; if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): ?>
312
	<tr>
313
	<td width="22%" class="vncellt"><?=gettext("ISP DNS servers");?></td>
314
	<td width="78%" class="listr">
315
		<?php
316
			$dns_servers = get_dns_servers();
317
			foreach($dns_servers as $dns) {
318
				echo "{$dns}<br />";
319
			}
320
		?>
321
		</td>
322
	</tr>
323
	<?php endif; endif; if ($ifinfo['media']): ?>
324
	<tr>
325
		<td width="22%" class="vncellt"><?=gettext("Media");?></td>
326
		<td width="78%" class="listr">
327
			<?=htmlspecialchars($ifinfo['media']);?>
328
		</td>
329
	</tr>
330
	<?php endif; if ($ifinfo['laggproto']): ?>
331
	<tr>
332
		<td width="22%" class="vncellt"><?=gettext("LAGG Protocol");?></td>
333
		<td width="78%" class="listr">
334
			<?=htmlspecialchars($ifinfo['laggproto']);?>
335
		</td>
336
	</tr>
337
	<?php endif; if (is_array($ifinfo['laggport'])): ?>
338
	<tr>
339
		<td width="22%" class="vncellt"><?=gettext("LAGG Ports");?></td>
340
		<td width="78%" class="listr">
341
			<?php 	foreach ($ifinfo['laggport'] as $laggport) { ?>
342
					<?php echo htmlspecialchars($laggport); ?><br />
343
			<?php	} ?>
344
		</td>
345
	</tr>
346
<?php endif; ?><?php if ($ifinfo['channel']): ?>
347
	<tr>
348
		<td width="22%" class="vncellt"><?=gettext("Channel");?></td>
349
		<td width="78%" class="listr">
350
			<?=htmlspecialchars($ifinfo['channel']);?>
351
		</td>
352
	</tr>
353
<?php endif; ?><?php if ($ifinfo['ssid']): ?>
354
	<tr>
355
		<td width="22%" class="vncellt"><?=gettext("SSID");?></td>
356
		<td width="78%" class="listr">
357
			<?=htmlspecialchars($ifinfo['ssid']);?>
358
		</td>
359
	</tr>
360
<?php endif; ?><?php if ($ifinfo['bssid']): ?>
361
	<tr>
362
		<td width="22%" class="vncellt"><?=gettext("BSSID");?></td>
363
		<td width="78%" class="listr">
364
			<?=htmlspecialchars($ifinfo['bssid']);?>
365
		</td>
366
	</tr>
367
<?php endif; ?><?php if ($ifinfo['rate']): ?>
368
	<tr>
369
		<td width="22%" class="vncellt"><?=gettext("Rate");?></td>
370
		<td width="78%" class="listr">
371
			<?=htmlspecialchars($ifinfo['rate']);?>
372
		</td>
373
	</tr>
374
<?php endif; ?><?php if ($ifinfo['rssi']): ?>
375
	<tr>
376
		<td width="22%" class="vncellt"><?=gettext("RSSI");?></td>
377
		<td width="78%" class="listr">
378
			<?=htmlspecialchars($ifinfo['rssi']);?>
379
		</td>
380
	</tr>
381
<?php endif; ?>
382
	<tr>
383
		<td width="22%" class="vncellt"><?=gettext("In/out packets");?></td>
384
		<td width="78%" class="listr">
385
		<?php
386
			echo htmlspecialchars($ifinfo['inpkts'] . "/" . $ifinfo['outpkts'] . " (");
387
			echo htmlspecialchars(format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");
388
		?>
389
		</td>
390
	</tr>
391
	<tr>
392
		<td width="22%" class="vncellt"><?=gettext("In/out packets (pass)");?></td>
393
		<td width="78%" class="listr">
394
			<?php
395
				echo htmlspecialchars($ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass'] . " (");
396
				echo htmlspecialchars(format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
397
			?>
398
		</td>
399
	</tr>
400
	<tr>
401
		<td width="22%" class="vncellt"><?=gettext("In/out packets (block)");?></td>
402
		<td width="78%" class="listr">
403
			<?php
404
				echo htmlspecialchars($ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock'] . " (");
405
				echo htmlspecialchars(format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
406
			?>
407
		</td>
408
	</tr>
409
<?php if (isset($ifinfo['inerrs'])): ?>
410
	<tr>
411
		<td width="22%" class="vncellt"><?=gettext("In/out errors");?></td>
412
		<td width="78%" class="listr">
413
			<?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?>
414
		</td>
415
	</tr>
416
<?php endif; ?>
417
<?php if (isset($ifinfo['collisions'])): ?>
418
	<tr>
419
		<td width="22%" class="vncellt"><?=gettext("Collisions");?></td>
420
		<td width="78%" class="listr">
421
			<?=htmlspecialchars($ifinfo['collisions']);?>
422
		</td>
423
	</tr>
424
<?php endif; ?>
425
<?php endif; ?>
426
<?php if ($ifinfo['bridge']): ?>
427
	<tr>
428
		<td width="22%" class="vncellt"><?php printf(gettext("Bridge (%s)"),$ifinfo['bridgeint']);?></td>
429
		<td width="78%" class="listr">
430
			<?=$ifinfo['bridge'];?>
431
		</td>
432
	</tr>
433
<?php endif; ?>
434
<?php if(file_exists("/usr/bin/vmstat")): ?>
435
<?php
436
	$real_interface = "";
437
	$interrupt_total = "";
438
	$interrupt_sec = "";
439
	$real_interface = $ifinfo['hwif'];
440
	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
441
	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
442
	if(strstr($interrupt_total, "hci")) {
443
		$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
444
		$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;          	
445
	}
446
	unset($interrupt_total); // XXX: FIX ME!  Need a regex and parse correct data 100% of the time.
447
?>
448
<?php if($interrupt_total): ?>
449
	<tr>
450
		<td width="22%" class="vncellt"><?=gettext("Interrupts/Second");?></td>
451
		<td width="78%" class="listr">
452
			<?php
453
				echo $interrupt_total . " " . gettext("total");
454
				echo "<br />";
455
				echo $interrupt_sec . " " . gettext("rate");
456
			?>
457
		</td>
458
	</tr>
459
<?php endif; ?>
460
<?php endif; ?>
461
<?php $i++; endforeach; ?>
462
</table>
463

    
464
<br />
465

    
466
<?php printf(gettext("Using dial-on-demand will bring the connection up again if any packet ".
467
"triggers it. To substantiate this point: disconnecting manually ".
468
"will %snot%s prevent dial-on-demand from making connections ".
469
"to the outside! Don't use dial-on-demand if you want to make sure that the line ".
470
"is kept disconnected."),'<strong>','</strong>')?>
471

    
472
<?php include("fend.inc"); ?>
473
</body>
474
</html>
(192-192/256)