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