From: Apple Date: Fri, 23 Apr 2004 00:37:49 +0000 (+0000) Subject: mDNSResponder-58.8.tar.gz X-Git-Tag: mac-os-x-1034^0 X-Git-Url: https://git.saurik.com/apple/mdnsresponder.git/commitdiff_plain/737925754ef5bb2f7d7eda2f09e7d6a29ba51f74 mDNSResponder-58.8.tar.gz --- diff --git a/Makefile b/Makefile index 71d4559..9e1478f 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ include /Developer/Makefiles/pb_makefiles/platform.make -MVERS = "mDNSResponder-58.6" +MVERS = "mDNSResponder-58.8" install: cd "$(SRCROOT)/mDNSMacOSX"; pbxbuild install OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) DSTROOT=$(DSTROOT) MVERS=$(MVERS) diff --git a/mDNSCore/mDNS.c b/mDNSCore/mDNS.c index 2bee7da..229df34 100755 --- a/mDNSCore/mDNS.c +++ b/mDNSCore/mDNS.c @@ -44,6 +44,15 @@ Change History (most recent first): $Log: mDNS.c,v $ +Revision 1.307.2.8 2004/04/03 05:18:19 bradley +Added cast to fix signed/unsigned warning due to int promotion. + +Revision 1.307.2.7 2004/03/30 06:46:24 cheshire +Compiler warning fixes from Don Woodward at Roku Labs + +Revision 1.307.2.6 2004/03/09 03:03:38 cheshire + Don't take lock until after mDNS_Update() has validated that the data is good + Revision 1.307.2.5 2004/03/02 02:55:24 cheshire Properly support "_services._dns-sd._udp" meta-queries @@ -2198,13 +2207,13 @@ mDNSlocal mDNSu16 GetRDLength(const ResourceRecord *const rr, mDNSBool estimate) const domainname *const name = estimate ? &rr->name : mDNSNULL; switch (rr->rrtype) { - case kDNSType_A: return(sizeof(rd->ip)); break; + case kDNSType_A: return(sizeof(rd->ip)); case kDNSType_CNAME:// Same as PTR case kDNSType_PTR: return(CompressedDomainNameLength(&rd->name, name)); case kDNSType_HINFO:return(mDNSu16)(2 + (int)rd->data[0] + (int)rd->data[1 + (int)rd->data[0]]); case kDNSType_NULL: // Same as TXT -- not self-describing, so have to just trust rdlength case kDNSType_TXT: return(rr->rdlength); // TXT is not self-describing, so have to just trust rdlength - case kDNSType_AAAA: return(sizeof(rd->ipv6)); break; + case kDNSType_AAAA: return(sizeof(rd->ipv6)); case kDNSType_SRV: return(mDNSu16)(6 + CompressedDomainNameLength(&rd->srv.target, name)); default: debugf("Warning! Don't know how to get length of resource type %d", rr->rrtype); return(rr->rdlength); @@ -2778,7 +2787,7 @@ mDNSlocal const mDNSu8 *FindCompressionPointer(const mDNSu8 *const base, const m mDNSlocal mDNSu8 *putDomainNameAsLabels(const DNSMessage *const msg, mDNSu8 *ptr, const mDNSu8 *const limit, const domainname *const name) { - const mDNSu8 *const base = (const mDNSu8 *const)msg; + const mDNSu8 *const base = (const mDNSu8 *)msg; const mDNSu8 * np = name->c; const mDNSu8 *const max = name->c + MAX_DOMAIN_NAME; // Maximum that's valid const mDNSu8 * pointer = mDNSNULL; @@ -3783,7 +3792,7 @@ mDNSlocal mDNSBool AccelerateThisQuery(mDNS *const m, DNSQuestion *q) if (TimeToSendThisQuestion(q, m->timenow + q->ThisQInterval/2)) { // We forecast: qname (n) type (2) class (2) - mDNSu32 forecast = DomainNameLength(&q->qname) + 4; + mDNSu32 forecast = (mDNSu32)DomainNameLength(&q->qname) + 4; CacheRecord *rr; for (rr=m->rrcache_hash[HashSlot(&q->qname)]; rr; rr=rr->next) // If we have a resource record in our cache, if (rr->resrec.rdlength <= SmallRecordLimit && // which is small enough to sensibly fit in the packet @@ -6172,11 +6181,11 @@ mDNSexport mStatus mDNS_Update(mDNS *const m, AuthRecord *const rr, mDNSu32 newt const mDNSu16 newrdlength, RData *const newrdata, mDNSRecordUpdateCallback *Callback) { - mDNS_Lock(m); - if (!ValidateRData(rr->resrec.rrtype, newrdlength, newrdata)) { LogMsg("Attempt to update record with invalid rdata: %s", GetRRDisplayString_rdb(m, &rr->resrec, &newrdata->u)); return(mStatus_Invalid); } + mDNS_Lock(m); + // If TTL is unspecified, leave TTL unchanged if (newttl == 0) newttl = rr->resrec.rroriginalttl; diff --git a/mDNSCore/mDNSClientAPI.h b/mDNSCore/mDNSClientAPI.h index a968c7f..cb5bace 100755 --- a/mDNSCore/mDNSClientAPI.h +++ b/mDNSCore/mDNSClientAPI.h @@ -23,6 +23,16 @@ Change History (most recent first): $Log: mDNSClientAPI.h,v $ +Revision 1.114.2.9 2004/04/22 03:17:35 cheshire +Fix use of "struct __attribute__((__packed__))" so it only applies on GCC >= 2.9 + +Revision 1.114.2.8 2004/03/30 06:55:37 cheshire +Gave name to anonymous struct, to avoid errors on certain compilers. +(Thanks to ramaprasad.kr@hp.com for reporting this.) + +Revision 1.114.2.7 2004/03/09 02:31:27 cheshire +Remove erroneous underscore in 'packed_struct' (makes no difference now, but might in future) + Revision 1.114.2.6 2004/03/02 02:55:25 cheshire Properly support "_services._dns-sd._udp" meta-queries @@ -443,8 +453,8 @@ Merge in license terms from Quinn's copy, in preparation for Darwin release // Most compilers naturally pack the on-the-wire structures correctly anyway, so a plain "struct" is usually fine. // In the event that structures are not packed correctly, mDNS_Init() will detect this and report an error, so the // developer will know what's wrong, and can investigate what needs to be done on that compiler to provide proper packing. -#ifndef packed_struct - #ifdef __GNUC__ +#ifndef packedstruct + #if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 9))) #define packedstruct struct __attribute__((__packed__)) #define packedunion union __attribute__((__packed__)) #else @@ -521,7 +531,7 @@ typedef unsigned long mDNSu32; // To enforce useful type checking, we make mDNSInterfaceID be a pointer to a dummy struct // This way, mDNSInterfaceIDs can be assigned, and compared with each other, but not with other types // Declaring the type to be the typical generic "void *" would lack this type checking -typedef struct { void *dummy; } *mDNSInterfaceID; +typedef struct mDNSInterfaceID_dummystruct { void *dummy; } *mDNSInterfaceID; // These types are for opaque two- and four-byte identifiers. // The "NotAnInteger" fields of the unions allow the value to be conveniently passed around in a diff --git a/mDNSMacOSX/CFSocket.c b/mDNSMacOSX/CFSocket.c index 519a899..fb2e821 100644 --- a/mDNSMacOSX/CFSocket.c +++ b/mDNSMacOSX/CFSocket.c @@ -23,6 +23,21 @@ Change History (most recent first): $Log: CFSocket.c,v $ +Revision 1.115.2.4 2004/04/23 00:34:06 cheshire +: mDNSResponder messages on wake +Take care to correctly update InterfaceIDs when a dormant interface comes back to life + +Revision 1.115.2.3 2004/04/08 23:18:11 cheshire + When interface turned off, browse "remove" events delivered with interface index zero +Refinement from Bob Bradley: Should use "mDNS *const m" instead of referencing mDNSStorage directly + +Revision 1.115.2.2 2004/04/08 00:42:37 cheshire + When interface turned off, browse "remove" events delivered with interface index zero +Unify use of the InterfaceID field, and make code that walks the list respect the CurrentlyActive flag + +Revision 1.115.2.1 2004/04/07 01:08:15 cheshire + When interface turned off, browse "remove" events delivered with interface index zero + Revision 1.115 2003/09/10 00:45:55 cheshire Don't log "sendto failed" errors during the first two minutes of startup @@ -458,7 +473,7 @@ mDNSexport mDNSInterfaceID mDNSPlatformInterfaceIDfromInterfaceIndex(const mDNS if (index == (uint32_t)~0) return((mDNSInterfaceID)~0); if (index) for (i = m->p->InterfaceList; i; i = i->next) - if (i->scope_id == index) + if (i->ifinfo.InterfaceID && i->scope_id == index) // Don't get tricked by inactive interfaces return(i->ifinfo.InterfaceID); return(mDNSNULL); } @@ -469,7 +484,8 @@ mDNSexport mDNSu32 mDNSPlatformInterfaceIndexfromInterfaceID(const mDNS *const m if (id == (mDNSInterfaceID)~0) return((mDNSu32)~0); if (id) for (i = m->p->InterfaceList; i; i = i->next) - if (i->ifinfo.InterfaceID == id) + // Don't use i->ifinfo.InterfaceID here because we want to find inactive interfaces where that's not set + if ((mDNSInterfaceID)i == id) return i->scope_id; return 0; } @@ -1102,6 +1118,7 @@ mDNSlocal NetworkInterfaceInfoOSX *SearchForInterfaceByName(mDNS *const m, char NetworkInterfaceInfoOSX *i; for (i = m->p->InterfaceList; i; i = i->next) if (!strcmp(i->ifa_name, ifname) && + i->CurrentlyActive && ((AAAA_OVER_V4 ) || (type == AF_INET && i->ifinfo.ip.type == mDNSAddrType_IPv4) || (type == AF_INET6 && i->ifinfo.ip.type == mDNSAddrType_IPv6) )) return(i); @@ -1112,48 +1129,49 @@ mDNSlocal void SetupActiveInterfaces(mDNS *const m) { NetworkInterfaceInfoOSX *i; for (i = m->p->InterfaceList; i; i = i->next) - { - mStatus err = 0; - NetworkInterfaceInfo *n = &i->ifinfo; - NetworkInterfaceInfoOSX *alias = SearchForInterfaceByName(m, i->ifa_name, i->sa_family); - if (!alias) alias = i; - - if (n->InterfaceID && n->InterfaceID != (mDNSInterfaceID)alias) - { - LogMsg("SetupActiveInterfaces ERROR! n->InterfaceID %p != alias %p", n->InterfaceID, alias); - n->InterfaceID = mDNSNULL; - } - - if (!n->InterfaceID) - { - n->InterfaceID = (mDNSInterfaceID)alias; - mDNS_RegisterInterface(m, n); - debugf("SetupActiveInterfaces: Registered %s(%lu) InterfaceID %p %#a%s", - i->ifa_name, i->scope_id, alias, &n->ip, n->InterfaceActive ? " (Primary)" : ""); - } - - if (!n->TxAndRx) - debugf("SetupActiveInterfaces: No TX/Rx on %s(%lu) InterfaceID %p %#a", i->ifa_name, i->scope_id, alias, &n->ip); - else + if (i->CurrentlyActive) { - if (i->sa_family == AF_INET && alias->sktv4 == -1) + mStatus err = 0; + NetworkInterfaceInfo *n = &i->ifinfo; + NetworkInterfaceInfoOSX *alias = SearchForInterfaceByName(m, i->ifa_name, i->sa_family); + if (!alias) alias = i; + + if (n->InterfaceID && n->InterfaceID != (mDNSInterfaceID)alias) + { + LogMsg("SetupActiveInterfaces ERROR! n->InterfaceID %p != alias %p", n->InterfaceID, alias); + n->InterfaceID = mDNSNULL; + } + + if (!n->InterfaceID) { - #if mDNS_AllowPort53 - err = SetupSocket(i, UnicastDNSPort, &alias->skt53, &alias->cfs53); - #endif - if (!err) err = SetupSocket(i, MulticastDNSPort, &alias->sktv4, &alias->cfsv4); - if (err == 0) debugf("SetupActiveInterfaces: v4 socket%2d %s(%lu) InterfaceID %p %#a", alias->sktv4, i->ifa_name, i->scope_id, n->InterfaceID, &n->ip); - else LogMsg("SetupActiveInterfaces: v4 socket%2d %s(%lu) InterfaceID %p %#a FAILED", alias->sktv4, i->ifa_name, i->scope_id, n->InterfaceID, &n->ip); + n->InterfaceID = (mDNSInterfaceID)alias; + mDNS_RegisterInterface(m, n); + debugf("SetupActiveInterfaces: Registered %s(%lu) InterfaceID %p %#a%s", + i->ifa_name, i->scope_id, alias, &n->ip, n->InterfaceActive ? " (Primary)" : ""); } - if (i->sa_family == AF_INET6 && alias->sktv6 == -1) + if (!n->TxAndRx) + debugf("SetupActiveInterfaces: No TX/Rx on %s(%lu) InterfaceID %p %#a", i->ifa_name, i->scope_id, alias, &n->ip); + else { - err = SetupSocket(i, MulticastDNSPort, &alias->sktv6, &alias->cfsv6); - if (err == 0) debugf("SetupActiveInterfaces: v6 socket%2d %s(%lu) InterfaceID %p %#a", alias->sktv6, i->ifa_name, i->scope_id, n->InterfaceID, &n->ip); - else LogMsg("SetupActiveInterfaces: v6 socket%2d %s(%lu) InterfaceID %p %#a FAILED", alias->sktv6, i->ifa_name, i->scope_id, n->InterfaceID, &n->ip); + if (i->sa_family == AF_INET && alias->sktv4 == -1) + { + #if mDNS_AllowPort53 + err = SetupSocket(i, UnicastDNSPort, &alias->skt53, &alias->cfs53); + #endif + if (!err) err = SetupSocket(i, MulticastDNSPort, &alias->sktv4, &alias->cfsv4); + if (err == 0) debugf("SetupActiveInterfaces: v4 socket%2d %s(%lu) InterfaceID %p %#a", alias->sktv4, i->ifa_name, i->scope_id, n->InterfaceID, &n->ip); + else LogMsg("SetupActiveInterfaces: v4 socket%2d %s(%lu) InterfaceID %p %#a FAILED", alias->sktv4, i->ifa_name, i->scope_id, n->InterfaceID, &n->ip); + } + + if (i->sa_family == AF_INET6 && alias->sktv6 == -1) + { + err = SetupSocket(i, MulticastDNSPort, &alias->sktv6, &alias->cfsv6); + if (err == 0) debugf("SetupActiveInterfaces: v6 socket%2d %s(%lu) InterfaceID %p %#a", alias->sktv6, i->ifa_name, i->scope_id, n->InterfaceID, &n->ip); + else LogMsg("SetupActiveInterfaces: v6 socket%2d %s(%lu) InterfaceID %p %#a FAILED", alias->sktv6, i->ifa_name, i->scope_id, n->InterfaceID, &n->ip); + } } } - } } mDNSlocal void MarkAllInterfacesInactive(mDNS *const m) @@ -1163,6 +1181,16 @@ mDNSlocal void MarkAllInterfacesInactive(mDNS *const m) i->CurrentlyActive = mDNSfalse; } +mDNSlocal mDNSu32 NumCacheRecordsForInterfaceID(mDNS *const m, mDNSInterfaceID id) + { + mDNSu32 slot, used = 0; + CacheRecord *rr; + for (slot = 0; slot < CACHE_HASH_SLOTS; slot++) + for (rr = m->rrcache_hash[slot]; rr; rr=rr->next) + if (rr->resrec.InterfaceID == id) used++; + return(used); + } + mDNSlocal void ClearInactiveInterfaces(mDNS *const m) { // First pass: @@ -1175,9 +1203,11 @@ mDNSlocal void ClearInactiveInterfaces(mDNS *const m) NetworkInterfaceInfoOSX *i; for (i = m->p->InterfaceList; i; i = i->next) { - // 1. If this interface is no longer active, or it's InterfaceID is changing, deregister it + // 1. If this interface is no longer active, or its InterfaceID is changing, deregister it NetworkInterfaceInfoOSX *alias = (NetworkInterfaceInfoOSX *)(i->ifinfo.InterfaceID); - if (i->ifinfo.InterfaceID && (!i->CurrentlyActive || (alias && !alias->CurrentlyActive) || i->CurrentlyActive == 2)) + NetworkInterfaceInfoOSX *newalias = SearchForInterfaceByName(m, i->ifa_name, i->sa_family); + if (!newalias) newalias = i; + if (i->ifinfo.InterfaceID && (!i->CurrentlyActive || (alias && !alias->CurrentlyActive) || i->CurrentlyActive == 2 || newalias != alias)) { debugf("ClearInactiveInterfaces: Deregistering %#a", &i->ifinfo.ip); mDNS_DeregisterInterface(m, &i->ifinfo); @@ -1207,7 +1237,7 @@ mDNSlocal void ClearInactiveInterfaces(mDNS *const m) i->cfsv4 = i->cfsv6 = NULL; // 3. If no longer active, delete interface from list and free memory - if (!i->CurrentlyActive) + if (!i->CurrentlyActive && NumCacheRecordsForInterfaceID(m, (mDNSInterfaceID)i) == 0) { debugf("ClearInactiveInterfaces: Deleting %#a", &i->ifinfo.ip); *p = i->next; diff --git a/mDNSMacOSX/daemon.c b/mDNSMacOSX/daemon.c index 35baa0d..51ab0f3 100644 --- a/mDNSMacOSX/daemon.c +++ b/mDNSMacOSX/daemon.c @@ -36,6 +36,17 @@ Change History (most recent first): $Log: daemon.c,v $ +Revision 1.134.2.6 2004/04/06 19:50:36 cheshire + mDNSResponder will not launch if "nobody" user doesn't exist. +After more discussion, we've decided to use userid -2 if "nobody" user doesn't exist. + +Revision 1.134.2.5 2004/04/03 01:29:07 cheshire + mDNSResponder will not launch if "nobody" user doesn't exist. +If "nobody" user doesn't exist, log a message and continue as "root" + +Revision 1.134.2.4 2004/04/02 21:50:21 cheshire +Fix errors in comments + Revision 1.134.2.3 2003/12/12 01:21:30 cheshire mDNSResponder should not run as root @@ -1628,7 +1639,7 @@ mDNSexport int main(int argc, char **argv) signal(SIGTERM, HandleSIGTERM); signal(SIGINFO, HandleSIGINFO); - // Register the server with mach_init for automatic restart only during debug mode + // Register the server with mach_init for automatic restart only during normal (non-debug) mode if (!debug_mode) registerBootstrapService(); @@ -1641,7 +1652,7 @@ mDNSexport int main(int argc, char **argv) int fd = open(_PATH_DEVNULL, O_RDWR, 0); if (fd != -1) { - // Avoid to unnecessarily duplicate a file descriptor to itself + // Avoid unnecessarily duplicating a file descriptor to itself if (fd != STDIN_FILENO) (void)dup2(fd, STDIN_FILENO); if (fd != STDOUT_FILENO) (void)dup2(fd, STDOUT_FILENO); if (fd != STDERR_FILENO) (void)dup2(fd, STDERR_FILENO); @@ -1665,7 +1676,7 @@ mDNSexport int main(int argc, char **argv) if ( pw != NULL) setuid( pw->pw_uid); else - status = mStatus_Incompatible; // refuse to run as root + setuid(-2); // User "nobody" is -2; use that value if "nobody" does not appear in the password database if (status == 0) { diff --git a/mDNSMacOSX/mDNSResponder.pbproj/project.pbxproj b/mDNSMacOSX/mDNSResponder.pbproj/project.pbxproj index e1aad01..cf1844f 100644 --- a/mDNSMacOSX/mDNSResponder.pbproj/project.pbxproj +++ b/mDNSMacOSX/mDNSResponder.pbproj/project.pbxproj @@ -767,9 +767,12 @@ }; F525E72804AA167501F1CF4D = { fileEncoding = 4; + indentWidth = 4; isa = PBXFileReference; path = uds_daemon.c; refType = 4; + tabWidth = 4; + usesTabs = 0; }; F525E72904AA167501F1CF4D = { fileRef = F525E72804AA167501F1CF4D; diff --git a/mDNSPosix/Responder.c b/mDNSPosix/Responder.c index 6130e0c..936df49 100755 --- a/mDNSPosix/Responder.c +++ b/mDNSPosix/Responder.c @@ -23,6 +23,9 @@ Change History (most recent first): $Log: Responder.c,v $ +Revision 1.16.2.1 2004/04/07 23:51:09 cheshire +Remove obsolete comments referring to doing mDNS on port 53 + Revision 1.16 2003/08/14 02:19:55 cheshire Split generic ResourceRecord type into two separate types: AuthRecord and CacheRecord @@ -354,14 +357,13 @@ enum { static void PrintUsage() { fprintf(stderr, - "Usage: %s [-v level ] [-r] [-n name] [-t type] [-d domain] [-x TXT] [-p port] [-f file] [-b] [-P pidfile]\n", + "Usage: %s [-v level ] [-n name] [-t type] [-d domain] [-x TXT] [-p port] [-f file] [-b] [-P pidfile]\n", gProgramName); fprintf(stderr, " -v verbose mode, level is a number from 0 to 2\n"); fprintf(stderr, " 0 = no debugging info (default)\n"); fprintf(stderr, " 1 = standard debugging info\n"); fprintf(stderr, " 2 = intense debugging info\n"); fprintf(stderr, " can be cycled kill -USR1\n"); - fprintf(stderr, " -r also bind to port 53 (port 5353 is always bound)\n"); fprintf(stderr, " -n uses 'name' as the host name (default is none)\n"); fprintf(stderr, " -t uses 'type' as the service type (default is '%s')\n", kDefaultServiceType); fprintf(stderr, " -d uses 'domain' as the service domain (default is '%s')\n", kDefaultServiceDomain); @@ -374,7 +376,6 @@ static void PrintUsage() fprintf(stderr, " only meaningful if -b also specified\n"); } -static mDNSBool gAvoidPort53 = mDNStrue; static const char *gRichTextHostName = ""; static const char *gServiceType = kDefaultServiceType; static const char *gServiceDomain = kDefaultServiceDomain; @@ -415,9 +416,6 @@ static void ParseArguments(int argc, char **argv) exit(1); } break; - case 'r': - gAvoidPort53 = mDNSfalse; - break; case 'n': gRichTextHostName = optarg; if ( ! CheckThatRichTextHostNameIsUsable(gRichTextHostName, mDNStrue) ) { diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c index 9092fdd..b28aa73 100755 --- a/mDNSPosix/mDNSPosix.c +++ b/mDNSPosix/mDNSPosix.c @@ -36,6 +36,9 @@ Change History (most recent first): $Log: mDNSPosix.c,v $ +Revision 1.25.2.1 2004/04/09 17:57:31 cheshire +Make sure to set the TxAndRx field so that duplicate suppression works correctly + Revision 1.25 2003/10/30 19:25:49 cheshire Fix signed/unsigned warning on certain compilers @@ -695,6 +698,7 @@ static int SetupOneInterface(mDNS *const m, struct sockaddr *intfAddr, const cha // Set up the fields required by the mDNS core. SockAddrTomDNSAddr(intfAddr, &intf->coreIntf.ip, NULL); intf->coreIntf.Advertise = m->AdvertiseLocalAddresses; + intf->coreIntf.TxAndRx = mDNStrue; // Set up the extra fields in PosixNetworkInterface. assert(intf->intfName != NULL); // intf->intfName already set up above diff --git a/mDNSVxWorks/mDNSVxWorks.c b/mDNSVxWorks/mDNSVxWorks.c index b482fb8..eb6683e 100644 --- a/mDNSVxWorks/mDNSVxWorks.c +++ b/mDNSVxWorks/mDNSVxWorks.c @@ -27,6 +27,15 @@ Change History (most recent first): $Log: mDNSVxWorks.c,v $ +Revision 1.7.2.2 2004/04/09 17:57:31 cheshire +Make sure to set the TxAndRx field so that duplicate suppression works correctly + +Revision 1.7.2.1 2004/04/03 21:31:20 bradley +Integrated changes from TOT to remove legacy port 53 support. + +Revision 1.8 2003/10/28 10:08:27 bradley +Removed legacy port 53 support as it is no longer needed. + Revision 1.7 2003/08/20 05:58:54 bradley Removed dependence on modified mDNSCore: define structures/prototypes locally. @@ -163,7 +172,6 @@ struct MDNSInterfaceItem MDNSInterfaceItem * next; char name[ 32 ]; MDNSSocketRef multicastSocketRef; - MDNSSocketRef unicastSocketRef; MDNSSocketRef sendingSocketRef; NetworkInterfaceInfo hostSet; mDNSBool hostRegistered; @@ -172,8 +180,7 @@ struct MDNSInterfaceItem int sendUnicastCounter; int sendErrorCounter; - int recvMulticastCounter; - int recvUnicastCounter; + int recvCounter; int recvErrorCounter; int recvLoopCounter; }; @@ -963,7 +970,6 @@ mDNSlocal mStatus SetupInterface( mDNS * const inMDNS, const struct ifaddrs *inA require_action( item, exit, err = mStatus_NoMemoryErr ); strcpy( item->name, inAddr->ifa_name ); item->multicastSocketRef = kInvalidSocketRef; - item->unicastSocketRef = kInvalidSocketRef; item->sendingSocketRef = kInvalidSocketRef; // Set up the multicast DNS (port 5353) socket for this interface. @@ -971,13 +977,7 @@ mDNSlocal mStatus SetupInterface( mDNS * const inMDNS, const struct ifaddrs *inA err = SetupSocket( inMDNS, inAddr, MulticastDNSPort, &socketRef ); require_noerr( err, exit ); item->multicastSocketRef = socketRef; - - // Set up the unicast DNS (port 53) socket for this interface (to handle normal DNS requests). - - err = SetupSocket( inMDNS, inAddr, UnicastDNSPort, &socketRef ); - require_noerr( err, exit ); - item->unicastSocketRef = socketRef; - + // Set up the sending socket for this interface. err = SetupSocket( inMDNS, inAddr, zeroIPPort, &socketRef ); @@ -990,6 +990,7 @@ mDNSlocal mStatus SetupInterface( mDNS * const inMDNS, const struct ifaddrs *inA item->hostSet.ip.type = mDNSAddrType_IPv4; item->hostSet.ip.ip.v4.NotAnInteger = ipv4->sin_addr.s_addr; item->hostSet.Advertise = inMDNS->AdvertiseLocalAddresses; + item->hostSet.TxAndRx = mDNStrue; err = mDNS_RegisterInterface( inMDNS, &item->hostSet ); require_noerr( err, exit ); @@ -1045,17 +1046,7 @@ mDNSlocal mStatus TearDownInterface( mDNS * const inMDNS, MDNSInterfaceItem *inI dlog( kDebugLevelVerbose, DEBUG_NAME "tearing down multicast socket %d\n", socketRef ); close( socketRef ); } - - // Close the unicast socket. - - socketRef = inItem->unicastSocketRef; - inItem->unicastSocketRef = kInvalidSocketRef; - if( socketRef != kInvalidSocketRef ) - { - dlog( kDebugLevelVerbose, DEBUG_NAME "tearing down unicast socket %d\n", socketRef ); - close( socketRef ); - } - + // Close the sending socket. socketRef = inItem->sendingSocketRef; @@ -1105,7 +1096,7 @@ mDNSlocal mStatus require_errno_action( socketRef, errno, exit, err = mStatus_UnknownErr ); // A port of zero means this socket is for sending and should be set up for sending. Otherwise, it is for receiving - // and should be set up for receiving. The reason for separate sending vs receiving sockets to workaround problems + // and should be set up for receiving. The reason for separate sending vs receiving sockets is to workaround problems // with VxWorks IP stack when using dynamic IP configuration such as DHCP (problems binding to wildcard IP when the // IP address later changes). Since we have to bind the Multicast DNS address to workaround these issues we have to // use a separate sending socket since it is illegal to send a packet with a multicast source address (RFC 1122). @@ -1126,7 +1117,7 @@ mDNSlocal mStatus err = setsockopt( socketRef, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mreq, sizeof( mreq ) ); check_errno( err, errno ); - // Bind to the multicast DNS address and specified port (53 for unicast or 5353 for multicast). + // Bind to the multicast DNS address and port 5353. memset( &addr, 0, sizeof( addr ) ); addr.sin_family = AF_INET; @@ -1168,12 +1159,17 @@ mDNSlocal mStatus err = setsockopt( socketRef, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &optionByte, sizeof( optionByte ) ); check_errno( err, errno ); + // WARNING: Setting this option causes unicast responses to be routed to the wrong interface so they are + // WARNING: disabled. These options were only hints to improve 802.11 performance (and not implemented) anyway. + +#if 0 // Mark packets as high-throughput/low-delay (i.e. lowest reliability) to maximize 802.11 multicast rate. option = IPTOS_LOWDELAY | IPTOS_THROUGHPUT; err = setsockopt( socketRef, IPPROTO_IP, IP_TOS, (char *) &option, sizeof( option ) ); check_errno( err, errno ); - +#endif + dlog( kDebugLevelVerbose, DEBUG_NAME "setting up sending socket done (%s, %u.%u.%u.%u, %d)\n", inAddr->ifa_name, ip.b[ 0 ], ip.b[ 1 ], ip.b[ 2 ], ip.b[ 3 ], socketRef ); } @@ -1477,11 +1473,6 @@ mDNSlocal void Task( mDNS *inMDNS ) TaskProcessPacket( inMDNS, item, item->multicastSocketRef ); ++n; } - if( FD_ISSET( item->unicastSocketRef, &readSet ) ) - { - TaskProcessPacket( inMDNS, item, item->unicastSocketRef ); - ++n; - } } // Check for a pending command and process it. @@ -1560,15 +1551,10 @@ mDNSlocal void TaskSetupReadSet( mDNS *inMDNS, fd_set *outReadSet, int *outMaxSo for( item = inMDNS->p->interfaceList; item; item = item->next ) { FD_SET( item->multicastSocketRef, outReadSet ); - FD_SET( item->unicastSocketRef, outReadSet ); if( item->multicastSocketRef > maxSocket ) { maxSocket = item->multicastSocketRef; } - if( item->unicastSocketRef > maxSocket ) - { - maxSocket = item->unicastSocketRef; - } } // Add the command pipe to the read set. @@ -1629,7 +1615,6 @@ mDNSlocal void TaskSetupTimeout( mDNSs32 inNextTaskTime, struct timeval *outTime mDNSlocal void TaskProcessPacket( mDNS *inMDNS, MDNSInterfaceItem *inItem, MDNSSocketRef inSocketRef ) { int n; - mDNSBool isMulticast; DNSMessage packet; struct sockaddr_in addr; int addrSize; @@ -1638,9 +1623,7 @@ mDNSlocal void TaskProcessPacket( mDNS *inMDNS, MDNSInterfaceItem *inItem, MDNSS mDNSIPPort srcPort; mDNSAddr dstAddr; mDNSIPPort dstPort; - - isMulticast = ( inSocketRef == inItem->multicastSocketRef ); - + // Receive the packet. addrSize = sizeof( addr ); @@ -1654,8 +1637,8 @@ mDNSlocal void TaskProcessPacket( mDNS *inMDNS, MDNSInterfaceItem *inItem, MDNSS srcAddr.ip.v4.NotAnInteger = addr.sin_addr.s_addr; srcPort.NotAnInteger = addr.sin_port; dstAddr.type = mDNSAddrType_IPv4; - dstAddr.ip.v4 = isMulticast ? AllDNSLinkGroup : inItem->hostSet.ip.ip.v4; - dstPort = isMulticast ? MulticastDNSPort : UnicastDNSPort; + dstAddr.ip.v4 = AllDNSLinkGroup; + dstPort = MulticastDNSPort; dlog( kDebugLevelChatty, DEBUG_NAME "packet received\n" ); dlog( kDebugLevelChatty, DEBUG_NAME " size = %d\n", n ); @@ -1676,9 +1659,8 @@ mDNSlocal void TaskProcessPacket( mDNS *inMDNS, MDNSInterfaceItem *inItem, MDNSS // Update counters. - inItem->recvMulticastCounter += isMulticast; - inItem->recvUnicastCounter += !isMulticast; - inItem->recvErrorCounter += ( n < 0 ); + inItem->recvCounter += 1; + inItem->recvErrorCounter += ( n < 0 ); } #if 0 @@ -2010,7 +1992,6 @@ void mDNSShow( BOOL inShowRecords ) printf( " -- interface %u --\n", n ); printf( " name = \"%s\"\n", item->name ); printf( " multicastSocketRef = %d\n", item->multicastSocketRef ); - printf( " unicastSocketRef = %d\n", item->unicastSocketRef ); printf( " sendingSocketRef = %d\n", item->sendingSocketRef ); ip = item->hostSet.ip; printf( " hostSet.ip = %u.%u.%u.%u\n", ip.ip.v4.b[ 0 ], ip.ip.v4.b[ 1 ], @@ -2021,8 +2002,7 @@ void mDNSShow( BOOL inShowRecords ) printf( " sendMulticastCounter = %d\n", item->sendMulticastCounter ); printf( " sendUnicastCounter = %d\n", item->sendUnicastCounter ); printf( " sendErrorCounter = %d\n", item->sendErrorCounter ); - printf( " recvMulticastCounter = %d\n", item->recvMulticastCounter ); - printf( " recvUnicastCounter = %d\n", item->recvUnicastCounter ); + printf( " recvCounter = %d\n", item->recvCounter ); printf( " recvErrorCounter = %d\n", item->recvErrorCounter ); printf( " recvLoopCounter = %d\n", item->recvLoopCounter ); printf( "\n" ); @@ -2046,7 +2026,7 @@ void mDNSShowRecords( void ) MDNSInterfaceItem * item; int n; AuthRecord * record; - char name[ 512 ]; + char name[ MAX_ESCAPED_DOMAIN_NAME ]; printf( "\n-- mDNS resource records --\n" ); n = 1; diff --git a/mDNSWindows/mDNSWin32.c b/mDNSWindows/mDNSWin32.c index 161e635..709574f 100755 --- a/mDNSWindows/mDNSWin32.c +++ b/mDNSWindows/mDNSWin32.c @@ -23,6 +23,15 @@ Change History (most recent first): $Log: mDNSWin32.c,v $ +Revision 1.22.2.1 2004/04/03 05:26:07 bradley +Integrated changes from TOT to remove legacy port 53 support. + +Revision 1.24 2003/10/24 23:23:02 bradley +Removed legacy port 53 support as it is no longer needed. + +Revision 1.23 2003/10/14 03:26:12 bradley +Clear interface list buffer to workaround Windows CE bug where interfaces are not reported correctly. + Revision 1.22 2003/08/20 06:21:25 bradley Updated to latest internal version of the Rendezvous for Windows platform plugin: Added support for Windows CE/PocketPC 2003; re-did interface-related code to emulate getifaddrs/freeifaddrs for @@ -380,7 +389,6 @@ mDNSlocal mStatus SetupInterface( mDNS * const inMDNS, const struct sockaddr_i mDNSlocal mStatus TearDownInterface( mDNS * const inMDNS, mDNSInterfaceData *inIFD ); mDNSlocal mStatus SetupSocket( mDNS * const inMDNS, const struct sockaddr_in * inAddress, - mDNSIPPort inPort, SocketRef * outSocketRef ); mDNSlocal mStatus SetupNotifications( mDNS * const inMDNS ); mDNSlocal mStatus TearDownNotifications( mDNS * const inMDNS ); @@ -544,14 +552,14 @@ mStatus // Send the packet. ifd = (mDNSInterfaceData *) inInterfaceID; - check( IsValidSocket( ifd->multicastSocketRef ) ); + check( IsValidSocket( ifd->sock ) ); addr.sin_family = AF_INET; addr.sin_port = inDstPort.NotAnInteger; addr.sin_addr.s_addr = inDstIP->ip.v4.NotAnInteger; n = (int)( inMsgEnd - ( (const mDNSu8 * const) inMsg ) ); - n = sendto( ifd->multicastSocketRef, (char *) inMsg, n, 0, (struct sockaddr *) &addr, sizeof( addr ) ); + n = sendto( ifd->sock, (char *) inMsg, n, 0, (struct sockaddr *) &addr, sizeof( addr ) ); check_errno( n, errno_compat() ); ifd->sendErrorCounter += ( n < 0 ); @@ -581,25 +589,18 @@ void mDNSPlatformUnlock( const mDNS * const inMDNS ) { check( inMDNS ); check( inMDNS->p ); + check( inMDNS->p->lockInitialized ); check( inMDNS->p->threadID ); - // When an API routine is called, "m->NextScheduledEvent" is reset to "timenow" before calling mDNSPlatformUnlock() - // Since our main mDNS_Execute() loop is on a different thread, we need to wake up that thread to: - // (a) handle immediate work (if any) resulting from this API call - // (b) calculate the next sleep time between now and the next interesting event + // Signal a wakeup event if when called from a task other than the mDNS task since if we are called from mDNS task, + // we'll loop back and call mDNS_Execute anyway. Signaling is needed to re-evaluate the wakeup via mDNS_Execute. - if( ( mDNSPlatformTimeNow() - inMDNS->NextScheduledEvent ) >= 0 ) + if( GetCurrentThreadId() != inMDNS->p->threadID ) { - // We only need to case a wakeup event when called from a task other than the mDNS task since if we are - // called from mDNS task, we'll loop back and call mDNS_Execute. This avoids filling up the command queue. + BOOL wasSet; - if( GetCurrentThreadId() != inMDNS->p->threadID ) - { - BOOL wasSet; - - wasSet = SetEvent( inMDNS->p->wakeupEvent ); - check( wasSet ); - } + wasSet = SetEvent( inMDNS->p->wakeupEvent ); + check( wasSet ); } LeaveCriticalSection( &inMDNS->p->lock ); } @@ -1057,7 +1058,6 @@ mDNSlocal mStatus SetupInterfaceList( mDNS * const inMDNS ) mDNSInterfaceData * ifd; struct ifaddrs * addrs; struct ifaddrs * p; - struct ifaddrs * loopback; u_int flagMask; u_int flagTest; @@ -1086,7 +1086,6 @@ mDNSlocal mStatus SetupInterfaceList( mDNS * const inMDNS ) flagMask = IFF_UP | IFF_MULTICAST | IFF_LOOPBACK | IFF_POINTTOPOINT; flagTest = IFF_UP | IFF_MULTICAST; - loopback = NULL; next = &inMDNS->p->interfaceList; err = getifaddrs( &addrs ); @@ -1178,45 +1177,22 @@ mDNSlocal mStatus SetupInterface( mDNS * const inMDNS, const struct sockaddr_in ifd = (mDNSInterfaceData *) calloc( 1, sizeof( *ifd ) ); require_action( ifd, exit, err = mStatus_NoMemoryErr ); - ifd->multicastSocketRef = kInvalidSocketRef; - ifd->unicastSocketRef = kInvalidSocketRef; - - /// - /// Set up multicast portion of interface. - /// - - // Set up the multicast DNS (port 5353) socket for this interface. - - err = SetupSocket( inMDNS, inAddress, MulticastDNSPort, &socketRef ); - require_noerr( err, exit ); - ifd->multicastSocketRef = socketRef; - - // Set up the read pending event and associate it so we can block until data is available for this socket. + ifd->sock = kInvalidSocketRef; - ifd->multicastReadPendingEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); - require_action( ifd->multicastReadPendingEvent, exit, err = mStatus_NoMemoryErr ); + // Set up a multicast DNS (port 5353) socket for this interface. - err = WSAEventSelect( ifd->multicastSocketRef, ifd->multicastReadPendingEvent, FD_READ ); + err = SetupSocket( inMDNS, inAddress, &socketRef ); require_noerr( err, exit ); - - /// - /// Set up unicast portion of interface. - /// - - // Set up the unicast DNS (port 53) socket for this interface (to handle normal DNS requests). - - err = SetupSocket( inMDNS, inAddress, UnicastDNSPort, &socketRef ); - require_noerr( err, exit ); - ifd->unicastSocketRef = socketRef; + ifd->sock = socketRef; // Set up the read pending event and associate it so we can block until data is available for this socket. - ifd->unicastReadPendingEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); - require_action( ifd->unicastReadPendingEvent, exit, err = mStatus_NoMemoryErr ); + ifd->readPendingEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); + require_action( ifd->readPendingEvent, exit, err = mStatus_NoMemoryErr ); - err = WSAEventSelect( ifd->unicastSocketRef, ifd->unicastReadPendingEvent, FD_READ ); + err = WSAEventSelect( ifd->sock, ifd->readPendingEvent, FD_READ ); require_noerr( err, exit ); - + // Register this interface with mDNS. ifd->hostSet.InterfaceID = (mDNSInterfaceID) ifd; @@ -1275,36 +1251,20 @@ mDNSlocal mStatus TearDownInterface( mDNS * const inMDNS, mDNSInterfaceData *inI // Tear down the multicast socket. - if( inIFD->multicastReadPendingEvent ) + if( inIFD->readPendingEvent ) { - CloseHandle( inIFD->multicastReadPendingEvent ); - inIFD->multicastReadPendingEvent = 0; + CloseHandle( inIFD->readPendingEvent ); + inIFD->readPendingEvent = 0; } - socketRef = inIFD->multicastSocketRef; - inIFD->multicastSocketRef = kInvalidSocketRef; + socketRef = inIFD->sock; + inIFD->sock = kInvalidSocketRef; if( IsValidSocket( socketRef ) ) { - dlog( kDebugLevelVerbose, DEBUG_NAME "tearing down multicast socket %d\n", socketRef ); + dlog( kDebugLevelVerbose, DEBUG_NAME "tearing down socket %d\n", socketRef ); close_compat( socketRef ); } - - // Tear down the unicast socket. - - if( inIFD->unicastReadPendingEvent ) - { - CloseHandle( inIFD->unicastReadPendingEvent ); - inIFD->unicastReadPendingEvent = 0; - } - - socketRef = inIFD->unicastSocketRef; - inIFD->unicastSocketRef = kInvalidSocketRef; - if( IsValidSocket( socketRef ) ) - { - dlog( kDebugLevelVerbose, DEBUG_NAME "tearing down unicast socket %d\n", socketRef ); - close_compat( socketRef ); - } - + // Free the memory used by the interface info. free( inIFD ); @@ -1319,7 +1279,6 @@ mDNSlocal mStatus SetupSocket( mDNS * const inMDNS, const struct sockaddr_in * inAddress, - mDNSIPPort inPort, SocketRef * outSocketRef ) { mStatus err; @@ -1341,37 +1300,27 @@ mDNSlocal mStatus require_action( IsValidSocket( socketRef ), exit, err = mStatus_NoMemoryErr ); // Turn on reuse address option so multiple servers can listen for Multicast DNS packets. - + option = 1; err = setsockopt( socketRef, SOL_SOCKET, SO_REUSEADDR, (char *) &option, sizeof( option ) ); check_errno( err, errno_compat() ); - // Bind to the specified port (53 for unicast or 5353 for multicast). + // Bind to the mutlicast DNS port 5353. ip.NotAnInteger = inAddress->sin_addr.s_addr; memset( &addr, 0, sizeof( addr ) ); addr.sin_family = AF_INET; - addr.sin_port = inPort.NotAnInteger; + addr.sin_port = MulticastDNSPort.NotAnInteger; addr.sin_addr.s_addr = ip.NotAnInteger; err = bind( socketRef, (struct sockaddr *) &addr, sizeof( addr ) ); - if( err && ( inPort.NotAnInteger == UnicastDNSPort.NotAnInteger ) ) - { - // Some systems prevent code without root permissions from binding to the DNS port so ignore this - // error since it is not critical. This should only occur with non-root processes. - - err = 0; - } check_errno( err, errno_compat() ); // Join the all-DNS multicast group so we receive Multicast DNS packets. - if( inPort.NotAnInteger == MulticastDNSPort.NotAnInteger ) - { - mreq.imr_multiaddr.s_addr = AllDNSLinkGroup.NotAnInteger; - mreq.imr_interface.s_addr = ip.NotAnInteger; - err = setsockopt( socketRef, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mreq, sizeof( mreq ) ); - check_errno( err, errno_compat() ); - } + mreq.imr_multiaddr.s_addr = AllDNSLinkGroup.NotAnInteger; + mreq.imr_interface.s_addr = ip.NotAnInteger; + err = setsockopt( socketRef, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mreq, sizeof( mreq ) ); + check_errno( err, errno_compat() ); // Direct multicast packets to the specified interface. @@ -1393,8 +1342,8 @@ mDNSlocal mStatus // Success! - dlog( kDebugLevelVerbose, DEBUG_NAME "setting up socket done (%u.%u.%u.%u:%u, %d)\n", - ip.b[ 0 ], ip.b[ 1 ], ip.b[ 2 ], ip.b[ 3 ], ntohs( inPort.NotAnInteger ), socketRef ); + dlog( kDebugLevelVerbose, DEBUG_NAME "setting up socket done (%u.%u.%u.%u, %d)\n", + ip.b[ 0 ], ip.b[ 1 ], ip.b[ 2 ], ip.b[ 3 ], socketRef ); *outSocketRef = socketRef; socketRef = kInvalidSocketRef; @@ -1635,14 +1584,9 @@ mDNSlocal unsigned WINAPI ProcessingThread( LPVOID inParam ) n = 0; for( ifd = m->p->interfaceList; ifd; ifd = ifd->next ) { - if( ifd->multicastReadPendingEvent == signaledObject ) + if( ifd->readPendingEvent == signaledObject ) { - ProcessingThreadProcessPacket( m, ifd, ifd->multicastSocketRef ); - ++n; - } - if( ifd->unicastReadPendingEvent == signaledObject ) - { - ProcessingThreadProcessPacket( m, ifd, ifd->unicastSocketRef ); + ProcessingThreadProcessPacket( m, ifd, ifd->sock ); ++n; } } @@ -1726,7 +1670,7 @@ mDNSlocal mStatus ProcessingThreadSetupWaitList( mDNS * const inMDNS, HANDLE **o // Allocate an array to hold all the objects to wait on. - waitListCount = kWaitListFixedItemCount + ( 2 * inMDNS->p->interfaceCount ); + waitListCount = kWaitListFixedItemCount + inMDNS->p->interfaceCount; waitList = (HANDLE *) malloc( waitListCount * sizeof( *waitList ) ); require_action( waitList, exit, err = mStatus_NoMemoryErr ); waitItemPtr = waitList; @@ -1741,8 +1685,7 @@ mDNSlocal mStatus ProcessingThreadSetupWaitList( mDNS * const inMDNS, HANDLE **o for( ifd = inMDNS->p->interfaceList; ifd; ifd = ifd->next ) { - *waitItemPtr++ = ifd->multicastReadPendingEvent; - *waitItemPtr++ = ifd->unicastReadPendingEvent; + *waitItemPtr++ = ifd->readPendingEvent; } *outWaitList = waitList; @@ -1766,7 +1709,6 @@ exit: mDNSlocal void ProcessingThreadProcessPacket( mDNS *inMDNS, mDNSInterfaceData *inIFD, SocketRef inSocketRef ) { int n; - mDNSBool isMulticast; DNSMessage packet; struct sockaddr_in addr; int addrSize; @@ -1776,8 +1718,6 @@ mDNSlocal void ProcessingThreadProcessPacket( mDNS *inMDNS, mDNSInterfaceData *i mDNSAddr dstAddr; mDNSIPPort dstPort; - isMulticast = (mDNSBool)( inSocketRef == inIFD->multicastSocketRef ); - // Receive the packet. addrSize = sizeof( addr ); @@ -1791,8 +1731,8 @@ mDNSlocal void ProcessingThreadProcessPacket( mDNS *inMDNS, mDNSInterfaceData *i srcAddr.ip.v4.NotAnInteger = addr.sin_addr.s_addr; srcPort.NotAnInteger = addr.sin_port; dstAddr.type = mDNSAddrType_IPv4; - dstAddr.ip.v4 = isMulticast ? AllDNSLinkGroup : inIFD->hostSet.ip.ip.v4; - dstPort = isMulticast ? MulticastDNSPort : UnicastDNSPort; + dstAddr.ip.v4 = AllDNSLinkGroup; + dstPort = MulticastDNSPort; dlog( kDebugLevelChatty, DEBUG_NAME "packet received\n" ); dlog( kDebugLevelChatty, DEBUG_NAME " size = %d\n", n ); @@ -1816,9 +1756,8 @@ mDNSlocal void ProcessingThreadProcessPacket( mDNS *inMDNS, mDNSInterfaceData *i // Update counters. - inIFD->recvMulticastCounter += isMulticast; - inIFD->recvUnicastCounter += !isMulticast; - inIFD->recvErrorCounter += ( n < 0 ); + inIFD->recvCounter += 1; + inIFD->recvErrorCounter += ( n < 0 ); } //=========================================================================================================================== @@ -1899,7 +1838,7 @@ int getifaddrs( struct ifaddrs **outAddrs ) require_action( size > 0, exit, err = -1 ); size *= 2; - buffer = malloc( size ); + buffer = calloc( 1, size ); require_action( buffer, exit, err = -1 ); // We now know the size of the list and have a buffer to hold so call WSAIoctl again to get it. diff --git a/mDNSWindows/mDNSWin32.h b/mDNSWindows/mDNSWin32.h index 2bf5ddd..499f6a6 100755 --- a/mDNSWindows/mDNSWin32.h +++ b/mDNSWindows/mDNSWin32.h @@ -23,6 +23,12 @@ Change History (most recent first): $Log: mDNSWin32.h,v $ +Revision 1.9.2.1 2004/04/03 05:26:08 bradley +Integrated changes from TOT to remove legacy port 53 support. + +Revision 1.10 2003/10/24 23:23:02 bradley +Removed legacy port 53 support as it is no longer needed. + Revision 1.9 2003/08/20 06:21:25 bradley Updated to latest internal version of the Rendezvous for Windows platform plugin: Added support for Windows CE/PocketPC 2003; re-did interface-related code to emulate getifaddrs/freeifaddrs for @@ -94,10 +100,8 @@ struct mDNSInterfaceData { mDNSInterfaceData * next; char name[ 256 ]; - SocketRef multicastSocketRef; - HANDLE multicastReadPendingEvent; - SocketRef unicastSocketRef; - HANDLE unicastReadPendingEvent; + SocketRef sock; + HANDLE readPendingEvent; NetworkInterfaceInfo hostSet; mDNSBool hostRegistered; @@ -105,8 +109,7 @@ struct mDNSInterfaceData int sendUnicastCounter; int sendErrorCounter; - int recvMulticastCounter; - int recvUnicastCounter; + int recvCounter; int recvErrorCounter; };