1 |
5b237745
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
system_routes.php
|
5 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
6 |
8450bc24
|
Scott Ullrich
|
|
7 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8 |
|
|
All rights reserved.
|
9 |
8450bc24
|
Scott Ullrich
|
|
10 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
8450bc24
|
Scott Ullrich
|
|
13 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
8450bc24
|
Scott Ullrich
|
|
16 |
5b237745
|
Scott Ullrich
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
8450bc24
|
Scott Ullrich
|
|
20 |
5b237745
|
Scott Ullrich
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
|
|
|
32 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
33 |
|
|
##|*IDENT=page-system-staticroutes
|
34 |
|
|
##|*NAME=System: Static Routes page
|
35 |
|
|
##|*DESCR=Allow access to the 'System: Static Routes' page.
|
36 |
|
|
##|*MATCH=system_routes.php*
|
37 |
|
|
##|-PRIV
|
38 |
|
|
|
39 |
|
|
|
40 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
41 |
|
|
|
42 |
|
|
if (!is_array($config['staticroutes']['route']))
|
43 |
|
|
$config['staticroutes']['route'] = array();
|
44 |
|
|
|
45 |
d173230c
|
Seth Mos
|
if (!is_array($config['gateways']['gateway_item']))
|
46 |
|
|
$config['gateways']['gateway_item'] = array();
|
47 |
|
|
|
48 |
5b237745
|
Scott Ullrich
|
staticroutes_sort();
|
49 |
|
|
$a_routes = &$config['staticroutes']['route'];
|
50 |
d173230c
|
Seth Mos
|
$a_gateways = &$config['gateways']['gateway_item'];
|
51 |
2b87adae
|
Bill Marquette
|
$changedesc = "Static Routes: ";
|
52 |
5b237745
|
Scott Ullrich
|
|
53 |
|
|
if ($_POST) {
|
54 |
|
|
|
55 |
|
|
$pconfig = $_POST;
|
56 |
|
|
|
57 |
|
|
if ($_POST['apply']) {
|
58 |
691dade5
|
Scott Ullrich
|
|
59 |
5b237745
|
Scott Ullrich
|
$retval = 0;
|
60 |
3851094f
|
Scott Ullrich
|
|
61 |
|
|
$retval = system_routing_configure();
|
62 |
|
|
$retval |= filter_configure();
|
63 |
13bbe450
|
Seth Mos
|
/* reconfigure our gateway monitor */
|
64 |
|
|
setup_gateways_monitor();
|
65 |
3851094f
|
Scott Ullrich
|
|
66 |
5b237745
|
Scott Ullrich
|
$savemsg = get_std_save_message($retval);
|
67 |
|
|
if ($retval == 0) {
|
68 |
|
|
if (file_exists($d_staticroutesdirty_path)) {
|
69 |
|
|
config_lock();
|
70 |
|
|
unlink($d_staticroutesdirty_path);
|
71 |
|
|
config_unlock();
|
72 |
|
|
}
|
73 |
|
|
}
|
74 |
2b87adae
|
Bill Marquette
|
} else {
|
75 |
|
|
if ($_POST['enablefastrouting'] == "") {
|
76 |
|
|
/* Only update config if something changed */
|
77 |
|
|
if (isset($config['staticroutes']['enablefastrouting'])) {
|
78 |
|
|
$changedesc .= " disable fast routing";
|
79 |
|
|
unset($config['staticroutes']['enablefastrouting']);
|
80 |
|
|
write_config($changedesc);
|
81 |
|
|
}
|
82 |
|
|
} else {
|
83 |
|
|
/* Only update config if something changed */
|
84 |
|
|
if (!isset($config['staticroutes']['enablefastrouting'])) {
|
85 |
|
|
$changedesc .= " enable fast routing";
|
86 |
|
|
$config['staticroutes']['enablefastrouting'] = "enabled";
|
87 |
|
|
write_config($changedesc);
|
88 |
|
|
}
|
89 |
|
|
}
|
90 |
5b237745
|
Scott Ullrich
|
}
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
if ($_GET['act'] == "del") {
|
94 |
|
|
if ($a_routes[$_GET['id']]) {
|
95 |
4fcae58f
|
Scott Ullrich
|
$changedesc .= "removed route to " . $a_routes[$_GET['id']['route']];
|
96 |
5b237745
|
Scott Ullrich
|
unset($a_routes[$_GET['id']]);
|
97 |
59d922dc
|
Bill Marquette
|
write_config($changedesc);
|
98 |
5b237745
|
Scott Ullrich
|
touch($d_staticroutesdirty_path);
|
99 |
|
|
header("Location: system_routes.php");
|
100 |
|
|
exit;
|
101 |
|
|
}
|
102 |
|
|
}
|
103 |
7f43ca88
|
Scott Ullrich
|
|
104 |
d88c6a9f
|
Scott Ullrich
|
$pgtitle = array("System","Static Routes");
|
105 |
7f43ca88
|
Scott Ullrich
|
include("head.inc");
|
106 |
|
|
|
107 |
5b237745
|
Scott Ullrich
|
?>
|
108 |
|
|
|
109 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
110 |
|
|
<?php include("fbegin.inc"); ?>
|
111 |
|
|
<form action="system_routes.php" method="post">
|
112 |
691dade5
|
Scott Ullrich
|
<input type="hidden" name="y1" value="1">
|
113 |
5b237745
|
Scott Ullrich
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
114 |
|
|
<?php if (file_exists($d_staticroutesdirty_path)): ?><p>
|
115 |
|
|
<?php print_info_box_np("The static route configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
|
116 |
|
|
<?php endif; ?>
|
117 |
0f282d7a
|
Scott Ullrich
|
|
118 |
5de92d20
|
Scott Ullrich
|
<?php if($config['system']['disablefilter'] <> "") :?>
|
119 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
120 |
|
|
|
121 |
691dade5
|
Scott Ullrich
|
<tr><td width="2%"><input type="checkbox" name="enablefastrouting" id="enablefastrouting" <?php if($config['staticroutes']['enablefastrouting'] == "enabled") echo " checked"; ?>></td><td><b>Enable fast routing</td></tr>
|
122 |
5de92d20
|
Scott Ullrich
|
|
123 |
0f282d7a
|
Scott Ullrich
|
<tr><td colspan=2><hr><input type="submit" value="Save"></td></tr>
|
124 |
5de92d20
|
Scott Ullrich
|
</table><br>
|
125 |
0831bc86
|
Scott Ullrich
|
<?php endif; ?>
|
126 |
0f282d7a
|
Scott Ullrich
|
|
127 |
5b237745
|
Scott Ullrich
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
128 |
d173230c
|
Seth Mos
|
<tr>
|
129 |
|
|
<td>
|
130 |
|
|
<?php
|
131 |
ba7ec830
|
Scott Ullrich
|
$tab_array = array();
|
132 |
|
|
$tab_array[0] = array("Gateways", false, "system_gateways.php");
|
133 |
c67a0d18
|
Seth Mos
|
$tab_array[1] = array("Routes", true, "system_routes.php");
|
134 |
b059ef72
|
Seth Mos
|
$tab_array[2] = array("Groups", false, "system_gateway_groups.php");
|
135 |
ba7ec830
|
Scott Ullrich
|
display_top_tabs($tab_array);
|
136 |
d173230c
|
Seth Mos
|
?>
|
137 |
8e830f0f
|
Scott Ullrich
|
</td></tr>
|
138 |
|
|
<tr>
|
139 |
|
|
<td>
|
140 |
|
|
<div id="mainarea">
|
141 |
|
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
142 |
5b237745
|
Scott Ullrich
|
<tr>
|
143 |
|
|
<td width="25%" class="listhdrr">Network</td>
|
144 |
|
|
<td width="20%" class="listhdrr">Gateway</td>
|
145 |
d173230c
|
Seth Mos
|
<td width="15%" class="listhdrr">Interface</td>
|
146 |
5b237745
|
Scott Ullrich
|
<td width="30%" class="listhdr">Description</td>
|
147 |
d415d821
|
Seth Mos
|
<td width="10%" class="list">
|
148 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
149 |
|
|
<tr>
|
150 |
18f7352b
|
Seth Mos
|
<td width="17"></td>
|
151 |
d415d821
|
Seth Mos
|
<td><a href="system_routes_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
152 |
|
|
</tr>
|
153 |
|
|
</table>
|
154 |
|
|
</td>
|
155 |
|
|
</tr>
|
156 |
5b237745
|
Scott Ullrich
|
<tr>
|
157 |
d173230c
|
Seth Mos
|
<?php $i = 0; foreach ($a_routes as $route): ?>
|
158 |
e68492cc
|
Bill Marquette
|
<td class="listlr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
|
159 |
d173230c
|
Seth Mos
|
<?=strtolower($route['network']);?>
|
160 |
5b237745
|
Scott Ullrich
|
</td>
|
161 |
e68492cc
|
Bill Marquette
|
<td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
|
162 |
d173230c
|
Seth Mos
|
<?php
|
163 |
|
|
echo $route['gateway'] . " ";
|
164 |
|
|
?>
|
165 |
5b237745
|
Scott Ullrich
|
</td>
|
166 |
e68492cc
|
Bill Marquette
|
<td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
|
167 |
d173230c
|
Seth Mos
|
<?php
|
168 |
|
|
foreach($a_gateways as $gateway) {
|
169 |
|
|
if($gateway['name'] == $route['gateway']) {
|
170 |
|
|
echo strtoupper($gateway['interface']) . " ";
|
171 |
fef3a8ef
|
Scott Ullrich
|
}
|
172 |
d173230c
|
Seth Mos
|
}
|
173 |
|
|
|
174 |
|
|
?>
|
175 |
5b237745
|
Scott Ullrich
|
</td>
|
176 |
e68492cc
|
Bill Marquette
|
<td class="listbg" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
|
177 |
33300c73
|
Scott Ullrich
|
<?=htmlspecialchars($route['descr']);?>
|
178 |
5b237745
|
Scott Ullrich
|
</td>
|
179 |
18f7352b
|
Seth Mos
|
<td valign="middle" nowrap class="list">
|
180 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
181 |
|
|
<tr>
|
182 |
|
|
<td><a href="system_routes_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
|
183 |
|
|
<td><a href="system_routes.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this route?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
|
184 |
|
|
</tr>
|
185 |
|
|
<tr>
|
186 |
|
|
<td width="17"></td>
|
187 |
|
|
<td><a href="system_routes_edit.php?dup=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
188 |
|
|
</tr>
|
189 |
|
|
</table>
|
190 |
d173230c
|
Seth Mos
|
</td>
|
191 |
18f7352b
|
Seth Mos
|
</tr>
|
192 |
5b237745
|
Scott Ullrich
|
<?php $i++; endforeach; ?>
|
193 |
8450bc24
|
Scott Ullrich
|
<tr>
|
194 |
5b237745
|
Scott Ullrich
|
<td class="list" colspan="4"></td>
|
195 |
d415d821
|
Seth Mos
|
<td class="list">
|
196 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
197 |
|
|
<tr>
|
198 |
18f7352b
|
Seth Mos
|
<td width="17"></td>
|
199 |
d415d821
|
Seth Mos
|
<td><a href="system_routes_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
200 |
|
|
</tr>
|
201 |
8e830f0f
|
Scott Ullrich
|
</table>
|
202 |
|
|
</td>
|
203 |
|
|
</tr>
|
204 |
d415d821
|
Seth Mos
|
</table>
|
205 |
8e830f0f
|
Scott Ullrich
|
</div>
|
206 |
|
|
</td>
|
207 |
|
|
</tr>
|
208 |
|
|
</table>
|
209 |
5b237745
|
Scott Ullrich
|
</form>
|
210 |
f3bfeeea
|
Scott Ullrich
|
<p><b>Note:</b> Do not enter static routes for networks assigned on any interface of this firewall. Static routes are only used for networks reachable via a different router, and not reachable via your default gateway.</p>
|
211 |
5b237745
|
Scott Ullrich
|
<?php include("fend.inc"); ?>
|
212 |
|
|
</body>
|
213 |
|
|
</html>
|