Project

General

Profile

Download (13.3 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
	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

    
47
if ($_GET['if']) {
48
	$interface = $_GET['if'];
49
	if ($_GET['action'] == "Disconnect" || $_GET['action'] == "Release") {
50
		interface_bring_down($interface);
51
	} else if ($_GET['action'] == "Connect" || $_GET['action'] == "Renew") {
52
		interface_configure($interface); 
53
	}
54
	header("Location: status_interfaces.php");
55
	exit;
56
}
57

    
58
$pgtitle = array(gettext("Status"),gettext("Interfaces"));
59
include("head.inc");
60

    
61
?>
62

    
63
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
64
<?php include("fbegin.inc"); ?>
65
<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
	// Load MAC-Manufacturer table
72
	$mac_man = load_mac_manufacturer_table();
73
?>
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
			<?=htmlspecialchars($ifname);?> <?=gettext("interface"); ?> (<?=htmlspecialchars($ifinfo['hwif']);?>)
82
		</td>
83
	</tr>
84
	<tr>
85
		<td width="22%" class="vncellt"><?=gettext("Status"); ?></td>
86
		<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
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Release");?>" class="formbtns">
100
			<?php else: ?>
101
				<a href="status_interfaces.php?action=Renew&if=<?php echo $ifdescr; ?>">
102
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Renew");?>" class="formbtns">
103
			<?php endif; ?>
104
			</a>
105
		</td>
106
	</tr>
107
	<?php endif; if ($ifinfo['pppoelink']): ?>
108
	<tr>
109
		<td width="22%" class="vncellt"><?=gettext("PPPoE"); ?></td>
110
		<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
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
115
			<?php else: ?>
116
				<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
117
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
118
				<?php endif; ?>
119
			</a>
120
		</td>
121
	</tr>
122
	<?php  endif; if ($ifinfo['pptplink']): ?>
123
	<tr>
124
		<td width="22%" class="vncellt"><?=gettext("PPTP"); ?></td>
125
		<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
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
130
			<?php else: ?>
131
				<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
				<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
147
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
148
			<?php endif; ?>
149
			</a>
150
		</td>
151
	</tr>
152
	<?php  endif; if ($ifinfo['ppplink']): ?>
153
	<tr>
154
		<td width="22%" class="vncellt"><?=gettext("PPP"); ?></td>
155
		<td width="78%" class="listr">
156
			<?=htmlspecialchars($ifinfo['pppinfo']);?>
157
			<?php if ($ifinfo['ppplink'] == "up"): ?>
158
				<a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
159
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
160
			<?php else: ?>
161
				<?php if (!$ifinfo['nodevice']): ?>
162
					<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
163
					<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
164
				<?php endif; ?>
165
			<?php endif; ?>
166
			</a>
167
		</td>
168
	</tr>
169
	<?php  endif; if ($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated']): ?>
170
	<tr>
171
		<td width="22%" class="vncellt"><?=gettext("Uptime ");?><?php if ($ifinfo['ppp_uptime_accumulated']) echo "(historical)"; ?></td>
172
		<td width="78%" class="listr">
173
			<?=htmlspecialchars($ifinfo['ppp_uptime']);?> <?=htmlspecialchars($ifinfo['ppp_uptime_accumulated']);?>
174
		</td>
175
        </tr>
176
	<?php  endif; if ($ifinfo['macaddr']): ?>
177
	<tr>
178
		<td width="22%" class="vncellt"><?=gettext("MAC address");?></td>
179
		<td width="78%" class="listr">
180
			<?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>" . $mac . " - " . htmlspecialchars($mac_man[$mac_hi]); print "</span>"; }
184
			      else {print htmlspecialchars($mac);}
185
			?>
186
		</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
		<td width="22%" class="vncellt"><?=gettext("IPv4 address");?></td>
193
		<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
		<td width="22%" class="vncellt"><?=gettext("Subnet mask IPv4");?></td>
201
		<td width="78%" class="listr">
202
			<?=htmlspecialchars($ifinfo['subnet']);?>
203
		</td>
204
	</tr>
205
	<?php endif; ?><?php if ($ifinfo['gateway']): ?>
206
	<tr>
207
		<td width="22%" class="vncellt"><?=gettext("Gateway IPv4");?></td>
208
		<td width="78%" class="listr">
209
			<?=htmlspecialchars($config['interfaces'][$ifdescr]['gateway']);?>
210
			<?=htmlspecialchars($ifinfo['gateway']);?>
211
		</td>
212
	</tr>
213
	<?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
	<?php endif; if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): ?>
238
	<tr>
239
	<td width="22%" class="vncellt"><?=gettext("ISP DNS servers");?></td>
240
	<td width="78%" class="listr">
241
		<?php
242
			$dns_servers = get_dns_servers();
243
			foreach($dns_servers as $dns) {
244
				echo "{$dns}<br>";
245
			}
246
		?>
247
		</td>
248
	</tr>
249
	<?php endif; endif; if ($ifinfo['media']): ?>
250
	<tr>
251
		<td width="22%" class="vncellt"><?=gettext("Media");?></td>
252
		<td width="78%" class="listr">
253
			<?=htmlspecialchars($ifinfo['media']);?>
254
		</td>
255
	</tr>
256
<?php endif; ?><?php if ($ifinfo['channel']): ?>
257
	<tr>
258
		<td width="22%" class="vncellt"><?=gettext("Channel");?></td>
259
		<td width="78%" class="listr">
260
			<?=htmlspecialchars($ifinfo['channel']);?>
261
		</td>
262
	</tr>
263
<?php endif; ?><?php if ($ifinfo['ssid']): ?>
264
	<tr>
265
		<td width="22%" class="vncellt"><?=gettext("SSID");?></td>
266
		<td width="78%" class="listr">
267
			<?=htmlspecialchars($ifinfo['ssid']);?>
268
		</td>
269
	</tr>
270
<?php endif; ?><?php if ($ifinfo['bssid']): ?>
271
	<tr>
272
		<td width="22%" class="vncellt"><?=gettext("BSSID");?></td>
273
		<td width="78%" class="listr">
274
			<?=htmlspecialchars($ifinfo['bssid']);?>
275
		</td>
276
	</tr>
277
<?php endif; ?><?php if ($ifinfo['rate']): ?>
278
	<tr>
279
		<td width="22%" class="vncellt"><?=gettext("Rate");?></td>
280
		<td width="78%" class="listr">
281
			<?=htmlspecialchars($ifinfo['rate']);?>
282
		</td>
283
	</tr>
284
<?php endif; ?><?php if ($ifinfo['rssi']): ?>
285
	<tr>
286
		<td width="22%" class="vncellt"><?=gettext("RSSI");?></td>
287
		<td width="78%" class="listr">
288
			<?=htmlspecialchars($ifinfo['rssi']);?>
289
		</td>
290
	</tr>
291
<?php endif; ?>
292
	<tr>
293
		<td width="22%" class="vncellt"><?=gettext("In/out packets");?></td>
294
		<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
		<td width="22%" class="vncellt"><?=gettext("In/out packets (pass)");?></td>
303
		<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
		<td width="22%" class="vncellt"><?=gettext("In/out packets (block)");?></td>
312
		<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
		<td width="22%" class="vncellt"><?=gettext("In/out errors");?></td>
322
		<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
		<td width="22%" class="vncellt"><?=gettext("Collisions");?></td>
330
		<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
		<td width="22%" class="vncellt"><?php printf(gettext("Bridge (%s)"),$ifinfo['bridgeint']);?></td>
339
		<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
		<td width="22%" class="vncellt"><?=gettext("Interrupts/Second");?></td>
361
		<td width="78%" class="listr">
362
			<?php
363
				echo $interrupt_total . " " . gettext("total");
364
				echo "<br/>";
365
				echo $interrupt_sec . " " . gettext("rate");
366
			?>
367
		</td>
368
	</tr>
369
<?php endif; ?>
370
<?php endif; ?>
371
<?php $i++; endforeach; ?>
372
</table>
373

    
374
<br/>
375

    
376
</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

    
382
<?php include("fend.inc"); ?>
(171-171/232)