xref: /titanic_51/usr/src/cmd/cmd-inet/usr.lib/mdnsd/mDNSPosix.h (revision 5ffb0c9b03b5149ff4f5821a62be4a52408ada2a)
14b22b933Srs200217 /* -*- Mode: C; tab-width: 4 -*-
24b22b933Srs200217  *
34b22b933Srs200217  * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
44b22b933Srs200217  *
54b22b933Srs200217  * Licensed under the Apache License, Version 2.0 (the "License");
64b22b933Srs200217  * you may not use this file except in compliance with the License.
74b22b933Srs200217  * You may obtain a copy of the License at
84b22b933Srs200217  *
94b22b933Srs200217  *     http://www.apache.org/licenses/LICENSE-2.0
104b22b933Srs200217  *
114b22b933Srs200217  * Unless required by applicable law or agreed to in writing, software
124b22b933Srs200217  * distributed under the License is distributed on an "AS IS" BASIS,
134b22b933Srs200217  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
144b22b933Srs200217  * See the License for the specific language governing permissions and
154b22b933Srs200217  * limitations under the License.
164b22b933Srs200217  */
174b22b933Srs200217 
184b22b933Srs200217 #ifndef __mDNSPlatformPosix_h
194b22b933Srs200217 #define __mDNSPlatformPosix_h
204b22b933Srs200217 
214b22b933Srs200217 #include <signal.h>
224b22b933Srs200217 #include <sys/time.h>
234b22b933Srs200217 
244b22b933Srs200217 #ifdef  __cplusplus
254b22b933Srs200217 extern "C" {
264b22b933Srs200217 #endif
274b22b933Srs200217 
284b22b933Srs200217 // PosixNetworkInterface is a record extension of the core NetworkInterfaceInfo
294b22b933Srs200217 // type that supports extra fields needed by the Posix platform.
304b22b933Srs200217 //
314b22b933Srs200217 // IMPORTANT: coreIntf must be the first field in the structure because
324b22b933Srs200217 // we cast between pointers to the two different types regularly.
334b22b933Srs200217 
344b22b933Srs200217 typedef struct PosixNetworkInterface PosixNetworkInterface;
354b22b933Srs200217 
364b22b933Srs200217 struct PosixNetworkInterface
374b22b933Srs200217 {
38*5ffb0c9bSToomas Soome     NetworkInterfaceInfo coreIntf;		// MUST be the first element in this structure
39*5ffb0c9bSToomas Soome     mDNSs32 LastSeen;
404b22b933Srs200217     const char *            intfName;
414b22b933Srs200217     PosixNetworkInterface * aliasIntf;
424b22b933Srs200217     int index;
434b22b933Srs200217     int multicastSocket4;
444b22b933Srs200217 #if HAVE_IPV6
454b22b933Srs200217     int multicastSocket6;
464b22b933Srs200217 #endif
474b22b933Srs200217 };
484b22b933Srs200217 
494b22b933Srs200217 // This is a global because debugf_() needs to be able to check its value
504b22b933Srs200217 extern int gMDNSPlatformPosixVerboseLevel;
514b22b933Srs200217 
524b22b933Srs200217 struct mDNS_PlatformSupport_struct
534b22b933Srs200217 {
544b22b933Srs200217     int unicastSocket4;
554b22b933Srs200217 #if HAVE_IPV6
564b22b933Srs200217     int unicastSocket6;
574b22b933Srs200217 #endif
584b22b933Srs200217 };
594b22b933Srs200217 
604b22b933Srs200217 #define uDNS_SERVERS_FILE "/etc/resolv.conf"
614b22b933Srs200217 extern int ParseDNSServers(mDNS *m, const char *filePath);
624b22b933Srs200217 extern mStatus mDNSPlatformPosixRefreshInterfaceList(mDNS *const m);
634b22b933Srs200217 // See comment in implementation.
644b22b933Srs200217 
654b22b933Srs200217 // Call mDNSPosixGetFDSet before calling select(), to update the parameters
664b22b933Srs200217 // as may be necessary to meet the needs of the mDNSCore code.
674b22b933Srs200217 // The timeout pointer MUST NOT be NULL.
684b22b933Srs200217 // Set timeout->tv_sec to 0x3FFFFFFF if you want to have effectively no timeout
694b22b933Srs200217 // After calling mDNSPosixGetFDSet(), call select(nfds, &readfds, NULL, NULL, &timeout); as usual
704b22b933Srs200217 // After select() returns, call mDNSPosixProcessFDSet() to let mDNSCore do its work
714b22b933Srs200217 extern void mDNSPosixGetFDSet(mDNS *m, int *nfds, fd_set *readfds, struct timeval *timeout);
724b22b933Srs200217 extern void mDNSPosixProcessFDSet(mDNS *const m, fd_set *readfds);
734b22b933Srs200217 
74*5ffb0c9bSToomas Soome typedef void (*mDNSPosixEventCallback)(int fd, short filter, void *context);
754b22b933Srs200217 
764b22b933Srs200217 extern mStatus mDNSPosixAddFDToEventLoop( int fd, mDNSPosixEventCallback callback, void *context);
774b22b933Srs200217 extern mStatus mDNSPosixRemoveFDFromEventLoop( int fd);
784b22b933Srs200217 extern mStatus mDNSPosixListenForSignalInEventLoop( int signum);
794b22b933Srs200217 extern mStatus mDNSPosixIgnoreSignalInEventLoop( int signum);
804b22b933Srs200217 extern mStatus mDNSPosixRunEventLoopOnce( mDNS *m, const struct timeval *pTimeout, sigset_t *pSignalsReceived, mDNSBool *pDataDispatched);
814b22b933Srs200217 
824b22b933Srs200217 #ifdef  __cplusplus
834b22b933Srs200217 }
844b22b933Srs200217 #endif
854b22b933Srs200217 
864b22b933Srs200217 #endif
87