Project

General

Profile

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