xref: /freebsd/lib/libifconfig/libifconfig.h (revision 37115154672f74744e8f5992a3f0953d61cb79bc)
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 
27ec214349SKristof Provost #pragma once
28ec214349SKristof Provost 
2994cba803SRyan Moeller #include <sys/types.h>
3094cba803SRyan Moeller 
3194cba803SRyan Moeller #include <net/if.h>
3294cba803SRyan Moeller 
33b1d757bcSAlan Somers #include <netinet/in.h>
3440e04359SKristof Provost #include <netinet/ip_carp.h>
35b1d757bcSAlan Somers #include <netinet6/in6_var.h>
36b1d757bcSAlan Somers 
37b1d757bcSAlan Somers #define ND6_IFF_DEFAULTIF    0x8000
38b1d757bcSAlan Somers 
39ec214349SKristof Provost typedef enum {
40b1d757bcSAlan Somers 	OK = 0,
41b1d757bcSAlan Somers 	OTHER,
42b1d757bcSAlan Somers 	IOCTL,
4340e04359SKristof Provost 	SOCKET,
4440e04359SKristof Provost 	NETLINK
45ec214349SKristof Provost } ifconfig_errtype;
46ec214349SKristof Provost 
47ec214349SKristof Provost /*
48ec214349SKristof Provost  * Opaque definition so calling application can just pass a
49ec214349SKristof Provost  * pointer to it for library use.
50ec214349SKristof Provost  */
51ec214349SKristof Provost struct ifconfig_handle;
52ec214349SKristof Provost typedef struct ifconfig_handle ifconfig_handle_t;
53ec214349SKristof Provost 
54b1d757bcSAlan Somers struct ifaddrs;
55e5539fb6SRyan Moeller struct ifbropreq;
56e5539fb6SRyan Moeller struct ifbreq;
57b1d757bcSAlan Somers struct in6_ndireq;
58b1d757bcSAlan Somers struct lagg_reqall;
59b1d757bcSAlan Somers struct lagg_reqflags;
60b1d757bcSAlan Somers struct lagg_reqopts;
61b1d757bcSAlan Somers struct lagg_reqport;
62b1d757bcSAlan Somers 
63e5539fb6SRyan Moeller /** Stores extra info associated with a bridge(4) interface */
64e5539fb6SRyan Moeller struct ifconfig_bridge_status {
65e5539fb6SRyan Moeller 	struct ifbropreq *params;	/**< current operational parameters */
66e5539fb6SRyan Moeller 	struct ifbreq *members;		/**< list of bridge members */
67e5539fb6SRyan Moeller 	size_t members_count;		/**< how many member interfaces */
68e5539fb6SRyan Moeller 	uint32_t cache_size;		/**< size of address cache */
69e5539fb6SRyan Moeller 	uint32_t cache_lifetime;	/**< address cache entry lifetime */
70e5539fb6SRyan Moeller };
71e5539fb6SRyan Moeller 
72ec214349SKristof Provost struct ifconfig_capabilities {
73ec214349SKristof Provost 	/** Current capabilities (ifconfig prints this as 'options')*/
74ec214349SKristof Provost 	int curcap;
75ec214349SKristof Provost 	/** Requested capabilities (ifconfig prints this as 'capabilities')*/
76ec214349SKristof Provost 	int reqcap;
77ec214349SKristof Provost };
78ec214349SKristof Provost 
79b1d757bcSAlan Somers /** Stores extra info associated with an inet address */
80b1d757bcSAlan Somers struct ifconfig_inet_addr {
81b1d757bcSAlan Somers 	const struct sockaddr_in *sin;
82b1d757bcSAlan Somers 	const struct sockaddr_in *netmask;
83b1d757bcSAlan Somers 	const struct sockaddr_in *dst;
84b1d757bcSAlan Somers 	const struct sockaddr_in *broadcast;
85b1d757bcSAlan Somers 	int prefixlen;
86b1d757bcSAlan Somers 	uint8_t vhid;
87b1d757bcSAlan Somers };
88b1d757bcSAlan Somers 
89b1d757bcSAlan Somers /** Stores extra info associated with an inet6 address */
90b1d757bcSAlan Somers struct ifconfig_inet6_addr {
91b1d757bcSAlan Somers 	struct sockaddr_in6 *sin6;
92b1d757bcSAlan Somers 	struct sockaddr_in6 *dstin6;
93b1d757bcSAlan Somers 	struct in6_addrlifetime lifetime;
94b1d757bcSAlan Somers 	int prefixlen;
95b1d757bcSAlan Somers 	uint32_t flags;
96b1d757bcSAlan Somers 	uint8_t vhid;
97b1d757bcSAlan Somers };
98b1d757bcSAlan Somers 
99b1d757bcSAlan Somers /** Stores extra info associated with a lagg(4) interface */
100b1d757bcSAlan Somers struct ifconfig_lagg_status {
101b1d757bcSAlan Somers 	struct lagg_reqall *ra;
102b1d757bcSAlan Somers 	struct lagg_reqopts *ro;
103b1d757bcSAlan Somers 	struct lagg_reqflags *rf;
104b1d757bcSAlan Somers };
105b1d757bcSAlan Somers 
106ec214349SKristof Provost /** Retrieves a new state object for use in other API calls.
107ec214349SKristof Provost  * Example usage:
108ec214349SKristof Provost  *{@code
109ec214349SKristof Provost  * // Create state object
110b1d757bcSAlan Somers  * ifconfig_handle_t *lifh;
111b1d757bcSAlan Somers  * lifh = ifconfig_open();
112b1d757bcSAlan Somers  * if (lifh == NULL) {
113b1d757bcSAlan Somers  *     // Handle error
114b1d757bcSAlan Somers  * }
115ec214349SKristof Provost  *
116b1d757bcSAlan Somers  * // Do stuff with the handle
117ec214349SKristof Provost  *
118ec214349SKristof Provost  * // Dispose of the state object
119ec214349SKristof Provost  * ifconfig_close(lifh);
120ec214349SKristof Provost  * lifh = NULL;
121ec214349SKristof Provost  *}
122ec214349SKristof Provost  */
123ec214349SKristof Provost ifconfig_handle_t *ifconfig_open(void);
124ec214349SKristof Provost 
125ec214349SKristof Provost /** Frees resources held in the provided state object.
126ec214349SKristof Provost  * @param h The state object to close.
127ec214349SKristof Provost  * @see #ifconfig_open(void)
128ec214349SKristof Provost  */
129ec214349SKristof Provost void ifconfig_close(ifconfig_handle_t *h);
130ec214349SKristof Provost 
13109703627SGordon Bergling /** Identifies what kind of error occurred. */
132ec214349SKristof Provost ifconfig_errtype ifconfig_err_errtype(ifconfig_handle_t *h);
133ec214349SKristof Provost 
134ec214349SKristof Provost /** Retrieves the errno associated with the error, if any. */
135ec214349SKristof Provost int ifconfig_err_errno(ifconfig_handle_t *h);
136ec214349SKristof Provost 
137b1d757bcSAlan Somers typedef void (*ifconfig_foreach_func_t)(ifconfig_handle_t *h,
138b1d757bcSAlan Somers     struct ifaddrs *ifa, void *udata);
139b1d757bcSAlan Somers 
140b1d757bcSAlan Somers /** Iterate over every network interface
141b1d757bcSAlan Somers  * @param h	An open ifconfig state object
142b1d757bcSAlan Somers  * @param cb	A callback function to call with a pointer to each interface
143b1d757bcSAlan Somers  * @param udata	An opaque value that will be passed to the callback.
144b1d757bcSAlan Somers  * @return	0 on success, nonzero if the list could not be iterated
145b1d757bcSAlan Somers  */
146b1d757bcSAlan Somers int ifconfig_foreach_iface(ifconfig_handle_t *h, ifconfig_foreach_func_t cb,
147b1d757bcSAlan Somers     void *udata);
148b1d757bcSAlan Somers 
149b1d757bcSAlan Somers /** Iterate over every address on a single network interface
150b1d757bcSAlan Somers  * @param h	An open ifconfig state object
151b1d757bcSAlan Somers  * @param ifa	A pointer that was supplied by a previous call to
152b1d757bcSAlan Somers  *              ifconfig_foreach_iface
153b1d757bcSAlan Somers  * @param udata	An opaque value that will be passed to the callback.
154b1d757bcSAlan Somers  * @param cb	A callback function to call with a pointer to each ifaddr
155b1d757bcSAlan Somers  */
156b1d757bcSAlan Somers void ifconfig_foreach_ifaddr(ifconfig_handle_t *h, struct ifaddrs *ifa,
157b1d757bcSAlan Somers     ifconfig_foreach_func_t cb, void *udata);
158b1d757bcSAlan Somers 
159ec214349SKristof Provost /** If error type was IOCTL, this identifies which request failed. */
160ec214349SKristof Provost unsigned long ifconfig_err_ioctlreq(ifconfig_handle_t *h);
161ec214349SKristof Provost int ifconfig_get_description(ifconfig_handle_t *h, const char *name,
162ec214349SKristof Provost     char **description);
163ec214349SKristof Provost int ifconfig_set_description(ifconfig_handle_t *h, const char *name,
164ec214349SKristof Provost     const char *newdescription);
165ec214349SKristof Provost int ifconfig_unset_description(ifconfig_handle_t *h, const char *name);
1669a2ff315SKristof Provost int ifconfig_set_name(ifconfig_handle_t *h, const char *name,
1679a2ff315SKristof Provost     const char *newname);
168c2803f1aSAndriy Voskoboinyk int ifconfig_get_orig_name(ifconfig_handle_t *h, const char *ifname,
169c2803f1aSAndriy Voskoboinyk     char **orig_name);
170b1d757bcSAlan Somers int ifconfig_set_fib(ifconfig_handle_t *h, const char *name, int fib);
171b1d757bcSAlan Somers int ifconfig_get_fib(ifconfig_handle_t *h, const char *name, int *fib);
172ec214349SKristof Provost int ifconfig_set_mtu(ifconfig_handle_t *h, const char *name, const int mtu);
173ec214349SKristof Provost int ifconfig_get_mtu(ifconfig_handle_t *h, const char *name, int *mtu);
174b1d757bcSAlan Somers int ifconfig_get_nd6(ifconfig_handle_t *h, const char *name,
175b1d757bcSAlan Somers     struct in6_ndireq *nd);
1769a2ff315SKristof Provost int ifconfig_set_metric(ifconfig_handle_t *h, const char *name,
1779a2ff315SKristof Provost     const int metric);
178ec214349SKristof Provost int ifconfig_get_metric(ifconfig_handle_t *h, const char *name, int *metric);
179ec214349SKristof Provost int ifconfig_set_capability(ifconfig_handle_t *h, const char *name,
180ec214349SKristof Provost     const int capability);
181ec214349SKristof Provost int ifconfig_get_capability(ifconfig_handle_t *h, const char *name,
182ec214349SKristof Provost     struct ifconfig_capabilities *capability);
183ec214349SKristof Provost 
184b1d757bcSAlan Somers /** Retrieve the list of groups to which this interface belongs
185b1d757bcSAlan Somers  * @param h	An open ifconfig state object
186b1d757bcSAlan Somers  * @param name	The interface name
187b1d757bcSAlan Somers  * @param ifgr	return argument.  The caller is responsible for freeing
188b1d757bcSAlan Somers  *              ifgr->ifgr_groups
189b1d757bcSAlan Somers  * @return	0 on success, nonzero on failure
190b1d757bcSAlan Somers  */
191b1d757bcSAlan Somers int ifconfig_get_groups(ifconfig_handle_t *h, const char *name,
192b1d757bcSAlan Somers     struct ifgroupreq *ifgr);
193b1d757bcSAlan Somers int ifconfig_get_ifstatus(ifconfig_handle_t *h, const char *name,
194b1d757bcSAlan Somers     struct ifstat *stat);
195b1d757bcSAlan Somers 
196b1d757bcSAlan Somers /** Retrieve the interface media information
197b1d757bcSAlan Somers  * @param h	An open ifconfig state object
198b1d757bcSAlan Somers  * @param name	The interface name
199b1d757bcSAlan Somers  * @param ifmr	Return argument.  The caller is responsible for freeing it
200b1d757bcSAlan Somers  * @return	0 on success, nonzero on failure
201b1d757bcSAlan Somers  */
202b1d757bcSAlan Somers int ifconfig_media_get_mediareq(ifconfig_handle_t *h, const char *name,
203b1d757bcSAlan Somers     struct ifmediareq **ifmr);
204c4ba4aa5SRyan Moeller 
205b1d757bcSAlan Somers const char *ifconfig_media_get_status(const struct ifmediareq *ifmr);
206c4ba4aa5SRyan Moeller 
207c4ba4aa5SRyan Moeller typedef int ifmedia_t;
208c4ba4aa5SRyan Moeller 
209c4ba4aa5SRyan Moeller #define INVALID_IFMEDIA ((ifmedia_t)-1)
210c4ba4aa5SRyan Moeller 
211c4ba4aa5SRyan Moeller /** Retrieve the name of a media type
212c4ba4aa5SRyan Moeller  * @param media	The media to be named
213c4ba4aa5SRyan Moeller  * @return	A pointer to the media type name, or NULL on failure
214c4ba4aa5SRyan Moeller  */
215c4ba4aa5SRyan Moeller const char *ifconfig_media_get_type(ifmedia_t media);
216c4ba4aa5SRyan Moeller 
217c4ba4aa5SRyan Moeller /** Retrieve a media type by its name
218c4ba4aa5SRyan Moeller  * @param name	The name of a media type
219c4ba4aa5SRyan Moeller  * @return	The media type value, or INVALID_IFMEDIA on failure
220c4ba4aa5SRyan Moeller  */
221c4ba4aa5SRyan Moeller ifmedia_t ifconfig_media_lookup_type(const char *name);
222c4ba4aa5SRyan Moeller 
223c4ba4aa5SRyan Moeller /** Retrieve the name of a media subtype
224c4ba4aa5SRyan Moeller  * @param media	The media subtype to be named
225c4ba4aa5SRyan Moeller  * @return	A pointer to the media subtype name, or NULL on failure
226c4ba4aa5SRyan Moeller  */
227c4ba4aa5SRyan Moeller const char *ifconfig_media_get_subtype(ifmedia_t media);
228c4ba4aa5SRyan Moeller 
229c4ba4aa5SRyan Moeller /** Retrieve a media subtype by its name
230c4ba4aa5SRyan Moeller  * @param media	The top level media type whose subtype we want
231c4ba4aa5SRyan Moeller  * @param name	The name of a media subtype
232c4ba4aa5SRyan Moeller  * @return	The media subtype value, or INVALID_IFMEDIA on failure
233c4ba4aa5SRyan Moeller  */
234c4ba4aa5SRyan Moeller ifmedia_t ifconfig_media_lookup_subtype(ifmedia_t media, const char *name);
235c4ba4aa5SRyan Moeller 
236c4ba4aa5SRyan Moeller /** Retrieve the name of a media mode
237c4ba4aa5SRyan Moeller  * @param media	The media mode to be named
238c4ba4aa5SRyan Moeller  * @return	A pointer to the media mode name, or NULL on failure
239c4ba4aa5SRyan Moeller  */
240c4ba4aa5SRyan Moeller const char *ifconfig_media_get_mode(ifmedia_t media);
241c4ba4aa5SRyan Moeller 
242c4ba4aa5SRyan Moeller /** Retrieve a media mode by its name
243c4ba4aa5SRyan Moeller  * @param media	The top level media type whose mode we want
244c4ba4aa5SRyan Moeller  * @param name	The name of a media mode
245c4ba4aa5SRyan Moeller  * @return	The media mode value, or INVALID_IFMEDIA on failure
246c4ba4aa5SRyan Moeller  */
247c4ba4aa5SRyan Moeller ifmedia_t ifconfig_media_lookup_mode(ifmedia_t media, const char *name);
248c4ba4aa5SRyan Moeller 
249c4ba4aa5SRyan Moeller /** Retrieve an array of media options
250c4ba4aa5SRyan Moeller  * @param media	The media for which to obtain the options
251c4ba4aa5SRyan Moeller  * @return	Pointer to an array of pointers to option names,
252c4ba4aa5SRyan Moeller  * 		terminated by a NULL pointer, or simply NULL on failure.
253c4ba4aa5SRyan Moeller  * 		The caller is responsible for freeing the array but not its
254c4ba4aa5SRyan Moeller  * 		contents.
255c4ba4aa5SRyan Moeller  */
256c4ba4aa5SRyan Moeller const char **ifconfig_media_get_options(ifmedia_t media);
257c4ba4aa5SRyan Moeller 
258c4ba4aa5SRyan Moeller /** Retrieve an array of media options by names
259c4ba4aa5SRyan Moeller  * @param media	The top level media type whose options we want
260c4ba4aa5SRyan Moeller  * @param opts	Pointer to an array of string pointers naming options
261c4ba4aa5SRyan Moeller  * @param nopts Number of elements in the opts array
262c4ba4aa5SRyan Moeller  * @return	Pointer to an array of media options, one for each option named
263c4ba4aa5SRyan Moeller  * 		in opts.  NULL is returned instead with errno set to ENOMEM if
264c4ba4aa5SRyan Moeller  * 		allocating the return array fails or EINVAL if media is not
265c4ba4aa5SRyan Moeller  * 		valid.  A media option in the array will be INVALID_IFMEDIA
266c4ba4aa5SRyan Moeller  * 		when lookup failed for the option named in that position in
267c4ba4aa5SRyan Moeller  * 		opts.  The caller is responsible for freeing the array.
268c4ba4aa5SRyan Moeller  */
269c4ba4aa5SRyan Moeller ifmedia_t *ifconfig_media_lookup_options(ifmedia_t media, const char **opts,
270c4ba4aa5SRyan Moeller     size_t nopts);
271b1d757bcSAlan Somers 
272b12a960eSRyan Moeller /** Retrieve the reason the interface is down
273b12a960eSRyan Moeller  * @param h	An open ifconfig state object
274b12a960eSRyan Moeller  * @param name	The interface name
275b12a960eSRyan Moeller  * @param ifdr	Return argument.
276b12a960eSRyan Moeller  * @return	0 on success, nonzero on failure
277b12a960eSRyan Moeller  */
278b12a960eSRyan Moeller int ifconfig_media_get_downreason(ifconfig_handle_t *h, const char *name,
279b12a960eSRyan Moeller     struct ifdownreason *ifdr);
280b12a960eSRyan Moeller 
28140e04359SKristof Provost struct ifconfig_carp {
28240e04359SKristof Provost 	size_t		carpr_count;
28340e04359SKristof Provost 	uint32_t	carpr_vhid;
28440e04359SKristof Provost 	uint32_t	carpr_state;
28540e04359SKristof Provost 	int32_t		carpr_advbase;
28640e04359SKristof Provost 	int32_t		carpr_advskew;
28740e04359SKristof Provost 	uint8_t		carpr_key[CARP_KEY_LEN];
28813781800SKristof Provost 	struct in_addr	carpr_addr;
28913781800SKristof Provost 	struct in6_addr	carpr_addr6;
290*37115154SKristof Provost 	carp_version_t	carpr_version;
291*37115154SKristof Provost 	uint8_t		carpr_vrrp_prio;
292*37115154SKristof Provost 	uint16_t	carpr_vrrp_adv_inter;
29340e04359SKristof Provost };
29440e04359SKristof Provost 
29540e04359SKristof Provost int ifconfig_carp_get_vhid(ifconfig_handle_t *h, const char *name,
29640e04359SKristof Provost     struct ifconfig_carp *carpr, uint32_t vhid);
297b1d757bcSAlan Somers int ifconfig_carp_get_info(ifconfig_handle_t *h, const char *name,
29840e04359SKristof Provost     struct ifconfig_carp *carpr, size_t ncarp);
29940e04359SKristof Provost int ifconfig_carp_set_info(ifconfig_handle_t *h, const char *name,
30040e04359SKristof Provost     const struct ifconfig_carp *carpr);
301b1d757bcSAlan Somers 
302b1d757bcSAlan Somers /** Retrieve additional information about an inet address
303b1d757bcSAlan Somers  * @param h	An open ifconfig state object
304b1d757bcSAlan Somers  * @param name	The interface name
30509703627SGordon Bergling  * @param ifa	Pointer to the address structure of interest
306b1d757bcSAlan Somers  * @param addr	Return argument.  It will be filled with additional information
307b1d757bcSAlan Somers  *              about the address.
308b1d757bcSAlan Somers  * @return	0 on success, nonzero on failure.
309b1d757bcSAlan Somers  */
310b1d757bcSAlan Somers int ifconfig_inet_get_addrinfo(ifconfig_handle_t *h,
311b1d757bcSAlan Somers     const char *name, struct ifaddrs *ifa, struct ifconfig_inet_addr *addr);
312b1d757bcSAlan Somers 
313b1d757bcSAlan Somers /** Retrieve additional information about an inet6 address
314b1d757bcSAlan Somers  * @param h	An open ifconfig state object
315b1d757bcSAlan Somers  * @param name	The interface name
31609703627SGordon Bergling  * @param ifa	Pointer to the address structure of interest
317b1d757bcSAlan Somers  * @param addr	Return argument.  It will be filled with additional information
318b1d757bcSAlan Somers  *              about the address.
319b1d757bcSAlan Somers  * @return	0 on success, nonzero on failure.
320b1d757bcSAlan Somers  */
321b1d757bcSAlan Somers int ifconfig_inet6_get_addrinfo(ifconfig_handle_t *h,
322b1d757bcSAlan Somers     const char *name, struct ifaddrs *ifa, struct ifconfig_inet6_addr *addr);
323b1d757bcSAlan Somers 
324e5539fb6SRyan Moeller /** Retrieve additional information about a bridge(4) interface */
325e5539fb6SRyan Moeller int ifconfig_bridge_get_bridge_status(ifconfig_handle_t *h,
326e5539fb6SRyan Moeller     const char *name, struct ifconfig_bridge_status **bridge);
327e5539fb6SRyan Moeller 
328e5539fb6SRyan Moeller /** Frees the structure returned by ifconfig_bridge_get_bridge_status.  Does
329e5539fb6SRyan Moeller  * nothing if the argument is NULL
330e5539fb6SRyan Moeller  * @param bridge	Pointer to the structure to free
331e5539fb6SRyan Moeller  */
332e5539fb6SRyan Moeller void ifconfig_bridge_free_bridge_status(struct ifconfig_bridge_status *bridge);
333e5539fb6SRyan Moeller 
334b1d757bcSAlan Somers /** Retrieve additional information about a lagg(4) interface */
335b1d757bcSAlan Somers int ifconfig_lagg_get_lagg_status(ifconfig_handle_t *h,
336b1d757bcSAlan Somers     const char *name, struct ifconfig_lagg_status **lagg_status);
337b1d757bcSAlan Somers 
338b1d757bcSAlan Somers /** Retrieve additional information about a member of a lagg(4) interface */
339b1d757bcSAlan Somers int ifconfig_lagg_get_laggport_status(ifconfig_handle_t *h,
340b1d757bcSAlan Somers     const char *name, struct lagg_reqport *rp);
341b1d757bcSAlan Somers 
342e5539fb6SRyan Moeller /** Frees the structure returned by ifconfig_lagg_get_lagg_status.  Does
343e5539fb6SRyan Moeller  * nothing if the argument is NULL
344b1d757bcSAlan Somers  * @param laggstat	Pointer to the structure to free
345b1d757bcSAlan Somers  */
346b1d757bcSAlan Somers void ifconfig_lagg_free_lagg_status(struct ifconfig_lagg_status *laggstat);
347b1d757bcSAlan Somers 
348ec214349SKristof Provost /** Destroy a virtual interface
349ec214349SKristof Provost  * @param name Interface to destroy
350ec214349SKristof Provost  */
351ec214349SKristof Provost int ifconfig_destroy_interface(ifconfig_handle_t *h, const char *name);
352ec214349SKristof Provost 
353ec214349SKristof Provost /** Creates a (virtual) interface
354ec214349SKristof Provost  * @param name Name of interface to create. Example: bridge or bridge42
355ec214349SKristof Provost  * @param name ifname Is set to actual name of created interface
356ec214349SKristof Provost  */
357ec214349SKristof Provost int ifconfig_create_interface(ifconfig_handle_t *h, const char *name,
358ec214349SKristof Provost     char **ifname);
359b1d757bcSAlan Somers 
360b1d757bcSAlan Somers /** Creates a (virtual) interface
361b1d757bcSAlan Somers  * @param name Name of interface to create. Example: vlan0 or ix0.50
362b1d757bcSAlan Somers  * @param name ifname Is set to actual name of created interface
363b1d757bcSAlan Somers  * @param vlandev Name of interface to attach to
364b1d757bcSAlan Somers  * @param vlanid VLAN ID/Tag. Must not be 0.
365b1d757bcSAlan Somers  */
366b1d757bcSAlan Somers int ifconfig_create_interface_vlan(ifconfig_handle_t *h, const char *name,
367b1d757bcSAlan Somers     char **ifname, const char *vlandev, const unsigned short vlantag);
368b1d757bcSAlan Somers 
369b1d757bcSAlan Somers int ifconfig_set_vlantag(ifconfig_handle_t *h, const char *name,
370b1d757bcSAlan Somers     const char *vlandev, const unsigned short vlantag);
3710710ec8cSRyan Moeller 
3720710ec8cSRyan Moeller /** Gets the names of all interface cloners available on the system
3730710ec8cSRyan Moeller  * @param bufp	Set to the address of the names buffer on success or NULL
3740710ec8cSRyan Moeller  *              if an error occurs.  This buffer must be freed when done.
3750710ec8cSRyan Moeller  * @param lenp	Set to the number of names in the returned buffer or 0
3760710ec8cSRyan Moeller  * 		if an error occurs.  Each name is contained within an
3770710ec8cSRyan Moeller  * 		IFNAMSIZ length slice of the buffer, for a total buffer
3780710ec8cSRyan Moeller  * 		length of *lenp * IFNAMSIZ bytes.
3790710ec8cSRyan Moeller  */
3800710ec8cSRyan Moeller int ifconfig_list_cloners(ifconfig_handle_t *h, char **bufp, size_t *lenp);
381