Project

General

Profile

Download (7.85 KB) Statistics
| Branch: | Tag: | Revision:
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 1d333258 Scott Ullrich
/*
32
	pfSense_MODULE:	routing
33
*/
34 5b237745 Scott Ullrich
35 6b07c15a Matthew Grooms
##|+PRIV
36
##|*IDENT=page-system-staticroutes
37
##|*NAME=System: Static Routes page
38
##|*DESCR=Allow access to the 'System: Static Routes' page.
39
##|*MATCH=system_routes.php*
40
##|-PRIV
41
42 5b237745 Scott Ullrich
require("guiconfig.inc");
43 7a927e67 Scott Ullrich
require_once("functions.inc");
44
require_once("filter.inc");
45
require_once("shaper.inc");
46 5b237745 Scott Ullrich
47
if (!is_array($config['staticroutes']['route']))
48
	$config['staticroutes']['route'] = array();
49
50
$a_routes = &$config['staticroutes']['route'];
51 6fdea6a2 smos
$a_gateways = return_gateways_array(true, true);
52 79eaddf4 Renato Botelho
$changedesc = gettext("Static Routes") . ": ";
53 5b237745 Scott Ullrich
54
if ($_POST) {
55
56
	$pconfig = $_POST;
57
58
	if ($_POST['apply']) {
59 691dade5 Scott Ullrich
60 5b237745 Scott Ullrich
		$retval = 0;
61 3851094f Scott Ullrich
62 e8471084 Ermal
		if (file_exists("{$g['tmp_path']}/.system_routes.apply")) {
63 bfe407e5 Warren Baker
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.system_routes.apply"));
64 e8471084 Ermal
			foreach ($toapplylist as $toapply)
65
				mwexec("{$toapply}");
66 966780ad Renato Botelho
67 e8471084 Ermal
			@unlink("{$g['tmp_path']}/.system_routes.apply");
68
		}
69
70 3851094f Scott Ullrich
		$retval = system_routing_configure();
71
		$retval |= filter_configure();
72 13bbe450 Seth Mos
		/* reconfigure our gateway monitor */
73
		setup_gateways_monitor();
74 3851094f Scott Ullrich
75 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
76 a368a026 Ermal Lu?i
		if ($retval == 0)
77
			clear_subsystem_dirty('staticroutes');
78 5b237745 Scott Ullrich
	}
79
}
80
81
if ($_GET['act'] == "del") {
82
	if ($a_routes[$_GET['id']]) {
83 25c3f30c Renato Botelho
		$changedesc .= gettext("removed route to") . " " . $a_routes[$_GET['id']]['route'];
84
85
		$targets = array();
86
		if (is_alias($a_routes[$_GET['id']]['network'])) {
87
			foreach (filter_expand_alias_array($a_routes[$_GET['id']]['network']) as $tgt) {
88
				if (is_ipaddrv4($tgt))
89
					$tgt .= "/32";
90
				else if (is_ipaddrv6($tgt))
91
					$tgt .= "/128";
92
				if (!is_subnet($tgt))
93
					continue;
94
				$targets[] = $tgt;
95
			}
96
		} else {
97
			$targets[] = $a_routes[$_GET['id']]['network'];
98 9c115b40 Ermal
		}
99 25c3f30c Renato Botelho
100
		foreach ($targets as $tgt) {
101
			$family = (is_subnetv6($tgt) ? "-inet6" : "-inet");
102
			mwexec("/sbin/route delete {$family} " . escapeshellarg($tgt));
103
		}
104
105
		unset($a_routes[$_GET['id']]);
106
		unset($targets);
107
		write_config($changedesc);
108
		header("Location: system_routes.php");
109
		exit;
110 5b237745 Scott Ullrich
	}
111
}
112 7f43ca88 Scott Ullrich
113 a2927ebf Vinicius Coque
$pgtitle = array(gettext("System"),gettext("Static Routes"));
114 b32dd0a6 jim-p
$shortcut_section = "routing";
115 02ca24c9 jim-p
116 7f43ca88 Scott Ullrich
include("head.inc");
117
118 5b237745 Scott Ullrich
?>
119
120
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
121
<?php include("fbegin.inc"); ?>
122
<form action="system_routes.php" method="post">
123 1bc92a15 Colin Fleming
<input type="hidden" name="y1" value="1" />
124 5b237745 Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
125 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('staticroutes')): ?><p>
126 1bc92a15 Colin Fleming
<?php print_info_box_np(sprintf(gettext("The static route configuration has been changed.%sYou must apply the changes in order for them to take effect."), "<br/>"));?><br/></p>
127 5b237745 Scott Ullrich
<?php endif; ?>
128 0f282d7a Scott Ullrich
129 966780ad Renato Botelho
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="system routes">
130
	<tr>
