Project

General

Profile

Download (10.1 KB) Statistics
| Branch: | Tag: | Revision:
1 8cccee1c Scott Ullrich
<?php
2 2bdf4a03 Scott Ullrich
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	status_interfaces.php
5 8c3e8725 Scott Ullrich
        part of pfSense
6
	Copyright (C) 2005 Scott Ullrich <sullrich@gmail.com>.
7
	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
35 51caa77a Scott Ullrich
require_once("guiconfig.inc");
36 5b237745 Scott Ullrich
37 c26e2cf0 Scott Ullrich
$wancfg = &$config['interfaces']['wan'];
38
39
if ($_POST) {
40 b99895fe Bill Marquette
	$interface = $_POST['interface'];
41
	$ifcfg = &$config['interfaces'][$interface];
42 c26e2cf0 Scott Ullrich
	if ($_POST['submit'] == "Disconnect" || $_POST['submit'] == "Release") {
43 b99895fe Bill Marquette
		if ($ifcfg['ipaddr'] == "dhcp")
44 a8826fb4 Scott Ullrich
			interfaces_dhcp_down($interface);
45 b99895fe Bill Marquette
		else if ($ifcfg['ipaddr'] == "pppoe")
46
			interfaces_wan_pppoe_down(); // FIXME: when we support multi-pppoe
47
		else if ($ifcfg['ipaddr'] == "pptp")
48
			interfaces_wan_pptp_down(); // FIXME: when we support multi-pptp
49 c26e2cf0 Scott Ullrich
	} else if ($_POST['submit'] == "Connect" || $_POST['submit'] == "Renew") {
50 b99895fe Bill Marquette
		if ($ifcfg['ipaddr'] == "dhcp")
51 a8826fb4 Scott Ullrich
			interfaces_dhcp_up($interface);
52 b99895fe Bill Marquette
		else if ($ifcfg['ipaddr'] == "pppoe")
53
			interfaces_wan_pppoe_up(); // FIXME: when we support multi-pppoe
54
		else if ($ifcfg['ipaddr'] == "pptp")
55
			interfaces_wan_pptp_up(); // FIXME: when we support multi-pptp
56 c26e2cf0 Scott Ullrich
	} else {
57
		header("Location: index.php");
58
		exit;
59
	}
60
}
61
62 d88c6a9f Scott Ullrich
$pgtitle = array("Status","Interfaces");
63 4df96eff Scott Ullrich
include("head.inc");
64
65 5b237745 Scott Ullrich
?>
66 8cccee1c Scott Ullrich
67
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
68 5b237745 Scott Ullrich
<?php include("fbegin.inc"); ?>
69
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
70
              <?php $i = 0; $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
71 51caa77a Scott Ullrich
		for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
72
			$ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
73
		}
74
		foreach ($ifdescrs as $ifdescr => $ifname):
75
			$ifinfo = get_interface_info($ifdescr);
76
		?>
77 fae80dfc Scott Ullrich
		<form action="status_interfaces.php" method="post">
78 312536e5 Scott Ullrich
		<input type="hidden" name="interface" value="<?php echo $ifdescr; ?>">
79 5b237745 Scott Ullrich
              <?php if ($i): ?>
80
              <tr>
81 51caa77a Scott Ullrich
			<td colspan="8" class="list" height="12"></td>
82
			</tr>
83
			<?php endif; ?>
84 8cccee1c Scott Ullrich
              <tr>
85
                <td colspan="2" class="listtopic">
86 5b237745 Scott Ullrich
                  <?=htmlspecialchars($ifname);?>
87 f559eaf6 Scott Ullrich
				  interface
88
				  (<?=convert_friendly_interface_to_real_interface_name($ifname);?>)
89 97593aa4 Scott Ullrich
				</td>
90 5b237745 Scott Ullrich
              </tr>
91 8cccee1c Scott Ullrich
              <tr>
92 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">Status</td>
93 8cccee1c Scott Ullrich
                <td width="78%" class="listr">
94 5b237745 Scott Ullrich
                  <?=htmlspecialchars($ifinfo['status']);?>
95
                </td>
96 c26e2cf0 Scott Ullrich
              </tr><?php if ($ifinfo['dhcplink']): ?>
97 8cccee1c Scott Ullrich
			  <tr>
98 c26e2cf0 Scott Ullrich
				<td width="22%" class="vncellt">DHCP</td>
99 8cccee1c Scott Ullrich
				<td width="78%" class="listr">
100 c26e2cf0 Scott Ullrich
				  <?=htmlspecialchars($ifinfo['dhcplink']);?>&nbsp;&nbsp;
