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 |
d88c6a9f
|
Scott Ullrich
|
$pgtitle = array("Status","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 |
|
|
<?=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']);?>
|
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']);?>
|
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']);?>
|
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 |
c90f2471
|
gnhb
|
<?=htmlspecialchars($ifinfo['pppinfo']);?>
|
142 |
|
|
<?php if ($ifinfo['ppplink'] == "up"): ?>
|
143 |
0d7b21de
|
sullrich
|
<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 |
c90f2471
|
gnhb
|
<?php if (!$ifinfo['nodevice']): ?>
|
147 |
9ebe7028
|
gnhb
|
<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
|
148 |
|
|
<input type="button" name="<?php echo $ifdescr; ?>" value="Connect" class="formbtns">
|
149 |
|
|
<?php endif; ?>
|
150 |
0d7b21de
|
sullrich
|
<?php endif; ?>
|
151 |
|
|
</a>
|
152 |
|
|
</td>
|
153 |
|
|
</tr>
|
154 |
8eb2f33a
|
Scott Ullrich
|
<?php endif; if ($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated']): ?>
|
155 |
|
|
<tr>
|
156 |
9ebe7028
|
gnhb
|
<td width="22%" class="vncellt">PPP uptime (historical)</td>
|
157 |
8eb2f33a
|
Scott Ullrich
|
<td width="78%" class="listr">
|
158 |
9ebe7028
|
gnhb
|
<span id="uptime"><?=htmlspecialchars($ifinfo['ppp_uptime']);?></span><span id="uptime_hist"> (<?=htmlspecialchars($ifinfo['ppp_uptime_accumulated']);?>)</span>
|
159 |
8eb2f33a
|
Scott Ullrich
|
</td>
|
160 |
|
|
</tr>
|
161 |
0d7b21de
|
sullrich
|
<?php endif; if ($ifinfo['macaddr']): ?>
|
162 |
|
|
<tr>
|
163 |
|
|
<td width="22%" class="vncellt">MAC address</td>
|
164 |
|
|
<td width="78%" class="listr">
|
165 |
|
|
<?=htmlspecialchars($ifinfo['macaddr']);?>
|
166 |
|
|
</td>
|
167 |
|
|
</tr>
|
168 |
|
|
<?php endif; if ($ifinfo['status'] != "down"): ?>
|
169 |
|
|
<?php if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down"): ?>
|
170 |
|
|
<?php if ($ifinfo['ipaddr']): ?>
|
171 |
|
|
<tr>
|
172 |
|
|
<td width="22%" class="vncellt">IP address</td>
|
173 |
|
|
<td width="78%" class="listr">
|
174 |
|
|
<?=htmlspecialchars($ifinfo['ipaddr']);?>
|
175 |
|
|
|
176 |
|
|
</td>
|
177 |
|
|
</tr>
|
178 |
|
|
<?php endif; ?><?php if ($ifinfo['subnet']): ?>
|
179 |
|
|
<tr>
|
180 |
|
|
<td width="22%" class="vncellt">Subnet mask</td>
|
181 |
|
|
<td width="78%" class="listr">
|
182 |
|
|
<?=htmlspecialchars($ifinfo['subnet']);?>
|
183 |
|
|
</td>
|
184 |
|
|
</tr>
|
185 |
|
|
<?php endif; ?><?php if ($ifinfo['gateway']): ?>
|
186 |
|
|
<tr>
|
187 |
|
|
<td width="22%" class="vncellt">Gateway</td>
|
188 |
|
|
<td width="78%" class="listr">
|
189 |
dde9a4fc
|
Seth Mos
|
<?=htmlspecialchars($config['interfaces'][$ifdescr]['gateway']);?>
|
190 |
|
|
<?=htmlspecialchars($ifinfo['gateway']);?>
|
191 |
0d7b21de
|
sullrich
|
</td>
|
192 |
|
|
</tr>
|
193 |
|
|
<?php endif; if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): ?>
|
194 |
|
|
<tr>
|
195 |
|
|
<td width="22%" class="vncellt">ISP DNS servers</td>
|
196 |
|
|
<td width="78%" class="listr">
|
197 |
6205a304
|
Scott Ullrich
|
<?php
|
198 |
|
|
$dns_servers = get_dns_servers();
|
199 |
|
|
foreach($dns_servers as $dns) {
|
200 |
|
|
echo "{$dns}<br>";
|
201 |
f559eaf6
|
Scott Ullrich
|
}
|
202 |
6205a304
|
Scott Ullrich
|
?>
|
203 |
|
|
</td>
|
204 |
0d7b21de
|
sullrich
|
</tr>
|
205 |
|
|
<?php endif; endif; if ($ifinfo['media']): ?>
|
206 |
|
|
<tr>
|
207 |
|
|
<td width="22%" class="vncellt">Media</td>
|
208 |
|
|
<td width="78%" class="listr">
|
209 |
|
|
<?=htmlspecialchars($ifinfo['media']);?>
|
210 |
|
|
</td>
|
211 |
|
|
</tr>
|
212 |
|
|
<?php endif; ?><?php if ($ifinfo['channel']): ?>
|
213 |
|
|
<tr>
|
214 |
|
|
<td width="22%" class="vncellt">Channel</td>
|
215 |
|
|
<td width="78%" class="listr">
|
216 |
|
|
<?=htmlspecialchars($ifinfo['channel']);?>
|
217 |
|
|
</td>
|
218 |
|
|
</tr>
|
219 |
|
|
<?php endif; ?><?php if ($ifinfo['ssid']): ?>
|
220 |
|
|
<tr>
|
221 |
|
|
<td width="22%" class="vncellt">SSID</td>
|
222 |
|
|
<td width="78%" class="listr">
|
223 |
|
|
<?=htmlspecialchars($ifinfo['ssid']);?>
|
224 |
|
|
</td>
|
225 |
|
|
</tr>
|
226 |
|
|
<?php endif; ?><?php if ($ifinfo['bssid']): ?>
|
227 |
|
|
<tr>
|
228 |
|
|
<td width="22%" class="vncellt">BSSID</td>
|
229 |
|
|
<td width="78%" class="listr">
|
230 |
|
|
<?=htmlspecialchars($ifinfo['bssid']);?>
|
231 |
|
|
</td>
|
232 |
|
|
</tr>
|
233 |
|
|
<?php endif; ?><?php if ($ifinfo['rate']): ?>
|
234 |
|
|
<tr>
|
235 |
|
|
<td width="22%" class="vncellt">Rate</td>
|
236 |
|
|
<td width="78%" class="listr">
|
237 |
|
|
<?=htmlspecialchars($ifinfo['rate']);?>
|
238 |
|
|
</td>
|
239 |
|
|
</tr>
|
240 |
|
|
<?php endif; ?><?php if ($ifinfo['rssi']): ?>
|
241 |
|
|
<tr>
|
242 |
|
|
<td width="22%" class="vncellt">RSSI</td>
|
243 |
|
|
<td width="78%" class="listr">
|
244 |
|
|
<?=htmlspecialchars($ifinfo['rssi']);?>
|
245 |
|
|
</td>
|
246 |
|
|
</tr>
|
247 |
|
|
<?php endif; ?>
|
248 |
|
|
<tr>
|
249 |
|
|
<td width="22%" class="vncellt">In/out packets</td>
|
250 |
|
|
<td width="78%" class="listr">
|
251 |
|
|
<?php
|
252 |
|
|
echo htmlspecialchars($ifinfo['inpkts'] . "/" . $ifinfo['outpkts'] . " (");
|
253 |
|
|
echo htmlspecialchars(format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");
|
254 |
|
|
?>
|
255 |
|
|
</td>
|
256 |
|
|
</tr>
|
257 |
|
|
<tr>
|
258 |
|
|
<td width="22%" class="vncellt">In/out packets (pass)</td>
|
259 |
|
|
<td width="78%" class="listr">
|
260 |
|
|
<?php
|
261 |
|
|
echo htmlspecialchars($ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass'] . " (");
|
262 |
|
|
echo htmlspecialchars(format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
|
263 |
|
|
?>
|
264 |
|
|
</td>
|
265 |
|
|
</tr>
|
266 |
|
|
<tr>
|
267 |
|
|
<td width="22%" class="vncellt">In/out packets (block)</td>
|
268 |
|
|
<td width="78%" class="listr">
|
269 |
|
|
<?php
|
270 |
|
|
echo htmlspecialchars($ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock'] . " (");
|
271 |
|
|
echo htmlspecialchars(format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
|
272 |
|
|
?>
|
273 |
|
|
</td>
|
274 |
|
|
</tr>
|
275 |
|
|
<?php if (isset($ifinfo['inerrs'])): ?>
|
276 |
|
|
<tr>
|
277 |
|
|
<td width="22%" class="vncellt">In/out errors</td>
|
278 |
|
|
<td width="78%" class="listr">
|
279 |
|
|
<?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?>
|
280 |
|
|
</td>
|
281 |
|
|
</tr>
|
282 |
|
|
<?php endif; ?>
|
283 |
|
|
<?php if (isset($ifinfo['collisions'])): ?>
|
284 |
|
|
<tr>
|
285 |
|
|
<td width="22%" class="vncellt">Collisions</td>
|
286 |
|
|
<td width="78%" class="listr">
|
287 |
|
|
<?=htmlspecialchars($ifinfo['collisions']);?>
|
288 |
|
|
</td>
|
289 |
|
|
</tr>
|
290 |
|
|
<?php endif; ?>
|
291 |
|
|
<?php endif; ?>
|
292 |
|
|
<?php if ($ifinfo['bridge']): ?>
|
293 |
|
|
<tr>
|
294 |
|
|
<td width="22%" class="vncellt">Bridge (<?=$ifinfo['bridgeint']?>)</td>
|
295 |
|
|
<td width="78%" class="listr">
|
296 |
|
|
<?=$ifinfo['bridge'];?>
|
297 |
|
|
</td>
|
298 |
|
|
</tr>
|
299 |
|
|
<?php endif; ?>
|
300 |
|
|
<?php if(file_exists("/usr/bin/vmstat")): ?>
|
301 |
|
|
<?php
|
302 |
|
|
$real_interface = "";
|
303 |
|
|
$interrupt_total = "";
|
304 |
|
|
$interrupt_sec = "";
|
305 |
|
|
$real_interface = $ifinfo['hwif'];
|
306 |
|
|
$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
|
307 |
|
|
$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
|
308 |
|
|
if(strstr($interrupt_total, "hci")) {
|
309 |
|
|
$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
|
310 |
|
|
$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;
|
311 |
|
|
}
|
312 |
|
|
unset($interrupt_total); // XXX: FIX ME! Need a regex and parse correct data 100% of the time.
|
313 |
|
|
?>
|
314 |
|
|
<?php if($interrupt_total): ?>
|
315 |
|
|
<tr>
|
316 |
|
|
<td width="22%" class="vncellt">Interrupts/Second</td>
|
317 |
|
|
<td width="78%" class="listr">
|
318 |
|
|
<?php
|
319 |
|
|
echo $interrupt_total . " total";
|
320 |
|
|
echo "<br/>";
|
321 |
|
|
echo $interrupt_sec . " rate";
|
322 |
|
|
?>
|
323 |
|
|
</td>
|
324 |
|
|
</tr>
|
325 |
|
|
<?php endif; ?>
|
326 |
|
|
<?php endif; ?>
|
327 |
|
|
<?php $i++; endforeach; ?>
|
328 |
|
|
</table>
|
329 |
29ed06c9
|
Scott Ullrich
|
|
330 |
d290167c
|
Seth Mos
|
<br/>
|
331 |
0d7b21de
|
sullrich
|
|
332 |
c26e2cf0
|
Scott Ullrich
|
</strong>Using dial-on-demand will bring the connection up again if any packet
|
333 |
8cccee1c
|
Scott Ullrich
|
triggers it. To substantiate this point: disconnecting manually
|
334 |
c26e2cf0
|
Scott Ullrich
|
will <strong>not</strong> prevent dial-on-demand from making connections
|
335 |
f559eaf6
|
Scott Ullrich
|
to the outside! Don't use dial-on-demand if you want to make sure that the line
|
336 |
8c3e8725
|
Scott Ullrich
|
is kept disconnected.
|
337 |
71d9cd3d
|
Scott Ullrich
|
|
338 |
5b237745
|
Scott Ullrich
|
<?php include("fend.inc"); ?>
|