1 # The Versatile IKE Control Interface (VICI) protocol #
3 The vici plugin implements the server side of an IPC protocol to configure,
4 monitor and control the IKE daemon charon. It uses request/response and event
5 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 hierarchial 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 reprensents 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 configuraiton 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 timeout = <timeout in ms before returning>
283 loglevel = <loglevel to issue "control-log" events for>
285 success = <yes or no>
286 errmsg = <error string on failure or timeout>
289 The default timeout of 0 waits indefinitely for a result, and a timeout value
290 of -1 returns a result immediately.
294 Redirect a client-initiated IKE_SA to another gateway. Only for IKEv2 and if
295 supported by the peer.
298 ike = <redirect an IKE_SA by configuration name>
299 ike-id = <redirect an IKE_SA by its unique id>
300 peer-ip = <redirect an IKE_SA with matching peer IP, may also be a
301 subnet in CIDR notation or an IP range>
302 peer-id = <redirect an IKE_SA with matching peer identity, may contain
305 success = <yes or no>
306 errmsg = <error string on failure>
311 Install a trap, drop or bypass policy defined by a CHILD_SA config.
314 child = <CHILD_SA configuration name to install>
315 ike = <optional IKE_SA configuraiton name to find child under>
317 success = <yes or no>
318 errmsg = <error string on failure>
323 Uninstall a trap, drop or bypass policy defined by a CHILD_SA config.
326 child = <CHILD_SA configuration name to install>
328 success = <yes or no>
329 errmsg = <error string on failure>
334 Lists currently active IKE_SAs and associated CHILD_SAs by streaming _list-sa_
338 noblock = <use non-blocking mode if key is set>
339 ike = <filter listed IKE_SAs by its name>
340 ike-id = <filter listed IKE_SA by its unique id>
342 # completes after streaming list-sa events
345 ### list-policies() ###
347 List currently installed trap, drop and bypass policies by streaming
348 _list-policy_ events.
351 drop = <set to yes to list drop policies>
352 pass = <set to yes to list bypass policies>
353 trap = <set to yes to list trap policies>
354 child = <filter by CHILD_SA configuration name>
356 # completes after streaming list-sa events
361 List currently loaded connections by streaming _list-conn_ events. This
362 call includes all connections known by the daemon, not only those loaded
366 ike = <list connections matching a given configuration name only>
368 # completes after streaming list-conn events
373 Return a list of connection names loaded exclusively over vici, not including
374 connections found in other backends.
378 <list of connection names>
384 List currently loaded certificates by streaming _list-cert_ events. This
385 call includes all certificates known by the daemon, not only those loaded
389 type = <certificate type to filter for, X509|X509_AC|X509_CRL|
390 OCSP_RESPONSE|PUBKEY or ANY>
391 flag = <X.509 certificate flag to filter for, NONE|CA|AA|OCSP or ANY>
392 subject = <set to list only certificates having subject>
394 # completes after streaming list-cert events
397 ### list-authorities() ###
399 List currently loaded certification authority information by streaming
400 _list-authority_ events.
403 name = <list certification authority of a given name>
405 # completes after streaming list-authority events
408 ### get-authorities() ###
410 Return a list of currently loaded certification authority names.
414 <list of certification authority names>
420 Load a single connection definition into the daemon. An existing connection
421 with the same name gets updated or replaced.
424 <IKE_SA config name> = {
425 # IKE configuration parameters with authentication and CHILD_SA
426 # subsections. Refer to swanctl.conf(5) for details.
428 success = <yes or no>
429 errmsg = <error string on failure>
433 ### unload-conn() ###
435 Unload a previously loaded connection definition by name.
438 name = <IKE_SA config name>
440 success = <yes or no>
441 errmsg = <error string on failure>
446 Load a certificate into the daemon.
449 type = <certificate type, X509|X509_AC|X509_CRL>
450 flag = <X.509 certificate flag, NONE|CA|AA|OCSP>
451 data = <PEM or DER encoded certificate data>
453 success = <yes or no>
454 errmsg = <error string on failure>
459 Load a private key into the daemon.
462 type = <private key type, RSA|ECDSA>
463 data = <PEM or DER encoded key data>
465 success = <yes or no>
466 errmsg = <error string on failure>
469 ### load-shared() ###
471 Load a shared IKE PSK, EAP or XAuth secret into the daemon.
474 type = <private key type, IKE|EAP|XAUTH>
475 data = <raw shared key data>
477 <list of shared key owner identities>
480 success = <yes or no>
481 errmsg = <error string on failure>
484 ### flush-certs() ###
486 Flushes the certificate cache. The optional type argument allows to flush
487 only certificates of a given type, e.g. all cached CRLs.
490 type = <certificate type to filter for, X509|X509_AC|X509_CRL|
491 OCSP_RESPONSE|PUBKEY or ANY>
493 success = <yes or no>
494 errmsg = <error string on failure>
497 ### clear-creds() ###
499 Clear all loaded certificate, private key and shared key credentials. This
500 affects only credentials loaded over vici, but additionally flushes the
504 success = <yes or no>
505 errmsg = <error string on failure>
508 ### load-authority() ###
510 Load a single certification authority definition into the daemon. An existing
511 authority with the same name gets replaced.
514 <certification authority name> = {
515 # certification authority parameters
516 # refer to swanctl.conf(5) for details.
518 success = <yes or no>
519 errmsg = <error string on failure>
523 ### unload-authority() ###
525 Unload a previously loaded certification authority definition by name.
528 name = <certification authority name>
530 success = <yes or no>
531 errmsg = <error string on failure>
536 Load an in-memory virtual IP and configuration attribute pool. Existing
537 pools with the same name get updated, if possible.
541 addrs = <subnet of virtual IP pool addresses>
542 <attribute type>* = [
543 # attribute type is one of address, dns, nbns, dhcp, netmask,
544 # server, subnet, split_include, split_exclude or a numerical
545 # attribute type identifier.
546 <list of attributes for type>
550 success = <yes or no>
551 errmsg = <error string on failure>
554 ### unload-pool() ###
556 Unload a previously loaded virtual IP and configuration attribute pool.
557 Unloading fails for pools with leases currently online.
560 name = <virtual IP address pool to delete>
562 success = <yes or no>
563 errmsg = <error string on failure>
568 List the currently loaded pools.
571 leases = <set to yes to include leases>
572 name = <optional name of the pool to query>
575 base = <virtual IP pool base address>
576 size = <total number of addresses in the pool>
577 online = <number of leases online>
578 offline = <number of leases offline>
580 <zero-based index>* = {
581 address = <IP address>
582 identity = <assigned identity>
583 status = <online|offline>
589 ### get-algorithms() ###
591 List currently loaded algorithms and their implementation.
595 <algorithm> = <plugin providing the implementation>
599 ## Server-issued events ##
601 Based on the packet layer, the vici plugin raises event messages using named
602 EVENT packets wrapping messages. The message contains event details.
606 The _log_ event is issued to registered clients for each debug log message.
607 This event is not associated with a command.
610 group = <subsystem identifier for debug message>
611 level = <log level, 0-4>
612 thread = <numerical thread identifier issuing the log message>
613 ikesa-name = <name of IKE_SA, if log is associated with any>
614 ikesa-uniqued = <unique identifier of IKE_A, if log associated with any>
615 msg = <log message text>
620 The _control-log_ event is issued for log events during active _initiate_ or
621 _terminate_ commands. It is issued only to clients currently having such
625 group = <subsystem identifier for debug message>
626 level = <log level, 0-4>
627 ikesa-name = <name of IKE_SA, if log associated with any>
628 ikesa-uniqued = <unique identifier of IKE_A, if log associated with any>
629 msg = <log message text>
634 The _list-sa_ event is issued to stream IKE_SAs during an active _list-sas_
638 <IKE_SA config name> = {
639 uniqueid = <IKE_SA unique identifier>
640 version = <IKE version, 1 or 2>
641 state = <IKE_SA state name>
642 local-host = <local IKE endpoint address>
643 local-port = <local IKE endpoint port>
644 local-id = <local IKE identity>
645 remote-host = <remote IKE endpoint address>
646 remote-port = <remote IKE endpoint port>
647 remote-id = <remote IKE identity>
648 remote-xauth-id = <remote XAuth identity, if XAuth-authenticated>
649 remote-eap-id = <remote EAP identity, if EAP-authenticated>
650 initiator = <yes, if initiator of IKE_SA>
651 initiator-spi = <hex encoded initiator SPI / cookie>
652 responder-spi = <hex encoded responder SPI / cookie>
653 nat-local = <yes, if local endpoint is behind a NAT>
654 nat-remote = <yes, if remote endpoint is behind a NAT>
655 nat-fake = <yes, if NAT situation has been faked as responder>
656 nat-any = <yes, if any endpoint is behind a NAT (also if faked)>
657 encr-alg = <IKE encryption algorithm string>
658 encr-keysize = <key size for encr-alg, if applicable>
659 integ-alg = <IKE integrity algorithm string>
660 integ-keysize = <key size for encr-alg, if applicable>
661 prf-alg = <IKE pseudo random function string>
662 dh-group = <IKE Diffie-Hellman group string>
663 established = <seconds the IKE_SA has been established>
664 rekey-time = <seconds before IKE_SA gets rekeyed>
665 reauth-time = <seconds before IKE_SA gets re-authenticated>
667 <list of virtual IPs assigned by the remote peer, installed locally>
670 <list of virtual IPs assigned to the remote peer>
673 <list of currently queued tasks for execution>
676 <list of tasks currently initiating actively>
679 <list of tasks currently handling passively>
683 uniqueid = <unique CHILD_SA identifier>
684 reqid = <reqid of CHILD_SA>
685 state = <state string of CHILD_SA>
686 mode = <IPsec mode, tunnel|transport|beet>
687 protocol = <IPsec protocol AH|ESP>
688 encap = <yes if using UDP encapsulation>
689 spi-in = <hex encoded inbound SPI>
690 spi-out = <hex encoded outbound SPI>
691 cpi-in = <hex encoded inbound CPI, if using compression>
692 cpi-out = <hex encoded outbound CPI, if using compression>
693 mark-in = <hex encoded inbound Netfilter mark value>
694 mark-mask-in = <hex encoded inbound Netfilter mark mask>
695 mark-out = <hex encoded outbound Netfilter mark value>
696 mark-mask-out = <hex encoded outbound Netfilter mark mask>
697 encr-alg = <ESP encryption algorithm name, if any>
698 encr-keysize = <ESP encryption key size, if applicable>
699 integ-alg = <ESP or AH integrity algorithm name, if any>
700 integ-keysize = <ESP or AH integrity key size, if applicable>
701 prf-alg = <CHILD_SA pseudo random function name>
702 dh-group = <CHILD_SA PFS rekeying DH group name, if any>
703 esn = <1 if using extended sequence numbers>
704 bytes-in = <number of input bytes processed>
705 packets-in = <number of input packets processed>
706 use-in = <seconds since last inbound packet, if any>
707 bytes-out = <number of output bytes processed>
708 packets-out = <number of output packets processed>
709 use-out = <seconds since last outbound packet, if any>
710 rekey-time = <seconds before CHILD_SA gets rekeyed>
711 life-time = <seconds before CHILD_SA expires>
712 install-time = <seconds the CHILD_SA has been installed>
714 <list of local traffic selectors>
717 <list of remote traffic selectors>
726 The _list-policy_ event is issued to stream installed policies during an active
727 _list-policies_ command.
730 <child-sa-config-name> = {
731 mode = <policy mode, tunnel|transport|pass|drop>
733 <list of local traffic selectors>
736 <list of remote traffic selectors>
743 The _list-conn_ event is issued to stream loaded connection during an active
744 _list-conns_ command.
747 <IKE_SA connection name> = {
749 <list of valid local IKE endpoint addresses>
752 <list of valid remote IKE endpoint addresses>
754 version = <IKE version as string, IKEv1|IKEv2 or 0 for any>
755 reauth_time = <IKE_SA reauthentication interval in seconds>
756 rekey_time = <IKE_SA rekeying interval in seconds>
758 local*, remote* = { # multiple local and remote auth sections
759 class = <authentication type>
760 eap-type = <EAP type to authenticate if when using EAP>
761 eap-vendor = <EAP vendor for type, if any>
762 xauth = <xauth backend name>
763 revocation = <revocation policy>
765 aaa_id = <AAA authentication backend identity>
766 eap_id = <EAP identity for authentication>
767 xauth_id = <XAuth username for authentication>
769 <group membership required to use connection>
772 <certificates allowed for authentication>
775 <CA certificates allowed for authentication>
779 <CHILD_SA config name>* = {
781 rekey_time = <CHILD_SA rekeying interval in seconds>
782 rekey_bytes = <CHILD_SA rekeying interval in bytes>
783 rekey_packets = <CHILD_SA rekeying interval in packets>
785 <list of local traffic selectors>
788 <list of remote traffic selectors>
797 The _list-cert_ event is issued to stream loaded certificates during an active
798 _list-certs_ command.
801 type = <certificate type, X509|X509_AC|X509_CRL|OCSP_RESPONSE|PUBKEY>
802 flag = <X.509 certificate flag, NONE|CA|AA|OCSP>
803 has_privkey = <set if a private key for the certificate is available>
804 data = <ASN1 encoded certificate data>
805 subject = <subject string if defined and certificate type is PUBKEY>
806 not-before = <time string if defined and certificate type is PUBKEY>
807 not-after = <time string if defined and certificate type is PUBKEY>
810 ### list-authority ###
812 The _list-authority_ event is issued to stream loaded certification authority
813 information during an active_list-authorities_ command.
816 <certification authority name> = {
817 cacert = <subject distinguished name of CA certificate>
819 <CRL URI (http, ldap or file)>
824 cert_uri_base = <base URI for download of hash-and-URL certificates>
830 The _ike-updown_ event is issued when an IKE_SA is established or terminated.
833 up = <set if up event>
834 <IKE_SA config name> = {
835 <same data as in the list-sas event, but without child-sas section>
841 The _ike-rekey_ event is issued when an IKE_SA is rekeyed.
844 <IKE_SA config name> = {
846 <same data as in the list-sas event, but without child-sas section>
849 <same data as in the list-sas event, but without child-sas section>
856 The _child-updown_ event is issued when a CHILD_SA is established or terminated.
859 up = <set if up event>
860 <IKE_SA config name> = {
861 <same data as in the list-sas event, but with only the affected
862 CHILD_SA in the child-sas section>
868 The _child-rekey_ event is issued when a CHILD_SA is rekeyed.
871 <IKE_SA config name> = {
872 <same data as in the list-sas event, but with the child-sas section
877 <same data as in the list-sas event>
880 <same data as in the list-sas event>
887 # libvici C client library #
889 libvici is the reference implementation of a C client library implementing
890 the vici protocol. It builds upon libstrongswan, but provides a stable API
891 to implement client applications in the C programming language. libvici uses
892 the libstrongswan thread pool to deliver event messages asynchronously.
894 ## Connecting to the daemon ##
896 This example shows how to connect to the daemon using the default URI, and
897 then perform proper cleanup:
905 int main(int argc, char *argv[])
911 conn = vici_connect(NULL);
915 vici_disconnect(conn);
920 fprintf(stderr, "connecting failed: %s\n", strerror(errno));
926 ## A simple client request ##
928 In the following example, a simple _version_ request is issued to the daemon
929 and the result is printed:
931 int get_version(vici_conn_t *conn)
937 req = vici_begin("version");
938 res = vici_submit(req, conn);
941 printf("%s %s (%s, %s, %s)\n",
942 vici_find_str(res, "", "daemon"),
943 vici_find_str(res, "", "version"),
944 vici_find_str(res, "", "sysname"),
945 vici_find_str(res, "", "release"),
946 vici_find_str(res, "", "machine"));
952 fprintf(stderr, "version request failed: %s\n", strerror(errno));
957 ## A request with event streaming and callback parsing ##
959 In this more advanced example, the _list-conns_ command is used to stream
960 loaded connections with the _list-conn_ event. The event message is parsed
961 with a simple callback to print the connection name:
963 int conn_cb(void *null, vici_res_t *res, char *name)
965 printf("%s\n", name);
969 void list_cb(void *null, char *name, vici_res_t *res)
971 if (vici_parse_cb(res, conn_cb, NULL, NULL, NULL) != 0)
973 fprintf(stderr, "parsing failed: %s\n", strerror(errno));
977 int list_conns(vici_conn_t *conn)
983 if (vici_register(conn, "list-conn", list_cb, NULL) == 0)
985 req = vici_begin("list-conns");
986 res = vici_submit(req, conn);
994 fprintf(stderr, "request failed: %s\n", strerror(errno));
996 vici_register(conn, "list-conn", NULL, NULL);
1001 fprintf(stderr, "registration failed: %s\n", strerror(errno));
1006 ## API documentation ##
1008 More information about the libvici API is available in the _libvici.h_ header
1009 file or the generated Doxygen documentation.
1013 The _vici ruby gem_ is a pure ruby implementation of the VICI protocol to
1014 implement client applications. It is provided in the _ruby_ subdirectory, and
1015 gets built and installed if strongSwan has been _./configure_'d with
1016 _--enable-vici_ and _--enable-ruby-gems_.
1018 The _Connection_ class from the _Vici_ module provides the high level interface,
1019 the underlying classes are usually not required to build ruby applications
1020 using VICI. The _Connection_ class provides methods for the supported VICI
1021 commands and an event listening mechanism.
1023 To represent the VICI message data tree, the gem converts the binary encoding
1024 to ruby data types. The _Connection_ class takes and returns ruby objects for
1025 the exchanged message data:
1026 * Sections get encoded as Hash, containing other sections as Hash, or
1027 * Key/Values, where the values are Strings as Hash values
1028 * Lists get encoded as Arrays with String values
1029 Non-String values that are not a Hash nor an Array get converted with .to_s
1032 ## Connecting to the daemon ##
1034 To create a connection to the daemon, a socket can be passed to the
1035 _Connection_ constructor. If none is passed, a default Unix socket at
1036 _/var/run/charon.vici_ is used:
1041 v = Vici::Connection.new(UNIXSocket.new("/var/run/charon.vici"))
1043 ## A simple client request ##
1045 An example to print the daemon version information is as simple as:
1048 puts "%s %s (%s, %s, %s)" % [
1049 x["daemon"], x["version"], x["sysname"], x["release"], x["machine"]
1052 ## A request with closure invocation ##
1054 The _Connection_ class takes care of event streaming by invoking a closure
1055 for each event. The following example lists all loaded connections using the
1056 _list-conns_ command and implicitly the _list-conn_ event:
1058 v.list_conns { |conn|
1059 conn.each { |key, value|
1064 ## API documentation ##
1066 For more details about the ruby gem refer to the comments in the gem source
1067 code or the generated documentation.
1071 The _vici Python egg_ is a pure Python implementation of the VICI protocol to
1072 implement client applications. It is provided in the _python_ subdirectory, and
1073 gets built and installed if strongSwan has been _./configure_'d with
1074 _--enable-vici_ and _--enable-python-eggs_.
1076 The _vici_ module provides a _Session()_ constructor for a high level interface,
1077 the underlying classes are usually not required to build Python applications
1078 using VICI. The _Session_ class provides methods for the supported VICI
1081 To represent the VICI message data tree, the library converts the binary
1082 encoding to Python data types. The _Session_ class takes and returns Python
1083 objects for the exchanged message data:
1084 * Sections get encoded as OrderedDict, containing other sections, or
1085 * Key/Values, where the values are strings as dictionary values
1086 * Lists get encoded as Python Lists with string values
1087 Values that do not conform to Python dict or list get converted to strings using
1090 ## Connecting to the daemon ##
1092 To create a connection to the daemon, a socket can be passed to the _Session_
1093 constructor. If none is passed, a default Unix socket at _/var/run/charon.vici_
1099 s = socket.socket(socket.AF_UNIX)
1100 s.connect("/var/run/charon.vici")
1103 ## A simple client request ##
1105 An example to print the daemon version information is as simple as:
1109 print "{daemon} {version} ({sysname}, {release}, {machine})".format(**ver)
1111 ## A request with response iteration ##
1113 The _Session_ class returns an iterable Python generator for streamed events to
1114 continuously stream objects to the caller. The following example lists all
1115 loaded connections using the _list-conns_ command and implicitly the _list-conn_
1118 for conn in v.list_conns():
1122 Please note that if the returned generator is not iterated completely, it must
1123 be closed using _close()_. This is implicitly done when breaking from a loop,
1124 but an explicit call may be required when directly iterating the generator with
1127 ## Sorting in dictionaries ##
1129 In VICI, in some message trees the order of objects in dictionary matters. In
1130 contrast to ruby Hashes, Python dictionaries do not preserve order of added
1131 objects. It is therefore recommended to use OrderedDicts instead of the default
1132 dictionaries. Objects returned by the library use OrderedDicts.
1134 ## API documentation ##
1136 For more details about the Python egg refer to the comments in the Python source
1139 # Vici::Session Perl CPAN module #
1141 The _Vici::Session Perl CPAN module_ is a pure Perl implementation of the VICI
1142 protocol to implement client applications. It is provided in the _perl_
1143 subdirectory, and gets built and installed if strongSwan has been
1144 _./configure_'d with_--enable-vici_ and _--enable-perl-cpan_.
1146 The _Vici::Session_ module provides a _new()_ constructor for a high level
1147 interface, the underlying _Vici::Packet_ and _Vici::Transport_ classes are
1148 usually not required to build Perl applications using VICI. The _Vici::Session_
1149 class provides methods for the supported VICI commands. The auxiliare
1150 _Vici::Message_ class is used to encode configuration parameters sent to
1151 the daemon and decode data returned by the daemon.
1153 ## Connecting to the daemon ##
1155 use IO::Socket::UNIX;
1159 my $socket = IO::Socket::UNIX->new(
1160 Type => SOCK_STREAM,
1161 Peer => '/var/run/charon.vici',
1162 ) or die "Vici socket: $!";
1164 my $session = Vici::Session->new($socket);
1166 ## A simple client request ##
1168 An example to print the daemon version information is as simple as:
1170 my $version = $session->version()->hash();
1172 foreach my $key ('daemon', 'version', 'sysname', 'release', 'machine' ) {
1173 print $version->{$key}, " ";
1176 The _Vici::Session_ methods are explained in the perl/Vici-Session/README.pod