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 * 3. Neither the name of the copyright holder nor the names of its contributors
16 * may be used to endorse or promote products derived from this software without
17 * specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 * Opaque definition so calling application can just pass a
41 * pointer to it for library use.
44 typedef struct libifc_handle libifc_handle_t;
46 struct libifc_capabilities {
47 /** Current capabilities (ifconfig prints this as 'options')*/
49 /** Requested capabilities (ifconfig prints this as 'capabilities')*/
54 /** Retrieves a new state object for use in other API calls.
57 * // Create state object
58 * libifc_handle_t *lifh = libifc_open();
62 * // Dispose of the state object
67 libifc_handle_t *libifc_open(void);
69 /** Frees resources held in the provided state object.
70 * @param h The state object to close.
71 * @see #libifc_open(void)
73 void libifc_close(libifc_handle_t *h);
75 /** Identifies what kind of error occured. */
76 libifc_errtype libifc_err_errtype(libifc_handle_t *h);
78 /** Retrieves the errno associated with the error, if any. */
79 int libifc_err_errno(libifc_handle_t *h);
81 /** If error type was IOCTL, this identifies which request failed. */
82 unsigned long libifc_err_ioctlreq(libifc_handle_t *h);
84 int libifc_get_description(libifc_handle_t *h, const char *name,
86 int libifc_set_description(libifc_handle_t *h, const char *name,
87 const char *newdescription);
88 int libifc_unset_description(libifc_handle_t *h, const char *name);
89 int libifc_set_name(libifc_handle_t *h, const char *name, const char *newname);
90 int libifc_set_mtu(libifc_handle_t *h, const char *name, const int mtu);
91 int libifc_get_mtu(libifc_handle_t *h, const char *name, int *mtu);
93 int libifc_set_metric(libifc_handle_t *h, const char *name, const int metric);
94 int libifc_get_metric(libifc_handle_t *h, const char *name, int *metric);
96 int libifc_set_capability(libifc_handle_t *h, const char *name,
97 const int capability);
98 int libifc_get_capability(libifc_handle_t *h, const char *name,
99 struct libifc_capabilities *capability);
101 /** Destroy a virtual interface
102 * @param name Interface to destroy
104 int libifc_destroy_interface(libifc_handle_t *h, const char *name);
106 /** Creates a (virtual) interface
107 * @param name Name of interface to create. Example: bridge or bridge42
108 * @param name ifname Is set to actual name of created interface
110 int libifc_create_interface(libifc_handle_t *h, const char *name,