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
##|+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
if ($_GET['if']) {
46
	$interface = $_GET['if'];
47
	if ($_GET['action'] == "Disconnect" || $_GET['action'] == "Release") {
48
		interface_bring_down($interface);
49
	} else if ($_GET['action'] == "Connect" || $_GET['action'] == "Renew") {
50
		interface_configure($interface); 
51
	}
52
	header("Location: status_interfaces.php");
53
	exit;
54
}
55

    
56
$pgtitle = array("Status","Interfaces");
57
include("head.inc");
58

    
59
?>
60

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

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

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

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

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

    
275

    
276
<?php include("fend.inc"); ?>
(144-144/203)