xref: /titanic_50/usr/src/head/ifaddrs.h (revision 4558d122136f151d62acbbc02ddb42df89a5ef66)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 #ifndef _IFADDRS_H
26 #define	_IFADDRS_H
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 #include <sys/types.h>
33 
34 /*
35  * The `getifaddrs' function generates a linked list of these structures.
36  * Each element of the list describes one network interface.
37  */
38 #if defined(_INT64_TYPE)
39 struct ifaddrs {
40 	struct ifaddrs	*ifa_next;	/* Pointer to the next structure. */
41 	char		*ifa_name;	/* Name of this network interface. */
42 	uint64_t	ifa_flags;	/* Flags as from SIOCGLIFFLAGS ioctl. */
43 	struct sockaddr_storage	*ifa_addr;
44 					/* Network address of this interface. */
45 	struct sockaddr_storage	*ifa_netmask;
46 					/* Netmask of this interface. */
47 	union {
48 		/*
49 		 * At most one of the following two is valid.  If the
50 		 * IFF_BROADCAST bit is set in `ifa_flags', then
51 		 * `ifa_broadaddr' is valid.  If the IFF_POINTOPOINT bit is
52 		 * set, then `ifa_dstaddr' is valid. It is never the case that
53 		 * both these bits are set at once.
54 		 */
55 		struct sockaddr_storage	*ifu_broadaddr;
56 		struct sockaddr_storage	*ifu_dstaddr;
57 	} ifa_ifu;
58 	void		*ifa_data; /* Address-specific data (may be unused). */
59 /*
60  * This may have been defined in <net/if.h>.
61  */
62 #ifndef ifa_broadaddr
63 #define	ifa_broadaddr	ifa_ifu.ifu_broadaddr	/* broadcast address */
64 #endif
65 #ifndef ifa_dstaddr
66 #define	ifa_dstaddr	ifa_ifu.ifu_dstaddr	/* other end of p-to-p link */
67 #endif
68 };
69 #endif
70 
71 /*
72  * Create a linked list of `struct ifaddrs' structures, one for each
73  * network interface on the host machine.  If successful, store the
74  * list in *ifap and return 0.  On errors, return -1 and set `errno'.
75  *
76  * The storage returned in *ifap is allocated dynamically and can
77  * only be properly freed by passing it to `freeifaddrs'.
78  */
79 extern int getifaddrs(struct ifaddrs **);
80 
81 /* Reclaim the storage allocated by a previous `getifaddrs' call. */
82 extern void freeifaddrs(struct ifaddrs *);
83 
84 
85 #ifdef	__cplusplus
86 }
87 #endif
88 
89 #endif	/* _IFADDRS_H */
90