Project

General

Profile

« Previous | Next » 

Revision a93e56c5

Added by Matthew Grooms almost 17 years ago

Overhaul IPsec related code. Shared functions have been consolidated into
a new file named /etc/ipsec.inc. Tunnel definitions have been split into
phase1 and phase2. This allows any number of phase2 definitions to be
created for a single phase1 definition. Several facets of configuration
have also been improved. The key size for variable length algorithms can
now be selected and the phase1 ID options have been extended to allow for
more flexible configuration. Several NAT-T related issues have also been
resolved.

Please note, IPsec remote access functionality has been temporarily
disabled. An improved implementation will be included in a follow up
commit.

View differences:

usr/local/www/diag_ipsec_sad.php
33 33

  
34 34
require("guiconfig.inc");
35 35

  
36
$pgtitle = array("Status","IPsec","SA");
36
$pgtitle = array("Status","IPsec","SAD");
37 37
include("head.inc");
38 38

  
39
?>
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
<?php
46
	$tab_array = array();
47
	$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
	display_top_tabs($tab_array);
51
?>
52
  </td></tr>
53
  <tr>
54
    <td>
55
<?php
39
$sad = ipsec_dump_sad();
56 40

  
57 41
/* delete any SA? */
58 42
if ($_GET['act'] == "del") {
59
	$fd = @popen("/sbin/setkey -c > /dev/null 2>&1", "w");
43
	$fd = @popen("/usr/local/sbin/setkey -c > /dev/null 2>&1", "w");
60 44
	if ($fd) {
61 45
		fwrite($fd, "delete {$_GET['src']} {$_GET['dst']} {$_GET['proto']} {$_GET['spi']} ;\n");
62 46
		pclose($fd);
......
64 48
	}
65 49
}
66 50

  
67
/* query SAD */
68
$fd = @popen("/sbin/setkey -D", "r");
69
$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 51
?>
101
	<div id="mainarea">
102
            <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
103
<?php if (count($sad)): ?>
104
  <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
		  <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
		</td>
131

  
132
	</tr>
133
<?php endforeach; ?>
134
<?php else: ?>
135
<tr><td><p><strong>No IPsec security associations.</strong></p></td></tr>
136
<?php endif; ?>
137
<td colspan="4">
138
		      <p><span class="vexpl"><span class="red"><strong>Note:<br>
139
                      </strong></span>You can configure your IPsec <a href="vpn_ipsec.php">here</a>.</span></p>
140
		  </td>
141
</table>
142
</div>
143 52

  
144
</td></tr>
145

  
146
</table>
147

  
148
<?php include("fend.inc"); ?>
53
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
54
	<?php include("fbegin.inc"); ?>
55
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
56
		<tr>
57
			<td>
58
				<?php
59
					$tab_array = array();
60
					$tab_array[0] = array("Overview", false, "diag_ipsec.php");
61
					$tab_array[1] = array("SAD", true, "diag_ipsec_sad.php");
62
					$tab_array[2] = array("SPD", false, "diag_ipsec_spd.php");
63
					display_top_tabs($tab_array);
64
				?>
65
			</td>
66
		</tr>
67
		<tr>
68
			<td>
69
				<div id="mainarea">
70
					<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
71
						<?php if (count($sad)): ?>
72
						<tr>
73
							<td nowrap class="listhdrr">Source</td>
74
							<td nowrap class="listhdrr">Destination</a></td>
75
							<td nowrap class="listhdrr">Protocol</td>
76
							<td nowrap class="listhdrr">SPI</td>
77
							<td nowrap class="listhdrr">Enc. alg.</td>
78
							<td nowrap class="listhdr">Auth. alg.</td>
79
							<td nowrap class="list"></td>
80
						</tr>
81
						<?php foreach ($sad as $sa): ?>
82
						<tr>
83
							<td class="listlr"><?=htmlspecialchars($sa['src']);?></td>
84
							<td class="listr"><?=htmlspecialchars($sa['dst']);?></td>
85
							<td class="listr"><?=htmlspecialchars(strtoupper($sa['proto']));?></td>
86
							<td class="listr"><?=htmlspecialchars($sa['spi']);?></td>
87
							<td class="listr"><?=htmlspecialchars($sa['ealgo']);?></td>
88
							<td class="listr"><?=htmlspecialchars($sa['aalgo']);?></td>
89
							<td class="list" nowrap>
90
								<?php
91
									$args = "src=" . rawurlencode($sa['src']);
92
									$args .= "&dst=" . rawurlencode($sa['dst']);
93
									$args .= "&proto=" . rawurlencode($sa['proto']);
94
									$args .= "&spi=" . rawurlencode("0x" . $sa['spi']);
95
								?>
96
								<a href="diag_ipsec_sad.php?act=del&<?=$args;?>" onclick="return confirm('Do you really want to delete this security association?')">
97
									<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0">
98
								</a>
99
							</td>
100
						</tr>
101
						<?php endforeach; ?>
102
						<?php else: ?>
103
						<tr>
104
							<td>
105
								<p><strong>No IPsec security associations.</strong></p>
106
							</td>
107
						</tr>
108
						<?php endif; ?>
109
						<td colspan="4">
110
							<p>
111
								<span class="vexpl">
112
									<span class="red">
113
										<strong>Note:<br></strong>
114
									</span>
115
									You can configure your IPsec <a href="vpn_ipsec.php">here</a>.
116
								</span>
117
							</p>
118
						</td>
119
					</table>
120
				</div>
121
			</td>
122
		</tr>
123
	</table>
124
	<?php include("fend.inc"); ?>
149 125
</body>
150 126
</html>

Also available in: Unified diff