Project

General

Profile

Download (4.32 KB) Statistics
| Branch: | Tag: | Revision:
1 93e1b16c Scott Ullrich
<?php
2
/*
3
	diag_traceroute.php
4
	part of m0n0wall (http://m0n0.ch/wall)
5
6
	Copyright (C) 2005 Paul Taylor (paultaylor@winndixie.com) and Manuel Kasper <mk@neon1.net>.
7
	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
32 b8a66425 Scott Ullrich
require("guiconfig.inc");
33 d88c6a9f Scott Ullrich
$pgtitle = array("Diagnostics","Traceroute");
34 b8a66425 Scott Ullrich
include("head.inc");
35
?>
36
<body link="#000000" vlink="#000000" alink="#000000">
37 30b8bfd2 Bill Marquette
<? include("fbegin.inc"); ?>
38 43fdebc5 Scott Ullrich
<?php
39
40 93e1b16c Scott Ullrich
define('MAX_TTL', 64);
41
define('DEFAULT_TTL', 18);
42
43
if ($_POST) {
44
	unset($input_errors);
45
	unset($do_traceroute);
46
47
	/* input validation */
48
	$reqdfields = explode(" ", "host ttl");
49
	$reqdfieldsn = explode(",", "Host,ttl");
50
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
51
52
	if (($_POST['ttl'] < 1) || ($_POST['ttl'] > MAX_TTL)) {
53
		$input_errors[] = "Maximum number of hops must be between 1 and {MAX_TTL}";
54
	}
55
56
	if (!$input_errors) {
57
		$do_traceroute = true;
58
		$host = $_POST['host'];
59
		$ttl = $_POST['ttl'];
60
61
	}
62
}
63
if (!isset($do_traceroute)) {
64
	$do_traceroute = false;
65
	$host = '';
66
	$ttl = DEFAULT_TTL;
67
}
68
?>
69
<?php if ($input_errors) print_input_errors($input_errors); ?>
70
			<form action="diag_traceroute.php" method="post" name="iform" id="iform">
71
			  <table width="100%" border="0" cellpadding="6" cellspacing="0">
72
                <tr>
73
				  <td width="22%" valign="top" class="vncellreq">Host</td>
74
				  <td width="78%" class="vtable"> 
75
                    <?=$mandfldhtml;?><input name="host" type="text" class="formfld" id="host" size="20" value="<?=htmlspecialchars($host);?>"></td>
76
				</tr>
77
				<tr>
78
				  <td width="22%" valign="top" class="vncellreq">Maximum number of hops</td>
79
				  <td width="78%" class="vtable">
80
					<select name="ttl" class="formfld" id="ttl">
81
					<?php for ($i = 1; $i <= MAX_TTL; $i++): ?>
82
					<option value="<?=$i;?>" <?php if ($i == $ttl) echo "selected"; ?>><?=$i;?></option>
83
					<?php endfor; ?>
84
					</select></td>
85
				</tr>
86 e61457d9 Scott Ullrich
87
				<tr>
88
				  <td width="22%" valign="top" class="vncellreq">Use ICMP</td>
89
				  <td width="78%" class="vtable">
90 bcd92ae7 Scott Ullrich
					<input name="useicmp" type="checkbox"<?php if($_POST['useicmp']) echo " CHECKED"; ?>>
91 e61457d9 Scott Ullrich
					</td>
92
				</tr>
93 93e1b16c Scott Ullrich
				<tr>
94
				  <td width="22%" valign="top">&nbsp;</td>
95
				  <td width="78%"> 
96
                    <input name="Submit" type="submit" class="formbtn" value="Traceroute">
97
				</td>
98
				</tr>
99
				<tr>
100
				<td valign="top" colspan="2">
101
				<p><span class="vexpl"><span class="red"><strong>Note: </strong></span> Traceroute may take a while to complete.  You may hit the Stop button on your browser at any time to see the progress of failed traceroutes.<p>
102
				<? if ($do_traceroute) {
103 586d257b Scott Ullrich
					echo "<font face='terminal' size='2'>";
104 93e1b16c Scott Ullrich
					echo("<br><strong>Traceroute output:</strong><br>");
105
					echo('<pre>');
106
					ob_end_flush();
107 e61457d9 Scott Ullrich
					if($_POST['useicmp'])
108
						$useicmp = "-I";
109
					else
110
						$useicmp = "";
111
					system("/usr/sbin/traceroute $useicmp -w 2 -m " . escapeshellarg($ttl) . " " . escapeshellarg($host));
112 93e1b16c Scott Ullrich
					echo('</pre>');
113
				}
114
				?>
115
				</td>
116
				</tr>
117 7a01068a Scott Ullrich
				<tr>
118 01c28384 Scott Ullrich
				  <td width="22%" valign="top">&nbsp;</td>
119
				  <td width="78%"> 
120 52456225 Scott Ullrich
					<span class="vexpl"><strong>Note: </strong></span> Multi-wan is not supported from this utility currently. 
121 7a01068a Scott Ullrich
				 </td>
122 01c28384 Scott Ullrich
				</tr>					
123 93e1b16c Scott Ullrich
			</table>
124
</form>
125
<?php include("fend.inc"); ?>