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