Remove wrapper. Old API is not supported anymore.
[platform/core/security/vasum.git] / client / vasum-client.h
1 /*
2  *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License
17  */
18
19
20 /**
21  * @file
22  * @author   Mateusz Malicki (m.malicki2@samsung.com)
23  * @brief    This file contains the public API for Vasum Client
24  * @defgroup libvasum-client libvasum-client
25  * @brief    C library for interfacing Vasum
26  *
27  * All functionalities that are possible using the Vasum's Command Line Interface can also be done with libvasum-client's calls.
28  *
29  * @par Simple usage:
30  * Basic usage:
31  * - Create VsmClient with vsm_client_create(). It'll be needed for all communication with Vasum.
32  * - Establish the connection with the daemon using vsm_connect()
33  * - Do what you need to do with the zones
34  * - Free the client with vsm_client_free()
35  *
36  * @code
37 #include <stdio.h>
38 #include <vasum-client.h>
39
40 int main(int argc, char** argv)
41 {
42     VsmStatus status;
43     VsmClient client;
44     VsmArrayString values = NULL;
45     int ret = 0;
46
47     // Create client handle
48     client = vsm_client_create();
49     if (NULL == client) {
50         // error!
51         ret = 1;
52         goto finish;
53     }
54
55     // Connect to Vasum
56     status = vsm_connect(client);
57     if (VSMCLIENT_SUCCESS != status) {
58         // error!
59         ret = 1;
60         goto finish;
61     }
62
63     status = vsm_get_zone_ids(client, &values);
64     if (VSMCLIENT_SUCCESS != status) {
65         // error!
66         ret = 1;
67         goto finish;
68     }
69
70     // print array
71     for (VsmArrayString iValues = values; *iValues; iValues++) {
72         printf("%s\n", *iValues);
73     }
74
75 finish:
76     vsm_array_string_free(values); // free memory
77     vsm_client_free(client); // destroy client handle
78     return ret;
79 }
80  @endcode
81
82  * @par Polling loop
83  *
84  * By default libVasum will create a separate thread for his communication with Vasum. Most of the time it'll sleep so it shouldn't be a concern.
85  * It's also possible to connect to an existing polling loop. To do this you'll need to:
86  * - Get the poll file descriptor with vsm_get_poll_fd()
87  * - Use epoll/poll/select to wait for events on the file descriptor
88  * - Call vsm_enter_eventloop() every time there's an event
89  *
90  * For example:
91  * @code
92 #include <pthread.h>
93 #include <assert.h>
94 #include <stdio.h>
95 #include <signal.h>
96 #include <sys/epoll.h>
97 #include <vasum-client.h>
98
99 volatile static sig_atomic_t running;
100 static int LOOP_INTERVAL = 1000; // ms
101
102 void* main_loop(void* client)
103 {
104     int fd = -1;
105     VsmStatus status = vsm_get_poll_fd(client, &fd);
106     assert(VSMCLIENT_SUCCESS == status);
107
108     while (running) {
109         struct epoll_event event;
110         int num = epoll_wait(fd, &event, 1, LOOP_INTERVAL);
111         if (num > 0) {
112             status = vsm_enter_eventloop(client, 0 , 0);
113             assert(VSMCLIENT_SUCCESS == status);
114         }
115     }
116     return NULL;
117 }
118
119 int main(int argc, char** argv)
120 {
121     pthread_t loop;
122     VsmStatus status;
123     VsmClient client;
124     int ret = 0;
125
126     client = vsm_client_create();
127     assert(client);
128
129     status = vsm_set_dispatcher_type(client, VSMDISPATCHER_EXTERNAL);
130     assert(VSMCLIENT_SUCCESS == status);
131
132     status = vsm_connect(client);
133     assert(VSMCLIENT_SUCCESS == status);
134
135     // start event loop
136     running = 1;
137     ret = pthread_create(&loop, NULL, main_loop, client);
138     assert(ret == 0);
139
140     // make vsm_* calls on client
141     // ...
142
143     status = vsm_disconnect(client);
144     assert(VSMCLIENT_SUCCESS == status);
145
146     //stop event loop
147     running = 0;
148     ret = pthread_join(loop, NULL);
149     assert(ret == 0);
150
151     vsm_client_free(client); // destroy client handle
152     return ret;
153 }
154  @endcode
155  */
156 /*@{*/
157 #ifndef VASUM_CLIENT_H
158 #define VASUM_CLIENT_H
159
160 #include <stdint.h>
161 #include <sys/stat.h>
162 #include <netinet/ip.h>
163 #include <linux/if_link.h>
164
165 #ifdef __cplusplus
166 extern "C"
167 {
168 #endif
169
170 /**
171  * vasum-server's opaque client pointer.
172  */
173 typedef void* VsmClient;
174
175 /**
176  * NULL-terminated string type.
177  *
178  * @sa vsm_string_free
179  */
180 typedef char* VsmString;
181
182 /**
183  * NULL-terminated array of strings type.
184  *
185  * @sa vsm_array_string_free
186  */
187 typedef VsmString* VsmArrayString;
188
189 typedef void *VsmAddrList;
190 /**
191  * Completion status of libvasum-client's functions
192  */
193 typedef enum {
194     VSMCLIENT_CUSTOM_ERROR,     /**< User specified error */
195     VSMCLIENT_IO_ERROR,         /**< Input/Output error */
196     VSMCLIENT_OPERATION_FAILED, /**< Operation failed */
197     VSMCLIENT_INVALID_ARGUMENT, /**< Invalid argument */
198     VSMCLIENT_OTHER_ERROR,      /**< Other error */
199     VSMCLIENT_SUCCESS           /**< Success */
200 } VsmStatus;
201
202 /**
203  * Subscription id
204  */
205 typedef unsigned int VsmSubscriptionId;
206
207 /**
208  * States of zone
209  */
210 typedef enum {
211     STOPPED,
212     STARTING,
213     RUNNING,
214     STOPPING,
215     ABORTING,
216     FREEZING,
217     FROZEN,
218     THAWED,
219     LOCKED,
220     MAX_STATE,
221     ACTIVATING = 128
222 } VsmZoneState;
223
224 /**
225  * Zone information
226  */
227 typedef void* VsmZone;
228
229 /**
230  * Netowrk device type
231  */
232 typedef enum {
233     VSMNETDEV_VETH,
234     VSMNETDEV_PHYS,
235     VSMNETDEV_MACVLAN
236 } VsmNetdevType;
237
238 /**
239  * Network device information
240  */
241 typedef void* VsmNetdev;
242
243 /**
244  * File type
245  */
246 typedef enum {
247     VSMFILE_DIRECTORY,
248     VSMFILE_FIFO,
249     VSMFILE_REGULAR
250 } VsmFileType;
251
252 /**
253  * Event dispacher types.
254  */
255 typedef enum {
256     VSMDISPATCHER_EXTERNAL,         /**< User must handle dispatching messages */
257     VSMDISPATCHER_INTERNAL          /**< Library will take care of dispatching messages */
258 } VsmDispacherType;
259
260 /**
261  * Get file descriptor associated with event dispatcher of zone client
262  *
263  * The function vsm_get_poll_fd() returns the file descriptor associated with the event dispatcher of vsm client.
264  * The file descriptor can be bound to another I/O multiplexing facilities like epoll, select, and poll.
265  *
266  * @param[in] client vsm client
267  * @param[out] fd epoll file descriptor
268  * @return status of this function call
269 */
270 VsmStatus vsm_get_poll_fd(VsmClient client, int* fd);
271
272 /**
273  * Wait for an I/O event on a vsm client
274  *
275  * vsm_enter_eventloop() waits for event on the vsm client
276  *
277  * The call waits for a maximum time of timout milliseconds. Specifying a timeout of -1 makes vsm_enter_eventloop() wait indefinitely,
278  * while specifying a timeout equal to zero makes vsm_enter_eventloop() to return immediately even if no events are available.
279  *
280  * @param[in] client vasum-server's client
281  * @param[in] flags Reserved
282  * @param[in] timeout Timeout time (milisecond), -1 is infinite
283  * @return status of this function call
284 */
285 VsmStatus vsm_enter_eventloop(VsmClient client, int flags, int timeout);
286
287 /**
288  * Set dispatching method
289  *
290  * @param[in] client vasum-server's client
291  * @param[in] dispacher dispatching method
292  * @return status of this function call
293  */
294 VsmStatus vsm_set_dispatcher_type(VsmClient client, VsmDispacherType dispacher);
295
296 /**
297  * Get dispatching method
298  *
299  * @param[in] client vasum-server's client
300  * @param[out] dispacher dispatching method
301  * @return status of this function call
302  */
303 VsmStatus vsm_get_dispatcher_type(VsmClient client, VsmDispacherType* dispacher);
304
305 /**
306  * Create a new vasum-server's client.
307  *
308  * @return Created client pointer or NULL on failure.
309  */
310 VsmClient vsm_client_create();
311
312 /**
313  * Release client resources.
314  *
315  * @param[in] client vasum-server's client
316  */
317 void vsm_client_free(VsmClient client);
318
319 /**
320  * Get status code of last vasum-server communication.
321  *
322  * @param[in] client vasum-server's client
323  * @return status of this function call
324  */
325 VsmStatus vsm_get_status(VsmClient client);
326
327 /**
328  * Get status message of the last vasum-server communication.
329  *
330  * @param[in] client vasum-server's client
331  * @return last status message from vasum-server communication
332  */
333 const char* vsm_get_status_message(VsmClient client);
334
335 /**
336  * Connect client to the vasum-server.
337  *
338  * @param[in] client vasum-server's client
339  * @return status of this function call
340  */
341 VsmStatus vsm_connect(VsmClient client);
342
343 /**
344  * Connect client to the vasum-server via custom address.
345  *
346  * @param[in] client vasum-server's client
347  * @param[in] address dbus address
348  * @return status of this function call
349  */
350 VsmStatus vsm_connect_custom(VsmClient client, const char* address);
351
352 /**
353  * Disconnect client from vasum-server.
354  *
355  * @param[in] client vasum-server's client
356  * @return status of this function call
357  */
358 VsmStatus vsm_disconnect(VsmClient client);
359
360 /**
361  * Release VsmArrayString.
362  *
363  * @param[in] astring VsmArrayString
364  */
365 void vsm_array_string_free(VsmArrayString astring);
366
367 /**
368  * Release VsmString.
369  *
370  * @param string VsmString
371  */
372 void vsm_string_free(VsmString string);
373
374 /**
375  * Get zone id (offline)
376  *
377  * @param zone VsmZone
378  * @return zone id
379  */
380 VsmString vsm_zone_get_id(VsmZone zone);
381
382 /**
383  * Get zone terminal (offline)
384  *
385  * @param zone VsmZone
386  * @return zone terminal
387  */
388 int vsm_zone_get_terminal(VsmZone zone);
389
390 /**
391  * Get zone state (offline)
392  *
393  * @param zone VsmZone
394  * @return zone state
395  */
396 VsmZoneState vsm_zone_get_state(VsmZone zone);
397
398 /**
399  * Get zone rootfs path (offline)
400  *
401  * @param zone VsmZone
402  * @return zone rootfs path
403  */
404 VsmString vsm_zone_get_rootfs(VsmZone zone);
405
406 /**
407  * Release VsmZone
408  *
409  * @param zone VsmZone
410  */
411 void vsm_zone_free(VsmZone zone);
412
413 /**
414  * Get netdev name (offline)
415  *
416  * @param netdev VsmNetdev
417  * @return netdev name
418  */
419 VsmString vsm_netdev_get_name(VsmNetdev netdev);
420
421 /**
422  * Get netdev type (offline)
423  *
424  * @param netdev VsmNetdev
425  * @return netdev type
426  */
427 VsmNetdevType vsm_netdev_get_type(VsmNetdev netdev);
428
429 /**
430  * Release VsmNetdev
431  *
432  * @param netdev VsmNetdev
433  */
434 void vsm_netdev_free(VsmNetdev netdev);
435
436 /**
437  * Zone's D-Bus state change callback function signature.
438  *
439  * @param[in] zoneId affected zone id
440  * @param[in] address new D-Bus address
441  * @param data custom user's data pointer passed to vsm_add_state_callback() function
442  */
443 typedef void (*VsmZoneDbusStateCallback)(const char* zoneId,
444                                              const char* address,
445                                              void* data);
446
447 /**
448  * Lock the command queue exclusively.
449  *
450  * @param[in] client vasum-server's client
451  * @return status of this function call
452  */
453 VsmStatus vsm_lock_queue(VsmClient client);
454
455 /**
456  * Unlock the command queue.
457  *
458  * @param[in] client vasum-server's client
459  * @return status of this function call
460  */
461 VsmStatus vsm_unlock_queue(VsmClient client);
462
463 /**
464  * Get dbus address of each zone.
465  *
466  * @param[in] client vasum-server's client
467  * @param[out] keys array of zones name
468  * @param[out] values array of zones dbus address
469  * @return status of this function call
470  * @post keys[i] corresponds to values[i]
471  * @remark Use vsm_array_string_free() to free memory occupied by @p keys and @p values.
472  */
473 VsmStatus vsm_get_zone_dbuses(VsmClient client, VsmArrayString* keys, VsmArrayString* values);
474
475 /**
476  * Get zones name.
477  *
478  * @param[in] client vasum-server's client
479  * @param[out] array array of zones name
480  * @return status of this function call
481  * @remark Use vsm_array_string_free() to free memory occupied by @p array.
482  */
483 VsmStatus vsm_get_zone_ids(VsmClient client, VsmArrayString* array);
484
485 /**
486  * Get active (foreground) zone name.
487  *
488  * @param[in] client vasum-server's client
489  * @param[out] id active zone name
490  * @return status of this function call
491  * @remark Use @p vsm_string_free() to free memory occupied by @p id.
492  */
493 VsmStatus vsm_get_active_zone_id(VsmClient client, VsmString* id);
494
495 /**
496  * Get zone name of process with given pid.
497  *
498  * @param[in] client vasum-server's client
499  * @param[in] pid process id
500  * @param[out] id active zone name
501  * @return status of this function call
502  * @remark Use @p vsm_string_free() to free memory occupied by @p id.
503  */
504 VsmStatus vsm_lookup_zone_by_pid(VsmClient client, int pid, VsmString* id);
505
506 /**
507  * Get zone informations of zone with given id.
508  *
509  * @param[in] client vasum-server's client
510  * @param[in] id zone name
511  * @param[out] zone zone informations
512  * @return status of this function call
513  * @remark Use @p vsm_zone_free() to free memory occupied by @p zone
514  */
515 VsmStatus vsm_lookup_zone_by_id(VsmClient client, const char* id, VsmZone* zone);
516
517 /**
518  * Get zone name with given terminal.
519  *
520  * @param[in] client vasum-server's client
521  * @param[in] terminal terminal id
522  * @param[out] id zone name with given terminal
523  * @return status of this function call
524  * @remark Use @p vsm_string_free() to free memory occupied by @p id.
525  */
526 VsmStatus vsm_lookup_zone_by_terminal_id(VsmClient client, int terminal, VsmString* id);
527
528 /**
529  * Set active (foreground) zone.
530  *
531  * @param[in] client vasum-server's client
532  * @param[in] id zone name
533  * @return status of this function call
534  */
535 VsmStatus vsm_set_active_zone(VsmClient client, const char* id);
536
537 /**
538  * Create and add zone
539  *
540  * @param[in] client vasum-server's client
541  * @param[in] id zone id
542  * @param[in] tname template name, NULL is equivalent to "default"
543  * @return status of this function call
544  */
545 VsmStatus vsm_create_zone(VsmClient client, const char* id, const char* tname);
546
547 /**
548  * Remove zone
549  *
550  * @param[in] client vasum-server's client
551  * @param[in] id zone id
552  * @param[in] force if 0 data will be kept, otherwise data will be lost
553  * @return status of this function call
554  */
555 VsmStatus vsm_destroy_zone(VsmClient client, const char* id, int force);
556
557 /**
558  * Shutdown zone
559  *
560  * @param[in] client vasum-server's client
561  * @param[in] id zone name
562  * @return status of this function call
563  */
564 VsmStatus vsm_shutdown_zone(VsmClient client, const char* id);
565
566 /**
567  * Start zone
568  *
569  * @param[in] client vasum-server's client
570  * @param[in] id zone name
571  * @return status of this function call
572  */
573 VsmStatus vsm_start_zone(VsmClient client, const char* id);
574
575 /**
576  * Lock zone
577  *
578  * @param[in] client vasum-server's client
579  * @param[in] id zone name
580  * @return status of this function call
581  */
582 VsmStatus vsm_lock_zone(VsmClient client, const char* id);
583
584 /**
585  * Unlock zone
586  *
587  * @param[in] client vasum-server's client
588  * @param[in] id zone name
589  * @return status of this function call
590  */
591 VsmStatus vsm_unlock_zone(VsmClient client, const char* id);
592
593 /**
594  * Register dbus state change callback function.
595  *
596  * @note The callback function will be invoked on a different thread.
597  *
598  * @param[in] client vasum-server's client
599  * @param[in] zoneDbusStateCallback callback function
600  * @param[in] data some extra data that will be passed to callback function
601  * @param[out] subscriptionId subscription identifier that can be used to unsubscribe signal,
602  *                      pointer can be NULL.
603  * @return status of this function call
604  */
605 VsmStatus vsm_add_state_callback(VsmClient client,
606                                  VsmZoneDbusStateCallback zoneDbusStateCallback,
607                                  void* data,
608                                  VsmSubscriptionId* subscriptionId);
609
610 /**
611  * Unregister dbus state change callback function.
612  *
613  * @param[in] client vasum-server's client
614  * @param[in] subscriptionId subscription identifier returned by vsm_add_state_callback
615  * @return status of this function call
616  */
617 VsmStatus vsm_del_state_callback(VsmClient client, VsmSubscriptionId subscriptionId);
618
619 /**
620  * Grant access to device
621  *
622  * @param[in] client vasum-server's client
623  * @param[in] zone zone name
624  * @param[in] device device path
625  * @param[in] flags access flags
626  * @return status of this function call
627  */
628 VsmStatus vsm_grant_device(VsmClient client,
629                            const char* zone,
630                            const char* device,
631                            uint32_t flags);
632
633 /**
634  * Revoke access to device
635  *
636  * @param[in] client vasum-server's client
637  * @param[in] zone zone name
638  * @param[in] device device path
639  * @return status of this function call
640  */
641 VsmStatus vsm_revoke_device(VsmClient client, const char* zone, const char* device);
642
643 /**
644  * Get array of netdev from given zone
645  *
646  * @param[in] client vasum-server's client
647  * @param[in] zone zone name
648  * @param[out] netdevIds array of netdev id
649  * @return status of this function call
650  * @remark Use vsm_array_string_free() to free memory occupied by @p netdevIds.
651  */
652 VsmStatus vsm_zone_get_netdevs(VsmClient client, const char* zone, VsmArrayString* netdevIds);
653
654
655 /**
656  * Get ipv4 address for given netdevId
657  *
658  * @param[in] client vasum-server's client
659  * @param[in] zone zone name
660  * @param[in] netdevId netdev id
661  * @param[out] addrs ip address array
662  * @return status of this function call
663  * @remark Use vsm_netdev_addr_free() to free memory occupied by address array.
664  */
665 VsmStatus vsm_netdev_get_ip_addr(VsmClient client,
666                                  const char* zone,
667                                  const char* netdevId,
668                                  VsmAddrList *addrs);
669
670 /**
671  * Release VsmAddrList
672  *
673  * @param addrs VsmAddrList
674  */
675 void vsm_addrlist_free(VsmAddrList addrs);
676
677 /**
678  * Get ipv4 address for given netdevId
679  *
680  * @param[in] client vasum-server's client
681  * @param[in] zone zone name
682  * @param[in] netdevId netdev id
683  * @param[out] addr ipv4 address
684  * @return status of this function call
685  */
686 VsmStatus vsm_netdev_get_ipv4_addr(VsmClient client,
687                                    const char* zone,
688                                    const char* netdevId,
689                                    struct in_addr *addr);
690
691 /**
692  * Get ipv6 address for given netdevId
693  *
694  * @param[in] client vasum-server's client
695  * @param[in] zone zone name
696  * @param[in] netdevId netdev id
697  * @param[out] addr ipv6 address
698  * @return status of this function call
699  */
700 VsmStatus vsm_netdev_get_ipv6_addr(VsmClient client,
701                                    const char* zone,
702                                    const char* netdevId,
703                                    struct in6_addr *addr);
704
705 /**
706  * Add ipv4 address for given netdevId
707  *
708  * @param[in] client vasum-server's client
709  * @param[in] zone zone name
710  * @param[in] netdevId netdev id
711  * @param[in] addr ipv4 address
712  * @param[in] prefix bit-length of the network prefix
713  * @return status of this function call
714  */
715 VsmStatus vsm_netdev_add_ipv4_addr(VsmClient client,
716                                    const char* zone,
717                                    const char* netdevId,
718                                    struct in_addr *addr,
719                                    int prefix);
720
721 /**
722  * Add ipv6 address for given netdevId
723  *
724  * @param[in] client vasum-server's client
725  * @param[in] zone zone name
726  * @param[in] netdevId netdev id
727  * @param[in] addr ipv6 address
728  * @param[in] prefix bit-length of the network prefix
729  * @return status of this function call
730  */
731 VsmStatus vsm_netdev_add_ipv6_addr(VsmClient client,
732                                    const char* zone,
733                                    const char* netdevId,
734                                    struct in6_addr *addr,
735                                    int prefix);
736
737 /**
738  * Remove ipv4 address from netdev
739  *
740  * @param[in] client vasum-server's client
741  * @param[in] zone zone name
742  * @param[in] netdevId network device id
743  * @param[in] addr ipv4 address
744  * @param[in] prefix bit-length of the network prefix
745  * @return status of this function call
746  */
747 VsmStatus vsm_netdev_del_ipv4_addr(VsmClient client,
748                                    const char* zone,
749                                    const char* netdevId,
750                                    struct in_addr* addr,
751                                    int prefix);
752
753 /**
754  * Remove ipv6 address from netdev
755  *
756  * @param[in] client vasum-server's client
757  * @param[in] zone zone name
758  * @param[in] netdevId network device id
759  * @param[in] addr ipv6 address
760  * @param[in] prefix bit-length of the network prefix
761  * @return status of this function call
762  */
763 VsmStatus vsm_netdev_del_ipv6_addr(VsmClient client,
764                                    const char* zone,
765                                    const char* netdevId,
766                                    struct in6_addr* addr,
767                                    int prefix);
768
769 /**
770  * Turn up a network device in the zone
771  *
772  * @param[in] client vasum-server's client
773  * @param[in] zone zone name
774  * @param[in] netdevId netdev id
775  * @return status of this function call
776  */
777 VsmStatus vsm_netdev_up(VsmClient client,
778                         const char* zone,
779                         const char* netdevId);
780
781 /**
782  * Turn down a network device in the zone
783  *
784  * @param[in] client vasum-server's client
785  * @param[in] zone zone name
786  * @param[in] netdevId netdev id
787  * @return status of this function call
788  */
789 VsmStatus vsm_netdev_down(VsmClient client,
790                           const char* zone,
791                           const char* netdevId);
792
793
794 /**
795  * Create veth netdev in zone
796  *
797  * @param[in] client vasum-server's client
798  * @param[in] zone zone name
799  * @param[in] zoneDev  Device ID in Zone network
800  * @param[in] hostDev  Device ID in Host network
801  * @return status of this function call
802  */
803 VsmStatus vsm_create_netdev_veth(VsmClient client,
804                                  const char* zone,
805                                  const char* zoneDev,
806                                  const char* hostDev);
807 /**
808  * Create macvlan in zone
809  *
810  * @param[in] client   vasum-server's client
811  * @param[in] zone     Zone name
812  * @param[in] zoneDev  Device ID in Zone network
813  * @param[in] hostDev  Device ID in Host network
814  * @param[in] mode     Mode with which macvlan will be created.
815  * @return status of this function call
816  *
817  * @see macvlan_mode
818  */
819 VsmStatus vsm_create_netdev_macvlan(VsmClient client,
820                                     const char* zone,
821                                     const char* zoneDev,
822                                     const char* hostDev,
823                                     enum macvlan_mode mode);
824 /**
825  * Create/move phys netdev in/to zone
826  *
827  * @param[in] client vasum-server's client
828  * @param[in] zone zone name
829  * @param[in] devId network device id
830  * @return status of this function call
831  */
832 VsmStatus vsm_create_netdev_phys(VsmClient client, const char* zone, const char* devId);
833
834 /**
835  * Get netdev informations
836  *
837  * @param[in] client vasum-server's client
838  * @param[in] zone zone name
839  * @param[in] netdevId network device id
840  * @param[out] netdev netdev informations
841  * @return status of this function call
842  * @remark Use vsm_netdev_free() to free memory occupied by @p netdev.
843  */
844 VsmStatus vsm_lookup_netdev_by_name(VsmClient client,
845                                     const char* zone,
846                                     const char* netdevId,
847                                     VsmNetdev* netdev);
848
849 /**
850  * Remove netdev from zone
851  *
852  * @param[in] client vasum-server's client
853  * @param[in] zone zone name
854  * @param[in] devId network device id
855  * @return status of this function call
856  */
857 VsmStatus vsm_destroy_netdev(VsmClient client, const char* zone, const char* devId);
858
859 /**
860  * Create file, directory or pipe in zone
861  *
862  * Declare file, directory or pipe that will be created while zone startup
863  *
864  * @param[in] client vasum-server's client
865  * @param[in] type file type
866  * @param[in] zone zone id
867  * @param[in] path path to file
868  * @param[in] flags if O_CREAT bit is set then file will be created in zone,
869  *                  otherwise file will by copied from host;
870  *                  it is meaningful only when O_CREAT is set
871  * @param[in] mode mode of file
872  * @return status of this function call
873  */
874 VsmStatus vsm_declare_file(VsmClient client,
875                            const char* zone,
876                            VsmFileType type,
877                            const char* path,
878                            int32_t flags,
879                            mode_t mode);
880
881 /**
882  * Create mount point in zone
883  *
884  * Declare mount that will be created while zone startup
885  * Parameters are passed to mount system function
886  *
887  * @param[in] client vasum-server's client
888  * @param[in] source device path (path in host)
889  * @param[in] zone zone id
890  * @param[in] target mount point (path in zone)
891  * @param[in] type filesystem type
892  * @param[in] flags mount flags as in mount function
893  * @param[in] data additional data as in mount function
894  * @return status of this function call
895  */
896 VsmStatus vsm_declare_mount(VsmClient client,
897                             const char* source,
898                             const char* zone,
899                             const char* target,
900                             const char* type,
901                             uint64_t flags,
902                             const char* data);
903
904 /**
905  * Create link in zone
906  *
907  * Declare link that will be created while zone startup
908  * Parameters are passed to link system function
909  *
910  * @param[in] client vasum-server's client
911  * @param[in] source path to link source (in host)
912  * @param[in] zone zone id
913  * @param[in] target path to link name (in zone)
914  * @return status of this function call
915  */
916 VsmStatus vsm_declare_link(VsmClient client,
917                            const char *source,
918                            const char* zone,
919                            const char *target);
920
921 /**
922  * Get all declarations
923  *
924  * Gets all declarations of resourcies
925  * (@see ::vsm_declare_link, @see ::vsm_declare_mount, @see ::vsm_declare_file)
926  *
927  * @param[in] client vasum-server's client
928  * @param[in] zone zone id
929  * @param[out] declarations array of declarations id
930  * @return status of this function call
931  */
932 VsmStatus vsm_list_declarations(VsmClient client,
933                                 const char* zone,
934                                 VsmArrayString* declarations);
935
936 /**
937  * Remove declaration
938  *
939  * Removes given declaration by its id (@see ::vsm_list_declarations)
940  *
941  * @param[in] client vasum-server's client
942  * @param[in] zone zone id
943  * @param[in] declaration declaration id
944  * @return status of this function call
945  */
946 VsmStatus vsm_remove_declaration(VsmClient client,
947                                  const char* zone,
948                                  VsmString declaration);
949
950 /**
951  * Clean up zones root directory
952  *
953  * Removes all unknown zones root directory entry
954  * @return status of this function call
955  */
956 VsmStatus vsm_clean_up_zones_root(VsmClient client);
957
958 /**
959  * Retrieve array size
960  *
961  * @return array size
962  */
963 unsigned int vsm_addrlist_size(VsmAddrList addrs);
964
965 /**
966  * Get address type for i'th entry
967  *
968  * @return network type (AF_INET or AF_INET6)
969  */
970 int vsm_addrlist_get_type(VsmAddrList addrs, unsigned int i);
971
972 /**
973  * Get pointer to in_addr property for i'th entry
974  * see inet_ntop man pages
975  *
976  * @return poiner of in_addr
977  */
978 const void *vsm_addrlist_get_addr(VsmAddrList addrs, unsigned int i);
979
980 /**
981  * Get address prefix for i'th entry
982  *
983  * @return adress prefix (mask bits count)
984  */
985 unsigned int vsm_addrlist_get_prefix(VsmAddrList addrs, unsigned int i);
986
987 #ifdef __cplusplus
988 }
989 #endif
990
991 #endif /* VASUM_CLIENT_H */
992 /*@}*/