b696dcfe9dabb739295a2f5380630d2653bd4c73
[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 /**
190  * Completion status of libvasum-client's functions
191  */
192 typedef enum {
193     VSMCLIENT_CUSTOM_ERROR,     /**< User specified error */
194     VSMCLIENT_IO_ERROR,         /**< Input/Output error */
195     VSMCLIENT_OPERATION_FAILED, /**< Operation failed */
196     VSMCLIENT_INVALID_ARGUMENT, /**< Invalid argument */
197     VSMCLIENT_OTHER_ERROR,      /**< Other error */
198     VSMCLIENT_SUCCESS           /**< Success */
199 } VsmStatus;
200
201 /**
202  * Subscription id
203  */
204 typedef unsigned int VsmSubscriptionId;
205
206 /**
207  * States of zone
208  */
209 typedef enum {
210     STOPPED,
211     STARTING,
212     RUNNING,
213     STOPPING,
214     ABORTING,
215     FREEZING,
216     FROZEN,
217     THAWED,
218     LOCKED,
219     MAX_STATE,
220     ACTIVATING = 128
221 } VsmZoneState;
222
223 /**
224  * Zone information
225  */
226 typedef void* VsmZone;
227
228 /**
229  * Netowrk device type
230  */
231 typedef enum {
232     VSMNETDEV_VETH,
233     VSMNETDEV_PHYS,
234     VSMNETDEV_MACVLAN
235 } VsmNetdevType;
236
237 /**
238  * Network device information
239  */
240 typedef void* VsmNetdev;
241
242 /**
243  * File type
244  */
245 typedef enum {
246     VSMFILE_DIRECTORY,
247     VSMFILE_FIFO,
248     VSMFILE_REGULAR
249 } VsmFileType;
250
251 /**
252  * Event dispacher types.
253  */
254 typedef enum {
255     VSMDISPATCHER_EXTERNAL,         /**< User must handle dispatching messages */
256     VSMDISPATCHER_INTERNAL          /**< Library will take care of dispatching messages */
257 } VsmDispacherType;
258
259 #ifndef __VASUM_WRAPPER_SOURCE__
260
261 /**
262  * Get file descriptor associated with event dispatcher of zone client
263  *
264  * The function vsm_get_poll_fd() returns the file descriptor associated with the event dispatcher of vsm client.
265  * The file descriptor can be bound to another I/O multiplexing facilities like epoll, select, and poll.
266  *
267  * @param[in] client vsm client
268  * @param[out] fd epoll file descriptor
269  * @return status of this function call
270 */
271 VsmStatus vsm_get_poll_fd(VsmClient client, int* fd);
272
273 /**
274  * Wait for an I/O event on a vsm client
275  *
276  * vsm_enter_eventloop() waits for event on the vsm client
277  *
278  * The call waits for a maximum time of timout milliseconds. Specifying a timeout of -1 makes vsm_enter_eventloop() wait indefinitely,
279  * while specifying a timeout equal to zero makes vsm_enter_eventloop() to return immediately even if no events are available.
280  *
281  * @param[in] client vasum-server's client
282  * @param[in] flags Reserved
283  * @param[in] timeout Timeout time (milisecond), -1 is infinite
284  * @return status of this function call
285 */
286 VsmStatus vsm_enter_eventloop(VsmClient client, int flags, int timeout);
287
288 /**
289  * Set dispatching method
290  *
291  * @param[in] client vasum-server's client
292  * @param[in] dispacher dispatching method
293  * @return status of this function call
294  */
295 VsmStatus vsm_set_dispatcher_type(VsmClient client, VsmDispacherType dispacher);
296
297 /**
298  * Get dispatching method
299  *
300  * @param[in] client vasum-server's client
301  * @param[out] dispacher dispatching method
302  * @return status of this function call
303  */
304 VsmStatus vsm_get_dispatcher_type(VsmClient client, VsmDispacherType* dispacher);
305
306 /**
307  * Create a new vasum-server's client.
308  *
309  * @return Created client pointer or NULL on failure.
310  */
311 VsmClient vsm_client_create();
312
313 /**
314  * Release client resources.
315  *
316  * @param[in] client vasum-server's client
317  */
318 void vsm_client_free(VsmClient client);
319
320 /**
321  * Get status code of last vasum-server communication.
322  *
323  * @param[in] client vasum-server's client
324  * @return status of this function call
325  */
326 VsmStatus vsm_get_status(VsmClient client);
327
328 /**
329  * Get status message of the last vasum-server communication.
330  *
331  * @param[in] client vasum-server's client
332  * @return last status message from vasum-server communication
333  */
334 const char* vsm_get_status_message(VsmClient client);
335
336 /**
337  * Connect client to the vasum-server.
338  *
339  * @param[in] client vasum-server's client
340  * @return status of this function call
341  */
342 VsmStatus vsm_connect(VsmClient client);
343
344 /**
345  * Connect client to the vasum-server via custom address.
346  *
347  * @param[in] client vasum-server's client
348  * @param[in] address dbus address
349  * @return status of this function call
350  */
351 VsmStatus vsm_connect_custom(VsmClient client, const char* address);
352
353 /**
354  * Disconnect client from vasum-server.
355  *
356  * @param[in] client vasum-server's client
357  * @return status of this function call
358  */
359 VsmStatus vsm_disconnect(VsmClient client);
360
361 /**
362  * Release VsmArrayString.
363  *
364  * @param[in] astring VsmArrayString
365  */
366 void vsm_array_string_free(VsmArrayString astring);
367
368 /**
369  * Release VsmString.
370  *
371  * @param string VsmString
372  */
373 void vsm_string_free(VsmString string);
374
375 /**
376  * Get zone id (offline)
377  *
378  * @param zone VsmZone
379  * @return zone id
380  */
381 VsmString vsm_zone_get_id(VsmZone zone);
382
383 /**
384  * Get zone terminal (offline)
385  *
386  * @param zone VsmZone
387  * @return zone terminal
388  */
389 int vsm_zone_get_terminal(VsmZone zone);
390
391 /**
392  * Get zone state (offline)
393  *
394  * @param zone VsmZone
395  * @return zone state
396  */
397 VsmZoneState vsm_zone_get_state(VsmZone zone);
398
399 /**
400  * Get zone rootfs path (offline)
401  *
402  * @param zone VsmZone
403  * @return zone rootfs path
404  */
405 VsmString vsm_zone_get_rootfs(VsmZone zone);
406
407 /**
408  * Release VsmZone
409  *
410  * @param zone VsmZone
411  */
412 void vsm_zone_free(VsmZone zone);
413
414 /**
415  * Get netdev name (offline)
416  *
417  * @param netdev VsmNetdev
418  * @return netdev name
419  */
420 VsmString vsm_netdev_get_name(VsmNetdev netdev);
421
422 /**
423  * Get netdev type (offline)
424  *
425  * @param netdev VsmNetdev
426  * @return netdev type
427  */
428 VsmNetdevType vsm_netdev_get_type(VsmNetdev netdev);
429
430 /**
431  * Release VsmNetdev
432  *
433  * @param netdev VsmNetdev
434  */
435 void vsm_netdev_free(VsmNetdev netdev);
436
437 /**
438  * Zone's D-Bus state change callback function signature.
439  *
440  * @param[in] zoneId affected zone id
441  * @param[in] address new D-Bus address
442  * @param data custom user's data pointer passed to vsm_add_state_callback() function
443  */
444 typedef void (*VsmZoneDbusStateCallback)(const char* zoneId,
445                                              const char* address,
446                                              void* data);
447
448 /**
449  * Lock the command queue exclusively.
450  *
451  * @param[in] client vasum-server's client
452  * @return status of this function call
453  */
454 VsmStatus vsm_lock_queue(VsmClient client);
455
456 /**
457  * Unlock the command queue.
458  *
459  * @param[in] client vasum-server's client
460  * @return status of this function call
461  */
462 VsmStatus vsm_unlock_queue(VsmClient client);
463
464 /**
465  * Get dbus address of each zone.
466  *
467  * @param[in] client vasum-server's client
468  * @param[out] keys array of zones name
469  * @param[out] values array of zones dbus address
470  * @return status of this function call
471  * @post keys[i] corresponds to values[i]
472  * @remark Use vsm_array_string_free() to free memory occupied by @p keys and @p values.
473  */
474 VsmStatus vsm_get_zone_dbuses(VsmClient client, VsmArrayString* keys, VsmArrayString* values);
475
476 /**
477  * Get zones name.
478  *
479  * @param[in] client vasum-server's client
480  * @param[out] array array of zones name
481  * @return status of this function call
482  * @remark Use vsm_array_string_free() to free memory occupied by @p array.
483  */
484 VsmStatus vsm_get_zone_ids(VsmClient client, VsmArrayString* array);
485
486 /**
487  * Get active (foreground) zone name.
488  *
489  * @param[in] client vasum-server's client
490  * @param[out] id active zone name
491  * @return status of this function call
492  * @remark Use @p vsm_string_free() to free memory occupied by @p id.
493  */
494 VsmStatus vsm_get_active_zone_id(VsmClient client, VsmString* id);
495
496 /**
497  * Get zone name of process with given pid.
498  *
499  * @param[in] client vasum-server's client
500  * @param[in] pid process id
501  * @param[out] id active zone name
502  * @return status of this function call
503  * @remark Use @p vsm_string_free() to free memory occupied by @p id.
504  */
505 VsmStatus vsm_lookup_zone_by_pid(VsmClient client, int pid, VsmString* id);
506
507 /**
508  * Get zone informations of zone with given id.
509  *
510  * @param[in] client vasum-server's client
511  * @param[in] id zone name
512  * @param[out] zone zone informations
513  * @return status of this function call
514  * @remark Use @p vsm_zone_free() to free memory occupied by @p zone
515  */
516 VsmStatus vsm_lookup_zone_by_id(VsmClient client, const char* id, VsmZone* zone);
517
518 /**
519  * Get zone name with given terminal.
520  *
521  * @param[in] client vasum-server's client
522  * @param[in] terminal terminal id
523  * @param[out] id zone name with given terminal
524  * @return status of this function call
525  * @remark Use @p vsm_string_free() to free memory occupied by @p id.
526  */
527 VsmStatus vsm_lookup_zone_by_terminal_id(VsmClient client, int terminal, VsmString* id);
528
529 /**
530  * Set active (foreground) zone.
531  *
532  * @param[in] client vasum-server's client
533  * @param[in] id zone name
534  * @return status of this function call
535  */
536 VsmStatus vsm_set_active_zone(VsmClient client, const char* id);
537
538 /**
539  * Create and add zone
540  *
541  * @param[in] client vasum-server's client
542  * @param[in] id zone id
543  * @param[in] tname template name, NULL is equivalent to "default"
544  * @return status of this function call
545  */
546 VsmStatus vsm_create_zone(VsmClient client, const char* id, const char* tname);
547
548 /**
549  * Remove zone
550  *
551  * @param[in] client vasum-server's client
552  * @param[in] id zone id
553  * @param[in] force if 0 data will be kept, otherwise data will be lost
554  * @return status of this function call
555  */
556 VsmStatus vsm_destroy_zone(VsmClient client, const char* id, int force);
557
558 /**
559  * Shutdown zone
560  *
561  * @param[in] client vasum-server's client
562  * @param[in] id zone name
563  * @return status of this function call
564  */
565 VsmStatus vsm_shutdown_zone(VsmClient client, const char* id);
566
567 /**
568  * Start zone
569  *
570  * @param[in] client vasum-server's client
571  * @param[in] id zone name
572  * @return status of this function call
573  */
574 VsmStatus vsm_start_zone(VsmClient client, const char* id);
575
576 /**
577  * Lock zone
578  *
579  * @param[in] client vasum-server's client
580  * @param[in] id zone name
581  * @return status of this function call
582  */
583 VsmStatus vsm_lock_zone(VsmClient client, const char* id);
584
585 /**
586  * Unlock zone
587  *
588  * @param[in] client vasum-server's client
589  * @param[in] id zone name
590  * @return status of this function call
591  */
592 VsmStatus vsm_unlock_zone(VsmClient client, const char* id);
593
594 /**
595  * Register dbus state change callback function.
596  *
597  * @note The callback function will be invoked on a different thread.
598  *
599  * @param[in] client vasum-server's client
600  * @param[in] zoneDbusStateCallback callback function
601  * @param[in] data some extra data that will be passed to callback function
602  * @param[out] subscriptionId subscription identifier that can be used to unsubscribe signal,
603  *                      pointer can be NULL.
604  * @return status of this function call
605  */
606 VsmStatus vsm_add_state_callback(VsmClient client,
607                                  VsmZoneDbusStateCallback zoneDbusStateCallback,
608                                  void* data,
609                                  VsmSubscriptionId* subscriptionId);
610
611 /**
612  * Unregister dbus state change callback function.
613  *
614  * @param[in] client vasum-server's client
615  * @param[in] subscriptionId subscription identifier returned by vsm_add_state_callback
616  * @return status of this function call
617  */
618 VsmStatus vsm_del_state_callback(VsmClient client, VsmSubscriptionId subscriptionId);
619
620 /**
621  * Grant access to device
622  *
623  * @param[in] client vasum-server's client
624  * @param[in] zone zone name
625  * @param[in] device device path
626  * @param[in] flags access flags
627  * @return status of this function call
628  */
629 VsmStatus vsm_grant_device(VsmClient client,
630                            const char* zone,
631                            const char* device,
632                            uint32_t flags);
633
634 /**
635  * Revoke access to device
636  *
637  * @param[in] client vasum-server's client
638  * @param[in] zone zone name
639  * @param[in] device device path
640  * @return status of this function call
641  */
642 VsmStatus vsm_revoke_device(VsmClient client, const char* zone, const char* device);
643
644 /**
645  * Get array of netdev from given zone
646  *
647  * @param[in] client vasum-server's client
648  * @param[in] zone zone name
649  * @param[out] netdevIds array of netdev id
650  * @return status of this function call
651  * @remark Use vsm_array_string_free() to free memory occupied by @p netdevIds.
652  */
653 VsmStatus vsm_zone_get_netdevs(VsmClient client, const char* zone, VsmArrayString* netdevIds);
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] addr ipv4 address
662  * @return status of this function call
663  */
664 VsmStatus vsm_netdev_get_ipv4_addr(VsmClient client,
665                                    const char* zone,
666                                    const char* netdevId,
667                                    struct in_addr *addr);
668
669 /**
670  * Get ipv6 address for given netdevId
671  *
672  * @param[in] client vasum-server's client
673  * @param[in] zone zone name
674  * @param[in] netdevId netdev id
675  * @param[out] addr ipv6 address
676  * @return status of this function call
677  */
678 VsmStatus vsm_netdev_get_ipv6_addr(VsmClient client,
679                                    const char* zone,
680                                    const char* netdevId,
681                                    struct in6_addr *addr);
682
683 /**
684  * Set ipv4 address for given netdevId
685  *
686  * @param[in] client vasum-server's client
687  * @param[in] zone zone name
688  * @param[in] netdevId netdev id
689  * @param[in] addr ipv4 address
690  * @param[in] prefix bit-length of the network prefix
691  * @return status of this function call
692  */
693 VsmStatus vsm_netdev_set_ipv4_addr(VsmClient client,
694                                    const char* zone,
695                                    const char* netdevId,
696                                    struct in_addr *addr,
697                                    int prefix);
698
699 /**
700  * Set ipv6 address for given netdevId
701  *
702  * @param[in] client vasum-server's client
703  * @param[in] zone zone name
704  * @param[in] netdevId netdev id
705  * @param[in] addr ipv6 address
706  * @param[in] prefix bit-length of the network prefix
707  * @return status of this function call
708  */
709 VsmStatus vsm_netdev_set_ipv6_addr(VsmClient client,
710                                    const char* zone,
711                                    const char* netdevId,
712                                    struct in6_addr *addr,
713                                    int prefix);
714
715 /**
716  * Remove ipv4 address from netdev
717  *
718  * @param[in] client vasum-server's client
719  * @param[in] zone zone name
720  * @param[in] netdevId network device id
721  * @param[in] addr ipv4 address
722  * @param[in] prefix bit-length of the network prefix
723  * @return status of this function call
724  */
725 VsmStatus vsm_netdev_del_ipv4_addr(VsmClient client,
726                                    const char* zone,
727                                    const char* netdevId,
728                                    struct in_addr* addr,
729                                    int prefix);
730
731 /**
732  * Remove ipv6 address from netdev
733  *
734  * @param[in] client vasum-server's client
735  * @param[in] zone zone name
736  * @param[in] netdevId network device id
737  * @param[in] addr ipv6 address
738  * @param[in] prefix bit-length of the network prefix
739  * @return status of this function call
740  */
741 VsmStatus vsm_netdev_del_ipv6_addr(VsmClient client,
742                                    const char* zone,
743                                    const char* netdevId,
744                                    struct in6_addr* addr,
745                                    int prefix);
746
747 /**
748  * Turn up a network device in the zone
749  *
750  * @param[in] client vasum-server's client
751  * @param[in] zone zone name
752  * @param[in] netdevId netdev id
753  * @return status of this function call
754  */
755 VsmStatus vsm_netdev_up(VsmClient client,
756                         const char* zone,
757                         const char* netdevId);
758
759 /**
760  * Turn down a network device in the zone
761  *
762  * @param[in] client vasum-server's client
763  * @param[in] zone zone name
764  * @param[in] netdevId netdev id
765  * @return status of this function call
766  */
767 VsmStatus vsm_netdev_down(VsmClient client,
768                           const char* zone,
769                           const char* netdevId);
770
771
772 /**
773  * Create veth netdev in zone
774  *
775  * @param[in] client vasum-server's client
776  * @param[in] zone zone name
777  * @param[in] zoneDev  Device ID in Zone network
778  * @param[in] hostDev  Device ID in Host network
779  * @return status of this function call
780  */
781 VsmStatus vsm_create_netdev_veth(VsmClient client,
782                                  const char* zone,
783                                  const char* zoneDev,
784                                  const char* hostDev);
785 /**
786  * Create macvlan in zone
787  *
788  * @param[in] client   vasum-server's client
789  * @param[in] zone     Zone name
790  * @param[in] zoneDev  Device ID in Zone network
791  * @param[in] hostDev  Device ID in Host network
792  * @param[in] mode     Mode with which macvlan will be created.
793  * @return status of this function call
794  *
795  * @see macvlan_mode
796  */
797 VsmStatus vsm_create_netdev_macvlan(VsmClient client,
798                                     const char* zone,
799                                     const char* zoneDev,
800                                     const char* hostDev,
801                                     enum macvlan_mode mode);
802 /**
803  * Create/move phys netdev in/to zone
804  *
805  * @param[in] client vasum-server's client
806  * @param[in] zone zone name
807  * @param[in] devId network device id
808  * @return status of this function call
809  */
810 VsmStatus vsm_create_netdev_phys(VsmClient client, const char* zone, const char* devId);
811
812 /**
813  * Get netdev informations
814  *
815  * @param[in] client vasum-server's client
816  * @param[in] zone zone name
817  * @param[in] netdevId network device id
818  * @param[out] netdev netdev informations
819  * @return status of this function call
820  * @remark Use vsm_netdev_free() to free memory occupied by @p netdev.
821  */
822 VsmStatus vsm_lookup_netdev_by_name(VsmClient client,
823                                     const char* zone,
824                                     const char* netdevId,
825                                     VsmNetdev* netdev);
826
827 /**
828  * Remove netdev from zone
829  *
830  * @param[in] client vasum-server's client
831  * @param[in] zone zone name
832  * @param[in] devId network device id
833  * @return status of this function call
834  */
835 VsmStatus vsm_destroy_netdev(VsmClient client, const char* zone, const char* devId);
836
837 /**
838  * Create file, directory or pipe in zone
839  *
840  * Declare file, directory or pipe that will be created while zone startup
841  *
842  * @param[in] client vasum-server's client
843  * @param[in] type file type
844  * @param[in] zone zone id
845  * @param[in] path path to file
846  * @param[in] flags if O_CREAT bit is set then file will be created in zone,
847  *                  otherwise file will by copied from host;
848  *                  it is meaningful only when O_CREAT is set
849  * @param[in] mode mode of file
850  * @return status of this function call
851  */
852 VsmStatus vsm_declare_file(VsmClient client,
853                            const char* zone,
854                            VsmFileType type,
855                            const char* path,
856                            int32_t flags,
857                            mode_t mode);
858
859 /**
860  * Create mount point in zone
861  *
862  * Declare mount that will be created while zone startup
863  * Parameters are passed to mount system function
864  *
865  * @param[in] client vasum-server's client
866  * @param[in] source device path (path in host)
867  * @param[in] zone zone id
868  * @param[in] target mount point (path in zone)
869  * @param[in] type filesystem type
870  * @param[in] flags mount flags as in mount function
871  * @param[in] data additional data as in mount function
872  * @return status of this function call
873  */
874 VsmStatus vsm_declare_mount(VsmClient client,
875                             const char* source,
876                             const char* zone,
877                             const char* target,
878                             const char* type,
879                             uint64_t flags,
880                             const char* data);
881
882 /**
883  * Create link in zone
884  *
885  * Declare link that will be created while zone startup
886  * Parameters are passed to link system function
887  *
888  * @param[in] client vasum-server's client
889  * @param[in] source path to link source (in host)
890  * @param[in] zone zone id
891  * @param[in] target path to link name (in zone)
892  * @return status of this function call
893  */
894 VsmStatus vsm_declare_link(VsmClient client,
895                            const char *source,
896                            const char* zone,
897                            const char *target);
898
899 /**
900  * Get all declarations
901  *
902  * Gets all declarations of resourcies
903  * (@see ::vsm_declare_link, @see ::vsm_declare_mount, @see ::vsm_declare_file)
904  *
905  * @param[in] client vasum-server's client
906  * @param[in] zone zone id
907  * @param[out] declarations array of declarations id
908  * @return status of this function call
909  */
910 VsmStatus vsm_list_declarations(VsmClient client,
911                                 const char* zone,
912                                 VsmArrayString* declarations);
913
914 /**
915  * Remove declaration
916  *
917  * Removes given declaration by its id (@see ::vsm_list_declarations)
918  *
919  * @param[in] client vasum-server's client
920  * @param[in] zone zone id
921  * @param[in] declaration declaration id
922  * @return status of this function call
923  */
924 VsmStatus vsm_remove_declaration(VsmClient client,
925                                  const char* zone,
926                                  VsmString declaration);
927
928 /**
929  * Clean up zones root directory
930  *
931  * Removes all unknown zones root directory entry
932  * @return status of this function call
933  */
934 VsmStatus vsm_clean_up_zones_root(VsmClient client);
935
936 #endif /* __VASUM_WRAPPER_SOURCE__ */
937
938 #ifdef __cplusplus
939 }
940 #endif
941
942 #endif /* VASUM_CLIENT_H */
943 /*@}*/