2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A * Create a linked list of `struct ifaddrs' structures, one for each 2N/A * address that is UP. If successful, store the list in *ifap and 2N/A * return 0. On errors, return -1 and set `errno'. 2N/A * The storage returned in *ifap is allocated dynamically and can 2N/A * only be properly freed by passing it to `freeifaddrs'. 2N/A * Returns all addresses configured on the system. If `IA_UP_ADDRS_ONLY' 2N/A * is set in `ia_flags', only the addresses that are IFF_UP are returned. 2N/A * Address list that is returned by this function must be freed 2N/A * using freeifaddrs(). 2N/A /* Get all interfaces from SIOCGLIFCONF */ 2N/A * Loop through the interfaces obtained from SIOCGLIFCOMF 2N/A * and retrieve the addresses, netmask and flags. 2N/A /* Prepare for the ioctl call */ 2N/A * Allocate the current list node. Each node contains data 2N/A * for one ifaddrs structure. 2N/A /* First node in the linked list */ 2N/A /* Get the netmask */ 2N/A /* Get the destination for a pt-pt interface */ 2N/A * Do a SIOCGLIFCONF and store all the interfaces in `buf'. 2N/A * When calculating the buffer size needed, add a small number 2N/A * of interfaces to those we counted. We do this to capture 2N/A * the interface status of potential interfaces which may have 2N/A * been plumbed between the SIOCGLIFNUM and the SIOCGLIFCONF. 2N/A * If every entry was filled, there are probably 2N/A * more interfaces than (lifn.lifn_count + 4). 2N/A * Redo the ioctls SIOCGLIFNUM and SIOCGLIFCONF to 2N/A * get all the interfaces.