112016SGirish.Moodalbail@Sun.COM /* 212016SGirish.Moodalbail@Sun.COM * CDDL HEADER START 312016SGirish.Moodalbail@Sun.COM * 412016SGirish.Moodalbail@Sun.COM * The contents of this file are subject to the terms of the 512016SGirish.Moodalbail@Sun.COM * Common Development and Distribution License (the "License"). 612016SGirish.Moodalbail@Sun.COM * You may not use this file except in compliance with the License. 712016SGirish.Moodalbail@Sun.COM * 812016SGirish.Moodalbail@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 912016SGirish.Moodalbail@Sun.COM * or http://www.opensolaris.org/os/licensing. 1012016SGirish.Moodalbail@Sun.COM * See the License for the specific language governing permissions 1112016SGirish.Moodalbail@Sun.COM * and limitations under the License. 1212016SGirish.Moodalbail@Sun.COM * 1312016SGirish.Moodalbail@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 1412016SGirish.Moodalbail@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1512016SGirish.Moodalbail@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 1612016SGirish.Moodalbail@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 1712016SGirish.Moodalbail@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 1812016SGirish.Moodalbail@Sun.COM * 1912016SGirish.Moodalbail@Sun.COM * CDDL HEADER END 2012016SGirish.Moodalbail@Sun.COM */ 2112016SGirish.Moodalbail@Sun.COM /* 22*12805SDarren.Reed@Oracle.COM * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2312016SGirish.Moodalbail@Sun.COM */ 2412016SGirish.Moodalbail@Sun.COM #ifndef _IFADDRS_H 2512016SGirish.Moodalbail@Sun.COM #define _IFADDRS_H 2612016SGirish.Moodalbail@Sun.COM 2712016SGirish.Moodalbail@Sun.COM #ifdef __cplusplus 2812016SGirish.Moodalbail@Sun.COM extern "C" { 2912016SGirish.Moodalbail@Sun.COM #endif 3012016SGirish.Moodalbail@Sun.COM 3112016SGirish.Moodalbail@Sun.COM #include <sys/types.h> 3212016SGirish.Moodalbail@Sun.COM 3312016SGirish.Moodalbail@Sun.COM /* 3412016SGirish.Moodalbail@Sun.COM * The `getifaddrs' function generates a linked list of these structures. 3512016SGirish.Moodalbail@Sun.COM * Each element of the list describes one network interface. 3612016SGirish.Moodalbail@Sun.COM */ 3712016SGirish.Moodalbail@Sun.COM #if defined(_INT64_TYPE) 3812016SGirish.Moodalbail@Sun.COM struct ifaddrs { 3912016SGirish.Moodalbail@Sun.COM struct ifaddrs *ifa_next; /* Pointer to the next structure. */ 4012016SGirish.Moodalbail@Sun.COM char *ifa_name; /* Name of this network interface. */ 4112016SGirish.Moodalbail@Sun.COM uint64_t ifa_flags; /* Flags as from SIOCGLIFFLAGS ioctl. */ 42*12805SDarren.Reed@Oracle.COM struct sockaddr *ifa_addr; /* Network address of this interface. */ 43*12805SDarren.Reed@Oracle.COM struct sockaddr *ifa_netmask; /* Netmask of this interface. */ 4412016SGirish.Moodalbail@Sun.COM union { 4512016SGirish.Moodalbail@Sun.COM /* 4612016SGirish.Moodalbail@Sun.COM * At most one of the following two is valid. If the 4712016SGirish.Moodalbail@Sun.COM * IFF_BROADCAST bit is set in `ifa_flags', then 4812016SGirish.Moodalbail@Sun.COM * `ifa_broadaddr' is valid. If the IFF_POINTOPOINT bit is 4912016SGirish.Moodalbail@Sun.COM * set, then `ifa_dstaddr' is valid. It is never the case that 5012016SGirish.Moodalbail@Sun.COM * both these bits are set at once. 5112016SGirish.Moodalbail@Sun.COM */ 52*12805SDarren.Reed@Oracle.COM struct sockaddr *ifu_broadaddr; 53*12805SDarren.Reed@Oracle.COM struct sockaddr *ifu_dstaddr; 5412016SGirish.Moodalbail@Sun.COM } ifa_ifu; 5512016SGirish.Moodalbail@Sun.COM void *ifa_data; /* Address-specific data (may be unused). */ 5612016SGirish.Moodalbail@Sun.COM /* 5712016SGirish.Moodalbail@Sun.COM * This may have been defined in <net/if.h>. 5812016SGirish.Moodalbail@Sun.COM */ 5912016SGirish.Moodalbail@Sun.COM #ifndef ifa_broadaddr 6012016SGirish.Moodalbail@Sun.COM #define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */ 6112016SGirish.Moodalbail@Sun.COM #endif 6212016SGirish.Moodalbail@Sun.COM #ifndef ifa_dstaddr 6312016SGirish.Moodalbail@Sun.COM #define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of p-to-p link */ 6412016SGirish.Moodalbail@Sun.COM #endif 6512016SGirish.Moodalbail@Sun.COM }; 6612016SGirish.Moodalbail@Sun.COM #endif 6712016SGirish.Moodalbail@Sun.COM 6812016SGirish.Moodalbail@Sun.COM /* 6912016SGirish.Moodalbail@Sun.COM * Create a linked list of `struct ifaddrs' structures, one for each 7012016SGirish.Moodalbail@Sun.COM * network interface on the host machine. If successful, store the 7112016SGirish.Moodalbail@Sun.COM * list in *ifap and return 0. On errors, return -1 and set `errno'. 7212016SGirish.Moodalbail@Sun.COM * 7312016SGirish.Moodalbail@Sun.COM * The storage returned in *ifap is allocated dynamically and can 7412016SGirish.Moodalbail@Sun.COM * only be properly freed by passing it to `freeifaddrs'. 7512016SGirish.Moodalbail@Sun.COM */ 7612016SGirish.Moodalbail@Sun.COM extern int getifaddrs(struct ifaddrs **); 7712016SGirish.Moodalbail@Sun.COM 7812016SGirish.Moodalbail@Sun.COM /* Reclaim the storage allocated by a previous `getifaddrs' call. */ 7912016SGirish.Moodalbail@Sun.COM extern void freeifaddrs(struct ifaddrs *); 8012016SGirish.Moodalbail@Sun.COM 8112016SGirish.Moodalbail@Sun.COM 8212016SGirish.Moodalbail@Sun.COM #ifdef __cplusplus 8312016SGirish.Moodalbail@Sun.COM } 8412016SGirish.Moodalbail@Sun.COM #endif 8512016SGirish.Moodalbail@Sun.COM 8612016SGirish.Moodalbail@Sun.COM #endif /* _IFADDRS_H */ 87