]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSPosix/mDNSPosix.h
mDNSResponder-107.1.tar.gz
[apple/mdnsresponder.git] / mDNSPosix / mDNSPosix.h
1 /* -*- Mode: C; tab-width: 4 -*-
2 *
3 * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23
24 Change History (most recent first):
25
26 $Log: mDNSPosix.h,v $
27 Revision 1.17 2005/02/04 00:39:59 cheshire
28 Move ParseDNSServers() from PosixDaemon.c to mDNSPosix.c so all Posix client layers can use it
29
30 Revision 1.16 2004/11/30 22:37:01 cheshire
31 Update copyright dates and add "Mode: C; tab-width: 4" headers
32
33 Revision 1.15 2004/02/06 01:19:51 cheshire
34 Conditionally exclude IPv6 code unless HAVE_IPV6 is set
35
36 Revision 1.14 2004/01/28 21:12:15 cheshire
37 Reconcile mDNSIPv6Support & HAVE_IPV6 into a single flag (HAVE_IPV6)
38
39 Revision 1.13 2004/01/24 05:12:03 cheshire
40 <rdar://problem/3534352>: Need separate socket for issuing unicast queries
41
42 Revision 1.12 2004/01/23 21:37:08 cheshire
43 For consistency, rename multicastSocket to multicastSocket4, and multicastSocketv6 to multicastSocket6
44
45 Revision 1.11 2003/12/11 03:03:51 rpantos
46 Clean up mDNSPosix so that it builds on OS X again.
47
48 Revision 1.10 2003/12/08 20:47:02 rpantos
49 Add support for mDNSResponder on Linux.
50
51 Revision 1.9 2003/10/30 19:25:19 cheshire
52 Fix warning on certain compilers
53
54 Revision 1.8 2003/08/12 19:56:26 cheshire
55 Update to APSL 2.0
56
57 Revision 1.7 2003/07/02 21:19:59 cheshire
58 <rdar://problem/3313413> Update copyright notices, etc., in source code comments
59
60 Revision 1.6 2003/03/13 03:46:21 cheshire
61 Fixes to make the code build on Linux
62
63 Revision 1.5 2003/03/08 00:35:56 cheshire
64 Switched to using new "mDNS_Execute" model (see "mDNSCore/Implementer Notes.txt")
65
66 Revision 1.4 2002/12/23 22:13:31 jgraessl
67
68 Reviewed by: Stuart Cheshire
69 Initial IPv6 support for mDNSResponder.
70
71 Revision 1.3 2002/09/21 20:44:53 zarzycki
72 Added APSL info
73
74 Revision 1.2 2002/09/19 04:20:44 cheshire
75 Remove high-ascii characters that confuse some systems
76
77 Revision 1.1 2002/09/17 06:24:34 cheshire
78 First checkin
79
80 */
81
82 #ifndef __mDNSPlatformPosix_h
83 #define __mDNSPlatformPosix_h
84
85 #include <signal.h>
86 #include <sys/time.h>
87
88 #ifdef __cplusplus
89 extern "C" {
90 #endif
91
92 // PosixNetworkInterface is a record extension of the core NetworkInterfaceInfo
93 // type that supports extra fields needed by the Posix platform.
94 //
95 // IMPORTANT: coreIntf must be the first field in the structure because
96 // we cast between pointers to the two different types regularly.
97
98 typedef struct PosixNetworkInterface PosixNetworkInterface;
99
100 struct PosixNetworkInterface
101 {
102 NetworkInterfaceInfo coreIntf;
103 const char * intfName;
104 PosixNetworkInterface * aliasIntf;
105 int index;
106 int multicastSocket4;
107 #if HAVE_IPV6
108 int multicastSocket6;
109 #endif
110 };
111
112 // This is a global because debugf_() needs to be able to check its value
113 extern int gMDNSPlatformPosixVerboseLevel;
114
115 struct mDNS_PlatformSupport_struct
116 {
117 int unicastSocket4;
118 #if HAVE_IPV6
119 int unicastSocket6;
120 #endif
121 };
122
123 #define uDNS_SERVERS_FILE "/etc/resolv.conf"
124 extern int ParseDNSServers(mDNS *m, const char *filePath);
125 extern mStatus mDNSPlatformPosixRefreshInterfaceList(mDNS *const m);
126 // See comment in implementation.
127
128 // Call mDNSPosixGetFDSet before calling select(), to update the parameters
129 // as may be necessary to meet the needs of the mDNSCore code.
130 // The timeout pointer MUST NOT be NULL.
131 // Set timeout->tv_sec to 0x3FFFFFFF if you want to have effectively no timeout
132 // After calling mDNSPosixGetFDSet(), call select(nfds, &readfds, NULL, NULL, &timeout); as usual
133 // After select() returns, call mDNSPosixProcessFDSet() to let mDNSCore do its work
134 extern void mDNSPosixGetFDSet(mDNS *m, int *nfds, fd_set *readfds, struct timeval *timeout);
135 extern void mDNSPosixProcessFDSet(mDNS *const m, fd_set *readfds);
136
137 typedef void (*mDNSPosixEventCallback)( void *context);
138
139 extern mStatus mDNSPosixAddFDToEventLoop( int fd, mDNSPosixEventCallback callback, void *context);
140 extern mStatus mDNSPosixRemoveFDFromEventLoop( int fd);
141 extern mStatus mDNSPosixListenForSignalInEventLoop( int signum);
142 extern mStatus mDNSPosixIgnoreSignalInEventLoop( int signum);
143 extern mStatus mDNSPosixRunEventLoopOnce( mDNS *m, const struct timeval *pTimeout, sigset_t *pSignalsReceived, mDNSBool *pDataDispatched);
144
145 #ifdef __cplusplus
146 }
147 #endif
148
149 #endif