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