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