]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSPosix/mDNSUNP.h
mDNSResponder-58.8.1.tar.gz
[apple/mdnsresponder.git] / mDNSPosix / mDNSUNP.h
1 /*
2 * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22
23 Change History (most recent first):
24
25 $Log: mDNSUNP.h,v $
26 Revision 1.8 2003/08/12 19:56:26 cheshire
27 Update to APSL 2.0
28
29 Revision 1.7 2003/08/06 18:20:51 cheshire
30 Makefile cleanup
31
32 Revision 1.6 2003/07/02 21:19:59 cheshire
33 <rdar://problem/3313413> Update copyright notices, etc., in source code comments
34
35 Revision 1.5 2003/03/13 03:46:21 cheshire
36 Fixes to make the code build on Linux
37
38 Revision 1.4 2002/12/23 22:13:32 jgraessl
39
40 Reviewed by: Stuart Cheshire
41 Initial IPv6 support for mDNSResponder.
42
43 Revision 1.3 2002/09/21 20:44:53 zarzycki
44 Added APSL info
45
46 Revision 1.2 2002/09/19 04:20:44 cheshire
47 Remove high-ascii characters that confuse some systems
48
49 Revision 1.1 2002/09/17 06:24:35 cheshire
50 First checkin
51
52 */
53
54 #ifndef __mDNSUNP_h
55 #define __mDNSUNP_h
56
57 #include <sys/types.h>
58 #include <sys/socket.h>
59 #include <net/if.h>
60 #include <netinet/in.h>
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65
66 #ifdef NOT_HAVE_SOCKLEN_T
67 typedef unsigned int socklen_t;
68 #endif
69
70 #if !defined(_SS_MAXSIZE)
71 #define sockaddr_storage sockaddr
72 #endif
73
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 )
77 #elif mDNSIPv6Support
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))
80 #else
81 #define GET_SA_LEN(X) ((X).sa_family == AF_INET ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr))
82 #endif
83
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 */
86
87 // Renamed from my_in_pktinfo because in_pktinfo is used by Linux.
88
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 */
93 };
94
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);
97
98 struct ifi_info {
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 */
109 };
110
111 #define IFI_ALIAS 1 /* ifi_addr is an alias */
112
113 extern struct ifi_info *get_ifi_info(int family, int doaliases);
114 extern void free_ifi_info(struct ifi_info *);
115
116 #ifdef __cplusplus
117 }
118 #endif
119
120 #endif