Home | History | Annotate | Line # | Download | only in mDNSShared
      1 /*
      2  * Copyright (c) 2018-2024 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  *     https://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 #if MDNSRESPONDER_SUPPORTS(APPLE, AUDIT_TOKEN)
     24     #include <mdns/audit_token.h>
     25 #endif
     26 
     27 typedef void (*QueryRecordResultHandler)(mDNS *const m, DNSQuestion *question, const ResourceRecord *const answer,
     28     mDNSBool expired, QC_result AddRecord, DNSServiceErrorType error, void *context);
     29 
     30 typedef struct
     31 {
     32     DNSQuestion                 q;                      // DNSQuestion for record query.
     33     domainname *                qname;                  // Name of the original record.
     34     mDNSInterfaceID             interfaceID;            // Interface over which to perform query.
     35     QueryRecordResultHandler    resultHandler;          // Handler for query record operation results.
     36     void *                      resultContext;          // Context to pass to result handler.
     37     mDNSu32                     reqID;                  // Client request ID.
     38     int                         searchListIndex;        // Index that indicates the next search domain to try.
     39     int                         searchListIndexLast;    // Value of searchListIndex prior to calling NextSearchDomain().
     40 #if MDNSRESPONDER_SUPPORTS(APPLE, UNICAST_DOTLOCAL)
     41     DNSQuestion *               q2;                     // DNSQuestion for unicast version of a record with a dot-local name.
     42     mDNSu16                     q2Type;                 // q2's original qtype value.
     43     mDNSBool                    q2LongLived;            // q2's original LongLived value.
     44     mDNSBool                    q2ReturnIntermed;       // q2's original ReturnIntermed value.
     45     mDNSBool                    q2TimeoutQuestion;      // q2's original TimeoutQuestion value.
     46     mDNSBool                    q2AppendSearchDomains;  // q2's original AppendSearchDomains value.
     47 #endif
     48 #if MDNSRESPONDER_SUPPORTS(APPLE, REACHABILITY_TRIGGER)
     49     mDNSBool                    answered;               // True if the query was answered.
     50 #endif
     51     mDNSBool                    useAAAAFallback;        // If a AAAA question gets a negative answer, it's restarted as an A.
     52     mDNSBool                    gotExpiredCNAME;        // True is an expired CNAME record was encountered.
     53 #if MDNSRESPONDER_SUPPORTS(APPLE, QUERIER)
     54     mDNSu16                     qtype;                  // Original QTYPE.
     55     mDNSBool                    useFailover;            // Use DNS service failover if applicable.
     56     mDNSBool                    failoverMode;           // Use DNS service failover immediately.
     57     mDNSBool                    prohibitEncryptedDNS;   // Prohibit use of encrypted DNS protocols.
     58     mDNSBool                    overrideDNSService;     // True if resolver UUID overrides DNS service selection.
     59     mDNSu8                      resolverUUID[UUID_SIZE];// Resolver UUID to use with original QNAME.
     60 #endif
     61 #if MDNSRESPONDER_SUPPORTS(APPLE, AUDIT_TOKEN)
     62     mdns_audit_token_t          peerToken;
     63     mdns_audit_token_t          delegatorToken;
     64 #endif
     65 
     66 }   QueryRecordOp;
     67 
     68 typedef struct
     69 {
     70     mDNSInterfaceID     interfaceID;    // InterfaceID being used for query record operations.
     71     mDNSu32             protocols;      // Protocols (IPv4, IPv6) specified by client.
     72     QueryRecordOp *     op4;            // Query record operation object for A record.
     73     QueryRecordOp *     op6;            // Query record operation object for AAAA record.
     74 
     75 }   GetAddrInfoClientRequest;
     76 mdns_compile_time_max_size_check(GetAddrInfoClientRequest, 32);
     77 
     78 typedef struct
     79 {
     80     QueryRecordOp       op; // Query record operation object.
     81 
     82 }   QueryRecordClientRequest;
     83 mdns_compile_time_max_size_check(QueryRecordClientRequest, 816);
     84 
     85 typedef struct
     86 {
     87     mDNSu32                 requestID;
     88     const char *            hostnameStr;
     89     mDNSu32                 interfaceIndex;
     90     DNSServiceFlags         flags;
     91     mDNSu32                 protocols;
     92     mDNSs32                 effectivePID;
     93     const mDNSu8 *          effectiveUUID;
     94     mDNSu32                 peerUID;
     95 #if MDNSRESPONDER_SUPPORTS(APPLE, QUERIER)
     96     const mDNSu8 *          resolverUUID;
     97     mdns_dns_service_id_t   customID;
     98     mDNSBool                needEncryption;
     99     mDNSBool                useFailover;
    100     mDNSBool                failoverMode;
    101     mDNSBool                prohibitEncryptedDNS;
    102 #endif
    103 #if MDNSRESPONDER_SUPPORTS(APPLE, AUDIT_TOKEN)
    104     mdns_audit_token_t      peerToken;
    105     mdns_audit_token_t      delegatorToken;
    106     mDNSBool                isInAppBrowserRequest;
    107 #endif
    108 #if MDNSRESPONDER_SUPPORTS(APPLE, LOG_PRIVACY_LEVEL)
    109     dnssd_log_privacy_level_t logPrivacyLevel;
    110 #endif
    111     mDNSBool                persistWhenARecordsUnusable;
    112 
    113 }   GetAddrInfoClientRequestParams;
    114 
    115 typedef struct
    116 {
    117     mDNSu32                 requestID;
    118     const char *            qnameStr;
    119     mDNSu32                 interfaceIndex;
    120     DNSServiceFlags         flags;
    121     mDNSu16                 qtype;
    122     mDNSu16                 qclass;
    123     mDNSs32                 effectivePID;
    124     const mDNSu8 *          effectiveUUID;
    125     mDNSu32                 peerUID;
    126 #if MDNSRESPONDER_SUPPORTS(APPLE, QUERIER)
    127     const mDNSu8 *          resolverUUID;
    128 	mdns_dns_service_id_t	customID;
    129     mDNSBool                needEncryption;
    130     mDNSBool                useFailover;
    131     mDNSBool                failoverMode;
    132     mDNSBool                prohibitEncryptedDNS;
    133     mDNSBool                overrideDNSService;
    134 #endif
    135 #if MDNSRESPONDER_SUPPORTS(APPLE, AUDIT_TOKEN)
    136     mdns_audit_token_t      peerToken;
    137     mdns_audit_token_t      delegatorToken;
    138     mDNSBool                isInAppBrowserRequest;
    139 #endif
    140     mDNSBool                useAAAAFallback;
    141 #if MDNSRESPONDER_SUPPORTS(APPLE, LOG_PRIVACY_LEVEL)
    142     dnssd_log_privacy_level_t logPrivacyLevel;
    143 #endif
    144 
    145 }   QueryRecordClientRequestParams;
    146 
    147 #ifdef __cplusplus
    148 extern "C" {
    149 #endif
    150 
    151 mDNSexport void GetAddrInfoClientRequestParamsInit(GetAddrInfoClientRequestParams *inParams);
    152 mDNSexport mStatus GetAddrInfoClientRequestStart(GetAddrInfoClientRequest *inRequest,
    153     const GetAddrInfoClientRequestParams *inParams, QueryRecordResultHandler inResultHandler, void *inResultContext);
    154 mDNSexport void GetAddrInfoClientRequestStop(GetAddrInfoClientRequest *inRequest);
    155 mDNSexport const domainname * GetAddrInfoClientRequestGetQName(const GetAddrInfoClientRequest *inRequest);
    156 mDNSexport mDNSBool GetAddrInfoClientRequestIsMulticast(const GetAddrInfoClientRequest *inRequest);
    157 
    158 mDNSexport void QueryRecordClientRequestParamsInit(QueryRecordClientRequestParams *inParams);
    159 mDNSexport mStatus QueryRecordClientRequestStart(QueryRecordClientRequest *inRequest,
    160     const QueryRecordClientRequestParams *inParams, QueryRecordResultHandler inResultHandler, void *inResultContext);
    161 mDNSexport void QueryRecordClientRequestStop(QueryRecordClientRequest *inRequest);
    162 mDNSexport const domainname * QueryRecordClientRequestGetQName(const QueryRecordClientRequest *inRequest);
    163 mDNSexport mDNSu16 QueryRecordClientRequestGetType(const QueryRecordClientRequest *inRequest);
    164 mDNSexport mDNSBool QueryRecordClientRequestIsMulticast(QueryRecordClientRequest *inRequest);
    165 #if MDNSRESPONDER_SUPPORTS(APPLE, POWERLOG_MDNS_REQUESTS)
    166 mDNSexport mDNSBool ClientRequestUsesAWDL(uint32_t ifindex, DNSServiceFlags flags);
    167 #endif
    168 
    169 #ifdef __cplusplus
    170 }
    171 #endif
    172 
    173 #endif  // __ClientRequests_h
    174