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