doubao_chat/lib/net/mdns/code/mDNSPosix.h

59 lines
2.2 KiB
C

#ifndef __mDNSPlatformPosix_h
#define __mDNSPlatformPosix_h
#include "lwip/sockets.h"
// PosixNetworkInterface is a record extension of the core NetworkInterfaceInfo
// type that supports extra fields needed by the Posix platform.
//
// IMPORTANT: coreIntf must be the first field in the structure because
// we cast between pointers to the two different types regularly.
typedef struct PosixNetworkInterface PosixNetworkInterface;
struct PosixNetworkInterface {
NetworkInterfaceInfo coreIntf;
const char *intfName;
PosixNetworkInterface *aliasIntf;
int index;
int multicastSocket4;
#if HAVE_IPV6
int multicastSocket6;
#endif
};
// This is a global because debugf_() needs to be able to check its value
extern int gMDNSPlatformPosixVerboseLevel;
struct mDNS_PlatformSupport_struct {
int unicastSocket4;
#if HAVE_IPV6
int unicastSocket6;
#endif
};
#define uDNS_SERVERS_FILE "/etc/resolv.conf"
extern int ParseDNSServers(mDNS *m, const char *filePath);
extern mStatus mDNSPlatformPosixRefreshInterfaceList(mDNS *const m);
// See comment in implementation.
// Call mDNSPosixGetFDSet before calling select(), to update the parameters
// as may be necessary to meet the needs of the mDNSCore code.
// The timeout pointer MUST NOT be NULL.
// Set timeout->tv_sec to 0x3FFFFFFF if you want to have effectively no timeout
// After calling mDNSPosixGetFDSet(), call select(nfds, &readfds, NULL, NULL, &timeout); as usual
// After select() returns, call mDNSPosixProcessFDSet() to let mDNSCore do its work
extern void mDNSPosixGetFDSet(mDNS *m, int *nfds, fd_set *readfds, struct timeval *timeout);
extern void mDNSPosixProcessFDSet(mDNS *const m, fd_set *readfds);
typedef void (*mDNSPosixEventCallback)(int fd, short filter, void *context);
extern mStatus mDNSPosixAddFDToEventLoop(int fd, mDNSPosixEventCallback callback, void *context);
extern mStatus mDNSPosixRemoveFDFromEventLoop(int fd);
extern mStatus mDNSPosixListenForSignalInEventLoop(int signum);
extern mStatus mDNSPosixIgnoreSignalInEventLoop(int signum);
//extern mStatus mDNSPosixRunEventLoopOnce( mDNS *m, const struct timeval *pTimeout, sigset_t *pSignalsReceived, mDNSBool *pDataDispatched);
#endif