Project

General

Profile

Download (16.7 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	status_interfaces.php
5
	part of pfSense
6
	Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>.
7
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
8
	All rights reserved.
9

    
10
	originally part of m0n0wall (http://m0n0.ch/wall)
11
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
12
	All rights reserved.
13

    
14
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16

    
17
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19

    
20
	2. Redistributions in binary form must reproduce the above copyright
21
	   notice, this list of conditions and the following disclaimer in the
22
	   documentation and/or other materials provided with the distribution.
23

    
24
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
	POSSIBILITY OF SUCH DAMAGE.
34
*/
35
/*	
36
	pfSense_MODULE:	interfaces
37
*/
38

    
39
##|+PRIV
40
##|*IDENT=page-status-interfaces
41
##|*NAME=Status: Interfaces page
42
##|*DESCR=Allow access to the 'Status: Interfaces' page.
43
##|*MATCH=status_interfaces.php*
44
##|-PRIV
45

    
46
require_once("guiconfig.inc");
47
require_once("shaper.inc");
48
require_once("filter.inc");
49

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

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

    
64
?>
65

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

    
472
<br />
473

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

    
480
<?php include("fend.inc"); ?>
481
</body>
482
</html>
(192-192/256)