Project

General

Profile

Download (12.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(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("IP 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");?></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");?></td>
208
		<td width="78%" class="listr">
209
			<?=htmlspecialchars($config['interfaces'][$ifdescr]['gateway']);?>
210
			<?=htmlspecialchars($ifinfo['gateway']);?>
211
		</td>
212
	</tr>
213
	<?php endif; if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): ?>
214
	<tr>
215
	<td width="22%" class="vncellt"><?=gettext("ISP DNS servers");?></td>
216
	<td width="78%" class="listr">
217
		<?php
218
			$dns_servers = get_dns_servers();
219
			foreach($dns_servers as $dns) {
220
				echo "{$dns}<br>";
221
			}
222
		?>
223
		</td>
224
	</tr>
225
	<?php endif; endif; if ($ifinfo['media']): ?>
226
	<tr>
227
		<td width="22%" class="vncellt"><?=gettext("Media");?></td>
228
		<td width="78%" class="listr">
229
			<?=htmlspecialchars($ifinfo['media']);?>
230
		</td>
231
	</tr>
232
<?php endif; ?><?php if ($ifinfo['channel']): ?>
233
	<tr>
234
		<td width="22%" class="vncellt"><?=gettext("Channel");?></td>
235
		<td width="78%" class="listr">
236
			<?=htmlspecialchars($ifinfo['channel']);?>
237
		</td>
238
	</tr>
239
<?php endif; ?><?php if ($ifinfo['ssid']): ?>
240
	<tr>
241
		<td width="22%" class="vncellt"><?=gettext("SSID");?></td>
242
		<td width="78%" class="listr">
243
			<?=htmlspecialchars($ifinfo['ssid']);?>
244
		</td>
245
	</tr>
246
<?php endif; ?><?php if ($ifinfo['bssid']): ?>
247
	<tr>
248
		<td width="22%" class="vncellt"><?=gettext("BSSID");?></td>
249
		<td width="78%" class="listr">
250
			<?=htmlspecialchars($ifinfo['bssid']);?>
251
		</td>
252
	</tr>
253
<?php endif; ?><?php if ($ifinfo['rate']): ?>
254
	<tr>
255
		<td width="22%" class="vncellt"><?=gettext("Rate");?></td>
256
		<td width="78%" class="listr">
257
			<?=htmlspecialchars($ifinfo['rate']);?>
258
		</td>
259
	</tr>
260
<?php endif; ?><?php if ($ifinfo['rssi']): ?>
261
	<tr>
262
		<td width="22%" class="vncellt"><?=gettext("RSSI");?></td>
263
		<td width="78%" class="listr">
264
			<?=htmlspecialchars($ifinfo['rssi']);?>
265
		</td>
266
	</tr>
267
<?php endif; ?>
268
	<tr>
269
		<td width="22%" class="vncellt"><?=gettext("In/out packets");?></td>
270
		<td width="78%" class="listr">
271
		<?php
272
			echo htmlspecialchars($ifinfo['inpkts'] . "/" . $ifinfo['outpkts'] . " (");
273
			echo htmlspecialchars(format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");
274
		?>
275
		</td>
276
	</tr>
277
	<tr>
278
		<td width="22%" class="vncellt"><?=gettext("In/out packets (pass)");?></td>
279
		<td width="78%" class="listr">
280
			<?php
281
				echo htmlspecialchars($ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass'] . " (");
282
				echo htmlspecialchars(format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
283
			?>
284
		</td>
285
	</tr>
286
	<tr>
287
		<td width="22%" class="vncellt"><?=gettext("In/out packets (block)");?></td>
288
		<td width="78%" class="listr">
289
			<?php
290
				echo htmlspecialchars($ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock'] . " (");
291
				echo htmlspecialchars(format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
292
			?>
293
		</td>
294
	</tr>
295
<?php if (isset($ifinfo['inerrs'])): ?>
296
	<tr>
297
		<td width="22%" class="vncellt"><?=gettext("In/out errors");?></td>
298
		<td width="78%" class="listr">
299
			<?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?>
300
		</td>
301
	</tr>
302
<?php endif; ?>
303
<?php if (isset($ifinfo['collisions'])): ?>
304
	<tr>
305
		<td width="22%" class="vncellt"><?=gettext("Collisions");?></td>
306
		<td width="78%" class="listr">
307
			<?=htmlspecialchars($ifinfo['collisions']);?>
308
		</td>
309
	</tr>
310
<?php endif; ?>
311
<?php endif; ?>
312
<?php if ($ifinfo['bridge']): ?>
313
	<tr>
314
		<td width="22%" class="vncellt"><?php printf(gettext("Bridge (%s)"),$ifinfo['bridgeint']);?></td>
315
		<td width="78%" class="listr">
316
			<?=$ifinfo['bridge'];?>
317
		</td>
318
	</tr>
319
<?php endif; ?>
320
<?php if(file_exists("/usr/bin/vmstat")): ?>
321
<?php
322
	$real_interface = "";
323
	$interrupt_total = "";
324
	$interrupt_sec = "";
325
	$real_interface = $ifinfo['hwif'];
326
	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
327
	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
328
	if(strstr($interrupt_total, "hci")) {
329
		$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
330
		$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;          	
331
	}
332
	unset($interrupt_total); // XXX: FIX ME!  Need a regex and parse correct data 100% of the time.
333
?>
334
<?php if($interrupt_total): ?>
335
	<tr>
336
		<td width="22%" class="vncellt"><?=gettext("Interrupts/Second");?></td>
337
		<td width="78%" class="listr">
338
			<?php
339
				echo $interrupt_total . " " . gettext("total");
340
				echo "<br/>";
341
				echo $interrupt_sec . " " . gettext("rate");
342
			?>
343
		</td>
344
	</tr>
345
<?php endif; ?>
346
<?php endif; ?>
347
<?php $i++; endforeach; ?>
348
</table>
349

    
350
<br/>
351

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

    
358
<?php include("fend.inc"); ?>
(167-167/228)