131
		<td>
132
		<?php
133
			$tab_array = array();
134
			$tab_array[0] = array(gettext("Gateways"), false, "system_gateways.php");
135
			$tab_array[1] = array(gettext("Routes"), true, "system_routes.php");
136
			$tab_array[2] = array(gettext("Groups"), false, "system_gateway_groups.php");
137
			display_top_tabs($tab_array);
138
		?>
139
		</td>
140
	</tr>
141
	<tr>
142
		<td>
143
			<div id="mainarea">
144
				<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
145
					<tr>
146
						<td width="25%" class="listhdrr"><?=gettext("Network");?></td>
147
						<td width="20%" class="listhdrr"><?=gettext("Gateway");?></td>
148
						<td width="15%" class="listhdrr"><?=gettext("Interface");?></td>
149
						<td width="30%" class="listhdr"><?=gettext("Description");?></td>
150
						<td width="10%" class="list">
151
							<table border="0" cellspacing="0" cellpadding="1" summary="add">
152
								<tr>
153
									<td width="17"></td>
154
									<td><a href="system_routes_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a></td>
155
								</tr>
156
							</table>
157
						</td>
158
					</tr>
159
					<?php $i = 0; foreach ($a_routes as $route): ?>
160
					<tr>
161
					<?php
162
						if (isset($route['disabled'])) {
163
							$textss = "<span class=\"gray\">";
164
							$textse = "</span>";
165
						} else
166
						$textss = $textse = "";
167
					?>
168
						<td class="listlr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
169
							<?=$textss;?><?=strtolower($route['network']);?><?=$textse;?>
170
						</td>
171
						<td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
172
							<?=$textss;?>
173
							<?php
174
								echo htmlentities($a_gateways[$route['gateway']]['name']) . " - " . htmlentities($a_gateways[$route['gateway']]['gateway']);
175
							?>
176
							<?=$textse;?>
177
						</td>
178
						<td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
179
							<?=$textss;?>
180
							<?php
181
								echo convert_friendly_interface_to_friendly_descr($a_gateways[$route['gateway']]['friendlyiface']) . " ";
182
							?>
183
							<?=$textse;?>
184
						</td>
185
						<td class="listbg" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
186
							<?=$textss;?><?=htmlspecialchars($route['descr']);?>&nbsp;<?=$textse;?>
187
						</td>
188
						<td valign="middle" class="list nowrap">
189
							<table border="0" cellspacing="0" cellpadding="1" summary="edit">
190
								<tr>
191
									<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" alt="edit" /></a>
192
									<td><a href="system_routes.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this route?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" /></a></td>
193
								</tr>
194
								<tr>
195
									<td width="17"></td>
196
									<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" alt="add" /></a></td>
197
								</tr>
198
							</table>
199
						</td>
200
					</tr>
201
					<?php $i++; endforeach; ?>
202
					<tr>
203
						<td class="list" colspan="4"></td>
204
						<td class="list">
205
							<table border="0" cellspacing="0" cellpadding="1" summary="edit">
206
								<tr>
207
									<td width="17"></td>
208
									<td><a href="system_routes_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="edit" /></a></td>
209
								</tr>
210
							</table>
211
						</td>
212
					</tr>
213
				</table>
214 8e830f0f Scott Ullrich
			</div>
215 966780ad Renato Botelho
		</td>
216
	</tr>
217
</table>
218
</form>
219
<p><b><?=gettext("Note:");?></b>  <?=gettext("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>
220 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
221
</body>
222
</html>