16e91bba0SGirish Moodalbail /* 26e91bba0SGirish Moodalbail * CDDL HEADER START 36e91bba0SGirish Moodalbail * 46e91bba0SGirish Moodalbail * The contents of this file are subject to the terms of the 56e91bba0SGirish Moodalbail * Common Development and Distribution License (the "License"). 66e91bba0SGirish Moodalbail * You may not use this file except in compliance with the License. 76e91bba0SGirish Moodalbail * 86e91bba0SGirish Moodalbail * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 96e91bba0SGirish Moodalbail * or http://www.opensolaris.org/os/licensing. 106e91bba0SGirish Moodalbail * See the License for the specific language governing permissions 116e91bba0SGirish Moodalbail * and limitations under the License. 126e91bba0SGirish Moodalbail * 136e91bba0SGirish Moodalbail * When distributing Covered Code, include this CDDL HEADER in each 146e91bba0SGirish Moodalbail * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 156e91bba0SGirish Moodalbail * If applicable, add the following below this CDDL HEADER, with the 166e91bba0SGirish Moodalbail * fields enclosed by brackets "[]" replaced with your own identifying 176e91bba0SGirish Moodalbail * information: Portions Copyright [yyyy] [name of copyright owner] 186e91bba0SGirish Moodalbail * 196e91bba0SGirish Moodalbail * CDDL HEADER END 206e91bba0SGirish Moodalbail */ 216e91bba0SGirish Moodalbail /* 22*64639aafSDarren Reed * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 236e91bba0SGirish Moodalbail */ 246e91bba0SGirish Moodalbail #ifndef _IFADDRS_H 256e91bba0SGirish Moodalbail #define _IFADDRS_H 266e91bba0SGirish Moodalbail 276e91bba0SGirish Moodalbail #ifdef __cplusplus 286e91bba0SGirish Moodalbail extern "C" { 296e91bba0SGirish Moodalbail #endif 306e91bba0SGirish Moodalbail 316e91bba0SGirish Moodalbail #include <sys/types.h> 326e91bba0SGirish Moodalbail 336e91bba0SGirish Moodalbail /* 346e91bba0SGirish Moodalbail * The `getifaddrs' function generates a linked list of these structures. 356e91bba0SGirish Moodalbail * Each element of the list describes one network interface. 366e91bba0SGirish Moodalbail */ 376e91bba0SGirish Moodalbail #if defined(_INT64_TYPE) 386e91bba0SGirish Moodalbail struct ifaddrs { 396e91bba0SGirish Moodalbail struct ifaddrs *ifa_next; /* Pointer to the next structure. */ 406e91bba0SGirish Moodalbail char *ifa_name; /* Name of this network interface. */ 416e91bba0SGirish Moodalbail uint64_t ifa_flags; /* Flags as from SIOCGLIFFLAGS ioctl. */ 42*64639aafSDarren Reed struct sockaddr *ifa_addr; /* Network address of this interface. */ 43*64639aafSDarren Reed struct sockaddr *ifa_netmask; /* Netmask of this interface. */ 446e91bba0SGirish Moodalbail union { 456e91bba0SGirish Moodalbail /* 466e91bba0SGirish Moodalbail * At most one of the following two is valid. If the 476e91bba0SGirish Moodalbail * IFF_BROADCAST bit is set in `ifa_flags', then 486e91bba0SGirish Moodalbail * `ifa_broadaddr' is valid. If the IFF_POINTOPOINT bit is 496e91bba0SGirish Moodalbail * set, then `ifa_dstaddr' is valid. It is never the case that 506e91bba0SGirish Moodalbail * both these bits are set at once. 516e91bba0SGirish Moodalbail */ 52*64639aafSDarren Reed struct sockaddr *ifu_broadaddr; 53*64639aafSDarren Reed struct sockaddr *ifu_dstaddr; 546e91bba0SGirish Moodalbail } ifa_ifu; 556e91bba0SGirish Moodalbail void *ifa_data; /* Address-specific data (may be unused). */ 566e91bba0SGirish Moodalbail /* 576e91bba0SGirish Moodalbail * This may have been defined in <net/if.h>. 586e91bba0SGirish Moodalbail */ 596e91bba0SGirish Moodalbail #ifndef ifa_broadaddr 606e91bba0SGirish Moodalbail #define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */ 616e91bba0SGirish Moodalbail #endif 626e91bba0SGirish Moodalbail #ifndef ifa_dstaddr 636e91bba0SGirish Moodalbail #define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of p-to-p link */ 646e91bba0SGirish Moodalbail #endif 656e91bba0SGirish Moodalbail }; 666e91bba0SGirish Moodalbail #endif 676e91bba0SGirish Moodalbail 686e91bba0SGirish Moodalbail /* 696e91bba0SGirish Moodalbail * Create a linked list of `struct ifaddrs' structures, one for each 706e91bba0SGirish Moodalbail * network interface on the host machine. If successful, store the 716e91bba0SGirish Moodalbail * list in *ifap and return 0. On errors, return -1 and set `errno'. 726e91bba0SGirish Moodalbail * 736e91bba0SGirish Moodalbail * The storage returned in *ifap is allocated dynamically and can 746e91bba0SGirish Moodalbail * only be properly freed by passing it to `freeifaddrs'. 756e91bba0SGirish Moodalbail */ 766e91bba0SGirish Moodalbail extern int getifaddrs(struct ifaddrs **); 776e91bba0SGirish Moodalbail 786e91bba0SGirish Moodalbail /* Reclaim the storage allocated by a previous `getifaddrs' call. */ 796e91bba0SGirish Moodalbail extern void freeifaddrs(struct ifaddrs *); 806e91bba0SGirish Moodalbail 816e91bba0SGirish Moodalbail 826e91bba0SGirish Moodalbail #ifdef __cplusplus 836e91bba0SGirish Moodalbail } 846e91bba0SGirish Moodalbail #endif 856e91bba0SGirish Moodalbail 866e91bba0SGirish Moodalbail #endif /* _IFADDRS_H */ 87