Project

General

Profile

Download (4.59 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 6b07c15a Matthew Grooms
##|+PRIV
32
##|*IDENT=page-diagnostics-traceroute
33
##|*NAME=Diagnostics: Traceroute page
34
##|*DESCR=Allow access to the 'Diagnostics: Traceroute' page.
35
##|*MATCH=diag_traceroute.php*
36
##|-PRIV
37
38
39 93e1b16c Scott Ullrich
40 b8a66425 Scott Ullrich
require("guiconfig.inc");
41 d88c6a9f Scott Ullrich
$pgtitle = array("Diagnostics","Traceroute");
42 b8a66425 Scott Ullrich
include("head.inc");
43
?>
44
<body link="#000000" vlink="#000000" alink="#000000">
45 30b8bfd2 Bill Marquette
<? include("fbegin.inc"); ?>
46 43fdebc5 Scott Ullrich
<?php
47
48 93e1b16c Scott Ullrich
define('MAX_TTL', 64);
49
define('DEFAULT_TTL', 18);
50
51
if ($_POST) {
52
	unset($input_errors);
53
	unset($do_traceroute);
54
55
	/* input validation */
56
	$reqdfields = explode(" ", "host ttl");
57
	$reqdfieldsn = explode(",", "Host,ttl");
58
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
59
60
	if (($_POST['ttl'] < 1) || ($_POST['ttl'] > MAX_TTL)) {
61
		$input_errors[] = "Maximum number of hops must be between 1 and {MAX_TTL}";
62
	}
63
64
	if (!$input_errors) {
65
		$do_traceroute = true;
66
		$host = $_POST['host'];
67
		$ttl = $_POST['ttl'];
68
69
	}
70
}
71
if (!isset($do_traceroute)) {
72
	$do_traceroute = false;
73
	$host = '';
74
	$ttl = DEFAULT_TTL;
75
}
76
?>
77
<?php if ($input_errors) print_input_errors($input_errors); ?>
78
			<form action="diag_traceroute.php" method="post" name="iform" id="iform">
79
			  <table width="100%" border="0" cellpadding="6" cellspacing="0">
80 0cece4a2 Scott Ullrich
				<tr>
81
					<td colspan="2" valign="top" class="listtopic">Traceroute</td>
82
				</tr>	
83 93e1b16c Scott Ullrich
                <tr>
84
				  <td width="22%" valign="top" class="vncellreq">Host</td>
85
				  <td width="78%" class="vtable"> 
86
                    <?=$mandfldhtml;?><input name="host" type="text" class="formfld" id="host" size="20" value="<?=htmlspecialchars($host);?>"></td>
87
				</tr>
88
				<tr>
89
				  <td width="22%" valign="top" class="vncellreq">Maximum number of hops</td>
90
				  <td width="78%" class="vtable">
91
					<select name="ttl" class="formfld" id="ttl">
92
					<?php for ($i = 1; $i <= MAX_TTL; $i++): ?>
93
					<option value="<?=$i;?>" <?php if ($i == $ttl) echo "selected"; ?>><?=$i;?></option>
94
					<?php endfor; ?>
95
					</select></td>
96
				</tr>
97 e61457d9 Scott Ullrich
98
				<tr>
99
				  <td width="22%" valign="top" class="vncellreq">Use ICMP</td>
100
				  <td width="78%" class="vtable">
101 bcd92ae7 Scott Ullrich
					<input name="useicmp" type="checkbox"<?php if($_POST['useicmp']) echo " CHECKED"; ?>>
102 e61457d9 Scott Ullrich
					</td>
103
				</tr>
104 93e1b16c Scott Ullrich
				<tr>
105
				  <td width="22%" valign="top">&nbsp;</td>
106
				  <td width="78%"> 
107
                    <input name="Submit" type="submit" class="formbtn" value="Traceroute">
108
				</td>
109
				</tr>
110
				<tr>
111
				<td valign="top" colspan="2">
112
				<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>
113
				<? if ($do_traceroute) {
114 586d257b Scott Ullrich
					echo "<font face='terminal' size='2'>";
115 93e1b16c Scott Ullrich
					echo("<br><strong>Traceroute output:</strong><br>");
116
					echo('<pre>');
117
					ob_end_flush();
118 e61457d9 Scott Ullrich
					if($_POST['useicmp'])
119
						$useicmp = "-I";
120
					else
121
						$useicmp = "";
122
					system("/usr/sbin/traceroute $useicmp -w 2 -m " . escapeshellarg($ttl) . " " . escapeshellarg($host));
123 93e1b16c Scott Ullrich
					echo('</pre>');
124
				}
125
				?>
126
				</td>
127
				</tr>
128 7a01068a Scott Ullrich
				<tr>
129 01c28384 Scott Ullrich
				  <td width="22%" valign="top">&nbsp;</td>
130
				  <td width="78%"> 
131 52456225 Scott Ullrich
					<span class="vexpl"><strong>Note: </strong></span> Multi-wan is not supported from this utility currently. 
132 7a01068a Scott Ullrich
				 </td>
133 01c28384 Scott Ullrich
				</tr>					
134 93e1b16c Scott Ullrich
			</table>
135
</form>
136
<?php include("fend.inc"); ?>