Project

General

Profile

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

    
215
              <tr>
216
                <td width="22%" class="vncellt">In/out errors</td>
217
                <td width="78%" class="listr">
218
                  <?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?>
219
                </td>
220
              </tr><?php endif; ?><?php if (isset($ifinfo['collisions'])): ?>
221
              <tr>
222
                <td width="22%" class="vncellt">Collisions</td>
223
                <td width="78%" class="listr">
224
                  <?=htmlspecialchars($ifinfo['collisions']);?>
225
                </td>
226
              </tr><?php endif; ?>
227
	      <?php endif; ?>
228

    
229
		  <?php if ($ifinfo['bridge']): ?>
230
		  <tr>
231
		    <td width="22%" class="vncellt">Bridge (<?=$ifinfo['bridgeint']?>)</td>
232
		    <td width="78%" class="listr">
233
		      <?=$ifinfo['bridge'];?>
234
		    </td>
235
		  </tr>
236
		  <?php endif; ?>
237

    
238
	<?php if(file_exists("/usr/bin/vmstat")): ?>
239
	<?php
240
			$real_interface = "";
241
			$interrupt_total = "";
242
			$interrupt_sec = "";
243
			$real_interface = $ifinfo['hwif'];
244
		/* XXX for virtual interfaces this are not the most accurate stats! */
245
          	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
246
          	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
247
          	if(strstr($interrupt_total, "hci")) {
248
    	      	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
249
	          	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;          	
250
          	}
251
			unset($interrupt_total); // XXX: FIX ME!  Need a regex and parse correct data 100% of the time.
252
	?>
253
	<?php if($interrupt_total): ?>
254
     <tr>
255
        <td width="22%" class="vncellt">Interrupts/Second</td>
256
        <td width="78%" class="listr">
257
          <?php
258

    
259
          	echo $interrupt_total . " total";
260
          	echo "<br/>";
261
          	echo $interrupt_sec . " rate";
262
          ?>
263
        </td>
264
      </tr>
265
     <?php endif; ?>
266
	<?php endif; ?>
267
	
268
              <?php $i++; endforeach; ?>
269
            </table>
270
<br/>
271
</strong>Using dial-on-demand will bring the connection up again if any packet
272
triggers it. To substantiate this point: disconnecting manually
273
will <strong>not</strong> prevent dial-on-demand from making connections
274
to the outside! Don't use dial-on-demand if you want to make sure that the line
275
is kept disconnected.
276

    
277

    
278
<?php include("fend.inc"); ?>
(157-157/217)