2 * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 Change History (most recent first):
26 Revision 1.8 2003/08/12 19:56:26 cheshire
29 Revision 1.7 2003/08/06 18:20:51 cheshire
32 Revision 1.6 2003/07/02 21:19:59 cheshire
33 <rdar://problem/3313413> Update copyright notices, etc., in source code comments
35 Revision 1.5 2003/03/13 03:46:21 cheshire
36 Fixes to make the code build on Linux
38 Revision 1.4 2002/12/23 22:13:32 jgraessl
40 Reviewed by: Stuart Cheshire
41 Initial IPv6 support for mDNSResponder.
43 Revision 1.3 2002/09/21 20:44:53 zarzycki
46 Revision 1.2 2002/09/19 04:20:44 cheshire
47 Remove high-ascii characters that confuse some systems
49 Revision 1.1 2002/09/17 06:24:35 cheshire
57 #include <sys/types.h>
58 #include <sys/socket.h>
60 #include <netinet/in.h>
66 #ifdef NOT_HAVE_SOCKLEN_T
67 typedef unsigned int socklen_t
;
70 #if !defined(_SS_MAXSIZE)
71 #define sockaddr_storage sockaddr
74 #ifndef NOT_HAVE_SA_LEN
75 #define GET_SA_LEN(X) (sizeof(struct sockaddr) > ((struct sockaddr*)&(X))->sa_len ? \
76 sizeof(struct sockaddr) : ((struct sockaddr*)&(X))->sa_len )
78 #define GET_SA_LEN(X) (((struct sockaddr*)&(X))->sa_family == AF_INET ? sizeof(struct sockaddr_in) : \
79 ((struct sockaddr*)&(X))->sa_family == AF_INET6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr))
81 #define GET_SA_LEN(X) ((X).sa_family == AF_INET ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr))
84 #define IFI_NAME 16 /* same as IFNAMSIZ in <net/if.h> */
85 #define IFI_HADDR 8 /* allow for 64-bit EUI-64 in future */
87 // Renamed from my_in_pktinfo because in_pktinfo is used by Linux.
89 struct my_in_pktinfo
{
90 struct sockaddr_storage ipi_addr
;
91 int ipi_ifindex
; /* received interface index */
92 char ipi_ifname
[IFI_NAME
]; /* received interface name */
95 extern ssize_t
recvfrom_flags(int fd
, void *ptr
, size_t nbytes
, int *flagsp
,
96 struct sockaddr
*sa
, socklen_t
*salenptr
, struct my_in_pktinfo
*pktp
);
99 char ifi_name
[IFI_NAME
]; /* interface name, null terminated */
100 u_char ifi_haddr
[IFI_HADDR
]; /* hardware address */
101 u_short ifi_hlen
; /* #bytes in hardware address: 0, 6, 8 */
102 short ifi_flags
; /* IFF_xxx constants from <net/if.h> */
103 short ifi_myflags
; /* our own IFI_xxx flags */
104 int ifi_index
; /* interface index */
105 struct sockaddr
*ifi_addr
; /* primary address */
106 struct sockaddr
*ifi_brdaddr
;/* broadcast address */
107 struct sockaddr
*ifi_dstaddr
;/* destination address */
108 struct ifi_info
*ifi_next
; /* next of these structures */
111 #define IFI_ALIAS 1 /* ifi_addr is an alias */
113 extern struct ifi_info
*get_ifi_info(int family
, int doaliases
);
114 extern void free_ifi_info(struct ifi_info
*);