1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2012 Apple Inc. All rights reserved.
6 * @header Interface to DNSX SPI
8 * @discussion Describes the functions and data structures
9 * that make up the DNSX SPI
12 #ifndef _DNS_SERVICES_H
13 #define _DNS_SERVICES_H
15 #include <dispatch/dispatch.h>
17 // DNSXConnRef: Opaque internal data type
18 typedef struct _DNSXConnRef_t
*DNSXConnRef
;
23 kDNSX_UnknownErr
= -65537, /* 0xFFFE FFFF */
25 kDNSX_BadParam
= -65540,
26 kDNSX_DaemonNotRunning
= -65563, /* Background daemon not running */
27 kDNSX_DictError
= -65565, /* Dictionary Error */
28 kDNSX_Engaged
= -65566, /* DNS Proxy is in use by another client */
29 kDNSX_Timeout
= -65568
32 // A max of 5 input interfaces can be processed at one time
34 #define IfIndex uint64_t
35 #define kDNSIfindexAny 0
37 // Enable DNS Proxy with an appropriate parameter defined below
41 // Other values reserved for future use
44 /*********************************************************************************************
46 * Enable DNS Proxy Functionality
48 *********************************************************************************************/
50 /* DNSXEnableProxy : Turns ON the DNS Proxy (Details below)
52 * DNSXEnableProxyReply() parameters:
54 * connRef: The DNSXConnRef initialized by DNSXEnableProxy().
56 * errCode: Will be kDNSX_NoError on success, otherwise will indicate the
57 * failure that occurred. Other parameters are undefined if
62 typedef void (*DNSXEnableProxyReply
)
70 * Enables the DNS Proxy functionality which will remain ON until the client terminates explictly (or exits/crashes).
71 * Client can turn it OFF by passing the returned DNSXConnRef to DNSXRefDeAlloc()
73 * DNSXEnableProxy() Parameters:
75 * connRef: A pointer to DNSXConnRef that is initialized to NULL when called for the first
76 * time. If the call succeeds it will be initialized to a non-NULL value.
77 * Client terminates the DNS Proxy by passing this DNSXConnRef to DNSXRefDeAlloc().
79 * proxyparam: Enable DNS Proxy functionality with parameters that are described in
80 * DNSProxyParameters above.
82 * inIfindexArr[MaxInputIf]: List of input interfaces from which the DNS queries will be accepted and
83 * forwarded to the output interface specified below. The daemon processes
84 * MaxInputIf entries in the list. For eg. if one has less than MaxInputIfs
85 * values, just initialize the other values to be 0. Note: This field needs to
86 * be initialized by the client.
88 * outIfindex: Output interface on which the query will be forwarded.
89 * Passing kDNSIfindexAny causes DNS Queries to be sent on the primary interface.
91 * clientq: Queue the client wants to schedule the callBack on (Note: Must not be NULL)
93 * callBack: CallBack function for the client that indicates success or failure.
94 * Note: callback may be invoked more than once, For eg. if enabling DNS Proxy
95 * first succeeds and the daemon possibly crashes sometime later.
97 * return value: Returns kDNSX_NoError when no error otherwise returns an error code indicating
98 * the error that occurred. Note: A return value of kDNSX_NoError does not mean
99 * that DNS Proxy was successfully enabled. The callBack may asynchronously
100 * return an error (such as kDNSX_DaemonNotRunning/ kDNSX_Engaged)
104 DNSXErrorType DNSXEnableProxy
106 DNSXConnRef
*connRef
,
107 DNSProxyParameters proxyparam
,
108 IfIndex inIfindexArr
[MaxInputIf
],
110 dispatch_queue_t clientq
,
111 DNSXEnableProxyReply callBack
116 * Terminate a connection with the daemon and free memory associated with the DNSXConnRef.
117 * Used to Disable DNS Proxy on that connection.
119 * connRef: A DNSXConnRef initialized by any of the DNSX*() calls.
122 void DNSXRefDeAlloc(DNSXConnRef connRef
);
124 #endif /* _DNS_SERVICES_H */