Project

General

Profile

Download (4.72 KB) Statistics
| Branch: | Tag: | Revision:
1 4d875b4f Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	diag_ipsec_sad.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","SA");
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", true, "diag_ipsec_sad.php");
49
	$tab_array[2] = array("SPD", false, "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 SA? */
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, "delete {$_GET['src']} {$_GET['dst']} {$_GET['proto']} {$_GET['spi']} ;\n");
62
		pclose($fd);
63
		sleep(1);
64
	}
65
}
66
67
/* query SAD */
68 fe227c69 Scott Ullrich
$fd = @popen("/sbin/setkey -D", "r");
69 5b237745 Scott Ullrich
$sad = array();
70
if ($fd) {
71
	while (!feof($fd)) {
72
		$line = chop(fgets($fd));
73
		if (!$line)
74
			continue;
75
		if ($line == "No SAD entries.")
76
			break;
77
		if ($line[0] != "\t") {
78
			if (is_array($cursa))
79
				$sad[] = $cursa;
80
			$cursa = array();
81
			list($cursa['src'],$cursa['dst']) = explode(" ", $line);
82
			$i = 0;
83
		} else {
84
			$linea = explode(" ", trim($line));
85
			if ($i == 1) {
86
				$cursa['proto'] = $linea[0];
87
				$cursa['spi'] = substr($linea[2], strpos($linea[2], "x")+1, -1);
88
			} else if ($i == 2) {
89
				$cursa['ealgo'] = $linea[1];
90
			} else if ($i == 3) {
91
				$cursa['aalgo'] = $linea[1];
92
			}
93
		}
94
		$i++;
95
	}
96
	if (is_array($cursa) && count($cursa))
97
		$sad[] = $cursa;
98
	pclose($fd);
99
}
100
?>
101 0f10aee4 Bill Marquette
	<div id="mainarea">
102
            <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
103
<?php if (count($sad)): ?>
104 5b237745 Scott Ullrich
  <tr>
105
                <td nowrap class="listhdrr">Source</td>
106
                <td nowrap class="listhdrr">Destination</a></td>
107
                <td nowrap class="listhdrr">Protocol</td>
108
                <td nowrap class="listhdrr">SPI</td>
109
                <td nowrap class="listhdrr">Enc. alg.</td>
110
                <td nowrap class="listhdr">Auth. alg.</td>
111
                <td nowrap class="list"></td>
112
	</tr>
113
<?php
114
foreach ($sad as $sa): ?>
115
	<tr>
116
		<td class="listlr"><?=htmlspecialchars($sa['src']);?></td>
117
		<td class="listr"><?=htmlspecialchars($sa['dst']);?></td>
118
		<td class="listr"><?=htmlspecialchars(strtoupper($sa['proto']));?></td>
119
		<td class="listr"><?=htmlspecialchars($sa['spi']);?></td>
120
		<td class="listr"><?=htmlspecialchars($sa['ealgo']);?></td>
121
		<td class="listr"><?=htmlspecialchars($sa['aalgo']);?></td>
122
		<td class="list" nowrap>
123
		<?php
124
			$args = "src=" . rawurlencode($sa['src']);
125
			$args .= "&dst=" . rawurlencode($sa['dst']);
126
			$args .= "&proto=" . rawurlencode($sa['proto']);
127
			$args .= "&spi=" . rawurlencode("0x" . $sa['spi']);
128
		?>
129 5c990bf4 Scott Ullrich
		  <a href="diag_ipsec_sad.php?act=del&<?=$args;?>" onclick="return confirm('Do you really want to delete this security association?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a>
130 5b237745 Scott Ullrich
		</td>
131 4d875b4f Scott Ullrich
132 5b237745 Scott Ullrich
	</tr>
133
<?php endforeach; ?>
134
<?php else: ?>
135 0f10aee4 Bill Marquette
<tr><td><p><strong>No IPsec security associations.</strong></p></td></tr>
136 5b237745 Scott Ullrich
<?php endif; ?>
137 c55a8ab9 Holger Bauer
<td colspan="4">
138
		      <p><span class="vexpl"><span class="red"><strong>Note:<br>
139 6ec0830d Simon Cornelius P Umacob
                      </strong></span>You can configure your IPsec <a href="vpn_ipsec.php">here</a>.</span></p>
140 c55a8ab9 Holger Bauer
		  </td>
141 0f10aee4 Bill Marquette
</table>
142 12af52d9 Scott Ullrich
</div>
143 c55a8ab9 Holger Bauer
144
</td></tr>
145
146
</table>
147 fda1fdae Scott Ullrich
148 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
149
</body>
150
</html>