Project

General

Profile

Download (4.59 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
##|+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

    
40
require("guiconfig.inc");
41
$pgtitle = array("Diagnostics","Traceroute");
42
include("head.inc");
43
?>
44
<body link="#000000" vlink="#000000" alink="#000000">
45
<? include("fbegin.inc"); ?>
46
<?php
47

    
48
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
				<tr>
81
					<td colspan="2" valign="top" class="listtopic">Traceroute</td>
82
				</tr>	
83
                <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

    
98
				<tr>
99
				  <td width="22%" valign="top" class="vncellreq">Use ICMP</td>
100
				  <td width="78%" class="vtable">
101
					<input name="useicmp" type="checkbox"<?php if($_POST['useicmp']) echo " CHECKED"; ?>>
102
					</td>
103
				</tr>
104
				<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
					echo "<font face='terminal' size='2'>";
115
					echo("<br><strong>Traceroute output:</strong><br>");
116
					echo('<pre>');
117
					ob_end_flush();
118
					if($_POST['useicmp'])
119
						$useicmp = "-I";
120
					else
121
						$useicmp = "";
122
					system("/usr/sbin/traceroute $useicmp -w 2 -m " . escapeshellarg($ttl) . " " . escapeshellarg($host));
123
					echo('</pre>');
124
				}
125
				?>
126
				</td>
127
				</tr>
128
				<tr>
129
				  <td width="22%" valign="top">&nbsp;</td>
130
				  <td width="78%"> 
131
					<span class="vexpl"><strong>Note: </strong></span> Multi-wan is not supported from this utility currently. 
132
				 </td>
133
				</tr>					
134
			</table>
135
</form>
136
<?php include("fend.inc"); ?>
(35-35/217)