Project

General

Profile

Download (10.2 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	status_interfaces.php
5
        part of pfSense
6
	Copyright (C) 2005 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
##|+PRIV
36
##|*IDENT=page-status-interfaces
37
##|*NAME=Status: Interfaces page
38
##|*DESCR=Allow access to the 'Status: Interfaces' page.
39
##|*MATCH=status_interfaces.php*
40
##|-PRIV
41

    
42

    
43
require_once("guiconfig.inc");
44

    
45
$wancfg = &$config['interfaces']['wan'];
46

    
47
if ($_POST) {
48
	$interface = $_POST['interface'];
49
	$ifcfg = &$config['interfaces'][$interface];
50
	if ($_POST['submit'] == "Disconnect" || $_POST['submit'] == "Release") {
51
		if ($ifcfg['ipaddr'] == "dhcp")
52
			interfaces_dhcp_down($interface);
53
		else if ($ifcfg['ipaddr'] == "pppoe")
54
			interfaces_wan_pppoe_down($interface); 
55
		else if ($ifcfg['ipaddr'] == "pptp")
56
			interfaces_wan_pptp_down($interface); 
57
	} else if ($_POST['submit'] == "Connect" || $_POST['submit'] == "Renew") {
58
		if ($ifcfg['ipaddr'] == "dhcp")
59
			interfaces_dhcp_up($interface);
60
		else if ($ifcfg['ipaddr'] == "pppoe")
61
			interfaces_wan_pppoe_up($interface); 
62
		else if ($ifcfg['ipaddr'] == "pptp")
63
			interfaces_wan_pptp_up($interface); 
64
	} else {
65
		header("Location: index.php");
66
		exit;
67
	}
68
}
69

    
70
$pgtitle = array("Status","Interfaces");
71
include("head.inc");
72

    
73
?>
74

    
75
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
76
<?php include("fbegin.inc"); ?>
77
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
78
              <?php $ifdescrs = get_configured_interface_with_descr(false, true);
79
		foreach ($ifdescrs as $ifdescr => $ifname):
80
			$ifinfo = get_interface_info($ifdescr);
81
		?>
82
		<form action="status_interfaces.php" method="post">
83
		<input type="hidden" name="interface" value="<?php echo $ifdescr; ?>">
84
              <?php if ($i): ?>
85
              <tr>
86
			<td colspan="8" class="list" height="12"></td>
87
			</tr>
88
			<?php endif; ?>
89
              <tr>
90
                <td colspan="2" class="listtopic">
91
                  <?=htmlspecialchars($ifname);?>
92
				  interface
93
				  (<?=($ifinfo['hwif']);?>)
94
				</td>
95
              </tr>
96
              <tr>
97
                <td width="22%" class="vncellt">Status</td>
98
                <td width="78%" class="listr">
99
                  <?=htmlspecialchars($ifinfo['status']);?>
100
                </td>
101
              </tr><?php if ($ifinfo['dhcplink']): ?>
102
			  <tr>
103
				<td width="22%" class="vncellt">DHCP</td>
104
				<td width="78%" class="listr">
105
				  <?=htmlspecialchars($ifinfo['dhcplink']);?>&nbsp;&nbsp;
106
				  <?php if ($ifinfo['dhcplink'] == "up"): ?>
107
				  <input type="submit" name="submit" value="Release" class="formbtns">
108
				  <?php else: ?>
109
				  <input type="submit" name="submit" value="Renew" class="formbtns">
110
				  <?php endif; ?>
111
				</td>
112
			  </tr><?php endif; if ($ifinfo['pppoelink']): ?>
113
              <tr>
114
                <td width="22%" class="vncellt">PPPoE</td>
115
                <td width="78%" class="listr">
116
                  <?=htmlspecialchars($ifinfo['pppoelink']);?>&nbsp;&nbsp;
117
				  <?php if ($ifinfo['pppoelink'] == "up"): ?>
118
				  <input type="submit" name="submit" value="Disconnect" class="formbtns">
119
				  <?php else: ?>
120
				  <input type="submit" name="submit" value="Connect" class="formbtns">
121
				  <?php endif; ?>
122
                </td>
123
              </tr><?php  endif; if ($ifinfo['pptplink']): ?>
124
              <tr>
125
                <td width="22%" class="vncellt">PPTP</td>
126
                <td width="78%" class="listr">
127
                  <?=htmlspecialchars($ifinfo['pptplink']);?>&nbsp;&nbsp;
128
				  <?php if ($ifinfo['pptplink'] == "up"): ?>
129
				  <input type="submit" name="submit" value="Disconnect" class="formbtns">
130
				  <?php else: ?>
131
				  <input type="submit" name="submit" value="Connect" class="formbtns">
132
				  <?php endif; ?>
133
                </td>
134
              </tr><?php  endif; if ($ifinfo['macaddr']): ?>
135
              <tr>
136
                <td width="22%" class="vncellt">MAC address</td>
137
                <td width="78%" class="listr">
138
                  <?=htmlspecialchars($ifinfo['macaddr']);?>
139
                </td>
140
              </tr>
141
	      </form>
142
		<?php endif; if ($ifinfo['status'] != "down"): ?>
143
			  <?php if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down"): ?>
144
			  <?php if ($ifinfo['ipaddr']): ?>
145
              <tr>
146
                <td width="22%" class="vncellt">IP address</td>
147
                <td width="78%" class="listr">
148
                  <?=htmlspecialchars($ifinfo['ipaddr']);?>
149
                  &nbsp; </td>
150
              </tr><?php endif; ?><?php if ($ifinfo['subnet']): ?>
151
              <tr>
152
                <td width="22%" class="vncellt">Subnet mask</td>
153
                <td width="78%" class="listr">
154
                  <?=htmlspecialchars($ifinfo['subnet']);?>
155
                </td>
156
              </tr><?php endif; ?><?php if ($ifinfo['gateway']): ?>
157
              <tr>
158
                <td width="22%" class="vncellt">Gateway</td>
159
                <td width="78%" class="listr">
160
			<?=htmlspecialchars($config['interfaces'][$ifdescr]['gateway']);?>
161
			<?=htmlspecialchars($ifinfo['gateway']);?>
162
			<?php /* FIXME: possibly show gateway status and if it is the default route */ ?>
163
                </td>
164
              </tr><?php endif; if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): ?>
