Revision 63253e04
Added by Renato Botelho almost 10 years ago
usr/local/www/diag_ipsec_xml.php | ||
---|---|---|
1 |
<?php |
|
2 |
/* $Id$ */ |
|
3 |
/* |
|
4 |
diag_ipsec_xml.php |
|
5 |
Copyright (C) 2007 pfSense Project |
|
6 |
Copyright (C) 2010 Seth Mos |
|
7 |
Copyright (C) 2013-2015 Electric Sheep Fencing, LP |
|
8 |
All rights reserved. |
|
9 |
|
|
10 |
Parts of this code was originally based on vpn_ipsec_sad.php |
|
11 |
Copyright (C) 2003-2004 Manuel Kasper |
|
12 |
|
|
13 |
Redistribution and use in source and binary forms, with or without |
|
14 |
modification, are permitted provided that the following conditions are met: |
|
15 |
|
|
16 |
1. Redistributions of source code must retain the above copyright notice, |
|
17 |
this list of conditions and the following disclaimer. |
|
18 |
|
|
19 |
2. Redistributions in binary form must reproduce the above copyright |
|
20 |
notice, this list of conditions and the following disclaimer in the |
|
21 |
documentation and/or other materials provided with the distribution. |
|
22 |
|
|
23 |
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
24 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
|
25 |
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
26 |
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, |
|
27 |
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
28 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
29 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
30 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
31 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
32 |
POSSIBILITY OF SUCH DAMAGE. |
|
33 |
*/ |
|
34 |
|
|
35 |
##|+PRIV |
|
36 |
##|*IDENT=page-ipsecxml |
|
37 |
##|*NAME=Diag IPsec XML page |
|
38 |
##|*DESCR=Allow access to the 'Diag IPsec XML' page. |
|
39 |
##|*MATCH=diag_ipsec_xml.php |
|
40 |
##|-PRIV |
|
41 |
|
|
42 |
global $g; |
|
43 |
|
|
44 |
require("guiconfig.inc"); |
|
45 |
require("ipsec.inc"); |
|
46 |
|
|
47 |
if (!is_array($config['ipsec']['phase2'])) |
|
48 |
$config['ipsec']['phase2'] = array(); |
|
49 |
|
|
50 |
$ipsec_status = array(); |
|
51 |
|
|
52 |
$a_phase2 = &$config['ipsec']['phase2']; |
|
53 |
|
|
54 |
$status = ipsec_smp_dump_status(); |
|
55 |
|
|
56 |
if (is_array($status['query']) && $status['query']['ikesalist'] && $status['query']['ikesalist']['ikesa']) { |
|
57 |
foreach ($a_phase2 as $ph2ent) { |
|
58 |
ipsec_lookup_phase1($ph2ent,$ph1ent); |
|
59 |
$tunnel = array(); |
|
60 |
if (!isset($ph2ent['disabled']) && !isset($ph1ent['disabled'])) { |
|
61 |
if(ipsec_phase1_status($status['query']['ikesalist']['ikesa'], $ph1ent['ikeid'])) |
|
62 |
$tunnel['state'] = "up"; |
|
63 |
elseif(!isset($config['ipsec']['enable'])) |
|
64 |
$tunnel['state'] = "disabled"; |
|
65 |
else |
|
66 |
$tunnel['state'] = "down"; |
|
67 |
|
|
68 |
$tunnel['src'] = ipsec_get_phase1_src($ph1ent); |
|
69 |
$tunnel['endpoint'] = $ph1ent['remote-gateway']; |
|
70 |
$tunnel['local'] = ipsec_idinfo_to_text($ph2ent['localid']); |
|
71 |
$tunnel['remote'] = ipsec_idinfo_to_text($ph2ent['remoteid']); |
|
72 |
$tunnel['name'] = "{$ph2ent['descr']}"; |
|
73 |
$ipsec_status['tunnel'][] = $tunnel; |
|
74 |
} |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
$listtags = array("tunnel"); |
|
79 |
$xml = dump_xml_config($ipsec_status, "ipsec"); |
|
80 |
|
|
81 |
echo $xml; |
|
82 |
?> |
Also available in: Unified diff
Remove diag_ipsec_xml.php, not being used