Project

General

Profile

Download (13 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
?>
72
<?php if ($i): ?>
73
	<tr>
74
		<td colspan="8" class="list" height="12"></td>
75
	</tr>
76
<?php endif; ?>
77
	<tr>
78
		<td colspan="2" class="listtopic">
79 ee644822 Carlos Eduardo Ramos
			<?=htmlspecialchars($ifname);?> <?=gettext("interface"); ?> (<?=htmlspecialchars($ifinfo['hwif']);?>)
80 0d7b21de sullrich
		</td>
81
	</tr>
82
	<tr>
83 ee644822 Carlos Eduardo Ramos
		<td width="22%" class="vncellt"><?=gettext("Status"); ?></td>
84 0d7b21de sullrich
		<td width="78%" class="listr">
85
			<?=htmlspecialchars($ifinfo['status']);?>
86
		</td>
87
	</tr>
88
	<?php if ($ifinfo['dhcplink']): ?>
89
	<tr>
90
		<td width="22%" class="vncellt">
91
			DHCP
92
		</td>
93
		<td width="78%" class="listr">
94
			<?=htmlspecialchars($ifinfo['dhcplink']);?>&nbsp;&nbsp;
95
			<?php if ($ifinfo['dhcplink'] == "up"): ?>
96
				<a href="status_interfaces.php?action=Release&if=<?php echo $ifdescr; ?>">
97 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Release");?>" class="formbtns">
98 0d7b21de sullrich
			<?php else: ?>
99
				<a href="status_interfaces.php?action=Renew&if=<?php echo $ifdescr; ?>">
100 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Renew");?>" class="formbtns">
101 0d7b21de sullrich
			<?php endif; ?>
102
			</a>
103
		</td>
104
	</tr>
105
	<?php endif; if ($ifinfo['pppoelink']): ?>
106
	<tr>
107 ee644822 Carlos Eduardo Ramos
		<td width="22%" class="vncellt"><?=gettext("PPPoE"); ?></td>
108 0d7b21de sullrich
		<td width="78%" class="listr">
109
			<?=htmlspecialchars($ifinfo['pppoelink']);?>&nbsp;&nbsp;
110
			<?php if ($ifinfo['pppoelink'] == "up"): ?>
111
				<a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
112 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
113 0d7b21de sullrich
			<?php else: ?>
114
				<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
115 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
116 0d7b21de sullrich
				<?php endif; ?>
117
			</a>
118
		</td>
119
	</tr>
120
	<?php  endif; if ($ifinfo['pptplink']): ?>
121
	<tr>
122 ee644822 Carlos Eduardo Ramos
		<td width="22%" class="vncellt"><?=gettext("PPTP"); ?></td>
123 0d7b21de sullrich
		<td width="78%" class="listr">
124
			<?=htmlspecialchars($ifinfo['pptplink']);?>&nbsp;&nbsp;
125
			<?php if ($ifinfo['pptplink'] == "up"): ?>
126
				<a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
127 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
128 0d7b21de sullrich
			<?php else: ?>
129
				<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
130 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
131 0d7b21de sullrich
			<?php endif; ?>
132
			</a>
133
		</td>
134
	</tr>
135 633de329 gnhb
	<?php  endif; if ($ifinfo['l2tplink']): ?>
136
	<tr>
137
		<td width="22%" class="vncellt"><?=gettext("L2TP"); ?></td>
138
		<td width="78%" class="listr">
139
			<?=htmlspecialchars($ifinfo['l2tplink']);?>&nbsp;&nbsp;
140
			<?php if ($ifinfo['l2tplink'] == "up"): ?>
141
				<a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
142
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
143
			<?php else: ?>
144 0d7b21de sullrich
				<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
145 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
146 0d7b21de sullrich
			<?php endif; ?>
147
			</a>
148
		</td>
149
	</tr>
150
	<?php  endif; if ($ifinfo['ppplink']): ?>
151
	<tr>
152 ee644822 Carlos Eduardo Ramos
		<td width="22%" class="vncellt"><?=gettext("PPP"); ?></td>
153 0d7b21de sullrich
		<td width="78%" class="listr">
154 c90f2471 gnhb
			<?=htmlspecialchars($ifinfo['pppinfo']);?>
155
			<?php if ($ifinfo['ppplink'] == "up"): ?>
156 0d7b21de sullrich
				<a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
157 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
158 0d7b21de sullrich
			<?php else: ?>
159 c90f2471 gnhb
				<?php if (!$ifinfo['nodevice']): ?>
160 9ebe7028 gnhb
					<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
161 c8927bfb Rafael Lucas
					<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
162 9ebe7028 gnhb
				<?php endif; ?>
163 0d7b21de sullrich
			<?php endif; ?>
164
			</a>
165
		</td>
166
	</tr>
167 8eb2f33a Scott Ullrich
	<?php  endif; if ($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated']): ?>
168
	<tr>
169 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Uptime ");?><?php if ($ifinfo['ppp_uptime_accumulated']) echo "(historical)"; ?></td>
170 59db783a gnhb
		<td width="78%" class="listr">
171
			<?=htmlspecialchars($ifinfo['ppp_uptime']);?> <?=htmlspecialchars($ifinfo['ppp_uptime_accumulated']);?>
172
		</td>
173 8eb2f33a Scott Ullrich
        </tr>
174 0d7b21de sullrich
	<?php  endif; if ($ifinfo['macaddr']): ?>
175
	<tr>
176 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("MAC address");?></td>
177 0d7b21de sullrich
		<td width="78%" class="listr">
178
			<?=htmlspecialchars($ifinfo['macaddr']);?>
179
		</td>
180
	</tr>
181
	<?php endif; if ($ifinfo['status'] != "down"): ?>
182
	<?php if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down"): ?>
183
	<?php if ($ifinfo['ipaddr']): ?>
184
	<tr>
185 bbcc0f9c Seth Mos
		<td width="22%" class="vncellt"><?=gettext("IPv4 address");?></td>
186 0d7b21de sullrich
		<td width="78%" class="listr">
187
			<?=htmlspecialchars($ifinfo['ipaddr']);?>
188
			&nbsp; 
189
		</td>
190
	</tr>
191
	<?php endif; ?><?php if ($ifinfo['subnet']): ?>
192
	<tr>
193 bbcc0f9c Seth Mos
		<td width="22%" class="vncellt"><?=gettext("Subnet mask IPv4");?></td>
194 0d7b21de sullrich
		<td width="78%" class="listr">
195
			<?=htmlspecialchars($ifinfo['subnet']);?>
196
		</td>
197
	</tr>
198
	<?php endif; ?><?php if ($ifinfo['gateway']): ?>
199
	<tr>
200 bbcc0f9c Seth Mos
		<td width="22%" class="vncellt"><?=gettext("Gateway IPv4");?></td>
201 0d7b21de sullrich
		<td width="78%" class="listr">
202 dde9a4fc Seth Mos
			<?=htmlspecialchars($config['interfaces'][$ifdescr]['gateway']);?>
203
			<?=htmlspecialchars($ifinfo['gateway']);?>
204 0d7b21de sullrich
		</td>
205
	</tr>
206 bbcc0f9c Seth Mos
	<?php endif; ?>
207
	<?php if ($ifinfo['ipaddrv6']): ?>
208
	<tr>
209
		<td width="22%" class="vncellt"><?=gettext("IPv6 address");?></td>
210
		<td width="78%" class="listr">
211
			<?=htmlspecialchars($ifinfo['ipaddrv6']);?>
212
			&nbsp; 
213
		</td>
214
	</tr>
215
	<?php endif; ?><?php if ($ifinfo['subnetv6']): ?>
216
	<tr>
217
		<td width="22%" class="vncellt"><?=gettext("Subnet mask IPv6");?></td>
218
		<td width="78%" class="listr">
219
			<?=htmlspecialchars($ifinfo['subnetv6']);?>
220
		</td>
221
	</tr>
222
	<?php endif; ?><?php if ($ifinfo['gatewayv6']): ?>
223
	<tr>
224
		<td width="22%" class="vncellt"><?=gettext("Gateway IPv6");?></td>
225
		<td width="78%" class="listr">
226
			<?=htmlspecialchars($config['interfaces'][$ifdescr]['gatewayv6']);?>
227
			<?=htmlspecialchars($ifinfo['gatewayv6']);?>
228
		</td>
229
	</tr>
230 0d7b21de sullrich
	<?php endif; if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): ?>
231
	<tr>
232 c8927bfb Rafael Lucas
	<td width="22%" class="vncellt"><?=gettext("ISP DNS servers");?></td>
233 0d7b21de sullrich
	<td width="78%" class="listr">
234 6205a304 Scott Ullrich
		<?php
235
			$dns_servers = get_dns_servers();
236
			foreach($dns_servers as $dns) {
237
				echo "{$dns}<br>";
238 f559eaf6 Scott Ullrich
			}
239 6205a304 Scott Ullrich
		?>
240
		</td>
241 0d7b21de sullrich
	</tr>
242
	<?php endif; endif; if ($ifinfo['media']): ?>
243
	<tr>
244 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Media");?></td>
245 0d7b21de sullrich
		<td width="78%" class="listr">
246
			<?=htmlspecialchars($ifinfo['media']);?>
247
		</td>
248
	</tr>
249
<?php endif; ?><?php if ($ifinfo['channel']): ?>
250
	<tr>
251 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Channel");?></td>
252 0d7b21de sullrich
		<td width="78%" class="listr">
253
			<?=htmlspecialchars($ifinfo['channel']);?>
254
		</td>
255
	</tr>
256
<?php endif; ?><?php if ($ifinfo['ssid']): ?>
257
	<tr>
258 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("SSID");?></td>
259 0d7b21de sullrich
		<td width="78%" class="listr">
260
			<?=htmlspecialchars($ifinfo['ssid']);?>
261
		</td>
262
	</tr>
263
<?php endif; ?><?php if ($ifinfo['bssid']): ?>
264
	<tr>
265 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("BSSID");?></td>
266 0d7b21de sullrich
		<td width="78%" class="listr">
267
			<?=htmlspecialchars($ifinfo['bssid']);?>
268
		</td>
269
	</tr>
270
<?php endif; ?><?php if ($ifinfo['rate']): ?>
271
	<tr>
272 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Rate");?></td>
273 0d7b21de sullrich
		<td width="78%" class="listr">
274
			<?=htmlspecialchars($ifinfo['rate']);?>
275
		</td>
276
	</tr>
277
<?php endif; ?><?php if ($ifinfo['rssi']): ?>
278
	<tr>
279 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("RSSI");?></td>
280 0d7b21de sullrich
		<td width="78%" class="listr">
281
			<?=htmlspecialchars($ifinfo['rssi']);?>
282
		</td>
283
	</tr>
284
<?php endif; ?>
285
	<tr>
286 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out packets");?></td>
287 0d7b21de sullrich
		<td width="78%" class="listr">
288
		<?php
289
			echo htmlspecialchars($ifinfo['inpkts'] . "/" . $ifinfo['outpkts'] . " (");
290
			echo htmlspecialchars(format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");
291
		?>
292
		</td>
293
	</tr>
294
	<tr>
295 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out packets (pass)");?></td>
296 0d7b21de sullrich
		<td width="78%" class="listr">
297
			<?php
298
				echo htmlspecialchars($ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass'] . " (");
299
				echo htmlspecialchars(format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
300
			?>
301
		</td>
302
	</tr>
303
	<tr>
304 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out packets (block)");?></td>
305 0d7b21de sullrich
		<td width="78%" class="listr">
306
			<?php
307
				echo htmlspecialchars($ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock'] . " (");
308
				echo htmlspecialchars(format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
309
			?>
310
		</td>
311
	</tr>
312
<?php if (isset($ifinfo['inerrs'])): ?>
313
	<tr>
314 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out errors");?></td>
315 0d7b21de sullrich
		<td width="78%" class="listr">
316
			<?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?>
317
		</td>
318
	</tr>
319
<?php endif; ?>
320
<?php if (isset($ifinfo['collisions'])): ?>
321
	<tr>
322 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Collisions");?></td>
323 0d7b21de sullrich
		<td width="78%" class="listr">
324
			<?=htmlspecialchars($ifinfo['collisions']);?>
325
		</td>
326
	</tr>
327
<?php endif; ?>
328
<?php endif; ?>
329
<?php if ($ifinfo['bridge']): ?>
330
	<tr>
331 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?php printf(gettext("Bridge (%s)"),$ifinfo['bridgeint']);?></td>
332 0d7b21de sullrich
		<td width="78%" class="listr">
333
			<?=$ifinfo['bridge'];?>
334
		</td>
335
	</tr>
336
<?php endif; ?>
337
<?php if(file_exists("/usr/bin/vmstat")): ?>
338
<?php
339
	$real_interface = "";
340
	$interrupt_total = "";
341
	$interrupt_sec = "";
342
	$real_interface = $ifinfo['hwif'];
343
	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
344
	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
345
	if(strstr($interrupt_total, "hci")) {
346
		$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
347
		$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;          	
348
	}
349
	unset($interrupt_total); // XXX: FIX ME!  Need a regex and parse correct data 100% of the time.
350
?>
351
<?php if($interrupt_total): ?>
352
	<tr>
353 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Interrupts/Second");?></td>
354 0d7b21de sullrich
		<td width="78%" class="listr">
355
			<?php
356 ee644822 Carlos Eduardo Ramos
				echo $interrupt_total . " " . gettext("total");
357 0d7b21de sullrich
				echo "<br/>";
358 ee644822 Carlos Eduardo Ramos
				echo $interrupt_sec . " " . gettext("rate");
359 0d7b21de sullrich
			?>
360
		</td>
361
	</tr>
362
<?php endif; ?>
363
<?php endif; ?>
364
<?php $i++; endforeach; ?>
365
</table>
366 29ed06c9 Scott Ullrich
367 d290167c Seth Mos
<br/>
368 0d7b21de sullrich
369 c8927bfb Rafael Lucas
</strong><?php printf(gettext("Using dial-on-demand will bring the connection up again if any packet ".
370
"triggers it. To substantiate this point: disconnecting manually ".
371
"will %snot%s prevent dial-on-demand from making connections ".
372
"to the outside! Don't use dial-on-demand if you want to make sure that the line ".
373
"is kept disconnected."),'<strong>','</strong>')?>
374 71d9cd3d Scott Ullrich
375 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>