Project

General

Profile

Download (5.48 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 0f10aee4 Bill Marquette
$pgtitle = "Diagnostics: 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 310b2c06 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
44 5b237745 Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">
45
  <tr><td>
46 b63695db Scott Ullrich
<?php
47
	$tab_array = array();
48 94304e4e Seth Mos
	$tab_array[0] = array("Overview", false, "diag_ipsec.php");
49
	$tab_array[1] = array("SAD", false, "diag_ipsec_sad.php");
50
	$tab_array[2] = array("SPD", true, "diag_ipsec_spd.php");
51 b63695db Scott Ullrich
	display_top_tabs($tab_array);
52
?>
53 5b237745 Scott Ullrich
  </td></tr>
54 4d875b4f Scott Ullrich
  <tr>
55 0f10aee4 Bill Marquette
    <td>
56 5b237745 Scott Ullrich
<?php
57
58
/* delete any SP? */
59
if ($_GET['act'] == "del") {
60 9f8b7ccb Seth Mos
	$fd = @popen("/usr/local/sbin/setkey -c > /dev/null 2>&1", "w");
61 5b237745 Scott Ullrich
	if ($fd) {
62
		fwrite($fd, "spddelete {$_GET['src']} {$_GET['dst']} any -P {$_GET['dir']} ;\n");
63
		pclose($fd);
64
		sleep(1);
65
	}
66
}
67
68
/* query SAD */
69 9f8b7ccb Seth Mos
$fd = @popen("/usr/local/sbin/setkey -DP", "r");
70 5b237745 Scott Ullrich
$spd = array();
71
if ($fd) {
72
	while (!feof($fd)) {
73
		$line = chop(fgets($fd));
74
		if (!$line)
75
			continue;
76
		if ($line == "No SPD entries.")
77
			break;
78
		if ($line[0] != "\t") {
79
			if (is_array($cursp))
80
				$spd[] = $cursp;
81
			$cursp = array();
82
			$linea = explode(" ", $line);
83
			$cursp['src'] = substr($linea[0], 0, strpos($linea[0], "["));
84
			$cursp['dst'] = substr($linea[1], 0, strpos($linea[1], "["));
85
			$i = 0;
86
		} else if (is_array($cursp)) {
87
			$linea = explode(" ", trim($line));
88
			if ($i == 1) {
89
				if ($linea[1] == "none")	/* don't show default anti-lockout rule */
90
					unset($cursp);
91
				else
92
					$cursp['dir'] = $linea[0];
93
			} else if ($i == 2) {
94
				$upperspec = explode("/", $linea[0]);
95
				$cursp['proto'] = $upperspec[0];
96
				list($cursp['ep_src'], $cursp['ep_dst']) = explode("-", $upperspec[2]);
97
			}
98
		}
99
		$i++;
100
	}
101
	if (is_array($cursp) && count($cursp))
102
		$spd[] = $cursp;
103
	pclose($fd);
104
}
105
?>
106 033ede97 Scott Ullrich
<div id="mainarea" style="background:#eeeeee">
107 0f10aee4 Bill Marquette
            <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
108
<?php if (count($spd)): ?>
109 5b237745 Scott Ullrich
  <tr>
110
                <td nowrap class="listhdrr">Source</td>
111
                <td nowrap class="listhdrr">Destination</a></td>
112
                <td nowrap class="listhdrr">Direction</td>
113
                <td nowrap class="listhdrr">Protocol</td>
114
                <td nowrap class="listhdrr">Tunnel endpoints</td>
115
                <td nowrap class="list"></td>
116
	</tr>
117
<?php
118
foreach ($spd as $sp): ?>
119
	<tr>
120
		<td class="listlr" valign="top"><?=htmlspecialchars($sp['src']);?></td>
121
		<td class="listr" valign="top"><?=htmlspecialchars($sp['dst']);?></td>
122 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>
123 5b237745 Scott Ullrich
		<td class="listr" valign="top"><?=htmlspecialchars(strtoupper($sp['proto']));?></td>
124
		<td class="listr" valign="top"><?=htmlspecialchars($sp['ep_src']);?> - <br>
125
			<?=htmlspecialchars($sp['ep_dst']);?></td>
126
		<td class="list" nowrap>
127
		<?php
128
			$args = "src=" . rawurlencode($sp['src']);
129
			$args .= "&dst=" . rawurlencode($sp['dst']);
130
			$args .= "&dir=" . rawurlencode($sp['dir']);
131
		?>
132 5c990bf4 Scott Ullrich
		  <a href="diag_ipsec_spd.php?act=del&<?=$args;?>" onclick="return confirm('Do you really want to delete this security policy?')">
133
		  <img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a>
134 5b237745 Scott Ullrich
		</td>
135 4d875b4f Scott Ullrich
136 5b237745 Scott Ullrich
	</tr>
137
<?php endforeach; ?>
138
</table>
139
<br>
140 0f10aee4 Bill Marquette
<table class="tabcont" border="0" cellspacing="0" cellpadding="6">
141 4d875b4f Scott Ullrich
  <tr>
142 5c990bf4 Scott Ullrich
	<td width="16"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_in.gif" width="11" height="11"></td>
143 5b237745 Scott Ullrich
	<td>incoming (as seen by firewall)</td>
144
  </tr>
145 4d875b4f Scott Ullrich
  <tr>
146 5b237745 Scott Ullrich
	<td colspan="5" height="4"></td>
147
  </tr>
148 4d875b4f Scott Ullrich
  <tr>
149 5c990bf4 Scott Ullrich
	<td><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_out.gif" width="11" height="11"></td>
150 5b237745 Scott Ullrich
	<td>outgoing (as seen by firewall)</td>
151
  </tr>
152
<?php else: ?>
153 0f10aee4 Bill Marquette
<tr><td><p><strong>No IPsec security policies.</strong></p></td></tr>
154 5b237745 Scott Ullrich
<?php endif; ?>
155 c55a8ab9 Holger Bauer
<td colspan="4">
156
		      <p><span class="vexpl"><span class="red"><strong>Note:<br>
157 d6528238 Chris Buechler
                      </strong></span>You can configure your IPsec <a href="vpn_ipsec.php">here</a>.</span></p>
158 c55a8ab9 Holger Bauer
		  </td>
159 0f10aee4 Bill Marquette
</table>
160 12af52d9 Scott Ullrich
</div>
161 0f10aee4 Bill Marquette
</td></tr></table>
162 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
163
</body>
164
</html>