]> git.saurik.com Git - apple/mdnsresponder.git/blame - mDNSShared/dnsextd.h
mDNSResponder-379.27.tar.gz
[apple/mdnsresponder.git] / mDNSShared / dnsextd.h
CommitLineData
67c8f8a1
A
1/* -*- Mode: C; tab-width: 4 -*-
2 *
3 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
4 *
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
15 * limitations under the License.
67c8f8a1
A
16 */
17
18
19#ifndef _dnsextd_h
20#define _dnsextd_h
21
22
23#include <mDNSEmbeddedAPI.h>
24#include <DNSCommon.h>
25#include <GenLinkedList.h>
26#include <sys/types.h>
27#include <sys/socket.h>
28#include <netinet/in.h>
29
30
83fb1e36 31#define LLQ_TABLESIZE 1024 // !!!KRS make this dynamically growable
67c8f8a1
A
32
33
34typedef enum DNSZoneSpecType
35{
83fb1e36
A
36 kDNSZonePublic,
37 kDNSZonePrivate
67c8f8a1
A
38} DNSZoneSpecType;
39
40
41typedef struct DNSZone
42{
83fb1e36
A
43 domainname name;
44 DNSZoneSpecType type;
45 DomainAuthInfo * updateKeys; // linked list of keys for signing deletion updates
46 DomainAuthInfo * queryKeys; // linked list of keys for queries
47 struct DNSZone * next;
67c8f8a1 48} DNSZone;
83fb1e36
A
49
50
67c8f8a1 51typedef struct
83fb1e36 52{
67c8f8a1
A
53 struct sockaddr_in src;
54 size_t len;
83fb1e36
A
55 DNSZone * zone;
56 mDNSBool isZonePublic;
67c8f8a1
A
57 DNSMessage msg;
58 // Note: extra storage for oversized (TCP) messages goes here
83fb1e36 59} PktMsg;
67c8f8a1
A
60
61// lease table entry
62typedef struct RRTableElem
83fb1e36 63{
67c8f8a1
A
64 struct RRTableElem *next;
65 struct sockaddr_in cli; // client's source address
66 long expire; // expiration time, in seconds since epoch
67 domainname zone; // from zone field of update message
68 domainname name; // name of the record
69 CacheRecord rr; // last field in struct allows for allocation of oversized RRs
83fb1e36 70} RRTableElem;
67c8f8a1
A
71
72typedef enum
83fb1e36
A
73{
74 RequestReceived = 0,
75 ChallengeSent = 1,
76 Established = 2
77} LLQState;
67c8f8a1
A
78
79typedef struct AnswerListElem
83fb1e36 80{
67c8f8a1
A
81 struct AnswerListElem *next;
82 domainname name;
83 mDNSu16 type;
84 CacheRecord *KnownAnswers; // All valid answers delivered to client
85 CacheRecord *EventList; // New answers (adds/removes) to be sent to client
86 int refcount;
87 mDNSBool UseTCP; // Use TCP if UDP would cause truncation
88 pthread_t tid; // Allow parallel list updates
83fb1e36 89} AnswerListElem;
67c8f8a1
A
90
91// llq table entry
92typedef struct LLQEntry
83fb1e36
A
93{
94 struct LLQEntry *next;
95 struct sockaddr_in cli; // clien'ts source address
67c8f8a1
A
96 domainname qname;
97 mDNSu16 qtype;
98 mDNSOpaque64 id;
99 LLQState state;
100 mDNSu32 lease; // original lease, in seconds
101 mDNSs32 expire; // expiration, absolute, in seconds since epoch
102 AnswerListElem *AnswerList;
83fb1e36 103} LLQEntry;
67c8f8a1
A
104
105
83fb1e36 106typedef void (*EventCallback)( void * context );
67c8f8a1
A
107
108typedef struct EventSource
83fb1e36
A
109{
110 EventCallback callback;
111 void * context;
112 TCPSocket * sock;
113 int fd;
114 mDNSBool markedForDeletion;
115 struct EventSource * next;
116} EventSource;
67c8f8a1
A
117
118
119// daemon-wide information
83fb1e36
A
120typedef struct
121{
67c8f8a1 122 // server variables - read only after initialization (no locking)
83fb1e36
A
123 struct sockaddr_in addr; // the address we will bind to
124 struct sockaddr_in llq_addr; // the address we will receive llq requests on.
125 struct sockaddr_in ns_addr; // the real ns server address
126 int tcpsd; // listening TCP socket for dns requests
127 int udpsd; // listening UDP socket for dns requests
128 int tlssd; // listening TCP socket for private browsing
129 int llq_tcpsd; // listening TCP socket for llq service
130 int llq_udpsd; // listening UDP socket for llq service
131 DNameListElem * public_names; // list of public SRV names
132 DNSZone * zones;
67c8f8a1
A
133
134 // daemon variables - read only after initialization (no locking)
135 mDNSIPPort private_port; // listening port for private messages
136 mDNSIPPort llq_port; // listening port for llq
137
138 // lease table variables (locked via mutex after initialization)
139 RRTableElem **table; // hashtable for records with leases
140 pthread_mutex_t tablelock; // mutex for lease table
141 mDNSs32 nbuckets; // buckets allocated
142 mDNSs32 nelems; // elements in table
143
144 // LLQ table variables
145 LLQEntry *LLQTable[LLQ_TABLESIZE]; // !!!KRS change this and RRTable to use a common data structure
146 AnswerListElem *AnswerTable[LLQ_TABLESIZE];
147 int AnswerTableCount;
148 int LLQEventNotifySock; // Unix domain socket pair - update handling thread writes to EventNotifySock, which wakes
149 int LLQEventListenSock; // the main thread listening on EventListenSock, indicating that the zone has changed
150
83fb1e36
A
151 GenLinkedList eventSources; // linked list of EventSource's
152} DaemonInfo;
67c8f8a1
A
153
154
155int
156ParseConfig
83fb1e36
A
157(
158 DaemonInfo * d,
159 const char * file
160);
67c8f8a1
A
161
162
163#endif