101
				  <?php if ($ifinfo['dhcplink'] == "up"): ?>
102
				  <input type="submit" name="submit" value="Release" class="formbtns">
103
				  <?php else: ?>
104
				  <input type="submit" name="submit" value="Renew" class="formbtns">
105
				  <?php endif; ?>
106
				</td>
107
			  </tr><?php endif; if ($ifinfo['pppoelink']): ?>
108 8cccee1c Scott Ullrich
              <tr>
109 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">PPPoE</td>
110 8cccee1c Scott Ullrich
                <td width="78%" class="listr">
111 c26e2cf0 Scott Ullrich
                  <?=htmlspecialchars($ifinfo['pppoelink']);?>&nbsp;&nbsp;
112
				  <?php if ($ifinfo['pppoelink'] == "up"): ?>
113
				  <input type="submit" name="submit" value="Disconnect" class="formbtns">
114
				  <?php else: ?>
115
				  <input type="submit" name="submit" value="Connect" class="formbtns">
116
				  <?php endif; ?>
117 5b237745 Scott Ullrich
                </td>
118
              </tr><?php  endif; if ($ifinfo['pptplink']): ?>
119 8cccee1c Scott Ullrich
              <tr>
120 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">PPTP</td>
121 8cccee1c Scott Ullrich
                <td width="78%" class="listr">
122 c26e2cf0 Scott Ullrich
                  <?=htmlspecialchars($ifinfo['pptplink']);?>&nbsp;&nbsp;
123
				  <?php if ($ifinfo['pptplink'] == "up"): ?>
124
				  <input type="submit" name="submit" value="Disconnect" class="formbtns">
125
				  <?php else: ?>
126
				  <input type="submit" name="submit" value="Connect" class="formbtns">
127
				  <?php endif; ?>
128 5b237745 Scott Ullrich
                </td>
129
              </tr><?php  endif; if ($ifinfo['macaddr']): ?>
130 8cccee1c Scott Ullrich
              <tr>
131 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">MAC address</td>
132 8cccee1c Scott Ullrich
                <td width="78%" class="listr">
133 5b237745 Scott Ullrich
                  <?=htmlspecialchars($ifinfo['macaddr']);?>
134
                </td>
135 a8826fb4 Scott Ullrich
              </tr>
136
	      </form>
137
		<?php endif; if ($ifinfo['status'] != "down"): ?>
138 c26e2cf0 Scott Ullrich
			  <?php if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down"): ?>
139 5b237745 Scott Ullrich
			  <?php if ($ifinfo['ipaddr']): ?>
140 8cccee1c Scott Ullrich
              <tr>
141 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">IP address</td>
142 8cccee1c Scott Ullrich
                <td width="78%" class="listr">
143 5b237745 Scott Ullrich
                  <?=htmlspecialchars($ifinfo['ipaddr']);?>
144
                  &nbsp; </td>
145
              </tr><?php endif; ?><?php if ($ifinfo['subnet']): ?>
146 8cccee1c Scott Ullrich
              <tr>
147 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">Subnet mask</td>
148 8cccee1c Scott Ullrich
                <td width="78%" class="listr">
149 5b237745 Scott Ullrich
                  <?=htmlspecialchars($ifinfo['subnet']);?>
150
                </td>
151
              </tr><?php endif; ?><?php if ($ifinfo['gateway']): ?>
152 8cccee1c Scott Ullrich
              <tr>
153 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">Gateway</td>
154 8cccee1c Scott Ullrich
                <td width="78%" class="listr">
155 5b237745 Scott Ullrich
                  <?=htmlspecialchars($ifinfo['gateway']);?>
156
                </td>
157 c394a5d1 Scott Ullrich
              </tr><?php endif; if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): ?>
158 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">ISP DNS servers</td>
159 6205a304 Scott Ullrich
                <td width="78%" class="listr">
160
		<?php
161
			$dns_servers = get_dns_servers();
162
			foreach($dns_servers as $dns) {
163
				echo "{$dns}<br>";
164 f559eaf6 Scott Ullrich
			}
165 6205a304 Scott Ullrich
		?>
166
		</td>
167 c26e2cf0 Scott Ullrich
			  <?php endif; endif; if ($ifinfo['media']): ?>
168 8cccee1c Scott Ullrich
              <tr>
169 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">Media</td>
170 8cccee1c Scott Ullrich
                <td width="78%" class="listr">
171 5b237745 Scott Ullrich
                  <?=htmlspecialchars($ifinfo['media']);?>
172
                </td>
173
              </tr><?php endif; ?><?php if ($ifinfo['channel']): ?>
174 8cccee1c Scott Ullrich
              <tr>
