Projet

Général

Profil

Télécharger (2,7 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / diag_ipsec_xml.php @ fe12d7ea

1
<?php
2
/* $Id$ */
3
/*
4
	diag_ipsec_xml.php
5
	Copyright (C) 2007 pfSense Project
6
	Copyright (C) 2010 Seth Mos
7
	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
##|+PRIV
35
##|*IDENT=page-ipsecxml
36
##|*NAME=Diag IPsec XML page
37
##|*DESCR=Allow access to the 'Diag IPsec XML' page.
38
##|*MATCH=diag_ipsec_xml.php
39
##|-PRIV
40

    
41
global $g;
42

    
43
require("guiconfig.inc");
44
require("ipsec.inc");
45

    
46
if (!is_array($config['ipsec']['phase2']))
47
    $config['ipsec']['phase2'] = array();
48

    
49
$ipsec_status = array();
50

    
51
$a_phase2 = &$config['ipsec']['phase2'];
52

    
53
$status = ipsec_smp_dump_status();
54

    
55
if (is_array($status['query']) && $status['query']['ikesalist'] && $status['query']['ikesalist']['ikesa'])) {
56
	foreach ($a_phase2 as $ph2ent) {
57
		ipsec_lookup_phase1($ph2ent,$ph1ent);
58
		$tunnel = array();
59
		if (!isset($ph2ent['disabled']) && !isset($ph1ent['disabled'])) {
60
			if(ipsec_phase1_status($status['query']['ikesalist']['ikesa'], $ph1ent['ikeid']))
61
				$tunnel['state'] = "up";
62
			elseif(!isset($config['ipsec']['enable']))
63
				$tunnel['state'] = "disabled";
64
			else
65
				$tunnel['state'] = "down";
66

    
67
			$tunnel['src'] = ipsec_get_phase1_src($ph1ent);
68
			$tunnel['endpoint'] = $ph1ent['remote-gateway'];
69
			$tunnel['local'] = ipsec_idinfo_to_text($ph2ent['localid']);
70
			$tunnel['remote'] = ipsec_idinfo_to_text($ph2ent['remoteid']);
71
			$tunnel['name'] = "{$ph2ent['descr']}";
72
			$ipsec_status['tunnel'][] = $tunnel;
73
		}
74
	}
75
}
76

    
77
$listtags = array("tunnel");
78
$xml = dump_xml_config($ipsec_status, "ipsec");
79

    
80
echo $xml;
81
?>
(17-17/255)