xref: /illumos-gate/usr/src/contrib/mDNSResponder/mDNSShared/ClientRequests.h (revision 472cd20d26008f77084ade4c2048159b98c2b705)
1 /*
2  * Copyright (c) 2018-2019 Apple Inc. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __ClientRequests_h
18 #define __ClientRequests_h
19 
20 #include "mDNSEmbeddedAPI.h"
21 #include "dns_sd_internal.h"
22 
23 typedef void (*QueryRecordResultHandler)(mDNS *const m, DNSQuestion *question, const ResourceRecord *const answer, QC_result AddRecord,
24     DNSServiceErrorType error, void *context);
25 
26 typedef struct
27 {
28     DNSQuestion                 q;                      // DNSQuestion for record query.
29     domainname *                qname;                  // Name of the original record.
30     mDNSInterfaceID             interfaceID;            // Interface over which to perform query.
31     QueryRecordResultHandler    resultHandler;          // Handler for query record operation results.
32     void *                      resultContext;          // Context to pass to result handler.
33     mDNSu32                     reqID;                  //
34     int                         searchListIndex;        // Index that indicates the next search domain to try.
35 #if MDNSRESPONDER_SUPPORTS(APPLE, UNICAST_DOTLOCAL)
36     DNSQuestion *               q2;                     // DNSQuestion for unicast version of a record with a dot-local name.
37     mDNSu16                     q2Type;                 // q2's original qtype value.
38     mDNSBool                    q2LongLived;            // q2's original LongLived value.
39     mDNSBool                    q2ReturnIntermed;       // q2's original ReturnIntermed value.
40     mDNSBool                    q2TimeoutQuestion;      // q2's original TimeoutQuestion value.
41     mDNSBool                    q2AppendSearchDomains;  // q2's original AppendSearchDomains value.
42 #endif
43 #if MDNSRESPONDER_SUPPORTS(APPLE, REACHABILITY_TRIGGER)
44     mDNSBool                    answered;               // True if the query was answered.
45 #endif
46 
47 }   QueryRecordOp;
48 
49 typedef struct
50 {
51     mDNSInterfaceID     interfaceID;    // InterfaceID being used for query record operations.
52     mDNSu32             protocols;      // Protocols (IPv4, IPv6) specified by client.
53     QueryRecordOp *     op4;            // Query record operation object for A record.
54     QueryRecordOp *     op6;            // Query record operation object for AAAA record.
55 
56 }   GetAddrInfoClientRequest;
57 
58 typedef struct
59 {
60     QueryRecordOp       op; // Query record operation object.
61 
62 }   QueryRecordClientRequest;
63 
64 typedef struct
65 {
66     mDNSu32                 requestID;
67     const char *            hostnameStr;
68     mDNSu32                 interfaceIndex;
69     DNSServiceFlags         flags;
70     mDNSu32                 protocols;
71     mDNSs32                 effectivePID;
72     const mDNSu8 *          effectiveUUID;
73     mDNSu32                 peerUID;
74 #if MDNSRESPONDER_SUPPORTS(APPLE, QUERIER)
75     mDNSBool                needEncryption;
76     const mDNSu8 *          resolverUUID;
77     mdns_dns_service_id_t   customID;
78 #endif
79 #if MDNSRESPONDER_SUPPORTS(APPLE, AUDIT_TOKEN)
80     const audit_token_t *   peerAuditToken;
81     const audit_token_t *   delegatorAuditToken;
82     mDNSBool                isInAppBrowserRequest;
83 #endif
84 
85 }   GetAddrInfoClientRequestParams;
86 
87 typedef struct
88 {
89     mDNSu32                 requestID;
90     const char *            qnameStr;
91     mDNSu32                 interfaceIndex;
92     DNSServiceFlags         flags;
93     mDNSu16                 qtype;
94     mDNSu16                 qclass;
95     mDNSs32                 effectivePID;
96     const mDNSu8 *          effectiveUUID;
97     mDNSu32                 peerUID;
98 #if MDNSRESPONDER_SUPPORTS(APPLE, QUERIER)
99     mDNSBool                needEncryption;
100     const mDNSu8 *          resolverUUID;
101 	mdns_dns_service_id_t	customID;
102 #endif
103 #if MDNSRESPONDER_SUPPORTS(APPLE, AUDIT_TOKEN)
104     const audit_token_t *   peerAuditToken;
105     const audit_token_t *   delegatorAuditToken;
106     mDNSBool                isInAppBrowserRequest;
107 #endif
108 
109 }   QueryRecordClientRequestParams;
110 
111 #ifdef __cplusplus
112 extern "C" {
113 #endif
114 
115 mDNSexport void GetAddrInfoClientRequestParamsInit(GetAddrInfoClientRequestParams *inParams);
116 mDNSexport mStatus GetAddrInfoClientRequestStart(GetAddrInfoClientRequest *inRequest,
117     const GetAddrInfoClientRequestParams *inParams, QueryRecordResultHandler inResultHandler, void *inResultContext);
118 mDNSexport void GetAddrInfoClientRequestStop(GetAddrInfoClientRequest *inRequest);
119 mDNSexport const domainname * GetAddrInfoClientRequestGetQName(const GetAddrInfoClientRequest *inRequest);
120 mDNSexport mDNSBool GetAddrInfoClientRequestIsMulticast(const GetAddrInfoClientRequest *inRequest);
121 
122 mDNSexport void QueryRecordClientRequestParamsInit(QueryRecordClientRequestParams *inParams);
123 mDNSexport mStatus QueryRecordClientRequestStart(QueryRecordClientRequest *inRequest,
124     const QueryRecordClientRequestParams *inParams, QueryRecordResultHandler inResultHandler, void *inResultContext);
125 mDNSexport void QueryRecordClientRequestStop(QueryRecordClientRequest *inRequest);
126 mDNSexport const domainname * QueryRecordClientRequestGetQName(const QueryRecordClientRequest *inRequest);
127 mDNSexport mDNSu16 QueryRecordClientRequestGetType(const QueryRecordClientRequest *inRequest);
128 mDNSexport mDNSBool QueryRecordClientRequestIsMulticast(QueryRecordClientRequest *inRequest);
129 
130 #if MDNSRESPONDER_SUPPORTS(APPLE, DNSSECv2)
131 // This is a "mDNSexport" wrapper around the "static" QueryRecordOpStart that cannot be called by outside, which can be
132 // called by the outside(dnssec related function).
133 mDNSexport mStatus QueryRecordOpStartForClientRequest(
134     QueryRecordOp *             inOp,
135     mDNSu32                     inReqID,
136     const domainname *          inQName,
137     mDNSu16                     inQType,
138     mDNSu16                     inQClass,
139     mDNSInterfaceID             inInterfaceID,
140     mDNSs32                     inServiceID,
141     mDNSu32                     inFlags,
142     mDNSBool                    inAppendSearchDomains,
143     mDNSs32                     inPID,
144     const mDNSu8                inUUID[UUID_SIZE],
145     mDNSu32                     inUID,
146 #if MDNSRESPONDER_SUPPORTS(APPLE, AUDIT_TOKEN)
147     const audit_token_t *       inPeerAuditTokenPtr,
148     const audit_token_t *       inDelegateAuditTokenPtr,
149 #endif
150 #if MDNSRESPONDER_SUPPORTS(APPLE, QUERIER)
151     const mDNSu8                inResolverUUID[UUID_SIZE],
152     mDNSBool                    inNeedEncryption,
153     const mdns_dns_service_id_t inCustomID,
154 #endif
155     QueryRecordResultHandler    inResultHandler,
156     void *                      inResultContext);
157 
158 mDNSexport void QueryRecordOpStopForClientRequest(QueryRecordOp *op);
159 #endif // MDNSRESPONDER_SUPPORTS(APPLE, DNSSECv2)
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 #endif  // __ClientRequests_h
166