1 # The Versatile IKE Control Interface (VICI) protocol #
3 The vici _[ˈvitʃi]_ plugin implements the server side of an IPC protocol to
4 configure, monitor and control the IKE daemon charon. It uses request/response
5 and event messages to communicate over a reliable stream based transport.
7 ## Transport protocol ##
9 To provide the service, the plugin opens a listening socket using a reliable,
10 stream based transport. charon relies on the different stream service
11 abstractions provided by libstrongswan, such as TCP and UNIX sockets.
13 A client connects to this service to access functionality. It may send an
14 arbitrary number of packets over the connection before closing it.
16 To exchange data, the transport protocol is segmented into byte sequences.
17 Each byte sequence is prefixed by a 32-bit length header in network order,
18 followed by the data. The maximum segment length is currently limited to 512KB
19 of data, and the length field contains the length of the data only, not
20 including the length field itself.
22 The order of byte sequences must be strict, byte sequences must arrive in the
27 Within the byte sequences defined by the transport layer, both the client
28 and the server can exchange packets. The type of packet defines its structure
29 and purpose. The packet type is a 8-bit identifier, and is the first byte
30 in a transport layer byte sequence. The length of the packet is given by the
33 While a packet type may define the format of the wrapped data freely, currently
34 all types either contain a name, a message or both. The following packet types
35 are currently defined:
37 * _CMD_REQUEST = 0_: A named request message
38 * _CMD_RESPONSE = 1_: An unnamed response message for a request
39 * _CMD_UNKNOWN = 2_: An unnamed response if requested command is unknown
40 * _EVENT_REGISTER = 3_: A named event registration request
41 * _EVENT_UNREGISTER = 4_: A named event deregistration request
42 * _EVENT_CONFIRM = 5_: An unnamed response for successful event (de-)registration
43 * _EVENT_UNKNOWN = 6_: A unnamed response if event (de-)registration failed
44 * _EVENT = 7_: A named event message
46 For packets having a named type, after the packet type an 8-bit length header
47 of the name follows, indicating the string length in bytes of the name tag, not
48 including the length field itself. The name is an ASCII string that is not
51 The rest of the packet forms the exchanged message, the length is determined
52 by the transport byte sequence length, subtracting the packet type and
53 the optional name tag in some messages.
57 Commands are currently always requested by the client. The server replies with
58 a response, or with a CMD_UNKNOWN failure message to let the client know
59 that it does not have a handler for such a command. There is no sequence number
60 to associate responses to requests, so only one command can be active at
61 a time on a single connection.
65 To receive event messages, the client explicitly registers for events by name,
66 and also unregisters if it does not want to receive events of the named kind
67 anymore. The server confirms event registration using EVENT_CONFIRM, or
68 indicates that there is no such event source with EVENT_UNKNOWN.
70 Events may get raised at any time while registered, even during an active
71 request command. This mechanism is used to feed continuous data during a request,
76 The defined packet types optionally wrap a message with additional data.
77 Messages are currently used in CMD_REQUEST/CMD_RESPONSE, and in EVENT packets.
78 A message uses a hierarchical tree of sections. Each section (or the implicit
79 root section) contains an arbitrary set of key/value pairs, lists and
80 sub-sections. The length of a message is not part of the message itself, but
81 the wrapping layer, usually calculated from the transport byte sequence length.
83 The message encoding consists of a sequence of elements. Each element starts
84 with the element type, optionally followed by an element name and/or an element
85 value. Currently the following message element types are defined:
87 * _SECTION_START = 1_: Begin a new section having a name
88 * _SECTION_END = 2_: End a previously started section
89 * _KEY_VALUE = 3_: Define a value for a named key in the current section
90 * _LIST_START = 4_: Begin a named list for list items
91 * _LIST_ITEM = 5_: Define an unnamed item value in the current list
92 * _LIST_END = 6_: End a previously started list
94 Types are encoded as 8-bit values. Types having a name (SECTION_START,
95 KEY_VALUE and LIST_START) have an ASCII string following the type, which itself
96 uses an 8-bit length header. The string must not be null-terminated, the string
97 length does not include the length field itself.
99 Types having a value (KEY_VALUE and LIST_ITEM) have a raw blob sequence,
100 prefixed with a 16-bit network order length. The blob follows the type or the
101 name tag if available, the length defined by the length field does not include
102 the length field itself.
104 The interpretation of any value is not defined by the message format; it can
105 take arbitrary blobs. The application may specify types for specific keys, such
106 as strings or integer representations. The vici plugin currently uses
107 non-null terminated strings as values only; numbers get encoded as strings.
111 Sections may be opened in the implicit root section, or any previously section.
112 They can be nested to arbitrary levels. A SECTION_END marker always closes
113 the last opened section; SECTION_START and SECTION_END items must be balanced
118 Key/Value pair elements may appear in the implicit root section or any explicit
119 sub-section at any level. Key names must be unique in the current section, use
120 lists to define multiple values for a key. Key/values may not appear in lists,
121 use a sub-section instead.
125 Lists may appear at the same locations as Key/Values, and may not be nested.
126 Only a single list may be opened at the same time, and all lists must be closed
127 in valid messages. After opening a list, only list items may appear before the
128 list closing element. Empty lists are allowed, list items may appear within
131 ### Encoding example ###
133 Consider the following structure using pseudo-markup for this example:
140 list1 = [ item1, item2 ]
143 The example above represents a valid tree structure, that gets encoded as
144 the following C array:
148 3, 4,'k','e','y','1', 0,6,'v','a','l','u','e','1',
150 1, 8,'s','e','c','t','i','o','n','1',
152 1, 11,'s','u','b','-','s','e','c','t','i','o','n',
154 3, 4,'k','e','y','2', 0,6,'v','a','l','u','e','2',
155 /* sub-section end */
158 4, 5, 'l','i','s','t','1',
160 5, 0,5,'i','t','e','m','1',
162 5, 0,5,'i','t','e','m','2',
169 ## Client-initiated commands ##
171 Based on the packet layer, VICI implements commands requested by the client
172 and responded to by the server using named _CMD_REQUEST_ and _CMD_RESPONSE_
173 packets wrapping messages. The request message may contain command arguments,
174 the response message the reply.
176 Some commands use response streaming, that is, a request triggers a series of
177 events to consecutively stream data to the client before the response message
178 completes the stream. A client must register for the appropriate event to
179 receive the stream, and unregister after the response has been received.
181 The following client issued commands with the appropriate command input and
182 output messages are currently defined:
186 Returns daemon and system specific version information.
189 daemon = <IKE daemon name>
190 version = <strongSwan version>
191 sysname = <operating system name>
192 release = <operating system release>
193 machine = <hardware identifier>
198 Returns IKE daemon statistics and load information.
202 running = <relative uptime in human-readable form>
203 since = <absolute startup time>
206 total = <total number of worker threads>
207 idle = <worker threads currently idle>
209 critical = <threads processing "critical" priority jobs>
210 high = <threads processing "high" priority jobs>
211 medium = <threads processing "medium" priority jobs>
212 low = <threads processing "low" priority jobs>
216 critical = <jobs queued with "critical" priority>
217 high = <jobs queued with "high" priority>
218 medium = <jobs queued with "medium" priority>
219 low = <jobs queued with "low" priority>
221 scheduled = <number of jobs scheduled for timed execution>
223 total = <total number of IKE_SAs active>
224 half-open = <number of IKE_SAs in half-open state>
227 <names of loaded plugins>
229 mem = { # available if built with leak-detective or on Windows
230 total = <total heap memory usage in bytes>
231 allocs = <total heap allocation blocks>
232 <heap-name>* = { # on Windows only
233 total = <heap memory usage in bytes by this heap>
234 allocs = <allocated blocks for this heap>
237 mallinfo = { # available with mallinfo() support
238 sbrk = <non-mmaped space available>
239 mmap = <mmaped space available>
240 used = <total number of bytes used>
241 free = <available but unused bytes>
245 ### reload-settings() ###
247 Reloads _strongswan.conf_ settings and all plugins supporting configuration
251 success = <yes or no>
252 errmsg = <error string on failure>
257 Initiates an SA while streaming _control-log_ events.
260 child = <CHILD_SA configuration name to initiate>
261 ike = <optional IKE_SA configuration name to find child under>
262 timeout = <timeout in ms before returning>
263 init-limits = <whether limits may prevent initiating the CHILD_SA>
264 loglevel = <loglevel to issue "control-log" events for>
266 success = <yes or no>
267 errmsg = <error string on failure or timeout>
270 The default timeout of 0 waits indefinitely for a result, and a timeout value
271 of -1 returns a result immediately.
275 Terminates an SA while streaming _control-log_ events.
278 child = <terminate a CHILD_SA by configuration name>
279 ike = <terminate an IKE_SA by configuration name>
280 child-id = <terminate a CHILD_SA by its reqid>
281 ike-id = <terminate an IKE_SA by its unique id>
282 force = <terminate IKE_SA without waiting for proper DELETE, if timeout
283 is given, waits for a response until it is reached>
284 timeout = <timeout in ms before returning, see below>
285 loglevel = <loglevel to issue "control-log" events for>
287 success = <yes or no>
288 matches = <number of matched SAs>
289 terminated = <number of terminated SAs>
290 errmsg = <error string on failure or timeout>
293 The default timeout of 0 waits indefinitely for a result, and a timeout value
294 of -1 returns a result immediately.
298 Initiate the rekeying of an SA.
301 child = <rekey a CHILD_SA by configuration name>
302 ike = <rekey an IKE_SA by configuration name>
303 child-id = <rekey a CHILD_SA by its reqid>
304 ike-id = <rekey an IKE_SA by its unique id>
305 reauth = <reauthenticate instead of rekey an IKEv2 SA>
307 success = <yes or no>
308 matches = <number of matched SAs>
309 errmsg = <error string on failure>
314 Redirect a client-initiated IKE_SA to another gateway. Only for IKEv2 and if
315 supported by the peer.
318 ike = <redirect an IKE_SA by configuration name>
319 ike-id = <redirect an IKE_SA by its unique id>
320 peer-ip = <redirect an IKE_SA with matching peer IP, may also be a
321 subnet in CIDR notation or an IP range>
322 peer-id = <redirect an IKE_SA with matching peer identity, may contain
325 success = <yes or no>
326 matches = <number of matched SAs>
327 errmsg = <error string on failure>
332 Install a trap, drop or bypass policy defined by a CHILD_SA config.
335 child = <CHILD_SA configuration name to install>
336 ike = <optional IKE_SA configuration name to find child under>
338 success = <yes or no>
339 errmsg = <error string on failure>
344 Uninstall a trap, drop or bypass policy defined by a CHILD_SA config.
347 child = <CHILD_SA configuration name to install>
348 ike = <optional IKE_SA configuration name to find child under,
349 if not given the first policy matching child is removed>
351 success = <yes or no>
352 errmsg = <error string on failure>
357 Lists currently active IKE_SAs and associated CHILD_SAs by streaming _list-sa_
361 noblock = <use non-blocking mode if key is set>
362 ike = <filter listed IKE_SAs by its name>
363 ike-id = <filter listed IKE_SA by its unique id>
365 # completes after streaming list-sa events
368 ### list-policies() ###
370 List currently installed trap, drop and bypass policies by streaming
371 _list-policy_ events.
374 drop = <set to yes to list drop policies>
375 pass = <set to yes to list bypass policies>
376 trap = <set to yes to list trap policies>
377 child = <filter by CHILD_SA configuration name>
378 ike = <filter by IKE_SA configuration name>
380 # completes after streaming list-sa events
385 List currently loaded connections by streaming _list-conn_ events. This
386 call includes all connections known by the daemon, not only those loaded
390 ike = <list connections matching a given configuration name only>
392 # completes after streaming list-conn events
397 Return a list of connection names loaded exclusively over vici, not including
398 connections found in other backends.
402 <list of connection names>
408 List currently loaded certificates by streaming _list-cert_ events. This
409 call includes all certificates known by the daemon, not only those loaded
413 type = <certificate type to filter for, X509|X509_AC|X509_CRL|
414 OCSP_RESPONSE|PUBKEY or ANY>
415 flag = <X.509 certificate flag to filter for, NONE|CA|AA|OCSP or ANY>
416 subject = <set to list only certificates having subject>
418 # completes after streaming list-cert events
421 ### list-authorities() ###
423 List currently loaded certification authority information by streaming
424 _list-authority_ events.
427 name = <list certification authority of a given name>
429 # completes after streaming list-authority events
432 ### get-authorities() ###
434 Return a list of currently loaded certification authority names.
438 <list of certification authority names>
444 Load a single connection definition into the daemon. An existing connection
445 with the same name gets updated or replaced.
448 <IKE_SA config name> = {
449 # IKE configuration parameters with authentication and CHILD_SA
450 # subsections. Refer to swanctl.conf(5) for details.
452 success = <yes or no>
453 errmsg = <error string on failure>
457 ### unload-conn() ###
459 Unload a previously loaded connection definition by name.
462 name = <IKE_SA config name>
464 success = <yes or no>
465 errmsg = <error string on failure>
470 Load a certificate into the daemon.
473 type = <certificate type, X509|X509_AC|X509_CRL>
474 flag = <X.509 certificate flag, NONE|CA|AA|OCSP>
475 data = <PEM or DER encoded certificate data>
477 success = <yes or no>
478 errmsg = <error string on failure>
483 Load a private key into the daemon.
486 type = <private key type, rsa|ecdsa|bliss|any>
487 data = <PEM or DER encoded key data>
489 success = <yes or no>
490 errmsg = <error string on failure>
491 id = <hex-encoded SHA-1 key identifier of the public key on success>
496 Unload the private key with the given key identifier.
499 id = <hex-encoded SHA-1 key identifier of the private key to unload>
501 success = <yes or no>
502 errmsg = <error string on failure>
507 Return a list of identifiers of private keys loaded exclusively over vici, not
508 including keys found in other backends.
512 <list of hex-encoded SHA-1 key identifiers>
518 Load a private key located on a token into the daemon. Such keys may be listed
519 and unloaded using the _get-keys_ and _unload-key_ commands, respectively (based
520 on the key identifier derived from the public key).
523 handle = <hex-encoded CKA_ID of the private key on token>
524 slot = <optional slot number>
525 module = <optional PKCS#11 module>
526 pin = <optional PIN to access the key, has to be provided via other
529 success = <yes or no>
530 errmsg = <error string on failure>
531 id = <hex-encoded SHA-1 key identifier of the public key on success>
534 ### load-shared() ###
536 Load a shared IKE PSK, EAP, XAuth or NTLM secret into the daemon.
539 id = <optional unique identifier of this shared key>
540 type = <shared key type, IKE|EAP|XAUTH|NTLM>
541 data = <raw shared key data>
543 <list of shared key owner identities>
546 success = <yes or no>
547 errmsg = <error string on failure>
550 ### unload-shared() ###
552 Unload a previously loaded shared IKE PSK, EAP, XAuth or NTLM secret by its
556 id = <unique identifier of the shared key to unload>
558 success = <yes or no>
559 errmsg = <error string on failure>
564 Return a list of unique identifiers of shared keys loaded exclusively over vici,
565 not including keys found in other backends.
569 <list of unique identifiers>
573 ### flush-certs() ###
575 Flushes the certificate cache. The optional type argument allows to flush
576 only certificates of a given type, e.g. all cached CRLs.
579 type = <certificate type to filter for, X509|X509_AC|X509_CRL|
580 OCSP_RESPONSE|PUBKEY or ANY>
582 success = <yes or no>
583 errmsg = <error string on failure>
586 ### clear-creds() ###
588 Clear all loaded certificate, private key and shared key credentials. This
589 affects only credentials loaded over vici, but additionally flushes the
593 success = <yes or no>
594 errmsg = <error string on failure>
597 ### load-authority() ###
599 Load a single certification authority definition into the daemon. An existing
600 authority with the same name gets replaced.
603 <certification authority name> = {
604 # certification authority parameters
605 # refer to swanctl.conf(5) for details.
607 success = <yes or no>
608 errmsg = <error string on failure>
612 ### unload-authority() ###
614 Unload a previously loaded certification authority definition by name.
617 name = <certification authority name>
619 success = <yes or no>
620 errmsg = <error string on failure>
625 Load an in-memory virtual IP and configuration attribute pool. Existing
626 pools with the same name get updated, if possible.
630 addrs = <subnet of virtual IP pool addresses>
631 <attribute type>* = [
632 # attribute type is one of address, dns, nbns, dhcp, netmask,
633 # server, subnet, split_include, split_exclude or a numerical
634 # attribute type identifier.
635 <list of attributes for type>
639 success = <yes or no>
640 errmsg = <error string on failure>
643 ### unload-pool() ###
645 Unload a previously loaded virtual IP and configuration attribute pool.
646 Unloading fails for pools with leases currently online.
649 name = <virtual IP address pool to delete>
651 success = <yes or no>
652 errmsg = <error string on failure>
657 List the currently loaded pools.
660 leases = <set to yes to include leases>
661 name = <optional name of the pool to query>
664 base = <virtual IP pool base address>
665 size = <total number of addresses in the pool>
666 online = <number of leases online>
667 offline = <number of leases offline>
669 <zero-based index>* = {
670 address = <IP address>
671 identity = <assigned identity>
672 status = <online|offline>
678 ### get-algorithms() ###
680 List currently loaded algorithms and their implementation.
684 <algorithm> = <plugin providing the implementation>
688 ### get-counters() ###
690 List global or connection-specific counters for several IKE events.
693 name = <optional connection name, omit for global counters>
694 all = <yes to get counters for all connections, name is ignored>
697 <name|empty for global counters> = {
698 <pairs of counter name and 64-bit counter value>
701 success = <yes or no>
702 errmsg = <error string on failure>
705 ### reset-counters() ###
707 Reset global or connection-specific IKE event counters.
710 name = <optional connection name, omit for global counters>
711 all = <yes to reset counters for all connections, name is ignored>
713 success = <yes or no>
714 errmsg = <error string on failure>
717 ## Server-issued events ##
719 Based on the packet layer, the vici plugin raises event messages using named
720 EVENT packets wrapping messages. The message contains event details.
724 The _log_ event is issued to registered clients for each debug log message.
725 This event is not associated with a command.
728 group = <subsystem identifier for debug message>
729 level = <log level, 0-4>
730 thread = <numerical thread identifier issuing the log message>
731 ikesa-name = <name of IKE_SA, if log is associated with any>
732 ikesa-uniqued = <unique identifier of IKE_A, if log associated with any>
733 msg = <log message text>
738 The _control-log_ event is issued for log events during active _initiate_ or
739 _terminate_ commands. It is issued only to clients currently having such
743 group = <subsystem identifier for debug message>
744 level = <log level, 0-4>
745 ikesa-name = <name of IKE_SA, if log associated with any>
746 ikesa-uniqued = <unique identifier of IKE_A, if log associated with any>
747 msg = <log message text>
752 The _list-sa_ event is issued to stream IKE_SAs during an active _list-sas_
756 <IKE_SA config name> = {
757 uniqueid = <IKE_SA unique identifier>
758 version = <IKE version, 1 or 2>
759 state = <IKE_SA state name>
760 local-host = <local IKE endpoint address>
761 local-port = <local IKE endpoint port>
762 local-id = <local IKE identity>
763 remote-host = <remote IKE endpoint address>
764 remote-port = <remote IKE endpoint port>
765 remote-id = <remote IKE identity>
766 remote-xauth-id = <remote XAuth identity, if XAuth-authenticated>
767 remote-eap-id = <remote EAP identity, if EAP-authenticated>
768 initiator = <yes, if initiator of IKE_SA>
769 initiator-spi = <hex encoded initiator SPI / cookie>
770 responder-spi = <hex encoded responder SPI / cookie>
771 nat-local = <yes, if local endpoint is behind a NAT>
772 nat-remote = <yes, if remote endpoint is behind a NAT>
773 nat-fake = <yes, if NAT situation has been faked as responder>
774 nat-any = <yes, if any endpoint is behind a NAT (also if faked)>
775 if-id-in = <hex encoded default inbound XFRM interface ID>
776 if-id-out = <hex encoded default outbound XFRM interface ID>
777 encr-alg = <IKE encryption algorithm string>
778 encr-keysize = <key size for encr-alg, if applicable>
779 integ-alg = <IKE integrity algorithm string>
780 integ-keysize = <key size for encr-alg, if applicable>
781 prf-alg = <IKE pseudo random function string>
782 dh-group = <IKE Diffie-Hellman group string>
783 established = <seconds the IKE_SA has been established>
784 rekey-time = <seconds before IKE_SA gets rekeyed>
785 reauth-time = <seconds before IKE_SA gets re-authenticated>
787 <list of virtual IPs assigned by the remote peer, installed locally>
790 <list of virtual IPs assigned to the remote peer>
793 <list of currently queued tasks for execution>
796 <list of tasks currently initiating actively>
799 <list of tasks currently handling passively>
802 <unique child-sa-name>* = {
803 name = <name of the CHILD_SA>
804 uniqueid = <unique CHILD_SA identifier>
805 reqid = <reqid of CHILD_SA>
806 state = <state string of CHILD_SA>
807 mode = <IPsec mode, tunnel|transport|beet>
808 protocol = <IPsec protocol AH|ESP>
809 encap = <yes if using UDP encapsulation>
810 spi-in = <hex encoded inbound SPI>
811 spi-out = <hex encoded outbound SPI>
812 cpi-in = <hex encoded inbound CPI, if using compression>
813 cpi-out = <hex encoded outbound CPI, if using compression>
814 mark-in = <hex encoded inbound Netfilter mark value>
815 mark-mask-in = <hex encoded inbound Netfilter mark mask>
816 mark-out = <hex encoded outbound Netfilter mark value>
817 mark-mask-out = <hex encoded outbound Netfilter mark mask>
818 if-id-in = <hex encoded inbound XFRM interface ID>
819 if-id-out = <hex encoded outbound XFRM interface ID>
820 encr-alg = <ESP encryption algorithm name, if any>
821 encr-keysize = <ESP encryption key size, if applicable>
822 integ-alg = <ESP or AH integrity algorithm name, if any>
823 integ-keysize = <ESP or AH integrity key size, if applicable>
824 prf-alg = <CHILD_SA pseudo random function name>
825 dh-group = <CHILD_SA PFS rekeying DH group name, if any>
826 esn = <1 if using extended sequence numbers>
827 bytes-in = <number of input bytes processed>
828 packets-in = <number of input packets processed>
829 use-in = <seconds since last inbound packet, if any>
830 bytes-out = <number of output bytes processed>
831 packets-out = <number of output packets processed>
832 use-out = <seconds since last outbound packet, if any>
833 rekey-time = <seconds before CHILD_SA gets rekeyed>
834 life-time = <seconds before CHILD_SA expires>
835 install-time = <seconds the CHILD_SA has been installed>
837 <list of local traffic selectors>
840 <list of remote traffic selectors>
849 The _list-policy_ event is issued to stream installed policies during an active
850 _list-policies_ command.
853 <ike-sa-config-name/child-sa-config-name> = {
854 child = <CHILD_SA configuration name>
855 ike = <IKE_SA configuration name or namespace, if available>
856 mode = <policy mode, tunnel|transport|pass|drop>
858 <list of local traffic selectors>
861 <list of remote traffic selectors>
868 The _list-conn_ event is issued to stream loaded connection during an active
869 _list-conns_ command.
872 <IKE_SA connection name> = {
874 <list of valid local IKE endpoint addresses>
877 <list of valid remote IKE endpoint addresses>
879 version = <IKE version as string, IKEv1|IKEv2 or 0 for any>
880 reauth_time = <IKE_SA reauthentication interval in seconds>
881 rekey_time = <IKE_SA rekeying interval in seconds>
883 local*, remote* = { # multiple local and remote auth sections
884 class = <authentication type>
885 eap-type = <EAP type to authenticate if when using EAP>
886 eap-vendor = <EAP vendor for type, if any>
887 xauth = <xauth backend name>
888 revocation = <revocation policy>
890 aaa_id = <AAA authentication backend identity>
891 eap_id = <EAP identity for authentication>
892 xauth_id = <XAuth username for authentication>
894 <group membership required to use connection>
897 <certificates allowed for authentication>
900 <CA certificates allowed for authentication>
904 <CHILD_SA config name>* = {
906 rekey_time = <CHILD_SA rekeying interval in seconds>
907 rekey_bytes = <CHILD_SA rekeying interval in bytes>
908 rekey_packets = <CHILD_SA rekeying interval in packets>
910 <list of local traffic selectors>
913 <list of remote traffic selectors>
922 The _list-cert_ event is issued to stream loaded certificates during an active
923 _list-certs_ command.
926 type = <certificate type, X509|X509_AC|X509_CRL|OCSP_RESPONSE|PUBKEY>
927 flag = <X.509 certificate flag, NONE|CA|AA|OCSP>
928 has_privkey = <set if a private key for the certificate is available>
929 data = <ASN1 encoded certificate data>
930 subject = <subject string if defined and certificate type is PUBKEY>
931 not-before = <time string if defined and certificate type is PUBKEY>
932 not-after = <time string if defined and certificate type is PUBKEY>
935 ### list-authority ###
937 The _list-authority_ event is issued to stream loaded certification authority
938 information during an active_list-authorities_ command.
941 <certification authority name> = {
942 cacert = <subject distinguished name of CA certificate>
944 <CRL URI (http, ldap or file)>
949 cert_uri_base = <base URI for download of hash-and-URL certificates>
955 The _ike-updown_ event is issued when an IKE_SA is established or terminated.
958 up = <set if up event>
959 <IKE_SA config name> = {
960 <same data as in the list-sas event, but without child-sas section>
966 The _ike-rekey_ event is issued when an IKE_SA is rekeyed.
969 <IKE_SA config name> = {
971 <same data as in the list-sas event, but without child-sas section>
974 <same data as in the list-sas event, but without child-sas section>
981 The _child-updown_ event is issued when a CHILD_SA is established or terminated.
984 up = <set if up event>
985 <IKE_SA config name> = {
986 <same data as in the list-sas event, but with only the affected
987 CHILD_SA in the child-sas section>
993 The _child-rekey_ event is issued when a CHILD_SA is rekeyed.
996 <IKE_SA config name> = {
997 <same data as in the list-sas event, but with the child-sas section
1002 <same data as in the list-sas event>
1005 <same data as in the list-sas event>
1012 # libvici C client library #
1014 libvici is the reference implementation of a C client library implementing
1015 the vici protocol. It builds upon libstrongswan, but provides a stable API
1016 to implement client applications in the C programming language. libvici uses
1017 the libstrongswan thread pool to deliver event messages asynchronously.
1019 ## Connecting to the daemon ##
1021 This example shows how to connect to the daemon using the default URI, and
1022 then perform proper cleanup:
1028 #include <libvici.h>
1030 int main(int argc, char *argv[])
1036 conn = vici_connect(NULL);
1040 vici_disconnect(conn);
1045 fprintf(stderr, "connecting failed: %s\n", strerror(errno));
1051 ## A simple client request ##
1053 In the following example, a simple _version_ request is issued to the daemon
1054 and the result is printed:
1056 int get_version(vici_conn_t *conn)
1062 req = vici_begin("version");
1063 res = vici_submit(req, conn);
1066 printf("%s %s (%s, %s, %s)\n",
1067 vici_find_str(res, "", "daemon"),
1068 vici_find_str(res, "", "version"),
1069 vici_find_str(res, "", "sysname"),
1070 vici_find_str(res, "", "release"),
1071 vici_find_str(res, "", "machine"));
1077 fprintf(stderr, "version request failed: %s\n", strerror(errno));
1082 ## A request with event streaming and callback parsing ##
1084 In this more advanced example, the _list-conns_ command is used to stream
1085 loaded connections with the _list-conn_ event. The event message is parsed
1086 with a simple callback to print the connection name:
1088 int conn_cb(void *null, vici_res_t *res, char *name)
1090 printf("%s\n", name);
1094 void list_cb(void *null, char *name, vici_res_t *res)
1096 if (vici_parse_cb(res, conn_cb, NULL, NULL, NULL) != 0)
1098 fprintf(stderr, "parsing failed: %s\n", strerror(errno));
1102 int list_conns(vici_conn_t *conn)
1108 if (vici_register(conn, "list-conn", list_cb, NULL) == 0)
1110 req = vici_begin("list-conns");
1111 res = vici_submit(req, conn);
1119 fprintf(stderr, "request failed: %s\n", strerror(errno));
1121 vici_register(conn, "list-conn", NULL, NULL);
1126 fprintf(stderr, "registration failed: %s\n", strerror(errno));
1131 ## API documentation ##
1133 More information about the libvici API is available in the _libvici.h_ header
1134 file or the generated Doxygen documentation.
1138 The _vici ruby gem_ is a pure ruby implementation of the VICI protocol to
1139 implement client applications. It is provided in the _ruby_ subdirectory, and
1140 gets built and installed if strongSwan has been _./configure_'d with
1141 _--enable-vici_ and _--enable-ruby-gems_.
1143 The _Connection_ class from the _Vici_ module provides the high level interface,
1144 the underlying classes are usually not required to build ruby applications
1145 using VICI. The _Connection_ class provides methods for the supported VICI
1146 commands and an event listening mechanism.
1148 To represent the VICI message data tree, the gem converts the binary encoding
1149 to ruby data types. The _Connection_ class takes and returns ruby objects for
1150 the exchanged message data:
1151 * Sections get encoded as Hash, containing other sections as Hash, or
1152 * Key/Values, where the values are Strings as Hash values
1153 * Lists get encoded as Arrays with String values
1154 Non-String values that are not a Hash nor an Array get converted with .to_s
1157 ## Connecting to the daemon ##
1159 To create a connection to the daemon, a socket can be passed to the
1160 _Connection_ constructor. If none is passed, a default Unix socket at
1161 _/var/run/charon.vici_ is used:
1166 v = Vici::Connection.new(UNIXSocket.new("/var/run/charon.vici"))
1168 ## A simple client request ##
1170 An example to print the daemon version information is as simple as:
1173 puts "%s %s (%s, %s, %s)" % [
1174 x["daemon"], x["version"], x["sysname"], x["release"], x["machine"]
1177 ## A request with closure invocation ##
1179 The _Connection_ class takes care of event streaming by invoking a closure
1180 for each event. The following example lists all loaded connections using the
1181 _list-conns_ command and implicitly the _list-conn_ event:
1183 v.list_conns { |conn|
1184 conn.each { |key, value|
1189 ## API documentation ##
1191 For more details about the ruby gem refer to the comments in the gem source
1192 code or the generated documentation.
1196 The _vici Python egg_ is a pure Python implementation of the VICI protocol to
1197 implement client applications. It is provided in the _python_ subdirectory, and
1198 gets built and installed if strongSwan has been _./configure_'d with
1199 _--enable-vici_ and _--enable-python-eggs_.
1201 The _vici_ module provides a _Session()_ constructor for a high level interface,
1202 the underlying classes are usually not required to build Python applications
1203 using VICI. The _Session_ class provides methods for the supported VICI
1206 To represent the VICI message data tree, the library converts the binary
1207 encoding to Python data types. The _Session_ class takes and returns Python
1208 objects for the exchanged message data:
1209 * Sections get encoded as OrderedDict, containing other sections, or
1210 * Key/Values, where the values are strings as dictionary values
1211 * Lists get encoded as Python Lists with string values
1212 Values that do not conform to Python dict or list get converted to strings using
1215 ## Connecting to the daemon ##
1217 To create a connection to the daemon, a socket can be passed to the _Session_
1218 constructor. If none is passed, a default Unix socket at _/var/run/charon.vici_
1224 s = socket.socket(socket.AF_UNIX)
1225 s.connect("/var/run/charon.vici")
1228 ## A simple client request ##
1230 An example to print the daemon version information is as simple as:
1234 print "{daemon} {version} ({sysname}, {release}, {machine})".format(**ver)
1236 ## A request with response iteration ##
1238 The _Session_ class returns an iterable Python generator for streamed events to
1239 continuously stream objects to the caller. The following example lists all
1240 loaded connections using the _list-conns_ command and implicitly the _list-conn_
1243 for conn in v.list_conns():
1247 Please note that if the returned generator is not iterated completely, it must
1248 be closed using _close()_. This is implicitly done when breaking from a loop,
1249 but an explicit call may be required when directly iterating the generator with
1252 ## Sorting in dictionaries ##
1254 In VICI, in some message trees the order of objects in dictionary matters. In
1255 contrast to ruby Hashes, Python dictionaries do not preserve order of added
1256 objects. It is therefore recommended to use OrderedDicts instead of the default
1257 dictionaries. Objects returned by the library use OrderedDicts.
1259 ## API documentation ##
1261 For more details about the Python egg refer to the comments in the Python source
1264 # Vici::Session Perl CPAN module #
1266 The _Vici::Session Perl CPAN module_ is a pure Perl implementation of the VICI
1267 protocol to implement client applications. It is provided in the _perl_
1268 subdirectory, and gets built and installed if strongSwan has been
1269 _./configure_'d with_--enable-vici_ and _--enable-perl-cpan_.
1271 The _Vici::Session_ module provides a _new()_ constructor for a high level
1272 interface, the underlying _Vici::Packet_ and _Vici::Transport_ classes are
1273 usually not required to build Perl applications using VICI. The _Vici::Session_
1274 class provides methods for the supported VICI commands. The auxiliare
1275 _Vici::Message_ class is used to encode configuration parameters sent to
1276 the daemon and decode data returned by the daemon.
1278 ## Connecting to the daemon ##
1280 use IO::Socket::UNIX;
1284 my $socket = IO::Socket::UNIX->new(
1285 Type => SOCK_STREAM,
1286 Peer => '/var/run/charon.vici',
1287 ) or die "Vici socket: $!";
1289 my $session = Vici::Session->new($socket);
1291 ## A simple client request ##
1293 An example to print the daemon version information is as simple as:
1295 my $version = $session->version()->hash();
1297 foreach my $key ('daemon', 'version', 'sysname', 'release', 'machine' ) {
1298 print $version->{$key}, " ";
1301 The _Vici::Session_ methods are explained in the perl/Vici-Session/README.pod