xref: /illumos-gate/usr/src/contrib/mDNSResponder/mDNSShared/dns_sd_private.h (revision 8a2b682e57a046b828f37bcde1776f131ef4629f)
1 /* -*- Mode: C; tab-width: 4 -*-
2  *
3  * Copyright (c) 2015 Apple Inc. All rights reserved.
4  */
5 
6 #ifndef _DNS_SD_PRIVATE_H
7 #define _DNS_SD_PRIVATE_H
8 
9 
10 // Private flags (kDNSServiceFlagsPrivateOne, kDNSServiceFlagsPrivateTwo, kDNSServiceFlagsPrivateThree, kDNSServiceFlagsPrivateFour) from dns_sd.h
11 enum
12 {
13     kDNSServiceFlagsDenyCellular           = 0x8000000,
14     /*
15      * This flag is meaningful only for Unicast DNS queries. When set, the daemon will restrict
16      * DNS resolutions on the cellular interface for that request.
17      */
18     kDNSServiceFlagsServiceIndex           = 0x10000000,
19     /*
20      * This flag is meaningful only for DNSServiceGetAddrInfo() for Unicast DNS queries.
21      * When set, DNSServiceGetAddrInfo() will interpret the "interfaceIndex" argument of the call
22      * as the "serviceIndex".
23      */
24 
25     kDNSServiceFlagsDenyExpensive          = 0x20000000,
26     /*
27      * This flag is meaningful only for Unicast DNS queries. When set, the daemon will restrict
28      * DNS resolutions on interfaces defined as expensive for that request.
29      */
30 
31     kDNSServiceFlagsPathEvaluationDone     = 0x40000000
32     /*
33      * This flag is meaningful for only Unicast DNS queries.
34      * When set, it indicates that Network PathEvaluation has already been performed.
35      */
36 };
37 
38 
39 #if !DNSSD_NO_CREATE_DELEGATE_CONNECTION
40 /* DNSServiceCreateDelegateConnection()
41  *
42  * Parameters:
43  *
44  * sdRef:           A pointer to an uninitialized DNSServiceRef. Deallocating
45  *                  the reference (via DNSServiceRefDeallocate()) severs the
46  *                  connection and deregisters all records registered on this connection.
47  *
48  * pid :            Process ID of the delegate
49  *
50  * uuid:            UUID of the delegate
51  *
52  *                  Note that only one of the two arguments (pid or uuid) can be specified. If pid
53  *                  is zero, uuid will be assumed to be a valid value; otherwise pid will be used.
54  *
55  * return value:    Returns kDNSServiceErr_NoError on success, otherwise returns
56  *                  an error code indicating the specific failure that occurred (in which
57  *                  case the DNSServiceRef is not initialized). kDNSServiceErr_NotAuth is
58  *                  returned to indicate that the calling process does not have entitlements
59  *                  to use this API.
60  */
61 DNSServiceErrorType DNSSD_API DNSServiceCreateDelegateConnection(DNSServiceRef *sdRef, int32_t pid, uuid_t uuid);
62 #endif
63 
64 // Map the source port of the local UDP socket that was opened for sending the DNS query
65 // to the process ID of the application that triggered the DNS resolution.
66 //
67 /* DNSServiceGetPID() Parameters:
68  *
69  * srcport:         Source port (in network byte order) of the UDP socket that was created by
70  *                  the daemon to send the DNS query on the wire.
71  *
72  * pid:             Process ID of the application that started the name resolution which triggered
73  *                  the daemon to send the query on the wire. The value can be -1 if the srcport
74  *                  cannot be mapped.
75  *
76  * return value:    Returns kDNSServiceErr_NoError on success, or kDNSServiceErr_ServiceNotRunning
77  *                  if the daemon is not running. The value of the pid is undefined if the return
78  *                  value has error.
79  */
80 DNSServiceErrorType DNSSD_API DNSServiceGetPID
81 (
82     uint16_t srcport,
83     int32_t *pid
84 );
85 
86 #define kDNSServiceCompPrivateDNS   "PrivateDNS"
87 #define kDNSServiceCompMulticastDNS "MulticastDNS"
88 
89 #endif
90