175 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">Channel</td>
176 8cccee1c Scott Ullrich
                <td width="78%" class="listr">
177 5b237745 Scott Ullrich
                  <?=htmlspecialchars($ifinfo['channel']);?>
178
                </td>
179
              </tr><?php endif; ?><?php if ($ifinfo['ssid']): ?>
180 8cccee1c Scott Ullrich
              <tr>
181 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">SSID</td>
182 8cccee1c Scott Ullrich
                <td width="78%" class="listr">
183 5b237745 Scott Ullrich
                  <?=htmlspecialchars($ifinfo['ssid']);?>
184
                </td>
185
              </tr><?php endif; ?>
186 8cccee1c Scott Ullrich
              <tr>
187 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">In/out packets</td>
188 8cccee1c Scott Ullrich
                <td width="78%" class="listr">
189
                  <?=htmlspecialchars($ifinfo['inpkts'] . "/" . $ifinfo['outpkts'] . " (" .
190 8c3e8725 Scott Ullrich
			format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");?>
191 5b237745 Scott Ullrich
                </td>
192
              </tr><?php if (isset($ifinfo['inerrs'])): ?>
193 8cccee1c Scott Ullrich
              <tr>
194 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">In/out errors</td>
195 8cccee1c Scott Ullrich
                <td width="78%" class="listr">
196 5b237745 Scott Ullrich
                  <?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?>
197
                </td>
198
              </tr><?php endif; ?><?php if (isset($ifinfo['collisions'])): ?>
199 8cccee1c Scott Ullrich
              <tr>
200 c26e2cf0 Scott Ullrich
                <td width="22%" class="vncellt">Collisions</td>
201 8cccee1c Scott Ullrich
                <td width="78%" class="listr">
202 5b237745 Scott Ullrich
                  <?=htmlspecialchars($ifinfo['collisions']);?>
203
                </td>
204
              </tr><?php endif; ?>
205
	      <?php endif; ?>
206 0529547c Scott Ullrich
207
		  <?php if ($ifinfo['bridge']): ?>
208
		  <tr>
209
		    <td width="22%" class="vncellt">Bridge (<?=$ifinfo['bridgeint']?>)</td>
210
		    <td width="78%" class="listr">
211
		      <?=$ifinfo['bridge'];?>
212
		    </td>
213
		  </tr>
214
		  <?php endif; ?>
215
216 6f7fb5c9 Scott Ullrich
	<?php if(file_exists("/usr/bin/vmstat")): ?>
217 29ed06c9 Scott Ullrich
	<?php
218 aa8f9947 Scott Ullrich
			$real_interface = "";
219
			$interrupt_total = "";
220
			$interrupt_sec = "";
221 6f7fb5c9 Scott Ullrich
			$real_interface = convert_friendly_interface_to_real_interface_name($ifname);
222
          	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
223
          	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
224 29ed06c9 Scott Ullrich
          	if(strstr($interrupt_total, "hci")) {
225 12bade7c Scott Ullrich
    	      	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
226
	          	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;          	
227 29ed06c9 Scott Ullrich
          	}	
228
	?>
229
	<?php if($interrupt_total): ?>
230
     <tr>
231
        <td width="22%" class="vncellt">Interrupts/Second</td>
232
        <td width="78%" class="listr">
233
          <?php
234
235 6f7fb5c9 Scott Ullrich
          	echo $interrupt_total . " total";
236
          	echo "<br/>";
237
          	echo $interrupt_sec . " rate";
238
          ?>
239
        </td>
240
      </tr>
241 29ed06c9 Scott Ullrich
     <?php endif; ?>
242 6f7fb5c9 Scott Ullrich
	<?php endif; ?>
243
	
244 5b237745 Scott Ullrich
              <?php $i++; endforeach; ?>
245
            </table>
246 d290167c Seth Mos
<br/>
247 c26e2cf0 Scott Ullrich
</strong>Using dial-on-demand will bring the connection up again if any packet
248 8cccee1c Scott Ullrich
triggers it. To substantiate this point: disconnecting manually
249 c26e2cf0 Scott Ullrich
will <strong>not</strong> prevent dial-on-demand from making connections
250 f559eaf6 Scott Ullrich
to the outside! Don't use dial-on-demand if you want to make sure that the line
251 8c3e8725 Scott Ullrich
is kept disconnected.
252 eb9b9c5c Scott Ullrich
<p>
253 987fe4ba Scott Ullrich
<span class="red"><strong>Note:</strong></span> In/out counters will wrap at 32bit (4 Gigabyte) ! <br/>
254 20d1251d Scott Ullrich
255 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>