Project

General

Profile

Download (5.42 KB) Statistics
| Branch: | Tag: | Revision:
1 4d875b4f Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	diag_ipsec_spd.php
5 4d875b4f Scott Ullrich
	Copyright (C) 2004 Scott Ullrich
6
	All rights reserved.
7
8
	originially part of m0n0wall (http://m0n0.ch/wall)
9 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11 4d875b4f Scott Ullrich
12 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14 4d875b4f Scott Ullrich
15 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17 4d875b4f Scott Ullrich
18 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21 4d875b4f Scott Ullrich
22 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33
34
require("guiconfig.inc");
35 b63695db Scott Ullrich
36 d88c6a9f Scott Ullrich
$pgtitle = array("Status","IPsec","SPD");
37 b63695db Scott Ullrich
include("head.inc");
38
39 5b237745 Scott Ullrich
?>
40
41
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
42
<?php include("fbegin.inc"); ?>
43
<table width="100%" border="0" cellpadding="0" cellspacing="0">
44
  <tr><td>
45 b63695db Scott Ullrich
<?php
46
	$tab_array = array();
47 d4888e75 Scott Ullrich
	$tab_array[0] = array("Overview", false, "diag_ipsec.php");
48
	$tab_array[1] = array("SAD", false, "diag_ipsec_sad.php");
49
	$tab_array[2] = array("SPD", true, "diag_ipsec_spd.php");
50 b63695db Scott Ullrich
	display_top_tabs($tab_array);
51
?>
52 5b237745 Scott Ullrich
  </td></tr>
53 4d875b4f Scott Ullrich
  <tr>
54 0f10aee4 Bill Marquette
    <td>
55 5b237745 Scott Ullrich
<?php
56
57
/* delete any SP? */
58
if ($_GET['act'] == "del") {
59 fe227c69 Scott Ullrich
	$fd = @popen("/sbin/setkey -c > /dev/null 2>&1", "w");
60 5b237745 Scott Ullrich
	if ($fd) {
61
		fwrite($fd, "spddelete {$_GET['src']} {$_GET['dst']} any -P {$_GET['dir']} ;\n");
62
		pclose($fd);
63
		sleep(1);
64
	}
65
}
66
67
/* query SAD */
68 fe227c69 Scott Ullrich
$fd = @popen("/sbin/setkey -DP", "r");
69 5b237745 Scott Ullrich
$spd = array();
70
if ($fd) {
71
	while (!feof($fd)) {
72
		$line = chop(fgets($fd));
73
		if (!$line)
74
			continue;
75
		if ($line == "No SPD entries.")
76
			break;
77
		if ($line[0] != "\t") {
78
			if (is_array($cursp))
79
				$spd[] = $cursp;
80
			$cursp = array();
81
			$linea = explode(" ", $line);
82
			$cursp['src'] = substr($linea[0], 0, strpos($linea[0], "["));
83
			$cursp['dst'] = substr($linea[1], 0, strpos($linea[1], "["));
84
			$i = 0;
85
		} else if (is_array($cursp)) {
86
			$linea = explode(" ", trim($line));
87
			if ($i == 1) {
88
				if ($linea[1] == "none")	/* don't show default anti-lockout rule */
89
					unset($cursp);
90
				else
91
					$cursp['dir'] = $linea[0];
92
			} else if ($i == 2) {
93
				$upperspec = explode("/", $linea[0]);
94
				$cursp['proto'] = $upperspec[0];
95
				list($cursp['ep_src'], $cursp['ep_dst']) = explode("-", $upperspec[2]);
96
			}
97
		}
98
		$i++;
99
	}
100
	if (is_array($cursp) && count($cursp))
101
		$spd[] = $cursp;
102
	pclose($fd);
103
}
104
?>
105 033ede97 Scott Ullrich
<div id="mainarea" style="background:#eeeeee">
106 0f10aee4 Bill Marquette
            <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
107
<?php if (count($spd)): ?>
108 5b237745 Scott Ullrich
  <tr>
109
                <td nowrap class="listhdrr">Source</td>
110
                <td nowrap class="listhdrr">Destination</a></td>
111
                <td nowrap class="listhdrr">Direction</td>
112
                <td nowrap class="listhdrr">Protocol</td>
113
                <td nowrap class="listhdrr">Tunnel endpoints</td>
114
                <td nowrap class="list"></td>
115
	</tr>
116
<?php
117
foreach ($spd as $sp): ?>
118
	<tr>
119
		<td class="listlr" valign="top"><?=htmlspecialchars($sp['src']);?></td>
120
		<td class="listr" valign="top"><?=htmlspecialchars($sp['dst']);?></td>
121 5c990bf4 Scott Ullrich
		<td class="listr" valign="top"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_<?=$sp['dir'];?>.gif" width="11" height="11" style="margin-top: 2px"></td>
122 5b237745 Scott Ullrich
		<td class="listr" valign="top"><?=htmlspecialchars(strtoupper($sp['proto']));?></td>
123
		<td class="listr" valign="top"><?=htmlspecialchars($sp['ep_src']);?> - <br>
124
			<?=htmlspecialchars($sp['ep_dst']);?></td>
125
		<td class="list" nowrap>
126
		<?php
127
			$args = "src=" . rawurlencode($sp['src']);
128
			$args .= "&dst=" . rawurlencode($sp['dst']);
129
			$args .= "&dir=" . rawurlencode($sp['dir']);
130
		?>
131 5c990bf4 Scott Ullrich
		  <a href="diag_ipsec_spd.php?act=del&<?=$args;?>" onclick="return confirm('Do you really want to delete this security policy?')">
132
		  <img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a>
133 5b237745 Scott Ullrich
		</td>
134 4d875b4f Scott Ullrich
135 5b237745 Scott Ullrich
	</tr>
136
<?php endforeach; ?>
137
</table>
138
<br>
139 0f10aee4 Bill Marquette
<table class="tabcont" border="0" cellspacing="0" cellpadding="6">
140 4d875b4f Scott Ullrich
  <tr>
141 5c990bf4 Scott Ullrich
	<td width="16"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_in.gif" width="11" height="11"></td>
142 5b237745 Scott Ullrich
	<td>incoming (as seen by firewall)</td>
143
  </tr>
144 4d875b4f Scott Ullrich
  <tr>
145 5b237745 Scott Ullrich
	<td colspan="5" height="4"></td>
146
  </tr>
147 4d875b4f Scott Ullrich
  <tr>
148 5c990bf4 Scott Ullrich
	<td><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_out.gif" width="11" height="11"></td>
149 5b237745 Scott Ullrich
	<td>outgoing (as seen by firewall)</td>
150
  </tr>
151
<?php else: ?>
152 0f10aee4 Bill Marquette
<tr><td><p><strong>No IPsec security policies.</strong></p></td></tr>
153 5b237745 Scott Ullrich
<?php endif; ?>
154 c55a8ab9 Holger Bauer
<td colspan="4">
155
		      <p><span class="vexpl"><span class="red"><strong>Note:<br>
156 6ec0830d Simon Cornelius P Umacob
                      </strong></span>You can configure your IPsec <a href="vpn_ipsec.php">here</a>.</span></p>
157 c55a8ab9 Holger Bauer
		  </td>
158 0f10aee4 Bill Marquette
</table>
159 12af52d9 Scott Ullrich
</div>
160 0f10aee4 Bill Marquette
</td></tr></table>
161 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
162
</body>
163
</html>