mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-07-23 09:21:56 +08:00
mDNSResponder: Update to v878.30.4
The sources can be obtained via: https://opensource.apple.com/tarballs/mDNSResponder/mDNSResponder-878.30.4.tar.gz Close #3522.
This commit is contained in:
parent
1e55d8204c
commit
2723609467
@ -16,7 +16,7 @@
|
||||
|
||||
include $(MAKEFILEPATH)/pb_makefiles/platform.make
|
||||
|
||||
MVERS = "mDNSResponder-878.20.3"
|
||||
MVERS = "mDNSResponder-878.30.4"
|
||||
|
||||
VER =
|
||||
ifneq ($(strip $(GCC_VERSION)),)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
*
|
||||
* Copyright (c) 2002-2015 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2002-2017 Apple Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -4170,12 +4170,12 @@ mDNSexport void AnswerCurrentQuestionWithResourceRecord(mDNS *const m, CacheReco
|
||||
responseLatencyMs = 0;
|
||||
}
|
||||
|
||||
MetricsUpdateUDNSQueryStats(queryName, q->qtype, &rr->resrec, q->metrics.querySendCount, responseLatencyMs, isForCellular);
|
||||
MetricsUpdateDNSQueryStats(queryName, q->qtype, &rr->resrec, q->metrics.querySendCount, responseLatencyMs, isForCellular);
|
||||
q->metrics.answered = mDNStrue;
|
||||
}
|
||||
if (q->metrics.querySendCount > 0)
|
||||
{
|
||||
MetricsUpdateUDNSResolveStats(queryName, &rr->resrec, isForCellular);
|
||||
MetricsUpdateDNSResolveStats(queryName, &rr->resrec, isForCellular);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -8944,6 +8944,13 @@ mDNSlocal void mDNSCoreReceiveResponse(mDNS *const m,
|
||||
response->h.numAuthorities, response->h.numAuthorities == 1 ? "y, " : "ies,",
|
||||
response->h.numAdditionals, response->h.numAdditionals == 1 ? " " : "s", end - response->data, LLQType);
|
||||
|
||||
#if AWD_METRICS
|
||||
if (mDNSSameIPPort(srcport, UnicastDNSPort))
|
||||
{
|
||||
MetricsUpdateDNSResponseSize((mDNSu32)(end - (mDNSu8 *)response));
|
||||
}
|
||||
#endif
|
||||
|
||||
// According to RFC 2181 <http://www.ietf.org/rfc/rfc2181.txt>
|
||||
// When a DNS client receives a reply with TC
|
||||
// set, it should ignore that response, and query again, using a
|
||||
@ -12127,7 +12134,7 @@ mDNSexport mStatus mDNS_StopQuery_internal(mDNS *const m, DNSQuestion *const que
|
||||
queryName = question->metrics.originalQName ? question->metrics.originalQName : &question->qname;
|
||||
isForCell = (question->qDNSServer && question->qDNSServer->cellIntf);
|
||||
durationMs = ((m->timenow - question->metrics.firstQueryTime) * 1000) / mDNSPlatformOneSecond;
|
||||
MetricsUpdateUDNSQueryStats(queryName, question->qtype, mDNSNULL, question->metrics.querySendCount, durationMs, isForCell);
|
||||
MetricsUpdateDNSQueryStats(queryName, question->qtype, mDNSNULL, question->metrics.querySendCount, durationMs, isForCell);
|
||||
}
|
||||
#endif
|
||||
// Take care to cut question from list *before* calling UpdateQuestionDuplicates
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
*
|
||||
* Copyright (c) 2002-2015 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2002-2017 Apple Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -1896,7 +1896,7 @@ typedef enum { DNSSECValNotRequired = 0, DNSSECValRequired, DNSSECValInProgress,
|
||||
// RFC 4122 defines it to be 16 bytes
|
||||
#define UUID_SIZE 16
|
||||
|
||||
#define AWD_METRICS (USE_AWD && TARGET_OS_EMBEDDED)
|
||||
#define AWD_METRICS (USE_AWD && TARGET_OS_IOS)
|
||||
|
||||
#if AWD_METRICS
|
||||
typedef struct
|
||||
@ -2039,7 +2039,7 @@ struct DNSQuestion_struct
|
||||
domainname *qnameOrig; // Copy of the original question name if it is not fully qualified
|
||||
mDNSQuestionCallback *QuestionCallback;
|
||||
void *QuestionContext;
|
||||
#if TARGET_OS_EMBEDDED
|
||||
#if AWD_METRICS
|
||||
uDNSMetrics metrics; // Data used for collecting unicast DNS query metrics.
|
||||
#endif
|
||||
#if USE_DNS64
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
*
|
||||
* Copyright (c) 2002-2015 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2002-2017 Apple Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -25,6 +25,10 @@
|
||||
#endif
|
||||
#include "uDNS.h"
|
||||
|
||||
#if AWD_METRICS
|
||||
#include "Metrics.h"
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER))
|
||||
// Disable "assignment within conditional expression".
|
||||
// Other compilers understand the convention that if you place the assignment expression within an extra pair
|
||||
@ -1329,6 +1333,12 @@ mDNSlocal void tcpCallback(TCPSocket *sock, void *context, mDNSBool ConnectionEs
|
||||
|
||||
err = mDNSSendDNSMessage(m, &tcpInfo->request, end, mDNSInterface_Any, mDNSNULL, &tcpInfo->Addr, tcpInfo->Port, sock, AuthInfo, mDNSfalse);
|
||||
if (err) { debugf("ERROR: tcpCallback: mDNSSendDNSMessage - %d", err); err = mStatus_UnknownErr; goto exit; }
|
||||
#if AWD_METRICS
|
||||
if (mDNSSameIPPort(tcpInfo->Port, UnicastDNSPort))
|
||||
{
|
||||
MetricsUpdateDNSQuerySize((mDNSu32)(end - (mDNSu8 *)&tcpInfo->request));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Record time we sent this question
|
||||
if (q)
|
||||
@ -4758,9 +4768,10 @@ mDNSexport void uDNS_CheckCurrentQuestion(mDNS *const m)
|
||||
else
|
||||
{
|
||||
err = mDNSSendDNSMessage(m, &m->omsg, end, q->qDNSServer->interface, q->LocalSocket, &q->qDNSServer->addr, q->qDNSServer->port, mDNSNULL, mDNSNULL, q->UseBackgroundTrafficClass);
|
||||
#if TARGET_OS_EMBEDDED
|
||||
#if AWD_METRICS
|
||||
if (!err)
|
||||
{
|
||||
MetricsUpdateDNSQuerySize((mDNSu32)(end - (mDNSu8 *)&m->omsg));
|
||||
if (q->metrics.answered)
|
||||
{
|
||||
q->metrics.querySendCount = 0;
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
/*
|
||||
* Copyright (c) 2016-2017 Apple Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -15,19 +14,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "mDNSEmbeddedAPI.h"
|
||||
|
||||
#ifndef __Metrics_h
|
||||
#define __Metrics_h
|
||||
|
||||
#include "mDNSEmbeddedAPI.h"
|
||||
#include <TargetConditionals.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_EMBEDDED
|
||||
#if TARGET_OS_IOS
|
||||
mStatus MetricsInit(void);
|
||||
void MetricsUpdateUDNSQueryStats(const domainname *inQueryName, mDNSu16 inType, const ResourceRecord *inRR, mDNSu32 inSendCount, mDNSu32 inLatencyMs, mDNSBool inForCell);
|
||||
void MetricsUpdateUDNSResolveStats(const domainname *inQueryName, const ResourceRecord *inRR, mDNSBool inForCell);
|
||||
void MetricsUpdateDNSQueryStats(const domainname *inQueryName, mDNSu16 inType, const ResourceRecord *inRR, mDNSu32 inSendCount, mDNSu32 inLatencyMs, mDNSBool inForCell);
|
||||
void MetricsUpdateDNSResolveStats(const domainname *inQueryName, const ResourceRecord *inRR, mDNSBool inForCell);
|
||||
void MetricsUpdateDNSQuerySize(mDNSu32 inSize);
|
||||
void MetricsUpdateDNSResponseSize(mDNSu32 inSize);
|
||||
void LogMetrics(void);
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -45,7 +45,7 @@
|
||||
#include "xpc_services.h" // Interface to XPC services
|
||||
#include "helper.h"
|
||||
|
||||
#if TARGET_OS_EMBEDDED
|
||||
#if AWD_METRICS
|
||||
#include "Metrics.h"
|
||||
#endif
|
||||
|
||||
@ -558,7 +558,7 @@ mDNSexport void INFOCallback(void)
|
||||
LogMsgNoIdent("%##s", mDNSStorage.FQDN.c);
|
||||
}
|
||||
|
||||
#if TARGET_OS_EMBEDDED
|
||||
#if AWD_METRICS
|
||||
LogMetrics();
|
||||
#endif
|
||||
LogMsgNoIdent("Timenow 0x%08lX (%d)", (mDNSu32)now, now);
|
||||
@ -1360,9 +1360,10 @@ mDNSlocal void * KQueueLoop(void *m_param)
|
||||
{
|
||||
if (events_found > kEventsToReadAtOnce || (events_found < 0 && errno != EINTR))
|
||||
{
|
||||
const int kevent_errno = errno;
|
||||
// Not sure what to do here, our kqueue has failed us - this isn't ideal
|
||||
LogMsg("ERROR: KQueueLoop - kevent failed errno %d (%s)", errno, strerror(errno));
|
||||
exit(errno);
|
||||
LogMsg("ERROR: KQueueLoop - kevent failed errno %d (%s)", kevent_errno, strerror(kevent_errno));
|
||||
exit(kevent_errno);
|
||||
}
|
||||
|
||||
numevents += events_found;
|
||||
@ -1390,7 +1391,7 @@ mDNSlocal size_t LaunchdCheckin(void)
|
||||
{
|
||||
// Ask launchd for our socket
|
||||
int result = launch_activate_socket("Listeners", &launchd_fds, &launchd_fds_count);
|
||||
if (result != 0) { LogMsg("launch_activate_socket() failed errno %d (%s)", errno, strerror(errno)); }
|
||||
if (result != 0) { LogMsg("launch_activate_socket() failed error %d (%s)", result, strerror(result)); }
|
||||
return launchd_fds_count;
|
||||
}
|
||||
|
||||
@ -1620,14 +1621,26 @@ mDNSexport int main(int argc, char **argv)
|
||||
|
||||
// Create the kqueue, mutex and thread to support KQSockets
|
||||
KQueueFD = kqueue();
|
||||
if (KQueueFD == -1) { LogMsg("kqueue() failed errno %d (%s)", errno, strerror(errno)); status = errno; goto exit; }
|
||||
if (KQueueFD == -1)
|
||||
{
|
||||
const int kqueue_errno = errno;
|
||||
LogMsg("kqueue() failed errno %d (%s)", kqueue_errno, strerror(kqueue_errno));
|
||||
status = kqueue_errno;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
i = pthread_mutex_init(&PlatformStorage.BigMutex, NULL);
|
||||
if (i == -1) { LogMsg("pthread_mutex_init() failed errno %d (%s)", errno, strerror(errno)); status = errno; goto exit; }
|
||||
if (i != 0) { LogMsg("pthread_mutex_init() failed error %d (%s)", i, strerror(i)); status = i; goto exit; }
|
||||
|
||||
int fdpair[2] = {0, 0};
|
||||
i = socketpair(AF_UNIX, SOCK_STREAM, 0, fdpair);
|
||||
if (i == -1) { LogMsg("socketpair() failed errno %d (%s)", errno, strerror(errno)); status = errno; goto exit; }
|
||||
if (i == -1)
|
||||
{
|
||||
const int socketpair_errno = errno;
|
||||
LogMsg("socketpair() failed errno %d (%s)", socketpair_errno, strerror(socketpair_errno));
|
||||
status = socketpair_errno;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// Socket pair returned us two identical sockets connected to each other
|
||||
// We will use the first socket to send the second socket. The second socket
|
||||
@ -1644,7 +1657,7 @@ mDNSexport int main(int argc, char **argv)
|
||||
#endif
|
||||
SandboxProcess();
|
||||
|
||||
#if TARGET_OS_EMBEDDED
|
||||
#if AWD_METRICS
|
||||
status = MetricsInit();
|
||||
if (status) { LogMsg("Daemon start: MetricsInit failed (%d)", status); }
|
||||
#endif
|
||||
@ -1666,7 +1679,7 @@ mDNSexport int main(int argc, char **argv)
|
||||
// Start the kqueue thread
|
||||
pthread_t KQueueThread;
|
||||
i = pthread_create(&KQueueThread, NULL, KQueueLoop, &mDNSStorage);
|
||||
if (i == -1) { LogMsg("pthread_create() failed errno %d (%s)", errno, strerror(errno)); status = errno; goto exit; }
|
||||
if (i != 0) { LogMsg("pthread_create() failed error %d (%s)", i, strerror(i)); status = i; goto exit; }
|
||||
if (status == 0)
|
||||
{
|
||||
CFRunLoopRun();
|
||||
|
@ -1456,15 +1456,17 @@ void RetrieveTCPInfo(int family, const v6addr_t laddr, uint16_t lport, const v6a
|
||||
sz = sizeof(mib)/sizeof(mib[0]);
|
||||
if (sysctlnametomib("net.inet.tcp.info", mib, &sz) == -1)
|
||||
{
|
||||
os_log(log_handle, "RetrieveTCPInfo: sysctlnametomib failed %d, %s", errno, strerror(errno));
|
||||
*err = errno;
|
||||
const int sysctl_errno = errno;
|
||||
os_log(log_handle, "RetrieveTCPInfo: sysctlnametomib failed %d, %s", sysctl_errno, strerror(sysctl_errno));
|
||||
*err = sysctl_errno;
|
||||
}
|
||||
miblen = (unsigned int)sz;
|
||||
len = sizeof(struct tcp_info);
|
||||
if (sysctl(mib, miblen, &ti, &len, &itpl, sizeof(struct info_tuple)) == -1)
|
||||
{
|
||||
os_log(log_handle, "RetrieveTCPInfo: sysctl failed %d, %s", errno, strerror(errno));
|
||||
*err = errno;
|
||||
const int sysctl_errno = errno;
|
||||
os_log(log_handle, "RetrieveTCPInfo: sysctl failed %d, %s", sysctl_errno, strerror(sysctl_errno));
|
||||
*err = sysctl_errno;
|
||||
}
|
||||
|
||||
*seq = ti.tcpi_snd_nxt - 1;
|
||||
@ -1745,8 +1747,9 @@ static int startRacoon(void)
|
||||
}
|
||||
else if (result < 0)
|
||||
{
|
||||
os_log_debug(log_handle, "select returned %d errno %d %s", result, errno, strerror(errno));
|
||||
if (errno != EINTR) break;
|
||||
const int select_errno = errno;
|
||||
os_log_debug(log_handle, "select returned %d errno %d %s", result, select_errno, strerror(select_errno));
|
||||
if (select_errno != EINTR) break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1827,7 +1830,7 @@ static int setupTunnelRoute(const v6addr_t local, const v6addr_t remote)
|
||||
/* send message, ignore error when route already exists */
|
||||
if (0 > write(s, &msg, msg.hdr.rtm_msglen))
|
||||
{
|
||||
int errno_ = errno;
|
||||
const int errno_ = errno;
|
||||
|
||||
os_log_info(log_handle,"write to routing socket failed: %s", strerror(errno_));
|
||||
if (EEXIST != errno_)
|
||||
@ -1872,7 +1875,7 @@ static int teardownTunnelRoute(const v6addr_t remote)
|
||||
memcpy(&msg.dst.sin6_addr, remote, sizeof(msg.dst.sin6_addr));
|
||||
if (0 > write(s, &msg, msg.hdr.rtm_msglen))
|
||||
{
|
||||
int errno_ = errno;
|
||||
const int errno_ = errno;
|
||||
|
||||
os_log_debug(log_handle,"write to routing socket failed: %s", strerror(errno_));
|
||||
|
||||
|
@ -661,6 +661,7 @@ mDNSexport mStatus mDNSPlatformSendUDP(const mDNS *const m, const void *const ms
|
||||
struct sockaddr_storage to;
|
||||
int s = -1, err;
|
||||
mStatus result = mStatus_NoError;
|
||||
int sendto_errno;
|
||||
|
||||
if (InterfaceID)
|
||||
{
|
||||
@ -736,9 +737,10 @@ mDNSexport mStatus mDNSPlatformSendUDP(const mDNS *const m, const void *const ms
|
||||
err = setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_IF, &info->scope_id, sizeof(info->scope_id));
|
||||
if (err < 0)
|
||||
{
|
||||
const int setsockopt_errno = errno;
|
||||
char name[IFNAMSIZ];
|
||||
if (if_indextoname(info->scope_id, name) != NULL)
|
||||
LogMsg("setsockopt - IPV6_MULTICAST_IF error %d errno %d (%s)", err, errno, strerror(errno));
|
||||
LogMsg("setsockopt - IPV6_MULTICAST_IF error %d errno %d (%s)", err, setsockopt_errno, strerror(setsockopt_errno));
|
||||
else
|
||||
LogInfo("setsockopt - IPV6_MUTLICAST_IF scopeid %d, not a valid interface", info->scope_id);
|
||||
}
|
||||
@ -779,6 +781,7 @@ mDNSexport mStatus mDNSPlatformSendUDP(const mDNS *const m, const void *const ms
|
||||
setTrafficClass(s, useBackgroundTrafficClass);
|
||||
|
||||
err = sendto(s, msg, (UInt8*)end - (UInt8*)msg, 0, (struct sockaddr *)&to, to.ss_len);
|
||||
sendto_errno = (err < 0) ? errno : 0;
|
||||
|
||||
// set traffic class back to default value
|
||||
if (useBackgroundTrafficClass)
|
||||
@ -788,30 +791,30 @@ mDNSexport mStatus mDNSPlatformSendUDP(const mDNS *const m, const void *const ms
|
||||
{
|
||||
static int MessageCount = 0;
|
||||
LogInfo("mDNSPlatformSendUDP -> sendto(%d) failed to send packet on InterfaceID %p %5s/%d to %#a:%d skt %d error %d errno %d (%s) %lu",
|
||||
s, InterfaceID, ifa_name, dst->type, dst, mDNSVal16(dstPort), s, err, errno, strerror(errno), (mDNSu32)(m->timenow));
|
||||
s, InterfaceID, ifa_name, dst->type, dst, mDNSVal16(dstPort), s, err, sendto_errno, strerror(sendto_errno), (mDNSu32)(m->timenow));
|
||||
if (!mDNSAddressIsAllDNSLinkGroup(dst))
|
||||
{
|
||||
if (errno == EHOSTUNREACH) return(mStatus_HostUnreachErr);
|
||||
if (errno == EHOSTDOWN || errno == ENETDOWN || errno == ENETUNREACH) return(mStatus_TransientErr);
|
||||
if (sendto_errno == EHOSTUNREACH) return(mStatus_HostUnreachErr);
|
||||
if (sendto_errno == EHOSTDOWN || sendto_errno == ENETDOWN || sendto_errno == ENETUNREACH) return(mStatus_TransientErr);
|
||||
}
|
||||
// Don't report EHOSTUNREACH in the first three minutes after boot
|
||||
// This is because mDNSResponder intentionally starts up early in the boot process (See <rdar://problem/3409090>)
|
||||
// but this means that sometimes it starts before configd has finished setting up the multicast routing entries.
|
||||
if (errno == EHOSTUNREACH && (mDNSu32)(mDNSPlatformRawTime()) < (mDNSu32)(mDNSPlatformOneSecond * 180)) return(mStatus_TransientErr);
|
||||
if (sendto_errno == EHOSTUNREACH && (mDNSu32)(mDNSPlatformRawTime()) < (mDNSu32)(mDNSPlatformOneSecond * 180)) return(mStatus_TransientErr);
|
||||
// Don't report EADDRNOTAVAIL ("Can't assign requested address") if we're in the middle of a network configuration change
|
||||
if (errno == EADDRNOTAVAIL && m->NetworkChanged) return(mStatus_TransientErr);
|
||||
if (errno == EHOSTUNREACH || errno == EADDRNOTAVAIL || errno == ENETDOWN)
|
||||
if (sendto_errno == EADDRNOTAVAIL && m->NetworkChanged) return(mStatus_TransientErr);
|
||||
if (sendto_errno == EHOSTUNREACH || sendto_errno == EADDRNOTAVAIL || sendto_errno == ENETDOWN)
|
||||
LogInfo("mDNSPlatformSendUDP sendto(%d) failed to send packet on InterfaceID %p %5s/%d to %#a:%d skt %d error %d errno %d (%s) %lu",
|
||||
s, InterfaceID, ifa_name, dst->type, dst, mDNSVal16(dstPort), s, err, errno, strerror(errno), (mDNSu32)(m->timenow));
|
||||
s, InterfaceID, ifa_name, dst->type, dst, mDNSVal16(dstPort), s, err, sendto_errno, strerror(sendto_errno), (mDNSu32)(m->timenow));
|
||||
else
|
||||
{
|
||||
MessageCount++;
|
||||
if (MessageCount < 50) // Cap and ensure NO spamming of LogMsgs
|
||||
LogMsg("mDNSPlatformSendUDP: sendto(%d) failed to send packet on InterfaceID %p %5s/%d to %#a:%d skt %d error %d errno %d (%s) %lu MessageCount is %d",
|
||||
s, InterfaceID, ifa_name, dst->type, dst, mDNSVal16(dstPort), s, err, errno, strerror(errno), (mDNSu32)(m->timenow), MessageCount);
|
||||
s, InterfaceID, ifa_name, dst->type, dst, mDNSVal16(dstPort), s, err, sendto_errno, strerror(sendto_errno), (mDNSu32)(m->timenow), MessageCount);
|
||||
else // If logging is enabled, remove the cap and log aggressively
|
||||
LogInfo("mDNSPlatformSendUDP: sendto(%d) failed to send packet on InterfaceID %p %5s/%d to %#a:%d skt %d error %d errno %d (%s) %lu MessageCount is %d",
|
||||
s, InterfaceID, ifa_name, dst->type, dst, mDNSVal16(dstPort), s, err, errno, strerror(errno), (mDNSu32)(m->timenow), MessageCount);
|
||||
s, InterfaceID, ifa_name, dst->type, dst, mDNSVal16(dstPort), s, err, sendto_errno, strerror(sendto_errno), (mDNSu32)(m->timenow), MessageCount);
|
||||
}
|
||||
|
||||
result = mStatus_UnknownErr;
|
||||
@ -1071,7 +1074,7 @@ mDNSexport void myKQSocketCallBack(int s1, short filter, void *context, mDNSBool
|
||||
// Find out about other socket parameter that can help understand why select() says the socket is ready for read
|
||||
// All of this is racy, as data may have arrived after the call to select()
|
||||
static unsigned int numLogMessages = 0;
|
||||
int save_errno = errno;
|
||||
const int save_errno = errno;
|
||||
int so_error = -1;
|
||||
int so_nread = -1;
|
||||
int fionread = -1;
|
||||
@ -1912,6 +1915,7 @@ mDNSlocal mStatus SetupSocket(KQSocketSet *cp, const mDNSIPPort port, u_short sa
|
||||
mStatus err = mStatus_NoError;
|
||||
char *errstr = mDNSNULL;
|
||||
const int mtu = 0;
|
||||
int saved_errno;
|
||||
|
||||
cp->closeFlag = mDNSNULL;
|
||||
|
||||
@ -2044,12 +2048,13 @@ mDNSlocal mStatus SetupSocket(KQSocketSet *cp, const mDNSIPPort port, u_short sa
|
||||
return(mStatus_NoError);
|
||||
|
||||
fail:
|
||||
saved_errno = errno;
|
||||
// For "bind" failures, only write log messages for our shared mDNS port, or for binding to zero
|
||||
if (strcmp(errstr, "bind") || mDNSSameIPPort(port, MulticastDNSPort) || mDNSIPPortIsZero(port))
|
||||
LogMsg("%s skt %d port %d error %d errno %d (%s)", errstr, skt, mDNSVal16(port), err, errno, strerror(errno));
|
||||
LogMsg("%s skt %d port %d error %d errno %d (%s)", errstr, skt, mDNSVal16(port), err, saved_errno, strerror(saved_errno));
|
||||
|
||||
// If we got a "bind" failure of EADDRINUSE, inform the caller as it might need to try another random port
|
||||
if (!strcmp(errstr, "bind") && errno == EADDRINUSE)
|
||||
if (!strcmp(errstr, "bind") && saved_errno == EADDRINUSE)
|
||||
{
|
||||
err = EADDRINUSE;
|
||||
if (mDNSSameIPPort(port, MulticastDNSPort))
|
||||
@ -2325,8 +2330,9 @@ cp += len; \
|
||||
sock = socket(PF_ROUTE, SOCK_RAW, 0);
|
||||
if (sock < 0)
|
||||
{
|
||||
LogMsg("getMACAddress: Can not open the socket - %s", strerror(errno));
|
||||
return errno;
|
||||
const int socket_errno = errno;
|
||||
LogMsg("getMACAddress: Can not open the socket - %s", strerror(socket_errno));
|
||||
return socket_errno;
|
||||
}
|
||||
|
||||
rtm->rtm_addrs |= RTA_DST | RTA_GATEWAY;
|
||||
@ -2358,9 +2364,10 @@ cp += len; \
|
||||
|
||||
if (write(sock, (char *)&m_rtmsg, rlen) < 0)
|
||||
{
|
||||
LogMsg("getMACAddress: writing to routing socket: %s", strerror(errno));
|
||||
const int write_errno = errno;
|
||||
LogMsg("getMACAddress: writing to routing socket: %s", strerror(write_errno));
|
||||
close(sock);
|
||||
return errno;
|
||||
return write_errno;
|
||||
}
|
||||
|
||||
do
|
||||
@ -3235,7 +3242,11 @@ mDNSlocal mDNSBool InterfaceSupportsKeepAlive(NetworkInterfaceInfo *const intf)
|
||||
mDNSlocal mDNSBool NetWakeInterface(NetworkInterfaceInfoOSX *i)
|
||||
{
|
||||
// We only use Sleep Proxy Service on multicast-capable interfaces, except loopback and D2D.
|
||||
if (!SPSInterface(i)) return(mDNSfalse);
|
||||
if (!MulticastInterface(i) || (i->ifa_flags & IFF_LOOPBACK) || i->D2DInterface)
|
||||
{
|
||||
LogSPS("NetWakeInterface: returning false for %s", i->ifinfo.ifname);
|
||||
return(mDNSfalse);
|
||||
}
|
||||
|
||||
// If the interface supports TCPKeepalive, it is capable of waking up for a magic packet
|
||||
// This check is needed since the SIOCGIFWAKEFLAGS ioctl returns wrong values for WOMP capability
|
||||
@ -3253,15 +3264,16 @@ mDNSlocal mDNSBool NetWakeInterface(NetworkInterfaceInfoOSX *i)
|
||||
strlcpy(ifr.ifr_name, i->ifinfo.ifname, sizeof(ifr.ifr_name));
|
||||
if (ioctl(s, SIOCGIFWAKEFLAGS, &ifr) < 0)
|
||||
{
|
||||
const int ioctl_errno = errno;
|
||||
// For some strange reason, in /usr/include/sys/errno.h, EOPNOTSUPP is defined to be
|
||||
// 102 when compiling kernel code, and 45 when compiling user-level code. Since this
|
||||
// error code is being returned from the kernel, we need to use the kernel version.
|
||||
#define KERNEL_EOPNOTSUPP 102
|
||||
if (errno != KERNEL_EOPNOTSUPP) // "Operation not supported on socket", the expected result on Leopard and earlier
|
||||
LogMsg("NetWakeInterface SIOCGIFWAKEFLAGS %s errno %d (%s)", i->ifinfo.ifname, errno, strerror(errno));
|
||||
if (ioctl_errno != KERNEL_EOPNOTSUPP) // "Operation not supported on socket", the expected result on Leopard and earlier
|
||||
LogMsg("NetWakeInterface SIOCGIFWAKEFLAGS %s errno %d (%s)", i->ifinfo.ifname, ioctl_errno, strerror(ioctl_errno));
|
||||
// If on Leopard or earlier, we get EOPNOTSUPP, so in that case
|
||||
// we enable WOL if this interface is not AirPort and "Wake for Network access" is turned on.
|
||||
ifr.ifr_wake_flags = (errno == KERNEL_EOPNOTSUPP && !(i)->BSSID.l[0] && i->m->SystemWakeOnLANEnabled) ? IF_WAKE_ON_MAGIC_PACKET : 0;
|
||||
ifr.ifr_wake_flags = (ioctl_errno == KERNEL_EOPNOTSUPP && !(i)->BSSID.l[0] && i->m->SystemWakeOnLANEnabled) ? IF_WAKE_ON_MAGIC_PACKET : 0;
|
||||
}
|
||||
|
||||
close(s);
|
||||
|
@ -66,7 +66,7 @@
|
||||
*/
|
||||
|
||||
#ifndef _DNS_SD_H
|
||||
#define _DNS_SD_H 8782003
|
||||
#define _DNS_SD_H 8783004
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user