mDNSEmbeddedAPI.h revision 4b22b9337f359bfd063322244f5336cc7c6ffcfa
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* -*- Mode: C; tab-width: 4 -*-
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Licensed under the Apache License, Version 2.0 (the "License");
4b22b9337f359bfd063322244f5336cc7c6ffcfars * you may not use this file except in compliance with the License.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * You may obtain a copy of the License at
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * http://www.apache.org/licenses/LICENSE-2.0
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Unless required by applicable law or agreed to in writing, software
4b22b9337f359bfd063322244f5336cc7c6ffcfars * distributed under the License is distributed on an "AS IS" BASIS,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * See the License for the specific language governing permissions and
4b22b9337f359bfd063322244f5336cc7c6ffcfars * limitations under the License.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars NOTE:
4b22b9337f359bfd063322244f5336cc7c6ffcfars If you're building an application that uses DNS Service Discovery
4b22b9337f359bfd063322244f5336cc7c6ffcfars this is probably NOT the header file you're looking for.
4b22b9337f359bfd063322244f5336cc7c6ffcfars In most cases you will want to use /usr/include/dns_sd.h instead.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars This header file defines the lowest level raw interface to mDNSCore,
4b22b9337f359bfd063322244f5336cc7c6ffcfars which is appropriate *only* on tiny embedded systems where everything
4b22b9337f359bfd063322244f5336cc7c6ffcfars runs in a single address space and memory is extremely constrained.
4b22b9337f359bfd063322244f5336cc7c6ffcfars All the APIs here are malloc-free, which means that the caller is
4b22b9337f359bfd063322244f5336cc7c6ffcfars responsible for passing in a pointer to the relevant storage that
4b22b9337f359bfd063322244f5336cc7c6ffcfars will be used in the execution of that call, and (when called with
4b22b9337f359bfd063322244f5336cc7c6ffcfars correct parameters) all the calls are guaranteed to succeed. There
4b22b9337f359bfd063322244f5336cc7c6ffcfars is never a case where a call can suffer intermittent failures because
4b22b9337f359bfd063322244f5336cc7c6ffcfars the implementation calls malloc() and sometimes malloc() returns NULL
4b22b9337f359bfd063322244f5336cc7c6ffcfars because memory is so limited that no more is available.
4b22b9337f359bfd063322244f5336cc7c6ffcfars This is primarily for devices that need to have precisely known fixed
4b22b9337f359bfd063322244f5336cc7c6ffcfars memory requirements, with absolutely no uncertainty or run-time variation,
4b22b9337f359bfd063322244f5336cc7c6ffcfars but that certainty comes at a cost of more difficult programming.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars For applications running on general-purpose desktop operating systems
4b22b9337f359bfd063322244f5336cc7c6ffcfars (Mac OS, Linux, Solaris, Windows, etc.) the API you should use is
4b22b9337f359bfd063322244f5336cc7c6ffcfars /usr/include/dns_sd.h, which defines the API by which multiple
4b22b9337f359bfd063322244f5336cc7c6ffcfars independent client processes communicate their DNS Service Discovery
4b22b9337f359bfd063322244f5336cc7c6ffcfars requests to a single "mdnsd" daemon running in the background.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars Even on platforms that don't run multiple independent processes in
4b22b9337f359bfd063322244f5336cc7c6ffcfars multiple independent address spaces, you can still use the preferred
4b22b9337f359bfd063322244f5336cc7c6ffcfars dns_sd.h APIs by linking in "dnssd_clientshim.c", which implements
4b22b9337f359bfd063322244f5336cc7c6ffcfars the standard "dns_sd.h" API calls, allocates any required storage
4b22b9337f359bfd063322244f5336cc7c6ffcfars using malloc(), and then calls through to the low-level malloc-free
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSCore routines defined here. This has the benefit that even though
4b22b9337f359bfd063322244f5336cc7c6ffcfars you're running on a small embedded system with a single address space,
4b22b9337f359bfd063322244f5336cc7c6ffcfars you can still use the exact same client C code as you'd use on a
4b22b9337f359bfd063322244f5336cc7c6ffcfars general-purpose desktop system.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars Change History (most recent first):
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars$Log: mDNSEmbeddedAPI.h,v $
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.296.2.1 2006/08/29 06:24:22 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRe-licensed mDNSResponder daemon source code under Apache License, Version 2.0
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.296 2006/06/29 05:28:01 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdded comment about mDNSlocal and mDNSexport
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.295 2006/06/29 03:02:43 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/4607042> mDNSResponder NXDOMAIN and CNAME support
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.294 2006/06/28 06:50:08 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsIn future we may want to change definition of mDNSs32 from "signed long" to "signed int"
4b22b9337f359bfd063322244f5336cc7c6ffcfarsI doubt anyone is building mDNSResponder on systems where int is 16-bits,
4b22b9337f359bfd063322244f5336cc7c6ffcfarsbut lets add a compile-time assertion to make sure.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.293 2006/06/12 18:00:43 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsTo make code a little more defensive, check _ILP64 before _LP64,
4b22b9337f359bfd063322244f5336cc7c6ffcfarsin case both are set by mistake on some platforms
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.292 2006/03/19 17:00:57 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDefine symbol MaxMsg instead of using hard-coded constant value '80'
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.291 2006/03/19 02:00:07 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/4073825> Improve logic for delaying packets after repeated interface transitions
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.290 2006/03/08 22:42:23 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix spelling mistake: LocalReverseMapomain -> LocalReverseMapDomain
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.289 2006/02/26 00:54:41 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFixes to avoid code generation warning/error on FreeBSD 7
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.288 2005/12/21 03:24:58 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/4388858> Code changes required to compile on EFI
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.287 2005/10/20 00:10:33 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/4290265> Add check to avoid crashing NAT gateways that have buggy DNS relay code
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.286 2005/09/24 01:09:40 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix comment typos
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.285 2005/09/16 20:57:47 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd macro mDNS_TimeNow_NoLock(m) to get properly adjusted time without also acquiring lock
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.284 2005/07/29 18:04:22 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/4137930> Hostname registration should register IPv6 AAAA record with DNS Update
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.283 2005/05/13 20:45:09 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/4074400> Rapid wide-area txt record updates don't work
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.282 2005/03/16 00:42:32 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/4012279> Long-lived queries not working on Windows
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.281 2005/02/25 17:47:44 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/4021868> SendServiceRegistration fails on wake from sleep
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.280 2005/02/25 04:21:00 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/4015377> mDNS -F returns the same domain multiple times with different casing
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.279 2005/02/17 01:56:14 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsIncrease ifname field to 64 bytes
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.278 2005/02/09 23:38:51 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3993508> Reregister hostname when DNS server changes but IP address does not
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.277 2005/02/09 23:31:12 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3984374> NAT-PMP response callback should return a boolean indicating if the packet matched the request
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.276 2005/02/01 19:33:29 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3985239> Keychain format too restrictive
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.275 2005/01/27 22:57:55 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix compile errors on gcc4
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.274 2005/01/19 21:01:54 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3955355> uDNS needs to support subtype registration and browsing
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.273 2005/01/19 19:15:31 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRefinement to <rdar://problem/3954575> - Simplify mDNS_PurgeResultsForDomain logic and move into daemon layer
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.272 2005/01/18 18:10:55 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3954575> Use 10.4 resolver API to get search domains
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.271 2005/01/15 00:56:41 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3954575> Unicast services don't disappear when logging
4b22b9337f359bfd063322244f5336cc7c6ffcfarsout of VPN
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.270 2005/01/14 18:34:22 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3954571> Services registered outside of firewall don't succeed after location change
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.269 2005/01/11 22:50:52 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFixed constant naming (was using kLLQ_DefLease for update leases)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.268 2004/12/22 22:25:47 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3734265> NATPMP: handle location changes
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.267 2004/12/22 00:13:49 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3873993> Change version, port, and polling interval for LLQ
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.266 2004/12/18 03:13:45 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3751638> kDNSServiceInterfaceIndexLocalOnly should return all local records
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.265 2004/12/17 23:37:45 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3485365> Guard against repeating wireless dissociation/re-association
4b22b9337f359bfd063322244f5336cc7c6ffcfars(and other repetitive configuration changes)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.264 2004/12/17 05:25:46 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3925163> Shorten DNS-SD queries to avoid NAT bugs
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.263 2004/12/16 20:40:25 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix compile warnings
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.262 2004/12/16 20:13:00 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3324626> Cache memory management improvements
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.261 2004/12/14 21:21:20 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3825979> NAT-PMP: Update response format to contain "Seconds Since Boot"
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.260 2004/12/12 23:51:42 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3845683> Wide-area registrations should fallback to using DHCP hostname as target
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.259 2004/12/11 20:55:29 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3916479> Clean up registration state machines
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.258 2004/12/10 20:48:32 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3705229> Need to pick final EDNS numbers for LLQ and GC
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.257 2004/12/10 02:09:23 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3898376> Modify default TTLs
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.256 2004/12/09 03:15:40 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3806610> use _legacy instead of _default to find "empty string" browse domains
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.255 2004/12/07 22:48:37 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsTidying
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.254 2004/12/07 21:26:04 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3908336> DNSServiceRegisterRecord() can crash on deregistration
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.253 2004/12/07 20:42:33 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd explicit context parameter to mDNS_RemoveRecordFromService()
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.252 2004/12/07 03:02:12 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFixed comments, grouped unicast-specific routines together
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.251 2004/12/06 21:15:22 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3884386> mDNSResponder crashed in CheckServiceRegistrations
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.250 2004/12/04 02:12:45 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3517236> mDNSResponder puts LargeCacheRecord on the stack
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.249 2004/12/03 05:18:33 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3810596> mDNSResponder needs to return more specific TSIG errors
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.248 2004/12/02 20:03:48 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3889647> Still publishes wide-area domains even after switching to a local subnet
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.247 2004/12/01 20:57:19 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3873921> Wide Area Service Discovery must be split-DNS aware
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.246 2004/11/29 23:26:32 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdded NonZeroTime() function, which usually returns the value given, with the exception
4b22b9337f359bfd063322244f5336cc7c6ffcfarsthat if the value given is zero, it returns one instead. For timer values where zero is
4b22b9337f359bfd063322244f5336cc7c6ffcfarsused to mean "not set", this can be used to ensure that setting them to the result of an
4b22b9337f359bfd063322244f5336cc7c6ffcfarsinterval computation (e.g. "now+interval") does not inadvertently result in a zero value.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.245 2004/11/25 01:28:09 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3557050> Need to implement random delay for 'QU' unicast replies (and set cache flush bit too)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.244 2004/11/24 22:00:59 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMove definition of mDNSAddressIsAllDNSLinkGroup() from mDNSMacOSX.c to mDNSEmbeddedAPI.h
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.243 2004/11/23 22:43:53 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsTidy up code alignment
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.242 2004/11/23 03:39:46 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsLet interface name/index mapping capability live directly in JNISupport.c,
4b22b9337f359bfd063322244f5336cc7c6ffcfarsinstead of having to call through to the daemon via IPC to get this information.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.241 2004/11/22 17:16:19 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3854298> Unicast services don't disappear when you disable all networking
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.240 2004/11/19 02:32:43 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsWide-Area Security: Add LLQ-ID to events
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.239 2004/11/15 20:09:23 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3719050> Wide Area support for Add/Remove record
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.238 2004/11/12 03:16:48 rpantos
4b22b9337f359bfd063322244f5336cc7c6ffcfarsrdar://problem/3809541 Add mDNSPlatformGetInterfaceByName, mDNSPlatformGetInterfaceName
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.237 2004/11/10 20:40:53 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3868216> LLQ mobility fragile on non-primary interface
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.236 2004/11/01 20:36:11 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3802395> mDNSResponder should not receive Keychain Notifications
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.235 2004/11/01 17:48:14 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsChanged SOA serial number back to signed. RFC 1035 may describe it as "unsigned", but
4b22b9337f359bfd063322244f5336cc7c6ffcfarsit's wrong. The SOA serial is a modular counter, as explained in "DNS & BIND", page
4b22b9337f359bfd063322244f5336cc7c6ffcfars137. Since C doesn't have a modular type, we used signed, C's closest approximation.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.234 2004/10/29 21:59:02 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsSOA serial should be a unsigned integer, as per RFC 1035
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.233 2004/10/28 03:24:41 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRename m->CanReceiveUnicastOn as m->CanReceiveUnicastOn5353
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.232 2004/10/26 06:20:23 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd mDNSAddressIsValidNonZero() macro
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.231 2004/10/26 06:11:41 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd improved logging to aid in diagnosis of <rdar://problem/3842714> mDNSResponder crashed
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.230 2004/10/26 03:52:02 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsUpdate checkin comments
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.229 2004/10/25 19:30:52 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3827956> Simplify dynamic host name structures
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.228 2004/10/23 01:16:00 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3851677> uDNS operations not always reliable on multi-homed hosts
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.227 2004/10/22 20:52:07 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3799260> Create NAT port mappings for Long Lived Queries
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.226 2004/10/20 01:50:40 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3844991> Cannot resolve non-local registrations using the mach API
4b22b9337f359bfd063322244f5336cc7c6ffcfarsImplemented ForceMCast mode for AuthRecords as well as for Questions
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.225 2004/10/19 21:33:17 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3844991> Cannot resolve non-local registrations using the mach API
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdded flag 'kDNSServiceFlagsForceMulticast'. Passing through an interface id for a unicast name
4b22b9337f359bfd063322244f5336cc7c6ffcfarsdoesn't force multicast unless you set this flag to indicate explicitly that this is what you want
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.224 2004/10/16 00:16:59 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3770558> Replace IP TTL 255 check with local subnet source address check
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.223 2004/10/15 23:00:17 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3799242> Need to update LLQs on location changes
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.222 2004/10/12 02:49:20 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3831228> Clean up LLQ sleep/wake, error handling
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.221 2004/10/10 06:57:15 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsChange definition of "localdomain" to make code compile a little smaller
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.220 2004/10/06 01:44:19 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3813936> Resolving too quickly sometimes returns stale TXT record
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.219 2004/10/03 23:18:58 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMove address comparison macros from DNSCommon.h to mDNSEmbeddedAPI.h
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.218 2004/10/03 23:14:12 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd "mDNSEthAddr" type and "zeroEthAddr" constant
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.217 2004/09/30 00:24:56 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3695802> Dynamically update default registration domains on config change
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.216 2004/09/27 23:24:32 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix typo: SOA refresh interval is supposed to be unsigned
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.215 2004/09/26 23:20:35 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3813108> Allow default registrations in multiple wide-area domains
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.214 2004/09/25 02:41:39 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3637266> Deliver near-pending "remove" events before new "add" events
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.213 2004/09/25 02:24:27 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRemoved unused rr->UseCount
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.212 2004/09/24 20:57:39 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3680902> Eliminate inappropriate casts that cause misaligned-address errors
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.211 2004/09/24 20:33:22 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRemove unused DNSDigest_MD5 declaration
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.210 2004/09/23 20:21:07 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3426876> Refine "immediate answer burst; restarting exponential backoff sequence" logic
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAssociate a unique sequence number with each received packet, and only increment the count of recent answer
4b22b9337f359bfd063322244f5336cc7c6ffcfarspackets if the packet sequence number for this answer record is not one we've already seen and counted.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.209 2004/09/23 20:14:39 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRename "question->RecentAnswers" to "question->RecentAnswerPkts"
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.208 2004/09/23 00:50:53 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3419452> Don't send a (DE) if a service is unregistered after wake from sleep
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.207 2004/09/22 02:34:46 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMove definitions of default TTL times from mDNS.c to mDNSEmbeddedAPI.h
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.206 2004/09/22 00:41:59 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMove tcp connection status codes into the legal range allocated for mDNS use
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.205 2004/09/21 23:40:11 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3810349> mDNSResponder to return errors on NAT traversal failure
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.204 2004/09/21 23:29:50 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3680045> DNSServiceResolve should delay sending packets
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.203 2004/09/21 20:58:22 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd ifname field to NetworkInterfaceInfo_struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.202 2004/09/17 00:46:34 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsmDNS_TimeNow should take const mDNS parameter
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.201 2004/09/17 00:31:51 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFor consistency with ipv6, renamed rdata field 'ip' to 'ipv4'
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.200 2004/09/17 00:19:10 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFor consistency with AllDNSLinkGroupv6, rename AllDNSLinkGroup to AllDNSLinkGroupv4
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.199 2004/09/16 21:59:16 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFor consistency with zerov6Addr, rename zeroIPAddr to zerov4Addr
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.198 2004/09/16 21:36:36 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3803162> Fix unsafe use of mDNSPlatformTimeNow()
4b22b9337f359bfd063322244f5336cc7c6ffcfarsChanges to add necessary locking calls around unicast DNS operations
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.197 2004/09/16 00:24:48 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3803162> Fix unsafe use of mDNSPlatformTimeNow()
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.196 2004/09/14 23:42:35 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3801296> Need to seed random number generator from platform-layer data
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.195 2004/09/14 23:27:46 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix compile errors
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.194 2004/09/10 00:49:57 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3787644> Add error code kDNSServiceErr_Firewall, for future use
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.193 2004/09/03 19:23:05 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3788460>: Need retransmission mechanism for wide-area service registrations
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.192 2004/09/02 03:48:47 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3709039> Disable targeted unicast query support by default
4b22b9337f359bfd063322244f5336cc7c6ffcfars1. New flag kDNSServiceFlagsAllowRemoteQuery to indicate we want to allow remote queries for this record
4b22b9337f359bfd063322244f5336cc7c6ffcfars2. New field AllowRemoteQuery in AuthRecord structure
4b22b9337f359bfd063322244f5336cc7c6ffcfars3. uds_daemon.c sets AllowRemoteQuery if kDNSServiceFlagsAllowRemoteQuery is set
4b22b9337f359bfd063322244f5336cc7c6ffcfars4. mDNS.c only answers remote queries if AllowRemoteQuery is set
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.191 2004/08/25 00:37:27 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3774635>: Cleanup DynDNS hostname registration code
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.190 2004/08/18 17:35:41 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3651443>: Feature #9586: Need support for Legacy NAT gateways
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.189 2004/08/14 03:22:41 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3762579> Dynamic DNS UI <-> mDNSResponder glue
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd GetUserSpecifiedDDNSName() routine
4b22b9337f359bfd063322244f5336cc7c6ffcfarsConvert ServiceRegDomain to domainname instead of C string
4b22b9337f359bfd063322244f5336cc7c6ffcfarsReplace mDNS_GenerateFQDN/mDNS_GenerateGlobalFQDN with mDNS_SetFQDNs
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.188 2004/08/13 23:46:58 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars"asyncronous" -> "asynchronous"
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.187 2004/08/13 23:37:02 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsNow that we do both uDNS and mDNS, global replace "uDNS_info.hostname" with
4b22b9337f359bfd063322244f5336cc7c6ffcfars"uDNS_info.UnicastHostname" for clarity
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.186 2004/08/13 23:25:00 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsNow that we do both uDNS and mDNS, global replace "m->hostname" with
4b22b9337f359bfd063322244f5336cc7c6ffcfars"m->MulticastHostname" for clarity
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.185 2004/08/12 00:32:36 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3759567>: LLQ Refreshes never terminate if unanswered
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.184 2004/08/11 17:09:31 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd comment clarifying the applicability of these APIs
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.183 2004/08/10 23:19:14 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3722542>: DNS Extension daemon for Wide Area Service Discovery
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMoved routines/constants to allow extern access for garbage collection daemon
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.182 2004/07/30 17:40:06 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3739115>: TXT Record updates not available for wide-area services
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.181 2004/07/29 19:27:15 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsNATPMP Support - minor fixes and cleanup
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.180 2004/07/29 02:03:35 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDelete unused #define and structure field
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.179 2004/07/26 22:49:30 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3651409>: Feature #9516: Need support for NATPMP in client
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.178 2004/07/13 21:24:24 rpantos
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix for <rdar://problem/3701120>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.177 2004/06/05 00:04:26 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3668639>: wide-area domains should be returned in reg. domain enumeration
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.176 2004/06/04 08:58:29 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3668624>: Keychain integration for secure dynamic update
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.175 2004/06/04 00:15:06 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMove misplaced brackets
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.174 2004/06/03 23:30:16 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRemove extraneous blank lines and white space
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.173 2004/06/03 03:09:58 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3668626>: Garbage Collection for Dynamic Updates
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.172 2004/06/01 23:46:50 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3675149>: DynDNS: dynamically look up LLQ/Update ports
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.171 2004/05/28 23:42:37 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3258021>: Feature: DNS server->client notification on record changes (#7805)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.170 2004/05/18 23:51:25 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsTidy up all checkin comments to use consistent "<rdar://problem/xxxxxxx>" format for bug numbers
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.169 2004/05/13 04:54:20 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsUnified list copy/free code. Added symetric list for
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.168 2004/05/12 22:03:09 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMade GetSearchDomainList a true platform-layer call (declaration moved
4b22b9337f359bfd063322244f5336cc7c6ffcfarsfrom mDNSMacOSX.h to mDNSEmbeddedAPI.h), implemented to return "local"
4b22b9337f359bfd063322244f5336cc7c6ffcfarsonly on non-OSX platforms. Changed call to return a copy of the list
4b22b9337f359bfd063322244f5336cc7c6ffcfarsto avoid shared memory issues. Added a routine to free the list.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.167 2004/04/22 04:07:01 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix from Bob Bradley: Don't try to do inline functions on compilers that don't support it
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.166 2004/04/22 03:15:56 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix use of "struct __attribute__((__packed__))" so it only applies on GCC >= 2.9
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.165 2004/04/22 03:05:28 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarskDNSClass_ANY should be kDNSQClass_ANY
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.164 2004/04/21 02:55:03 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsUpdate comments describing 'InterfaceActive' field
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.163 2004/04/21 02:49:11 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsTo reduce future confusion, renamed 'TxAndRx' to 'McastTxRx'
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.162 2004/04/15 00:51:28 bradley
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMinor tweaks for Windows and C++ builds. Added casts for signed/unsigned integers and 64-bit pointers.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsPrefix some functions with mDNS to avoid conflicts. Disable benign warnings on Microsoft compilers.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.161 2004/04/14 23:09:28 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsSupport for TSIG signed dynamic updates.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.160 2004/04/09 17:40:26 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRemove unnecessary "Multicast" field -- it duplicates the semantics of the existing McastTxRx field
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.159 2004/04/09 16:37:15 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsSuggestion from Bob Bradley:
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMove NumCacheRecordsForInterfaceID() to DNSCommon.c so it's available to all platform layers
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.158 2004/04/02 19:38:33 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsUpdate comment about typical RR TTLs
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.157 2004/04/02 19:35:53 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd clarifying comments about legal mDNSInterfaceID values
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.156 2004/04/02 19:19:48 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd code to do optional logging of multi-packet KA list time intervals
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.155 2004/03/24 00:29:45 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMake it safe to call StopQuery in a unicast question callback
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.154 2004/03/20 01:05:49 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsTest __LP64__ and __ILP64__ to compile properly on a wider range of 64-bit architectures
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.153 2004/03/13 01:57:33 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3192546>: DynDNS: Dynamic update of service records
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.152 2004/03/09 02:27:16 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRemove erroneous underscore in 'packed_struct' (makes no difference now, but might in future)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.151 2004/03/02 03:21:56 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3549576> Properly support "_services._dns-sd._udp" meta-queries
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.150 2004/02/21 02:06:24 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsCan't use anonymous unions -- they're non-standard and don't work on all compilers
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.149 2004/02/06 23:04:19 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsBasic Dynamic Update support via mDNS_Register (dissabled via
4b22b9337f359bfd063322244f5336cc7c6ffcfarsUNICAST_REGISTRATION #define)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.148 2004/02/03 19:47:36 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdded an asynchronous state machine mechanism to uDNS.c, including
4b22b9337f359bfd063322244f5336cc7c6ffcfarscalls to find the parent zone for a domain name. Changes include code
4b22b9337f359bfd063322244f5336cc7c6ffcfarsin repository previously dissabled via "#if 0 incomplete". Codepath
4b22b9337f359bfd063322244f5336cc7c6ffcfarsis currently unused, and will be called to create update records, etc.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.147 2004/02/03 18:57:35 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsUpdate comment for "IsLocalDomain()"
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.146 2004/01/30 02:20:24 bradley
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMap inline to __inline when building with Microsoft C compilers since they do not support C99 inline.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.145 2004/01/29 02:59:17 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsUnicast DNS: Changed from a resource record oriented question/response
4b22b9337f359bfd063322244f5336cc7c6ffcfarsmatching to packet based matching. New callback architecture allows
4b22b9337f359bfd063322244f5336cc7c6ffcfarscollections of records in a response to be processed differently
4b22b9337f359bfd063322244f5336cc7c6ffcfarsdepending on the nature of the request, and allows the same structure
4b22b9337f359bfd063322244f5336cc7c6ffcfarsto be used for internal and client-driven queries with different processing needs.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.144 2004/01/28 20:20:45 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsUnified ActiveQueries and ActiveInternalQueries lists, using a flag to
4b22b9337f359bfd063322244f5336cc7c6ffcfarsdemux them. Check-in includes work-in-progress code, #ifdef'd out.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.143 2004/01/28 03:41:00 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3541946>: Need ability to do targeted queries as well as multicast queries
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.142 2004/01/28 02:30:07 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdded default Search Domains to unicast browsing, controlled via
4b22b9337f359bfd063322244f5336cc7c6ffcfarsNetworking sharing prefs pane. Stopped sending unicast messages on
4b22b9337f359bfd063322244f5336cc7c6ffcfarsevery interface. Fixed unicast resolving via mach-port API.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.141 2004/01/27 20:15:22 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3541288>: Time to prune obsolete code for listening on port 53
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.140 2004/01/24 23:37:08 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAt Kiren's suggestion, made functions to convert mDNSOpaque16s to/from integer values
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.139 2004/01/24 08:46:26 bradley
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdded InterfaceID<->Index platform interfaces since they are now used by all platforms for the DNS-SD APIs.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.138 2004/01/24 04:59:15 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFixes so that Posix/Linux, OS9, Windows, and VxWorks targets build again
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.137 2004/01/24 03:40:56 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMove mDNSAddrIsDNSMulticast() from DNSCommon.h to mDNSEmbeddedAPI.h so clients can use it
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.136 2004/01/24 03:38:27 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix minor syntactic error: Headers should use "extern" declarations, not "mDNSexport"
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.135 2004/01/23 23:23:15 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdded TCP support for truncated unicast messages.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.134 2004/01/22 03:54:11 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsCreate special meta-interface 'mDNSInterface_ForceMCast' (-2),
4b22b9337f359bfd063322244f5336cc7c6ffcfarswhich means "do this query via multicast, even if it's apparently a unicast domain"
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.133 2004/01/22 03:48:41 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMake sure uDNS client doesn't accidentally use query ID zero
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.132 2004/01/22 03:43:08 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsExport constants like mDNSInterface_LocalOnly so that the client layers can use them
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.131 2004/01/21 21:53:18 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3448144>: Don't try to receive unicast responses if we're not the first to bind to the UDP port
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.130 2003/12/14 05:05:29 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd comments explaining mDNS_Init_NoCache and mDNS_Init_ZeroCacheSize
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.129 2003/12/13 03:05:27 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3192548>: DynDNS: Unicast query of service records
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.128 2003/12/01 21:44:23 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd mStatus_BadInterfaceErr = -65552 for consistency with dns_sd.h
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.127 2003/12/01 18:26:37 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAlso pack the OpaqueXX union types. Otherwise, on some systems, mDNSOpaque16 is four bytes!
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.126 2003/12/01 18:23:48 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3464646>: Scalar size problem in mDNS code on some 64-bit architectures
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.125 2003/11/22 00:18:27 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd compile-time asserts to verify correct sizes of mDNSu32, mDNSOpaque16, etc.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.124 2003/11/20 22:59:54 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsChanged runtime checks in mDNS.c to be compile-time checks in mDNSEmbeddedAPI.h
4b22b9337f359bfd063322244f5336cc7c6ffcfarsThanks to Bob Bradley for suggesting the ingenious compiler trick to make this work.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.123 2003/11/20 22:53:01 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd comment about MAX_ESCAPED_DOMAIN_LABEL
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.122 2003/11/20 20:49:53 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAnother fix from HP: Use packedstruct macro to ensure proper packing for on-the-wire packet structures
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.121 2003/11/20 05:01:38 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsUpdate comments; add explanation of Advertise/DontAdvertiseLocalAddresses
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.120 2003/11/14 20:59:08 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsClients can't use AssignDomainName macro because mDNSPlatformMemCopy is defined in mDNSPlatformFunctions.h.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsBest solution is just to combine mDNSEmbeddedAPI.h and mDNSPlatformFunctions.h into a single file.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.119 2003/11/14 19:47:52 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDefine symbol MAX_ESCAPED_DOMAIN_NAME to indicate recommended buffer size for ConvertDomainNameToCString
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.118 2003/11/14 19:18:34 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMove AssignDomainName macro to mDNSEmbeddedAPI.h to that client layers can use it too
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.117 2003/11/08 23:32:24 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsGave name to anonymous struct, to avoid errors on certain compilers.
4b22b9337f359bfd063322244f5336cc7c6ffcfars(Thanks to ramaprasad.kr@hp.com for reporting this.)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.116 2003/11/07 03:32:56 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3472153> mDNSResponder delivers answers in inconsistent order
4b22b9337f359bfd063322244f5336cc7c6ffcfarsThis is the real fix. Checkin 1.312 was overly simplistic; Calling GetFreeCacheRR() can sometimes
4b22b9337f359bfd063322244f5336cc7c6ffcfarspurge records from the cache, causing tail pointer *rp to be stale on return. The correct fix is
4b22b9337f359bfd063322244f5336cc7c6ffcfarsto maintain a system-wide tail pointer for each cache slot, and then if neccesary GetFreeCacheRR()
4b22b9337f359bfd063322244f5336cc7c6ffcfarscan update this pointer, so that mDNSCoreReceiveResponse() appends records in the right place.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.115 2003/09/23 00:53:54 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsNumFailedProbes should be unsigned
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.114 2003/08/29 19:44:15 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3400967> Traffic reduction: Eliminate synchronized QUs when a new service appears
4b22b9337f359bfd063322244f5336cc7c6ffcfars1. Use m->RandomQueryDelay to impose a random delay in the range 0-500ms on queries
4b22b9337f359bfd063322244f5336cc7c6ffcfars that already have at least one unique answer in the cache
4b22b9337f359bfd063322244f5336cc7c6ffcfars2. For these queries, go straight to QM, skipping QU
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.113 2003/08/21 19:31:58 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsCosmetic: Swap order of fields
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.112 2003/08/21 19:27:36 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3387878> Traffic reduction: No need to announce record for longer than TTL
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.111 2003/08/21 02:21:50 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3386473> Efficiency: Reduce repeated queries
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.110 2003/08/20 23:39:31 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3344098> Review syslog messages, and remove as appropriate
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.109 2003/08/19 22:24:10 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsComment change
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.108 2003/08/19 22:20:00 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3376721> Don't use IPv6 on interfaces that have a routable IPv4 address configured
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMore minor refinements
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.107 2003/08/19 06:48:25 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3376552> Guard against excessive record updates
4b22b9337f359bfd063322244f5336cc7c6ffcfarsEach record starts with 10 UpdateCredits.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsEvery update consumes one UpdateCredit.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsUpdateCredits are replenished at a rate of one one per minute, up to a maximum of 10.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAs the number of UpdateCredits declines, the number of announcements is similarly scaled back.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsWhen fewer than 5 UpdateCredits remain, the first announcement is also delayed by an increasing amount.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.106 2003/08/19 04:49:28 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3368159> Interaction between v4, v6 and dual-stack hosts not working quite right
4b22b9337f359bfd063322244f5336cc7c6ffcfars1. A dual-stack host should only suppress its own query if it sees the same query from other hosts on BOTH IPv4 and IPv6.
4b22b9337f359bfd063322244f5336cc7c6ffcfars2. When we see the first v4 (or first v6) member of a group, we re-trigger questions and probes on that interface.
4b22b9337f359bfd063322244f5336cc7c6ffcfars3. When we see the last v4 (or v6) member of a group go away, we revalidate all the records received on that interface.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.105 2003/08/19 02:33:37 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsUpdate comments
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.104 2003/08/19 02:31:11 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3378386> mDNSResponder overenthusiastic with final expiration queries
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFinal expiration queries now only mark the question for sending on the particular interface
4b22b9337f359bfd063322244f5336cc7c6ffcfarspertaining to the record that's expiring.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.103 2003/08/18 19:05:44 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3382423> UpdateRecord not working right
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdded "newrdlength" field to hold new length of updated rdata
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.102 2003/08/16 03:39:00 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3338440> InterfaceID -1 indicates "local only"
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.101 2003/08/15 20:16:02 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3366590> mDNSResponder takes too much RPRVT
4b22b9337f359bfd063322244f5336cc7c6ffcfarsWe want to avoid touching the rdata pages, so we don't page them in.
4b22b9337f359bfd063322244f5336cc7c6ffcfars1. RDLength was stored with the rdata, which meant touching the page just to find the length.
4b22b9337f359bfd063322244f5336cc7c6ffcfars Moved this from the RData to the ResourceRecord object.
4b22b9337f359bfd063322244f5336cc7c6ffcfars2. To avoid unnecessarily touching the rdata just to compare it,
4b22b9337f359bfd063322244f5336cc7c6ffcfars compute a hash of the rdata and store the hash in the ResourceRecord object.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.100 2003/08/14 19:29:04 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3378473> Include cache records in SIGINFO output
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMoved declarations of DNSTypeName() and GetRRDisplayString to mDNSEmbeddedAPI.h so daemon.c can use them
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.99 2003/08/14 02:17:05 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3375491> Split generic ResourceRecord type into two separate types: AuthRecord and CacheRecord
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.98 2003/08/12 19:56:23 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsUpdate to APSL 2.0
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.97 2003/08/12 14:59:27 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3374490> Rate-limiting blocks some legitimate responses
4b22b9337f359bfd063322244f5336cc7c6ffcfarsWhen setting LastMCTime also record LastMCInterface. When checking LastMCTime to determine
4b22b9337f359bfd063322244f5336cc7c6ffcfarswhether to suppress the response, also check LastMCInterface to see if it matches.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.96 2003/08/12 13:57:04 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3323817> Improve cache performance
4b22b9337f359bfd063322244f5336cc7c6ffcfarsChanged the number of hash table slots from 37 to 499
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.95 2003/08/09 00:55:02 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3366553> mDNSResponder is taking 20-30% of the CPU
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDon't scan the whole cache after every packet.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.94 2003/08/09 00:35:29 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.93 2003/08/08 18:55:48 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3370365> Guard against time going backwards
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.92 2003/08/08 18:36:04 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3344154> Only need to revalidate on interface removal on platforms that have the PhantomInterfaces bug
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.91 2003/08/06 21:33:39 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix compiler warnings on PocketPC 2003 (Windows CE)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.90 2003/08/06 20:30:17 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd structure definition for rdataMX (not currently used, but good to have it for completeness)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.89 2003/08/06 18:58:19 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsUpdate comments
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.88 2003/07/24 23:45:44 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsTo eliminate compiler warnings, changed definition of mDNSBool from
4b22b9337f359bfd063322244f5336cc7c6ffcfars"unsigned char" to "int", since "int" is in fact truly the type that C uses
4b22b9337f359bfd063322244f5336cc7c6ffcfarsfor the result of comparison operators (a<b) and logical operators (a||b)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.87 2003/07/22 23:57:20 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMove platform-layer function prototypes from mDNSEmbeddedAPI.h to mDNSPlatformFunctions.h where they belong
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.86 2003/07/20 03:52:02 ksekar
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3320722>: Feature: New DNS-SD APIs (#7875) (mDNSResponder component)
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdded error type for incompatibility between daemon and client versions
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.85 2003/07/19 03:23:13 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/2986147> mDNSResponder needs to receive and cache larger records
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.84 2003/07/18 23:52:12 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsTo improve consistency of field naming, global search-and-replace:
4b22b9337f359bfd063322244f5336cc7c6ffcfarsNextProbeTime -> NextScheduledProbe
4b22b9337f359bfd063322244f5336cc7c6ffcfarsNextResponseTime -> NextScheduledResponse
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.83 2003/07/18 00:29:59 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3268878> Remove mDNSResponder version from packet header and use HINFO record instead
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.82 2003/07/17 17:35:04 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3325583> Rate-limit responses, to guard against packet flooding
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.81 2003/07/16 05:01:36 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd fields 'LargeAnswers' and 'ExpectUnicastResponse' in preparation for
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3315761> Need to implement "unicast response" request, using top bit of qclass
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.80 2003/07/15 01:55:12 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3315777> Need to implement service registration with subtypes
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.79 2003/07/13 02:28:00 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3325166> SendResponses didn't all its responses
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDelete all references to RRInterfaceActive -- it's now superfluous
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.78 2003/07/13 01:47:53 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix one error and one warning in the Windows build
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.77 2003/07/11 01:32:38 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsSyntactic cleanup (no change to funcationality): Now that we only have one host name,
4b22b9337f359bfd063322244f5336cc7c6ffcfarsrename field "hostname1" to "hostname", and field "RR_A1" to "RR_A".
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.76 2003/07/11 01:28:00 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3161289> No more local.arpa
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.75 2003/07/02 21:19:45 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3313413> Update copyright notices, etc., in source code comments
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.74 2003/07/02 02:41:23 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/2986146> mDNSResponder needs to start with a smaller cache and then grow it as needed
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.73 2003/06/10 04:24:39 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3283637> React when we observe other people query unsuccessfully for a record that's in our cache
4b22b9337f359bfd063322244f5336cc7c6ffcfarsSome additional refinements:
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDon't try to do this for unicast-response queries
4b22b9337f359bfd063322244f5336cc7c6ffcfarsbetter tracking of Qs and KAs in multi-packet KA lists
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.72 2003/06/10 01:46:27 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd better comments explaining how these data structures are intended to be used from the client layer
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.71 2003/06/07 06:45:05 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3283666> No need for multiple machines to all be sending the same queries
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.70 2003/06/07 04:50:53 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3283637> React when we observe other people query unsuccessfully for a record that's in our cache
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.69 2003/06/07 04:22:17 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd MsgBuffer for error log and debug messages
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.68 2003/06/07 01:46:38 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3283540> When query produces zero results, call mDNS_Reconfirm() on any antecedent records
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.67 2003/06/07 01:22:14 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3283516> mDNSResponder needs an mDNS_Reconfirm() function
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.66 2003/06/07 00:59:43 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3283454> Need some randomness to spread queries on the network
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.65 2003/06/06 21:41:11 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFor consistency, mDNS_StopQuery() should return an mStatus result, just like all the other mDNSCore routines
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.64 2003/06/06 21:38:55 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRenamed 'NewData' as 'FreshData' (The data may not be new data, just a refresh of data that we
4b22b9337f359bfd063322244f5336cc7c6ffcfarsalready had in our cache. This refreshes our TTL on the data, but the data itself stays the same.)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.63 2003/06/06 17:20:14 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFor clarity, rename question fields name/rrtype/rrclass as qname/qtype/qclass
4b22b9337f359bfd063322244f5336cc7c6ffcfars(Global search-and-replace; no functional change to code execution.)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.62 2003/06/04 01:25:33 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3274950> Cannot perform multi-packet known-answer suppression messages
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDisplay time interval between first and subsequent queries
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.61 2003/06/03 05:02:16 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3277080> Duplicate registrations not handled as efficiently as they should be
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.60 2003/05/31 00:09:49 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3274862> Add ability to discover what services are on a network
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.59 2003/05/29 06:11:35 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3272214>: Report if there appear to be too many "Resolve" callbacks
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.58 2003/05/29 05:48:06 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMinor fix for when generating printf warnings: mDNS_snprintf arguments are now 3,4
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.57 2003/05/26 03:21:27 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsTidy up address structure naming:
4b22b9337f359bfd063322244f5336cc7c6ffcfarsmDNSIPAddr => mDNSv4Addr (for consistency with mDNSv6Addr)
4b22b9337f359bfd063322244f5336cc7c6ffcfarsmDNSAddr.addr.ipv4 => mDNSAddr.ip.v4
4b22b9337f359bfd063322244f5336cc7c6ffcfarsmDNSAddr.addr.ipv6 => mDNSAddr.ip.v6
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.56 2003/05/26 03:01:27 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3268904> sprintf/vsprintf-style functions are unsafe; use snprintf/vsnprintf instead
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.55 2003/05/26 00:47:30 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsComment clarification
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.54 2003/05/24 16:39:48 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3268631> SendResponses also needs to handle multihoming better
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.53 2003/05/23 02:15:37 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFixed misleading use of the term "duplicate suppression" where it should have
4b22b9337f359bfd063322244f5336cc7c6ffcfarssaid "known answer suppression". (Duplicate answer suppression is something
4b22b9337f359bfd063322244f5336cc7c6ffcfarsdifferent, and duplicate question suppression is yet another thing, so the use
4b22b9337f359bfd063322244f5336cc7c6ffcfarsof the completely vague term "duplicate suppression" was particularly bad.)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.52 2003/05/22 02:29:22 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/2984918> SendQueries needs to handle multihoming better
4b22b9337f359bfd063322244f5336cc7c6ffcfarsComplete rewrite of SendQueries. Works much better now :-)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.51 2003/05/21 20:14:55 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix comments and warnings
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.50 2003/05/14 07:08:36 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3159272> mDNSResponder should be smarter about reconfigurations
4b22b9337f359bfd063322244f5336cc7c6ffcfarsPreviously, when there was any network configuration change, mDNSResponder
4b22b9337f359bfd063322244f5336cc7c6ffcfarswould tear down the entire list of active interfaces and start again.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsThat was very disruptive, and caused the entire cache to be flushed,
4b22b9337f359bfd063322244f5336cc7c6ffcfarsand caused lots of extra network traffic. Now it only removes interfaces
4b22b9337f359bfd063322244f5336cc7c6ffcfarsthat have really gone, and only adds new ones that weren't there before.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.49 2003/05/07 01:49:36 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRemove "const" in ConstructServiceName prototype
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.48 2003/05/07 00:18:44 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix typo: "kDNSQClass_Mask" should be "kDNSClass_Mask"
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.47 2003/05/06 00:00:46 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3248914> Rationalize naming of domainname manipulation functions
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.46 2003/04/30 20:39:09 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd comment
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.45 2003/04/29 00:40:50 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix compiler warnings
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.44 2003/04/26 02:41:56 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3241281> Change timenow from a local variable to a structure member
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.43 2003/04/25 01:45:56 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3240002> mDNS_RegisterNoSuchService needs to include a host name
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.42 2003/04/15 20:58:31 jgraessl
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3229014> Added a hash to lookup records in the cache.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.41 2003/04/15 18:09:13 jgraessl
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3228892>
4b22b9337f359bfd063322244f5336cc7c6ffcfarsReviewed by: Stuart Cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdded code to keep track of when the next cache item will expire so we can
4b22b9337f359bfd063322244f5336cc7c6ffcfarscall TidyRRCache only when necessary.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.40 2003/03/29 01:55:19 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3212360> mDNSResponder sometimes suffers false self-conflicts when it sees its own packets
4b22b9337f359bfd063322244f5336cc7c6ffcfarsSolution: Major cleanup of packet timing and conflict handling rules
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.39 2003/03/27 03:30:55 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3210018> Name conflicts not handled properly, resulting in memory corruption, and eventual crash
4b22b9337f359bfd063322244f5336cc7c6ffcfarsProblem was that HostNameCallback() was calling mDNS_DeregisterInterface(), which is not safe in a callback
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFixes:
4b22b9337f359bfd063322244f5336cc7c6ffcfars1. Make mDNS_DeregisterInterface() safe to call from a callback
4b22b9337f359bfd063322244f5336cc7c6ffcfars2. Make HostNameCallback() use mDNS_DeadvertiseInterface() instead
4b22b9337f359bfd063322244f5336cc7c6ffcfars (it never really needed to deregister the interface at all)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.38 2003/03/15 04:40:36 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsChange type called "mDNSOpaqueID" to the more descriptive name "mDNSInterfaceID"
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.37 2003/03/14 21:34:11 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3176950> Can't setup and print to Lexmark PS printers via Airport Extreme
4b22b9337f359bfd063322244f5336cc7c6ffcfarsIncrease size of cache rdata from 512 to 768
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.36 2003/03/05 03:38:35 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3185731> Bogus error message in console: died or deallocated, but no record of client can be found!
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFixed by leaving client in list after conflict, until client explicitly deallocates
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.35 2003/02/21 02:47:54 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3099194> mDNSResponder needs performance improvements
4b22b9337f359bfd063322244f5336cc7c6ffcfarsSeveral places in the code were calling CacheRRActive(), which searched the entire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsquestion list every time, to see if this cache resource record answers any question.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsInstead, we now have a field "CRActiveQuestion" in the resource record structure
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.34 2003/02/21 01:54:08 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3099194> mDNSResponder needs performance improvements
4b22b9337f359bfd063322244f5336cc7c6ffcfarsSwitched to using new "mDNS_Execute" model (see "Implementer Notes.txt")
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.33 2003/02/20 06:48:32 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3169535> Xserve RAID needs to do interface-specific registrations
4b22b9337f359bfd063322244f5336cc7c6ffcfarsReviewed by: Josh Graessley, Bob Bradley
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.32 2003/01/31 03:35:59 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3147097> mDNSResponder sometimes fails to find the correct results
4b22b9337f359bfd063322244f5336cc7c6ffcfarsWhen there were *two* active questions in the list, they were incorrectly
4b22b9337f359bfd063322244f5336cc7c6ffcfarsfinding *each other* and *both* being marked as duplicates of another question
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.31 2003/01/29 02:46:37 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsFix for IPv6:
4b22b9337f359bfd063322244f5336cc7c6ffcfarsA physical interface is identified solely by its InterfaceID (not by IP and type).
4b22b9337f359bfd063322244f5336cc7c6ffcfarsOn a given InterfaceID, mDNSCore may send both v4 and v6 multicasts.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsIn cases where the requested outbound protocol (v4 or v6) is not supported on
4b22b9337f359bfd063322244f5336cc7c6ffcfarsthat InterfaceID, the platform support layer should simply discard that packet.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.30 2003/01/29 01:47:08 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRename 'Active' to 'CRActive' or 'InterfaceActive' for improved clarity
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.29 2003/01/28 05:23:43 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3147097> mDNSResponder sometimes fails to find the correct results
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdd 'Active' flag for interfaces
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.28 2003/01/28 01:35:56 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevise comment about ThisQInterval to reflect new semantics
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.27 2003/01/13 23:49:42 jgraessl
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMerged changes for the following fixes in to top of tree:
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3086540> computer name changes not handled properly
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3124348> service name changes are not properly handled
4b22b9337f359bfd063322244f5336cc7c6ffcfars<rdar://problem/3124352> announcements sent in pairs, failing chattiness test
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.26 2002/12/23 22:13:28 jgraessl
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsReviewed by: Stuart Cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsInitial IPv6 support for mDNSResponder.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.25 2002/09/21 20:44:49 zarzycki
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdded APSL info
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.24 2002/09/19 23:47:35 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsAdded mDNS_RegisterNoSuchService() function for assertion of non-existence
4b22b9337f359bfd063322244f5336cc7c6ffcfarsof a particular named service
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.23 2002/09/19 21:25:34 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsmDNS_snprintf() doesn't need to be in a separate file
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.22 2002/09/19 04:20:43 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRemove high-ascii characters that confuse some systems
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.21 2002/09/17 01:06:35 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsChange mDNS_AdvertiseLocalAddresses to be a parameter to mDNS_Init()
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsRevision 1.20 2002/09/16 18:41:41 cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfarsMerge in license terms from Quinn's copy, in preparation for Darwin release
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars*/
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma ident "%Z%%M% %I% %E% SMI"
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifndef __mDNSClientAPI_h
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define __mDNSClientAPI_h
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if defined(EFI32) || defined(EFI64)
4b22b9337f359bfd063322244f5336cc7c6ffcfars// EFI doesn't have stdarg.h
4b22b9337f359bfd063322244f5336cc7c6ffcfars#include "Tiano.h"
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define va_list VA_LIST
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define va_start(a, b) VA_START(a, b)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define va_end(a) VA_END(a)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define va_arg(a, b) VA_ARG(a, b)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#else
4b22b9337f359bfd063322244f5336cc7c6ffcfars#include <stdarg.h> // stdarg.h is required for for va_list support for the mDNS_vsnprintf declaration
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#include "mDNSDebug.h"
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifdef __cplusplus
4b22b9337f359bfd063322244f5336cc7c6ffcfars extern "C" {
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Function scope indicators
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// If you see "mDNSlocal" before a function name in a C file, it means the function is not callable outside this file
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifndef mDNSlocal
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSlocal static
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars// If you see "mDNSexport" before a symbol in a C file, it means the symbol is exported for use by clients
4b22b9337f359bfd063322244f5336cc7c6ffcfars// For every "mDNSexport" in a C file, there needs to be a corresponding "extern" declaration in some header file
4b22b9337f359bfd063322244f5336cc7c6ffcfars// (When a C file #includes a header file, the "extern" declarations tell the compiler:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// "This symbol exists -- but not necessarily in this C file.")
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifndef mDNSexport
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSexport
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Explanation: These local/export markers are a little habit of mine for signaling the programmers' intentions.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// When "mDNSlocal" is just a synonym for "static", and "mDNSexport" is a complete no-op, you could be
4b22b9337f359bfd063322244f5336cc7c6ffcfars// forgiven for asking what purpose they serve. The idea is that if you see "mDNSexport" in front of a
4b22b9337f359bfd063322244f5336cc7c6ffcfars// function definition it means the programmer intended it to be exported and callable from other files
4b22b9337f359bfd063322244f5336cc7c6ffcfars// in the project. If you see "mDNSlocal" in front of a function definition it means the programmer
4b22b9337f359bfd063322244f5336cc7c6ffcfars// intended it to be private to that file. If you see neither in front of a function definition it
4b22b9337f359bfd063322244f5336cc7c6ffcfars// means the programmer forgot (so you should work out which it is supposed to be, and fix it).
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Using "mDNSlocal" instead of "static" makes it easier to do a textual searches for one or the other.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// For example you can do a search for "static" to find if any functions declare any local variables as "static"
4b22b9337f359bfd063322244f5336cc7c6ffcfars// (generally a bad idea unless it's also "const", because static storage usually risks being non-thread-safe)
4b22b9337f359bfd063322244f5336cc7c6ffcfars// without the results being cluttered with hundreds of matches for functions declared static.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// - Stuart Cheshire
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Structure packing macro
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// If we're not using GNUC, it's not fatal.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Most compilers naturally pack the on-the-wire structures correctly anyway, so a plain "struct" is usually fine.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// In the event that structures are not packed correctly, mDNS_Init() will detect this and report an error, so the
4b22b9337f359bfd063322244f5336cc7c6ffcfars// developer will know what's wrong, and can investigate what needs to be done on that compiler to provide proper packing.
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifndef packedstruct
4b22b9337f359bfd063322244f5336cc7c6ffcfars #if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 9)))
4b22b9337f359bfd063322244f5336cc7c6ffcfars #define packedstruct struct __attribute__((__packed__))
4b22b9337f359bfd063322244f5336cc7c6ffcfars #define packedunion union __attribute__((__packed__))
4b22b9337f359bfd063322244f5336cc7c6ffcfars #else
4b22b9337f359bfd063322244f5336cc7c6ffcfars #define packedstruct struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars #define packedunion union
4b22b9337f359bfd063322244f5336cc7c6ffcfars #endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - DNS Resource Record class and type constants
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef enum // From RFC 1035
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSClass_IN = 1, // Internet
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSClass_CS = 2, // CSNET
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSClass_CH = 3, // CHAOS
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSClass_HS = 4, // Hesiod
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSClass_NONE = 254, // Used in DNS UPDATE [RFC 2136]
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSClass_Mask = 0x7FFF,// Multicast DNS uses the bottom 15 bits to identify the record class...
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSClass_UniqueRRSet = 0x8000,// ... and the top bit indicates that all other cached records are now invalid
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSQClass_ANY = 255, // Not a DNS class, but a DNS query class, meaning "all classes"
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSQClass_UnicastResponse = 0x8000 // Top bit set in a question means "unicast response acceptable"
4b22b9337f359bfd063322244f5336cc7c6ffcfars } DNS_ClassValues;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef enum // From RFC 1035
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_A = 1, // 1 Address
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_NS, // 2 Name Server
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_MD, // 3 Mail Destination
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_MF, // 4 Mail Forwarder
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_CNAME, // 5 Canonical Name
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_SOA, // 6 Start of Authority
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_MB, // 7 Mailbox
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_MG, // 8 Mail Group
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_MR, // 9 Mail Rename
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_NULL, // 10 NULL RR
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_WKS, // 11 Well-known-service
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_PTR, // 12 Domain name pointer
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_HINFO, // 13 Host information
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_MINFO, // 14 Mailbox information
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_MX, // 15 Mail Exchanger
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_TXT, // 16 Arbitrary text string
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_AAAA = 28, // 28 IPv6 address
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_SRV = 33, // 33 Service record
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_OPT = 41, // EDNS0 OPT record
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSType_TSIG = 250, // 250 Transaction Signature
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSQType_ANY = 255 // Not a DNS type, but a DNS query type, meaning "all types"
4b22b9337f359bfd063322244f5336cc7c6ffcfars } DNS_TypeValues;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - Simple types
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNS defines its own names for these common types to simplify portability across
4b22b9337f359bfd063322244f5336cc7c6ffcfars// multiple platforms that may each have their own (different) names for these types.
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef int mDNSBool;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef signed char mDNSs8;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef unsigned char mDNSu8;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef signed short mDNSs16;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef unsigned short mDNSu16;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// <http://gcc.gnu.org/onlinedocs/gcc-3.3.3/cpp/Common-Predefined-Macros.html> says
4b22b9337f359bfd063322244f5336cc7c6ffcfars// __LP64__ _LP64
4b22b9337f359bfd063322244f5336cc7c6ffcfars// These macros are defined, with value 1, if (and only if) the compilation is
4b22b9337f359bfd063322244f5336cc7c6ffcfars// for a target where long int and pointer both use 64-bits and int uses 32-bit.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// <http://www.intel.com/software/products/compilers/clin/docs/ug/lin1077.htm> says
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Macro Name __LP64__ Value 1
4b22b9337f359bfd063322244f5336cc7c6ffcfars// A quick Google search for "defined(__LP64__)" OR "#ifdef __LP64__" gives 2590 hits and
4b22b9337f359bfd063322244f5336cc7c6ffcfars// a search for "#if __LP64__" gives only 12, so I think we'll go with the majority and use defined()
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if defined(_ILP64) || defined(__ILP64__)
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef signed int32 mDNSs32;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef unsigned int32 mDNSu32;
4b22b9337f359bfd063322244f5336cc7c6ffcfars#elif defined(_LP64) || defined(__LP64__)
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef signed int mDNSs32;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef unsigned int mDNSu32;
4b22b9337f359bfd063322244f5336cc7c6ffcfars#else
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef signed long mDNSs32;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef unsigned long mDNSu32;
4b22b9337f359bfd063322244f5336cc7c6ffcfars//typedef signed int mDNSs32;
4b22b9337f359bfd063322244f5336cc7c6ffcfars//typedef unsigned int mDNSu32;
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// To enforce useful type checking, we make mDNSInterfaceID be a pointer to a dummy struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars// This way, mDNSInterfaceIDs can be assigned, and compared with each other, but not with other types
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Declaring the type to be the typical generic "void *" would lack this type checking
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct mDNSInterfaceID_dummystruct { void *dummy; } *mDNSInterfaceID;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// These types are for opaque two- and four-byte identifiers.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The "NotAnInteger" fields of the unions allow the value to be conveniently passed around in a
4b22b9337f359bfd063322244f5336cc7c6ffcfars// register for the sake of efficiency, and compared for equality or inequality, but don't forget --
4b22b9337f359bfd063322244f5336cc7c6ffcfars// just because it is in a register doesn't mean it is an integer. Operations like greater than,
4b22b9337f359bfd063322244f5336cc7c6ffcfars// less than, add, multiply, increment, decrement, etc., are undefined for opaque identifiers,
4b22b9337f359bfd063322244f5336cc7c6ffcfars// and if you make the mistake of trying to do those using the NotAnInteger field, then you'll
4b22b9337f359bfd063322244f5336cc7c6ffcfars// find you get code that doesn't work consistently on big-endian and little-endian machines.
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedunion { mDNSu8 b[ 2]; mDNSu16 NotAnInteger; } mDNSOpaque16;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedunion { mDNSu8 b[ 4]; mDNSu32 NotAnInteger; } mDNSOpaque32;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedunion { mDNSu8 b[ 6]; mDNSu16 w[3]; mDNSu32 l[1]; } mDNSOpaque48;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedunion { mDNSu8 b[16]; mDNSu16 w[8]; mDNSu32 l[4]; } mDNSOpaque128;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef mDNSOpaque16 mDNSIPPort; // An IP port is a two-byte opaque identifier (not an integer)
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef mDNSOpaque32 mDNSv4Addr; // An IP address is a four-byte opaque identifier (not an integer)
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef mDNSOpaque128 mDNSv6Addr; // An IPv6 address is a 16-byte opaque identifier (not an integer)
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef mDNSOpaque48 mDNSEthAddr; // An Ethernet address is a six-byte opaque identifier (not an integer)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsenum
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddrType_None = 0,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddrType_IPv4 = 4,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddrType_IPv6 = 6,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddrType_Unknown = ~0 // Special marker value used in known answer list recording
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 type;
4b22b9337f359bfd063322244f5336cc7c6ffcfars union { mDNSv6Addr v6; mDNSv4Addr v4; } ip;
4b22b9337f359bfd063322244f5336cc7c6ffcfars } mDNSAddr;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsenum { mDNSfalse = 0, mDNStrue = 1 };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSNULL 0L
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsenum
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_Waiting = 1,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_NoError = 0,
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // mDNS return values are in the range FFFE FF00 (-65792) to FFFE FFFF (-65537)
4b22b9337f359bfd063322244f5336cc7c6ffcfars // The top end of the range (FFFE FFFF) is used for error codes;
4b22b9337f359bfd063322244f5336cc7c6ffcfars // the bottom end of the range (FFFE FF00) is used for non-error values;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Error codes:
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_UnknownErr = -65537, // First value: 0xFFFE FFFF
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_NoSuchNameErr = -65538,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_NoMemoryErr = -65539,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_BadParamErr = -65540,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_BadReferenceErr = -65541,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_BadStateErr = -65542,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_BadFlagsErr = -65543,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_UnsupportedErr = -65544,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_NotInitializedErr = -65545,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_NoCache = -65546,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_AlreadyRegistered = -65547,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_NameConflict = -65548,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_Invalid = -65549,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_Firewall = -65550,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_Incompatible = -65551,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_BadInterfaceErr = -65552,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_Refused = -65553,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_NoSuchRecord = -65554,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_NoAuth = -65555,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_NoSuchKey = -65556,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_NATTraversal = -65557,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_DoubleNAT = -65558,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_BadTime = -65559,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_BadSig = -65560, // while we define this per RFC 2845, BIND 9 returns Refused for bad/missing signatures
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_BadKey = -65561,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_TransientErr = -65562, // transient failures, e.g. sending packets shortly after a network transition or wake from sleep
4b22b9337f359bfd063322244f5336cc7c6ffcfars // -65563 to -65786 currently unused; available for allocation
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // tcp connection status
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_ConnPending = -65787,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_ConnFailed = -65788,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_ConnEstablished = -65789,
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Non-error values:
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_GrowCache = -65790,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_ConfigChanged = -65791,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus_MemFree = -65792 // Last value: 0xFFFE FF00
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // mStatus_MemFree is the last legal mDNS error code, at the end of the range allocated for mDNS
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef mDNSs32 mStatus;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// RFC 1034/1035 specify that a domain label consists of a length byte plus up to 63 characters
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define MAX_DOMAIN_LABEL 63
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct { mDNSu8 c[ 64]; } domainlabel; // One label: length byte and up to 63 characters
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// RFC 1034/1035 specify that a domain name, including length bytes, data bytes, and terminating zero, may be up to 255 bytes long
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define MAX_DOMAIN_NAME 255
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct { mDNSu8 c[256]; } domainname; // Up to 255 bytes of length-prefixed domainlabels
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct { mDNSu8 c[256]; } UTF8str255; // Null-terminated C string
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The longest legal textual form of a DNS name is 1005 bytes, including the C-string terminating NULL at the end.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Explanation:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// When a native domainname object is converted to printable textual form using ConvertDomainNameToCString(),
4b22b9337f359bfd063322244f5336cc7c6ffcfars// non-printing characters are represented in the conventional DNS way, as '\ddd', where ddd is a three-digit decimal number.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The longest legal domain name is 255 bytes, in the form of four labels as shown below:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Length byte, 63 data bytes, length byte, 63 data bytes, length byte, 63 data bytes, length byte, 61 data bytes, zero byte.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Each label is encoded textually as characters followed by a trailing dot.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// If every character has to be represented as a four-byte escape sequence, then this makes the maximum textual form four labels
4b22b9337f359bfd063322244f5336cc7c6ffcfars// plus the C-string terminating NULL as shown below:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// 63*4+1 + 63*4+1 + 63*4+1 + 61*4+1 + 1 = 1005.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Note that MAX_ESCAPED_DOMAIN_LABEL is not normally used: If you're only decoding a single label, escaping is usually not required.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// It is for domain names, where dots are used as label separators, that proper escaping is vital.
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define MAX_ESCAPED_DOMAIN_LABEL 254
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define MAX_ESCAPED_DOMAIN_NAME 1005
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Most records have a TTL of 75 minutes, so that their 80% cache-renewal query occurs once per hour.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// For records containing a hostname (in the name on the left, or in the rdata on the right),
4b22b9337f359bfd063322244f5336cc7c6ffcfars// like A, AAAA, reverse-mapping PTR, and SRV, we use a two-minute TTL by default, because we don't want
4b22b9337f359bfd063322244f5336cc7c6ffcfars// them to hang around for too long in the cache if the host in question crashes or otherwise goes away.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Wide-area service discovery records have a very short TTL to avoid poluting intermediate caches with
4b22b9337f359bfd063322244f5336cc7c6ffcfars// dynamic records. When discovered via Long Lived Queries (with change notifications), resource record
4b22b9337f359bfd063322244f5336cc7c6ffcfars// TTLs can be safely ignored.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kStandardTTL (3600UL * 100 / 80)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kHostNameTTL 120UL
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kWideAreaTTL 3
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define DefaultTTLforRRType(X) (((X) == kDNSType_A || (X) == kDNSType_AAAA || (X) == kDNSType_SRV) ? kHostNameTTL : kStandardTTL)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - DNS Message structures
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_numZones numQuestions
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_numPrereqs numAnswers
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_numUpdates numAuthorities
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedstruct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque16 id;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque16 flags;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 numQuestions;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 numAnswers;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 numAuthorities;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 numAdditionals;
4b22b9337f359bfd063322244f5336cc7c6ffcfars } DNSMessageHeader;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// We can send and receive packets up to 9000 bytes (Ethernet Jumbo Frame size, if that ever becomes widely used)
4b22b9337f359bfd063322244f5336cc7c6ffcfars// However, in the normal case we try to limit packets to 1500 bytes so that we don't get IP fragmentation on standard Ethernet
4b22b9337f359bfd063322244f5336cc7c6ffcfars// 40 (IPv6 header) + 8 (UDP header) + 12 (DNS message header) + 1440 (DNS message body) = 1500 total
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define AbsoluteMaxDNSMessageData 8940
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define NormalMaxDNSMessageData 1440
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedstruct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSMessageHeader h; // Note: Size 12 bytes
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 data[AbsoluteMaxDNSMessageData]; // 40 (IPv6) + 8 (UDP) + 12 (DNS header) + 8940 (data) = 9000
4b22b9337f359bfd063322244f5336cc7c6ffcfars } DNSMessage;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - Resource Record structures
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Authoritative Resource Records:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// There are four basic types: Shared, Advisory, Unique, Known Unique
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// * Shared Resource Records do not have to be unique
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- Shared Resource Records are used for DNS-SD service PTRs
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- It is okay for several hosts to have RRs with the same name but different RDATA
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- We use a random delay on responses to reduce collisions when all the hosts respond to the same query
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- These RRs typically have moderately high TTLs (e.g. one hour)
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- These records are announced on startup and topology changes for the benefit of passive listeners
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- These records send a goodbye packet when deregistering
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// * Advisory Resource Records are like Shared Resource Records, except they don't send a goodbye packet
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// * Unique Resource Records should be unique among hosts within any given mDNS scope
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- The majority of Resource Records are of this type
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- If two entities on the network have RRs with the same name but different RDATA, this is a conflict
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- Responses may be sent immediately, because only one host should be responding to any particular query
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- These RRs typically have low TTLs (e.g. a few minutes)
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- On startup and after topology changes, a host issues queries to verify uniqueness
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// * Known Unique Resource Records are treated like Unique Resource Records, except that mDNS does
4b22b9337f359bfd063322244f5336cc7c6ffcfars// not have to verify their uniqueness because this is already known by other means (e.g. the RR name
4b22b9337f359bfd063322244f5336cc7c6ffcfars// is derived from the host's IP or Ethernet address, which is already known to be a unique identifier).
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Summary of properties of different record types:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Probe? Does this record type send probes before announcing?
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Conflict? Does this record type react if we observe an apparent conflict?
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Goodbye? Does this record type send a goodbye packet on departure?
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Probe? Conflict? Goodbye? Notes
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Unregistered Should not appear in any list (sanity check value)
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Shared No No Yes e.g. Service PTR record
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Deregistering No No Yes Shared record about to announce its departure and leave the list
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Advisory No No No
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Unique Yes Yes No Record intended to be unique -- will probe to verify
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Verified Yes Yes No Record has completed probing, and is verified unique
4b22b9337f359bfd063322244f5336cc7c6ffcfars// KnownUnique No Yes No Record is assumed by other means to be unique
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Valid lifecycle of a record:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Unregistered -> Shared -> Deregistering -(goodbye)-> Unregistered
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Unregistered -> Advisory -> Unregistered
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Unregistered -> Unique -(probe)-> Verified -> Unregistered
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Unregistered -> KnownUnique -> Unregistered
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Each Authoritative kDNSRecordType has only one bit set. This makes it easy to quickly see if a record
4b22b9337f359bfd063322244f5336cc7c6ffcfars// is one of a particular set of types simply by performing the appropriate bitwise masking operation.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Cache Resource Records (received from the network):
4b22b9337f359bfd063322244f5336cc7c6ffcfars// There are four basic types: Answer, Unique Answer, Additional, Unique Additional
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Bit 7 (the top bit) of kDNSRecordType is always set for Cache Resource Records; always clear for Authoritative Resource Records
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Bit 6 (value 0x40) is set for answer records; clear for additional records
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Bit 5 (value 0x20) is set for records received with the kDNSClass_UniqueRRSet
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsenum
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypeUnregistered = 0x00, // Not currently in any list
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypeDeregistering = 0x01, // Shared record about to announce its departure and leave the list
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypeUnique = 0x02, // Will become a kDNSRecordTypeVerified when probing is complete
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypeAdvisory = 0x04, // Like Shared, but no goodbye packet
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypeShared = 0x08, // Shared means record name does not have to be unique -- use random delay on responses
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypeVerified = 0x10, // Unique means mDNS should check that name is unique (and then send immediate responses)
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypeKnownUnique = 0x20, // Known Unique means mDNS can assume name is unique without checking
4b22b9337f359bfd063322244f5336cc7c6ffcfars // For Dynamic Update records, Known Unique means the record must already exist on the server.
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypeUniqueMask = (kDNSRecordTypeUnique | kDNSRecordTypeVerified | kDNSRecordTypeKnownUnique),
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypeActiveMask = (kDNSRecordTypeAdvisory | kDNSRecordTypeShared | kDNSRecordTypeVerified | kDNSRecordTypeKnownUnique),
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypePacketAdd = 0x80, // Received in the Additional Section of a DNS Response
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypePacketAddUnique = 0x90, // Received in the Additional Section of a DNS Response with kDNSClass_UniqueRRSet set
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypePacketAuth = 0xA0, // Received in the Authorities Section of a DNS Response
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypePacketAuthUnique = 0xB0, // Received in the Authorities Section of a DNS Response with kDNSClass_UniqueRRSet set
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypePacketAns = 0xC0, // Received in the Answer Section of a DNS Response
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypePacketAnsUnique = 0xD0, // Received in the Answer Section of a DNS Response with kDNSClass_UniqueRRSet set
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypePacketAnsMask = 0x40, // True for PacketAns and PacketAnsUnique
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSRecordTypePacketUniqueMask = 0x10 // True for PacketAddUnique, PacketAnsUnique, PacketAuthUnique
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedstruct { mDNSu16 priority; mDNSu16 weight; mDNSIPPort port; domainname target; } rdataSRV;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedstruct { mDNSu16 preference; domainname exchange; } rdataMX;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedstruct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname mname;
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname rname;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 serial; // Modular counter; increases when zone changes
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 refresh; // Time in seconds that a slave waits after successful replication of the database before it attempts replication again
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 retry; // Time in seconds that a slave waits after an unsuccessful replication attempt before it attempts replication again
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 expire; // Time in seconds that a slave holds on to old data while replication attempts remain unsuccessful
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 min; // Nominally the minimum record TTL for this zone, in seconds; also used for negative caching.
4b22b9337f359bfd063322244f5336cc7c6ffcfars } rdataSOA;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedstruct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 vers;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 llqOp;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 err;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 id[8];
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 lease;
4b22b9337f359bfd063322244f5336cc7c6ffcfars } LLQOptData;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define LLQ_OPTLEN ((3 * sizeof(mDNSu16)) + 8 + sizeof(mDNSu32))
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Windows adds pad bytes to sizeof(LLQOptData). Use this macro when setting length fields or validating option rdata from
4b22b9337f359bfd063322244f5336cc7c6ffcfars// off the wire. Use sizeof(LLQOptData) when dealing with structures (e.g. memcpy). Never memcpy between on-the-wire
4b22b9337f359bfd063322244f5336cc7c6ffcfars// representation and a structure
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// NOTE: rdataOpt format may be repeated an arbitrary number of times in a single resource record
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedstruct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 opt;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 optlen;
4b22b9337f359bfd063322244f5336cc7c6ffcfars union { LLQOptData llq; mDNSu32 lease; } OptData;
4b22b9337f359bfd063322244f5336cc7c6ffcfars } rdataOpt;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// StandardAuthRDSize is 264 (256+8), which is large enough to hold a maximum-sized SRV record
4b22b9337f359bfd063322244f5336cc7c6ffcfars// MaximumRDSize is 8K the absolute maximum we support (at least for now)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define StandardAuthRDSize 264
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define MaximumRDSize 8192
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// InlineCacheRDSize is 68
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Records received from the network with rdata this size or less have their rdata stored right in the CacheRecord object
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Records received from the network with rdata larger than this have additional storage allocated for the rdata
4b22b9337f359bfd063322244f5336cc7c6ffcfars// A quick unscientific sample from a busy network at Apple with lots of machines revealed this:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// 1461 records in cache
4b22b9337f359bfd063322244f5336cc7c6ffcfars// 292 were one-byte TXT records
4b22b9337f359bfd063322244f5336cc7c6ffcfars// 136 were four-byte A records
4b22b9337f359bfd063322244f5336cc7c6ffcfars// 184 were sixteen-byte AAAA records
4b22b9337f359bfd063322244f5336cc7c6ffcfars// 780 were various PTR, TXT and SRV records from 12-64 bytes
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Only 69 records had rdata bigger than 64 bytes
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Note that since CacheRecord object and a CacheGroup object are allocated out of the same pool, it's sensible to
4b22b9337f359bfd063322244f5336cc7c6ffcfars// have them both be the same size. Making one smaller without making the other smaller won't actually save any memory.
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define InlineCacheRDSize 68
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define InlineCacheGroupNameSize 144
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef union
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 data[StandardAuthRDSize];
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSv4Addr ipv4; // For 'A' record
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSv6Addr ipv6; // For 'AAAA' record
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname name; // For PTR, NS, and CNAME records
4b22b9337f359bfd063322244f5336cc7c6ffcfars UTF8str255 txt; // For TXT record
4b22b9337f359bfd063322244f5336cc7c6ffcfars rdataSRV srv; // For SRV record
4b22b9337f359bfd063322244f5336cc7c6ffcfars rdataMX mx; // For MX record
4b22b9337f359bfd063322244f5336cc7c6ffcfars rdataSOA soa; // For SOA record
4b22b9337f359bfd063322244f5336cc7c6ffcfars rdataOpt opt; // For eDNS0 opt record
4b22b9337f359bfd063322244f5336cc7c6ffcfars } RDataBody;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 MaxRDLength; // Amount of storage allocated for rdata (usually sizeof(RDataBody))
4b22b9337f359bfd063322244f5336cc7c6ffcfars RDataBody u;
4b22b9337f359bfd063322244f5336cc7c6ffcfars } RData;
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define sizeofRDataHeader (sizeof(RData) - sizeof(RDataBody))
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct AuthRecord_struct AuthRecord;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct CacheRecord_struct CacheRecord;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct CacheGroup_struct CacheGroup;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct DNSQuestion_struct DNSQuestion;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct mDNS_struct mDNS;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct mDNS_PlatformSupport_struct mDNS_PlatformSupport;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct NATTraversalInfo_struct NATTraversalInfo;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Note: Within an mDNSRecordCallback mDNS all API calls are legal except mDNS_Init(), mDNS_Close(), mDNS_Execute()
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef void mDNSRecordCallback(mDNS *const m, AuthRecord *const rr, mStatus result);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Note:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Restrictions: An mDNSRecordUpdateCallback may not make any mDNS API calls.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The intent of this callback is to allow the client to free memory, if necessary.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The internal data structures of the mDNS code may not be in a state where mDNS API calls may be made safely.
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef void mDNSRecordUpdateCallback(mDNS *const m, AuthRecord *const rr, RData *OldRData);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 RecordType; // See enum above
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSInterfaceID InterfaceID; // Set if this RR is specific to one interface
4b22b9337f359bfd063322244f5336cc7c6ffcfars // For records received off the wire, InterfaceID is *always* set to the receiving interface
4b22b9337f359bfd063322244f5336cc7c6ffcfars // For our authoritative records, InterfaceID is usually zero, except for those few records
4b22b9337f359bfd063322244f5336cc7c6ffcfars // that are interface-specific (e.g. address records, especially linklocal addresses)
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname *name;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 rrtype;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 rrclass;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 rroriginalttl; // In seconds
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 rdlength; // Size of the raw rdata, in bytes
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 rdestimate; // Upper bound on size of rdata after name compression
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 namehash; // Name-based (i.e. case-insensitive) hash of name
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 rdatahash; // For rdata containing domain name (e.g. PTR, SRV, CNAME etc.), case-insensitive name hash
4b22b9337f359bfd063322244f5336cc7c6ffcfars // else, for all other rdata, 32-bit hash of the raw rdata
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Note: This requirement is important. Various routines like AddAdditionalsToResponseList(),
4b22b9337f359bfd063322244f5336cc7c6ffcfars // ReconfirmAntecedents(), etc., use rdatahash as a pre-flight check to see
4b22b9337f359bfd063322244f5336cc7c6ffcfars // whether it's worth doing a full SameDomainName() call. If the rdatahash
4b22b9337f359bfd063322244f5336cc7c6ffcfars // is not a correct case-insensitive name hash, they'll get false negatives.
4b22b9337f359bfd063322244f5336cc7c6ffcfars RData *rdata; // Pointer to storage for this rdata
4b22b9337f359bfd063322244f5336cc7c6ffcfars } ResourceRecord;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Unless otherwise noted, states may apply to either independent record registrations or service registrations
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef enum
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_FetchingZoneData = 1, // getting info - update not sent
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_Pending = 2, // update sent, reply not received
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_Registered = 3, // update sent, reply received
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_DeregPending = 4, // dereg sent, reply not received
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_DeregDeferred = 5, // dereg requested while in Pending state - send dereg AFTER registration is confirmed
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_Cancelled = 6, // update not sent, reg. cancelled by client
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_Unregistered = 8, // not in any list
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_Refresh = 9, // outstanding refresh (or target change) message
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_NATMap = 10, // establishing NAT port mapping or learning public address
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_UpdatePending = 11, // update in flight as result of mDNS_Update call
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_NoTarget = 12, // service registration pending registration of hostname (ServiceRegistrations only)
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_ExtraQueued = 13, // extra record to be registered upon completion of service registration (RecordRegistrations only)
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_NATError = 14 // unable to complete NAT traversal
4b22b9337f359bfd063322244f5336cc7c6ffcfars } regState_t;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// context for both ServiceRecordSet and individual AuthRec structs
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars // registration/lease state
4b22b9337f359bfd063322244f5336cc7c6ffcfars regState_t state;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool lease; // dynamic update contains (should contain) lease option
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 expire; // expiration of lease (-1 for static)
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool TestForSelfConflict; // on name conflict, check if we're just seeing our own orphaned records
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // identifier to match update request and response
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque16 id;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // server info
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname zone; // the zone that is updated
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddr ns; // primary name server for the record's zone !!!KRS not technically correct to cache longer than TTL
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSIPPort port; // port on which server accepts dynamic updates
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // NAT traversal context
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATTraversalInfo *NATinfo; // may be NULL
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // state for deferred operations
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool ClientCallbackDeferred; // invoke client callback on completion of pending operation(s)
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus DeferredStatus; // status to deliver when above flag is set
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool SRVUpdateDeferred; // do we need to change target or port once current operation completes?
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool SRVChanged; // temporarily deregistered service because its SRV target or port changed
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // uDNS_UpdateRecord support fields
4b22b9337f359bfd063322244f5336cc7c6ffcfars RData *OrigRData; mDNSu16 OrigRDLen; // previously registered, being deleted
4b22b9337f359bfd063322244f5336cc7c6ffcfars RData *InFlightRData; mDNSu16 InFlightRDLen; // currently being registered
4b22b9337f359bfd063322244f5336cc7c6ffcfars RData *QueuedRData; mDNSu16 QueuedRDLen; // if the client call Update while an update is in flight, we must finish the
4b22b9337f359bfd063322244f5336cc7c6ffcfars // pending operation (re-transmitting if necessary) THEN register the queued update
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSRecordUpdateCallback *UpdateRDCallback; // client callback to free old rdata
4b22b9337f359bfd063322244f5336cc7c6ffcfars } uDNS_RegInfo;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsstruct AuthRecord_struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars // For examples of how to set up this structure for use in mDNS_Register(),
4b22b9337f359bfd063322244f5336cc7c6ffcfars // see mDNS_AdvertiseInterface() or mDNS_RegisterService().
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Basically, resrec and persistent metadata need to be set up before calling mDNS_Register().
4b22b9337f359bfd063322244f5336cc7c6ffcfars // mDNS_SetupResourceRecord() is avaliable as a helper routine to set up most fields to sensible default values for you
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *next; // Next in list; first element of structure for efficiency reasons
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Field Group 1: Common ResourceRecord fields
4b22b9337f359bfd063322244f5336cc7c6ffcfars ResourceRecord resrec;
4b22b9337f359bfd063322244f5336cc7c6ffcfars uDNS_RegInfo uDNS_info;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Field Group 2: Persistent metadata for Authoritative Records
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *Additional1; // Recommended additional record to include in response
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *Additional2; // Another additional
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *DependentOn; // This record depends on another for its uniqueness checking
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *RRSet; // This unique record is part of an RRSet
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSRecordCallback *RecordCallback; // Callback function to call for state changes, and to free memory asynchronously on deregistration
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *RecordContext; // Context parameter for the callback function
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 HostTarget; // Set if the target of this record (PTR, CNAME, SRV, etc.) is our host name
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 AllowRemoteQuery; // Set if we allow hosts not on the local link to query this record
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 ForceMCast; // Set by client to advertise solely via multicast, even for apparently unicast names
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Field Group 3: Transient state for Authoritative Records
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 Acknowledged; // Set if we've given the success callback to the client
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 ProbeCount; // Number of probes remaining before this record is valid (kDNSRecordTypeUnique)
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 AnnounceCount; // Number of announcements remaining (kDNSRecordTypeShared)
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 RequireGoodbye; // Set if this RR has been announced on the wire and will require a goodbye packet
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 LocalAnswer; // Set if this RR has been delivered to LocalOnly questions
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 IncludeInProbe; // Set if this RR is being put into a probe right now
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSInterfaceID ImmedAnswer; // Someone on this interface issued a query we need to answer (all-ones for all interfaces)
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 ImmedUnicast; // Set if we may send our response directly via unicast to the requester
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if MDNS_LOG_ANSWER_SUPPRESSION_TIMES
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 ImmedAnswerMarkTime;
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSInterfaceID ImmedAdditional; // Hint that we might want to also send this record, just to be helpful
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSInterfaceID SendRNow; // The interface this query is being sent on right now
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSv4Addr v4Requester; // Recent v4 query for this record, or all-ones if more than one recent query
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSv6Addr v6Requester; // Recent v6 query for this record, or all-ones if more than one recent query
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *NextResponse; // Link to the next element in the chain of responses to generate
4b22b9337f359bfd063322244f5336cc7c6ffcfars const mDNSu8 *NR_AnswerTo; // Set if this record was selected by virtue of being a direct answer to a question
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *NR_AdditionalTo; // Set if this record was selected by virtue of being additional to another
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 ThisAPInterval; // In platform time units: Current interval for announce/probe
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 AnnounceUntil; // In platform time units: Creation time + TTL
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 LastAPTime; // In platform time units: Last time we sent announcement/probe
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 LastMCTime; // Last time we multicast this record (used to guard against packet-storm attacks)
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSInterfaceID LastMCInterface; // Interface this record was multicast on at the time LastMCTime was recorded
4b22b9337f359bfd063322244f5336cc7c6ffcfars RData *NewRData; // Set if we are updating this record with new rdata
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 newrdlength; // ... and the length of the new RData
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSRecordUpdateCallback *UpdateCallback;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 UpdateCredits; // Token-bucket rate limiting of excessive updates
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 NextUpdateCredit; // Time next token is added to bucket
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 UpdateBlocked; // Set if update delaying is in effect
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname namestorage;
4b22b9337f359bfd063322244f5336cc7c6ffcfars RData rdatastorage; // Normally the storage is right here, except for oversized records
4b22b9337f359bfd063322244f5336cc7c6ffcfars // rdatastorage MUST be the last thing in the structure -- when using oversized AuthRecords, extra bytes
4b22b9337f359bfd063322244f5336cc7c6ffcfars // are appended after the end of the AuthRecord, logically augmenting the size of the rdatastorage
4b22b9337f359bfd063322244f5336cc7c6ffcfars // DO NOT ADD ANY MORE FIELDS HERE
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Wrapper struct for Auth Records for higher-level code that cannot use the AuthRecord's ->next pointer field
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct ARListElem
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars struct ARListElem *next;
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord ar; // Note: Must be last struct in field to accomodate oversized AuthRecords
4b22b9337f359bfd063322244f5336cc7c6ffcfars } ARListElem;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsstruct CacheGroup_struct // Header object for a list of CacheRecords with the same name
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars CacheGroup *next; // Next CacheGroup object in this hash table bucket
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 namehash; // Name-based (i.e. case insensitive) hash of name
4b22b9337f359bfd063322244f5336cc7c6ffcfars CacheRecord *members; // List of CacheRecords with this same name
4b22b9337f359bfd063322244f5336cc7c6ffcfars CacheRecord **rrcache_tail; // Tail end of that list
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname *name; // Common name for all CacheRecords in this list
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 namestorage[InlineCacheGroupNameSize];
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsstruct CacheRecord_struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars CacheRecord *next; // Next in list; first element of structure for efficiency reasons
4b22b9337f359bfd063322244f5336cc7c6ffcfars ResourceRecord resrec;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Transient state for Cache Records
4b22b9337f359bfd063322244f5336cc7c6ffcfars CacheRecord *NextInKAList; // Link to the next element in the chain of known answers to send
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 TimeRcvd; // In platform time units
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 DelayDelivery; // Set if we want to defer delivery of this answer to local clients
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 NextRequiredQuery; // In platform time units
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 LastUsed; // In platform time units
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion *CRActiveQuestion; // Points to an active question referencing this answer
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 UnansweredQueries; // Number of times we've issued a query for this record without getting an answer
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 LastUnansweredTime; // In platform time units; last time we incremented UnansweredQueries
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 MPUnansweredQ; // Multi-packet query handling: Number of times we've seen a query for this record
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 MPLastUnansweredQT; // Multi-packet query handling: Last time we incremented MPUnansweredQ
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 MPUnansweredKA; // Multi-packet query handling: Number of times we've seen this record in a KA list
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool MPExpectingKA; // Multi-packet query handling: Set when we increment MPUnansweredQ; allows one KA
4b22b9337f359bfd063322244f5336cc7c6ffcfars CacheRecord *NextInCFList; // Set if this is in the list of records we just received with the cache flush bit set
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars struct { mDNSu16 MaxRDLength; mDNSu8 data[InlineCacheRDSize]; } rdatastorage; // Storage for small records is right here
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Storage sufficient to hold either a CacheGroup header or a CacheRecord
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef union CacheEntity_union CacheEntity;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsunion CacheEntity_union { CacheEntity *next; CacheGroup cg; CacheRecord cr; };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars CacheRecord r;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 _extradata[MaximumRDSize-InlineCacheRDSize]; // Glue on the necessary number of extra bytes
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname namestorage; // Needs to go *after* the extra rdata bytes
4b22b9337f359bfd063322244f5336cc7c6ffcfars } LargeCacheRecord;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct uDNS_HostnameInfo
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars struct uDNS_HostnameInfo *next;
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname fqdn;
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *arv4; // registered IPv4 address record
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *arv6; // registered IPv6 address record
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSRecordCallback *StatusCallback; // callback to deliver success or error code to client layer
4b22b9337f359bfd063322244f5336cc7c6ffcfars const void *StatusContext; // Client Context
4b22b9337f359bfd063322244f5336cc7c6ffcfars } uDNS_HostnameInfo;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsenum
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSServer_Untested = 0,
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSServer_Failed = 1,
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSServer_Passed = 2
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct DNSServer
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars struct DNSServer *next;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddr addr;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool del; // Set when we're planning to delete this from the list
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 teststate; // Have we sent bug-detection query to this server?
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname domain; // name->server matching for "split dns"
4b22b9337f359bfd063322244f5336cc7c6ffcfars } DNSServer;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct NetworkInterfaceInfo_struct NetworkInterfaceInfo;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// A NetworkInterfaceInfo_struct serves two purposes:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// 1. It holds the address, PTR and HINFO records to advertise a given IP address on a given physical interface
4b22b9337f359bfd063322244f5336cc7c6ffcfars// 2. It tells mDNSCore which physical interfaces are available; each physical interface has its own unique InterfaceID.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Since there may be multiple IP addresses on a single physical interface,
4b22b9337f359bfd063322244f5336cc7c6ffcfars// there may be multiple NetworkInterfaceInfo_structs with the same InterfaceID.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// In this case, to avoid sending the same packet n times, when there's more than one
4b22b9337f359bfd063322244f5336cc7c6ffcfars// struct with the same InterfaceID, mDNSCore picks one member of the set to be the
4b22b9337f359bfd063322244f5336cc7c6ffcfars// active representative of the set; all others have the 'InterfaceActive' flag unset.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsstruct NetworkInterfaceInfo_struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Internal state fields. These are used internally by mDNSCore; the client layer needn't be concerned with them.
4b22b9337f359bfd063322244f5336cc7c6ffcfars NetworkInterfaceInfo *next;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool InterfaceActive; // Set if interface is sending & receiving packets (see comment above)
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool IPv4Available; // If InterfaceActive, set if v4 available on this InterfaceID
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool IPv6Available; // If InterfaceActive, set if v6 available on this InterfaceID
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Standard AuthRecords that every Responder host should have (one per active IP address)
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord RR_A; // 'A' or 'AAAA' (address) record for our ".local" name
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord RR_PTR; // PTR (reverse lookup) record
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord RR_HINFO;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Client API fields: The client must set up these fields *before* calling mDNS_RegisterInterface()
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSInterfaceID InterfaceID; // Identifies physical interface; MUST NOT be 0, -1, or -2
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddr ip; // The IPv4 or IPv6 address to advertise
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddr mask;
4b22b9337f359bfd063322244f5336cc7c6ffcfars char ifname[64]; // Windows uses a GUID string for the interface name, which doesn't fit in 16 bytes
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool Advertise; // False if you are only searching on this interface
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool McastTxRx; // Send/Receive multicast on this { InterfaceID, address family } ?
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct ExtraResourceRecord_struct ExtraResourceRecord;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsstruct ExtraResourceRecord_struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars ExtraResourceRecord *next;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 ClientID; // Opaque ID field to be used by client to map an AddRecord call to a set of Extra records
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord r;
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Note: Add any additional fields *before* the AuthRecord in this structure, not at the end.
4b22b9337f359bfd063322244f5336cc7c6ffcfars // In some cases clients can allocate larger chunks of memory and set r->rdata->MaxRDLength to indicate
4b22b9337f359bfd063322244f5336cc7c6ffcfars // that this extra memory is available, which would result in any fields after the AuthRecord getting smashed
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Note: Within an mDNSServiceCallback mDNS all API calls are legal except mDNS_Init(), mDNS_Close(), mDNS_Execute()
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct ServiceRecordSet_struct ServiceRecordSet;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef void mDNSServiceCallback(mDNS *const m, ServiceRecordSet *const sr, mStatus result);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsstruct ServiceRecordSet_struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Internal state fields. These are used internally by mDNSCore; the client layer needn't be concerned with them.
4b22b9337f359bfd063322244f5336cc7c6ffcfars // No fields need to be set up by the client prior to calling mDNS_RegisterService();
4b22b9337f359bfd063322244f5336cc7c6ffcfars // all required data is passed as parameters to that function.
4b22b9337f359bfd063322244f5336cc7c6ffcfars ServiceRecordSet *next;
4b22b9337f359bfd063322244f5336cc7c6ffcfars uDNS_RegInfo uDNS_info;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSServiceCallback *ServiceCallback;
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *ServiceContext;
4b22b9337f359bfd063322244f5336cc7c6ffcfars ExtraResourceRecord *Extras; // Optional list of extra AuthRecords attached to this service registration
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 NumSubTypes;
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *SubTypes;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool Conflict; // Set if this record set was forcibly deregistered because of a conflict
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname Host; // Set if this service record does not use the standard target host name
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord RR_ADV; // e.g. _services._dns-sd._udp.local. PTR _printer._tcp.local.
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord RR_PTR; // e.g. _printer._tcp.local. PTR Name._printer._tcp.local.
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord RR_SRV; // e.g. Name._printer._tcp.local. SRV 0 0 port target
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord RR_TXT; // e.g. Name._printer._tcp.local. TXT PrintQueueName
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Don't add any fields after AuthRecord RR_TXT.
4b22b9337f359bfd063322244f5336cc7c6ffcfars // This is where the implicit extra space goes if we allocate a ServiceRecordSet containing an oversized RR_TXT record
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - Question structures
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// We record the last eight instances of each duplicate query
4b22b9337f359bfd063322244f5336cc7c6ffcfars// This gives us v4/v6 on each of Ethernet/AirPort and Firewire, and two free slots "for future expansion"
4b22b9337f359bfd063322244f5336cc7c6ffcfars// If the host has more active interfaces that this it is not fatal -- duplicate question suppression will degrade gracefully.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Since we will still remember the last eight, the busiest interfaces will still get the effective duplicate question suppression.
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define DupSuppressInfoSize 8
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 Time;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSInterfaceID InterfaceID;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 Type; // v4 or v6?
4b22b9337f359bfd063322244f5336cc7c6ffcfars } DupSuppressInfo;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef enum
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Setup states
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_UnInit = 0,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_GetZoneInfo = 1,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_InitialRequest = 2,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_SecondaryRequest = 3,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_Refresh = 4,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_Retry = 5,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_Established = 6,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_Suspended = 7,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_SuspendDeferred = 8, // suspend once we get zone info
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_SuspendedPoll = 9, // suspended from polling state
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_NatMapWait = 10,
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Established/error states
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_Static = 16,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_Poll = 17,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_Error = 18,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_Cancelled = 19
4b22b9337f359bfd063322244f5336cc7c6ffcfars } LLQ_State;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_State state;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddr servAddr;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSIPPort servPort;
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion *question;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 origLease; // seconds (relative)
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 retry; // ticks (absolute)
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 expire; // ticks (absolute)
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs16 ntries;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 id[8];
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool deriveRemovesOnResume;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool NATMap; // does this LLQ use the global LLQ NAT mapping?
4b22b9337f359bfd063322244f5336cc7c6ffcfars } LLQ_Info;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// LLQ constants
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kDNSOpt_LLQ 1
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kDNSOpt_Lease 2
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kLLQ_Vers 1
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kLLQ_DefLease 7200 // 2 hours
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kLLQ_MAX_TRIES 3 // retry an operation 3 times max
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kLLQ_INIT_RESEND 2 // resend an un-ack'd packet after 2 seconds, then double for each additional
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kLLQ_DEF_RETRY 1800 // retry a failed operation after 30 minutes
4b22b9337f359bfd063322244f5336cc7c6ffcfars// LLQ Operation Codes
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kLLQOp_Setup 1
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kLLQOp_Refresh 2
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kLLQOp_Event 3
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define LLQ_OPT_RDLEN ((2 * sizeof(mDNSu16)) + LLQ_OPTLEN)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define LEASE_OPT_RDLEN (2 * sizeof(mDNSu16)) + sizeof(mDNSs32)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// LLQ Errror Codes
4b22b9337f359bfd063322244f5336cc7c6ffcfarsenum
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQErr_NoError = 0,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQErr_ServFull = 1,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQErr_Static = 2,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQErr_FormErr = 3,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQErr_NoSuchLLQ = 4,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQErr_BadVers = 5,
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQErr_UnknownErr = 6
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef void (*InternalResponseHndlr)(mDNS *const m, DNSMessage *msg, const mDNSu8 *end, DNSQuestion *question, void *internalContext);
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque16 id;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool internal;
4b22b9337f359bfd063322244f5336cc7c6ffcfars InternalResponseHndlr responseCallback; // NULL if internal field is false
4b22b9337f359bfd063322244f5336cc7c6ffcfars LLQ_Info *llq; // NULL for 1-shot queries
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool Answered; // have we received an answer (including NXDOMAIN) for this question?
4b22b9337f359bfd063322244f5336cc7c6ffcfars CacheRecord *knownAnswers;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 RestartTime; // Mark when we restart a suspended query
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *context;
4b22b9337f359bfd063322244f5336cc7c6ffcfars } uDNS_QuestionInfo;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Note: Within an mDNSQuestionCallback mDNS all API calls are legal except mDNS_Init(), mDNS_Close(), mDNS_Execute()
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef void mDNSQuestionCallback(mDNS *const m, DNSQuestion *question, const ResourceRecord *const answer, mDNSBool AddRecord);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsstruct DNSQuestion_struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Internal state fields. These are used internally by mDNSCore; the client layer needn't be concerned with them.
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion *next;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 qnamehash;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 DelayAnswering; // Set if we want to defer answering this question until the cache settles
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 LastQTime; // Last scheduled transmission of this Q on *all* applicable interfaces
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 ThisQInterval; // LastQTime + ThisQInterval is the next scheduled transmission of this Q
4b22b9337f359bfd063322244f5336cc7c6ffcfars // ThisQInterval > 0 for an active question;
4b22b9337f359bfd063322244f5336cc7c6ffcfars // ThisQInterval = 0 for a suspended question that's still in the list
4b22b9337f359bfd063322244f5336cc7c6ffcfars // ThisQInterval = -1 for a cancelled question that's been removed from the list
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 LastAnswerPktNum; // The sequence number of the last response packet containing an answer to this Q
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 RecentAnswerPkts; // Number of answers since the last time we sent this query
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 CurrentAnswers; // Number of records currently in the cache that answer this question
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 LargeAnswers; // Number of answers with rdata > 1024 bytes
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 UniqueAnswers; // Number of answers received with kDNSClass_UniqueRRSet bit set
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSInterfaceID FlappingInterface;// Set when an interface goes away, to flag if removes are delivered for this Q
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion *DuplicateOf;
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion *NextInDQList;
4b22b9337f359bfd063322244f5336cc7c6ffcfars DupSuppressInfo DupSuppress[DupSuppressInfoSize];
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSInterfaceID SendQNow; // The interface this query is being sent on right now
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool SendOnAll; // Set if we're sending this question on all active interfaces
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 RequestUnicast; // Non-zero if we want to send query with kDNSQClass_UnicastResponse bit set
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 LastQTxTime; // Last time this Q was sent on one (but not necessarily all) interfaces
4b22b9337f359bfd063322244f5336cc7c6ffcfars uDNS_QuestionInfo uDNS_info;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Client API fields: The client must set up these fields *before* calling mDNS_StartQuery()
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSInterfaceID InterfaceID; // Non-zero if you want to issue queries only on a single specific IP interface
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddr Target; // Non-zero if you want to direct queries to a specific unicast target address
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSIPPort TargetPort; // Must be set if Target is set
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque16 TargetQID; // Must be set if Target is set
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname qname;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 qtype;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 qclass;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool LongLived; // Set by client for calls to mDNS_StartQuery to indicate LLQs to unicast layer.
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool ExpectUnique; // Set by client if it's expecting unique RR(s) for this question, not shared RRs
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool ForceMCast; // Set by client to force mDNS query, even for apparently uDNS names
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool ReturnCNAME; // Set by client to request callbacks for intermediate CNAME records
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSQuestionCallback *QuestionCallback;
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *QuestionContext;
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Client API fields: The client must set up name and InterfaceID *before* calling mDNS_StartResolveService()
4b22b9337f359bfd063322244f5336cc7c6ffcfars // When the callback is invoked, ip, port, TXTlen and TXTinfo will have been filled in with the results learned from the network.
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname name;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSInterfaceID InterfaceID; // ID of the interface the response was received on
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddr ip; // Remote (destination) IP address where this service can be accessed
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSIPPort port; // Port where this service can be accessed
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 TXTlen;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 TXTinfo[2048]; // Additional demultiplexing information (e.g. LPR queue name)
4b22b9337f359bfd063322244f5336cc7c6ffcfars } ServiceInfo;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Note: Within an mDNSServiceInfoQueryCallback mDNS all API calls are legal except mDNS_Init(), mDNS_Close(), mDNS_Execute()
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct ServiceInfoQuery_struct ServiceInfoQuery;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef void mDNSServiceInfoQueryCallback(mDNS *const m, ServiceInfoQuery *query);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsstruct ServiceInfoQuery_struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Internal state fields. These are used internally by mDNSCore; the client layer needn't be concerned with them.
4b22b9337f359bfd063322244f5336cc7c6ffcfars // No fields need to be set up by the client prior to calling mDNS_StartResolveService();
4b22b9337f359bfd063322244f5336cc7c6ffcfars // all required data is passed as parameters to that function.
4b22b9337f359bfd063322244f5336cc7c6ffcfars // The ServiceInfoQuery structure memory is working storage for mDNSCore to discover the requested information
4b22b9337f359bfd063322244f5336cc7c6ffcfars // and place it in the ServiceInfo structure. After the client has called mDNS_StopResolveService(), it may
4b22b9337f359bfd063322244f5336cc7c6ffcfars // dispose of the ServiceInfoQuery structure while retaining the results in the ServiceInfo structure.
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion qSRV;
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion qTXT;
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion qAv4;
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion qAv6;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 GotSRV;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 GotTXT;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 GotADD;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 Answers;
4b22b9337f359bfd063322244f5336cc7c6ffcfars ServiceInfo *info;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSServiceInfoQueryCallback *ServiceInfoQueryCallback;
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *ServiceInfoQueryContext;
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - NAT Traversal structures and constants
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define NATMAP_INIT_RETRY (mDNSPlatformOneSecond / 4) // start at 250ms w/ exponential decay
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define NATMAP_MAX_RETRY mDNSPlatformOneSecond // back off to once per second
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define NATMAP_MAX_TRIES 3 // for max 3 tries
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define NATMAP_DEFAULT_LEASE (60 * 60) // lease life in seconds
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define NATMAP_VERS 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define NATMAP_RESPONSE_MASK 0x80
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef enum
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATOp_AddrRequest = 0,
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATOp_MapUDP = 1,
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATOp_MapTCP = 2
4b22b9337f359bfd063322244f5336cc7c6ffcfars } NATOp_t;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsenum
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATErr_None = 0,
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATErr_Vers = 1,
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATErr_Refused = 2,
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATErr_NetFail = 3,
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATErr_Res = 4,
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATErr_Opcode = 5
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef mDNSu16 NATErr_t;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef enum
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATState_Init = 0,
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATState_Request = 1,
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATState_Established = 2,
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATState_Legacy = 3,
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATState_Error = 4,
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATState_Refresh = 5,
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATState_Deleted = 6
4b22b9337f359bfd063322244f5336cc7c6ffcfars } NATState_t;
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Note: we have no explicit "cancelled" state, where a service/interface is deregistered while we
4b22b9337f359bfd063322244f5336cc7c6ffcfars // have an outstanding NAT request. This is conveyed by the "reg" pointer being set to NULL
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedstruct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 vers;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 opcode;
4b22b9337f359bfd063322244f5336cc7c6ffcfars } NATAddrRequest;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedstruct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 vers;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 opcode;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque16 err;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque32 uptime;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSv4Addr PubAddr;
4b22b9337f359bfd063322244f5336cc7c6ffcfars } NATAddrReply;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedstruct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 vers;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 opcode;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque16 unused;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSIPPort priv;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSIPPort pub;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque32 lease;
4b22b9337f359bfd063322244f5336cc7c6ffcfars } NATPortMapRequest;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef packedstruct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 vers;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 opcode;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque16 err;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque32 uptime;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSIPPort priv;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSIPPort pub;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque32 lease;
4b22b9337f359bfd063322244f5336cc7c6ffcfars } NATPortMapReply;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Pass NULL for pkt on error (including timeout)
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef mDNSBool (*NATResponseHndlr)(NATTraversalInfo *n, mDNS *m, mDNSu8 *pkt, mDNSu16 len);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsstruct NATTraversalInfo_struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATOp_t op;
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATResponseHndlr ReceiveResponse;
4b22b9337f359bfd063322244f5336cc7c6ffcfars union { AuthRecord *RecordRegistration; ServiceRecordSet *ServiceRegistration; } reg;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddr Router;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSIPPort PublicPort;
4b22b9337f359bfd063322244f5336cc7c6ffcfars union { NATAddrRequest AddrReq; NATPortMapRequest PortReq; } request;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 retry; // absolute time when we retry
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 RetryInterval; // delta between time sent and retry
4b22b9337f359bfd063322244f5336cc7c6ffcfars int ntries;
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATState_t state;
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATTraversalInfo *next;
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - Main mDNS object, used to hold all the mDNS state
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef void mDNSCallback(mDNS *const m, mStatus result);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define CACHE_HASH_SLOTS 499
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsenum
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNS_KnownBug_PhantomInterfaces = 1
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 nextevent;
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion *ActiveQueries; //!!!KRS this should be a hashtable (hash on messageID)
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion *CurrentQuery; // pointer to ActiveQueries list being examined in a loop. Functions that remove
4b22b9337f359bfd063322244f5336cc7c6ffcfars // elements from the ActiveQueries list must update this pointer (if non-NULL) as necessary.
4b22b9337f359bfd063322244f5336cc7c6ffcfars //!!!KRS do the same for registration lists
4b22b9337f359bfd063322244f5336cc7c6ffcfars ServiceRecordSet *ServiceRegistrations;
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *RecordRegistrations;
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATTraversalInfo *NATTraversals;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 NextMessageID;
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSServer *Servers; // list of DNS servers
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddr Router;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddr AdvertisedV4; // IPv4 address pointed to by hostname
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddr MappedV4; // Cache of public address if PrimaryIP is behind a NAT
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSAddr AdvertisedV6; // IPv6 address pointed to by hostname
4b22b9337f359bfd063322244f5336cc7c6ffcfars NATTraversalInfo *LLQNatInfo; // Nat port mapping to receive LLQ events
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname ServiceRegDomain; // (going away w/ multi-user support)
4b22b9337f359bfd063322244f5336cc7c6ffcfars struct uDNS_AuthInfo *AuthInfoList; // list of domains requiring authentication for updates.
4b22b9337f359bfd063322244f5336cc7c6ffcfars uDNS_HostnameInfo *Hostnames; // List of registered hostnames + hostname metadata
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion ReverseMap; // Reverse-map query to find static hostname for service target
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool ReverseMapActive; // Is above query active?
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname StaticHostname; // Current answer to reverse-map query (above)
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool DelaySRVUpdate; // Delay SRV target/port update to avoid "flap"
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 NextSRVUpdate; // Time to perform delayed update
4b22b9337f359bfd063322244f5336cc7c6ffcfars } uDNS_GlobalInfo;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsstruct mDNS_struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Internal state fields. These hold the main internal state of mDNSCore;
4b22b9337f359bfd063322244f5336cc7c6ffcfars // the client layer needn't be concerned with them.
4b22b9337f359bfd063322244f5336cc7c6ffcfars // No fields need to be set up by the client prior to calling mDNS_Init();
4b22b9337f359bfd063322244f5336cc7c6ffcfars // all required data is passed as parameters to that function.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNS_PlatformSupport *p; // Pointer to platform-specific data of indeterminite size
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 KnownBugs;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool CanReceiveUnicastOn5353;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool AdvertiseLocalAddresses;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mStatus mDNSPlatformStatus;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSIPPort UnicastPort4;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSIPPort UnicastPort6;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSCallback *MainCallback;
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *MainContext;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // For debugging: To catch and report locking failures
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 mDNS_busy; // Incremented between mDNS_Lock/mDNS_Unlock section
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 mDNS_reentrancy; // Incremented when calling a client callback
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 mDNS_shutdown; // Set when we're shutting down, allows us to skip some unnecessary steps
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 lock_rrcache; // For debugging: Set at times when these lists may not be modified
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 lock_Questions;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 lock_Records;
4b22b9337f359bfd063322244f5336cc7c6ffcfars #define MaxMsg 120
4b22b9337f359bfd063322244f5336cc7c6ffcfars char MsgBuffer[MaxMsg]; // Temp storage used while building error log messages
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Task Scheduling variables
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 timenow_adjust; // Correction applied if we ever discover time went backwards
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 timenow; // The time that this particular activation of the mDNS code started
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 timenow_last; // The time the last time we ran
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 NextScheduledEvent; // Derived from values below
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 SuppressSending; // Don't send *any* packets during this time
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 NextCacheCheck; // Next time to refresh cache record before it expires
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 NextScheduledQuery; // Next time to send query in its exponential backoff sequence
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 NextScheduledProbe; // Next time to probe for new authoritative record
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 NextScheduledResponse; // Next time to send authoritative record(s) in responses
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 ExpectUnicastResponse; // Set when we send a query with the kDNSQClass_UnicastResponse bit set
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 RandomQueryDelay; // For de-synchronization of query packets on the wire
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 RandomReconfirmDelay; // For de-synchronization of reconfirmation queries on the wire
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 PktNum; // Unique sequence number assigned to each received packet
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool SendDeregistrations; // Set if we need to send deregistrations (immediately)
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool SendImmediateAnswers; // Set if we need to send answers (immediately -- or as soon as SuppressSending clears)
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool SleepState; // Set if we're sleeping (send no more packets)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // These fields only required for mDNS Searcher...
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion *Questions; // List of all registered questions, active and inactive
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion *NewQuestions; // Fresh questions not yet answered from cache
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion *CurrentQuestion; // Next question about to be examined in AnswerLocalQuestions()
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion *LocalOnlyQuestions; // Questions with InterfaceID set to mDNSInterface_LocalOnly
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSQuestion *NewLocalOnlyQuestions; // Fresh local-only questions not yet answered
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 rrcache_size; // Total number of available cache entries
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 rrcache_totalused; // Number of cache entries currently occupied
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 rrcache_active; // Number of cache entries currently occupied by records that answer active questions
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 rrcache_report;
4b22b9337f359bfd063322244f5336cc7c6ffcfars CacheEntity *rrcache_free;
4b22b9337f359bfd063322244f5336cc7c6ffcfars CacheGroup *rrcache_hash[CACHE_HASH_SLOTS];
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Fields below only required for mDNS Responder...
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainlabel nicelabel; // Rich text label encoded using canonically precomposed UTF-8
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainlabel hostlabel; // Conforms to RFC 1034 "letter-digit-hyphen" ARPANET host name rules
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname MulticastHostname; // Fully Qualified "dot-local" Host Name, e.g. "Foo.local."
4b22b9337f359bfd063322244f5336cc7c6ffcfars UTF8str255 HIHardware;
4b22b9337f359bfd063322244f5336cc7c6ffcfars UTF8str255 HISoftware;
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *ResourceRecords;
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *DuplicateRecords; // Records currently 'on hold' because they are duplicates of existing records
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *NewLocalRecords; // Fresh local-only records not yet delivered to local-only questions
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *CurrentRecord; // Next AuthRecord about to be examined
4b22b9337f359bfd063322244f5336cc7c6ffcfars NetworkInterfaceInfo *HostInterfaces;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 ProbeFailTime;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu32 NumFailedProbes;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 SuppressProbes;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // unicast-specific data
4b22b9337f359bfd063322244f5336cc7c6ffcfars uDNS_GlobalInfo uDNS_info;
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSs32 SuppressStdPort53Queries; // Wait before allowing the next standard unicast query to the user's configured DNS server
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Fixed storage, to avoid creating large objects on the stack
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSMessage imsg; // Incoming message received from wire
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSMessage omsg; // Outgoing message we're building
4b22b9337f359bfd063322244f5336cc7c6ffcfars LargeCacheRecord rec; // Resource Record extracted from received message
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define FORALL_CACHERECORDS(SLOT,CG,CR) \
4b22b9337f359bfd063322244f5336cc7c6ffcfars for ((SLOT) = 0; (SLOT) < CACHE_HASH_SLOTS; (SLOT)++) \
4b22b9337f359bfd063322244f5336cc7c6ffcfars for((CG)=m->rrcache_hash[(SLOT)]; (CG); (CG)=(CG)->next) \
4b22b9337f359bfd063322244f5336cc7c6ffcfars for ((CR) = (CG)->members; (CR); (CR)=(CR)->next)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - Useful Static Constants
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSIPPort zeroIPPort;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSv4Addr zerov4Addr;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSv6Addr zerov6Addr;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSEthAddr zeroEthAddr;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSv4Addr onesIPv4Addr;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSv6Addr onesIPv6Addr;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSAddr zeroAddr;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSInterfaceID mDNSInterface_Any; // Zero
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSInterfaceID mDNSInterface_LocalOnly; // Special value
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSIPPort UnicastDNSPort;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSIPPort NATPMPPort;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSIPPort DNSEXTPort;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSIPPort MulticastDNSPort;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSIPPort LoopbackIPCPort;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSv4Addr AllDNSAdminGroup;
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define AllDNSLinkGroupv4 (AllDNSLinkGroup_v4.ip.v4)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define AllDNSLinkGroupv6 (AllDNSLinkGroup_v6.ip.v6)
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSAddr AllDNSLinkGroup_v4;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSAddr AllDNSLinkGroup_v6;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSOpaque16 zeroID;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSOpaque16 QueryFlags;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSOpaque16 uQueryFlags;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSOpaque16 ResponseFlags;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSOpaque16 UpdateReqFlags;
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const mDNSOpaque16 UpdateRespFlags;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define localdomain (*(const domainname *)"\x5" "local")
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define LocalReverseMapDomain (*(const domainname *)"\x3" "254" "\x3" "169" "\x7" "in-addr" "\x4" "arpa")
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - Inline functions
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if (defined(_MSC_VER))
4b22b9337f359bfd063322244f5336cc7c6ffcfars #define mDNSinline static __inline
4b22b9337f359bfd063322244f5336cc7c6ffcfars#elif ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 9)))
4b22b9337f359bfd063322244f5336cc7c6ffcfars #define mDNSinline static inline
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// If we're not doing inline functions, then this header needs to have the extern declarations
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if !defined(mDNSinline)
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSs32 NonZeroTime(mDNSs32 t);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu16 mDNSVal16(mDNSOpaque16 x);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu32 mDNSVal32(mDNSOpaque32 x);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSOpaque16 mDNSOpaque16fromIntVal(mDNSu16 v);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSOpaque32 mDNSOpaque32fromIntVal(mDNSu32 v);
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// If we're compiling the particular C file that instantiates our inlines, then we
4b22b9337f359bfd063322244f5336cc7c6ffcfars// define "mDNSinline" (to empty string) so that we generate code in the following section
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if (!defined(mDNSinline) && mDNS_InstantiateInlines)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSinline
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifdef mDNSinline
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsmDNSinline mDNSs32 NonZeroTime(mDNSs32 t) { if (t) return(t); else return(1); }
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsmDNSinline mDNSu16 mDNSVal16(mDNSOpaque16 x) { return((mDNSu16)((mDNSu16)x.b[0] << 8 | (mDNSu16)x.b[1])); }
4b22b9337f359bfd063322244f5336cc7c6ffcfarsmDNSinline mDNSu32 mDNSVal32(mDNSOpaque32 x) { return((mDNSu32)((mDNSu32)x.b[0] << 24 | (mDNSu32)x.b[1] << 16 | (mDNSu32)x.b[2] << 8 | (mDNSu32)x.b[3])); }
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsmDNSinline mDNSOpaque16 mDNSOpaque16fromIntVal(mDNSu16 v)
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque16 x;
4b22b9337f359bfd063322244f5336cc7c6ffcfars x.b[0] = (mDNSu8)(v >> 8);
4b22b9337f359bfd063322244f5336cc7c6ffcfars x.b[1] = (mDNSu8)(v & 0xFF);
4b22b9337f359bfd063322244f5336cc7c6ffcfars return(x);
4b22b9337f359bfd063322244f5336cc7c6ffcfars }
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsmDNSinline mDNSOpaque32 mDNSOpaque32fromIntVal(mDNSu32 v)
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSOpaque32 x;
4b22b9337f359bfd063322244f5336cc7c6ffcfars x.b[0] = (mDNSu8) (v >> 24) ;
4b22b9337f359bfd063322244f5336cc7c6ffcfars x.b[1] = (mDNSu8)((v >> 16) & 0xFF);
4b22b9337f359bfd063322244f5336cc7c6ffcfars x.b[2] = (mDNSu8)((v >> 8 ) & 0xFF);
4b22b9337f359bfd063322244f5336cc7c6ffcfars x.b[3] = (mDNSu8)((v ) & 0xFF);
4b22b9337f359bfd063322244f5336cc7c6ffcfars return x;
4b22b9337f359bfd063322244f5336cc7c6ffcfars }
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - Main Client Functions
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Every client should call mDNS_Init, passing in storage for the mDNS object and the mDNS_PlatformSupport object.
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Clients that are only advertising services should use mDNS_Init_NoCache and mDNS_Init_ZeroCacheSize.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Clients that plan to perform queries (mDNS_StartQuery, mDNS_StartBrowse, mDNS_StartResolveService, etc.)
4b22b9337f359bfd063322244f5336cc7c6ffcfars// need to provide storage for the resource record cache, or the query calls will return 'mStatus_NoCache'.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The rrcachestorage parameter is the address of memory for the resource record cache, and
4b22b9337f359bfd063322244f5336cc7c6ffcfars// the rrcachesize parameter is the number of entries in the CacheRecord array passed in.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// (i.e. the size of the cache memory needs to be sizeof(CacheRecord) * rrcachesize).
4b22b9337f359bfd063322244f5336cc7c6ffcfars// OS X 10.3 Panther uses an initial cache size of 64 entries, and then mDNSCore sends an
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mStatus_GrowCache message if it needs more.
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Most clients should use mDNS_Init_AdvertiseLocalAddresses. This causes mDNSCore to automatically
4b22b9337f359bfd063322244f5336cc7c6ffcfars// create the correct address records for all the hosts interfaces. If you plan to advertise
4b22b9337f359bfd063322244f5336cc7c6ffcfars// services being offered by the local machine, this is almost always what you want.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// There are two cases where you might use mDNS_Init_DontAdvertiseLocalAddresses:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// 1. A client-only device, that browses for services but doesn't advertise any of its own.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// 2. A proxy-registration service, that advertises services being offered by other machines, and takes
4b22b9337f359bfd063322244f5336cc7c6ffcfars// the appropriate steps to manually create the correct address records for those other machines.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// In principle, a proxy-like registration service could manually create address records for its own machine too,
4b22b9337f359bfd063322244f5336cc7c6ffcfars// but this would be pointless extra effort when using mDNS_Init_AdvertiseLocalAddresses does that for you.
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// When mDNS has finished setting up the client's callback is called
4b22b9337f359bfd063322244f5336cc7c6ffcfars// A client can also spin and poll the mDNSPlatformStatus field to see when it changes from mStatus_Waiting to mStatus_NoError
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Call mDNS_Close to tidy up before exiting
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Call mDNS_Register with a completed AuthRecord object to register a resource record
4b22b9337f359bfd063322244f5336cc7c6ffcfars// If the resource record type is kDNSRecordTypeUnique (or kDNSknownunique) then if a conflicting resource record is discovered,
4b22b9337f359bfd063322244f5336cc7c6ffcfars// the resource record's mDNSRecordCallback will be called with error code mStatus_NameConflict. The callback should deregister
4b22b9337f359bfd063322244f5336cc7c6ffcfars// the record, and may then try registering the record again after picking a new name (e.g. by automatically appending a number).
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Following deregistration, the RecordCallback will be called with result mStatus_MemFree to signal that it is safe to deallocate
4b22b9337f359bfd063322244f5336cc7c6ffcfars// the record's storage (memory must be freed asynchronously to allow for goodbye packets and dynamic update deregistration).
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Call mDNS_StartQuery to initiate a query. mDNS will proceed to issue Multicast DNS query packets, and any time a response
4b22b9337f359bfd063322244f5336cc7c6ffcfars// is received containing a record which matches the question, the DNSQuestion's mDNSAnswerCallback function will be called
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Call mDNS_StopQuery when no more answers are required
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Care should be taken on multi-threaded or interrupt-driven environments.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The main mDNS routines call mDNSPlatformLock() on entry and mDNSPlatformUnlock() on exit;
4b22b9337f359bfd063322244f5336cc7c6ffcfars// each platform layer needs to implement these appropriately for its respective platform.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// For example, if the support code on a particular platform implements timer callbacks at interrupt time, then
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNSPlatformLock/Unlock need to disable interrupts or do similar concurrency control to ensure that the mDNS
4b22b9337f359bfd063322244f5336cc7c6ffcfars// code is not entered by an interrupt-time timer callback while in the middle of processing a client call.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_Init (mDNS *const m, mDNS_PlatformSupport *const p,
4b22b9337f359bfd063322244f5336cc7c6ffcfars CacheEntity *rrcachestorage, mDNSu32 rrcachesize,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSBool AdvertiseLocalAddresses,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSCallback *Callback, void *Context);
4b22b9337f359bfd063322244f5336cc7c6ffcfars// See notes above on use of NoCache/ZeroCacheSize
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_Init_NoCache mDNSNULL
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_Init_ZeroCacheSize 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars// See notes above on use of Advertise/DontAdvertiseLocalAddresses
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_Init_AdvertiseLocalAddresses mDNStrue
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_Init_DontAdvertiseLocalAddresses mDNSfalse
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_Init_NoInitCallback mDNSNULL
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_Init_NoInitCallbackContext mDNSNULL
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNS_GrowCache (mDNS *const m, CacheEntity *storage, mDNSu32 numrecords);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNS_Close (mDNS *const m);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSs32 mDNS_Execute (mDNS *const m);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_Register (mDNS *const m, AuthRecord *const rr);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_Update (mDNS *const m, AuthRecord *const rr, mDNSu32 newttl,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const mDNSu16 newrdlength, RData *const newrdata, mDNSRecordUpdateCallback *Callback);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_Deregister(mDNS *const m, AuthRecord *const rr);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_StartQuery(mDNS *const m, DNSQuestion *const question);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_StopQuery (mDNS *const m, DNSQuestion *const question);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_Reconfirm (mDNS *const m, CacheRecord *const cacherr);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_ReconfirmByValue(mDNS *const m, ResourceRecord *const rr);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSs32 mDNS_TimeNow(const mDNS *const m);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - Platform support functions that are accessible to the client layer too
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSs32 mDNSPlatformOneSecond;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - General utility and helper functions
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNS_RegisterService is a single call to register the set of resource records associated with a given named service.
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNS_StartResolveService is single call which is equivalent to multiple calls to mDNS_StartQuery,
4b22b9337f359bfd063322244f5336cc7c6ffcfars// to find the IP address, port number, and demultiplexing information for a given named service.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// As with mDNS_StartQuery, it executes asynchronously, and calls the ServiceInfoQueryCallback when the answer is
4b22b9337f359bfd063322244f5336cc7c6ffcfars// found. After the service is resolved, the client should call mDNS_StopResolveService to complete the transaction.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The client can also call mDNS_StopResolveService at any time to abort the transaction.
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNS_AddRecordToService adds an additional record to a Service Record Set. This record may be deregistered
4b22b9337f359bfd063322244f5336cc7c6ffcfars// via mDNS_RemoveRecordFromService, or by deregistering the service. mDNS_RemoveRecordFromService is passed a
4b22b9337f359bfd063322244f5336cc7c6ffcfars// callback to free the memory associated with the extra RR when it is safe to do so. The ExtraResourceRecord
4b22b9337f359bfd063322244f5336cc7c6ffcfars// object can be found in the record's context pointer.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNS_GetBrowseDomains is a special case of the mDNS_StartQuery call, where the resulting answers
4b22b9337f359bfd063322244f5336cc7c6ffcfars// are a list of PTR records indicating (in the rdata) domains that are recommended for browsing.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// After getting the list of domains to browse, call mDNS_StopQuery to end the search.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNS_GetDefaultBrowseDomain returns the name of the domain that should be highlighted by default.
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNS_GetRegistrationDomains and mDNS_GetDefaultRegistrationDomain are the equivalent calls to get the list
4b22b9337f359bfd063322244f5336cc7c6ffcfars// of one or more domains that should be offered to the user as choices for where they may register their service,
4b22b9337f359bfd063322244f5336cc7c6ffcfars// and the default domain in which to register in the case where the user has made no selection.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNS_SetupResourceRecord(AuthRecord *rr, RData *RDataStorage, mDNSInterfaceID InterfaceID,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu16 rrtype, mDNSu32 ttl, mDNSu8 RecordType, mDNSRecordCallback Callback, void *Context);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_RegisterService (mDNS *const m, ServiceRecordSet *sr,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const domainlabel *const name, const domainname *const type, const domainname *const domain,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const domainname *const host, mDNSIPPort port, const mDNSu8 txtinfo[], mDNSu16 txtlen,
4b22b9337f359bfd063322244f5336cc7c6ffcfars AuthRecord *SubTypes, mDNSu32 NumSubTypes,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const mDNSInterfaceID InterfaceID, mDNSServiceCallback Callback, void *Context);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_AddRecordToService(mDNS *const m, ServiceRecordSet *sr, ExtraResourceRecord *extra, RData *rdata, mDNSu32 ttl);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_RemoveRecordFromService(mDNS *const m, ServiceRecordSet *sr, ExtraResourceRecord *extra, mDNSRecordCallback MemFreeCallback, void *Context);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_RenameAndReregisterService(mDNS *const m, ServiceRecordSet *const sr, const domainlabel *newname);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_DeregisterService(mDNS *const m, ServiceRecordSet *sr);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_RegisterNoSuchService(mDNS *const m, AuthRecord *const rr,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const domainlabel *const name, const domainname *const type, const domainname *const domain,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const domainname *const host,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const mDNSInterfaceID InterfaceID, mDNSRecordCallback Callback, void *Context);
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_DeregisterNoSuchService mDNS_Deregister
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_StartBrowse(mDNS *const m, DNSQuestion *const question,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const domainname *const srv, const domainname *const domain,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const mDNSInterfaceID InterfaceID, mDNSBool ForceMCast, mDNSQuestionCallback *Callback, void *Context);
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_StopBrowse mDNS_StopQuery
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_StartResolveService(mDNS *const m, ServiceInfoQuery *query, ServiceInfo *info, mDNSServiceInfoQueryCallback *Callback, void *Context);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNS_StopResolveService (mDNS *const m, ServiceInfoQuery *query);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef enum
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNS_DomainTypeBrowse = 0,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNS_DomainTypeBrowseDefault = 1,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNS_DomainTypeBrowseLegacy = 2,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNS_DomainTypeRegistration = 3,
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNS_DomainTypeRegistrationDefault = 4,
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNS_DomainTypeMax = 4
4b22b9337f359bfd063322244f5336cc7c6ffcfars } mDNS_DomainType;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern const char *const mDNS_DomainTypeNames[];
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_GetDomains(mDNS *const m, DNSQuestion *const question, mDNS_DomainType DomainType, const domainname *dom,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const mDNSInterfaceID InterfaceID, mDNSQuestionCallback *Callback, void *Context);
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_StopGetDomains mDNS_StopQuery
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_AdvertiseDomains(mDNS *const m, AuthRecord *rr, mDNS_DomainType DomainType, const mDNSInterfaceID InterfaceID, char *domname);
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_StopAdvertiseDomains mDNS_Deregister
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - DNS name utility functions
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// In order to expose the full capabilities of the DNS protocol (which allows any arbitrary eight-bit values
4b22b9337f359bfd063322244f5336cc7c6ffcfars// in domain name labels, including unlikely characters like ascii nulls and even dots) all the mDNS APIs
4b22b9337f359bfd063322244f5336cc7c6ffcfars// work with DNS's native length-prefixed strings. For convenience in C, the following utility functions
4b22b9337f359bfd063322244f5336cc7c6ffcfars// are provided for converting between C's null-terminated strings and DNS's length-prefixed strings.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Assignment
4b22b9337f359bfd063322244f5336cc7c6ffcfars// A simple C structure assignment of a domainname can cause a protection fault by accessing unmapped memory,
4b22b9337f359bfd063322244f5336cc7c6ffcfars// because that object is defined to be 256 bytes long, but not all domainname objects are truly the full size.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// This macro uses mDNSPlatformMemCopy() to make sure it only touches the actual bytes that are valid.
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define AssignDomainName(DST, SRC) mDNSPlatformMemCopy((SRC)->c, (DST)->c, DomainNameLength((SRC)))
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Comparison functions
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSBool SameDomainLabel(const mDNSu8 *a, const mDNSu8 *b);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSBool SameDomainName(const domainname *const d1, const domainname *const d2);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSBool IsLocalDomain(const domainname *d); // returns true for domains that by default should be looked up using link-local multicast
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Get total length of domain name, in native DNS format, including terminal root label
4b22b9337f359bfd063322244f5336cc7c6ffcfars// (e.g. length of "com." is 5 (length byte, three data bytes, final zero)
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu16 DomainNameLength(const domainname *const name);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Append functions to append one or more labels to an existing native format domain name:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// AppendLiteralLabelString adds a single label from a literal C string, with no escape character interpretation.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// AppendDNSNameString adds zero or more labels from a C string using conventional DNS dots-and-escaping interpretation
4b22b9337f359bfd063322244f5336cc7c6ffcfars// AppendDomainLabel adds a single label from a native format domainlabel
4b22b9337f359bfd063322244f5336cc7c6ffcfars// AppendDomainName adds zero or more labels from a native format domainname
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu8 *AppendLiteralLabelString(domainname *const name, const char *cstr);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu8 *AppendDNSNameString (domainname *const name, const char *cstr);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu8 *AppendDomainLabel (domainname *const name, const domainlabel *const label);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu8 *AppendDomainName (domainname *const name, const domainname *const append);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Convert from null-terminated string to native DNS format:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The DomainLabel form makes a single label from a literal C string, with no escape character interpretation.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The DomainName form makes native format domain name from a C string using conventional DNS interpretation:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// dots separate labels, and within each label, '\.' represents a literal dot, '\\' represents a literal
4b22b9337f359bfd063322244f5336cc7c6ffcfars// backslash and backslash with three decimal digits (e.g. \000) represents an arbitrary byte value.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSBool MakeDomainLabelFromLiteralString(domainlabel *const label, const char *cstr);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu8 *MakeDomainNameFromDNSNameString (domainname *const name, const char *cstr);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Convert native format domainlabel or domainname back to C string format
4b22b9337f359bfd063322244f5336cc7c6ffcfars// IMPORTANT:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// When using ConvertDomainLabelToCString, the target buffer must be MAX_ESCAPED_DOMAIN_LABEL (254) bytes long
4b22b9337f359bfd063322244f5336cc7c6ffcfars// to guarantee there will be no buffer overrun. It is only safe to use a buffer shorter than this in rare cases
4b22b9337f359bfd063322244f5336cc7c6ffcfars// where the label is known to be constrained somehow (for example, if the label is known to be either "_tcp" or "_udp").
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Similarly, when using ConvertDomainNameToCString, the target buffer must be MAX_ESCAPED_DOMAIN_NAME (1005) bytes long.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// See definitions of MAX_ESCAPED_DOMAIN_LABEL and MAX_ESCAPED_DOMAIN_NAME for more detailed explanation.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern char *ConvertDomainLabelToCString_withescape(const domainlabel *const name, char *cstr, char esc);
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define ConvertDomainLabelToCString_unescaped(D,C) ConvertDomainLabelToCString_withescape((D), (C), 0)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define ConvertDomainLabelToCString(D,C) ConvertDomainLabelToCString_withescape((D), (C), '\\')
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern char *ConvertDomainNameToCString_withescape(const domainname *const name, char *cstr, char esc);
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define ConvertDomainNameToCString_unescaped(D,C) ConvertDomainNameToCString_withescape((D), (C), 0)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define ConvertDomainNameToCString(D,C) ConvertDomainNameToCString_withescape((D), (C), '\\')
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void ConvertUTF8PstringToRFC1034HostLabel(const mDNSu8 UTF8Name[], domainlabel *const hostlabel);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu8 *ConstructServiceName(domainname *const fqdn, const domainlabel *name, const domainname *type, const domainname *const domain);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSBool DeconstructServiceName(const domainname *const fqdn, domainlabel *const name, domainname *const type, domainname *const domain);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Note: Some old functions have been replaced by more sensibly-named versions.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// You can uncomment the hash-defines below if you don't want to have to change your source code right away.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// When updating your code, note that (unlike the old versions) *all* the new routines take the target object
4b22b9337f359bfd063322244f5336cc7c6ffcfars// as their first parameter.
4b22b9337f359bfd063322244f5336cc7c6ffcfars//#define ConvertCStringToDomainName(SRC,DST) MakeDomainNameFromDNSNameString((DST),(SRC))
4b22b9337f359bfd063322244f5336cc7c6ffcfars//#define ConvertCStringToDomainLabel(SRC,DST) MakeDomainLabelFromLiteralString((DST),(SRC))
4b22b9337f359bfd063322244f5336cc7c6ffcfars//#define AppendStringLabelToName(DST,SRC) AppendLiteralLabelString((DST),(SRC))
4b22b9337f359bfd063322244f5336cc7c6ffcfars//#define AppendStringNameToName(DST,SRC) AppendDNSNameString((DST),(SRC))
4b22b9337f359bfd063322244f5336cc7c6ffcfars//#define AppendDomainLabelToName(DST,SRC) AppendDomainLabel((DST),(SRC))
4b22b9337f359bfd063322244f5336cc7c6ffcfars//#define AppendDomainNameToName(DST,SRC) AppendDomainName((DST),(SRC))
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - Other utility functions and macros
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNS_vsnprintf/snprintf return the number of characters written, excluding the final terminating null.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The output is always null-terminated: for example, if the output turns out to be exactly buflen long,
4b22b9337f359bfd063322244f5336cc7c6ffcfars// then the output will be truncated by one character to allow space for the terminating null.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Unlike standard C vsnprintf/snprintf, they return the number of characters *actually* written,
4b22b9337f359bfd063322244f5336cc7c6ffcfars// not the number of characters that *would* have been printed were buflen unlimited.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu32 mDNS_vsnprintf(char *sbuffer, mDNSu32 buflen, const char *fmt, va_list arg);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu32 mDNS_snprintf(char *sbuffer, mDNSu32 buflen, const char *fmt, ...) IS_A_PRINTF_STYLE_FUNCTION(3,4);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu32 NumCacheRecordsForInterfaceID(const mDNS *const m, mDNSInterfaceID id);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern char *DNSTypeName(mDNSu16 rrtype);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern char *GetRRDisplayString_rdb(const ResourceRecord *rr, RDataBody *rd, char *buffer);
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define RRDisplayString(m, rr) GetRRDisplayString_rdb(rr, &(rr)->rdata->u, (m)->MsgBuffer)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define ARDisplayString(m, rr) GetRRDisplayString_rdb(&(rr)->resrec, &(rr)->resrec.rdata->u, (m)->MsgBuffer)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define CRDisplayString(m, rr) GetRRDisplayString_rdb(&(rr)->resrec, &(rr)->resrec.rdata->u, (m)->MsgBuffer)
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSBool mDNSSameAddress(const mDNSAddr *ip1, const mDNSAddr *ip2);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void IncrementLabelSuffix(domainlabel *name, mDNSBool RichText);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSBool IsPrivateV4Addr(mDNSAddr *addr); // returns true for RFC1918 private addresses
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSSameIPv4Address(A,B) ((A).NotAnInteger == (B).NotAnInteger)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSSameIPv6Address(A,B) ((A).l[0] == (B).l[0] && (A).l[1] == (B).l[1] && (A).l[2] == (B).l[2] && (A).l[3] == (B).l[3])
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSSameEthAddress(A,B) ((A)->w[0] == (B)->w[0] && (A)->w[1] == (B)->w[1] && (A)->w[2] == (B)->w[2])
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSIPv4AddressIsZero(A) mDNSSameIPv4Address((A), zerov4Addr)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSIPv6AddressIsZero(A) mDNSSameIPv6Address((A), zerov6Addr)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSIPv4AddressIsOnes(A) mDNSSameIPv4Address((A), onesIPv4Addr)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSIPv6AddressIsOnes(A) mDNSSameIPv6Address((A), onesIPv6Addr)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSAddressIsAllDNSLinkGroup(X) ( \
4b22b9337f359bfd063322244f5336cc7c6ffcfars ((X)->type == mDNSAddrType_IPv4 && mDNSSameIPv4Address((X)->ip.v4, AllDNSLinkGroupv4)) || \
4b22b9337f359bfd063322244f5336cc7c6ffcfars ((X)->type == mDNSAddrType_IPv6 && mDNSSameIPv6Address((X)->ip.v6, AllDNSLinkGroupv6)) )
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSAddressIsZero(X) ( \
4b22b9337f359bfd063322244f5336cc7c6ffcfars ((X)->type == mDNSAddrType_IPv4 && mDNSIPv4AddressIsZero((X)->ip.v4)) || \
4b22b9337f359bfd063322244f5336cc7c6ffcfars ((X)->type == mDNSAddrType_IPv6 && mDNSIPv6AddressIsZero((X)->ip.v6)) )
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSAddressIsValidNonZero(X) ( \
4b22b9337f359bfd063322244f5336cc7c6ffcfars ((X)->type == mDNSAddrType_IPv4 && !mDNSIPv4AddressIsZero((X)->ip.v4)) || \
4b22b9337f359bfd063322244f5336cc7c6ffcfars ((X)->type == mDNSAddrType_IPv6 && !mDNSIPv6AddressIsZero((X)->ip.v6)) )
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSAddressIsOnes(X) ( \
4b22b9337f359bfd063322244f5336cc7c6ffcfars ((X)->type == mDNSAddrType_IPv4 && mDNSIPv4AddressIsOnes((X)->ip.v4)) || \
4b22b9337f359bfd063322244f5336cc7c6ffcfars ((X)->type == mDNSAddrType_IPv6 && mDNSIPv6AddressIsOnes((X)->ip.v6)) )
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNSAddressIsValid(X) ( \
4b22b9337f359bfd063322244f5336cc7c6ffcfars ((X)->type == mDNSAddrType_IPv4) ? !(mDNSIPv4AddressIsZero((X)->ip.v4) || mDNSIPv4AddressIsOnes((X)->ip.v4)) : \
4b22b9337f359bfd063322244f5336cc7c6ffcfars ((X)->type == mDNSAddrType_IPv6) ? !(mDNSIPv6AddressIsZero((X)->ip.v6) || mDNSIPv6AddressIsOnes((X)->ip.v6)) : mDNSfalse)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - Authentication Support
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define HMAC_LEN 64
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define HMAC_IPAD 0x36
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define HMAC_OPAD 0x5c
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define MD5_LEN 16
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// padded keys for inned/outer hash rounds
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 ipad[HMAC_LEN];
4b22b9337f359bfd063322244f5336cc7c6ffcfars mDNSu8 opad[HMAC_LEN];
4b22b9337f359bfd063322244f5336cc7c6ffcfars } HMAC_Key;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Internal data structure to maintain authentication information for an update domain
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct uDNS_AuthInfo
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname zone;
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname keyname;
4b22b9337f359bfd063322244f5336cc7c6ffcfars HMAC_Key key;
4b22b9337f359bfd063322244f5336cc7c6ffcfars struct uDNS_AuthInfo *next;
4b22b9337f359bfd063322244f5336cc7c6ffcfars } uDNS_AuthInfo;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Unicast DNS and Dynamic Update specific Client Calls
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNS_SetSecretForZone tells the core to authenticate (via TSIG with an HMAC_MD5 hash of the shared secret)
4b22b9337f359bfd063322244f5336cc7c6ffcfars// when dynamically updating a given zone (and its subdomains). The key used in authentication must be in
4b22b9337f359bfd063322244f5336cc7c6ffcfars// domain name format. The shared secret must be a null-terminated base64 encoded string. A minimum size of
4b22b9337f359bfd063322244f5336cc7c6ffcfars// 16 bytes (128 bits) is recommended for an MD5 hash as per RFC 2485.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Calling this routine multiple times for a zone replaces previously entered values. Call with a NULL key
4b22b9337f359bfd063322244f5336cc7c6ffcfars// to dissable authentication for the zone.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_SetSecretForZone(mDNS *m, const domainname *zone, const domainname *key, const char *sharedSecret);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Hostname/Unicast Interface Configuration
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// All hostnames advertised point to one IPv4 address and/or one IPv6 address, set via SetPrimaryInterfaceInfo. Invoking this routine
4b22b9337f359bfd063322244f5336cc7c6ffcfars// updates all existing hostnames to point to the new address.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// A hostname is added via AddDynDNSHostName, which points to the primary interface's v4 and/or v6 addresss
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The status callback is invoked to convey success or failure codes - the callback should not modify the AuthRecord or free memory.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Added hostnames may be removed (deregistered) via mDNS_RemoveDynDNSHostName.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Host domains added prior to specification of the primary interface address and computer name will be deferred until
4b22b9337f359bfd063322244f5336cc7c6ffcfars// these values are initialized.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// When routable V4 interfaces are added or removed, mDNS_UpdateLLQs should be called to re-estabish LLQs in case the
4b22b9337f359bfd063322244f5336cc7c6ffcfars// destination address for events (i.e. the route) has changed. For performance reasons, the caller is responsible for
4b22b9337f359bfd063322244f5336cc7c6ffcfars// batching changes, e.g. calling the routine only once if multiple interfaces are simultanously removed or added.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// DNS servers used to resolve unicast queries are specified by mDNS_AddDNSServer, and may later be removed via mDNS_DeleteDNSServers.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// For "split" DNS configurations, in which queries for different domains are sent to different servers (e.g. VPN and external),
4b22b9337f359bfd063322244f5336cc7c6ffcfars// a domain may be associated with a DNS server. For standard configurations, specify the root label (".") or NULL.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNS_AddDynDNSHostName(mDNS *m, const domainname *fqdn, mDNSRecordCallback *StatusCallback, const void *StatusContext);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNS_RemoveDynDNSHostName(mDNS *m, const domainname *fqdn);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNS_SetPrimaryInterfaceInfo(mDNS *m, const mDNSAddr *v4addr, const mDNSAddr *v6addr, const mDNSAddr *router);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNS_UpdateLLQs(mDNS *m);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNS_AddDNSServer(mDNS *const m, const mDNSAddr *dnsAddr, const domainname *domain);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNS_DeleteDNSServers(mDNS *const m);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Routines called by the core, exported by DNSDigest.c
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Convert a base64 encoded key into a binary byte stream
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSs32 DNSDigest_Base64ToBin(const char *src, mDNSu8 *target, mDNSu32 targsize);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Convert an arbitrary binary key (of any length) into an HMAC key (stored in AuthInfo struct)
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void DNSDigest_ConstructHMACKey(uDNS_AuthInfo *info, const mDNSu8 *key, mDNSu32 len);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// sign a DNS message. The message must be compete, with all values in network byte order. end points to the end
4b22b9337f359bfd063322244f5336cc7c6ffcfars// of the message, and is modified by this routine. numAdditionals is a pointer to the number of additional
4b22b9337f359bfd063322244f5336cc7c6ffcfars// records in HOST byte order, which is incremented upon successful completion of this routine. The function returns
4b22b9337f359bfd063322244f5336cc7c6ffcfars// the new end pointer on success, and NULL on failure.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu8 *DNSDigest_SignMessage(DNSMessage *msg, mDNSu8 **end, mDNSu16 *numAdditionals, uDNS_AuthInfo *info);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - PlatformSupport interface
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// This section defines the interface to the Platform Support layer.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Normal client code should not use any of types defined here, or directly call any of the functions defined here.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The definitions are placed here because sometimes clients do use these calls indirectly, via other supported client operations.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// For example, AssignDomainName is a macro defined using mDNSPlatformMemCopy()
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Every platform support module must provide the following functions.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNSPlatformInit() typically opens a communication endpoint, and starts listening for mDNS packets.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// When Setup is complete, the platform support layer calls mDNSCoreInitComplete().
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNSPlatformSendUDP() sends one UDP packet
4b22b9337f359bfd063322244f5336cc7c6ffcfars// When a packet is received, the PlatformSupport code calls mDNSCoreReceive()
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNSPlatformClose() tidies up on exit
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Note: mDNSPlatformMemAllocate/mDNSPlatformMemFree are only required for handling oversized resource records and unicast DNS.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// If your target platform has a well-defined specialized application, and you know that all the records it uses
4b22b9337f359bfd063322244f5336cc7c6ffcfars// are InlineCacheRDSize or less, then you can just make a simple mDNSPlatformMemAllocate() stub that always returns
4b22b9337f359bfd063322244f5336cc7c6ffcfars// NULL. InlineCacheRDSize is a compile-time constant, which is set by default to 64. If you need to handle records
4b22b9337f359bfd063322244f5336cc7c6ffcfars// a little larger than this and you don't want to have to implement run-time allocation and freeing, then you
4b22b9337f359bfd063322244f5336cc7c6ffcfars// can raise the value of this constant to a suitable value (at the expense of increased memory usage).
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// USE CAUTION WHEN CALLING mDNSPlatformRawTime: The m->timenow_adjust correction factor needs to be added
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Generally speaking:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Code that's protected by the main mDNS lock should just use the m->timenow value
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Code outside the main mDNS lock should use mDNS_TimeNow(m) to get properly adjusted time
4b22b9337f359bfd063322244f5336cc7c6ffcfars// In certain cases there may be reasons why it's necessary to get the time without taking the lock first
4b22b9337f359bfd063322244f5336cc7c6ffcfars// (e.g. inside the routines that are doing the locking and unlocking, where a call to get the lock would result in a
4b22b9337f359bfd063322244f5336cc7c6ffcfars// recursive loop); in these cases use mDNS_TimeNow_NoLock(m) to get mDNSPlatformRawTime with the proper correction factor added.
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNSPlatformUTC returns the time, in seconds, since Jan 1st 1970 UTC and is required for generating TSIG records
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNSPlatformInit (mDNS *const m);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNSPlatformClose (mDNS *const m);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNSPlatformSendUDP(const mDNS *const m, const void *const msg, const mDNSu8 *const end,
4b22b9337f359bfd063322244f5336cc7c6ffcfarsmDNSInterfaceID InterfaceID, const mDNSAddr *dst, mDNSIPPort dstport);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNSPlatformLock (const mDNS *const m);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNSPlatformUnlock (const mDNS *const m);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNSPlatformStrCopy (const void *src, void *dst);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu32 mDNSPlatformStrLen (const void *src);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNSPlatformMemCopy (const void *src, void *dst, mDNSu32 len);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSBool mDNSPlatformMemSame (const void *src, const void *dst, mDNSu32 len);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNSPlatformMemZero ( void *dst, mDNSu32 len);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void * mDNSPlatformMemAllocate (mDNSu32 len);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNSPlatformMemFree (void *mem);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu32 mDNSPlatformRandomSeed (void);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNSPlatformTimeInit (void);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSs32 mDNSPlatformRawTime (void);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSs32 mDNSPlatformUTC (void);
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define mDNS_TimeNow_NoLock(m) (mDNSPlatformRawTime() + m->timenow_adjust)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Platform support modules should provide the following functions to map between opaque interface IDs
4b22b9337f359bfd063322244f5336cc7c6ffcfars// and interface indexes in order to support the DNS-SD API. If your target platform does not support
4b22b9337f359bfd063322244f5336cc7c6ffcfars// multiple interfaces and/or does not support the DNS-SD API, these functions can be empty.
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSInterfaceID mDNSPlatformInterfaceIDfromInterfaceIndex(mDNS *const m, mDNSu32 index);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSu32 mDNSPlatformInterfaceIndexfromInterfaceID(mDNS *const m, mDNSInterfaceID id);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Every platform support module must provide the following functions if it is to support unicast DNS
4b22b9337f359bfd063322244f5336cc7c6ffcfars// and Dynamic Update.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// All TCP socket operations implemented by the platform layer MUST NOT BLOCK.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNSPlatformTCPConnect initiates a TCP connection with a peer, adding the socket descriptor to the
4b22b9337f359bfd063322244f5336cc7c6ffcfars// main event loop. The return value indicates whether the connection succeeded, failed, or is pending
4b22b9337f359bfd063322244f5336cc7c6ffcfars// (i.e. the call would block.) On return, the descriptor parameter is set to point to the connected socket.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The TCPConnectionCallback is subsequently invoked when the connection
4b22b9337f359bfd063322244f5336cc7c6ffcfars// completes (in which case the ConnectionEstablished parameter is true), or data is available for
4b22b9337f359bfd063322244f5336cc7c6ffcfars// reading on the socket (indicated by the ConnectionEstablished parameter being false.) If the connection
4b22b9337f359bfd063322244f5336cc7c6ffcfars// asynchronously fails, the TCPConnectionCallback should be invoked as usual, with the error being
4b22b9337f359bfd063322244f5336cc7c6ffcfars// returned in subsequent calls to PlatformReadTCP or PlatformWriteTCP. (This allows for platforms
4b22b9337f359bfd063322244f5336cc7c6ffcfars// with limited asynchronous error detection capabilities.) PlatformReadTCP and PlatformWriteTCP must
4b22b9337f359bfd063322244f5336cc7c6ffcfars// return the number of bytes read/written, 0 if the call would block, and -1 if an error.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// PlatformTCPCloseConnection must close the connection to the peer and remove the descriptor from the
4b22b9337f359bfd063322244f5336cc7c6ffcfars// event loop. CloseConnectin may be called at any time, including in a ConnectionCallback.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef void (*TCPConnectionCallback)(int sd, void *context, mDNSBool ConnectionEstablished);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNSPlatformTCPConnect(const mDNSAddr *dst, mDNSOpaque16 dstport, mDNSInterfaceID InterfaceID,
4b22b9337f359bfd063322244f5336cc7c6ffcfars TCPConnectionCallback callback, void *context, int *descriptor);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNSPlatformTCPCloseConnection(int sd);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern int mDNSPlatformReadTCP(int sd, void *buf, int buflen);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern int mDNSPlatformWriteTCP(int sd, const char *msg, int len);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Platforms that support unicast browsing and dynamic update registration for clients who do not specify a domain
4b22b9337f359bfd063322244f5336cc7c6ffcfars// in browse/registration calls must implement these routines to get the "default" browse/registration list.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The Get() functions must return a linked list of DNameListElem structs, allocated via mDNSPlatformMemAllocate.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Platforms may implement the Get() calls via the mDNS_CopyDNameList() helper routine.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Callers should free lists obtained via the Get() calls with th mDNS_FreeDNameList routine, provided by the core.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct DNameListElem
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars domainname name;
4b22b9337f359bfd063322244f5336cc7c6ffcfars struct DNameListElem *next;
4b22b9337f359bfd063322244f5336cc7c6ffcfars } DNameListElem;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern DNameListElem *mDNSPlatformGetSearchDomainList(void);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern DNameListElem *mDNSPlatformGetRegDomainList(void);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Helper functions provided by the core
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern DNameListElem *mDNS_CopyDNameList(const DNameListElem *orig);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNS_FreeDNameList(DNameListElem *list);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifdef _LEGACY_NAT_TRAVERSAL_
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Support for legacy NAT traversal protocols, implemented by the platform layer and callable by the core.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define DYN_PORT_MIN 49152 // ephemeral port range
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define DYN_PORT_MAX 65535
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define LEGACY_NATMAP_MAX_TRIES 4 // if our desired mapping is taken, how many times we try mapping to a random port
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus LNT_GetPublicIP(mDNSOpaque32 *ip);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus LNT_MapPort(mDNSIPPort priv, mDNSIPPort pub, mDNSBool tcp);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus LNT_UnmapPort(mDNSIPPort PubPort, mDNSBool tcp);
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif // _LEGACY_NAT_TRAVERSAL_
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The core mDNS code provides these functions, for the platform support code to call at appropriate times
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNS_SetFQDN() is called once on startup (typically from mDNSPlatformInit())
4b22b9337f359bfd063322244f5336cc7c6ffcfars// and then again on each subsequent change of the host name.
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNS_RegisterInterface() is used by the platform support layer to inform mDNSCore of what
4b22b9337f359bfd063322244f5336cc7c6ffcfars// physical and/or logical interfaces are available for sending and receiving packets.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Typically it is called on startup for each available interface, but register/deregister may be
4b22b9337f359bfd063322244f5336cc7c6ffcfars// called again later, on multiple occasions, to inform the core of interface configuration changes.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// If set->Advertise is set non-zero, then mDNS_RegisterInterface() also registers the standard
4b22b9337f359bfd063322244f5336cc7c6ffcfars// resource records that should be associated with every publicised IP address/interface:
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- Name-to-address records (A/AAAA)
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- Address-to-name records (PTR)
4b22b9337f359bfd063322244f5336cc7c6ffcfars// -- Host information (HINFO)
4b22b9337f359bfd063322244f5336cc7c6ffcfars// IMPORTANT: The specified mDNSInterfaceID MUST NOT be 0, -1, or -2; these values have special meaning
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNS_RegisterInterface does not result in the registration of global hostnames via dynamic update -
4b22b9337f359bfd063322244f5336cc7c6ffcfars// see mDNS_SetPrimaryInterfaceInfo, mDNS_AddDynDNSHostName, etc. for this purpose.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Note that the set may be deallocated immediately after it is deregistered via mDNS_DeegisterInterface.
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNS_RegisterDNS() is used by the platform support layer to provide the core with the addresses of
4b22b9337f359bfd063322244f5336cc7c6ffcfars// available domain name servers for unicast queries/updates. RegisterDNS() should be called once for
4b22b9337f359bfd063322244f5336cc7c6ffcfars// each name server, typically at startup, or when a new name server becomes available. DeregiterDNS()
4b22b9337f359bfd063322244f5336cc7c6ffcfars// must be called whenever a registered name server becomes unavailable. DeregisterDNSList deregisters
4b22b9337f359bfd063322244f5336cc7c6ffcfars// all registered servers. mDNS_DNSRegistered() returns true if one or more servers are registered in the core.
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNSCoreInitComplete() is called when the platform support layer is finished.
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Typically this is at the end of mDNSPlatformInit(), but may be later
4b22b9337f359bfd063322244f5336cc7c6ffcfars// (on platforms like OT that allow asynchronous initialization of the networking stack).
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNSCoreReceive() is called when a UDP packet is received
4b22b9337f359bfd063322244f5336cc7c6ffcfars//
4b22b9337f359bfd063322244f5336cc7c6ffcfars// mDNSCoreMachineSleep() is called when the machine sleeps or wakes
4b22b9337f359bfd063322244f5336cc7c6ffcfars// (This refers to heavyweight laptop-style sleep/wake that disables network access,
4b22b9337f359bfd063322244f5336cc7c6ffcfars// not lightweight second-by-second CPU power management modes.)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNS_SetFQDN(mDNS *const m);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mStatus mDNS_RegisterInterface (mDNS *const m, NetworkInterfaceInfo *set, mDNSBool flapping);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNS_DeregisterInterface(mDNS *const m, NetworkInterfaceInfo *set, mDNSBool flapping);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNSCoreInitComplete(mDNS *const m, mStatus result);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNSCoreReceive(mDNS *const m, void *const msg, const mDNSu8 *const end,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const mDNSAddr *const srcaddr, const mDNSIPPort srcport,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const mDNSAddr *const dstaddr, const mDNSIPPort dstport, const mDNSInterfaceID InterfaceID);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern void mDNSCoreMachineSleep(mDNS *const m, mDNSBool wake);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern mDNSBool mDNSAddrIsDNSMulticast(const mDNSAddr *ip);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if 0
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma mark - Compile-Time assertion checks
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Some C compiler cleverness. We can make the compiler check certain things for
4b22b9337f359bfd063322244f5336cc7c6ffcfars// us, and report compile-time errors if anything is wrong. The usual way to do
4b22b9337f359bfd063322244f5336cc7c6ffcfars// this would be to use a run-time "if" statement, but then you don't find out
4b22b9337f359bfd063322244f5336cc7c6ffcfars// what's wrong until you run the software. This way, if the assertion condition
4b22b9337f359bfd063322244f5336cc7c6ffcfars// is false, the array size is negative, and the complier complains immediately.
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsstruct mDNS_CompileTimeAssertionChecks
4b22b9337f359bfd063322244f5336cc7c6ffcfars {
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Check that the compiler generated our on-the-wire packet format structure definitions
4b22b9337f359bfd063322244f5336cc7c6ffcfars // properly packed, without adding padding bytes to align fields on 32-bit or 64-bit boundaries.
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assert0[(sizeof(rdataSRV) == 262 ) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assert1[(sizeof(DNSMessageHeader) == 12 ) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assert2[(sizeof(DNSMessage) == 12+AbsoluteMaxDNSMessageData) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assert3[(sizeof(mDNSs8) == 1 ) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assert4[(sizeof(mDNSu8) == 1 ) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assert5[(sizeof(mDNSs16) == 2 ) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assert6[(sizeof(mDNSu16) == 2 ) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assert7[(sizeof(mDNSs32) == 4 ) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assert8[(sizeof(mDNSu32) == 4 ) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assert9[(sizeof(mDNSOpaque16) == 2 ) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assertA[(sizeof(mDNSOpaque32) == 4 ) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assertB[(sizeof(mDNSOpaque128) == 16 ) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assertC[(sizeof(CacheRecord ) >= sizeof(CacheGroup) ) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars char assertD[(sizeof(int) >= 4 ) ? 1 : -1];
4b22b9337f359bfd063322244f5336cc7c6ffcfars };
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars// ***************************************************************************
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifdef __cplusplus
4b22b9337f359bfd063322244f5336cc7c6ffcfars }
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif