Index: head/lib/libifc/libifc_internal.c =================================================================== --- head/lib/libifc/libifc_internal.c (revision 305289) +++ head/lib/libifc/libifc_internal.c (nonexistent) @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2016, Marie Helene Kvello-Aune - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * thislist of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - - -#include - -#include -#include -#include -#include -#include - - -#include "libifc.h" // Needed for libifc_errstate -#include "libifc_internal.h" - -int -libifc_ioctlwrap_ret(libifc_handle_t *h, unsigned long request, int rcode) -{ - if (rcode != 0) { - h->error.errtype = IOCTL; - h->error.ioctl_request = request; - h->error.errcode = errno; - } - return (rcode); -} - - -int -libifc_ioctlwrap(libifc_handle_t *h, const int addressfamily, - unsigned long request, struct ifreq *ifr) -{ - int s; - - if (libifc_socket(h, addressfamily, &s) != 0) { - return (-1); - } - - int rcode = ioctl(s, request, ifr); - return (libifc_ioctlwrap_ret(h, request, rcode)); -} - - -/* - * Function to get socket for the specified address family. - * If the socket doesn't already exist, attempt to create it. - */ -int libifc_socket(libifc_handle_t *h, const int addressfamily, int *s) -{ - if (addressfamily > AF_MAX) { - h->error.errtype = SOCKET; - h->error.errcode = EINVAL; - return (-1); - } - - if (h->sockets[addressfamily] != -1) { - *s = h->sockets[addressfamily]; - return (0); - } - - /* We don't have a socket of that type available. Create one. */ - h->sockets[addressfamily] = socket(addressfamily, SOCK_DGRAM, 0); - if (h->sockets[addressfamily] == -1) { - h->error.errtype = SOCKET; - h->error.errcode = errno; - return (-1); - } - - *s = h->sockets[addressfamily]; - return (0); -} Property changes on: head/lib/libifc/libifc_internal.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/lib/libifc/libifc.c =================================================================== --- head/lib/libifc/libifc.c (revision 305289) +++ head/lib/libifc/libifc.c (nonexistent) @@ -1,397 +0,0 @@ -/* - * Copyright (c) 2016, Marie Helene Kvello-Aune - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * thislist of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "libifc.h" -#include "libifc_internal.h" - - -libifc_handle_t * -libifc_open(void) -{ - struct libifc_handle *h; - - h = calloc(1, sizeof(struct libifc_handle)); - - for (int i = 0; i <= AF_MAX; i++) { - h->sockets[i] = -1; - } - - return (h); -} - - -void -libifc_close(libifc_handle_t *h) -{ - for (int i = 0; i <= AF_MAX; i++) { - if (h->sockets[i] != -1) { - (void)close(h->sockets[i]); - } - } - free(h); -} - - -libifc_errtype -libifc_err_errtype(libifc_handle_t *h) -{ - return (h->error.errtype); -} - - -int -libifc_err_errno(libifc_handle_t *h) -{ - return (h->error.errcode); -} - - -unsigned long -libifc_err_ioctlreq(libifc_handle_t *h) -{ - return (h->error.ioctl_request); -} - - -int -libifc_get_description(libifc_handle_t *h, const char *name, char **description) -{ - struct ifreq ifr; - char *descr = NULL; - size_t descrlen = 64; - - memset(&ifr, 0, sizeof(struct ifreq)); - (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - for (;;) { - if ((descr = reallocf(descr, descrlen)) == NULL) { - h->error.errtype = OTHER; - h->error.errcode = ENOMEM; - return (-1); - } - - ifr.ifr_buffer.buffer = descr; - ifr.ifr_buffer.length = descrlen; - if (libifc_ioctlwrap(h, AF_LOCAL, SIOCGIFDESCR, - &ifr) != 0) { - return (-1); - } - - if (ifr.ifr_buffer.buffer == descr) { - if (strlen(descr) > 0) { - *description = strdup(descr); - free(descr); - return (0); - } - } else if (ifr.ifr_buffer.length > descrlen) { - descrlen = ifr.ifr_buffer.length; - continue; - } - break; - } - free(descr); - h->error.errtype = OTHER; - h->error.errcode = 0; - return (-1); -} - - -int -libifc_set_description(libifc_handle_t *h, const char *name, - const char *newdescription) -{ - struct ifreq ifr; - int desclen; - - memset(&ifr, 0, sizeof(struct ifreq)); - desclen = strlen(newdescription); - - /* - * Unset description if the new description is 0 characters long. - * TODO: Decide whether this should be an error condition instead. - */ - if (desclen == 0) { - return (libifc_unset_description(h, name)); - } - - (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - - ifr.ifr_buffer.length = desclen + 1; - ifr.ifr_buffer.buffer = strdup(newdescription); - if (ifr.ifr_buffer.buffer == NULL) { - h->error.errtype = OTHER; - h->error.errcode = ENOMEM; - return (-1); - } - - if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFDESCR, &ifr) != 0) { - free(ifr.ifr_buffer.buffer); - return (-1); - } - free(ifr.ifr_buffer.buffer); - return (0); -} - - -int libifc_unset_description(libifc_handle_t *h, const char *name) -{ - struct ifreq ifr; - - memset(&ifr, 0, sizeof(struct ifreq)); - (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - ifr.ifr_buffer.length = 0; - ifr.ifr_buffer.buffer = NULL; - - if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFDESCR, &ifr) < 0) { - return (-1); - } - return (0); -} - - -int libifc_set_name(libifc_handle_t *h, const char *name, const char *newname) -{ - struct ifreq ifr; - char *tmpname; - - memset(&ifr, 0, sizeof(struct ifreq)); - tmpname = strdup(newname); - if (tmpname == NULL) { - h->error.errtype = OTHER; - h->error.errcode = ENOMEM; - return (-1); - } - - (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - ifr.ifr_data = tmpname; - - if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFNAME, &ifr) != 0) { - free(tmpname); - return (-1); - } - free(tmpname); - return (0); -} - - -int libifc_set_mtu(libifc_handle_t *h, const char *name, const int mtu) -{ - struct ifreq ifr; - - memset(&ifr, 0, sizeof(struct ifreq)); - (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - ifr.ifr_mtu = mtu; - if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFMTU, &ifr) < 0) { - return (-1); - } - return (0); -} - - -int libifc_get_mtu(libifc_handle_t *h, const char *name, int *mtu) -{ - struct ifreq ifr; - - memset(&ifr, 0, sizeof(struct ifreq)); - (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - if (libifc_ioctlwrap(h, AF_LOCAL, SIOCGIFMTU, &ifr) == -1) { - return (-1); - } - *mtu = ifr.ifr_mtu; - return (0); -} - - -int libifc_set_metric(libifc_handle_t *h, const char *name, const int mtu) -{ - struct ifreq ifr; - - memset(&ifr, 0, sizeof(struct ifreq)); - (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - ifr.ifr_mtu = mtu; - if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFMETRIC, &ifr) < 0) { - return (-1); - } - return (0); -} - - -int libifc_get_metric(libifc_handle_t *h, const char *name, int *metric) -{ - struct ifreq ifr; - - memset(&ifr, 0, sizeof(struct ifreq)); - (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - if (libifc_ioctlwrap(h, AF_LOCAL, SIOCGIFMETRIC, &ifr) == -1) { - return (-1); - } - *metric = ifr.ifr_metric; - return (0); -} - - -int libifc_set_capability(libifc_handle_t *h, const char *name, - const int capability) -{ - struct ifreq ifr; - struct libifc_capabilities ifcap; - int flags; - int value; - - memset(&ifr, 0, sizeof(struct ifreq)); - if (libifc_get_capability(h, name, &ifcap) != 0) { - return (-1); - } - - value = capability; - flags = ifcap.curcap; - if (value < 0) { - value = -value; - flags &= ~value; - } else { - flags |= value; - } - flags &= ifcap.reqcap; - - (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - - /* - * TODO: Verify that it's safe to not have ifr.ifr_curcap - * set for this request. - */ - ifr.ifr_reqcap = flags; - if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFCAP, &ifr) < 0) { - return (-1); - } - return (0); -} - - -int libifc_get_capability(libifc_handle_t *h, const char *name, - struct libifc_capabilities *capability) -{ - struct ifreq ifr; - - memset(&ifr, 0, sizeof(struct ifreq)); - (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - - if (libifc_ioctlwrap(h, AF_LOCAL, SIOCGIFCAP, &ifr) < 0) { - return (-1); - } - capability->curcap = ifr.ifr_curcap; - capability->reqcap = ifr.ifr_reqcap; - return (0); -} - - -int libifc_destroy_interface(libifc_handle_t *h, const char *name) -{ - struct ifreq ifr; - - memset(&ifr, 0, sizeof(struct ifreq)); - (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - - if (libifc_ioctlwrap(h, AF_LOCAL, SIOCIFDESTROY, &ifr) < 0) { - return (-1); - } - return (0); -} - - -int libifc_create_interface(libifc_handle_t *h, const char *name, char **ifname) -{ - struct ifreq ifr; - - memset(&ifr, 0, sizeof(struct ifreq)); - (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - - /* - * TODO: - * Insert special snowflake handling here. See GitHub issue #12 for details. - * In the meantime, hard-nosupport interfaces that need special handling. - */ - if ((strncmp(name, "wlan", strlen("wlan")) == 0) || - (strncmp(name, "vlan", strlen("vlan")) == 0) || - (strncmp(name, "vxlan", strlen("vxlan")) == 0)) { - h->error.errtype = OTHER; - h->error.errcode = ENOSYS; - return (-1); - } - - /* No special handling for this interface type. */ - - if (libifc_ioctlwrap(h, AF_LOCAL, SIOCIFCREATE2, &ifr) < 0) { - return (-1); - } - *ifname = strdup(ifr.ifr_name); - return (0); -} Property changes on: head/lib/libifc/libifc.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/lib/libifc/libifc.h =================================================================== --- head/lib/libifc/libifc.h (revision 305289) +++ head/lib/libifc/libifc.h (nonexistent) @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2016, Marie Helene Kvello-Aune - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * thislist of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#pragma once - -typedef enum { - OTHER, IOCTL, SOCKET -} libifc_errtype; - -/* - * Opaque definition so calling application can just pass a - * pointer to it for library use. - */ -struct libifc_handle; -typedef struct libifc_handle libifc_handle_t; - -struct libifc_capabilities { - /** Current capabilities (ifconfig prints this as 'options')*/ - int curcap; - /** Requested capabilities (ifconfig prints this as 'capabilities')*/ - int reqcap; -}; - - -/** Retrieves a new state object for use in other API calls. - * Example usage: - *{@code - * // Create state object - * libifc_handle_t *lifh = libifc_open(); - * - * // Do stuff with it - * - * // Dispose of the state object - * libifc_close(lifh); - * lifh = NULL; - *} - */ -libifc_handle_t *libifc_open(void); - -/** Frees resources held in the provided state object. - * @param h The state object to close. - * @see #libifc_open(void) - */ -void libifc_close(libifc_handle_t *h); - -/** Identifies what kind of error occured. */ -libifc_errtype libifc_err_errtype(libifc_handle_t *h); - -/** Retrieves the errno associated with the error, if any. */ -int libifc_err_errno(libifc_handle_t *h); - -/** If error type was IOCTL, this identifies which request failed. */ -unsigned long libifc_err_ioctlreq(libifc_handle_t *h); - -int libifc_get_description(libifc_handle_t *h, const char *name, - char **description); -int libifc_set_description(libifc_handle_t *h, const char *name, - const char *newdescription); -int libifc_unset_description(libifc_handle_t *h, const char *name); -int libifc_set_name(libifc_handle_t *h, const char *name, const char *newname); -int libifc_set_mtu(libifc_handle_t *h, const char *name, const int mtu); -int libifc_get_mtu(libifc_handle_t *h, const char *name, int *mtu); - -int libifc_set_metric(libifc_handle_t *h, const char *name, const int metric); -int libifc_get_metric(libifc_handle_t *h, const char *name, int *metric); - -int libifc_set_capability(libifc_handle_t *h, const char *name, - const int capability); -int libifc_get_capability(libifc_handle_t *h, const char *name, - struct libifc_capabilities *capability); - -/** Destroy a virtual interface - * @param name Interface to destroy - */ -int libifc_destroy_interface(libifc_handle_t *h, const char *name); - -/** Creates a (virtual) interface - * @param name Name of interface to create. Example: bridge or bridge42 - * @param name ifname Is set to actual name of created interface - */ -int libifc_create_interface(libifc_handle_t *h, const char *name, - char **ifname); Property changes on: head/lib/libifc/libifc.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/lib/libifc/Makefile =================================================================== --- head/lib/libifc/Makefile (revision 305289) +++ head/lib/libifc/Makefile (nonexistent) @@ -1,20 +0,0 @@ -# $FreeBSD$ - -PACKAGE= lib${LIB} -LIB= ifc -# Don't build shared library, for now. -NO_PIC= - -SHLIBDIR?= /lib -SHLIB_MAJOR= 1 -SRCS= libifc.c libifc_internal.c - -INCSDIR= ${INCLUDEDIR} -INCS= libifc.h - -#MAN= libifco.3 - -CFLAGS+= -I${.CURDIR} -WARNS?=6 - -.include Property changes on: head/lib/libifc/Makefile ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/lib/libifc/libifc_internal.h =================================================================== --- head/lib/libifc/libifc_internal.h (revision 305289) +++ head/lib/libifc/libifc_internal.h (nonexistent) @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2016, Marie Helene Kvello-Aune - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * thislist of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#pragma once - -#include "libifc.h" - - -struct errstate { - /** - * Type of error. - */ - libifc_errtype errtype; - - /** - * The error occured in this ioctl() request. - * Populated if errtype = IOCTL - */ - unsigned long ioctl_request; - - /** - * The value of the global errno variable when the error occured. - */ - int errcode; -}; - -struct libifc_handle { - struct errstate error; - int sockets[AF_MAX + 1]; -}; - -/** - * Retrieves socket for address family from - * cache, or creates it if it doesn't already exist. - * @param addressfamily The address family of the socket to retrieve - * @param s The retrieved socket. - * @return 0 on success, -1 on failure. - * {@example - * This example shows how to retrieve a socket from the cache. - * {@code - * static void myfunc() \{ - * int s; - * if (libifc_socket(AF_LOCAL, &s) != 0) \{ - * // Handle error state here - * \} - * // user code here - * \} - * } - * } - */ -int libifc_socket(libifc_handle_t *h, const int addressfamily, int *s); - -/** Function used by other wrapper functions to populate _errstate when appropriate.*/ -int libifc_ioctlwrap_ret(libifc_handle_t *h, unsigned long request, int rcode); - -/** Function to wrap ioctl() and automatically populate libifc_errstate when appropriate.*/ -int libifc_ioctlwrap(libifc_handle_t *h, const int addressfamily, - unsigned long request, struct ifreq *ifr); Property changes on: head/lib/libifc/libifc_internal.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/lib/Makefile =================================================================== --- head/lib/Makefile (revision 305289) +++ head/lib/Makefile (revision 305290) @@ -1,327 +1,327 @@ # @(#)Makefile 8.1 (Berkeley) 6/4/93 # $FreeBSD$ .include # The SUBDIR_BOOTSTRAP list is a small set of libraries which are used by many # of the other libraries. These are built first with a .WAIT between them # and the main list to avoid needing a SUBDIR_DEPEND line on every library # naming just these few items. SUBDIR_BOOTSTRAP= \ csu \ .WAIT \ libc \ libc_nonshared \ libcompiler_rt \ ${_libclang_rt} \ ${_libcplusplus} \ ${_libcxxrt} \ libelf \ msun # The main list; please keep these sorted alphabetically. SUBDIR= ${SUBDIR_BOOTSTRAP} \ .WAIT \ libalias \ libarchive \ ${_libatm} \ libauditd \ libbegemot \ ${_libblacklist} \ libblocksruntime \ ${_libbluetooth} \ ${_libbsnmp} \ libbsdstat \ libbsm \ libbz2 \ libcalendar \ libcam \ ${_libcasper} \ ${_libcom_err} \ libcompat \ libcrypt \ libdevctl \ ${_libdevdctl} \ libdevinfo \ libdevstat \ libdpv \ libdwarf \ libedit \ ${_libelftc} \ libevent \ libexecinfo \ libexpat \ libfetch \ libfigpar \ libgeom \ ${_libgpio} \ ${_libgssapi} \ ${_librpcsec_gss} \ ${_libiconv_modules} \ - libifc \ + libifconfig \ libipsec \ libjail \ libkiconv \ libkvm \ ${_libldns} \ liblzma \ ${_libmagic} \ libmemstat \ libmd \ ${_libmilter} \ ${_libmp} \ libmt \ ${_libnandfs} \ lib80211 \ libnetbsd \ ${_libnetgraph} \ ${_libngatm} \ libnv \ libopenbsd \ libopie \ libpam \ libpcap \ ${_libpe} \ libpjdlog \ ${_libpmc} \ ${_libproc} \ libprocstat \ ${_libradius} \ librpcsvc \ librt \ ${_librtld_db} \ libsbuf \ ${_libsdp} \ ${_libsm} \ libsmb \ ${_libsmdb} \ ${_libsmutil} \ libsqlite3 \ libstand \ libstdbuf \ libstdthreads \ libsysdecode \ libtacplus \ ${_libtelnet} \ ${_libthr} \ libthread_db \ libucl \ libufs \ libugidfw \ libulog \ ${_libunbound} \ ${_libusbhid} \ ${_libusb} \ libutil \ ${_libvgl} \ ${_libvmmapi} \ libwrap \ libxo \ liby \ ${_libypclnt} \ libz \ ncurses \ ${_atf} \ ${_clang} \ ${_cuse} \ ${_tests} # Inter-library dependencies. When the makefile for a library contains LDADD # libraries, those libraries should be listed as build order dependencies here. SUBDIR_DEPEND_libarchive= libz libbz2 libexpat liblzma libmd SUBDIR_DEPEND_libatm= libmd SUBDIR_DEPEND_libauditdm= libbsm SUBDIR_DEPEND_libbsnmp= ${_libnetgraph} SUBDIR_DEPEND_libc++:= libcxxrt SUBDIR_DEPEND_libc= libcompiler_rt SUBDIR_DEPEND_libcam= libsbuf SUBDIR_DEPEND_libcasper= libnv SUBDIR_DEPEND_libdevstat= libkvm SUBDIR_DEPEND_libdpv= libfigpar ncurses libutil SUBDIR_DEPEND_libedit= ncurses SUBDIR_DEPEND_libgeom= libexpat libsbuf SUBDIR_DEPEND_liblibrpcsec_gss= libgssapi SUBDIR_DEPEND_libmagic= libz SUBDIR_DEPEND_libmemstat= libkvm SUBDIR_DEPEND_libopie= libmd SUBDIR_DEPEND_libpam= libcrypt libopie ${_libradius} librpcsvc libtacplus libutil ${_libypclnt} ${_libcom_err} SUBDIR_DEPEND_libpjdlog= libutil SUBDIR_DEPEND_libprocstat= libkvm libutil SUBDIR_DEPEND_libradius= libmd SUBDIR_DEPEND_libsmb= libkiconv SUBDIR_DEPEND_libtacplus= libmd SUBDIR_DEPEND_libulog= libmd SUBDIR_DEPEND_libunbound= ${_libldns} SUBDIR_DEPEND_liblzma= ${_libthr} # NB: keep these sorted by MK_* knobs .if ${MK_ATM} != "no" _libngatm= libngatm .endif .if ${MK_BLACKLIST} != "no" _libblacklist= libblacklist .endif .if ${MK_BLUETOOTH} != "no" _libbluetooth= libbluetooth _libsdp= libsdp .endif .if ${MK_BSNMP} != "no" _libbsnmp= libbsnmp .endif .if ${MK_CASPER} != "no" _libcasper= libcasper .endif .if ${MK_CLANG} != "no" && !defined(COMPAT_32BIT) && !defined(COMPAT_SOFTFP) _clang= clang .endif .if ${MK_CUSE} != "no" _cuse= libcuse .endif .if ${MK_CXX} != "no" _libdevdctl= libdevdctl .endif .if ${MK_TOOLCHAIN} != "no" _libelftc= libelftc _libpe= libpe .endif .if ${MK_FILE} != "no" _libmagic= libmagic .endif .if ${MK_GPIO} != "no" _libgpio= libgpio .endif .if ${MK_GSSAPI} != "no" _libgssapi= libgssapi _librpcsec_gss= librpcsec_gss .endif .if ${MK_ICONV} != "no" _libiconv_modules= libiconv_modules .endif .if ${MK_KERBEROS_SUPPORT} != "no" _libcom_err= libcom_err .endif .if ${MK_LDNS} != "no" _libldns= libldns .endif # The libraries under libclang_rt can only be built by clang, and only make # sense to build when clang is enabled at all. Furthermore, they can only be # built for certain architectures. .if ${MK_CLANG} != "no" && ${COMPILER_TYPE} == "clang" && \ (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ (${MACHINE_CPUARCH} == "arm" && ${MACHINE_ARCH} != "armeb") || \ (${MACHINE_CPUARCH} == "i386")) _libclang_rt= libclang_rt .endif .if ${MK_LIBCPLUSPLUS} != "no" _libcxxrt= libcxxrt _libcplusplus= libc++ .endif .if ${MK_LIBTHR} != "no" _libthr= libthr .endif .if ${MK_NAND} != "no" _libnandfs= libnandfs .endif .if ${MK_NETGRAPH} != "no" _libnetgraph= libnetgraph .endif .if ${MK_NIS} != "no" _libypclnt= libypclnt .endif .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" _libvgl= libvgl _libproc= libproc _librtld_db= librtld_db .endif .if ${MACHINE_CPUARCH} == "amd64" .if ${MK_BHYVE} != "no" _libvmmapi= libvmmapi .endif .endif .if ${MACHINE_CPUARCH} == "mips" _libproc= libproc _librtld_db= librtld_db .endif .if ${MACHINE_CPUARCH} == "powerpc" _libproc= libproc _librtld_db= librtld_db .endif .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" || \ ${MACHINE_CPUARCH} == "riscv" _libproc= libproc _librtld_db= librtld_db .endif .if ${MK_OPENSSL} != "no" _libmp= libmp .endif .if ${MK_PMC} != "no" _libpmc= libpmc .endif .if ${MK_RADIUS_SUPPORT} != "no" _libradius= libradius .endif .if ${MK_SENDMAIL} != "no" _libmilter= libmilter _libsm= libsm _libsmdb= libsmdb _libsmutil= libsmutil .endif .if ${MK_TELNET} != "no" _libtelnet= libtelnet .endif .if ${MK_TESTS_SUPPORT} != "no" _atf= atf .endif .if ${MK_TESTS} != "no" _tests= tests .endif .if ${MK_UNBOUND} != "no" _libunbound= libunbound .endif .if ${MK_USB} != "no" _libusbhid= libusbhid _libusb= libusb .endif .if !make(install) SUBDIR_PARALLEL= .endif .include Index: head/lib/libifconfig/Makefile =================================================================== --- head/lib/libifconfig/Makefile (nonexistent) +++ head/lib/libifconfig/Makefile (revision 305290) @@ -0,0 +1,20 @@ +# $FreeBSD$ + +PACKAGE= lib${LIB} +LIB= ifconfig +# Don't build shared library, for now. +NO_PIC= + +SHLIBDIR?= /lib +SHLIB_MAJOR= 1 +SRCS= libifconfig.c libifconfig_internal.c + +INCSDIR= ${INCLUDEDIR} +INCS= libifconfig.h + +#MAN= libifconfig.3 + +CFLAGS+= -I${.CURDIR} +WARNS?=6 + +.include Property changes on: head/lib/libifconfig/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/lib/libifconfig/libifconfig.c =================================================================== --- head/lib/libifconfig/libifconfig.c (nonexistent) +++ head/lib/libifconfig/libifconfig.c (revision 305290) @@ -0,0 +1,397 @@ +/* + * Copyright (c) 2016, Marie Helene Kvello-Aune + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * thislist of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "libifconfig.h" +#include "libifconfig_internal.h" + + +ifconfig_handle_t * +ifconfig_open(void) +{ + struct ifconfig_handle *h; + + h = calloc(1, sizeof(struct ifconfig_handle)); + + for (int i = 0; i <= AF_MAX; i++) { + h->sockets[i] = -1; + } + + return (h); +} + + +void +ifconfig_close(ifconfig_handle_t *h) +{ + for (int i = 0; i <= AF_MAX; i++) { + if (h->sockets[i] != -1) { + (void)close(h->sockets[i]); + } + } + free(h); +} + + +ifconfig_errtype +ifconfig_err_errtype(ifconfig_handle_t *h) +{ + return (h->error.errtype); +} + + +int +ifconfig_err_errno(ifconfig_handle_t *h) +{ + return (h->error.errcode); +} + + +unsigned long +ifconfig_err_ioctlreq(ifconfig_handle_t *h) +{ + return (h->error.ioctl_request); +} + + +int +ifconfig_get_description(ifconfig_handle_t *h, const char *name, char **description) +{ + struct ifreq ifr; + char *descr = NULL; + size_t descrlen = 64; + + memset(&ifr, 0, sizeof(struct ifreq)); + (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + for (;;) { + if ((descr = reallocf(descr, descrlen)) == NULL) { + h->error.errtype = OTHER; + h->error.errcode = ENOMEM; + return (-1); + } + + ifr.ifr_buffer.buffer = descr; + ifr.ifr_buffer.length = descrlen; + if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCGIFDESCR, + &ifr) != 0) { + return (-1); + } + + if (ifr.ifr_buffer.buffer == descr) { + if (strlen(descr) > 0) { + *description = strdup(descr); + free(descr); + return (0); + } + } else if (ifr.ifr_buffer.length > descrlen) { + descrlen = ifr.ifr_buffer.length; + continue; + } + break; + } + free(descr); + h->error.errtype = OTHER; + h->error.errcode = 0; + return (-1); +} + + +int +ifconfig_set_description(ifconfig_handle_t *h, const char *name, + const char *newdescription) +{ + struct ifreq ifr; + int desclen; + + memset(&ifr, 0, sizeof(struct ifreq)); + desclen = strlen(newdescription); + + /* + * Unset description if the new description is 0 characters long. + * TODO: Decide whether this should be an error condition instead. + */ + if (desclen == 0) { + return (ifconfig_unset_description(h, name)); + } + + (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + + ifr.ifr_buffer.length = desclen + 1; + ifr.ifr_buffer.buffer = strdup(newdescription); + if (ifr.ifr_buffer.buffer == NULL) { + h->error.errtype = OTHER; + h->error.errcode = ENOMEM; + return (-1); + } + + if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCSIFDESCR, &ifr) != 0) { + free(ifr.ifr_buffer.buffer); + return (-1); + } + free(ifr.ifr_buffer.buffer); + return (0); +} + + +int ifconfig_unset_description(ifconfig_handle_t *h, const char *name) +{ + struct ifreq ifr; + + memset(&ifr, 0, sizeof(struct ifreq)); + (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + ifr.ifr_buffer.length = 0; + ifr.ifr_buffer.buffer = NULL; + + if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCSIFDESCR, &ifr) < 0) { + return (-1); + } + return (0); +} + + +int ifconfig_set_name(ifconfig_handle_t *h, const char *name, const char *newname) +{ + struct ifreq ifr; + char *tmpname; + + memset(&ifr, 0, sizeof(struct ifreq)); + tmpname = strdup(newname); + if (tmpname == NULL) { + h->error.errtype = OTHER; + h->error.errcode = ENOMEM; + return (-1); + } + + (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + ifr.ifr_data = tmpname; + + if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCSIFNAME, &ifr) != 0) { + free(tmpname); + return (-1); + } + free(tmpname); + return (0); +} + + +int ifconfig_set_mtu(ifconfig_handle_t *h, const char *name, const int mtu) +{ + struct ifreq ifr; + + memset(&ifr, 0, sizeof(struct ifreq)); + (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + ifr.ifr_mtu = mtu; + if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCSIFMTU, &ifr) < 0) { + return (-1); + } + return (0); +} + + +int ifconfig_get_mtu(ifconfig_handle_t *h, const char *name, int *mtu) +{ + struct ifreq ifr; + + memset(&ifr, 0, sizeof(struct ifreq)); + (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCGIFMTU, &ifr) == -1) { + return (-1); + } + *mtu = ifr.ifr_mtu; + return (0); +} + + +int ifconfig_set_metric(ifconfig_handle_t *h, const char *name, const int mtu) +{ + struct ifreq ifr; + + memset(&ifr, 0, sizeof(struct ifreq)); + (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + ifr.ifr_mtu = mtu; + if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCSIFMETRIC, &ifr) < 0) { + return (-1); + } + return (0); +} + + +int ifconfig_get_metric(ifconfig_handle_t *h, const char *name, int *metric) +{ + struct ifreq ifr; + + memset(&ifr, 0, sizeof(struct ifreq)); + (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCGIFMETRIC, &ifr) == -1) { + return (-1); + } + *metric = ifr.ifr_metric; + return (0); +} + + +int ifconfig_set_capability(ifconfig_handle_t *h, const char *name, + const int capability) +{ + struct ifreq ifr; + struct ifconfig_capabilities ifcap; + int flags; + int value; + + memset(&ifr, 0, sizeof(struct ifreq)); + if (ifconfig_get_capability(h, name, &ifcap) != 0) { + return (-1); + } + + value = capability; + flags = ifcap.curcap; + if (value < 0) { + value = -value; + flags &= ~value; + } else { + flags |= value; + } + flags &= ifcap.reqcap; + + (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + + /* + * TODO: Verify that it's safe to not have ifr.ifr_curcap + * set for this request. + */ + ifr.ifr_reqcap = flags; + if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCSIFCAP, &ifr) < 0) { + return (-1); + } + return (0); +} + + +int ifconfig_get_capability(ifconfig_handle_t *h, const char *name, + struct ifconfig_capabilities *capability) +{ + struct ifreq ifr; + + memset(&ifr, 0, sizeof(struct ifreq)); + (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + + if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCGIFCAP, &ifr) < 0) { + return (-1); + } + capability->curcap = ifr.ifr_curcap; + capability->reqcap = ifr.ifr_reqcap; + return (0); +} + + +int ifconfig_destroy_interface(ifconfig_handle_t *h, const char *name) +{ + struct ifreq ifr; + + memset(&ifr, 0, sizeof(struct ifreq)); + (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + + if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCIFDESTROY, &ifr) < 0) { + return (-1); + } + return (0); +} + + +int ifconfig_create_interface(ifconfig_handle_t *h, const char *name, char **ifname) +{ + struct ifreq ifr; + + memset(&ifr, 0, sizeof(struct ifreq)); + (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + + /* + * TODO: + * Insert special snowflake handling here. See GitHub issue #12 for details. + * In the meantime, hard-nosupport interfaces that need special handling. + */ + if ((strncmp(name, "wlan", strlen("wlan")) == 0) || + (strncmp(name, "vlan", strlen("vlan")) == 0) || + (strncmp(name, "vxlan", strlen("vxlan")) == 0)) { + h->error.errtype = OTHER; + h->error.errcode = ENOSYS; + return (-1); + } + + /* No special handling for this interface type. */ + + if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCIFCREATE2, &ifr) < 0) { + return (-1); + } + *ifname = strdup(ifr.ifr_name); + return (0); +} Property changes on: head/lib/libifconfig/libifconfig.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/lib/libifconfig/libifconfig.h =================================================================== --- head/lib/libifconfig/libifconfig.h (nonexistent) +++ head/lib/libifconfig/libifconfig.h (revision 305290) @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2016, Marie Helene Kvello-Aune + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * thislist of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#pragma once + +typedef enum { + OTHER, IOCTL, SOCKET +} ifconfig_errtype; + +/* + * Opaque definition so calling application can just pass a + * pointer to it for library use. + */ +struct ifconfig_handle; +typedef struct ifconfig_handle ifconfig_handle_t; + +struct ifconfig_capabilities { + /** Current capabilities (ifconfig prints this as 'options')*/ + int curcap; + /** Requested capabilities (ifconfig prints this as 'capabilities')*/ + int reqcap; +}; + + +/** Retrieves a new state object for use in other API calls. + * Example usage: + *{@code + * // Create state object + * ifconfig_handle_t *lifh = ifconfig_open(); + * + * // Do stuff with it + * + * // Dispose of the state object + * ifconfig_close(lifh); + * lifh = NULL; + *} + */ +ifconfig_handle_t *ifconfig_open(void); + +/** Frees resources held in the provided state object. + * @param h The state object to close. + * @see #ifconfig_open(void) + */ +void ifconfig_close(ifconfig_handle_t *h); + +/** Identifies what kind of error occured. */ +ifconfig_errtype ifconfig_err_errtype(ifconfig_handle_t *h); + +/** Retrieves the errno associated with the error, if any. */ +int ifconfig_err_errno(ifconfig_handle_t *h); + +/** If error type was IOCTL, this identifies which request failed. */ +unsigned long ifconfig_err_ioctlreq(ifconfig_handle_t *h); + +int ifconfig_get_description(ifconfig_handle_t *h, const char *name, + char **description); +int ifconfig_set_description(ifconfig_handle_t *h, const char *name, + const char *newdescription); +int ifconfig_unset_description(ifconfig_handle_t *h, const char *name); +int ifconfig_set_name(ifconfig_handle_t *h, const char *name, const char *newname); +int ifconfig_set_mtu(ifconfig_handle_t *h, const char *name, const int mtu); +int ifconfig_get_mtu(ifconfig_handle_t *h, const char *name, int *mtu); + +int ifconfig_set_metric(ifconfig_handle_t *h, const char *name, const int metric); +int ifconfig_get_metric(ifconfig_handle_t *h, const char *name, int *metric); + +int ifconfig_set_capability(ifconfig_handle_t *h, const char *name, + const int capability); +int ifconfig_get_capability(ifconfig_handle_t *h, const char *name, + struct ifconfig_capabilities *capability); + +/** Destroy a virtual interface + * @param name Interface to destroy + */ +int ifconfig_destroy_interface(ifconfig_handle_t *h, const char *name); + +/** Creates a (virtual) interface + * @param name Name of interface to create. Example: bridge or bridge42 + * @param name ifname Is set to actual name of created interface + */ +int ifconfig_create_interface(ifconfig_handle_t *h, const char *name, + char **ifname); Property changes on: head/lib/libifconfig/libifconfig.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/lib/libifconfig/libifconfig_internal.c =================================================================== --- head/lib/libifconfig/libifconfig_internal.c (nonexistent) +++ head/lib/libifconfig/libifconfig_internal.c (revision 305290) @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2016, Marie Helene Kvello-Aune + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * thislist of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + + +#include + +#include +#include +#include +#include +#include + + +#include "libifconfig.h" // Needed for ifconfig_errstate +#include "libifconfig_internal.h" + +int +ifconfig_ioctlwrap_ret(ifconfig_handle_t *h, unsigned long request, int rcode) +{ + if (rcode != 0) { + h->error.errtype = IOCTL; + h->error.ioctl_request = request; + h->error.errcode = errno; + } + return (rcode); +} + + +int +ifconfig_ioctlwrap(ifconfig_handle_t *h, const int addressfamily, + unsigned long request, struct ifreq *ifr) +{ + int s; + + if (ifconfig_socket(h, addressfamily, &s) != 0) { + return (-1); + } + + int rcode = ioctl(s, request, ifr); + return (ifconfig_ioctlwrap_ret(h, request, rcode)); +} + + +/* + * Function to get socket for the specified address family. + * If the socket doesn't already exist, attempt to create it. + */ +int ifconfig_socket(ifconfig_handle_t *h, const int addressfamily, int *s) +{ + if (addressfamily > AF_MAX) { + h->error.errtype = SOCKET; + h->error.errcode = EINVAL; + return (-1); + } + + if (h->sockets[addressfamily] != -1) { + *s = h->sockets[addressfamily]; + return (0); + } + + /* We don't have a socket of that type available. Create one. */ + h->sockets[addressfamily] = socket(addressfamily, SOCK_DGRAM, 0); + if (h->sockets[addressfamily] == -1) { + h->error.errtype = SOCKET; + h->error.errcode = errno; + return (-1); + } + + *s = h->sockets[addressfamily]; + return (0); +} Property changes on: head/lib/libifconfig/libifconfig_internal.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/lib/libifconfig/libifconfig_internal.h =================================================================== --- head/lib/libifconfig/libifconfig_internal.h (nonexistent) +++ head/lib/libifconfig/libifconfig_internal.h (revision 305290) @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2016, Marie Helene Kvello-Aune + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * thislist of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#pragma once + +#include "libifconfig.h" + + +struct errstate { + /** + * Type of error. + */ + ifconfig_errtype errtype; + + /** + * The error occured in this ioctl() request. + * Populated if errtype = IOCTL + */ + unsigned long ioctl_request; + + /** + * The value of the global errno variable when the error occured. + */ + int errcode; +}; + +struct ifconfig_handle { + struct errstate error; + int sockets[AF_MAX + 1]; +}; + +/** + * Retrieves socket for address family from + * cache, or creates it if it doesn't already exist. + * @param addressfamily The address family of the socket to retrieve + * @param s The retrieved socket. + * @return 0 on success, -1 on failure. + * {@example + * This example shows how to retrieve a socket from the cache. + * {@code + * static void myfunc() \{ + * int s; + * if (ifconfig_socket(AF_LOCAL, &s) != 0) \{ + * // Handle error state here + * \} + * // user code here + * \} + * } + * } + */ +int ifconfig_socket(ifconfig_handle_t *h, const int addressfamily, int *s); + +/** Function used by other wrapper functions to populate _errstate when appropriate.*/ +int ifconfig_ioctlwrap_ret(ifconfig_handle_t *h, unsigned long request, int rcode); + +/** Function to wrap ioctl() and automatically populate ifconfig_errstate when appropriate.*/ +int ifconfig_ioctlwrap(ifconfig_handle_t *h, const int addressfamily, + unsigned long request, struct ifreq *ifr); Property changes on: head/lib/libifconfig/libifconfig_internal.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/share/examples/libifc/ifdestroy.c =================================================================== --- head/share/examples/libifc/ifdestroy.c (revision 305289) +++ head/share/examples/libifc/ifdestroy.c (nonexistent) @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2016, Marie Helene Kvello-Aune - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * thislist of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - - -int main(int argc, char *argv[]) -{ - if (argc != 2) { - errx(EINVAL, "Invalid number of arguments." - " Only one argument is accepted, and it should be the name" - " of the interface to be destroyed."); - } - - char *ifname; - - /* We have a static number of arguments. Therefore we can do it simple. */ - ifname = strdup(argv[1]); - - printf("Interface name: %s\n", ifname); - - libifc_handle_t *lifh = libifc_open(); - if (libifc_destroy_interface(lifh, ifname) == 0) { - printf("Successfully destroyed interface '%s'.", ifname); - libifc_close(lifh); - lifh = NULL; - free(ifname); - return (0); - } else { - switch (libifc_err_errtype(lifh)) { - case SOCKET: - warnx("couldn't create socket. This shouldn't happen.\n"); - break; - case IOCTL: - if (libifc_err_ioctlreq(lifh) == SIOCIFDESTROY) { - warnx( - "Failed to destroy interface (SIOCIFDESTROY)\n"); - } - break; - default: - warnx( - "Should basically never end up here in this example.\n"); - break; - } - - libifc_close(lifh); - lifh = NULL; - free(ifname); - return (-1); - } -} Property changes on: head/share/examples/libifc/ifdestroy.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/share/examples/libifc/setmtu.c =================================================================== --- head/share/examples/libifc/setmtu.c (revision 305289) +++ head/share/examples/libifc/setmtu.c (nonexistent) @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2016, Marie Helene Kvello-Aune - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * thislist of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - - -int main(int argc, char *argv[]) -{ - if (argc != 3) { - errx(EINVAL, "Invalid number of arguments." - " First argument should be interface name, second argument" - " should be the MTU to set."); - } - - char *ifname, *ptr; - int mtu; - - /* We have a static number of arguments. Therefore we can do it simple. */ - ifname = strdup(argv[1]); - mtu = (int)strtol(argv[2], &ptr, 10); - - printf("Interface name: %s\n", ifname); - printf("New MTU: %d", mtu); - - libifc_handle_t *lifh = libifc_open(); - if (libifc_set_mtu(lifh, ifname, mtu) == 0) { - printf("Successfully changed MTU of %s to %d\n", ifname, mtu); - libifc_close(lifh); - lifh = NULL; - free(ifname); - return (0); - } else { - switch (libifc_err_errtype(lifh)) { - case SOCKET: - warnx("couldn't create socket. This shouldn't happen.\n"); - break; - case IOCTL: - if (libifc_err_ioctlreq(lifh) == SIOCSIFMTU) { - warnx("Failed to set MTU (SIOCSIFMTU)\n"); - } else { - warnx( - "Failed to set MTU due to error in unexpected ioctl() call %lu. Error code: %i.\n", - libifc_err_ioctlreq(lifh), - libifc_err_errno(lifh)); - } - break; - default: - warnx( - "Should basically never end up here in this example.\n"); - break; - } - - libifc_close(lifh); - lifh = NULL; - free(ifname); - return (-1); - } -} Property changes on: head/share/examples/libifc/setmtu.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/share/examples/libifc/ifcreate.c =================================================================== --- head/share/examples/libifc/ifcreate.c (revision 305289) +++ head/share/examples/libifc/ifcreate.c (nonexistent) @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2016, Marie Helene Kvello-Aune - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * thislist of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - - -int main(int argc, char *argv[]) -{ - if (argc != 2) { - errx(EINVAL, "Invalid number of arguments." - " Only one argument is accepted, and it should be the name" - " of the interface to be created."); - } - - char *ifname, *ifactualname; - - /* We have a static number of arguments. Therefore we can do it simple. */ - ifname = strdup(argv[1]); - - printf("Requested interface name: %s\n", ifname); - - libifc_handle_t *lifh = libifc_open(); - if (libifc_create_interface(lifh, ifname, &ifactualname) == 0) { - printf("Successfully created interface '%s'\n", ifactualname); - libifc_close(lifh); - lifh = NULL; - free(ifname); - free(ifactualname); - return (0); - } else { - switch (libifc_err_errtype(lifh)) { - case SOCKET: - warnx("couldn't create socket. This shouldn't happen.\n"); - break; - case IOCTL: - if (libifc_err_ioctlreq(lifh) == SIOCIFCREATE2) { - warnx( - "Failed to create interface (SIOCIFCREATE2)\n"); - } - break; - default: - warnx( - "This is a thorough example accommodating for temporary" - " 'not implemented yet' errors. That's likely what happened" - " now. If not, your guess is as good as mine. ;)" - " Error code: %d\n", libifc_err_errno( - lifh)); - break; - } - - libifc_close(lifh); - lifh = NULL; - free(ifname); - free(ifactualname); - return (-1); - } -} Property changes on: head/share/examples/libifc/ifcreate.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/share/examples/libifc/setdescription.c =================================================================== --- head/share/examples/libifc/setdescription.c (revision 305289) +++ head/share/examples/libifc/setdescription.c (nonexistent) @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2016, Marie Helene Kvello-Aune - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * thislist of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include - - -int main(int argc, char *argv[]) -{ - if (argc != 3) { - errx(EINVAL, "Invalid number of arguments." - " First argument should be interface name, second argument" - " should be the description to set."); - } - - char *ifname, *ifdescr, *curdescr; - /* We have a static number of arguments. Therefore we can do it simple. */ - ifname = strdup(argv[1]); - ifdescr = strdup(argv[2]); - curdescr = NULL; - - printf("Interface name: %s\n", ifname); - - libifc_handle_t *lifh = libifc_open(); - if (libifc_get_description(lifh, ifname, &curdescr) == 0) { - printf("Old description: %s\n", curdescr); - } - - printf("New description: %s\n\n", ifdescr); - - if (libifc_set_description(lifh, ifname, ifdescr) == 0) { - printf("New description successfully set.\n"); - } else { - switch (libifc_err_errtype(lifh)) { - case SOCKET: - err(libifc_err_errno(lifh), "Socket error"); - break; - case IOCTL: - err(libifc_err_errno( - lifh), "IOCTL(%lu) error", - libifc_err_ioctlreq(lifh)); - break; - case OTHER: - err(libifc_err_errno(lifh), "Other error"); - break; - } - } - - free(ifname); - free(ifdescr); - free(curdescr); - ifname = NULL; - ifdescr = NULL; - curdescr = NULL; - - libifc_close(lifh); - return (0); -} Property changes on: head/share/examples/libifc/setdescription.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/share/examples/libifc/Makefile =================================================================== --- head/share/examples/libifc/Makefile (revision 305289) +++ head/share/examples/libifc/Makefile (nonexistent) @@ -1,9 +0,0 @@ -# $FreeBSD$ - -default: - $(CC) -Wall -fPIC -lifc -g -o example_setdescription setdescription.c - $(CC) -Wall -fPIC -lifc -g -o example_setmtu setmtu.c - $(CC) -Wall -fPIC -lifc -g -o example_ifdestroy ifdestroy.c - $(CC) -Wall -fPIC -lifc -g -o example_ifcreate ifcreate.c -clean: - rm -f example_* Property changes on: head/share/examples/libifc/Makefile ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/share/examples/libifconfig/Makefile =================================================================== --- head/share/examples/libifconfig/Makefile (nonexistent) +++ head/share/examples/libifconfig/Makefile (revision 305290) @@ -0,0 +1,8 @@ +# $FreeBSD$ +default: + $(CC) -Wall -fPIC -lifconfig -g -o example_setdescription setdescription.c + $(CC) -Wall -fPIC -lifconfig -g -o example_setmtu setmtu.c + $(CC) -Wall -fPIC -lifconfig -g -o example_ifdestroy ifdestroy.c + $(CC) -Wall -fPIC -lifconfig -g -o example_ifcreate ifcreate.c +clean: + rm -f example_* Property changes on: head/share/examples/libifconfig/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/share/examples/libifconfig/ifcreate.c =================================================================== --- head/share/examples/libifconfig/ifcreate.c (nonexistent) +++ head/share/examples/libifconfig/ifcreate.c (revision 305290) @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2016, Marie Helene Kvello-Aune + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * thislist of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include + + +int main(int argc, char *argv[]) +{ + if (argc != 2) { + errx(EINVAL, "Invalid number of arguments." + " Only one argument is accepted, and it should be the name" + " of the interface to be created."); + } + + char *ifname, *ifactualname; + + /* We have a static number of arguments. Therefore we can do it simple. */ + ifname = strdup(argv[1]); + + printf("Requested interface name: %s\n", ifname); + + ifconfig_handle_t *lifh = ifconfig_open(); + if (ifconfig_create_interface(lifh, ifname, &ifactualname) == 0) { + printf("Successfully created interface '%s'\n", ifactualname); + ifconfig_close(lifh); + lifh = NULL; + free(ifname); + free(ifactualname); + return (0); + } else { + switch (ifconfig_err_errtype(lifh)) { + case SOCKET: + warnx("couldn't create socket. This shouldn't happen.\n"); + break; + case IOCTL: + if (ifconfig_err_ioctlreq(lifh) == SIOCIFCREATE2) { + warnx( + "Failed to create interface (SIOCIFCREATE2)\n"); + } + break; + default: + warnx( + "This is a thorough example accommodating for temporary" + " 'not implemented yet' errors. That's likely what happened" + " now. If not, your guess is as good as mine. ;)" + " Error code: %d\n", ifconfig_err_errno( + lifh)); + break; + } + + ifconfig_close(lifh); + lifh = NULL; + free(ifname); + free(ifactualname); + return (-1); + } +} Property changes on: head/share/examples/libifconfig/ifcreate.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/share/examples/libifconfig/ifdestroy.c =================================================================== --- head/share/examples/libifconfig/ifdestroy.c (nonexistent) +++ head/share/examples/libifconfig/ifdestroy.c (revision 305290) @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2016, Marie Helene Kvello-Aune + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * thislist of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include + + +int main(int argc, char *argv[]) +{ + if (argc != 2) { + errx(EINVAL, "Invalid number of arguments." + " Only one argument is accepted, and it should be the name" + " of the interface to be destroyed."); + } + + char *ifname; + + /* We have a static number of arguments. Therefore we can do it simple. */ + ifname = strdup(argv[1]); + + printf("Interface name: %s\n", ifname); + + ifconfig_handle_t *lifh = ifconfig_open(); + if (ifconfig_destroy_interface(lifh, ifname) == 0) { + printf("Successfully destroyed interface '%s'.", ifname); + ifconfig_close(lifh); + lifh = NULL; + free(ifname); + return (0); + } else { + switch (ifconfig_err_errtype(lifh)) { + case SOCKET: + warnx("couldn't create socket. This shouldn't happen.\n"); + break; + case IOCTL: + if (ifconfig_err_ioctlreq(lifh) == SIOCIFDESTROY) { + warnx( + "Failed to destroy interface (SIOCIFDESTROY)\n"); + } + break; + default: + warnx( + "Should basically never end up here in this example.\n"); + break; + } + + ifconfig_close(lifh); + lifh = NULL; + free(ifname); + return (-1); + } +} Property changes on: head/share/examples/libifconfig/ifdestroy.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/share/examples/libifconfig/setdescription.c =================================================================== --- head/share/examples/libifconfig/setdescription.c (nonexistent) +++ head/share/examples/libifconfig/setdescription.c (revision 305290) @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2016, Marie Helene Kvello-Aune + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * thislist of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include + + +int main(int argc, char *argv[]) +{ + if (argc != 3) { + errx(EINVAL, "Invalid number of arguments." + " First argument should be interface name, second argument" + " should be the description to set."); + } + + char *ifname, *ifdescr, *curdescr; + /* We have a static number of arguments. Therefore we can do it simple. */ + ifname = strdup(argv[1]); + ifdescr = strdup(argv[2]); + curdescr = NULL; + + printf("Interface name: %s\n", ifname); + + ifconfig_handle_t *lifh = ifconfig_open(); + if (ifconfig_get_description(lifh, ifname, &curdescr) == 0) { + printf("Old description: %s\n", curdescr); + } + + printf("New description: %s\n\n", ifdescr); + + if (ifconfig_set_description(lifh, ifname, ifdescr) == 0) { + printf("New description successfully set.\n"); + } else { + switch (ifconfig_err_errtype(lifh)) { + case SOCKET: + err(ifconfig_err_errno(lifh), "Socket error"); + break; + case IOCTL: + err(ifconfig_err_errno( + lifh), "IOCTL(%lu) error", + ifconfig_err_ioctlreq(lifh)); + break; + case OTHER: + err(ifconfig_err_errno(lifh), "Other error"); + break; + } + } + + free(ifname); + free(ifdescr); + free(curdescr); + ifname = NULL; + ifdescr = NULL; + curdescr = NULL; + + ifconfig_close(lifh); + return (0); +} Property changes on: head/share/examples/libifconfig/setdescription.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/share/examples/libifconfig/setmtu.c =================================================================== --- head/share/examples/libifconfig/setmtu.c (nonexistent) +++ head/share/examples/libifconfig/setmtu.c (revision 305290) @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2016, Marie Helene Kvello-Aune + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * thislist of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include + + +int main(int argc, char *argv[]) +{ + if (argc != 3) { + errx(EINVAL, "Invalid number of arguments." + " First argument should be interface name, second argument" + " should be the MTU to set."); + } + + char *ifname, *ptr; + int mtu; + + /* We have a static number of arguments. Therefore we can do it simple. */ + ifname = strdup(argv[1]); + mtu = (int)strtol(argv[2], &ptr, 10); + + printf("Interface name: %s\n", ifname); + printf("New MTU: %d", mtu); + + ifconfig_handle_t *lifh = ifconfig_open(); + if (ifconfig_set_mtu(lifh, ifname, mtu) == 0) { + printf("Successfully changed MTU of %s to %d\n", ifname, mtu); + ifconfig_close(lifh); + lifh = NULL; + free(ifname); + return (0); + } else { + switch (ifconfig_err_errtype(lifh)) { + case SOCKET: + warnx("couldn't create socket. This shouldn't happen.\n"); + break; + case IOCTL: + if (ifconfig_err_ioctlreq(lifh) == SIOCSIFMTU) { + warnx("Failed to set MTU (SIOCSIFMTU)\n"); + } else { + warnx( + "Failed to set MTU due to error in unexpected ioctl() call %lu. Error code: %i.\n", + ifconfig_err_ioctlreq(lifh), + ifconfig_err_errno(lifh)); + } + break; + default: + warnx( + "Should basically never end up here in this example.\n"); + break; + } + + ifconfig_close(lifh); + lifh = NULL; + free(ifname); + return (-1); + } +} Property changes on: head/share/examples/libifconfig/setmtu.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/share/mk/bsd.libnames.mk =================================================================== --- head/share/mk/bsd.libnames.mk (revision 305289) +++ head/share/mk/bsd.libnames.mk (revision 305290) @@ -1,194 +1,194 @@ # $FreeBSD$ # The include file define library names. # Other include files (e.g. bsd.prog.mk, bsd.lib.mk) include this # file where necessary. .if !target(____) .error bsd.libnames.mk cannot be included directly. .endif .sinclude # Src directory locations are also defined in src.libnames.mk. LIBCRT0?= ${DESTDIR}${LIBDIR}/crt0.o LIB80211?= ${DESTDIR}${LIBDIR}/lib80211.a LIBALIAS?= ${DESTDIR}${LIBDIR}/libalias.a LIBARCHIVE?= ${DESTDIR}${LIBDIR}/libarchive.a LIBASN1?= ${DESTDIR}${LIBDIR}/libasn1.a LIBATM?= ${DESTDIR}${LIBDIR}/libatm.a LIBAUDITD?= ${DESTDIR}${LIBDIR}/libauditd.a LIBAVL?= ${DESTDIR}${LIBDIR}/libavl.a LIBBEGEMOT?= ${DESTDIR}${LIBDIR}/libbegemot.a LIBBLACKLIST?= ${DESTDIR}${LIBDIR}/libblacklist.a LIBBLUETOOTH?= ${DESTDIR}${LIBDIR}/libbluetooth.a LIBBSDXML?= ${DESTDIR}${LIBDIR}/libbsdxml.a LIBBSM?= ${DESTDIR}${LIBDIR}/libbsm.a LIBBSNMP?= ${DESTDIR}${LIBDIR}/libbsnmp.a LIBBZ2?= ${DESTDIR}${LIBDIR}/libbz2.a LIBC?= ${DESTDIR}${LIBDIR}/libc.a LIBCALENDAR?= ${DESTDIR}${LIBDIR}/libcalendar.a LIBCAM?= ${DESTDIR}${LIBDIR}/libcam.a LIBCAP_DNS?= ${DESTDIR}${LIBDIR}/libcap_dns.a LIBCAP_GRP?= ${DESTDIR}${LIBDIR}/libcap_grp.a LIBCAP_PWD?= ${DESTDIR}${LIBDIR}/libcap_pwd.a LIBCAP_RANDOM?= ${DESTDIR}${LIBDIR}/libcap_random.a LIBCAP_SYSCTL?= ${DESTDIR}${LIBDIR}/libcap_sysctl.a LIBCASPER?= ${DESTDIR}${LIBDIR}/libcasper.a LIBCOMPAT?= ${DESTDIR}${LIBDIR}/libcompat.a LIBCOMPILER_RT?=${DESTDIR}${LIBDIR}/libcompiler_rt.a LIBCOM_ERR?= ${DESTDIR}${LIBDIR}/libcom_err.a LIBCPLUSPLUS?= ${DESTDIR}${LIBDIR}/libc++.a LIBCRYPT?= ${DESTDIR}${LIBDIR}/libcrypt.a LIBCRYPTO?= ${DESTDIR}${LIBDIR}/libcrypto.a LIBCTF?= ${DESTDIR}${LIBDIR}/libctf.a LIBCURSES?= ${DESTDIR}${LIBDIR}/libcurses.a LIBCUSE?= ${DESTDIR}${LIBDIR}/libcuse.a LIBCXGB4?= ${DESTDIR}${LIBDIR}/libcxgb4.a LIBCXXRT?= ${DESTDIR}${LIBDIR}/libcxxrt.a LIBC_PIC?= ${DESTDIR}${LIBDIR}/libc_pic.a LIBDEVCTL?= ${DESTDIR}${LIBDIR}/libdevctl.a LIBDEVDCTL?= ${DESTDIR}${LIBDIR}/libdevdctl.a LIBDEVINFO?= ${DESTDIR}${LIBDIR}/libdevinfo.a LIBDEVSTAT?= ${DESTDIR}${LIBDIR}/libdevstat.a LIBDIALOG?= ${DESTDIR}${LIBDIR}/libdialog.a LIBDNS?= ${DESTDIR}${LIBDIR}/libdns.a LIBDPV?= ${DESTDIR}${LIBDIR}/libdpv.a LIBDTRACE?= ${DESTDIR}${LIBDIR}/libdtrace.a LIBDWARF?= ${DESTDIR}${LIBDIR}/libdwarf.a LIBEDIT?= ${DESTDIR}${LIBDIR}/libedit.a LIBELF?= ${DESTDIR}${LIBDIR}/libelf.a LIBEXECINFO?= ${DESTDIR}${LIBDIR}/libexecinfo.a LIBFETCH?= ${DESTDIR}${LIBDIR}/libfetch.a LIBFIGPAR?= ${DESTDIR}${LIBDIR}/libfigpar.a LIBFL?= "don't use LIBFL, use LIBL" LIBFORM?= ${DESTDIR}${LIBDIR}/libform.a LIBG2C?= ${DESTDIR}${LIBDIR}/libg2c.a LIBGEOM?= ${DESTDIR}${LIBDIR}/libgeom.a LIBGNUREGEX?= ${DESTDIR}${LIBDIR}/libgnuregex.a LIBGPIO?= ${DESTDIR}${LIBDIR}/libgpio.a LIBGSSAPI?= ${DESTDIR}${LIBDIR}/libgssapi.a LIBGSSAPI_KRB5?= ${DESTDIR}${LIBDIR}/libgssapi_krb5.a LIBHDB?= ${DESTDIR}${LIBDIR}/libhdb.a LIBHEIMBASE?= ${DESTDIR}${LIBDIR}/libheimbase.a LIBHEIMNTLM?= ${DESTDIR}${LIBDIR}/libheimntlm.a LIBHEIMSQLITE?= ${DESTDIR}${LIBDIR}/libheimsqlite.a LIBHX509?= ${DESTDIR}${LIBDIR}/libhx509.a LIBIBCM?= ${DESTDIR}${LIBDIR}/libibcm.a LIBIBCOMMON?= ${DESTDIR}${LIBDIR}/libibcommon.a LIBIBMAD?= ${DESTDIR}${LIBDIR}/libibmad.a LIBIBSDP?= ${DESTDIR}${LIBDIR}/libibsdp.a LIBIBUMAD?= ${DESTDIR}${LIBDIR}/libibumad.a LIBIBVERBS?= ${DESTDIR}${LIBDIR}/libibverbs.a -LIBIFC?= ${DESTDIR}${LIBDIR}/libifc.a +LIBIFCONFIG?= ${DESTDIR}${LIBDIR}/libifconfig.a LIBIPSEC?= ${DESTDIR}${LIBDIR}/libipsec.a LIBJAIL?= ${DESTDIR}${LIBDIR}/libjail.a LIBKADM5CLNT?= ${DESTDIR}${LIBDIR}/libkadm5clnt.a LIBKADM5SRV?= ${DESTDIR}${LIBDIR}/libkadm5srv.a LIBKAFS5?= ${DESTDIR}${LIBDIR}/libkafs5.a LIBKDC?= ${DESTDIR}${LIBDIR}/libkdc.a LIBKEYCAP?= ${DESTDIR}${LIBDIR}/libkeycap.a LIBKICONV?= ${DESTDIR}${LIBDIR}/libkiconv.a LIBKRB5?= ${DESTDIR}${LIBDIR}/libkrb5.a LIBKVM?= ${DESTDIR}${LIBDIR}/libkvm.a LIBL?= ${DESTDIR}${LIBDIR}/libl.a LIBLN?= "don't use LIBLN, use LIBL" LIBLZMA?= ${DESTDIR}${LIBDIR}/liblzma.a LIBM?= ${DESTDIR}${LIBDIR}/libm.a LIBMAGIC?= ${DESTDIR}${LIBDIR}/libmagic.a LIBMD?= ${DESTDIR}${LIBDIR}/libmd.a LIBMEMSTAT?= ${DESTDIR}${LIBDIR}/libmemstat.a LIBMENU?= ${DESTDIR}${LIBDIR}/libmenu.a LIBMILTER?= ${DESTDIR}${LIBDIR}/libmilter.a LIBMLX4?= ${DESTDIR}${LIBDIR}/libmlx4.a LIBMP?= ${DESTDIR}${LIBDIR}/libmp.a LIBMT?= ${DESTDIR}${LIBDIR}/libmt.a LIBMTHCA?= ${DESTDIR}${LIBDIR}/libmthca.a LIBNANDFS?= ${DESTDIR}${LIBDIR}/libnandfs.a LIBNCURSES?= ${DESTDIR}${LIBDIR}/libncurses.a LIBNCURSESW?= ${DESTDIR}${LIBDIR}/libncursesw.a LIBNETGRAPH?= ${DESTDIR}${LIBDIR}/libnetgraph.a LIBNGATM?= ${DESTDIR}${LIBDIR}/libngatm.a LIBNV?= ${DESTDIR}${LIBDIR}/libnv.a LIBNVPAIR?= ${DESTDIR}${LIBDIR}/libnvpair.a LIBOPENSM?= ${DESTDIR}${LIBDIR}/libopensm.a LIBOPIE?= ${DESTDIR}${LIBDIR}/libopie.a LIBOSMCOMP?= ${DESTDIR}${LIBDIR}/libosmcomp.a LIBOSMVENDOR?= ${DESTDIR}${LIBDIR}/libosmvendor.a LIBPAM?= ${DESTDIR}${LIBDIR}/libpam.a LIBPANEL?= ${DESTDIR}${LIBDIR}/libpanel.a LIBPANELW?= ${DESTDIR}${LIBDIR}/libpanelw.a LIBPCAP?= ${DESTDIR}${LIBDIR}/libpcap.a LIBPJDLOG?= ${DESTDIR}${LIBDIR}/libpjdlog.a LIBPMC?= ${DESTDIR}${LIBDIR}/libpmc.a LIBPROC?= ${DESTDIR}${LIBDIR}/libproc.a LIBPROCSTAT?= ${DESTDIR}${LIBDIR}/libprocstat.a LIBPTHREAD?= ${DESTDIR}${LIBDIR}/libpthread.a LIBRADIUS?= ${DESTDIR}${LIBDIR}/libradius.a LIBRDMACM?= ${DESTDIR}${LIBDIR}/librdmacm.a LIBROKEN?= ${DESTDIR}${LIBDIR}/libroken.a LIBRPCSEC_GSS?= ${DESTDIR}${LIBDIR}/librpcsec_gss.a LIBRPCSVC?= ${DESTDIR}${LIBDIR}/librpcsvc.a LIBRT?= ${DESTDIR}${LIBDIR}/librt.a LIBRTLD_DB?= ${DESTDIR}${LIBDIR}/librtld_db.a LIBSBUF?= ${DESTDIR}${LIBDIR}/libsbuf.a LIBSDP?= ${DESTDIR}${LIBDIR}/libsdp.a LIBSMB?= ${DESTDIR}${LIBDIR}/libsmb.a LIBSSL?= ${DESTDIR}${LIBDIR}/libssl.a LIBSSP_NONSHARED?= ${DESTDIR}${LIBDIR}/libssp_nonshared.a LIBSTAND?= ${DESTDIR}${LIBDIR}/libstand.a LIBSTDCPLUSPLUS?= ${DESTDIR}${LIBDIR}/libstdc++.a LIBSTDTHREADS?= ${DESTDIR}${LIBDIR}/libstdthreads.a LIBSYSDECODE?= ${DESTDIR}${LIBDIR}/libsysdecode.a LIBTACPLUS?= ${DESTDIR}${LIBDIR}/libtacplus.a LIBTERMCAP?= ${DESTDIR}${LIBDIR}/libtermcap.a LIBTERMCAPW?= ${DESTDIR}${LIBDIR}/libtermcapw.a LIBTERMLIB?= "don't use LIBTERMLIB, use LIBTERMCAP" LIBTINFO?= "don't use LIBTINFO, use LIBNCURSES" LIBUFS?= ${DESTDIR}${LIBDIR}/libufs.a LIBUGIDFW?= ${DESTDIR}${LIBDIR}/libugidfw.a LIBULOG?= ${DESTDIR}${LIBDIR}/libulog.a LIBUMEM?= ${DESTDIR}${LIBDIR}/libumem.a LIBUSB?= ${DESTDIR}${LIBDIR}/libusb.a LIBUSBHID?= ${DESTDIR}${LIBDIR}/libusbhid.a LIBUTIL?= ${DESTDIR}${LIBDIR}/libutil.a LIBUUTIL?= ${DESTDIR}${LIBDIR}/libuutil.a LIBVGL?= ${DESTDIR}${LIBDIR}/libvgl.a LIBVMMAPI?= ${DESTDIR}${LIBDIR}/libvmmapi.a LIBWIND?= ${DESTDIR}${LIBDIR}/libwind.a LIBWRAP?= ${DESTDIR}${LIBDIR}/libwrap.a LIBXO?= ${DESTDIR}${LIBDIR}/libxo.a LIBXPG4?= ${DESTDIR}${LIBDIR}/libxpg4.a LIBY?= ${DESTDIR}${LIBDIR}/liby.a LIBYPCLNT?= ${DESTDIR}${LIBDIR}/libypclnt.a LIBZ?= ${DESTDIR}${LIBDIR}/libz.a LIBZFS?= ${DESTDIR}${LIBDIR}/libzfs.a LIBZFS_CORE?= ${DESTDIR}${LIBDIR}/libzfs_core.a LIBZPOOL?= ${DESTDIR}${LIBDIR}/libzpool.a # enforce the 2 -lpthread and -lc to always be the last in that exact order .if defined(LDADD) .if ${LDADD:M-lpthread} LDADD:= ${LDADD:N-lpthread} -lpthread .endif .if ${LDADD:M-lc} LDADD:= ${LDADD:N-lc} -lc .endif .endif # Only do this for src builds. .if defined(SRCTOP) .if defined(_LIBRARIES) && defined(LIB) && \ ${_LIBRARIES:M${LIB}} != "" .if !defined(LIB${LIB:tu}) .error ${.CURDIR}: Missing value for LIB${LIB:tu} in ${_this:T}. Likely should be: LIB${LIB:tu}?= $${DESTDIR}$${LIBDIR}/lib${LIB}.a .endif .endif # Derive LIB*SRCDIR from LIB*DIR .for lib in ${_LIBRARIES} LIB${lib:tu}SRCDIR?= ${SRCTOP}/${LIB${lib:tu}DIR:S,^${OBJTOP}/,,} .endfor .endif Index: head/share/mk/src.libnames.mk =================================================================== --- head/share/mk/src.libnames.mk (revision 305289) +++ head/share/mk/src.libnames.mk (revision 305290) @@ -1,578 +1,578 @@ # $FreeBSD$ # # The include file define library names suitable # for INTERNALLIB and PRIVATELIB definition .if !target(____) .error src.libnames.mk cannot be included directly. .endif .if !target(____) ____: .include _PRIVATELIBS= \ atf_c \ atf_cxx \ bsdstat \ devdctl \ event \ heimipcc \ heimipcs \ ldns \ sqlite3 \ ssh \ ucl \ unbound _INTERNALLIBS= \ amu \ bsnmptools \ cron \ elftc \ fifolog \ ipf \ lpr \ netbsd \ ntp \ ntpevent \ openbsd \ opts \ parse \ pe \ readline \ sl \ sm \ smdb \ smutil \ telnet \ vers _LIBRARIES= \ ${_PRIVATELIBS} \ ${_INTERNALLIBS} \ ${LOCAL_LIBRARIES} \ 80211 \ alias \ archive \ asn1 \ auditd \ avl \ begemot \ bluetooth \ bsdxml \ bsm \ bsnmp \ bz2 \ c \ c_pic \ calendar \ cam \ casper \ cap_dns \ cap_grp \ cap_pwd \ cap_random \ cap_sysctl \ com_err \ compiler_rt \ crypt \ crypto \ ctf \ cuse \ cxxrt \ devctl \ devdctl \ devinfo \ devstat \ dialog \ dpv \ dtrace \ dwarf \ edit \ elf \ execinfo \ fetch \ figpar \ geom \ gnuregex \ gpio \ gssapi \ gssapi_krb5 \ hdb \ heimbase \ heimntlm \ heimsqlite \ hx509 \ - ifc \ + ifconfig \ ipsec \ jail \ kadm5clnt \ kadm5srv \ kafs5 \ kdc \ kiconv \ krb5 \ kvm \ l \ lzma \ m \ magic \ md \ memstat \ mp \ mt \ nandfs \ ncurses \ ncursesw \ netgraph \ ngatm \ nv \ nvpair \ opie \ pam \ panel \ panelw \ pcap \ pcsclite \ pjdlog \ pmc \ proc \ procstat \ pthread \ radius \ readline \ roken \ rpcsec_gss \ rpcsvc \ rt \ rtld_db \ sbuf \ sdp \ sm \ smb \ ssl \ ssp_nonshared \ stdthreads \ supcplusplus \ sysdecode \ tacplus \ termcap \ termcapw \ ufs \ ugidfw \ ulog \ umem \ usb \ usbhid \ util \ uutil \ vmmapi \ wind \ wrap \ xo \ y \ ypclnt \ z \ zfs_core \ zfs \ zpool \ .if ${MK_BLACKLIST} != "no" _LIBRARIES+= \ blacklist \ .endif .if ${MK_OFED} != "no" _LIBRARIES+= \ cxgb4 \ ibcm \ ibcommon \ ibmad \ ibsdp \ ibumad \ ibverbs \ mlx4 \ mthca \ opensm \ osmcomp \ osmvendor \ rdmacm \ .endif # Each library's LIBADD needs to be duplicated here for static linkage of # 2nd+ order consumers. Auto-generating this would be better. _DP_80211= sbuf bsdxml _DP_archive= z bz2 lzma bsdxml .if ${MK_BLACKLIST} != "no" _DP_blacklist+= pthread .endif .if ${MK_OPENSSL} != "no" _DP_archive+= crypto .else _DP_archive+= md .endif _DP_sqlite3= pthread _DP_ssl= crypto _DP_ssh= crypto crypt z .if ${MK_LDNS} != "no" _DP_ssh+= ldns .endif _DP_edit= ncursesw .if ${MK_OPENSSL} != "no" _DP_bsnmp= crypto .endif _DP_geom= bsdxml sbuf _DP_cam= sbuf _DP_kvm= elf _DP_casper= nv _DP_cap_dns= nv _DP_cap_grp= nv _DP_cap_pwd= nv _DP_cap_random= nv _DP_cap_sysctl= nv _DP_pjdlog= util _DP_opie= md _DP_usb= pthread _DP_unbound= ssl crypto pthread _DP_rt= pthread .if ${MK_OPENSSL} == "no" _DP_radius= md .else _DP_radius= crypto .endif _DP_rtld_db= elf procstat _DP_procstat= kvm util elf .if ${MK_CXX} == "yes" .if ${MK_LIBCPLUSPLUS} != "no" _DP_proc= cxxrt .else _DP_proc= supcplusplus .endif .endif .if ${MK_CDDL} != "no" _DP_proc+= ctf .endif _DP_proc+= elf procstat rtld_db util _DP_mp= crypto _DP_memstat= kvm _DP_magic= z _DP_mt= sbuf bsdxml _DP_ldns= crypto .if ${MK_OPENSSL} != "no" _DP_fetch= ssl crypto .else _DP_fetch= md .endif _DP_execinfo= elf _DP_dwarf= elf _DP_dpv= dialog figpar util ncursesw _DP_dialog= ncursesw m _DP_cuse= pthread _DP_atf_cxx= atf_c _DP_devstat= kvm _DP_pam= radius tacplus opie md util .if ${MK_KERBEROS} != "no" _DP_pam+= krb5 .endif .if ${MK_OPENSSH} != "no" _DP_pam+= ssh .endif .if ${MK_NIS} != "no" _DP_pam+= ypclnt .endif _DP_readline= ncursesw _DP_roken= crypt _DP_kadm5clnt= com_err krb5 roken _DP_kadm5srv= com_err hdb krb5 roken _DP_heimntlm= crypto com_err krb5 roken _DP_hx509= asn1 com_err crypto roken wind _DP_hdb= asn1 com_err krb5 roken sqlite3 _DP_asn1= com_err roken _DP_kdc= roken hdb hx509 krb5 heimntlm asn1 crypto _DP_wind= com_err roken _DP_heimbase= pthread _DP_heimipcc= heimbase roken pthread _DP_heimipcs= heimbase roken pthread _DP_kafs5= asn1 krb5 roken _DP_krb5+= asn1 com_err crypt crypto hx509 roken wind heimbase heimipcc _DP_gssapi_krb5+= gssapi krb5 crypto roken asn1 com_err _DP_lzma= pthread _DP_ucl= m _DP_vmmapi= util _DP_ctf= z _DP_dtrace= ctf elf proc pthread rtld_db _DP_xo= util # The libc dependencies are not strictly needed but are defined to make the # assert happy. _DP_c= compiler_rt .if ${MK_SSP} != "no" _DP_c+= ssp_nonshared .endif _DP_stdthreads= pthread _DP_tacplus= md _DP_panel= ncurses _DP_panelw= ncursesw _DP_rpcsec_gss= gssapi _DP_smb= kiconv _DP_ulog= md _DP_fifolog= z _DP_ipf= kvm _DP_zfs= md pthread umem util uutil m nvpair avl bsdxml geom nvpair z \ zfs_core _DP_zfs_core= nvpair _DP_zpool= md pthread z nvpair avl umem .if ${MK_OFED} != "no" _DP_cxgb4= ibverbs pthread _DP_ibcm= ibverbs _DP_ibmad= ibcommon ibumad _DP_ibumad= ibcommon _DP_mlx4= ibverbs pthread _DP_mthca= ibverbs pthread _DP_opensm= pthread _DP_osmcomp= pthread _DP_osmvendor= ibumad opensm osmcomp pthread _DP_rdmacm= ibverbs .endif # Define special cases LDADD_supcplusplus= -lsupc++ LIBATF_C= ${DESTDIR}${LIBDIR}/libprivateatf-c.a LIBATF_CXX= ${DESTDIR}${LIBDIR}/libprivateatf-c++.a LDADD_atf_c= -lprivateatf-c LDADD_atf_cxx= -lprivateatf-c++ .for _l in ${_PRIVATELIBS} LIB${_l:tu}?= ${DESTDIR}${LIBDIR}/libprivate${_l}.a .endfor .for _l in ${_LIBRARIES} .if ${_INTERNALLIBS:M${_l}} LDADD_${_l}_L+= -L${LIB${_l:tu}DIR} .endif DPADD_${_l}?= ${LIB${_l:tu}} .if ${_PRIVATELIBS:M${_l}} LDADD_${_l}?= -lprivate${_l} .else LDADD_${_l}?= ${LDADD_${_l}_L} -l${_l} .endif # Add in all dependencies for static linkage. .if defined(_DP_${_l}) && (${_INTERNALLIBS:M${_l}} || \ (defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO"))) .for _d in ${_DP_${_l}} DPADD_${_l}+= ${DPADD_${_d}} LDADD_${_l}+= ${LDADD_${_d}} .endfor .endif .endfor # These are special cases where the library is broken and anything that uses # it needs to add more dependencies. Broken usually means that it has a # cyclic dependency and cannot link its own dependencies. This is bad, please # fix the library instead. # Unless the library itself is broken then the proper place to define # dependencies is _DP_* above. # libatf-c++ exposes libatf-c abi hence we need to explicit link to atf_c for # atf_cxx DPADD_atf_cxx+= ${DPADD_atf_c} LDADD_atf_cxx+= ${LDADD_atf_c} # Detect LDADD/DPADD that should be LIBADD, before modifying LDADD here. _BADLDADD= .for _l in ${LDADD:M-l*:N-l*/*:C,^-l,,} .if ${_LIBRARIES:M${_l}} && !${_PRIVATELIBS:M${_l}} _BADLDADD+= ${_l} .endif .endfor .if !empty(_BADLDADD) .error ${.CURDIR}: These libraries should be LIBADD+=foo rather than DPADD/LDADD+=-lfoo: ${_BADLDADD} .endif .for _l in ${LIBADD} DPADD+= ${DPADD_${_l}} LDADD+= ${LDADD_${_l}} .endfor # INTERNALLIB definitions. LIBELFTCDIR= ${OBJTOP}/lib/libelftc LIBELFTC?= ${LIBELFTCDIR}/libelftc.a LIBPEDIR= ${OBJTOP}/lib/libpe LIBPE?= ${LIBPEDIR}/libpe.a LIBREADLINEDIR= ${OBJTOP}/gnu/lib/libreadline/readline LIBREADLINE?= ${LIBREADLINEDIR}/libreadline.a LIBOPENBSDDIR= ${OBJTOP}/lib/libopenbsd LIBOPENBSD?= ${LIBOPENBSDDIR}/libopenbsd.a LIBSMDIR= ${OBJTOP}/lib/libsm LIBSM?= ${LIBSMDIR}/libsm.a LIBSMDBDIR= ${OBJTOP}/lib/libsmdb LIBSMDB?= ${LIBSMDBDIR}/libsmdb.a LIBSMUTILDIR= ${OBJTOP}/lib/libsmutil LIBSMUTIL?= ${LIBSMDBDIR}/libsmutil.a LIBNETBSDDIR?= ${OBJTOP}/lib/libnetbsd LIBNETBSD?= ${LIBNETBSDDIR}/libnetbsd.a LIBVERSDIR?= ${OBJTOP}/kerberos5/lib/libvers LIBVERS?= ${LIBVERSDIR}/libvers.a LIBSLDIR= ${OBJTOP}/kerberos5/lib/libsl LIBSL?= ${LIBSLDIR}/libsl.a LIBIPFDIR= ${OBJTOP}/sbin/ipf/libipf LIBIPF?= ${LIBIPFDIR}/libipf.a LIBTELNETDIR= ${OBJTOP}/lib/libtelnet LIBTELNET?= ${LIBTELNETDIR}/libtelnet.a LIBCRONDIR= ${OBJTOP}/usr.sbin/cron/lib LIBCRON?= ${LIBCRONDIR}/libcron.a LIBNTPDIR= ${OBJTOP}/usr.sbin/ntp/libntp LIBNTP?= ${LIBNTPDIR}/libntp.a LIBNTPEVENTDIR= ${OBJTOP}/usr.sbin/ntp/libntpevent LIBNTPEVENT?= ${LIBNTPEVENTDIR}/libntpevent.a LIBOPTSDIR= ${OBJTOP}/usr.sbin/ntp/libopts LIBOPTS?= ${LIBOPTSDIR}/libopts.a LIBPARSEDIR= ${OBJTOP}/usr.sbin/ntp/libparse LIBPARSE?= ${LIBPARSEDIR}/libparse.a LIBLPRDIR= ${OBJTOP}/usr.sbin/lpr/common_source LIBLPR?= ${LIBOPTSDIR}/liblpr.a LIBFIFOLOGDIR= ${OBJTOP}/usr.sbin/fifolog/lib LIBFIFOLOG?= ${LIBOPTSDIR}/libfifolog.a LIBBSNMPTOOLSDIR= ${OBJTOP}/usr.sbin/bsnmpd/tools/libbsnmptools LIBBSNMPTOOLS?= ${LIBBSNMPTOOLSDIR}/libbsnmptools.a LIBAMUDIR= ${OBJTOP}/usr.sbin/amd/libamu LIBAMU?= ${LIBAMUDIR}/libamu/libamu.a # Define a directory for each library. This is useful for adding -L in when # not using a --sysroot or for meta mode bootstrapping when there is no # Makefile.depend. These are sorted by directory. LIBAVLDIR= ${OBJTOP}/cddl/lib/libavl LIBCTFDIR= ${OBJTOP}/cddl/lib/libctf LIBDTRACEDIR= ${OBJTOP}/cddl/lib/libdtrace LIBNVPAIRDIR= ${OBJTOP}/cddl/lib/libnvpair LIBUMEMDIR= ${OBJTOP}/cddl/lib/libumem LIBUUTILDIR= ${OBJTOP}/cddl/lib/libuutil LIBZFSDIR= ${OBJTOP}/cddl/lib/libzfs LIBZFS_COREDIR= ${OBJTOP}/cddl/lib/libzfs_core LIBZPOOLDIR= ${OBJTOP}/cddl/lib/libzpool LIBCXGB4DIR= ${OBJTOP}/contrib/ofed/usr.lib/libcxgb4 LIBIBCMDIR= ${OBJTOP}/contrib/ofed/usr.lib/libibcm LIBIBCOMMONDIR= ${OBJTOP}/contrib/ofed/usr.lib/libibcommon LIBIBMADDIR= ${OBJTOP}/contrib/ofed/usr.lib/libibmad LIBIBUMADDIR= ${OBJTOP}/contrib/ofed/usr.lib/libibumad LIBIBVERBSDIR= ${OBJTOP}/contrib/ofed/usr.lib/libibverbs LIBMLX4DIR= ${OBJTOP}/contrib/ofed/usr.lib/libmlx4 LIBMTHCADIR= ${OBJTOP}/contrib/ofed/usr.lib/libmthca LIBOPENSMDIR= ${OBJTOP}/contrib/ofed/usr.lib/libopensm LIBOSMCOMPDIR= ${OBJTOP}/contrib/ofed/usr.lib/libosmcomp LIBOSMVENDORDIR= ${OBJTOP}/contrib/ofed/usr.lib/libosmvendor LIBRDMACMDIR= ${OBJTOP}/contrib/ofed/usr.lib/librdmacm LIBIBSDPDIR= ${OBJTOP}/contrib/ofed/usr.lib/libsdp LIBDIALOGDIR= ${OBJTOP}/gnu/lib/libdialog LIBGCOVDIR= ${OBJTOP}/gnu/lib/libgcov LIBGOMPDIR= ${OBJTOP}/gnu/lib/libgomp LIBGNUREGEXDIR= ${OBJTOP}/gnu/lib/libregex LIBSSPDIR= ${OBJTOP}/gnu/lib/libssp LIBSSP_NONSHAREDDIR= ${OBJTOP}/gnu/lib/libssp/libssp_nonshared LIBSUPCPLUSPLUSDIR= ${OBJTOP}/gnu/lib/libsupc++ LIBASN1DIR= ${OBJTOP}/kerberos5/lib/libasn1 LIBGSSAPI_KRB5DIR= ${OBJTOP}/kerberos5/lib/libgssapi_krb5 LIBGSSAPI_NTLMDIR= ${OBJTOP}/kerberos5/lib/libgssapi_ntlm LIBGSSAPI_SPNEGODIR= ${OBJTOP}/kerberos5/lib/libgssapi_spnego LIBHDBDIR= ${OBJTOP}/kerberos5/lib/libhdb LIBHEIMBASEDIR= ${OBJTOP}/kerberos5/lib/libheimbase LIBHEIMIPCCDIR= ${OBJTOP}/kerberos5/lib/libheimipcc LIBHEIMIPCSDIR= ${OBJTOP}/kerberos5/lib/libheimipcs LIBHEIMNTLMDIR= ${OBJTOP}/kerberos5/lib/libheimntlm LIBHX509DIR= ${OBJTOP}/kerberos5/lib/libhx509 LIBKADM5CLNTDIR= ${OBJTOP}/kerberos5/lib/libkadm5clnt LIBKADM5SRVDIR= ${OBJTOP}/kerberos5/lib/libkadm5srv LIBKAFS5DIR= ${OBJTOP}/kerberos5/lib/libkafs5 LIBKDCDIR= ${OBJTOP}/kerberos5/lib/libkdc LIBKRB5DIR= ${OBJTOP}/kerberos5/lib/libkrb5 LIBROKENDIR= ${OBJTOP}/kerberos5/lib/libroken LIBWINDDIR= ${OBJTOP}/kerberos5/lib/libwind LIBATF_CDIR= ${OBJTOP}/lib/atf/libatf-c LIBATF_CXXDIR= ${OBJTOP}/lib/atf/libatf-c++ LIBALIASDIR= ${OBJTOP}/lib/libalias/libalias LIBBLACKLISTDIR= ${OBJTOP}/lib/libblacklist LIBBLOCKSRUNTIMEDIR= ${OBJTOP}/lib/libblocksruntime LIBBSNMPDIR= ${OBJTOP}/lib/libbsnmp/libbsnmp LIBCASPERDIR= ${OBJTOP}/lib/libcasper/libcasper LIBCAP_DNSDIR= ${OBJTOP}/lib/libcasper/services/cap_dns LIBCAP_GRPDIR= ${OBJTOP}/lib/libcasper/services/cap_grp LIBCAP_PWDDIR= ${OBJTOP}/lib/libcasper/services/cap_pwd LIBCAP_RANDOMDIR= ${OBJTOP}/lib/libcasper/services/cap_random LIBCAP_SYSCTLDIR= ${OBJTOP}/lib/libcasper/services/cap_sysctl LIBBSDXMLDIR= ${OBJTOP}/lib/libexpat LIBKVMDIR= ${OBJTOP}/lib/libkvm LIBPTHREADDIR= ${OBJTOP}/lib/libthr LIBMDIR= ${OBJTOP}/lib/msun LIBFORMDIR= ${OBJTOP}/lib/ncurses/form LIBFORMLIBWDIR= ${OBJTOP}/lib/ncurses/formw LIBMENUDIR= ${OBJTOP}/lib/ncurses/menu LIBMENULIBWDIR= ${OBJTOP}/lib/ncurses/menuw LIBNCURSESDIR= ${OBJTOP}/lib/ncurses/ncurses LIBNCURSESWDIR= ${OBJTOP}/lib/ncurses/ncursesw LIBPANELDIR= ${OBJTOP}/lib/ncurses/panel LIBPANELWDIR= ${OBJTOP}/lib/ncurses/panelw LIBCRYPTODIR= ${OBJTOP}/secure/lib/libcrypto LIBSSHDIR= ${OBJTOP}/secure/lib/libssh LIBSSLDIR= ${OBJTOP}/secure/lib/libssl LIBTEKENDIR= ${OBJTOP}/sys/teken/libteken LIBEGACYDIR= ${OBJTOP}/tools/build LIBLNDIR= ${OBJTOP}/usr.bin/lex/lib LIBTERMCAPDIR= ${LIBNCURSESDIR} LIBTERMCAPWDIR= ${LIBNCURSESWDIR} # Default other library directories to lib/libNAME. .for lib in ${_LIBRARIES} LIB${lib:tu}DIR?= ${OBJTOP}/lib/lib${lib} .endfor # Validate that listed LIBADD are valid. .for _l in ${LIBADD} .if empty(_LIBRARIES:M${_l}) _BADLIBADD+= ${_l} .endif .endfor .if !empty(_BADLIBADD) .error ${.CURDIR}: Invalid LIBADD used which may need to be added to ${_this:T}: ${_BADLIBADD} .endif # Sanity check that libraries are defined here properly when building them. .if defined(LIB) && ${_LIBRARIES:M${LIB}} != "" .if !empty(LIBADD) && \ (!defined(_DP_${LIB}) || ${LIBADD:O:u} != ${_DP_${LIB}:O:u}) .error ${.CURDIR}: Missing or incorrect _DP_${LIB} entry in ${_this:T}. Should match LIBADD for ${LIB} ('${LIBADD}' vs '${_DP_${LIB}}') .endif # Note that OBJTOP is not yet defined here but for the purpose of the check # it is fine as it resolves to the SRC directory. .if !defined(LIB${LIB:tu}DIR) || !exists(${SRCTOP}/${LIB${LIB:tu}DIR:S,^${OBJTOP}/,,}) .error ${.CURDIR}: Missing or incorrect value for LIB${LIB:tu}DIR in ${_this:T}: ${LIB${LIB:tu}DIR:S,^${OBJTOP}/,,} .endif .if ${_INTERNALLIBS:M${LIB}} != "" && !defined(LIB${LIB:tu}) .error ${.CURDIR}: Missing value for LIB${LIB:tu} in ${_this:T}. Likely should be: LIB${LIB:tu}?= $${LIB${LIB:tu}DIR}/lib${LIB}.a .endif .endif .endif # !target(____)