Project

General

Profile

Download (5.31 KB) Statistics
| Branch: | Tag: | Revision:
1 cf7d1057 Scott Ullrich
<?php
2
/* $Id$ */
3
/*
4
	diag_ipsec.php
5 13d193c2 Scott Ullrich
	Copyright (C) 2004-2009 Scott Ullrich
6 a93e56c5 Matthew Grooms
	Copyright (C) 2008 Shrew Soft Inc <mgrooms@shrew.net>.
7 cf7d1057 Scott Ullrich
	All rights reserved.
8
9
	Parts of this code was originally based on vpn_ipsec_sad.php
10
	Copyright (C) 2003-2004 Manuel Kasper
11
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17
18
	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
22
	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 13d193c2 Scott Ullrich
/*
35
	pfSense_MODULE:	ipsec
36
*/
37
38 6b07c15a Matthew Grooms
##|+PRIV
39
##|*IDENT=page-status-ipsec
40
##|*NAME=Status: IPsec page
41
##|*DESCR=Allow access to the 'Status: IPsec' page.
42
##|*MATCH=diag_ipsec.php*
43
##|-PRIV
44
45
46 a93e56c5 Matthew Grooms
global $g;
47
48 f8ec8de4 Renato Botelho
$pgtitle = array(gettext("Status"),gettext("IPsec"));
49 cf7d1057 Scott Ullrich
50
require("guiconfig.inc");
51
include("head.inc");
52 483e6de8 Scott Ullrich
require("ipsec.inc");
53 a93e56c5 Matthew Grooms
54 6e8b0ec3 jim-p
if ($_GET['act'] == "connect") {
55
	if (is_ipaddr($_GET['remoteid']) && is_ipaddr($_GET['source'])) {
56
		exec("/sbin/ping -S " . escapeshellarg($_GET['source']) . " -c 1 " . escapeshellarg($_GET['remoteid']));
57
	}
58
}
59
60 a93e56c5 Matthew Grooms
if (!is_array($config['ipsec']['phase2']))
61
    $config['ipsec']['phase2'] = array();
62
63
$a_phase2 = &$config['ipsec']['phase2'];
64
65
$spd = ipsec_dump_spd();
66
$sad = ipsec_dump_sad();
67
68 cf7d1057 Scott Ullrich
?>
69
70
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
71
<?php include("fbegin.inc"); ?>
72
<div id="inputerrors"></div>
73
<table width="100%" border="0" cellpadding="0" cellspacing="0">
74
	<tr>
75 a93e56c5 Matthew Grooms
		<td>
76
			<?php
77
				$tab_array = array();
78 f8ec8de4 Renato Botelho
				$tab_array[0] = array(gettext("Overview"), true, "diag_ipsec.php");
79
				$tab_array[1] = array(gettext("SAD"), false, "diag_ipsec_sad.php");
80
				$tab_array[2] = array(gettext("SPD"), false, "diag_ipsec_spd.php");
81
				$tab_array[3] = array(gettext("Logs"), false, "diag_logs_ipsec.php");
82 a93e56c5 Matthew Grooms
				display_top_tabs($tab_array);
83
			?>
84 331aa57b Scott Ullrich
		</td>
85 cf7d1057 Scott Ullrich
	</tr>
86 a93e56c5 Matthew Grooms
	<tr>
87
    	<td>
88
			<div id="mainarea">
89 034b4918 Scott Ullrich
				<table width="100%" border="0" cellpadding="6" cellspacing="0" class="tabcont sortable">
90 a93e56c5 Matthew Grooms
					<tr>
91 f8ec8de4 Renato Botelho
						<td nowrap class="listhdrr"><?=gettext("Local IP");?></td>
92
						<td nowrap class="listhdrr"><?=gettext("Remote IP");?></a></td>
93
						<td nowrap class="listhdrr"><?=gettext("Local Network");?></td>
94
						<td nowrap class="listhdrr"><?=gettext("Remote Network");?></a></td>
95
						<td nowrap class="listhdrr"><?=gettext("Description");?></a></td>
96
						<td nowrap class="listhdrr"><?=gettext("Status");?></td>
97 a93e56c5 Matthew Grooms
					</tr>
98
					<?php
99
						foreach ($a_phase2 as $ph2ent) {
100 221f5d17 Chris Buechler
							ipsec_lookup_phase1($ph2ent,$ph1ent);
101
							if (!isset($ph2ent['disabled']) && !isset($ph1ent['disabled'])) {
102 a93e56c5 Matthew Grooms
								if(ipsec_phase2_status($spd,$sad,$ph1ent,$ph2ent))
103
									$icon = "pass";
104 b385327a Chris Buechler
								elseif(!isset($config['ipsec']['enable']))
105
									$icon = "block";
106 a93e56c5 Matthew Grooms
								else
107
									$icon = "reject";
108
					?>
109
					<tr>
110
						<td class="listlr">
111
							<?=htmlspecialchars(ipsec_get_phase1_src($ph1ent));?>
112
						</td>
113
						<td class="listr">
114
							<?=htmlspecialchars($ph1ent['remote-gateway']);?>
115
						</td>
116
						<td class="listr">
117
							<?php echo ipsec_idinfo_to_text($ph2ent['localid']); ?>
118
						</td>
119
						<td class="listr">
120
							<?php echo ipsec_idinfo_to_text($ph2ent['remoteid']); ?>
121
						</td>
122
						<td class="listr"><?=htmlspecialchars($ph2ent['descr']);?></td>
123
						<td class="listr">
124 ba363183 Scott Ullrich
							<center>
125
								<img src ="/themes/<?=$g['theme']?>/images/icons/icon_<?=$icon?>.gif">
126
							</center>
127 a93e56c5 Matthew Grooms
						</td>
128 6e8b0ec3 jim-p
						<td class="list">
129
							<?php
130
							$source = "";
131
							if ($ph2ent['localid']['type'] == 'lan') {
132
								$source = get_interface_ip('lan');
133
							} else {
134
								$source = get_interface_ip(find_ip_interface($ph2ent['localid']['address']));
135
							}
136
137
							?>
138
							<?php if (($ph2ent['remoteid']['type'] != "mobile") && ($icon != "pass") && ($source != "")): ?>
139
							<center>
140
								<a href="diag_ipsec.php?act=connect&remoteid=<?= $ph2ent['remoteid']['address'] ?>&source=<?= $source ?>">
141
								<img src ="/themes/<?=$g['theme']?>/images/icons/icon_service_start.gif" alt="Connect VPN" title="Connect VPN" border="0">
142
								</a>
143
							</center>
144
							<?php else: ?>
145
								&nbsp;
146
							<?php endif; ?>
147
						</td>
148 a93e56c5 Matthew Grooms
					</tr>
149
					<?php
150
							}
151
						}
152
					?>
153
				</table>
154
			</div>
155 cf7d1057 Scott Ullrich
		</td>
156 a93e56c5 Matthew Grooms
	</tr>
157 cf7d1057 Scott Ullrich
</table>
158
159 0f78d3ad Scott Ullrich
<p/>
160
161
<span class="vexpl">
162
	<span class="red">
163 89a24955 Carlos Eduardo Ramos
		<strong><?=gettext("Note:");?><br /></strong>
164 0f78d3ad Scott Ullrich
	</span>
165 f8ec8de4 Renato Botelho
	<?=gettext("You can configure your IPsec");?> 
166 0f78d3ad Scott Ullrich
	<a href="vpn_ipsec.php">here</a>.
167
</span>
168
169 cf7d1057 Scott Ullrich
<?php include("fend.inc"); ?>
170
</body>
171
</html>