Project

General

Profile

Download (4.32 KB) Statistics
| Branch: | Tag: | Revision:
1
<?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
require("guiconfig.inc");
33
$pgtitle = array("Diagnostics","Traceroute");
34
include("head.inc");
35
?>
36
<body link="#000000" vlink="#000000" alink="#000000">
37
<? include("fbegin.inc"); ?>
38
<?php
39

    
40
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

    
87
				<tr>
88
				  <td width="22%" valign="top" class="vncellreq">Use ICMP</td>
89
				  <td width="78%" class="vtable">
90
					<input name="useicmp" type="checkbox"<?php if($_POST['useicmp']) echo " CHECKED"; ?>>
91
					</td>
92
				</tr>
93
				<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
					echo "<font face='terminal' size='2'>";
104
					echo("<br><strong>Traceroute output:</strong><br>");
105
					echo('<pre>');
106
					ob_end_flush();
107
					if($_POST['useicmp'])
108
						$useicmp = "-I";
109
					else
110
						$useicmp = "";
111
					system("/usr/sbin/traceroute $useicmp -w 2 -m " . escapeshellarg($ttl) . " " . escapeshellarg($host));
112
					echo('</pre>');
113
				}
114
				?>
115
				</td>
116
				</tr>
117
				<tr>
118
				  <td width="22%" valign="top">&nbsp;</td>
119
				  <td width="78%"> 
120
					<span class="vexpl"><strong>Note: </strong></span> Multi-wan is not supported from this utility currently. 
121
				 </td>
122
				</tr>					
123
			</table>
124
</form>
125
<?php include("fend.inc"); ?>
(29-29/189)