Project

General

Profile

Download (10.5 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("Status","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
?>
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
			<?=htmlspecialchars($ifname);?>
80
			interface
81
			(<?=($ifinfo['hwif']);?>)
82
		</td>
83
	</tr>
84
	<tr>
85
		<td width="22%" class="vncellt">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="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="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">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="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="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">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="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="Connect" class="formbtns">
133
			<?php endif; ?>
134
			</a>
135
		</td>
136
	</tr>
137
	<?php  endif; if ($ifinfo['ppplink']): ?>
138
	<tr>
139
		<td width="22%" class="vncellt">PPP</td>
140
		<td width="78%" class="listr">
141
			<?=htmlspecialchars($ifinfo['ppplink']);?>&nbsp;&nbsp;
142
			<?php if ($ifinfo['status'] == "up"): ?>
143
				<a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
144
				<input type="button" name="<?php echo $ifdescr; ?>" value="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="Connect" class="formbtns">
148
			<?php endif; ?>
149
			</a>
150
		</td>
151
	</tr>
152
	<?php  endif; if ($ifinfo['macaddr']): ?>
153
	<tr>
154
		<td width="22%" class="vncellt">MAC address</td>
155
		<td width="78%" class="listr">
156
			<?=htmlspecialchars($ifinfo['macaddr']);?>
157
		</td>
158
	</tr>
159
	<?php endif; if ($ifinfo['status'] != "down"): ?>
160
	<?php if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down"): ?>
161
	<?php if ($ifinfo['ipaddr']): ?>
162
	<tr>
163
		<td width="22%" class="vncellt">IP address</td>
164
		<td width="78%" class="listr">
165
			<?=htmlspecialchars($ifinfo['ipaddr']);?>
166
			&nbsp; 
167
		</td>
168
	</tr>
169
	<?php endif; ?><?php if ($ifinfo['subnet']): ?>
170
	<tr>
171
		<td width="22%" class="vncellt">Subnet mask</td>
172
		<td width="78%" class="listr">
173
			<?=htmlspecialchars($ifinfo['subnet']);?>
174
		</td>
175
	</tr>
176
	<?php endif; ?><?php if ($ifinfo['gateway']): ?>
177
	<tr>
178
		<td width="22%" class="vncellt">Gateway</td>
179
		<td width="78%" class="listr">
180
			<?=htmlspecialchars($config['interfaces'][$ifdescr]['gateway']);?>
181
			<?=htmlspecialchars($ifinfo['gateway']);?>
182
		</td>
183
	</tr>
184
	<?php endif; if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): ?>
185
	<tr>
186
	<td width="22%" class="vncellt">ISP DNS servers</td>
187
	<td width="78%" class="listr">
188
		<?php
189
			$dns_servers = get_dns_servers();
190
			foreach($dns_servers as $dns) {
191
				echo "{$dns}<br>";
192
			}
193
		?>
194
		</td>
195
	</tr>
196
	<?php endif; endif; if ($ifinfo['media']): ?>
197
	<tr>
198
		<td width="22%" class="vncellt">Media</td>
199
		<td width="78%" class="listr">
200
			<?=htmlspecialchars($ifinfo['media']);?>
201
		</td>
202
	</tr>
203
<?php endif; ?><?php if ($ifinfo['channel']): ?>
204
	<tr>
205
		<td width="22%" class="vncellt">Channel</td>
206
		<td width="78%" class="listr">
207
			<?=htmlspecialchars($ifinfo['channel']);?>
208
		</td>
209
	</tr>
210
<?php endif; ?><?php if ($ifinfo['ssid']): ?>
211
	<tr>
212
		<td width="22%" class="vncellt">SSID</td>
213
		<td width="78%" class="listr">
214
			<?=htmlspecialchars($ifinfo['ssid']);?>
215
		</td>
216
	</tr>
217
<?php endif; ?><?php if ($ifinfo['bssid']): ?>
218
	<tr>
219
		<td width="22%" class="vncellt">BSSID</td>
220
		<td width="78%" class="listr">
221
			<?=htmlspecialchars($ifinfo['bssid']);?>
222
		</td>
223
	</tr>
224
<?php endif; ?><?php if ($ifinfo['rate']): ?>
225
	<tr>
226
		<td width="22%" class="vncellt">Rate</td>
227
		<td width="78%" class="listr">
228
			<?=htmlspecialchars($ifinfo['rate']);?>
229
		</td>
230
	</tr>
231
<?php endif; ?><?php if ($ifinfo['rssi']): ?>
232
	<tr>
233
		<td width="22%" class="vncellt">RSSI</td>
234
		<td width="78%" class="listr">
235
			<?=htmlspecialchars($ifinfo['rssi']);?>
236
		</td>
237
	</tr>
238
<?php endif; ?>
239
	<tr>
240
		<td width="22%" class="vncellt">In/out packets</td>
241
		<td width="78%" class="listr">
242
		<?php
243
			echo htmlspecialchars($ifinfo['inpkts'] . "/" . $ifinfo['outpkts'] . " (");
244
			echo htmlspecialchars(format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");
245
		?>
246
		</td>
247
	</tr>
248
	<tr>
249
		<td width="22%" class="vncellt">In/out packets (pass)</td>
250
		<td width="78%" class="listr">
251
			<?php
252
				echo htmlspecialchars($ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass'] . " (");
253
				echo htmlspecialchars(format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
254
			?>
255
		</td>
256
	</tr>
257
	<tr>
258
		<td width="22%" class="vncellt">In/out packets (block)</td>
259
		<td width="78%" class="listr">
260
			<?php
261
				echo htmlspecialchars($ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock'] . " (");
262
				echo htmlspecialchars(format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
263
			?>
264
		</td>
265
	</tr>
266
<?php if (isset($ifinfo['inerrs'])): ?>
267
	<tr>
268
		<td width="22%" class="vncellt">In/out errors</td>
269
		<td width="78%" class="listr">
270
			<?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?>
271
		</td>
272
	</tr>
273
<?php endif; ?>
274
<?php if (isset($ifinfo['collisions'])): ?>
275
	<tr>
276
		<td width="22%" class="vncellt">Collisions</td>
277
		<td width="78%" class="listr">
278
			<?=htmlspecialchars($ifinfo['collisions']);?>
279
		</td>
280
	</tr>
281
<?php endif; ?>
282
<?php endif; ?>
283
<?php if ($ifinfo['bridge']): ?>
284
	<tr>
285
		<td width="22%" class="vncellt">Bridge (<?=$ifinfo['bridgeint']?>)</td>
286
		<td width="78%" class="listr">
287
			<?=$ifinfo['bridge'];?>
288
		</td>
289
	</tr>
290
<?php endif; ?>
291
<?php if(file_exists("/usr/bin/vmstat")): ?>
292
<?php
293
	$real_interface = "";
294
	$interrupt_total = "";
295
	$interrupt_sec = "";
296
	$real_interface = $ifinfo['hwif'];
297
	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
298
	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
299
	if(strstr($interrupt_total, "hci")) {
300
		$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
301
		$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;          	
302
	}
303
	unset($interrupt_total); // XXX: FIX ME!  Need a regex and parse correct data 100% of the time.
304
?>
305
<?php if($interrupt_total): ?>
306
	<tr>
307
		<td width="22%" class="vncellt">Interrupts/Second</td>
308
		<td width="78%" class="listr">
309
			<?php
310
				echo $interrupt_total . " total";
311
				echo "<br/>";
312
				echo $interrupt_sec . " rate";
313
			?>
314
		</td>
315
	</tr>
316
<?php endif; ?>
317
<?php endif; ?>
318
<?php $i++; endforeach; ?>
319
</table>
320

    
321
<br/>
322

    
323
</strong>Using dial-on-demand will bring the connection up again if any packet
324
triggers it. To substantiate this point: disconnecting manually
325
will <strong>not</strong> prevent dial-on-demand from making connections
326
to the outside! Don't use dial-on-demand if you want to make sure that the line
327
is kept disconnected.
328

    
329
<?php include("fend.inc"); ?>
(154-154/214)