Annotation of embedaddon/strongswan/src/libcharon/plugins/vici/perl/Vici-Session/lib/Vici/Session.pm, revision 1.1.1.1

1.1       misho       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 rekey {
                     40:     return request_vars_res('rekey', @_);
                     41: }
                     42: 
                     43: sub redirect {
                     44:     return request_vars_res('redirect', @_);
                     45: }
                     46: 
                     47: sub install {
                     48:     return request_vars_res('install', @_);
                     49: }
                     50: 
                     51: sub uninstall {
                     52:     return request_vars_res('uninstall', @_);
                     53: }
                     54: 
                     55: sub list_sas {
                     56:     return request_list('list-sas', 'list-sa', @_);
                     57: }
                     58: 
                     59: sub list_policies {
                     60:     return request_list('list-policies', 'list-policy', @_);
                     61: }
                     62: 
                     63: sub list_conns {
                     64:     return request_list('list-conns', 'list-conn', @_);
                     65: }
                     66: 
                     67: sub get_conns {
                     68:     return request('get-conns', @_);
                     69: }
                     70: 
                     71: sub list_certs {
                     72:     return request_list('list-certs', 'list-cert', @_);
                     73: }
                     74: 
                     75: sub list_authorities {
                     76:     return request_list('list-authorities', 'list-authority', @_);
                     77: }
                     78: 
                     79: sub get_authorities {
                     80:     return request('get-authorities', @_);
                     81: }
                     82: 
                     83: sub load_conn {
                     84:     return request_vars_res('load-conn', @_);
                     85: }
                     86: 
                     87: sub unload_conn {
                     88:     return request_vars_res('unload-conn', @_);
                     89: }
                     90: 
                     91: sub load_cert {
                     92:     return request_vars_res('load-cert', @_);
                     93: }
                     94: 
                     95: sub load_key {
                     96:     return request_vars('load-key', @_);
                     97: }
                     98: 
                     99: sub unload_key {
                    100:     return request_vars_res('unload-key', @_);
                    101: }
                    102: 
                    103: sub get_keys {
                    104:     return request('get-keys', @_);
                    105: }
                    106: 
                    107: sub load_token {
                    108:     return request_vars('load-token', @_);
                    109: }
                    110: 
                    111: sub load_shared {
                    112:     return request_vars_res('load-shared', @_);
                    113: }
                    114: 
                    115: sub unload_shared {
                    116:     return request_vars_res('unload-shared', @_);
                    117: }
                    118: 
                    119: sub get_shared {
                    120:     return request('get-shared', @_);
                    121: }
                    122: 
                    123: sub flush_certs {
                    124:     return request_vars_res('flush-certs', @_);
                    125: }
                    126: 
                    127: sub clear_creds {
                    128:     return request_res('clear-creds', @_);
                    129: }
                    130: 
                    131: sub load_authority {
                    132:     return request_vars_res('load-authority', @_);
                    133: }
                    134: 
                    135: sub unload_authority {
                    136:     return request_vars_res('unload-authority', @_);
                    137: }
                    138: 
                    139: sub load_pool {
                    140:     return request_vars_res('load-pool', @_);
                    141: }
                    142: 
                    143: sub unload_pool {
                    144:     return request_vars_res('unload-pool', @_);
                    145: }
                    146: 
                    147: sub get_pools {
                    148:     return request('get-pools', @_);
                    149: }
                    150: 
                    151: sub get_algorithms {
                    152:     return request('get-algorithms', @_);
                    153: }
                    154: 
                    155: sub get_counters {
                    156:     return request_vars('get-counters', @_);
                    157: }
                    158: 
                    159: sub reset_counters {
                    160:     return request_vars_res('reset-counters', @_);
                    161: }
                    162: 
                    163: # Private functions
                    164: 
                    165: sub request {
                    166:     my ($command, $self) = @_;
                    167:     return $self->{'Packet'}->request($command);
                    168: }
                    169: 
                    170: sub request_vars {
                    171:     my ($command, $self, $vars) = @_;
                    172:     return $self->{'Packet'}->request($command, $vars);
                    173: }
                    174: 
                    175: sub request_res {
                    176:     my ($command, $self) = @_;
                    177:     my $msg = $self->{'Packet'}->request($command);
                    178:     return $msg->result();
                    179: }
                    180: 
                    181: sub request_vars_res {
                    182:     my ($command, $self, $vars) = @_;
                    183:     my $msg = $self->{'Packet'}->request($command, $vars);
                    184:     return $msg->result();
                    185: }
                    186: 
                    187: sub request_list {
                    188:     my ($command, $event, $self, $vars) = @_;
                    189:     return $self->{'Packet'}->streamed_request($command, $event, $vars);
                    190: }
                    191: 
                    192: 1;
                    193: __END__
                    194: =head1 NAME
                    195: 
                    196: Vici::Session - Perl binding for the strongSwan VICI configuration interface
                    197: 
                    198: =head1 SYNOPSIS
                    199: 
                    200: use Vici::Session;
                    201: 
                    202: =head1 DESCRIPTION
                    203: 
                    204: The Vici::Session module allows a Perl script to communicate with the open
                    205: source strongSwan IPsec daemon (https://www.strongswan.com) via the documented
                    206: Versatile IKE Configuration Interface (VICI). VICI allows the configuration,
                    207: management and monitoring of multiple IPsec connections.
                    208: 
                    209: =head2 EXPORT
                    210: 
                    211: None by default.
                    212: 
                    213: =head1 SEE ALSO
                    214: 
                    215: strongSwan Wiki:  https://wiki.strongswan.org/projects/strongswan/wiki/Vici
                    216: 
                    217: strongSwan Mailing list:  users@lists.strongswan.org
                    218: 
                    219: =head1 AUTHOR
                    220: 
                    221: Andreas Steffen, E<lt>andreas.steffen@strongswan.orgE<gt>
                    222: 
                    223: =head1 COPYRIGHT AND LICENSE
                    224: 
                    225: Copyright (C) 2015 by Andreas Steffen
                    226: 
                    227: Permission is hereby granted, free of charge, to any person obtaining a copy
                    228: of this software and associated documentation files (the "Software"), to deal
                    229: in the Software without restriction, including without limitation the rights
                    230: to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
                    231: copies of the Software, and to permit persons to whom the Software is
                    232: furnished to do so, subject to the following conditions:
                    233: 
                    234: The above copyright notice and this permission notice shall be included in
                    235: all copies or substantial portions of the Software.
                    236: 
                    237: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
                    238: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
                    239: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
                    240: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
                    241: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
                    242: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
                    243: THE SOFTWARE.
                    244: 
                    245: =cut

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>