2 * Copyright (c) 2016, Marie Helene Kvello-Aune
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * thislist of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation and/or
13 * other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 * Opaque definition so calling application can just pass a
37 * pointer to it for library use.
39 struct ifconfig_handle;
40 typedef struct ifconfig_handle ifconfig_handle_t;
42 struct ifconfig_capabilities {
43 /** Current capabilities (ifconfig prints this as 'options')*/
45 /** Requested capabilities (ifconfig prints this as 'capabilities')*/
49 /** Retrieves a new state object for use in other API calls.
52 * // Create state object
53 * ifconfig_handle_t *lifh = ifconfig_open();
57 * // Dispose of the state object
58 * ifconfig_close(lifh);
62 ifconfig_handle_t *ifconfig_open(void);
64 /** Frees resources held in the provided state object.
65 * @param h The state object to close.
66 * @see #ifconfig_open(void)
68 void ifconfig_close(ifconfig_handle_t *h);
70 /** Identifies what kind of error occured. */
71 ifconfig_errtype ifconfig_err_errtype(ifconfig_handle_t *h);
73 /** Retrieves the errno associated with the error, if any. */
74 int ifconfig_err_errno(ifconfig_handle_t *h);
76 /** If error type was IOCTL, this identifies which request failed. */
77 unsigned long ifconfig_err_ioctlreq(ifconfig_handle_t *h);
78 int ifconfig_get_description(ifconfig_handle_t *h, const char *name,
80 int ifconfig_set_description(ifconfig_handle_t *h, const char *name,
81 const char *newdescription);
82 int ifconfig_unset_description(ifconfig_handle_t *h, const char *name);
83 int ifconfig_set_name(ifconfig_handle_t *h, const char *name,
85 int ifconfig_set_mtu(ifconfig_handle_t *h, const char *name, const int mtu);
86 int ifconfig_get_mtu(ifconfig_handle_t *h, const char *name, int *mtu);
87 int ifconfig_set_metric(ifconfig_handle_t *h, const char *name,
89 int ifconfig_get_metric(ifconfig_handle_t *h, const char *name, int *metric);
90 int ifconfig_set_capability(ifconfig_handle_t *h, const char *name,
91 const int capability);
92 int ifconfig_get_capability(ifconfig_handle_t *h, const char *name,
93 struct ifconfig_capabilities *capability);
95 /** Destroy a virtual interface
96 * @param name Interface to destroy
98 int ifconfig_destroy_interface(ifconfig_handle_t *h, const char *name);
100 /** Creates a (virtual) interface
101 * @param name Name of interface to create. Example: bridge or bridge42
102 * @param name ifname Is set to actual name of created interface
104 int ifconfig_create_interface(ifconfig_handle_t *h, const char *name,