]> git.saurik.com Git - apple/mdnsresponder.git/blame - mDNSCore/uDNS.h
mDNSResponder-576.30.4.tar.gz
[apple/mdnsresponder.git] / mDNSCore / uDNS.h
CommitLineData
67c8f8a1
A
1/* -*- Mode: C; tab-width: 4 -*-
2 *
51601d48 3 * Copyright (c) 2002-2013 Apple Computer, 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 __UDNS_H_
19#define __UDNS_H_
20
7f0064bd 21#include "mDNSEmbeddedAPI.h"
8e92c31c
A
22#include "DNSCommon.h"
23
83fb1e36
A
24#ifdef __cplusplus
25extern "C" {
8e92c31c
A
26#endif
27
7cb34e5c 28#define RESTART_GOODBYE_DELAY (6 * mDNSPlatformOneSecond) // delay after restarting LLQ before nuking previous known answers (avoids flutter if we restart before we have networking up)
7cb34e5c 29#define INIT_UCAST_POLL_INTERVAL (3 * mDNSPlatformOneSecond) // this interval is used after send failures on network transitions
83fb1e36 30 // which typically heal quickly, so we start agressively and exponentially back off
283ee3ff 31#define MAX_UCAST_POLL_INTERVAL (60 * 60 * mDNSPlatformOneSecond)
67c8f8a1 32//#define MAX_UCAST_POLL_INTERVAL (1 * 60 * mDNSPlatformOneSecond)
05292456 33#define LLQ_POLL_INTERVAL (15 * 60 * mDNSPlatformOneSecond) // Polling interval for zones w/ an advertised LLQ port (ie not static zones) if LLQ fails due to NAT, etc.
7cb34e5c 34#define RESPONSE_WINDOW (60 * mDNSPlatformOneSecond) // require server responses within one minute of request
51601d48
A
35#define MAX_DNSSEC_UNANSWERED_QUERIES 1 // number of unanswered queries from any one uDNS server before turning off DNSSEC Validation
36#define MAX_UCAST_UNANSWERED_QUERIES 2 // number of unanswered queries from any one uDNS server before trying another server
37#define DNSSERVER_PENALTY_TIME (60 * mDNSPlatformOneSecond) // number of seconds for which new questions don't pick this server
67c8f8a1 38
4a95efb2
A
39// On some interfaces, we want to delay the first retransmission to a minimum of 2 seconds
40// rather than the default (1 second).
41#define MIN_UCAST_RETRANS_TIMEOUT (2 * mDNSPlatformOneSecond)
42
283ee3ff 43#define DEFAULT_UPDATE_LEASE 7200
67c8f8a1
A
44
45#define QuestionIntervalStep 3
46#define QuestionIntervalStep2 (QuestionIntervalStep*QuestionIntervalStep)
47#define QuestionIntervalStep3 (QuestionIntervalStep*QuestionIntervalStep*QuestionIntervalStep)
48#define InitialQuestionInterval ((mDNSPlatformOneSecond + QuestionIntervalStep-1) / QuestionIntervalStep)
51601d48
A
49#define MaxQuestionInterval (3600 * mDNSPlatformOneSecond)
50
51// just move to MaxQuestionInterval once over this threshold
52#define QuestionIntervalThreshold (QuestionIntervalStep3 * mDNSPlatformOneSecond)
67c8f8a1 53
263eeeab
A
54// For Unicast record registrations, we initialize the interval to 1 second. When we send any query for
55// the record registration e.g., GetZoneData, we always back off by QuestionIntervalStep
56// so that the first retry does not happen until 3 seconds which should be enough for TCP/TLS to be done.
57#define INIT_RECORD_REG_INTERVAL (1 * mDNSPlatformOneSecond)
83fb1e36
A
58#define MAX_RECORD_REG_INTERVAL (15 * 60 * mDNSPlatformOneSecond)
59#define MERGE_DELAY_TIME (1 * mDNSPlatformOneSecond)
263eeeab 60
83fb1e36 61// If we are refreshing, we do it at least 5 times with a min update frequency of
263eeeab 62// 5 minutes
83fb1e36
A
63#define MAX_UPDATE_REFRESH_COUNT 5
64#define MIN_UPDATE_REFRESH_TIME (5 * 60 * mDNSPlatformOneSecond)
294beb6e
A
65
66// For questions that use kDNSServiceFlagsTimeout and we don't have a matching resolver e.g., no dns servers,
67// then use the default value of 30 seconds
83fb1e36
A
68#define DEFAULT_UDNS_TIMEOUT 30 // in seconds
69
70// For questions that are validating responses (q->ValidatingResponse == 1), use 10 seconds
71// which accomodates two DNS servers and two queries per DNS server.
72#define DEFAULT_UDNSSEC_TIMEOUT 10 // in seconds
294beb6e 73
51601d48
A
74// If we are sending queries with EDNS0/DO option and we have no indications that the server
75// is DNSSEC aware and we have already reached MAX_DNSSEC_RETRANSMISSIONS, we disable
76// validation (for optional case only) for any questions that uses this server
77#define MAX_DNSSEC_RETRANSMISSIONS 3
78
8e92c31c
A
79// Entry points into unicast-specific routines
80
96f69b28
A
81extern void LLQGotZoneData(mDNS *const m, mStatus err, const ZoneData *zoneInfo);
82extern void startLLQHandshake(mDNS *m, DNSQuestion *q);
030b743d 83extern void sendLLQRefresh(mDNS *m, DNSQuestion *q);
67c8f8a1 84
96f69b28
A
85extern void SleepRecordRegistrations(mDNS *m);
86
7f0064bd
A
87// uDNS_UpdateRecord
88// following fields must be set, and the update validated, upon entry.
89// rr->NewRData
90// rr->newrdlength
91// rr->UpdateCallback
92
7f0064bd 93extern mStatus uDNS_UpdateRecord(mDNS *m, AuthRecord *rr);
67c8f8a1
A
94
95extern void SetNextQueryTime(mDNS *const m, const DNSQuestion *const q);
67c8f8a1 96extern mStatus mDNS_Register_internal(mDNS *const m, AuthRecord *const rr);
67c8f8a1
A
97extern mStatus mDNS_Deregister_internal(mDNS *const m, AuthRecord *const rr, mDNS_Dereg_type drt);
98extern mStatus mDNS_StartQuery_internal(mDNS *const m, DNSQuestion *const question);
99extern mStatus mDNS_StopQuery_internal(mDNS *const m, DNSQuestion *const question);
100extern mStatus mDNS_StartNATOperation_internal(mDNS *const m, NATTraversalInfo *traversal);
101
96f69b28 102extern void RecordRegistrationGotZoneData(mDNS *const m, mStatus err, const ZoneData *zoneData);
8e92c31c 103extern mStatus uDNS_DeregisterRecord(mDNS *const m, AuthRecord *const rr);
32bb7e43 104extern const domainname *GetServiceTarget(mDNS *m, AuthRecord *const rr);
67c8f8a1
A
105extern void uDNS_CheckCurrentQuestion(mDNS *const m);
106
8e92c31c
A
107// integer fields of msg header must be in HOST byte order before calling this routine
108extern void uDNS_ReceiveMsg(mDNS *const m, DNSMessage *const msg, const mDNSu8 *const end,
83fb1e36 109 const mDNSAddr *const srcaddr, const mDNSIPPort srcport);
8e92c31c 110
263eeeab
A
111extern void uDNS_Tasks(mDNS *const m);
112extern void UpdateAllSRVRecords(mDNS *m);
113extern void CheckNATMappings(mDNS *m);
8e92c31c 114
67c8f8a1 115extern mStatus uDNS_SetupDNSConfig(mDNS *const m);
3c427d54 116
51601d48
A
117// uDNS_SetupWABQueries reads search domains from the platform layer and starts the Wide Area Bonjour
118// (WAB) domain enumeration queries if necessary.
3c427d54 119
51601d48
A
120#define UDNS_WAB_BROWSE_QUERY 0x00000001 // Browse queries (b, db)
121#define UDNS_WAB_LBROWSE_QUERY 0x00000002 // Browse queries (lb)
122#define UDNS_WAB_REG_QUERY 0x00000004 // Registration queries (r and dr)
3c427d54 123
51601d48
A
124extern void uDNS_SetupWABQueries(mDNS *const m);
125extern void uDNS_StartWABQueries(mDNS *const m, int queryType);
126extern void uDNS_StopWABQueries(mDNS *const m, int queryType);
294beb6e 127extern domainname *uDNS_GetNextSearchDomain(mDNS *const m, mDNSInterfaceID InterfaceID, mDNSs8 *searchIndex, mDNSBool ignoreDotLocal);
67c8f8a1
A
128
129typedef enum
83fb1e36
A
130{
131 uDNS_LLQ_Not = 0, // Normal uDNS answer: Flush any stale records from cache, and respect record TTL
132 uDNS_LLQ_Ignore, // LLQ initial challenge packet: ignore -- has no useful records for us
133 uDNS_LLQ_Entire, // LLQ initial set of answers: Flush any stale records from cache, but assume TTL is 2 x LLQ refresh interval
134 uDNS_LLQ_Events // LLQ event packet: don't flush cache; assume TTL is 2 x LLQ refresh interval
135} uDNS_LLQType;
67c8f8a1 136
263eeeab 137extern uDNS_LLQType uDNS_recvLLQResponse(mDNS *const m, const DNSMessage *const msg, const mDNSu8 *const end, const mDNSAddr *const srcaddr, const mDNSIPPort srcport, DNSQuestion **matchQuestion);
67c8f8a1 138extern DomainAuthInfo *GetAuthInfoForName_internal(mDNS *m, const domainname *const name);
96f69b28 139extern DomainAuthInfo *GetAuthInfoForQuestion(mDNS *m, const DNSQuestion *const q);
67c8f8a1
A
140extern void DisposeTCPConn(struct tcpInfo_t *tcp);
141
142// NAT traversal
51601d48 143extern void uDNS_ReceiveNATPacket(mDNS *m, const mDNSInterfaceID InterfaceID, mDNSu8 *pkt, mDNSu16 len); // Called for each received PCP or NAT-PMP packet
83fb1e36 144extern void natTraversalHandleAddressReply(mDNS *const m, mDNSu16 err, mDNSv4Addr ExtAddr);
51601d48 145extern void natTraversalHandlePortMapReply(mDNS *const m, NATTraversalInfo *n, const mDNSInterfaceID InterfaceID, mDNSu16 err, mDNSIPPort extport, mDNSu32 lease, NATTProtocol protocol);
67c8f8a1 146
83fb1e36
A
147#ifdef __cplusplus
148}
8e92c31c
A
149#endif
150
151#endif // __UDNS_H_