]>
Commit | Line | Data |
---|---|---|
67c8f8a1 A |
1 | /* -*- Mode: C; tab-width: 4 -*- |
2 | * | |
19fa75a9 | 3 | * Copyright (c) 2002-2020 Apple Inc. All rights reserved. |
8e92c31c | 4 | * |
67c8f8a1 A |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | * you may not use this file except in compliance with the License. | |
7 | * You may obtain a copy of the License at | |
83fb1e36 | 8 | * |
67c8f8a1 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
83fb1e36 | 10 | * |
67c8f8a1 A |
11 | * Unless required by applicable law or agreed to in writing, software |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
8e92c31c | 15 | * limitations under the License. |
263eeeab | 16 | */ |
8e92c31c A |
17 | |
18 | #ifndef __DNSCOMMON_H_ | |
19 | #define __DNSCOMMON_H_ | |
20 | ||
7f0064bd | 21 | #include "mDNSEmbeddedAPI.h" |
8e92c31c | 22 | |
83fb1e36 A |
23 | #ifdef __cplusplus |
24 | extern "C" { | |
8e92c31c A |
25 | #endif |
26 | ||
5e65c77f A |
27 | //************************************************************************************************************* |
28 | // Macros | |
29 | ||
30 | // Note: The C preprocessor stringify operator ('#') makes a string from its argument, without macro expansion | |
31 | // e.g. If "version" is #define'd to be "4", then STRINGIFY_AWE(version) will return the string "version", not "4" | |
32 | // To expand "version" to its value before making the string, use STRINGIFY(version) instead | |
83fb1e36 | 33 | #define STRINGIFY_ARGUMENT_WITHOUT_EXPANSION(s) # s |
5e65c77f A |
34 | #define STRINGIFY(s) STRINGIFY_ARGUMENT_WITHOUT_EXPANSION(s) |
35 | ||
8e92c31c A |
36 | // *************************************************************************** |
37 | #if COMPILER_LIKES_PRAGMA_MARK | |
38 | #pragma mark - DNS Protocol Constants | |
39 | #endif | |
40 | ||
41 | typedef enum | |
83fb1e36 | 42 | { |
9f221bca A |
43 | kDNSFlag0_QR_Mask = 0x80, // Query or response? |
44 | kDNSFlag0_QR_Query = 0x00, | |
45 | kDNSFlag0_QR_Response = 0x80, | |
46 | ||
f0cc3e7b A |
47 | kDNSFlag0_OP_Mask = 0xF << 3, // Operation type |
48 | kDNSFlag0_OP_StdQuery = 0x0 << 3, | |
49 | kDNSFlag0_OP_Iquery = 0x1 << 3, | |
50 | kDNSFlag0_OP_Status = 0x2 << 3, | |
51 | kDNSFlag0_OP_Unused3 = 0x3 << 3, | |
52 | kDNSFlag0_OP_Notify = 0x4 << 3, | |
53 | kDNSFlag0_OP_Update = 0x5 << 3, | |
54 | kDNSFlag0_OP_DSO = 0x6 << 3, | |
83fb1e36 A |
55 | |
56 | kDNSFlag0_QROP_Mask = kDNSFlag0_QR_Mask | kDNSFlag0_OP_Mask, | |
57 | ||
58 | kDNSFlag0_AA = 0x04, // Authoritative Answer? | |
59 | kDNSFlag0_TC = 0x02, // Truncated? | |
60 | kDNSFlag0_RD = 0x01, // Recursion Desired? | |
61 | kDNSFlag1_RA = 0x80, // Recursion Available? | |
62 | ||
63 | kDNSFlag1_Zero = 0x40, // Reserved; must be zero | |
64 | kDNSFlag1_AD = 0x20, // Authentic Data [RFC 2535] | |
65 | kDNSFlag1_CD = 0x10, // Checking Disabled [RFC 2535] | |
66 | ||
67 | kDNSFlag1_RC_Mask = 0x0F, // Response code | |
68 | kDNSFlag1_RC_NoErr = 0x00, | |
69 | kDNSFlag1_RC_FormErr = 0x01, | |
70 | kDNSFlag1_RC_ServFail = 0x02, | |
71 | kDNSFlag1_RC_NXDomain = 0x03, | |
72 | kDNSFlag1_RC_NotImpl = 0x04, | |
73 | kDNSFlag1_RC_Refused = 0x05, | |
74 | kDNSFlag1_RC_YXDomain = 0x06, | |
75 | kDNSFlag1_RC_YXRRSet = 0x07, | |
76 | kDNSFlag1_RC_NXRRSet = 0x08, | |
77 | kDNSFlag1_RC_NotAuth = 0x09, | |
f0cc3e7b A |
78 | kDNSFlag1_RC_NotZone = 0x0A, |
79 | kDNSFlag1_RC_DSOTypeNI = 0x0B | |
83fb1e36 | 80 | } DNS_Flags; |
8e92c31c | 81 | |
7f0064bd | 82 | typedef enum |
83fb1e36 A |
83 | { |
84 | TSIG_ErrBadSig = 16, | |
85 | TSIG_ErrBadKey = 17, | |
86 | TSIG_ErrBadTime = 18 | |
87 | } TSIG_ErrorCode; | |
67c8f8a1 | 88 | |
9f221bca | 89 | |
8e92c31c A |
90 | // *************************************************************************** |
91 | #if COMPILER_LIKES_PRAGMA_MARK | |
92 | #pragma mark - | |
93 | #pragma mark - General Utility Functions | |
94 | #endif | |
95 | ||
32bb7e43 | 96 | extern NetworkInterfaceInfo *GetFirstActiveInterface(NetworkInterfaceInfo *intf); |
8e92c31c A |
97 | extern mDNSInterfaceID GetNextActiveInterfaceID(const NetworkInterfaceInfo *intf); |
98 | ||
83fb1e36 | 99 | extern mDNSu32 mDNSRandom(mDNSu32 max); // Returns pseudo-random result from zero to max inclusive |
8e92c31c | 100 | |
19fa75a9 | 101 | #if !MDNSRESPONDER_SUPPORTS(APPLE, QUERIER) |
672757b6 | 102 | extern mDNSu32 mDNS_GetNextResolverGroupID(void); |
19fa75a9 | 103 | #endif |
672757b6 | 104 | |
8e92c31c A |
105 | // *************************************************************************** |
106 | #if COMPILER_LIKES_PRAGMA_MARK | |
107 | #pragma mark - | |
108 | #pragma mark - Domain Name Utility Functions | |
109 | #endif | |
67c8f8a1 | 110 | |
51601d48 A |
111 | #define mDNSSubTypeLabel "\x04_sub" |
112 | ||
32bb7e43 | 113 | #define mDNSIsDigit(X) ((X) >= '0' && (X) <= '9') |
8e92c31c A |
114 | #define mDNSIsUpperCase(X) ((X) >= 'A' && (X) <= 'Z') |
115 | #define mDNSIsLowerCase(X) ((X) >= 'a' && (X) <= 'z') | |
32bb7e43 | 116 | #define mDNSIsLetter(X) (mDNSIsUpperCase(X) || mDNSIsLowerCase(X)) |
fc8aa221 A |
117 | |
118 | // We believe we have adequate safeguards to protect against cache poisoning. | |
119 | // In the event that someone does find a workable cache poisoning attack, we want to limit the lifetime of the poisoned entry. | |
120 | // We set the maximum allowable TTL to one hour. | |
121 | // With the 25% correction factor to avoid the DNS Zeno's paradox bug, that gives us an actual maximum lifetime of 75 minutes. | |
122 | ||
f0cc3e7b A |
123 | #define mDNSMaximumMulticastTTLSeconds (mDNSu32)4500 |
124 | #define mDNSMaximumUnicastTTLSeconds (mDNSu32)3600 | |
67c8f8a1 | 125 | |
32bb7e43 | 126 | #define mDNSValidHostChar(X, notfirst, notlast) (mDNSIsLetter(X) || mDNSIsDigit(X) || ((notfirst) && (notlast) && (X) == '-') ) |
8e92c31c A |
127 | |
128 | extern mDNSu16 CompressedDomainNameLength(const domainname *const name, const domainname *parent); | |
67c8f8a1 A |
129 | extern int CountLabels(const domainname *d); |
130 | extern const domainname *SkipLeadingLabels(const domainname *d, int skip); | |
8e92c31c | 131 | |
7cb34e5c | 132 | extern mDNSu32 TruncateUTF8ToLength(mDNSu8 *string, mDNSu32 length, mDNSu32 max); |
8e92c31c A |
133 | extern mDNSBool LabelContainsSuffix(const domainlabel *const name, const mDNSBool RichText); |
134 | extern mDNSu32 RemoveLabelSuffix(domainlabel *name, mDNSBool RichText); | |
263eeeab | 135 | extern void AppendLabelSuffix(domainlabel *const name, mDNSu32 val, const mDNSBool RichText); |
8e92c31c A |
136 | #define ValidateDomainName(N) (DomainNameLength(N) <= MAX_DOMAIN_NAME) |
137 | ||
8e92c31c A |
138 | // *************************************************************************** |
139 | #if COMPILER_LIKES_PRAGMA_MARK | |
140 | #pragma mark - | |
141 | #pragma mark - Resource Record Utility Functions | |
142 | #endif | |
143 | ||
030b743d A |
144 | // IdenticalResourceRecord returns true if two resources records have |
145 | // the same name, type, class, and identical rdata (InterfaceID and TTL may differ) | |
146 | ||
147 | // IdenticalSameNameRecord is the same, except it skips the expensive SameDomainName() check, | |
148 | // which is at its most expensive and least useful in cases where we know in advance that the names match | |
149 | ||
150 | // Note: The dominant use of IdenticalResourceRecord is from ProcessQuery(), handling known-answer lists. In this case | |
151 | // it's common to have a whole bunch or records with exactly the same name (e.g. "_http._tcp.local") but different RDATA. | |
152 | // The SameDomainName() check is expensive when the names match, and in this case *all* the names match, so we | |
153 | // used to waste a lot of CPU time verifying that the names match, only then to find that the RDATA is different. | |
154 | // We observed mDNSResponder spending 30% of its total CPU time on this single task alone. | |
155 | // By swapping the checks so that we check the RDATA first, we can quickly detect when it's different | |
156 | // (99% of the time) and then bail out before we waste time on the expensive SameDomainName() check. | |
157 | ||
158 | #define IdenticalResourceRecord(r1,r2) ( \ | |
83fb1e36 A |
159 | (r1)->rrtype == (r2)->rrtype && \ |
160 | (r1)->rrclass == (r2)->rrclass && \ | |
161 | (r1)->namehash == (r2)->namehash && \ | |
162 | (r1)->rdlength == (r2)->rdlength && \ | |
163 | (r1)->rdatahash == (r2)->rdatahash && \ | |
164 | SameRDataBody((r1), &(r2)->rdata->u, SameDomainName) && \ | |
165 | SameDomainName((r1)->name, (r2)->name)) | |
030b743d A |
166 | |
167 | #define IdenticalSameNameRecord(r1,r2) ( \ | |
83fb1e36 A |
168 | (r1)->rrtype == (r2)->rrtype && \ |
169 | (r1)->rrclass == (r2)->rrclass && \ | |
170 | (r1)->rdlength == (r2)->rdlength && \ | |
171 | (r1)->rdatahash == (r2)->rdatahash && \ | |
172 | SameRDataBody((r1), &(r2)->rdata->u, SameDomainName)) | |
030b743d | 173 | |
32bb7e43 A |
174 | // A given RRType answers a QuestionType if RRType is CNAME, or types match, or QuestionType is ANY, |
175 | // or the RRType is NSEC and positively asserts the nonexistence of the type being requested | |
263eeeab | 176 | #define RRTypeAnswersQuestionType(R,Q) ((R)->rrtype == kDNSType_CNAME || (R)->rrtype == (Q) || (Q) == kDNSQType_ANY || RRAssertsNonexistence((R),(Q))) |
83fb1e36 A |
177 | // Unicast NSEC records have the NSEC bit set whereas the multicast NSEC ones don't |
178 | #define UNICAST_NSEC(rr) ((rr)->rrtype == kDNSType_NSEC && RRAssertsExistence((rr), kDNSType_NSEC)) | |
32bb7e43 | 179 | |
030b743d | 180 | extern mDNSu32 RDataHashValue(const ResourceRecord *const rr); |
263eeeab | 181 | extern mDNSBool SameRDataBody(const ResourceRecord *const r1, const RDataBody *const r2, DomainNameComparisonFn *samename); |
f0cc3e7b | 182 | extern mDNSBool SameNameCacheRecordAnswersQuestion(const CacheRecord *const cr, const DNSQuestion *const q); |
32bb7e43 | 183 | extern mDNSBool ResourceRecordAnswersQuestion(const ResourceRecord *const rr, const DNSQuestion *const q); |
f0cc3e7b A |
184 | extern mDNSBool AuthRecordAnswersQuestion(const AuthRecord *const ar, const DNSQuestion *const q); |
185 | extern mDNSBool CacheRecordAnswersQuestion(const CacheRecord *const cr, const DNSQuestion *const q); | |
186 | extern mDNSBool AnyTypeRecordAnswersQuestion (const AuthRecord *const ar, const DNSQuestion *const q); | |
3c3ba2cc | 187 | extern mDNSBool ResourceRecordAnswersUnicastResponse(const ResourceRecord *const rr, const DNSQuestion *const q); |
294beb6e | 188 | extern mDNSBool LocalOnlyRecordAnswersQuestion(AuthRecord *const rr, const DNSQuestion *const q); |
8e92c31c | 189 | extern mDNSu16 GetRDLength(const ResourceRecord *const rr, mDNSBool estimate); |
67c8f8a1 | 190 | extern mDNSBool ValidateRData(const mDNSu16 rrtype, const mDNSu16 rdlength, const RData *const rd); |
51601d48 | 191 | extern mStatus DNSNameToLowerCase(domainname *d, domainname *result); |
8e92c31c A |
192 | |
193 | #define GetRRDomainNameTarget(RR) ( \ | |
83fb1e36 A |
194 | ((RR)->rrtype == kDNSType_NS || (RR)->rrtype == kDNSType_CNAME || (RR)->rrtype == kDNSType_PTR || (RR)->rrtype == kDNSType_DNAME) ? &(RR)->rdata->u.name : \ |
195 | ((RR)->rrtype == kDNSType_MX || (RR)->rrtype == kDNSType_AFSDB || (RR)->rrtype == kDNSType_RT || (RR)->rrtype == kDNSType_KX ) ? &(RR)->rdata->u.mx.exchange : \ | |
196 | ((RR)->rrtype == kDNSType_SRV ) ? &(RR)->rdata->u.srv.target : mDNSNULL ) | |
8e92c31c | 197 | |
263eeeab | 198 | #define LocalRecordReady(X) ((X)->resrec.RecordType != kDNSRecordTypeUnique) |
8e92c31c | 199 | |
8e92c31c A |
200 | // *************************************************************************** |
201 | #if COMPILER_LIKES_PRAGMA_MARK | |
202 | #pragma mark - | |
8e92c31c A |
203 | #pragma mark - DNS Message Creation Functions |
204 | #endif | |
205 | ||
206 | extern void InitializeDNSMessage(DNSMessageHeader *h, mDNSOpaque16 id, mDNSOpaque16 flags); | |
207 | extern const mDNSu8 *FindCompressionPointer(const mDNSu8 *const base, const mDNSu8 *const end, const mDNSu8 *const domname); | |
8e92c31c | 208 | extern mDNSu8 *putDomainNameAsLabels(const DNSMessage *const msg, mDNSu8 *ptr, const mDNSu8 *const limit, const domainname *const name); |
67c8f8a1 | 209 | extern mDNSu8 *putRData(const DNSMessage *const msg, mDNSu8 *ptr, const mDNSu8 *const limit, const ResourceRecord *const rr); |
8e92c31c | 210 | |
7f0064bd | 211 | // If we have a single large record to put in the packet, then we allow the packet to be up to 9K bytes, |
67c8f8a1 | 212 | // but in the normal case we try to keep the packets below 1500 to avoid IP fragmentation on standard Ethernet |
ca3eca6b A |
213 | |
214 | #define AllowedRRSpace(msg) (((msg)->h.numAnswers || (msg)->h.numAuthorities || (msg)->h.numAdditionals) ? NormalMaxDNSMessageData : AbsoluteMaxDNSMessageData) | |
215 | ||
19fa75a9 A |
216 | extern mDNSu8 *PutResourceRecordTTLWithLimit(DNSMessage *const msg, mDNSu8 *ptr, mDNSu16 *count, const ResourceRecord *rr, |
217 | mDNSu32 ttl, const mDNSu8 *limit); | |
32bb7e43 A |
218 | |
219 | #define PutResourceRecordTTL(msg, ptr, count, rr, ttl) \ | |
83fb1e36 | 220 | PutResourceRecordTTLWithLimit((msg), (ptr), (count), (rr), (ttl), (msg)->data + AllowedRRSpace(msg)) |
ca3eca6b | 221 | |
32bb7e43 | 222 | #define PutResourceRecordTTLJumbo(msg, ptr, count, rr, ttl) \ |
83fb1e36 | 223 | PutResourceRecordTTLWithLimit((msg), (ptr), (count), (rr), (ttl), (msg)->data + AbsoluteMaxDNSMessageData) |
ca3eca6b | 224 | |
32bb7e43 | 225 | #define PutResourceRecord(MSG, P, C, RR) PutResourceRecordTTL((MSG), (P), (C), (RR), (RR)->rroriginalttl) |
8e92c31c | 226 | |
ca3eca6b | 227 | // The PutRR_OS variants assume a local variable 'm', put build the packet at m->omsg, |
51601d48 | 228 | // and assume local variables 'OwnerRecordSpace' & 'TraceRecordSpace' indicating how many bytes (if any) to reserve to add an OWNER/TRACER option at the end |
ca3eca6b | 229 | #define PutRR_OS_TTL(ptr, count, rr, ttl) \ |
51601d48 | 230 | PutResourceRecordTTLWithLimit(&m->omsg, (ptr), (count), (rr), (ttl), m->omsg.data + AllowedRRSpace(&m->omsg) - OwnerRecordSpace - TraceRecordSpace) |
ca3eca6b A |
231 | |
232 | #define PutRR_OS(P, C, RR) PutRR_OS_TTL((P), (C), (RR), (RR)->rroriginalttl) | |
233 | ||
8e92c31c | 234 | extern mDNSu8 *putQuestion(DNSMessage *const msg, mDNSu8 *ptr, const mDNSu8 *const limit, const domainname *const name, mDNSu16 rrtype, mDNSu16 rrclass); |
7f0064bd | 235 | extern mDNSu8 *putZone(DNSMessage *const msg, mDNSu8 *ptr, mDNSu8 *limit, const domainname *zone, mDNSOpaque16 zoneClass); |
263eeeab | 236 | extern mDNSu8 *putPrereqNameNotInUse(const domainname *const name, DNSMessage *const msg, mDNSu8 *const ptr, mDNSu8 *const end); |
7f0064bd | 237 | extern mDNSu8 *putDeletionRecord(DNSMessage *msg, mDNSu8 *ptr, ResourceRecord *rr); |
263eeeab A |
238 | extern mDNSu8 *putDeletionRecordWithLimit(DNSMessage *msg, mDNSu8 *ptr, ResourceRecord *rr, mDNSu8 *limit); |
239 | extern mDNSu8 *putDeleteRRSetWithLimit(DNSMessage *msg, mDNSu8 *ptr, const domainname *name, mDNSu16 rrtype, mDNSu8 *limit); | |
7f0064bd | 240 | extern mDNSu8 *putDeleteAllRRSets(DNSMessage *msg, mDNSu8 *ptr, const domainname *name); |
9f221bca | 241 | extern mDNSu8 *putUpdateLease(DNSMessage *msg, mDNSu8 *ptr, mDNSu32 lease); |
263eeeab | 242 | extern mDNSu8 *putUpdateLeaseWithLimit(DNSMessage *msg, mDNSu8 *ptr, mDNSu32 lease, mDNSu8 *limit); |
8e92c31c | 243 | |
51601d48 A |
244 | extern int baseEncode(char *buffer, int blen, const mDNSu8 *data, int len, int encAlg); |
245 | extern void NSEC3Parse(const ResourceRecord *const rr, mDNSu8 **salt, int *hashLength, mDNSu8 **nxtName, int *bitmaplen, mDNSu8 **bitmap); | |
246 | ||
8e92c31c A |
247 | // *************************************************************************** |
248 | #if COMPILER_LIKES_PRAGMA_MARK | |
249 | #pragma mark - | |
250 | #pragma mark - DNS Message Parsing Functions | |
251 | #endif | |
252 | ||
12c5fa7a | 253 | #define HashSlotFromNameHash(X) ((X) % CACHE_HASH_SLOTS) |
8e92c31c | 254 | extern mDNSu32 DomainNameHashValue(const domainname *const name); |
8e92c31c | 255 | extern void SetNewRData(ResourceRecord *const rr, RData *NewRData, mDNSu16 rdlength); |
8e92c31c | 256 | extern const mDNSu8 *skipDomainName(const DNSMessage *const msg, const mDNSu8 *ptr, const mDNSu8 *const end); |
8e92c31c | 257 | extern const mDNSu8 *getDomainName(const DNSMessage *const msg, const mDNSu8 *ptr, const mDNSu8 *const end, |
83fb1e36 | 258 | domainname *const name); |
8e92c31c | 259 | extern const mDNSu8 *skipResourceRecord(const DNSMessage *msg, const mDNSu8 *ptr, const mDNSu8 *end); |
67c8f8a1 | 260 | extern const mDNSu8 *GetLargeResourceRecord(mDNS *const m, const DNSMessage * const msg, const mDNSu8 *ptr, |
83fb1e36 | 261 | const mDNSu8 * end, const mDNSInterfaceID InterfaceID, mDNSu8 RecordType, LargeCacheRecord *const largecr); |
19fa75a9 A |
262 | extern mDNSBool SetRData(const DNSMessage *const msg, const mDNSu8 *ptr, const mDNSu8 *end, ResourceRecord *rr, |
263 | mDNSu16 rdlength); | |
8e92c31c | 264 | extern const mDNSu8 *skipQuestion(const DNSMessage *msg, const mDNSu8 *ptr, const mDNSu8 *end); |
8e92c31c | 265 | extern const mDNSu8 *getQuestion(const DNSMessage *msg, const mDNSu8 *ptr, const mDNSu8 *end, const mDNSInterfaceID InterfaceID, |
83fb1e36 | 266 | DNSQuestion *question); |
8e92c31c | 267 | extern const mDNSu8 *LocateAnswers(const DNSMessage *const msg, const mDNSu8 *const end); |
8e92c31c | 268 | extern const mDNSu8 *LocateAuthorities(const DNSMessage *const msg, const mDNSu8 *const end); |
8e92c31c | 269 | extern const mDNSu8 *LocateAdditionals(const DNSMessage *const msg, const mDNSu8 *const end); |
32bb7e43 | 270 | extern const mDNSu8 *LocateOptRR(const DNSMessage *const msg, const mDNSu8 *const end, int minsize); |
67c8f8a1 | 271 | extern const rdataOPT *GetLLQOptData(mDNS *const m, const DNSMessage *const msg, const mDNSu8 *const end); |
12c5fa7a | 272 | extern mDNSBool GetPktLease(mDNS *const m, const DNSMessage *const msg, const mDNSu8 *const end, mDNSu32 *const lease); |
f0cc3e7b A |
273 | extern void DumpPacket(mStatus status, mDNSBool sent, const char *transport, const mDNSAddr *srcaddr, mDNSIPPort srcport, |
274 | const mDNSAddr *dstaddr, mDNSIPPort dstport, const DNSMessage *const msg, const mDNSu8 *const end, | |
275 | mDNSInterfaceID interfaceID); | |
83fb1e36 A |
276 | extern mDNSBool RRAssertsNonexistence(const ResourceRecord *const rr, mDNSu16 type); |
277 | extern mDNSBool RRAssertsExistence(const ResourceRecord *const rr, mDNSu16 type); | |
51601d48 | 278 | extern mDNSBool BitmapTypeCheck(mDNSu8 *bmap, int bitmaplen, mDNSu16 type); |
83fb1e36 A |
279 | |
280 | extern mDNSu16 swap16(mDNSu16 x); | |
281 | extern mDNSu32 swap32(mDNSu32 x); | |
8e92c31c | 282 | |
19fa75a9 A |
283 | extern mDNSBool GetReverseIPv6Addr(const domainname *inQName, mDNSu8 outIPv6[16]); |
284 | ||
8e92c31c A |
285 | // *************************************************************************** |
286 | #if COMPILER_LIKES_PRAGMA_MARK | |
287 | #pragma mark - | |
8e92c31c A |
288 | #pragma mark - Packet Sending Functions |
289 | #endif | |
67c8f8a1 | 290 | extern mStatus mDNSSendDNSMessage(mDNS *const m, DNSMessage *const msg, mDNSu8 *end, |
f0cc3e7b A |
291 | mDNSInterfaceID InterfaceID, TCPSocket *tcpSrc, UDPSocket *udpSrc, const mDNSAddr *dst, |
292 | mDNSIPPort dstport, DomainAuthInfo *authInfo, mDNSBool useBackgroundTrafficClass); | |
7f0064bd A |
293 | |
294 | // *************************************************************************** | |
295 | #if COMPILER_LIKES_PRAGMA_MARK | |
296 | #pragma mark - | |
297 | #pragma mark - RR List Management & Task Management | |
298 | #endif | |
299 | ||
32bb7e43 | 300 | extern void ShowTaskSchedulingError(mDNS *const m); |
263eeeab A |
301 | extern void mDNS_Lock_(mDNS *const m, const char * const functionname); |
302 | extern void mDNS_Unlock_(mDNS *const m, const char * const functionname); | |
f0cc3e7b | 303 | |
32bb7e43 A |
304 | #if defined(_WIN32) |
305 | #define __func__ __FUNCTION__ | |
306 | #endif | |
307 | ||
263eeeab | 308 | #define mDNS_Lock(X) mDNS_Lock_((X), __func__) |
67c8f8a1 | 309 | |
263eeeab | 310 | #define mDNS_Unlock(X) mDNS_Unlock_((X), __func__) |
67c8f8a1 | 311 | |
9f221bca A |
312 | #define mDNS_CheckLock(X) \ |
313 | if ((X)->mDNS_busy != (X)->mDNS_reentrancy+1) LogMsg("%s: Lock not held! mDNS_busy (%ld) mDNS_reentrancy (%ld)", __func__, (X)->mDNS_busy, (X)->mDNS_reentrancy) | |
83fb1e36 | 314 | |
67c8f8a1 | 315 | #define mDNS_DropLockBeforeCallback() do { m->mDNS_reentrancy++; \ |
9f221bca A |
316 | if (m->mDNS_busy != m->mDNS_reentrancy) LogMsg("%s: Locking Failure! mDNS_busy (%ld) != mDNS_reentrancy (%ld)", __func__, m->mDNS_busy, m->mDNS_reentrancy); \ |
317 | } while (0) | |
67c8f8a1 A |
318 | |
319 | #define mDNS_ReclaimLockAfterCallback() do { \ | |
9f221bca A |
320 | if (m->mDNS_busy != m->mDNS_reentrancy) LogMsg("%s: Unlocking Failure! mDNS_busy (%ld) != mDNS_reentrancy (%ld)", __func__, m->mDNS_busy, m->mDNS_reentrancy); \ |
321 | m->mDNS_reentrancy--; } while (0) | |
283ee3ff | 322 | |
83fb1e36 A |
323 | #ifdef __cplusplus |
324 | } | |
8e92c31c A |
325 | #endif |
326 | ||
327 | #endif // __DNSCOMMON_H_ |