1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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
15 * limitations under the License.
17 Change History (most recent first):
20 Revision 1.5 2007/03/20 17:07:16 cheshire
21 Rename "struct uDNS_TCPSocket_struct" to "TCPSocket", "struct uDNS_UDPSocket_struct" to "UDPSocket"
23 Revision 1.4 2006/12/22 20:59:51 cheshire
24 <rdar://problem/4742742> Read *all* DNS keys from keychain,
25 not just key for the system-wide default registration domain
27 Revision 1.3 2006/11/18 05:01:33 cheshire
28 Preliminary support for unifying the uDNS and mDNS code,
29 including caching of uDNS answers
31 Revision 1.2 2006/08/14 23:24:56 cheshire
32 Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
34 Revision 1.1 2006/07/06 00:09:05 cheshire
35 <rdar://problem/4472013> Add Private DNS server functionality to dnsextd
45 #include <mDNSEmbeddedAPI.h>
46 #include <DNSCommon.h>
47 #include <GenLinkedList.h>
48 #include <sys/types.h>
49 #include <sys/socket.h>
50 #include <netinet/in.h>
53 #define LLQ_TABLESIZE 1024 // !!!KRS make this dynamically growable
56 typedef enum DNSZoneSpecType
63 typedef struct DNSZone
67 DomainAuthInfo
* updateKeys
; // linked list of keys for signing deletion updates
68 DomainAuthInfo
* queryKeys
; // linked list of keys for queries
69 struct DNSZone
* next
;
75 struct sockaddr_in src
;
78 mDNSBool isZonePublic
;
80 // Note: extra storage for oversized (TCP) messages goes here
84 typedef struct RRTableElem
86 struct RRTableElem
*next
;
87 struct sockaddr_in cli
; // client's source address
88 long expire
; // expiration time, in seconds since epoch
89 domainname zone
; // from zone field of update message
90 domainname name
; // name of the record
91 CacheRecord rr
; // last field in struct allows for allocation of oversized RRs
101 typedef struct AnswerListElem
103 struct AnswerListElem
*next
;
106 CacheRecord
*KnownAnswers
; // All valid answers delivered to client
107 CacheRecord
*EventList
; // New answers (adds/removes) to be sent to client
109 mDNSBool UseTCP
; // Use TCP if UDP would cause truncation
110 pthread_t tid
; // Allow parallel list updates
114 typedef struct LLQEntry
116 struct LLQEntry
*next
;
117 struct sockaddr_in cli
; // clien'ts source address
122 mDNSu32 lease
; // original lease, in seconds
123 mDNSs32 expire
; // expiration, absolute, in seconds since epoch
124 AnswerListElem
*AnswerList
;
128 typedef void (*EventCallback
)( void * context
);
130 typedef struct EventSource
132 EventCallback callback
;
136 mDNSBool markedForDeletion
;
137 struct EventSource
* next
;
141 // daemon-wide information
144 // server variables - read only after initialization (no locking)
145 struct sockaddr_in addr
; // the address we will bind to
146 struct sockaddr_in llq_addr
; // the address we will receive llq requests on.
147 struct sockaddr_in ns_addr
; // the real ns server address
148 int tcpsd
; // listening TCP socket for dns requests
149 int udpsd
; // listening UDP socket for dns requests
150 int tlssd
; // listening TCP socket for private browsing
151 int llq_tcpsd
; // listening TCP socket for llq service
152 int llq_udpsd
; // listening UDP socket for llq service
153 DNameListElem
* public_names
; // list of public SRV names
156 // daemon variables - read only after initialization (no locking)
157 mDNSIPPort private_port
; // listening port for private messages
158 mDNSIPPort llq_port
; // listening port for llq
160 // lease table variables (locked via mutex after initialization)
161 RRTableElem
**table
; // hashtable for records with leases
162 pthread_mutex_t tablelock
; // mutex for lease table
163 mDNSs32 nbuckets
; // buckets allocated
164 mDNSs32 nelems
; // elements in table
166 // LLQ table variables
167 LLQEntry
*LLQTable
[LLQ_TABLESIZE
]; // !!!KRS change this and RRTable to use a common data structure
168 AnswerListElem
*AnswerTable
[LLQ_TABLESIZE
];
169 int AnswerTableCount
;
170 int LLQEventNotifySock
; // Unix domain socket pair - update handling thread writes to EventNotifySock, which wakes
171 int LLQEventListenSock
; // the main thread listening on EventListenSock, indicating that the zone has changed
173 GenLinkedList eventSources
; // linked list of EventSource's