Project

General

Profile

Download (5.25 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
<?php
2
/*
3
	diag_ping.php
4 5543b9ed Scott Ullrich
	part of m0n0wall (http://m0n0.ch/wall)
5 5b237745 Scott Ullrich
6 5543b9ed Scott Ullrich
	Copyright (C) 2003-2005 Bob Zoller (bob@kludgebox.com) and Manuel Kasper <mk@neon1.net>.
7 5b237745 Scott Ullrich
	All rights reserved.
8
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11
12
	1. Redistributions of source code must retain the above copyright notice,
13
	this list of conditions and the following disclaimer.
14
15
	2. Redistributions in binary form must reproduce the above copyright
16
	notice, this list of conditions and the following disclaimer in the
17
	documentation and/or other materials provided with the distribution.
18
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31 13d193c2 Scott Ullrich
/*	
32 8bea9639 Seth Mos
	pfSense_BUILDER_BINARIES:	/sbin/ping /sbin/ping6
33 13d193c2 Scott Ullrich
	pfSense_MODULE:	routing
34
*/
35
36 6b07c15a Matthew Grooms
##|+PRIV
37
##|*IDENT=page-diagnostics-ping
38
##|*NAME=Diagnostics: Ping page
39
##|*DESCR=Allow access to the 'Diagnostics: Ping' page.
40
##|*MATCH=diag_ping.php*
41
##|-PRIV
42
43 36678039 Carlos Eduardo Ramos
$pgtitle = array(gettext("Diagnostics"), gettext("Ping"));
44 5b237745 Scott Ullrich
require("guiconfig.inc");
45
46
define('MAX_COUNT', 10);
47
define('DEFAULT_COUNT', 3);
48
49 b8cc74ed sullrich
if ($_POST || $_REQUEST['host']) {
50 5b237745 Scott Ullrich
	unset($input_errors);
51
	unset($do_ping);
52
53
	/* input validation */
54
	$reqdfields = explode(" ", "host count");
55 9d8eeb2f Vinicius Coque
	$reqdfieldsn = array(gettext("Host"),gettext("Count"));
56 b8cc74ed sullrich
	do_input_validation($_REQUEST, $reqdfields, $reqdfieldsn, &$input_errors);
57 5b237745 Scott Ullrich
58 b8cc74ed sullrich
	if (($_REQUEST['count'] < 1) || ($_REQUEST['count'] > MAX_COUNT)) {
59 4a5430e3 cadu
		$input_errors[] = sprintf(gettext("Count must be between 1 and %s"), MAX_COUNT);
60 5b237745 Scott Ullrich
	}
61
62
	if (!$input_errors) {
63
		$do_ping = true;
64 8bea9639 Seth Mos
		$host = $_REQUEST['host'];
65 b8cc74ed sullrich
		$interface = $_REQUEST['interface'];
66 61ba386b Scott Ullrich
		$count = $_POST['count'];
67 3a134b53 Erik Fonnesbeck
		if (preg_match('/[^0-9]/', $count) )
68
			$count = DEFAULT_COUNT;
69 5b237745 Scott Ullrich
	}
70
}
71
if (!isset($do_ping)) {
72
	$do_ping = false;
73
	$host = '';
74
	$count = DEFAULT_COUNT;
75
}
76 b63695db Scott Ullrich
77 aad0ec36 Bill Marquette
include("head.inc"); ?>
78
<body link="#000000" vlink="#000000" alink="#000000">
79
<? include("fbegin.inc"); ?>
80
<table width="100%" border="0" cellpadding="0" cellspacing="0">
81
        <tr>
82
                <td>
83 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
84
			<form action="diag_ping.php" method="post" name="iform" id="iform">
85
			  <table width="100%" border="0" cellpadding="6" cellspacing="0">
86 0cece4a2 Scott Ullrich
				<tr>
87 36678039 Carlos Eduardo Ramos
					<td colspan="2" valign="top" class="listtopic"><?=gettext("Ping"); ?></td>
88 0cece4a2 Scott Ullrich
				</tr>
89 5b237745 Scott Ullrich
                <tr>
90 36678039 Carlos Eduardo Ramos
				  <td width="22%" valign="top" class="vncellreq"><?=gettext("Host"); ?></td>
91 5543b9ed Scott Ullrich
				  <td width="78%" class="vtable"> 
92
                    <?=$mandfldhtml;?><input name="host" type="text" class="formfld" id="host" size="20" value="<?=htmlspecialchars($host);?>"></td>
93
				</tr>
94
				<tr>
95 fda82f52 Carlos Eduardo Ramos
				  <td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
96 4d875b4f Scott Ullrich
				  <td width="78%" class="vtable">
97 5543b9ed Scott Ullrich
				  <select name="interface" class="formfld">
98 cbe3ea96 Ermal Luçi
                      <?php $interfaces = get_configured_interface_with_descr();
99 5543b9ed Scott Ullrich
					  foreach ($interfaces as $iface => $ifacename): ?>
100 7ec05d27 Ermal Luçi
                      <option value="<?=$iface;?>" <?php if (!link_interface_to_bridge($iface) && $iface == $interface) echo "selected"; ?>> 
101 5543b9ed Scott Ullrich
                      <?=htmlspecialchars($ifacename);?>
102
                      </option>
103
                      <?php endforeach; ?>
104
                    </select>
105
				  </td>
106 5b237745 Scott Ullrich
				</tr>
107
				<tr>
108 4a5430e3 cadu
				  <td width="22%" valign="top" class="vncellreq"><?= gettext("Count"); ?></td>
109 5b237745 Scott Ullrich
				  <td width="78%" class="vtable">
110 5543b9ed Scott Ullrich
					<select name="count" class="formfld" id="count">
111 5b237745 Scott Ullrich
					<?php for ($i = 1; $i <= MAX_COUNT; $i++): ?>
112
					<option value="<?=$i;?>" <?php if ($i == $count) echo "selected"; ?>><?=$i;?></option>
113
					<?php endfor; ?>
114
					</select></td>
115
				</tr>
116
				<tr>
117
				  <td width="22%" valign="top">&nbsp;</td>
118 5543b9ed Scott Ullrich
				  <td width="78%"> 
119 fda82f52 Carlos Eduardo Ramos
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Ping"); ?>">
120 5b237745 Scott Ullrich
				</td>
121
				</tr>
122
				<tr>
123
				<td valign="top" colspan="2">
124
				<? if ($do_ping) {
125 586d257b Scott Ullrich
					echo "<font face='terminal' size='2'>";
126 7728ad58 Neriberto C.Prado
					echo "<strong>" . gettext("Ping output") . ":</strong><br>";
127 5b237745 Scott Ullrich
					echo('<pre>');
128 8bea9639 Seth Mos
					$ifaddr = get_interface_ip($interface);
129
					if ($ifaddr)
130
						system("/sbin/ping -S$ifaddr -c$count " . escapeshellarg($host));
131
					else
132
						system("/sbin/ping -c$count " . escapeshellarg($host));
133
					$ifaddr = get_interface_ipv6($interface);
134
					if ($ifaddr)
135
						system("/sbin/ping6 -S$ifaddr -c$count " . escapeshellarg($host));
136
					else
137
						system("/sbin/ping6 -c$count " . escapeshellarg($host));
138 86551a06 Seth Mos
					
139 5b237745 Scott Ullrich
					echo('</pre>');
140
				}
141
				?>
142
				</td>
143
				</tr>
144 7a01068a Scott Ullrich
				<tr>
145 01c28384 Scott Ullrich
				  <td width="22%" valign="top">&nbsp;</td>
146
				  <td width="78%"> 
147 7a01068a Scott Ullrich
				 </td>
148
				</tr>			
149 5b237745 Scott Ullrich
			</table>
150 13d193c2 Scott Ullrich
		</form>
151
	</td>
152
</tr>
153
</table>
154 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>