Project

General

Profile

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