vici: flush-certs command flushes certificate cache
[strongswan.git] / src / libcharon / plugins / vici / perl / Vici-Session / lib / Vici / Session.pm
1 package Vici::Session;
2
3 our $VERSION = '0.9';
4
5 use strict;
6 use Vici::Packet;
7 use Vici::Message;
8
9 sub new {
10 my $class = shift;
11 my $socket = shift;
12 my $self = {
13 Packet => Vici::Packet->new($socket),
14 };
15 bless($self, $class);
16 return $self;
17 }
18
19 sub version {
20 return request('version', @_);
21 }
22
23 sub stats {
24 return request('stats', @_);
25 }
26
27 sub reload_settings {
28 return request_res('reload-settings', @_);
29 }
30
31 sub initiate {
32 return request_vars_res('initiate', @_);
33 }
34
35 sub terminate {
36 return request_vars_res('terminate', @_);
37 }
38
39 sub redirect {
40 return request_vars_res('redirect', @_);
41 }
42
43 sub install {
44 return request_vars_res('install', @_);
45 }
46
47 sub uninstall {
48 return request_vars_res('uninstall', @_);
49 }
50
51 sub list_sas {
52 return request_list('list-sas', 'list-sa', @_);
53 }
54
55 sub list_policies {
56 return request_list('list-policies', 'list-policy', @_);
57 }
58
59 sub list_conns {
60 return request_list('list-conns', 'list-conn', @_);
61 }
62
63 sub get_conns {
64 return request('get-conns', @_);
65 }
66
67 sub list_certs {
68 return request_list('list-certs', 'list-cert', @_);
69 }
70
71 sub list_authorities {
72 return request_list('list-authorities', 'list-authority', @_);
73 }
74
75 sub get_authorities {
76 return request('get-authorities', @_);
77 }
78
79 sub load_conn {
80 return request_vars_res('load-conn', @_);
81 }
82
83 sub unload_conn {
84 return request_vars_res('unload-conn', @_);
85 }
86
87 sub load_cert {
88 return request_vars_res('load-cert', @_);
89 }
90
91 sub load_key {
92 return request_vars_res('load-key', @_);
93 }
94
95 sub load_shared {
96 return request_vars_res('load-shared', @_);
97 }
98
99 sub flush_certs {
100 return request_vars_res('flush-certs', @_);
101 }
102
103 sub clear_creds {
104 return request_res('clear-creds', @_);
105 }
106
107 sub load_authority {
108 return request_vars_res('load-authority', @_);
109 }
110
111 sub unload_authority {
112 return request_vars_res('unload-authority', @_);
113 }
114
115 sub load_pool {
116 return request_vars_res('load-pool', @_);
117 }
118
119 sub unload_pool {
120 return request_vars_res('unload-pool', @_);
121 }
122
123 sub get_pools {
124 return request('get-pools', @_);
125 }
126
127 sub get_algorithms {
128 return request('get-algorithms', @_);
129 }
130
131 # Private functions
132
133 sub request {
134 my ($command, $self) = @_;
135 return $self->{'Packet'}->request($command);
136 }
137
138 sub request_res {
139 my ($command, $self) = @_;
140 my $msg = $self->{'Packet'}->request($command);
141 return $msg->result();
142 }
143
144 sub request_vars_res {
145 my ($command, $self, $vars) = @_;
146 my $msg = $self->{'Packet'}->request($command, $vars);
147 return $msg->result();
148 }
149
150 sub request_list {
151 my ($command, $event, $self, $vars) = @_;
152 return $self->{'Packet'}->streamed_request($command, $event, $vars);
153 }
154
155 1;
156 __END__
157 =head1 NAME
158
159 Vici::Session - Perl binding for the strongSwan VICI configuration interface
160
161 =head1 SYNOPSIS
162
163 use Vici::Session;
164
165 =head1 DESCRIPTION
166
167 The Vici::Session module allows a Perl script to communicate with the open
168 source strongSwan IPsec daemon (https://www.strongswan.com) via the documented
169 Versatile IKE Configuration Interface (VICI). VICI allows the configuration,
170 management and monitoring of multiple IPsec connections.
171
172 =head2 EXPORT
173
174 None by default.
175
176 =head1 SEE ALSO
177
178 strongSwan Wiki: https://wiki.strongswan.org/projects/strongswan/wiki/Vici
179
180 strongSwan Mailing list: users@lists.strongswan.org
181
182 =head1 AUTHOR
183
184 Andreas Steffen, E<lt>andreas.steffen@strongswan.orgE<gt>
185
186 =head1 COPYRIGHT AND LICENSE
187
188 Copyright (C) 2015 by Andreas Steffen
189
190 Permission is hereby granted, free of charge, to any person obtaining a copy
191 of this software and associated documentation files (the "Software"), to deal
192 in the Software without restriction, including without limitation the rights
193 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
194 copies of the Software, and to permit persons to whom the Software is
195 furnished to do so, subject to the following conditions:
196
197 The above copyright notice and this permission notice shall be included in
198 all copies or substantial portions of the Software.
199
200 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
201 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
202 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
203 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
204 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
205 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
206 THE SOFTWARE.
207
208 =cut