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 /* 2264639aafSDarren Reed * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 23*3ee59242SSebastian Wiedenroth * Copyright 2022 Sebastian Wiedenroth 246e91bba0SGirish Moodalbail */ 256e91bba0SGirish Moodalbail #ifndef _IFADDRS_H 266e91bba0SGirish Moodalbail #define _IFADDRS_H 276e91bba0SGirish Moodalbail 286e91bba0SGirish Moodalbail #ifdef __cplusplus 296e91bba0SGirish Moodalbail extern "C" { 306e91bba0SGirish Moodalbail #endif 316e91bba0SGirish Moodalbail 326e91bba0SGirish Moodalbail #include <sys/types.h> 336e91bba0SGirish Moodalbail 346e91bba0SGirish Moodalbail /* 356e91bba0SGirish Moodalbail * The `getifaddrs' function generates a linked list of these structures. 366e91bba0SGirish Moodalbail * Each element of the list describes one network interface. 376e91bba0SGirish Moodalbail */ 386e91bba0SGirish Moodalbail #if defined(_INT64_TYPE) 396e91bba0SGirish Moodalbail struct ifaddrs { 406e91bba0SGirish Moodalbail struct ifaddrs *ifa_next; /* Pointer to the next structure. */ 416e91bba0SGirish Moodalbail char *ifa_name; /* Name of this network interface. */ 426e91bba0SGirish Moodalbail uint64_t ifa_flags; /* Flags as from SIOCGLIFFLAGS ioctl. */ 4364639aafSDarren Reed struct sockaddr *ifa_addr; /* Network address of this interface. */ 4464639aafSDarren Reed struct sockaddr *ifa_netmask; /* Netmask of this interface. */ 456e91bba0SGirish Moodalbail union { 466e91bba0SGirish Moodalbail /* 476e91bba0SGirish Moodalbail * At most one of the following two is valid. If the 486e91bba0SGirish Moodalbail * IFF_BROADCAST bit is set in `ifa_flags', then 496e91bba0SGirish Moodalbail * `ifa_broadaddr' is valid. If the IFF_POINTOPOINT bit is 506e91bba0SGirish Moodalbail * set, then `ifa_dstaddr' is valid. It is never the case that 516e91bba0SGirish Moodalbail * both these bits are set at once. 526e91bba0SGirish Moodalbail */ 5364639aafSDarren Reed struct sockaddr *ifu_broadaddr; 5464639aafSDarren Reed struct sockaddr *ifu_dstaddr; 556e91bba0SGirish Moodalbail } ifa_ifu; 566e91bba0SGirish Moodalbail void *ifa_data; /* Address-specific data (may be unused). */ 576e91bba0SGirish Moodalbail /* 586e91bba0SGirish Moodalbail * This may have been defined in <net/if.h>. 596e91bba0SGirish Moodalbail */ 606e91bba0SGirish Moodalbail #ifndef ifa_broadaddr 616e91bba0SGirish Moodalbail #define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */ 626e91bba0SGirish Moodalbail #endif 636e91bba0SGirish Moodalbail #ifndef ifa_dstaddr 646e91bba0SGirish Moodalbail #define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of p-to-p link */ 656e91bba0SGirish Moodalbail #endif 666e91bba0SGirish Moodalbail }; 676e91bba0SGirish Moodalbail #endif 686e91bba0SGirish Moodalbail 69*3ee59242SSebastian Wiedenroth #ifdef __PRAGMA_REDEFINE_EXTNAME 70*3ee59242SSebastian Wiedenroth #pragma redefine_extname getifaddrs __getifaddrs 71*3ee59242SSebastian Wiedenroth #else 72*3ee59242SSebastian Wiedenroth extern int __getifaddrs(struct ifaddrs **); 73*3ee59242SSebastian Wiedenroth #define getifaddrs __getifaddrs 74*3ee59242SSebastian Wiedenroth #endif 75*3ee59242SSebastian Wiedenroth 766e91bba0SGirish Moodalbail /* 776e91bba0SGirish Moodalbail * Create a linked list of `struct ifaddrs' structures, one for each 786e91bba0SGirish Moodalbail * network interface on the host machine. If successful, store the 796e91bba0SGirish Moodalbail * list in *ifap and return 0. On errors, return -1 and set `errno'. 806e91bba0SGirish Moodalbail * 816e91bba0SGirish Moodalbail * The storage returned in *ifap is allocated dynamically and can 826e91bba0SGirish Moodalbail * only be properly freed by passing it to `freeifaddrs'. 836e91bba0SGirish Moodalbail */ 846e91bba0SGirish Moodalbail extern int getifaddrs(struct ifaddrs **); 856e91bba0SGirish Moodalbail 866e91bba0SGirish Moodalbail /* Reclaim the storage allocated by a previous `getifaddrs' call. */ 876e91bba0SGirish Moodalbail extern void freeifaddrs(struct ifaddrs *); 886e91bba0SGirish Moodalbail 896e91bba0SGirish Moodalbail 906e91bba0SGirish Moodalbail #ifdef __cplusplus 916e91bba0SGirish Moodalbail } 926e91bba0SGirish Moodalbail #endif 936e91bba0SGirish Moodalbail 946e91bba0SGirish Moodalbail #endif /* _IFADDRS_H */ 95