165
                <td width="22%" class="vncellt">ISP DNS servers</td>
166
                <td width="78%" class="listr">
167
		<?php
168
			$dns_servers = get_dns_servers();
169
			foreach($dns_servers as $dns) {
170
				echo "{$dns}<br>";
171
			}
172
		?>
173
		</td>
174
			  <?php endif; endif; if ($ifinfo['media']): ?>
175
              <tr>
176
                <td width="22%" class="vncellt">Media</td>
177
                <td width="78%" class="listr">
178
                  <?=htmlspecialchars($ifinfo['media']);?>
179
                </td>
180
              </tr><?php endif; ?><?php if ($ifinfo['channel']): ?>
181
              <tr>
182
                <td width="22%" class="vncellt">Channel</td>
183
                <td width="78%" class="listr">
184
                  <?=htmlspecialchars($ifinfo['channel']);?>
185
                </td>
186
              </tr><?php endif; ?><?php if ($ifinfo['ssid']): ?>
187
              <tr>
188
                <td width="22%" class="vncellt">SSID</td>
189
                <td width="78%" class="listr">
190
                  <?=htmlspecialchars($ifinfo['ssid']);?>
191
                </td>
192
              </tr><?php endif; ?>
193
              <tr>
194
                <td width="22%" class="vncellt">In/out packets</td>
195
                <td width="78%" class="listr">
196
                  <?=htmlspecialchars($ifinfo['inpkts'] . "/" . $ifinfo['outpkts'] . " (" .
197
			format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");?>
198
                </td>
199
              </tr><?php if (isset($ifinfo['inerrs'])): ?>
200
              <tr>
201
                <td width="22%" class="vncellt">In/out errors</td>
202
                <td width="78%" class="listr">
203
                  <?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?>
204
                </td>
205
              </tr><?php endif; ?><?php if (isset($ifinfo['collisions'])): ?>
206
              <tr>
207
                <td width="22%" class="vncellt">Collisions</td>
208
                <td width="78%" class="listr">
209
                  <?=htmlspecialchars($ifinfo['collisions']);?>
210
                </td>
211
              </tr><?php endif; ?>
212
	      <?php endif; ?>
213

    
214
		  <?php if ($ifinfo['bridge']): ?>
215
		  <tr>
216
		    <td width="22%" class="vncellt">Bridge (<?=$ifinfo['bridgeint']?>)</td>
217
		    <td width="78%" class="listr">
218
		      <?=$ifinfo['bridge'];?>
219
		    </td>
220
		  </tr>
221
		  <?php endif; ?>
222

    
223
	<?php if(file_exists("/usr/bin/vmstat")): ?>
224
	<?php
225
			$real_interface = "";
226
			$interrupt_total = "";
227
			$interrupt_sec = "";
228
			$real_interface = $ifinfo['hwif'];
229
          	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
230
          	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
231
          	if(strstr($interrupt_total, "hci")) {
232
    	      	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
233
	          	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;          	
234
          	}
235
			unset($interrupt_total); // XXX: FIX ME!  Need a regex and parse correct data 100% of the time.
236
	?>
237
	<?php if($interrupt_total): ?>
238
     <tr>
239
        <td width="22%" class="vncellt">Interrupts/Second</td>
240
        <td width="78%" class="listr">
241
          <?php
242

    
243
          	echo $interrupt_total . " total";
244
          	echo "<br/>";
245
          	echo $interrupt_sec . " rate";
246
          ?>
247
        </td>
248
      </tr>
249
     <?php endif; ?>
250
	<?php endif; ?>
251
	
252
              <?php $i++; endforeach; ?>
253
            </table>
254
<br/>
255
</strong>Using dial-on-demand will bring the connection up again if any packet
256
triggers it. To substantiate this point: disconnecting manually
257
will <strong>not</strong> prevent dial-on-demand from making connections
258
to the outside! Don't use dial-on-demand if you want to make sure that the line
259
is kept disconnected.
260
<p>
261
<span class="red"><strong>Note:</strong></span> In/out counters will wrap at 32bit (4 Gigabyte) ! <br/>
262

    
263
<?php include("fend.inc"); ?>
(153-153/211)