Project

General

Profile

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

    
328
<br/>
329

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

    
336
<?php include("fend.inc"); ?>
(161-161/222)