Project

General

Profile

Download (5.86 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
	pfSense_BUILDER_BINARIES:	/usr/sbin/traceroute
33
	pfSense_MODULE:	routing
34
*/
35

    
36
##|+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
require("guiconfig.inc");
44

    
45
$pgtitle = array(gettext("Diagnostics"),gettext("Traceroute"));
46
include("head.inc");
47

    
48
?>
49
<body link="#000000" vlink="#000000" alink="#000000">
50
<?php include("fbegin.inc"); ?>
51
<?php
52

    
53
define('MAX_TTL', 64);
54
define('DEFAULT_TTL', 18);
55

    
56
if ($_POST || $_REQUEST['host']) {
57
	unset($input_errors);
58
	unset($do_traceroute);
59

    
60
	/* input validation */
61
	$reqdfields = explode(" ", "host ttl");
62
	$reqdfieldsn = array(gettext("Host"),gettext("ttl"));
63
	do_input_validation($_REQUEST, $reqdfields, $reqdfieldsn, &$input_errors);
64

    
65
	if (($_REQUEST['ttl'] < 1) || ($_REQUEST['ttl'] > MAX_TTL)) {
66
		$input_errors[] = sprintf(gettext("Maximum number of hops must be between 1 and %s"), MAX_TTL);
67
	}
68

    
69
	if (!$input_errors) {
70
		$gateway = $_REQUEST['gateway'];
71
		$do_traceroute = true;
72
		$host = $_REQUEST['host'];
73
		$ttl = $_REQUEST['ttl'];
74
		$resolve = $_REQUEST['resolve'];
75
	}
76
} else
77
	$resolve = true;
78

    
79
if (!isset($do_traceroute)) {
80
	$do_traceroute = false;
81
	$host = '';
82
	$ttl = DEFAULT_TTL;
83
}
84

    
85
?>
86
<?php if ($input_errors) print_input_errors($input_errors); ?>
87
	<form action="diag_traceroute.php" method="post" name="iform" id="iform">
88
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
89
			<tr>
90
				<td colspan="2" valign="top" class="listtopic"><?=gettext("Traceroute");?></td>
91
			</tr>
92
			<tr>
93
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Host");?></td>
94
				<td width="78%" class="vtable">
95
					<?=$mandfldhtml;?><input name="host" type="text" class="formfld" id="host" size="20" value="<?=htmlspecialchars($host);?>"></td>
96
			</tr>
97
			<tr>
98
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Gateway"); ?></td>
99
				<td width="78%" class="vtable">
100
					<select name="gateway" class="formfld">
101
						<option value="default" <?php echo ($interface == "default" ? "selected" : "") ?>>Default</option>
102
						<?php $gateways = return_gateways_array();
103
							foreach ($gateways as $gwname => $gwitem): ?>
104
							<option value="<?=$gwitem['interface'];?>" <?php if (!link_interface_to_bridge($gwitem['friendlyiface']) && $gwitem['interface'] == $gateway) echo "selected"; ?>>
105
							<?=htmlspecialchars($gwname);?>
106
							</option>
107
						<?php endforeach; ?>
108
					</select>
109
				</td>
110
			</tr>
111
			<tr>
112
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Maximum number of hops");?></td>
113
				<td width="78%" class="vtable">
114
					<select name="ttl" class="formfld" id="ttl">
115
						<?php for ($i = 1; $i <= MAX_TTL; $i++): ?>
116
							<option value="<?=$i;?>" <?php if ($i == $ttl) echo "selected"; ?>><?=$i;?></option>
117
						<?php endfor; ?>
118
					</select>
119
				</td>
120
			</tr>
121
			<tr>
122
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Reverse Address Lookup");?></td>
123
				<td width="78%" class="vtable">
124
					<input name="resolve" type="checkbox"<?php echo (!isset($resolve) ? "" : " CHECKED"); ?>>
125
				</td>
126
			</tr>
127
			<tr>
128
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Use ICMP");?></td>
129
				<td width="78%" class="vtable">
130
					<input name="useicmp" type="checkbox"<?php if($_REQUEST['useicmp']) echo " CHECKED"; ?>>
131
				</td>
132
			</tr>
133
			<tr>
134
				<td width="22%" valign="top">&nbsp;</td>
135
				<td width="78%">
136
					<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Traceroute");?>">
137
				</td>
138
			</tr>
139
			<tr>
140
				<td valign="top" colspan="2">
141
					<p><span class="vexpl"><span class="red"><b><?=gettext("Note: ");?></b></span><?=gettext("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.");?></span><p>
142
						<?php if ($do_traceroute) {
143
							echo "<font face='terminal' size='2'>";
144
							echo("<br><strong>" . gettext("Traceroute output:") . "</strong><br>");
145
							echo('<pre>');
146
							ob_end_flush();
147
							$useicmp = isset($_REQUEST['useicmp']) ? "-I" : "";
148
							$srcint = ($gateway != "default") ? "-i " . escapeshellarg(get_real_interface($gateway)) : "";
149
							$n = isset($resolve) ? "" : "-n";
150
							system("/usr/sbin/traceroute $n $srcint $useicmp -w 2 -m " . escapeshellarg($ttl) . " " . escapeshellarg($host));
151
							system("/usr/sbin/traceroute6 $n $srcint $useicmp -w 2 -m " . escapeshellarg($ttl) . " " . escapeshellarg($host));
152
							echo('</pre>');
153
						}
154
					?>
155
				</td>
156
			</tr>
157
		</table>
158
</form>
159
<?php include("fend.inc"); ?>
(51-51/249)