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
require_once("guiconfig.inc");
36

    
37
$wancfg = &$config['interfaces']['wan'];
38

    
39
if ($_POST) {
40
	$interface = $_POST['interface'];
41
	$ifcfg = &$config['interfaces'][$interface];
42
	if ($_POST['submit'] == "Disconnect" || $_POST['submit'] == "Release") {
43
		if ($ifcfg['ipaddr'] == "dhcp")
44
			interfaces_dhcp_down($interface);
45
		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
	} else if ($_POST['submit'] == "Connect" || $_POST['submit'] == "Renew") {
50
		if ($ifcfg['ipaddr'] == "dhcp")
51
			interfaces_dhcp_up($interface);
52
		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
	} else {
57
		header("Location: index.php");
58
		exit;
59
	}
60
}
61

    
62
$pgtitle = "Status: Interfaces";
63
include("head.inc");
64

    
65
?>
66

    
67
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
68
<?php include("fbegin.inc"); ?>
69
<p class="pgtitle"><?=$pgtitle?></p>
70
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
71
              <?php $i = 0; $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
72
		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
		<form action="status_interfaces.php" method="post">
79
		<input type="hidden" name="interface" value="<?php echo $ifdescr; ?>">
80
              <?php if ($i): ?>
81
              <tr>
82
			<td colspan="8" class="list" height="12"></td>
83
			</tr>
84
			<?php endif; ?>
85
              <tr>
86
                <td colspan="2" class="listtopic">
87
                  <?=htmlspecialchars($ifname);?>
88
				  interface
89
				  (<?=convert_friendly_interface_to_real_interface_name($ifname);?>)
90
				</td>
91
              </tr>
92
              <tr>
93
                <td width="22%" class="vncellt">Status</td>
94
                <td width="78%" class="listr">
95
                  <?=htmlspecialchars($ifinfo['status']);?>
96
                </td>
97
              </tr><?php if ($ifinfo['dhcplink']): ?>
98
			  <tr>
99
				<td width="22%" class="vncellt">DHCP</td>
100
				<td width="78%" class="listr">
101
				  <?=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
              <tr>
110
                <td width="22%" class="vncellt">PPPoE</td>
111
                <td width="78%" class="listr">
112
                  <?=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
                </td>
119
              </tr><?php  endif; if ($ifinfo['pptplink']): ?>
120
              <tr>
121
                <td width="22%" class="vncellt">PPTP</td>
122
                <td width="78%" class="listr">
123
                  <?=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
                </td>
130
              </tr><?php  endif; if ($ifinfo['macaddr']): ?>
131
              <tr>
132
                <td width="22%" class="vncellt">MAC address</td>
133
                <td width="78%" class="listr">
134
                  <?=htmlspecialchars($ifinfo['macaddr']);?>
135
                </td>
136
              </tr>
137
	      </form>
138
		<?php endif; if ($ifinfo['status'] != "down"): ?>
139
			  <?php if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down"): ?>
140
			  <?php if ($ifinfo['ipaddr']): ?>
141
              <tr>
142
                <td width="22%" class="vncellt">IP address</td>
143
                <td width="78%" class="listr">
144
                  <?=htmlspecialchars($ifinfo['ipaddr']);?>
145
                  &nbsp; </td>
146
              </tr><?php endif; ?><?php if ($ifinfo['subnet']): ?>
147
              <tr>
148
                <td width="22%" class="vncellt">Subnet mask</td>
149
                <td width="78%" class="listr">
150
                  <?=htmlspecialchars($ifinfo['subnet']);?>
151
                </td>
152
              </tr><?php endif; ?><?php if ($ifinfo['gateway']): ?>
153
              <tr>
154
                <td width="22%" class="vncellt">Gateway</td>
155
                <td width="78%" class="listr">
156
                  <?=htmlspecialchars($ifinfo['gateway']);?>
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
                  <?=htmlspecialchars($ifinfo['inpkts'] . "/" . $ifinfo['outpkts'] . " (" .
191
			format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");?>
192
                </td>
193
              </tr><?php if (isset($ifinfo['inerrs'])): ?>
194
              <tr>
195
                <td width="22%" class="vncellt">In/out errors</td>
196
                <td width="78%" class="listr">
197
                  <?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?>
198
                </td>
199
              </tr><?php endif; ?><?php if (isset($ifinfo['collisions'])): ?>
200
              <tr>
201
                <td width="22%" class="vncellt">Collisions</td>
202
                <td width="78%" class="listr">
203
                  <?=htmlspecialchars($ifinfo['collisions']);?>
204
                </td>
205
              </tr><?php endif; ?>
206
	      <?php endif; ?>
207

    
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
	<?php if(file_exists("/usr/bin/vmstat")): ?>
218
	<?php
219
			$real_interface = "";
220
			$interrupt_total = "";
221
			$interrupt_sec = "";
222
			$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
          	if(strstr($interrupt_total, "hci")) {
226
    	      	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
227
	          	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;          	
228
          	}	
229
          	$interrupt_total = "";
230
	?>
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
          	echo $interrupt_total . " total";
238
          	echo "<br/>";
239
          	echo $interrupt_sec . " rate";
240
          ?>
241
        </td>
242
      </tr>
243
     <?php endif; ?>
244
	<?php endif; ?>
245
	
246
              <?php $i++; endforeach; ?>
247
            </table>
248
<br/>
249
</strong>Using dial-on-demand will bring the connection up again if any packet
250
triggers it. To substantiate this point: disconnecting manually
251
will <strong>not</strong> prevent dial-on-demand from making connections
252
to the outside! Don't use dial-on-demand if you want to make sure that the line
253
is kept disconnected.
254
<p>
255
<span class="red"><strong>Note:</strong></span> In/out counters will wrap at 32bit (4 Gigabyte) ! <br/>
256

    
257
<?php include("fend.inc"); ?>
(126-126/173)