1ec214349SKristof Provost /* 2b1d757bcSAlan Somers * Copyright (c) 2016-2017, Marie Helene Kvello-Aune 3ec214349SKristof Provost * All rights reserved. 4ec214349SKristof Provost * 5ec214349SKristof Provost * Redistribution and use in source and binary forms, with or without modification, 6ec214349SKristof Provost * are permitted provided that the following conditions are met: 7ec214349SKristof Provost * 8ec214349SKristof Provost * 1. Redistributions of source code must retain the above copyright notice, 9ec214349SKristof Provost * thislist of conditions and the following disclaimer. 10ec214349SKristof Provost * 11ec214349SKristof Provost * 2. Redistributions in binary form must reproduce the above copyright notice, 12ec214349SKristof Provost * this list of conditions and the following disclaimer in the documentation and/or 13ec214349SKristof Provost * other materials provided with the distribution. 14ec214349SKristof Provost * 15ec214349SKristof Provost * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16ec214349SKristof Provost * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17ec214349SKristof Provost * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18ec214349SKristof Provost * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19ec214349SKristof Provost * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20ec214349SKristof Provost * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21ec214349SKristof Provost * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22ec214349SKristof Provost * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23ec214349SKristof Provost * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24ec214349SKristof Provost * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25ec214349SKristof Provost * 26ec214349SKristof Provost * $FreeBSD$ 27ec214349SKristof Provost */ 28ec214349SKristof Provost 29ec214349SKristof Provost #pragma once 30ec214349SKristof Provost 3194cba803SRyan Moeller #include <sys/types.h> 3294cba803SRyan Moeller 3394cba803SRyan Moeller #include <net/if.h> 3494cba803SRyan Moeller 35b1d757bcSAlan Somers #include <netinet/in.h> 36*40e04359SKristof Provost #include <netinet/ip_carp.h> 37b1d757bcSAlan Somers #include <netinet6/in6_var.h> 38b1d757bcSAlan Somers 39b1d757bcSAlan Somers #define ND6_IFF_DEFAULTIF 0x8000 40b1d757bcSAlan Somers 41ec214349SKristof Provost typedef enum { 42b1d757bcSAlan Somers OK = 0, 43b1d757bcSAlan Somers OTHER, 44b1d757bcSAlan Somers IOCTL, 45*40e04359SKristof Provost SOCKET, 46*40e04359SKristof Provost NETLINK 47ec214349SKristof Provost } ifconfig_errtype; 48ec214349SKristof Provost 49ec214349SKristof Provost /* 50ec214349SKristof Provost * Opaque definition so calling application can just pass a 51ec214349SKristof Provost * pointer to it for library use. 52ec214349SKristof Provost */ 53ec214349SKristof Provost struct ifconfig_handle; 54ec214349SKristof Provost typedef struct ifconfig_handle ifconfig_handle_t; 55ec214349SKristof Provost 56b1d757bcSAlan Somers struct ifaddrs; 57e5539fb6SRyan Moeller struct ifbropreq; 58e5539fb6SRyan Moeller struct ifbreq; 59b1d757bcSAlan Somers struct in6_ndireq; 60b1d757bcSAlan Somers struct lagg_reqall; 61b1d757bcSAlan Somers struct lagg_reqflags; 62b1d757bcSAlan Somers struct lagg_reqopts; 63b1d757bcSAlan Somers struct lagg_reqport; 64b1d757bcSAlan Somers 65e5539fb6SRyan Moeller /** Stores extra info associated with a bridge(4) interface */ 66e5539fb6SRyan Moeller struct ifconfig_bridge_status { 67e5539fb6SRyan Moeller struct ifbropreq *params; /**< current operational parameters */ 68e5539fb6SRyan Moeller struct ifbreq *members; /**< list of bridge members */ 69e5539fb6SRyan Moeller size_t members_count; /**< how many member interfaces */ 70e5539fb6SRyan Moeller uint32_t cache_size; /**< size of address cache */ 71e5539fb6SRyan Moeller uint32_t cache_lifetime; /**< address cache entry lifetime */ 72e5539fb6SRyan Moeller }; 73e5539fb6SRyan Moeller 74ec214349SKristof Provost struct ifconfig_capabilities { 75ec214349SKristof Provost /** Current capabilities (ifconfig prints this as 'options')*/ 76ec214349SKristof Provost int curcap; 77ec214349SKristof Provost /** Requested capabilities (ifconfig prints this as 'capabilities')*/ 78ec214349SKristof Provost int reqcap; 79ec214349SKristof Provost }; 80ec214349SKristof Provost 81b1d757bcSAlan Somers /** Stores extra info associated with an inet address */ 82b1d757bcSAlan Somers struct ifconfig_inet_addr { 83b1d757bcSAlan Somers const struct sockaddr_in *sin; 84b1d757bcSAlan Somers const struct sockaddr_in *netmask; 85b1d757bcSAlan Somers const struct sockaddr_in *dst; 86b1d757bcSAlan Somers const struct sockaddr_in *broadcast; 87b1d757bcSAlan Somers int prefixlen; 88b1d757bcSAlan Somers uint8_t vhid; 89b1d757bcSAlan Somers }; 90b1d757bcSAlan Somers 91b1d757bcSAlan Somers /** Stores extra info associated with an inet6 address */ 92b1d757bcSAlan Somers struct ifconfig_inet6_addr { 93b1d757bcSAlan Somers struct sockaddr_in6 *sin6; 94b1d757bcSAlan Somers struct sockaddr_in6 *dstin6; 95b1d757bcSAlan Somers struct in6_addrlifetime lifetime; 96b1d757bcSAlan Somers int prefixlen; 97b1d757bcSAlan Somers uint32_t flags; 98b1d757bcSAlan Somers uint8_t vhid; 99b1d757bcSAlan Somers }; 100b1d757bcSAlan Somers 101b1d757bcSAlan Somers /** Stores extra info associated with a lagg(4) interface */ 102b1d757bcSAlan Somers struct ifconfig_lagg_status { 103b1d757bcSAlan Somers struct lagg_reqall *ra; 104b1d757bcSAlan Somers struct lagg_reqopts *ro; 105b1d757bcSAlan Somers struct lagg_reqflags *rf; 106b1d757bcSAlan Somers }; 107b1d757bcSAlan Somers 108ec214349SKristof Provost /** Retrieves a new state object for use in other API calls. 109ec214349SKristof Provost * Example usage: 110ec214349SKristof Provost *{@code 111ec214349SKristof Provost * // Create state object 112b1d757bcSAlan Somers * ifconfig_handle_t *lifh; 113b1d757bcSAlan Somers * lifh = ifconfig_open(); 114b1d757bcSAlan Somers * if (lifh == NULL) { 115b1d757bcSAlan Somers * // Handle error 116b1d757bcSAlan Somers * } 117ec214349SKristof Provost * 118b1d757bcSAlan Somers * // Do stuff with the handle 119ec214349SKristof Provost * 120ec214349SKristof Provost * // Dispose of the state object 121ec214349SKristof Provost * ifconfig_close(lifh); 122ec214349SKristof Provost * lifh = NULL; 123ec214349SKristof Provost *} 124ec214349SKristof Provost */ 125ec214349SKristof Provost ifconfig_handle_t *ifconfig_open(void); 126ec214349SKristof Provost 127ec214349SKristof Provost /** Frees resources held in the provided state object. 128ec214349SKristof Provost * @param h The state object to close. 129ec214349SKristof Provost * @see #ifconfig_open(void) 130ec214349SKristof Provost */ 131ec214349SKristof Provost void ifconfig_close(ifconfig_handle_t *h); 132ec214349SKristof Provost 13309703627SGordon Bergling /** Identifies what kind of error occurred. */ 134ec214349SKristof Provost ifconfig_errtype ifconfig_err_errtype(ifconfig_handle_t *h); 135ec214349SKristof Provost 136ec214349SKristof Provost /** Retrieves the errno associated with the error, if any. */ 137ec214349SKristof Provost int ifconfig_err_errno(ifconfig_handle_t *h); 138ec214349SKristof Provost 139b1d757bcSAlan Somers typedef void (*ifconfig_foreach_func_t)(ifconfig_handle_t *h, 140b1d757bcSAlan Somers struct ifaddrs *ifa, void *udata); 141b1d757bcSAlan Somers 142b1d757bcSAlan Somers /** Iterate over every network interface 143b1d757bcSAlan Somers * @param h An open ifconfig state object 144b1d757bcSAlan Somers * @param cb A callback function to call with a pointer to each interface 145b1d757bcSAlan Somers * @param udata An opaque value that will be passed to the callback. 146b1d757bcSAlan Somers * @return 0 on success, nonzero if the list could not be iterated 147b1d757bcSAlan Somers */ 148b1d757bcSAlan Somers int ifconfig_foreach_iface(ifconfig_handle_t *h, ifconfig_foreach_func_t cb, 149b1d757bcSAlan Somers void *udata); 150b1d757bcSAlan Somers 151b1d757bcSAlan Somers /** Iterate over every address on a single network interface 152b1d757bcSAlan Somers * @param h An open ifconfig state object 153b1d757bcSAlan Somers * @param ifa A pointer that was supplied by a previous call to 154b1d757bcSAlan Somers * ifconfig_foreach_iface 155b1d757bcSAlan Somers * @param udata An opaque value that will be passed to the callback. 156b1d757bcSAlan Somers * @param cb A callback function to call with a pointer to each ifaddr 157b1d757bcSAlan Somers */ 158b1d757bcSAlan Somers void ifconfig_foreach_ifaddr(ifconfig_handle_t *h, struct ifaddrs *ifa, 159b1d757bcSAlan Somers ifconfig_foreach_func_t cb, void *udata); 160b1d757bcSAlan Somers 161ec214349SKristof Provost /** If error type was IOCTL, this identifies which request failed. */ 162ec214349SKristof Provost unsigned long ifconfig_err_ioctlreq(ifconfig_handle_t *h); 163ec214349SKristof Provost int ifconfig_get_description(ifconfig_handle_t *h, const char *name, 164ec214349SKristof Provost char **description); 165ec214349SKristof Provost int ifconfig_set_description(ifconfig_handle_t *h, const char *name, 166ec214349SKristof Provost const char *newdescription); 167ec214349SKristof Provost int ifconfig_unset_description(ifconfig_handle_t *h, const char *name); 1689a2ff315SKristof Provost int ifconfig_set_name(ifconfig_handle_t *h, const char *name, 1699a2ff315SKristof Provost const char *newname); 170c2803f1aSAndriy Voskoboinyk int ifconfig_get_orig_name(ifconfig_handle_t *h, const char *ifname, 171c2803f1aSAndriy Voskoboinyk char **orig_name); 172b1d757bcSAlan Somers int ifconfig_set_fib(ifconfig_handle_t *h, const char *name, int fib); 173b1d757bcSAlan Somers int ifconfig_get_fib(ifconfig_handle_t *h, const char *name, int *fib); 174ec214349SKristof Provost int ifconfig_set_mtu(ifconfig_handle_t *h, const char *name, const int mtu); 175ec214349SKristof Provost int ifconfig_get_mtu(ifconfig_handle_t *h, const char *name, int *mtu); 176b1d757bcSAlan Somers int ifconfig_get_nd6(ifconfig_handle_t *h, const char *name, 177b1d757bcSAlan Somers struct in6_ndireq *nd); 1789a2ff315SKristof Provost int ifconfig_set_metric(ifconfig_handle_t *h, const char *name, 1799a2ff315SKristof Provost const int metric); 180ec214349SKristof Provost int ifconfig_get_metric(ifconfig_handle_t *h, const char *name, int *metric); 181ec214349SKristof Provost int ifconfig_set_capability(ifconfig_handle_t *h, const char *name, 182ec214349SKristof Provost const int capability); 183ec214349SKristof Provost int ifconfig_get_capability(ifconfig_handle_t *h, const char *name, 184ec214349SKristof Provost struct ifconfig_capabilities *capability); 185ec214349SKristof Provost 186b1d757bcSAlan Somers /** Retrieve the list of groups to which this interface belongs 187b1d757bcSAlan Somers * @param h An open ifconfig state object 188b1d757bcSAlan Somers * @param name The interface name 189b1d757bcSAlan Somers * @param ifgr return argument. The caller is responsible for freeing 190b1d757bcSAlan Somers * ifgr->ifgr_groups 191b1d757bcSAlan Somers * @return 0 on success, nonzero on failure 192b1d757bcSAlan Somers */ 193b1d757bcSAlan Somers int ifconfig_get_groups(ifconfig_handle_t *h, const char *name, 194b1d757bcSAlan Somers struct ifgroupreq *ifgr); 195b1d757bcSAlan Somers int ifconfig_get_ifstatus(ifconfig_handle_t *h, const char *name, 196b1d757bcSAlan Somers struct ifstat *stat); 197b1d757bcSAlan Somers 198b1d757bcSAlan Somers /** Retrieve the interface media information 199b1d757bcSAlan Somers * @param h An open ifconfig state object 200b1d757bcSAlan Somers * @param name The interface name 201b1d757bcSAlan Somers * @param ifmr Return argument. The caller is responsible for freeing it 202b1d757bcSAlan Somers * @return 0 on success, nonzero on failure 203b1d757bcSAlan Somers */ 204b1d757bcSAlan Somers int ifconfig_media_get_mediareq(ifconfig_handle_t *h, const char *name, 205b1d757bcSAlan Somers struct ifmediareq **ifmr); 206c4ba4aa5SRyan Moeller 207b1d757bcSAlan Somers const char *ifconfig_media_get_status(const struct ifmediareq *ifmr); 208c4ba4aa5SRyan Moeller 209c4ba4aa5SRyan Moeller typedef int ifmedia_t; 210c4ba4aa5SRyan Moeller 211c4ba4aa5SRyan Moeller #define INVALID_IFMEDIA ((ifmedia_t)-1) 212c4ba4aa5SRyan Moeller 213c4ba4aa5SRyan Moeller /** Retrieve the name of a media type 214c4ba4aa5SRyan Moeller * @param media The media to be named 215c4ba4aa5SRyan Moeller * @return A pointer to the media type name, or NULL on failure 216c4ba4aa5SRyan Moeller */ 217c4ba4aa5SRyan Moeller const char *ifconfig_media_get_type(ifmedia_t media); 218c4ba4aa5SRyan Moeller 219c4ba4aa5SRyan Moeller /** Retrieve a media type by its name 220c4ba4aa5SRyan Moeller * @param name The name of a media type 221c4ba4aa5SRyan Moeller * @return The media type value, or INVALID_IFMEDIA on failure 222c4ba4aa5SRyan Moeller */ 223c4ba4aa5SRyan Moeller ifmedia_t ifconfig_media_lookup_type(const char *name); 224c4ba4aa5SRyan Moeller 225c4ba4aa5SRyan Moeller /** Retrieve the name of a media subtype 226c4ba4aa5SRyan Moeller * @param media The media subtype to be named 227c4ba4aa5SRyan Moeller * @return A pointer to the media subtype name, or NULL on failure 228c4ba4aa5SRyan Moeller */ 229c4ba4aa5SRyan Moeller const char *ifconfig_media_get_subtype(ifmedia_t media); 230c4ba4aa5SRyan Moeller 231c4ba4aa5SRyan Moeller /** Retrieve a media subtype by its name 232c4ba4aa5SRyan Moeller * @param media The top level media type whose subtype we want 233c4ba4aa5SRyan Moeller * @param name The name of a media subtype 234c4ba4aa5SRyan Moeller * @return The media subtype value, or INVALID_IFMEDIA on failure 235c4ba4aa5SRyan Moeller */ 236c4ba4aa5SRyan Moeller ifmedia_t ifconfig_media_lookup_subtype(ifmedia_t media, const char *name); 237c4ba4aa5SRyan Moeller 238c4ba4aa5SRyan Moeller /** Retrieve the name of a media mode 239c4ba4aa5SRyan Moeller * @param media The media mode to be named 240c4ba4aa5SRyan Moeller * @return A pointer to the media mode name, or NULL on failure 241c4ba4aa5SRyan Moeller */ 242c4ba4aa5SRyan Moeller const char *ifconfig_media_get_mode(ifmedia_t media); 243c4ba4aa5SRyan Moeller 244c4ba4aa5SRyan Moeller /** Retrieve a media mode by its name 245c4ba4aa5SRyan Moeller * @param media The top level media type whose mode we want 246c4ba4aa5SRyan Moeller * @param name The name of a media mode 247c4ba4aa5SRyan Moeller * @return The media mode value, or INVALID_IFMEDIA on failure 248c4ba4aa5SRyan Moeller */ 249c4ba4aa5SRyan Moeller ifmedia_t ifconfig_media_lookup_mode(ifmedia_t media, const char *name); 250c4ba4aa5SRyan Moeller 251c4ba4aa5SRyan Moeller /** Retrieve an array of media options 252c4ba4aa5SRyan Moeller * @param media The media for which to obtain the options 253c4ba4aa5SRyan Moeller * @return Pointer to an array of pointers to option names, 254c4ba4aa5SRyan Moeller * terminated by a NULL pointer, or simply NULL on failure. 255c4ba4aa5SRyan Moeller * The caller is responsible for freeing the array but not its 256c4ba4aa5SRyan Moeller * contents. 257c4ba4aa5SRyan Moeller */ 258c4ba4aa5SRyan Moeller const char **ifconfig_media_get_options(ifmedia_t media); 259c4ba4aa5SRyan Moeller 260c4ba4aa5SRyan Moeller /** Retrieve an array of media options by names 261c4ba4aa5SRyan Moeller * @param media The top level media type whose options we want 262c4ba4aa5SRyan Moeller * @param opts Pointer to an array of string pointers naming options 263c4ba4aa5SRyan Moeller * @param nopts Number of elements in the opts array 264c4ba4aa5SRyan Moeller * @return Pointer to an array of media options, one for each option named 265c4ba4aa5SRyan Moeller * in opts. NULL is returned instead with errno set to ENOMEM if 266c4ba4aa5SRyan Moeller * allocating the return array fails or EINVAL if media is not 267c4ba4aa5SRyan Moeller * valid. A media option in the array will be INVALID_IFMEDIA 268c4ba4aa5SRyan Moeller * when lookup failed for the option named in that position in 269c4ba4aa5SRyan Moeller * opts. The caller is responsible for freeing the array. 270c4ba4aa5SRyan Moeller */ 271c4ba4aa5SRyan Moeller ifmedia_t *ifconfig_media_lookup_options(ifmedia_t media, const char **opts, 272c4ba4aa5SRyan Moeller size_t nopts); 273b1d757bcSAlan Somers 274b12a960eSRyan Moeller /** Retrieve the reason the interface is down 275b12a960eSRyan Moeller * @param h An open ifconfig state object 276b12a960eSRyan Moeller * @param name The interface name 277b12a960eSRyan Moeller * @param ifdr Return argument. 278b12a960eSRyan Moeller * @return 0 on success, nonzero on failure 279b12a960eSRyan Moeller */ 280b12a960eSRyan Moeller int ifconfig_media_get_downreason(ifconfig_handle_t *h, const char *name, 281b12a960eSRyan Moeller struct ifdownreason *ifdr); 282b12a960eSRyan Moeller 283*40e04359SKristof Provost struct ifconfig_carp { 284*40e04359SKristof Provost size_t carpr_count; 285*40e04359SKristof Provost uint32_t carpr_vhid; 286*40e04359SKristof Provost uint32_t carpr_state; 287*40e04359SKristof Provost int32_t carpr_advbase; 288*40e04359SKristof Provost int32_t carpr_advskew; 289*40e04359SKristof Provost uint8_t carpr_key[CARP_KEY_LEN]; 290*40e04359SKristof Provost }; 291*40e04359SKristof Provost 292*40e04359SKristof Provost int ifconfig_carp_get_vhid(ifconfig_handle_t *h, const char *name, 293*40e04359SKristof Provost struct ifconfig_carp *carpr, uint32_t vhid); 294b1d757bcSAlan Somers int ifconfig_carp_get_info(ifconfig_handle_t *h, const char *name, 295*40e04359SKristof Provost struct ifconfig_carp *carpr, size_t ncarp); 296*40e04359SKristof Provost int ifconfig_carp_set_info(ifconfig_handle_t *h, const char *name, 297*40e04359SKristof Provost const struct ifconfig_carp *carpr); 298b1d757bcSAlan Somers 299b1d757bcSAlan Somers /** Retrieve additional information about an inet address 300b1d757bcSAlan Somers * @param h An open ifconfig state object 301b1d757bcSAlan Somers * @param name The interface name 30209703627SGordon Bergling * @param ifa Pointer to the address structure of interest 303b1d757bcSAlan Somers * @param addr Return argument. It will be filled with additional information 304b1d757bcSAlan Somers * about the address. 305b1d757bcSAlan Somers * @return 0 on success, nonzero on failure. 306b1d757bcSAlan Somers */ 307b1d757bcSAlan Somers int ifconfig_inet_get_addrinfo(ifconfig_handle_t *h, 308b1d757bcSAlan Somers const char *name, struct ifaddrs *ifa, struct ifconfig_inet_addr *addr); 309b1d757bcSAlan Somers 310b1d757bcSAlan Somers /** Retrieve additional information about an inet6 address 311b1d757bcSAlan Somers * @param h An open ifconfig state object 312b1d757bcSAlan Somers * @param name The interface name 31309703627SGordon Bergling * @param ifa Pointer to the address structure of interest 314b1d757bcSAlan Somers * @param addr Return argument. It will be filled with additional information 315b1d757bcSAlan Somers * about the address. 316b1d757bcSAlan Somers * @return 0 on success, nonzero on failure. 317b1d757bcSAlan Somers */ 318b1d757bcSAlan Somers int ifconfig_inet6_get_addrinfo(ifconfig_handle_t *h, 319b1d757bcSAlan Somers const char *name, struct ifaddrs *ifa, struct ifconfig_inet6_addr *addr); 320b1d757bcSAlan Somers 321e5539fb6SRyan Moeller /** Retrieve additional information about a bridge(4) interface */ 322e5539fb6SRyan Moeller int ifconfig_bridge_get_bridge_status(ifconfig_handle_t *h, 323e5539fb6SRyan Moeller const char *name, struct ifconfig_bridge_status **bridge); 324e5539fb6SRyan Moeller 325e5539fb6SRyan Moeller /** Frees the structure returned by ifconfig_bridge_get_bridge_status. Does 326e5539fb6SRyan Moeller * nothing if the argument is NULL 327e5539fb6SRyan Moeller * @param bridge Pointer to the structure to free 328e5539fb6SRyan Moeller */ 329e5539fb6SRyan Moeller void ifconfig_bridge_free_bridge_status(struct ifconfig_bridge_status *bridge); 330e5539fb6SRyan Moeller 331b1d757bcSAlan Somers /** Retrieve additional information about a lagg(4) interface */ 332b1d757bcSAlan Somers int ifconfig_lagg_get_lagg_status(ifconfig_handle_t *h, 333b1d757bcSAlan Somers const char *name, struct ifconfig_lagg_status **lagg_status); 334b1d757bcSAlan Somers 335b1d757bcSAlan Somers /** Retrieve additional information about a member of a lagg(4) interface */ 336b1d757bcSAlan Somers int ifconfig_lagg_get_laggport_status(ifconfig_handle_t *h, 337b1d757bcSAlan Somers const char *name, struct lagg_reqport *rp); 338b1d757bcSAlan Somers 339e5539fb6SRyan Moeller /** Frees the structure returned by ifconfig_lagg_get_lagg_status. Does 340e5539fb6SRyan Moeller * nothing if the argument is NULL 341b1d757bcSAlan Somers * @param laggstat Pointer to the structure to free 342b1d757bcSAlan Somers */ 343b1d757bcSAlan Somers void ifconfig_lagg_free_lagg_status(struct ifconfig_lagg_status *laggstat); 344b1d757bcSAlan Somers 345ec214349SKristof Provost /** Destroy a virtual interface 346ec214349SKristof Provost * @param name Interface to destroy 347ec214349SKristof Provost */ 348ec214349SKristof Provost int ifconfig_destroy_interface(ifconfig_handle_t *h, const char *name); 349ec214349SKristof Provost 350ec214349SKristof Provost /** Creates a (virtual) interface 351ec214349SKristof Provost * @param name Name of interface to create. Example: bridge or bridge42 352ec214349SKristof Provost * @param name ifname Is set to actual name of created interface 353ec214349SKristof Provost */ 354ec214349SKristof Provost int ifconfig_create_interface(ifconfig_handle_t *h, const char *name, 355ec214349SKristof Provost char **ifname); 356b1d757bcSAlan Somers 357b1d757bcSAlan Somers /** Creates a (virtual) interface 358b1d757bcSAlan Somers * @param name Name of interface to create. Example: vlan0 or ix0.50 359b1d757bcSAlan Somers * @param name ifname Is set to actual name of created interface 360b1d757bcSAlan Somers * @param vlandev Name of interface to attach to 361b1d757bcSAlan Somers * @param vlanid VLAN ID/Tag. Must not be 0. 362b1d757bcSAlan Somers */ 363b1d757bcSAlan Somers int ifconfig_create_interface_vlan(ifconfig_handle_t *h, const char *name, 364b1d757bcSAlan Somers char **ifname, const char *vlandev, const unsigned short vlantag); 365b1d757bcSAlan Somers 366b1d757bcSAlan Somers int ifconfig_set_vlantag(ifconfig_handle_t *h, const char *name, 367b1d757bcSAlan Somers const char *vlandev, const unsigned short vlantag); 3680710ec8cSRyan Moeller 3690710ec8cSRyan Moeller /** Gets the names of all interface cloners available on the system 3700710ec8cSRyan Moeller * @param bufp Set to the address of the names buffer on success or NULL 3710710ec8cSRyan Moeller * if an error occurs. This buffer must be freed when done. 3720710ec8cSRyan Moeller * @param lenp Set to the number of names in the returned buffer or 0 3730710ec8cSRyan Moeller * if an error occurs. Each name is contained within an 3740710ec8cSRyan Moeller * IFNAMSIZ length slice of the buffer, for a total buffer 3750710ec8cSRyan Moeller * length of *lenp * IFNAMSIZ bytes. 3760710ec8cSRyan Moeller */ 3770710ec8cSRyan Moeller int ifconfig_list_cloners(ifconfig_handle_t *h, char **bufp, size_t *lenp); 378